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
4 package org.mozilla.javascript;
6 import java.lang.reflect.Method;
7 +import java.lang.reflect.InvocationTargetException;
10 * Load generated classes.
12 implements GeneratedClassLoader
14 public DefiningClassLoader() {
15 - this.parentLoader = getClass().getClassLoader();
16 + init(getClass().getClassLoader());
19 public DefiningClassLoader(ClassLoader parentLoader) {
24 + private void init(ClassLoader parentLoader) {
26 this.parentLoader = parentLoader;
28 + this.contextLoader = null;
29 + if (method_getContextClassLoader != null) {
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) {
39 + if (this.contextLoader == this.parentLoader) {
40 + this.contextLoader = null;
46 public Class defineClass(String name, byte[] data) {
49 Class cl = findLoadedClass(name);
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);
62 - cl = findSystemClass(name);
64 + cl = loadFromParent(name);
65 + } catch (ClassNotFoundException ex) {
66 + cl = contextLoader.loadClass(name);
75 + private Class loadFromParent(String name)
76 + throws ClassNotFoundException
78 + if (parentLoader != null) {
79 + return parentLoader.loadClass(name);
81 + return findSystemClass(name);
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;
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",
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
113 <project name="toolsrc" default="compile" basedir=".">
115 + <condition property="boot_refID" value="macPath" else="nonMacPath">
118 + <os family="unix"/>
120 + <equals arg1="${ant.java.version}" arg2="1.5"/>
121 + <equals arg1="${ant.java.version}" arg2="1.6"/>
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"/>
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"/>
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>
153 - package org.mozilla.javascript.tools.debugger;
154 - import java.awt.Component;
157 - <replace file="${src.debugger}/AbstractTreeTableModel.java">
158 - <replacetoken>import javax.swing.tree.*;</replacetoken>
160 - package org.mozilla.javascript.tools.debugger;
161 - import javax.swing.tree.*;
164 - <replace file="${src.debugger}/JTreeTable.java">
165 - <replacetoken>import javax.swing.*;</replacetoken>
167 - package org.mozilla.javascript.tools.debugger;
168 - import javax.swing.*;
171 - <replace file="${src.debugger}/TreeTableModel.java">
172 - <replacetoken>import javax.swing.tree.TreeModel;</replacetoken>
174 - package org.mozilla.javascript.tools.debugger;
175 - import javax.swing.tree.TreeModel;
178 - <replace file="${src.debugger}/TreeTableModelAdapter.java">
179 - <replacetoken>import javax.swing.JTree;</replacetoken>
181 - package org.mozilla.javascript.tools.debugger;
182 - import javax.swing.JTree;
187 <target name="compile" depends="properties,get-swing-ex">
189 includes="org/**/*.java"
192 + <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
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) {
208 public void keyTyped(KeyEvent e) {
209 + if (w.isEditable() == false) {
213 public void keyReleased(KeyEvent e) {
214 + if (w.isEditable() == false) {
224 -class FileWindow extends JInternalFrame implements ActionListener {
225 +class FileWindow extends JInternalFrame implements ActionListener, DocumentListener {
228 SourceInfo sourceInfo;
229 @@ -888,15 +894,16 @@
233 + boolean isModified = false;
235 public void actionPerformed(ActionEvent e) {
236 String cmd = e.getActionCommand();
237 if (cmd.equals("Cut")) {
240 } else if (cmd.equals("Copy")) {
242 } else if (cmd.equals("Paste")) {
243 - // textArea.paste();
248 @@ -910,17 +917,73 @@
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();
260 MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
262 String url = getUrl();
264 - new Thread(new LoadFile(db,scope,url)).start();
265 + new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start();
271 + if (getUrl() != null) {
272 + OutputStream os = null;
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();
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);
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) {
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 @@
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() );
347 private void updateToolTip() {
348 @@ -990,7 +1061,10 @@
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);
357 if (currentPos != -1) {
359 @@ -1001,6 +1075,31 @@
360 fileHeader.repaint();
363 + /* Implementation of DocumentListener interface */
364 + public void insertUpdate(DocumentEvent e) {
368 + public void removeUpdate(DocumentEvent e) {
372 + public void changedUpdate(DocumentEvent 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);
391 @@ -1618,7 +1717,7 @@
393 db.currentWindow = w;
395 - db.menubar.addFile(url);
396 + // db.menubar.addFile(url);
400 @@ -1752,8 +1851,10 @@
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,
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")) {
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);
436 @@ -1925,11 +2029,16 @@
437 item.addActionListener(this);
440 + public void setSaveEnabled(boolean state) {
441 + saveItem.setEnabled(state);
446 JCheckBoxMenuItem breakOnExceptions;
447 JCheckBoxMenuItem breakOnEnter;
448 JCheckBoxMenuItem breakOnReturn;
449 + JMenuItem saveItem;
452 class EnterInterrupt implements Runnable {
453 @@ -1942,6 +2051,13 @@
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 @@
470 db.toolBar.setEnabled(true);
472 + // set flag to disable source editing
473 + db.setSourceEditingEnabled(false);
475 // raise the debugger window
478 @@ -1967,6 +2087,13 @@
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);
497 + // set flag to enable source editing
498 + db.setSourceEditingEnabled(true);
500 //db.console.consoleTextArea.requestFocus();
503 @@ -1988,17 +2119,24 @@
507 + Reader reader = null;
508 OpenFile(Main db, String fileName)
510 this.fileName = fileName;
513 + OpenFile(Main db, String fileName, Reader reader) {
514 + this(db, fileName);
515 + this.reader = reader;
518 Context cx = Context.enter();
519 ContextData contextData = ContextData.get(cx);
520 contextData.breakNextLine = true;
522 - cx.compileReader(new FileReader(fileName), fileName, 1, null);
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 @@
533 + Reader reader = null;
534 + Object result = null;
535 + Exception exception = null;
537 + boolean sfExecute = false;
539 LoadFile(Main db, Scriptable scope, String fileName) {
541 this.fileName = fileName;
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;
556 + if ( db.officeScripts.isScriptRunning( fileName ) )
558 + exception = new Exception("The script is already executing");
559 + if ( !sfExecute ) {
560 + MessageDialogWrapper.showMessageDialog(db,
561 + "Script already executing",
563 + JOptionPane.ERROR_MESSAGE);
567 + db.officeScripts.setScriptRunning( fileName, true );
568 Context cx = Context.enter();
569 ContextData contextData = ContextData.get(cx);
572 + contextData.breakNextLine = false;
576 contextData.breakNextLine = true;
579 + FileWindow w = (FileWindow)db.getSelectedFrame();
582 + db.swingInvoke(new SetFilePosition(db, w, -1 ) );
585 - cx.evaluateReader(scope, new FileReader(fileName),
586 + result = cx.evaluateReader(scope,
587 + reader == null ? new FileReader(fileName) : reader,
589 } catch (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,
603 JOptionPane.ERROR_MESSAGE);
607 + db.officeScripts.setScriptRunning( fileName, false );
611 @@ -2416,13 +2604,13 @@
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);
619 - console.setMaximum(true);
620 - console.setSelected(true);
622 - console.consoleTextArea.requestFocus();
623 + // console.setMaximum(true);
624 + // console.setSelected(true);
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);
640 - if (!fnOrScript.isGeneratedScript()) {
641 - // Not eval or Function, try to load it from URL
642 - String source = null;
644 - InputStream is = openSource(url);
645 - try { source = readSource(is); }
646 - finally { is.close(); }
647 - } catch (IOException ex) {
649 - ("Failed to load source from "+url+": "+ ex);
651 - if (source != null) {
652 - si = registerSource(url, source);
657 - item = registerScript(si, fnOrScript);
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"; }
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 @@
677 si = new SourceInfo(sourceUrl, source);
678 sourceNames.put(sourceUrl, si);
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>")) {
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
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));
726 - if (console.isVisible()) {
727 + /* if (console.isVisible()) {
728 final JSInternalConsole finalConsole = console;
729 swingInvoke(new Runnable() {
737 swingInvoke(new EnterInterrupt(this, cx));
738 swingInvoke(new UpdateContext(this, cx));
739 @@ -3217,6 +3389,14 @@
743 + } else if (cmd.equals("Run")) {
744 + FileWindow w = (FileWindow)getSelectedFrame();
747 + } else if (cmd.equals("Save")) {
748 + FileWindow w = (FileWindow)getSelectedFrame();
751 } else if (cmd.equals("More Windows...")) {
752 MoreWindows dlg = new MoreWindows(this, fileWindows,
754 @@ -3509,6 +3689,60 @@
758 + JInternalFrame getFrameForUrl( URL url )
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() ) ) {
769 + public void highlighLineInSelectedWindow(URL url, int lineNum ){
770 + //FileWindow w = (FileWindow)getFrameForUrl( url );
771 + FileWindow w = (FileWindow)getSelectedFrame();
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 );
786 + Scriptable scope = w.db.getScope();
789 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
794 + String url = w.getUrl();
795 + Thread executorThread = null;
798 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
800 + result = executor.result;
801 + if ( executor.exception != null )
803 + throw executor.exception;
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);
825 + if (scriptUrl != null) {
828 + InputStreamReader reader = new InputStreamReader(scriptUrl.openStream());
829 + String fileName = null;
830 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") )
832 + fileName = scriptUrl.toString();
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);
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);
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) {
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 )
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 ) )
916 + scriptItems.remove( me.getKey() );
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);
931 + if (!fnOrScript.isGeneratedScript()) {
932 + // Not eval or Function, try to load it from URL
933 + String source = null;
935 + InputStream is = openSource(url);
936 + try { source = readSource(is); }
937 + finally { is.close(); }
938 + } catch (IOException ex) {
940 + ("Failed to load source from "+url+": "+ ex);
942 + if (source != null) {
943 + si = registerSource(url, source);
948 + item = registerScript(si, fnOrScript);
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 );
965 + desk.getDesktopManager().deiconifyFrame(w);
966 + desk.getDesktopManager().activateFrame(w);
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 );
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;
997 + //Scriptable scope = w.db.getScope();
998 + Scriptable scope = w.db.officeScripts.getScriptScope( key );
1001 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
1006 + String url = w.getUrl();
1007 + Thread executorThread = null;
1010 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
1012 + result = executor.result;
1013 + if ( executor.exception != null )
1015 + throw executor.exception;
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
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;
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,
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);