fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / external / rhino / rhino1_5R5.patch
blobe44872e3df8fcb911622efda76e4a3f687257bc3
1 --- misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Thu Mar 25 21:54:34 2004
2 +++ misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Fri Mar 28 17:24:23 2008
3 @@ -38,6 +38,7 @@
4 package org.mozilla.javascript;
6 import java.lang.reflect.Method;
7 +import java.lang.reflect.InvocationTargetException;
9 /**
10 * Load generated classes.
11 @@ -48,11 +49,34 @@
12 implements GeneratedClassLoader
14 public DefiningClassLoader() {
15 - this.parentLoader = getClass().getClassLoader();
16 + init(getClass().getClassLoader());
19 public DefiningClassLoader(ClassLoader parentLoader) {
21 + init(parentLoader);
22 + }
24 + private void init(ClassLoader parentLoader) {
26 this.parentLoader = parentLoader;
28 + this.contextLoader = null;
29 + if (method_getContextClassLoader != null) {
30 + try {
31 + this.contextLoader = (ClassLoader)
32 + method_getContextClassLoader.invoke(
33 + Thread.currentThread(),
34 + ScriptRuntime.emptyArgs);
35 + } catch (IllegalAccessException ex) {
36 + } catch (InvocationTargetException ex) {
37 + } catch (SecurityException ex) {
38 + }
39 + if (this.contextLoader == this.parentLoader) {
40 + this.contextLoader = null;
41 + }
42 + }
46 public Class defineClass(String name, byte[] data) {
47 @@ -68,10 +92,20 @@
49 Class cl = findLoadedClass(name);
50 if (cl == null) {
51 - if (parentLoader != null) {
52 - cl = parentLoader.loadClass(name);
53 + // First try parent class loader and if that does not work, try
54 + // contextLoader, but that will be null if
55 + // Thread.getContextClassLoader() == parentLoader
56 + // or on JDK 1.1 due to lack Thread.getContextClassLoader().
57 + // To avoid catching and rethrowing ClassNotFoundException
58 + // in this cases, use try/catch check only if contextLoader != null.
59 + if (contextLoader == null) {
60 + cl = loadFromParent(name);
61 } else {
62 - cl = findSystemClass(name);
63 + try {
64 + cl = loadFromParent(name);
65 + } catch (ClassNotFoundException ex) {
66 + cl = contextLoader.loadClass(name);
67 + }
70 if (resolve) {
71 @@ -80,5 +114,37 @@
72 return cl;
75 + private Class loadFromParent(String name)
76 + throws ClassNotFoundException
77 + {
78 + if (parentLoader != null) {
79 + return parentLoader.loadClass(name);
80 + } else {
81 + return findSystemClass(name);
82 + }
84 + }
86 private ClassLoader parentLoader;
88 + private ClassLoader contextLoader;
90 + // We'd like to use "Thread.getContextClassLoader", but
91 + // that's only available on Java2.
92 + private static Method method_getContextClassLoader;
94 + static {
95 + try {
96 + // Don't use "Thread.class": that performs the lookup
97 + // in the class initializer, which doesn't allow us to
98 + // catch possible security exceptions.
99 + Class threadClass = Class.forName("java.lang.Thread");
100 + method_getContextClassLoader =
101 + threadClass.getDeclaredMethod("getContextClassLoader",
102 + new Class[0]);
103 + } catch (ClassNotFoundException e) {
104 + } catch (NoSuchMethodException e) {
105 + } catch (SecurityException e) {
109 --- misc/rhino1_5R5/toolsrc/build.xml 2004-03-25 21:54:34.000000000 +0100
110 +++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-01-17 20:46:44.000000000 +0100
111 @@ -6,6 +6,28 @@
113 <project name="toolsrc" default="compile" basedir=".">
115 + <condition property="boot_refID" value="macPath" else="nonMacPath">
116 + <and>
117 + <os family="mac"/>
118 + <os family="unix"/>
119 + <or>
120 + <equals arg1="${ant.java.version}" arg2="1.5"/>
121 + <equals arg1="${ant.java.version}" arg2="1.6"/>
122 + </or>
123 + </and>
124 + </condition>
125 + <path id="macPath" location="${java.home}/../Classes/classes.jar"/>
126 + <!-- rhino.jar from OpenJDK breaks build -->
127 + <path id="nonMacPath">
128 + <fileset dir="${java.home}/">
129 + <include name="jre/lib/*.jar"/>
130 + <include name="lib/*.jar"/>
131 + <exclude name="jre/lib/rhino.jar"/>
132 + <exclude name="lib/rhino.jar"/>
133 + </fileset>
134 + </path>
135 + <path id="my.bootstrap.classpath" refID="${boot_refID}"/>
137 <target name="properties">
138 <property name="nest" value=".."/>
139 <property name="build.dir" value="./build"/>
140 @@ -20,46 +42,10 @@
141 <!-- Download source from Sun's site, unzip it, remove
142 the files we don't need, and change the package
144 - <get src="http://java.sun.com/products/jfc/tsc/articles/treetable2/downloads/src.zip" dest="${nest}/${build.dir}/swingExSrc.zip"/>
145 - <unzip src="${nest}/${build.dir}/swingExSrc.zip" dest="${src.debugger}"/>
146 + <unzip src="../../../../../download/swingExSrc.zip" dest="${src.debugger}"/>
147 <delete file="${src.debugger}/FileSystemModel2.java" />
148 <delete file="${src.debugger}/MergeSort.java" />
149 <delete file="${src.debugger}/TreeTableExample2.java" />
150 - <replace file="${src.debugger}/AbstractCellEditor.java">
151 - <replacetoken>import java.awt.Component;</replacetoken>
152 - <replacevalue>
153 - package org.mozilla.javascript.tools.debugger;
154 - import java.awt.Component;
155 - </replacevalue>
156 - </replace>
157 - <replace file="${src.debugger}/AbstractTreeTableModel.java">
158 - <replacetoken>import javax.swing.tree.*;</replacetoken>
159 - <replacevalue>
160 - package org.mozilla.javascript.tools.debugger;
161 - import javax.swing.tree.*;
162 - </replacevalue>
163 - </replace>
164 - <replace file="${src.debugger}/JTreeTable.java">
165 - <replacetoken>import javax.swing.*;</replacetoken>
166 - <replacevalue>
167 - package org.mozilla.javascript.tools.debugger;
168 - import javax.swing.*;
169 - </replacevalue>
170 - </replace>
171 - <replace file="${src.debugger}/TreeTableModel.java">
172 - <replacetoken>import javax.swing.tree.TreeModel;</replacetoken>
173 - <replacevalue>
174 - package org.mozilla.javascript.tools.debugger;
175 - import javax.swing.tree.TreeModel;
176 - </replacevalue>
177 - </replace>
178 - <replace file="${src.debugger}/TreeTableModelAdapter.java">
179 - <replacetoken>import javax.swing.JTree;</replacetoken>
180 - <replacevalue>
181 - package org.mozilla.javascript.tools.debugger;
182 - import javax.swing.JTree;
183 - </replacevalue>
184 - </replace>
185 </target>
187 <target name="compile" depends="properties,get-swing-ex">
188 @@ -68,6 +54,7 @@
189 includes="org/**/*.java"
190 deprecation="on"
191 debug="${debug}">
192 + <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
193 </javac>
194 <copy todir="${nest}/${classes}">
195 <fileset dir="." includes="org/**/*.properties" />
196 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2004-03-25 21:54:34.000000000 +0100
197 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2009-01-17 20:44:22.000000000 +0100
198 @@ -470,15 +470,21 @@
199 case KeyEvent.VK_BACK_SPACE:
200 case KeyEvent.VK_ENTER:
201 case KeyEvent.VK_DELETE:
202 + if (w.isEditable() == false) {
203 e.consume();
205 break;
208 public void keyTyped(KeyEvent e) {
209 + if (w.isEditable() == false) {
210 e.consume();
213 public void keyReleased(KeyEvent e) {
214 + if (w.isEditable() == false) {
215 e.consume();
220 @@ -879,7 +885,7 @@
224 -class FileWindow extends JInternalFrame implements ActionListener {
225 +class FileWindow extends JInternalFrame implements ActionListener, DocumentListener {
227 Main db;
228 SourceInfo sourceInfo;
229 @@ -888,15 +894,16 @@
230 JScrollPane p;
231 int currentPos;
232 JLabel statusBar;
233 + boolean isModified = false;
235 public void actionPerformed(ActionEvent e) {
236 String cmd = e.getActionCommand();
237 if (cmd.equals("Cut")) {
238 - // textArea.cut();
239 + textArea.cut();
240 } else if (cmd.equals("Copy")) {
241 textArea.copy();
242 } else if (cmd.equals("Paste")) {
243 - // textArea.paste();
244 + textArea.paste();
248 @@ -910,17 +917,73 @@
251 void load() {
252 - Scriptable scope = db.getScope();
253 + //Scriptable scope = db.getScope();
254 + Scriptable scope = db.officeScripts.getScriptScope( getUrl() );
255 + if ( scope == null )
257 + scope = db.getScope();
259 if (scope == null) {
260 MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
261 } else {
262 String url = getUrl();
263 if (url != null) {
264 - new Thread(new LoadFile(db,scope,url)).start();
265 + new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start();
270 + void save() {
271 + if (getUrl() != null) {
272 + OutputStream os = null;
273 + try {
274 + if ( getUrl().startsWith("vnd.sun.star") )
276 + URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() );
277 + if ( scriptUrl == null )
279 + throw new IOException("Can't optain stream for " + getUrl() );
281 + os = scriptUrl.openConnection().getOutputStream();
283 + else
285 + os = new FileOutputStream( getUrl() );
287 + String s = textArea.getText();
288 + os.write(s.getBytes(), 0, s.length());
290 + this.isModified = false;
292 + catch (IOException ioe) {
293 + JOptionPane.showMessageDialog(this,
294 + "Error saving file: " + ioe.getMessage(),
295 + "Error", JOptionPane.ERROR_MESSAGE);
297 + finally
299 + if ( os != null )
301 + try
303 + os.close();
304 + os = null;
306 + catch( IOException ioe )
308 + System.err.println("Error closing stream: " + ioe.getMessage() );
309 + ioe.printStackTrace();
316 + public boolean isEditable() {
317 + return db.isSourceEditingEnabled();
321 public int getPosition(int line) {
322 int result = -1;
323 try {
324 @@ -953,7 +1016,7 @@
325 fileHeader.repaint();
329 + public Main getDB() { return db; }
330 FileWindow(Main db, SourceInfo sourceInfo) {
331 super(SourceInfo.getShortName(sourceInfo.getUrl()),
332 true, true, true, true);
333 @@ -972,6 +1035,14 @@
334 pack();
335 updateText();
336 textArea.select(0);
337 + addInternalFrameListener( new InternalFrameAdapter() {
338 + public void internalFrameClosed(InternalFrameEvent e) {
339 + // clean up scriptItems and sourceNames hashes
340 + getDB().removeScript( getUrl() );
341 + // remove scripts for officeScripts
342 + getDB().officeScripts.deleteScript( getUrl() );
344 + } );
347 private void updateToolTip() {
348 @@ -990,7 +1061,10 @@
349 void updateText() {
350 String newText = sourceInfo.getSource();
351 if (!textArea.getText().equals(newText)) {
352 + textArea.getDocument().removeDocumentListener(this);
353 textArea.setText(newText);
354 + this.isModified = false;
355 + textArea.getDocument().addDocumentListener(this);
356 int pos = 0;
357 if (currentPos != -1) {
358 pos = currentPos;
359 @@ -1001,6 +1075,31 @@
360 fileHeader.repaint();
363 + /* Implementation of DocumentListener interface */
364 + public void insertUpdate(DocumentEvent e) {
365 + doChanged(e);
368 + public void removeUpdate(DocumentEvent e) {
369 + doChanged(e);
372 + public void changedUpdate(DocumentEvent e) {
373 + doChanged(e);
376 + public void doChanged(DocumentEvent e) {
377 + this.isModified = true;
380 + public boolean isModified() {
381 + return this.isModified;
384 + public String getText() {
385 + return textArea.getText();
388 void setPosition(int pos) {
389 textArea.select(pos);
390 currentPos = pos;
391 @@ -1618,7 +1717,7 @@
392 if (line != -1) {
393 db.currentWindow = w;
395 - db.menubar.addFile(url);
396 + // db.menubar.addFile(url);
397 w.setVisible(true);
398 if (activate) {
399 try {
400 @@ -1752,8 +1851,10 @@
401 Menubar(Main db) {
402 super();
403 this.db = db;
404 - String[] fileItems = {"Open...", "Run...", "", "Exit"};
405 - String[] fileCmds = {"Open", "Load", "", "Exit"};
406 + // String[] fileItems = {"Open...", "Run...", "", "Exit"};
407 + // String[] fileCmds = {"Open", "Load", "", "Exit"};
408 + String[] fileItems = {"Run", "Save", "", "Exit"};
409 + String[] fileCmds = {"Run", "Save", "", "Exit"};
410 char[] fileShortCuts = {'0', 'N', '\0', 'X'};
411 int[] fileAccelerators = {KeyEvent.VK_O,
412 KeyEvent.VK_N,
413 @@ -1795,6 +1896,9 @@
414 KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK);
415 item.setAccelerator(k);
417 + if (fileItems[i].equals("Save")) {
418 + saveItem = item;
422 for (int i = 0; i < editItems.length; ++i) {
423 @@ -1849,9 +1953,9 @@
424 item.addActionListener(this);
425 windowMenu.add(item = new JMenuItem("Tile", 'T'));
426 item.addActionListener(this);
427 - windowMenu.addSeparator();
428 - windowMenu.add(item = new JMenuItem("Console", 'C'));
429 - item.addActionListener(this);
430 +// windowMenu.addSeparator();
431 +// windowMenu.add(item = new JMenuItem("Console", 'C'));
432 +// item.addActionListener(this);
433 add(windowMenu);
436 @@ -1925,11 +2029,16 @@
437 item.addActionListener(this);
440 + public void setSaveEnabled(boolean state) {
441 + saveItem.setEnabled(state);
444 Main db;
445 JMenu windowMenu;
446 JCheckBoxMenuItem breakOnExceptions;
447 JCheckBoxMenuItem breakOnEnter;
448 JCheckBoxMenuItem breakOnReturn;
449 + JMenuItem saveItem;
452 class EnterInterrupt implements Runnable {
453 @@ -1942,6 +2051,13 @@
454 public void run() {
455 JMenu menu = db.getJMenuBar().getMenu(0);
456 //menu.getItem(0).setEnabled(false); // File->Load
458 + // disable Edit menu Cut, Copy, Paste items
459 + menu = db.getJMenuBar().getMenu(1);
460 + for (int i = 0; i < 3; i++) {
461 + menu.getItem(i).setEnabled(false);
464 menu = db.getJMenuBar().getMenu(2);
465 menu.getItem(0).setEnabled(false); // Debug->Break
466 int count = menu.getItemCount();
467 @@ -1954,6 +2070,10 @@
468 b = true;
470 db.toolBar.setEnabled(true);
472 + // set flag to disable source editing
473 + db.setSourceEditingEnabled(false);
475 // raise the debugger window
476 db.toFront();
478 @@ -1967,6 +2087,13 @@
479 public void run() {
480 JMenu menu = db.getJMenuBar().getMenu(0);
481 menu.getItem(0).setEnabled(true); // File->Load
483 + // enable Edit menu items
484 + menu = db.getJMenuBar().getMenu(1);
485 + for (int i = 0; i < 3; i++) {
486 + menu.getItem(i).setEnabled(true);
489 menu = db.getJMenuBar().getMenu(2);
490 menu.getItem(0).setEnabled(true); // Debug->Break
491 int count = menu.getItemCount() - 1;
492 @@ -1980,6 +2107,10 @@
493 db.toolBar.getComponent(ci).setEnabled(b);
494 b = false;
497 + // set flag to enable source editing
498 + db.setSourceEditingEnabled(true);
500 //db.console.consoleTextArea.requestFocus();
503 @@ -1988,17 +2119,24 @@
505 String fileName;
506 Main db;
507 + Reader reader = null;
508 OpenFile(Main db, String fileName)
510 this.fileName = fileName;
511 this.db = db;
513 + OpenFile(Main db, String fileName, Reader reader) {
514 + this(db, fileName);
515 + this.reader = reader;
517 public void run() {
518 Context cx = Context.enter();
519 ContextData contextData = ContextData.get(cx);
520 contextData.breakNextLine = true;
521 try {
522 - cx.compileReader(new FileReader(fileName), fileName, 1, null);
523 + cx.compileReader(
524 + reader == null ? new FileReader(fileName) : reader,
525 + fileName, 1, null);
526 } catch (Exception exc) {
527 String msg = exc.getMessage();
528 if (exc instanceof EcmaError) {
529 @@ -2019,29 +2157,79 @@
530 Scriptable scope;
531 String fileName;
532 Main db;
533 + Reader reader = null;
534 + Object result = null;
535 + Exception exception = null;
536 + int lineNum = -1;
537 + boolean sfExecute = false;
539 LoadFile(Main db, Scriptable scope, String fileName) {
540 this.scope = scope;
541 this.fileName = fileName;
542 this.db = db;
545 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader) {
546 + this(db, scope, fileName);
547 + this.reader = reader;
549 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) {
550 + this(db, scope, fileName);
551 + this.reader = reader;
552 + this.sfExecute = sfExecute;
555 public void run() {
556 + if ( db.officeScripts.isScriptRunning( fileName ) )
557 + {
558 + exception = new Exception("The script is already executing");
559 + if ( !sfExecute ) {
560 + MessageDialogWrapper.showMessageDialog(db,
561 + "Script already executing",
562 + "Run",
563 + JOptionPane.ERROR_MESSAGE);
565 + return;
566 + }
567 + db.officeScripts.setScriptRunning( fileName, true );
568 Context cx = Context.enter();
569 ContextData contextData = ContextData.get(cx);
570 + if ( sfExecute )
572 + contextData.breakNextLine = false;
574 + else
576 contextData.breakNextLine = true;
578 + /*
579 + FileWindow w = (FileWindow)db.getSelectedFrame();
580 + if ( sfExecute )
582 + db.swingInvoke(new SetFilePosition(db, w, -1 ) );
583 + }*/
584 try {
585 - cx.evaluateReader(scope, new FileReader(fileName),
586 + result = cx.evaluateReader(scope,
587 + reader == null ? new FileReader(fileName) : reader,
588 fileName, 1, null);
589 } catch (Exception exc) {
590 + exception = exc;
591 String msg = exc.getMessage();
592 if (exc instanceof EcmaError) {
593 EcmaError err = (EcmaError)exc;
594 msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg;
597 + int lineNum = err.getLineNumber() ;
598 + //db.swingInvoke(new SetFilePosition(db, w, lineNum ) );
599 + if ( !sfExecute ) {
600 MessageDialogWrapper.showMessageDialog(db,
601 msg,
602 "Run",
603 JOptionPane.ERROR_MESSAGE);
606 } finally {
607 + db.officeScripts.setScriptRunning( fileName, false );
608 cx.exit();
611 @@ -2416,13 +2604,13 @@
612 super.setVisible(b);
613 if (b) {
614 // this needs to be done after the window is visible
615 - console.consoleTextArea.requestFocus();
616 + // console.consoleTextArea.requestFocus();
617 context.split.setDividerLocation(0.5);
618 try {
619 - console.setMaximum(true);
620 - console.setSelected(true);
621 - console.show();
622 - console.consoleTextArea.requestFocus();
623 + // console.setMaximum(true);
624 + // console.setSelected(true);
625 + // console.show();
626 + // console.consoleTextArea.requestFocus();
627 } catch (Exception exc) {
630 @@ -2449,35 +2637,6 @@
632 Hashtable functionNames = new Hashtable();
634 - ScriptItem getScriptItem(DebuggableScript fnOrScript) {
635 - ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
636 - if (item == null) {
637 - String url = getNormilizedUrl(fnOrScript);
638 - SourceInfo si = (SourceInfo)sourceNames.get(url);
639 - if (si == null) {
640 - if (!fnOrScript.isGeneratedScript()) {
641 - // Not eval or Function, try to load it from URL
642 - String source = null;
643 - try {
644 - InputStream is = openSource(url);
645 - try { source = readSource(is); }
646 - finally { is.close(); }
647 - } catch (IOException ex) {
648 - System.err.println
649 - ("Failed to load source from "+url+": "+ ex);
651 - if (source != null) {
652 - si = registerSource(url, source);
656 - if (si != null) {
657 - item = registerScript(si, fnOrScript);
660 - return item;
663 /* Debugger Interface */
665 public void handleCompilationDone(Context cx, DebuggableScript fnOrScript,
666 @@ -2490,7 +2649,7 @@
668 String getNormilizedUrl(DebuggableScript fnOrScript) {
669 String url = fnOrScript.getSourceName();
670 - if (url == null) { url = "<stdin>"; }
671 + if (url == null) { url = "document"; }
672 else {
673 // Not to produce window for eval from different lines,
674 // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval)
675 @@ -2601,7 +2760,7 @@
676 if (si == null) {
677 si = new SourceInfo(sourceUrl, source);
678 sourceNames.put(sourceUrl, si);
679 - } else {
680 + } else if (!source.equals(si.getSource())) {
681 si.setSource(source);
684 @@ -2762,7 +2921,7 @@
685 desk = new JDesktopPane();
686 desk.setPreferredSize(new Dimension(600, 300));
687 desk.setMinimumSize(new Dimension(150, 50));
688 - desk.add(console = new JSInternalConsole("JavaScript Console"));
689 + // desk.add(console = new JSInternalConsole("JavaScript Console"));
690 context = new ContextWindow(this);
691 context.setPreferredSize(new Dimension(600, 120));
692 context.setMinimumSize(new Dimension(50, 50));
693 @@ -2871,7 +3030,7 @@
694 FrameHelper frame = contextData.getFrame(frameIndex);
695 String sourceName = frame.getUrl();
696 if (sourceName == null || sourceName.equals("<stdin>")) {
697 - console.show();
698 + // console.show();
699 helper.reset();
700 return;
702 @@ -2895,6 +3054,19 @@
703 int dispatcherIsWaiting = 0;
704 Context currentContext = null;
706 + // Flag used to establish whether source code editing is allowed in
707 + // the debugger, switched on and off depending on whether a debug session
708 + // is active
709 + boolean sourceEditingEnabled = true;
711 + public boolean isSourceEditingEnabled() {
712 + return sourceEditingEnabled;
715 + void setSourceEditingEnabled(boolean b) {
716 + sourceEditingEnabled = b;
719 Context getCurrentContext() {
720 return currentContext;
722 @@ -3028,14 +3200,14 @@
723 swingInvoke(CreateFileWindow.action(this, si, line));
725 } else {
726 - if (console.isVisible()) {
727 + /* if (console.isVisible()) {
728 final JSInternalConsole finalConsole = console;
729 swingInvoke(new Runnable() {
730 public void run() {
731 finalConsole.show();
735 + } */
737 swingInvoke(new EnterInterrupt(this, cx));
738 swingInvoke(new UpdateContext(this, cx));
739 @@ -3217,6 +3389,14 @@
740 fileName)).start();
743 + } else if (cmd.equals("Run")) {
744 + FileWindow w = (FileWindow)getSelectedFrame();
745 + if (w != null)
746 + w.load();
747 + } else if (cmd.equals("Save")) {
748 + FileWindow w = (FileWindow)getSelectedFrame();
749 + if (w != null)
750 + w.save();
751 } else if (cmd.equals("More Windows...")) {
752 MoreWindows dlg = new MoreWindows(this, fileWindows,
753 "Window", "Files");
754 @@ -3509,6 +3689,60 @@
758 + JInternalFrame getFrameForUrl( URL url )
759 + {
760 + JInternalFrame[] frames = desk.getAllFrames();
761 + for (int i = 0; i < frames.length; i++) {
762 + FileWindow w = (FileWindow)frames[i];
763 + if ( url.toString().equals( w.getUrl() ) ) {
764 + return w;
767 + return null;
768 + }
769 + public void highlighLineInSelectedWindow(URL url, int lineNum ){
770 + //FileWindow w = (FileWindow)getFrameForUrl( url );
771 + FileWindow w = (FileWindow)getSelectedFrame();
772 + if (w != null)
774 + if ( lineNum > -1 )
775 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
778 + public Object runSelectedWindow( URL scriptUrl ) throws Exception
780 + Object result = null;
781 + FileWindow w = (FileWindow)getSelectedFrame();
782 + //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl );
783 + w.toFront();
784 + if (w != null)
786 + Scriptable scope = w.db.getScope();
787 + if (scope == null)
789 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
790 + result = null;
791 + }
792 + else
794 + String url = w.getUrl();
795 + Thread executorThread = null;
796 + if (url != null)
798 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
799 + executor.run();
800 + result = executor.result;
801 + if ( executor.exception != null )
803 + throw executor.exception;
808 + return result;
813 // public interface
815 @@ -3604,6 +3838,69 @@
816 return console.getErr();
819 + public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) {
820 + if (scope == null) {
821 + MessageDialogWrapper.showMessageDialog(this,
822 + "Can't compile scripts: no scope available",
823 + "Open", JOptionPane.ERROR_MESSAGE);
824 + } else {
825 + if (scriptUrl != null) {
826 + try
828 + InputStreamReader reader = new InputStreamReader(scriptUrl.openStream());
829 + String fileName = null;
830 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") )
832 + fileName = scriptUrl.toString();
834 + else
836 + fileName = scriptUrl.getPath();
838 + officeScripts.addScript( fileName, scriptUrl, scope, closeCallback );
839 + //new Thread(new OpenFile(this, scope, fileName, reader )).start();
840 + swingInvoke( new OpenFile(this, fileName, reader ));
842 + catch ( IOException e )
844 + MessageDialogWrapper.showMessageDialog(this,
845 + "Can't open stream for script: " + e.toString(),
846 + "Open", JOptionPane.ERROR_MESSAGE);
850 + split1.setDividerLocation(1.0);
853 + public void openFile(String fileName) {
854 + Scriptable scope = getScope();
855 + if (scope == null) {
856 + MessageDialogWrapper.showMessageDialog(this,
857 + "Can't compile scripts: no scope available",
858 + "Open", JOptionPane.ERROR_MESSAGE);
859 + } else {
860 + if (fileName != null) {
861 + new Thread(new OpenFile(this, fileName)).start();
864 + split1.setDividerLocation(1.0);
867 + public void openStream(InputStream in) {
868 + Scriptable scope = getScope();
869 + if (scope == null) {
870 + MessageDialogWrapper.showMessageDialog(this,
871 + "Can't compile scripts: no scope available",
872 + "Open", JOptionPane.ERROR_MESSAGE);
873 + } else {
874 + if (in != null) {
875 + new Thread(new OpenFile(this, null, new InputStreamReader(in))).start();
878 + split1.setDividerLocation(1.0);
879 + menubar.setSaveEnabled(false);
882 public static void main(String[] args) {
883 try {
884 mainThread = Thread.currentThread();
885 @@ -3635,5 +3932,162 @@
889 + // patched Office specific interface
891 + OfficeScriptInfo officeScripts = new OfficeScriptInfo();
893 + void removeScript( String url )
895 + // Remove the FileWindow from list of open sources
896 + fileWindows.remove( url );
898 + // Remove sourceInfo from sourceNames, ensures that
899 + // breakpoints etc are deleted
900 + synchronized (sourceNames) {
901 + sourceNames.remove( url );
903 + // Removes scriptItems for the script, ensures that a new open ( from openFile )
904 + // will succeed, openFile should open file but fails due to fact that
905 + synchronized ( scriptItems )
906 + {
907 + Iterator iter = scriptItems.entrySet().iterator();
908 + while ( iter.hasNext() )
910 + Map.Entry me = ( Map.Entry )iter.next();
911 + ScriptItem item = (ScriptItem)me.getValue();
912 + SourceInfo si = item.getSourceInfo();
913 + if ( si.getUrl().equals( url ) )
915 + //match
916 + scriptItems.remove( me.getKey() );
917 + break;
921 + officeScripts.deleteScript( url );
925 + ScriptItem getScriptItem(DebuggableScript fnOrScript) {
926 + ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
927 + if (item == null) {
928 + String url = getNormilizedUrl(fnOrScript);
929 + SourceInfo si = (SourceInfo)sourceNames.get(url);
930 + if (si == null) {
931 + if (!fnOrScript.isGeneratedScript()) {
932 + // Not eval or Function, try to load it from URL
933 + String source = null;
934 + try {
935 + InputStream is = openSource(url);
936 + try { source = readSource(is); }
937 + finally { is.close(); }
938 + } catch (IOException ex) {
939 + System.err.println
940 + ("Failed to load source from "+url+": "+ ex);
942 + if (source != null) {
943 + si = registerSource(url, source);
947 + if (si != null) {
948 + item = registerScript(si, fnOrScript);
952 + return item;
955 + public void showScriptWindow(URL url ){
956 + String key = url.getPath();
957 + if ( url.getProtocol().startsWith("vnd.sun.star") )
959 + key = url.toString();
961 + FileWindow w = (FileWindow)getFileWindow( key );
962 + if ( w != null )
964 + //w.maximize();
965 + desk.getDesktopManager().deiconifyFrame(w);
966 + desk.getDesktopManager().activateFrame(w);
967 + w.show();
968 + w.toFront();
972 + public void highlighLineInScriptWindow(URL url, int lineNum ){
973 + String key = url.getPath();
974 + if ( url.getProtocol().startsWith("vnd.sun.star") )
976 + key = url.getPath();
978 + FileWindow w = (FileWindow)getFileWindow( key );
979 + if (w != null)
981 + if ( lineNum > -1 )
982 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
985 + public Object runScriptWindow( URL scriptUrl ) throws Exception
987 + String key = scriptUrl.getPath();
988 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") )
990 + key = scriptUrl.toString();
992 + FileWindow w = (FileWindow)getFileWindow( key );
993 + Object result = null;
994 + w.toFront();
995 + if (w != null)
997 + //Scriptable scope = w.db.getScope();
998 + Scriptable scope = w.db.officeScripts.getScriptScope( key );
999 + if (scope == null)
1001 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
1002 + result = null;
1003 + }
1004 + else
1006 + String url = w.getUrl();
1007 + Thread executorThread = null;
1008 + if (url != null)
1010 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
1011 + executor.run();
1012 + result = executor.result;
1013 + if ( executor.exception != null )
1015 + throw executor.exception;
1020 + return result;
1024 + public boolean isModified( URL url )
1026 + String key = url.getPath();
1027 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1029 + key = url.toString();
1031 + FileWindow w = (FileWindow)getFileWindow( key );
1032 + return w.isModified();
1035 + public String getText( URL url )
1037 + String key = url.toString();
1038 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1040 + key = url.toString();
1042 + FileWindow w = (FileWindow)getFileWindow( key );
1043 + return w.getText();
1048 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004
1049 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008
1050 @@ -36,6 +36,7 @@
1051 package org.mozilla.javascript.tools.shell;
1053 import java.security.*;
1054 +import java.security.cert.Certificate;
1055 import java.net.MalformedURLException;
1056 import java.net.URL;
1057 import java.util.Hashtable;
1058 @@ -124,7 +125,7 @@
1060 public JavaPolicySecurity() {
1061 // To trigger error on jdk-1.1 with lazy load
1062 - new CodeSource(null, null);
1063 + new CodeSource(null, (Certificate [])null);
1066 protected void callProcessFileSecure(final Context cx,
1067 @@ -167,7 +168,7 @@
1070 private ProtectionDomain getUrlDomain(URL url) {
1071 - CodeSource cs = new CodeSource(url, null);
1072 + CodeSource cs = new CodeSource(url, (Certificate [])null);
1073 PermissionCollection pc = Policy.getPolicy().getPermissions(cs);
1074 return new ProtectionDomain(cs, pc);