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">
188 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2004-03-25 21:54:34.000000000 +0100
189 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2009-01-17 20:44:22.000000000 +0100
190 @@ -470,15 +470,21 @@
191 case KeyEvent.VK_BACK_SPACE:
192 case KeyEvent.VK_ENTER:
193 case KeyEvent.VK_DELETE:
194 + if (w.isEditable() == false) {
200 public void keyTyped(KeyEvent e) {
201 + if (w.isEditable() == false) {
205 public void keyReleased(KeyEvent e) {
206 + if (w.isEditable() == false) {
216 -class FileWindow extends JInternalFrame implements ActionListener {
217 +class FileWindow extends JInternalFrame implements ActionListener, DocumentListener {
220 SourceInfo sourceInfo;
221 @@ -888,15 +894,16 @@
225 + boolean isModified = false;
227 public void actionPerformed(ActionEvent e) {
228 String cmd = e.getActionCommand();
229 if (cmd.equals("Cut")) {
232 } else if (cmd.equals("Copy")) {
234 } else if (cmd.equals("Paste")) {
235 - // textArea.paste();
240 @@ -910,17 +917,73 @@
244 - Scriptable scope = db.getScope();
245 + //Scriptable scope = db.getScope();
246 + Scriptable scope = db.officeScripts.getScriptScope( getUrl() );
247 + if ( scope == null )
249 + scope = db.getScope();
252 MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
254 String url = getUrl();
256 - new Thread(new LoadFile(db,scope,url)).start();
257 + new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start();
263 + if (getUrl() != null) {
264 + OutputStream os = null;
266 + if ( getUrl().startsWith("vnd.sun.star") )
268 + URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() );
269 + if ( scriptUrl == null )
271 + throw new IOException("Can't optain stream for " + getUrl() );
273 + os = scriptUrl.openConnection().getOutputStream();
277 + os = new FileOutputStream( getUrl() );
279 + String s = textArea.getText();
280 + os.write(s.getBytes(), 0, s.length());
282 + this.isModified = false;
284 + catch (IOException ioe) {
285 + JOptionPane.showMessageDialog(this,
286 + "Error saving file: " + ioe.getMessage(),
287 + "Error", JOptionPane.ERROR_MESSAGE);
298 + catch( IOException ioe )
300 + System.err.println("Error closing stream: " + ioe.getMessage() );
301 + ioe.printStackTrace();
308 + public boolean isEditable() {
309 + return db.isSourceEditingEnabled();
313 public int getPosition(int line) {
317 fileHeader.repaint();
321 + public Main getDB() { return db; }
322 FileWindow(Main db, SourceInfo sourceInfo) {
323 super(SourceInfo.getShortName(sourceInfo.getUrl()),
324 true, true, true, true);
325 @@ -972,6 +1035,14 @@
329 + addInternalFrameListener( new InternalFrameAdapter() {
330 + public void internalFrameClosed(InternalFrameEvent e) {
331 + // clean up scriptItems and sourceNames hashes
332 + getDB().removeScript( getUrl() );
333 + // remove scripts for officeScripts
334 + getDB().officeScripts.deleteScript( getUrl() );
339 private void updateToolTip() {
340 @@ -990,7 +1061,10 @@
342 String newText = sourceInfo.getSource();
343 if (!textArea.getText().equals(newText)) {
344 + textArea.getDocument().removeDocumentListener(this);
345 textArea.setText(newText);
346 + this.isModified = false;
347 + textArea.getDocument().addDocumentListener(this);
349 if (currentPos != -1) {
351 @@ -1001,6 +1075,31 @@
352 fileHeader.repaint();
355 + /* Implementation of DocumentListener interface */
356 + public void insertUpdate(DocumentEvent e) {
360 + public void removeUpdate(DocumentEvent e) {
364 + public void changedUpdate(DocumentEvent e) {
368 + public void doChanged(DocumentEvent e) {
369 + this.isModified = true;
372 + public boolean isModified() {
373 + return this.isModified;
376 + public String getText() {
377 + return textArea.getText();
380 void setPosition(int pos) {
381 textArea.select(pos);
383 @@ -1618,7 +1717,7 @@
385 db.currentWindow = w;
387 - db.menubar.addFile(url);
388 + // db.menubar.addFile(url);
392 @@ -1752,8 +1851,10 @@
396 - String[] fileItems = {"Open...", "Run...", "", "Exit"};
397 - String[] fileCmds = {"Open", "Load", "", "Exit"};
398 + // String[] fileItems = {"Open...", "Run...", "", "Exit"};
399 + // String[] fileCmds = {"Open", "Load", "", "Exit"};
400 + String[] fileItems = {"Run", "Save", "", "Exit"};
401 + String[] fileCmds = {"Run", "Save", "", "Exit"};
402 char[] fileShortCuts = {'0', 'N', '\0', 'X'};
403 int[] fileAccelerators = {KeyEvent.VK_O,
405 @@ -1795,6 +1896,9 @@
406 KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK);
407 item.setAccelerator(k);
409 + if (fileItems[i].equals("Save")) {
414 for (int i = 0; i < editItems.length; ++i) {
415 @@ -1849,9 +1953,9 @@
416 item.addActionListener(this);
417 windowMenu.add(item = new JMenuItem("Tile", 'T'));
418 item.addActionListener(this);
419 - windowMenu.addSeparator();
420 - windowMenu.add(item = new JMenuItem("Console", 'C'));
421 - item.addActionListener(this);
422 +// windowMenu.addSeparator();
423 +// windowMenu.add(item = new JMenuItem("Console", 'C'));
424 +// item.addActionListener(this);
428 @@ -1925,11 +2029,16 @@
429 item.addActionListener(this);
432 + public void setSaveEnabled(boolean state) {
433 + saveItem.setEnabled(state);
438 JCheckBoxMenuItem breakOnExceptions;
439 JCheckBoxMenuItem breakOnEnter;
440 JCheckBoxMenuItem breakOnReturn;
441 + JMenuItem saveItem;
444 class EnterInterrupt implements Runnable {
445 @@ -1942,6 +2051,13 @@
447 JMenu menu = db.getJMenuBar().getMenu(0);
448 //menu.getItem(0).setEnabled(false); // File->Load
450 + // disable Edit menu Cut, Copy, Paste items
451 + menu = db.getJMenuBar().getMenu(1);
452 + for (int i = 0; i < 3; i++) {
453 + menu.getItem(i).setEnabled(false);
456 menu = db.getJMenuBar().getMenu(2);
457 menu.getItem(0).setEnabled(false); // Debug->Break
458 int count = menu.getItemCount();
459 @@ -1954,6 +2070,10 @@
462 db.toolBar.setEnabled(true);
464 + // set flag to disable source editing
465 + db.setSourceEditingEnabled(false);
467 // raise the debugger window
470 @@ -1967,6 +2087,13 @@
472 JMenu menu = db.getJMenuBar().getMenu(0);
473 menu.getItem(0).setEnabled(true); // File->Load
475 + // enable Edit menu items
476 + menu = db.getJMenuBar().getMenu(1);
477 + for (int i = 0; i < 3; i++) {
478 + menu.getItem(i).setEnabled(true);
481 menu = db.getJMenuBar().getMenu(2);
482 menu.getItem(0).setEnabled(true); // Debug->Break
483 int count = menu.getItemCount() - 1;
484 @@ -1980,6 +2107,10 @@
485 db.toolBar.getComponent(ci).setEnabled(b);
489 + // set flag to enable source editing
490 + db.setSourceEditingEnabled(true);
492 //db.console.consoleTextArea.requestFocus();
495 @@ -1988,17 +2119,24 @@
499 + Reader reader = null;
500 OpenFile(Main db, String fileName)
502 this.fileName = fileName;
505 + OpenFile(Main db, String fileName, Reader reader) {
506 + this(db, fileName);
507 + this.reader = reader;
510 Context cx = Context.enter();
511 ContextData contextData = ContextData.get(cx);
512 contextData.breakNextLine = true;
514 - cx.compileReader(new FileReader(fileName), fileName, 1, null);
516 + reader == null ? new FileReader(fileName) : reader,
517 + fileName, 1, null);
518 } catch (Exception exc) {
519 String msg = exc.getMessage();
520 if (exc instanceof EcmaError) {
521 @@ -2019,29 +2157,79 @@
525 + Reader reader = null;
526 + Object result = null;
527 + Exception exception = null;
529 + boolean sfExecute = false;
531 LoadFile(Main db, Scriptable scope, String fileName) {
533 this.fileName = fileName;
537 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader) {
538 + this(db, scope, fileName);
539 + this.reader = reader;
541 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) {
542 + this(db, scope, fileName);
543 + this.reader = reader;
544 + this.sfExecute = sfExecute;
548 + if ( db.officeScripts.isScriptRunning( fileName ) )
550 + exception = new Exception("The script is already executing");
551 + if ( !sfExecute ) {
552 + MessageDialogWrapper.showMessageDialog(db,
553 + "Script already executing",
555 + JOptionPane.ERROR_MESSAGE);
559 + db.officeScripts.setScriptRunning( fileName, true );
560 Context cx = Context.enter();
561 ContextData contextData = ContextData.get(cx);
564 + contextData.breakNextLine = false;
568 contextData.breakNextLine = true;
571 + FileWindow w = (FileWindow)db.getSelectedFrame();
574 + db.swingInvoke(new SetFilePosition(db, w, -1 ) );
577 - cx.evaluateReader(scope, new FileReader(fileName),
578 + result = cx.evaluateReader(scope,
579 + reader == null ? new FileReader(fileName) : reader,
581 } catch (Exception exc) {
583 String msg = exc.getMessage();
584 if (exc instanceof EcmaError) {
585 EcmaError err = (EcmaError)exc;
586 msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg;
589 + int lineNum = err.getLineNumber() ;
590 + //db.swingInvoke(new SetFilePosition(db, w, lineNum ) );
591 + if ( !sfExecute ) {
592 MessageDialogWrapper.showMessageDialog(db,
595 JOptionPane.ERROR_MESSAGE);
599 + db.officeScripts.setScriptRunning( fileName, false );
603 @@ -2416,13 +2604,13 @@
606 // this needs to be done after the window is visible
607 - console.consoleTextArea.requestFocus();
608 + // console.consoleTextArea.requestFocus();
609 context.split.setDividerLocation(0.5);
611 - console.setMaximum(true);
612 - console.setSelected(true);
614 - console.consoleTextArea.requestFocus();
615 + // console.setMaximum(true);
616 + // console.setSelected(true);
618 + // console.consoleTextArea.requestFocus();
619 } catch (Exception exc) {
622 @@ -2449,35 +2637,6 @@
624 Hashtable functionNames = new Hashtable();
626 - ScriptItem getScriptItem(DebuggableScript fnOrScript) {
627 - ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
628 - if (item == null) {
629 - String url = getNormilizedUrl(fnOrScript);
630 - SourceInfo si = (SourceInfo)sourceNames.get(url);
632 - if (!fnOrScript.isGeneratedScript()) {
633 - // Not eval or Function, try to load it from URL
634 - String source = null;
636 - InputStream is = openSource(url);
637 - try { source = readSource(is); }
638 - finally { is.close(); }
639 - } catch (IOException ex) {
641 - ("Failed to load source from "+url+": "+ ex);
643 - if (source != null) {
644 - si = registerSource(url, source);
649 - item = registerScript(si, fnOrScript);
655 /* Debugger Interface */
657 public void handleCompilationDone(Context cx, DebuggableScript fnOrScript,
658 @@ -2490,7 +2649,7 @@
660 String getNormilizedUrl(DebuggableScript fnOrScript) {
661 String url = fnOrScript.getSourceName();
662 - if (url == null) { url = "<stdin>"; }
663 + if (url == null) { url = "document"; }
665 // Not to produce window for eval from different lines,
666 // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval)
667 @@ -2601,7 +2760,7 @@
669 si = new SourceInfo(sourceUrl, source);
670 sourceNames.put(sourceUrl, si);
672 + } else if (!source.equals(si.getSource())) {
673 si.setSource(source);
676 @@ -2762,7 +2921,7 @@
677 desk = new JDesktopPane();
678 desk.setPreferredSize(new Dimension(600, 300));
679 desk.setMinimumSize(new Dimension(150, 50));
680 - desk.add(console = new JSInternalConsole("JavaScript Console"));
681 + // desk.add(console = new JSInternalConsole("JavaScript Console"));
682 context = new ContextWindow(this);
683 context.setPreferredSize(new Dimension(600, 120));
684 context.setMinimumSize(new Dimension(50, 50));
685 @@ -2871,7 +3030,7 @@
686 FrameHelper frame = contextData.getFrame(frameIndex);
687 String sourceName = frame.getUrl();
688 if (sourceName == null || sourceName.equals("<stdin>")) {
694 @@ -2895,6 +3054,19 @@
695 int dispatcherIsWaiting = 0;
696 Context currentContext = null;
698 + // Flag used to establish whether source code editing is allowed in
699 + // the debugger, switched on and off depending on whether a debug session
701 + boolean sourceEditingEnabled = true;
703 + public boolean isSourceEditingEnabled() {
704 + return sourceEditingEnabled;
707 + void setSourceEditingEnabled(boolean b) {
708 + sourceEditingEnabled = b;
711 Context getCurrentContext() {
712 return currentContext;
714 @@ -3028,14 +3200,14 @@
715 swingInvoke(CreateFileWindow.action(this, si, line));
718 - if (console.isVisible()) {
719 + /* if (console.isVisible()) {
720 final JSInternalConsole finalConsole = console;
721 swingInvoke(new Runnable() {
729 swingInvoke(new EnterInterrupt(this, cx));
730 swingInvoke(new UpdateContext(this, cx));
731 @@ -3217,6 +3389,14 @@
735 + } else if (cmd.equals("Run")) {
736 + FileWindow w = (FileWindow)getSelectedFrame();
739 + } else if (cmd.equals("Save")) {
740 + FileWindow w = (FileWindow)getSelectedFrame();
743 } else if (cmd.equals("More Windows...")) {
744 MoreWindows dlg = new MoreWindows(this, fileWindows,
746 @@ -3509,6 +3689,60 @@
750 + JInternalFrame getFrameForUrl( URL url )
752 + JInternalFrame[] frames = desk.getAllFrames();
753 + for (int i = 0; i < frames.length; i++) {
754 + FileWindow w = (FileWindow)frames[i];
755 + if ( url.toString().equals( w.getUrl() ) ) {
761 + public void highlighLineInSelectedWindow(URL url, int lineNum ){
762 + //FileWindow w = (FileWindow)getFrameForUrl( url );
763 + FileWindow w = (FileWindow)getSelectedFrame();
766 + if ( lineNum > -1 )
767 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
770 + public Object runSelectedWindow( URL scriptUrl ) throws Exception
772 + Object result = null;
773 + FileWindow w = (FileWindow)getSelectedFrame();
774 + //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl );
778 + Scriptable scope = w.db.getScope();
781 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
786 + String url = w.getUrl();
787 + Thread executorThread = null;
790 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
792 + result = executor.result;
793 + if ( executor.exception != null )
795 + throw executor.exception;
807 @@ -3604,6 +3838,69 @@
808 return console.getErr();
811 + public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) {
812 + if (scope == null) {
813 + MessageDialogWrapper.showMessageDialog(this,
814 + "Can't compile scripts: no scope available",
815 + "Open", JOptionPane.ERROR_MESSAGE);
817 + if (scriptUrl != null) {
820 + InputStreamReader reader = new InputStreamReader(scriptUrl.openStream());
821 + String fileName = null;
822 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") )
824 + fileName = scriptUrl.toString();
828 + fileName = scriptUrl.getPath();
830 + officeScripts.addScript( fileName, scriptUrl, scope, closeCallback );
831 + //new Thread(new OpenFile(this, scope, fileName, reader )).start();
832 + swingInvoke( new OpenFile(this, fileName, reader ));
834 + catch ( IOException e )
836 + MessageDialogWrapper.showMessageDialog(this,
837 + "Can't open stream for script: " + e.toString(),
838 + "Open", JOptionPane.ERROR_MESSAGE);
842 + split1.setDividerLocation(1.0);
845 + public void openFile(String fileName) {
846 + Scriptable scope = getScope();
847 + if (scope == null) {
848 + MessageDialogWrapper.showMessageDialog(this,
849 + "Can't compile scripts: no scope available",
850 + "Open", JOptionPane.ERROR_MESSAGE);
852 + if (fileName != null) {
853 + new Thread(new OpenFile(this, fileName)).start();
856 + split1.setDividerLocation(1.0);
859 + public void openStream(InputStream in) {
860 + Scriptable scope = getScope();
861 + if (scope == null) {
862 + MessageDialogWrapper.showMessageDialog(this,
863 + "Can't compile scripts: no scope available",
864 + "Open", JOptionPane.ERROR_MESSAGE);
867 + new Thread(new OpenFile(this, null, new InputStreamReader(in))).start();
870 + split1.setDividerLocation(1.0);
871 + menubar.setSaveEnabled(false);
874 public static void main(String[] args) {
876 mainThread = Thread.currentThread();
877 @@ -3635,5 +3932,162 @@
881 + // patched Office specific interface
883 + OfficeScriptInfo officeScripts = new OfficeScriptInfo();
885 + void removeScript( String url )
887 + // Remove the FileWindow from list of open sources
888 + fileWindows.remove( url );
890 + // Remove sourceInfo from sourceNames, ensures that
891 + // breakpoints etc are deleted
892 + synchronized (sourceNames) {
893 + sourceNames.remove( url );
895 + // Removes scriptItems for the script, ensures that a new open ( from openFile )
896 + // will succeed, openFile should open file but fails due to fact that
897 + synchronized ( scriptItems )
899 + Iterator iter = scriptItems.entrySet().iterator();
900 + while ( iter.hasNext() )
902 + Map.Entry me = ( Map.Entry )iter.next();
903 + ScriptItem item = (ScriptItem)me.getValue();
904 + SourceInfo si = item.getSourceInfo();
905 + if ( si.getUrl().equals( url ) )
908 + scriptItems.remove( me.getKey() );
913 + officeScripts.deleteScript( url );
917 + ScriptItem getScriptItem(DebuggableScript fnOrScript) {
918 + ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
919 + if (item == null) {
920 + String url = getNormilizedUrl(fnOrScript);
921 + SourceInfo si = (SourceInfo)sourceNames.get(url);
923 + if (!fnOrScript.isGeneratedScript()) {
924 + // Not eval or Function, try to load it from URL
925 + String source = null;
927 + InputStream is = openSource(url);
928 + try { source = readSource(is); }
929 + finally { is.close(); }
930 + } catch (IOException ex) {
932 + ("Failed to load source from "+url+": "+ ex);
934 + if (source != null) {
935 + si = registerSource(url, source);
940 + item = registerScript(si, fnOrScript);
947 + public void showScriptWindow(URL url ){
948 + String key = url.getPath();
949 + if ( url.getProtocol().startsWith("vnd.sun.star") )
951 + key = url.toString();
953 + FileWindow w = (FileWindow)getFileWindow( key );
957 + desk.getDesktopManager().deiconifyFrame(w);
958 + desk.getDesktopManager().activateFrame(w);
964 + public void highlighLineInScriptWindow(URL url, int lineNum ){
965 + String key = url.getPath();
966 + if ( url.getProtocol().startsWith("vnd.sun.star") )
968 + key = url.getPath();
970 + FileWindow w = (FileWindow)getFileWindow( key );
973 + if ( lineNum > -1 )
974 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
977 + public Object runScriptWindow( URL scriptUrl ) throws Exception
979 + String key = scriptUrl.getPath();
980 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") )
982 + key = scriptUrl.toString();
984 + FileWindow w = (FileWindow)getFileWindow( key );
985 + Object result = null;
989 + //Scriptable scope = w.db.getScope();
990 + Scriptable scope = w.db.officeScripts.getScriptScope( key );
993 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
998 + String url = w.getUrl();
999 + Thread executorThread = null;
1002 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
1004 + result = executor.result;
1005 + if ( executor.exception != null )
1007 + throw executor.exception;
1016 + public boolean isModified( URL url )
1018 + String key = url.getPath();
1019 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1021 + key = url.toString();
1023 + FileWindow w = (FileWindow)getFileWindow( key );
1024 + return w.isModified();
1027 + public String getText( URL url )
1029 + String key = url.toString();
1030 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1032 + key = url.toString();
1034 + FileWindow w = (FileWindow)getFileWindow( key );
1035 + return w.getText();
1040 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004
1041 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008
1043 package org.mozilla.javascript.tools.shell;
1045 import java.security.*;
1046 +import java.security.cert.Certificate;
1047 import java.net.MalformedURLException;
1048 import java.net.URL;
1049 import java.util.Hashtable;
1052 public JavaPolicySecurity() {
1053 // To trigger error on jdk-1.1 with lazy load
1054 - new CodeSource(null, null);
1055 + new CodeSource(null, (Certificate [])null);
1058 protected void callProcessFileSecure(final Context cx,
1062 private ProtectionDomain getUrlDomain(URL url) {
1063 - CodeSource cs = new CodeSource(url, null);
1064 + CodeSource cs = new CodeSource(url, (Certificate [])null);
1065 PermissionCollection pc = Policy.getPolicy().getPermissions(cs);
1066 return new ProtectionDomain(cs, pc);