Index: core/nbproject/project.xml
===================================================================
RCS file: /cvs/core/nbproject/project.xml,v
retrieving revision 1.10
diff -u -r1.10 project.xml
--- core/nbproject/project.xml 18 Aug 2005 17:42:26 -0000 1.10
+++ core/nbproject/project.xml 2 Sep 2005 20:38:23 -0000
@@ -36,6 +36,14 @@
+ org.netbeans.modules.sendopts
+
+
+
+ 1.0
+
+
+
org.netbeans.swing.plaf
Index: core/src/META-INF/services/org.netbeans.CLIHandler
===================================================================
RCS file: core/src/META-INF/services/org.netbeans.CLIHandler
diff -N core/src/META-INF/services/org.netbeans.CLIHandler
--- core/src/META-INF/services/org.netbeans.CLIHandler 4 Jun 2005 05:11:01 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-org.netbeans.core.CLIOptions2
Index: core/src/org/netbeans/core/CLIOptions2.java
===================================================================
RCS file: core/src/org/netbeans/core/CLIOptions2.java
diff -N core/src/org/netbeans/core/CLIOptions2.java
--- core/src/org/netbeans/core/CLIOptions2.java 5 Jan 2005 14:55:47 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-/*
- * Sun Public License Notice
- *
- * The contents of this file are subject to the Sun Public License
- * Version 1.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://www.sun.com/
- *
- * The Original Code is NetBeans. The Initial Developer of the Original
- * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.core;
-
-import org.netbeans.CLIHandler;
-
-/**
- * Shows the main window, so it is fronted when second instance of
- * NetBeans tries to start.
- *
- * @author Jaroslav Tulach
- */
-public class CLIOptions2 extends CLIHandler implements Runnable {
- /** number of invocations */
- private int cnt;
-
- /**
- * Create a default handler.
- */
- public CLIOptions2 () {
- super(WHEN_INIT);
- }
-
- protected int cli(Args arguments) {
- return cli(arguments.getArguments());
- }
-
- final int cli(String[] args) {
- if (cnt++ == 0) return 0;
-
- /*
- for (int i = 0; i < args.length; i++) {
- if ("--nofront".equals (args[i])) {
- return 0;
- }
- }
- */
- javax.swing.SwingUtilities.invokeLater (this);
-
- return 0;
- }
-
- public void run () {
- java.awt.Frame f = org.openide.windows.WindowManager.getDefault ().getMainWindow ();
-
- // makes sure the frame is visible
- f.setVisible(true);
- // uniconifies the frame if it is inconified
- if ((f.getExtendedState () & java.awt.Frame.ICONIFIED) != 0) {
- f.setExtendedState (~java.awt.Frame.ICONIFIED & f.getExtendedState ());
- }
- // moves it to front and requests focus
- f.toFront ();
-
- }
-
-
- protected void usage(java.io.PrintWriter w) {
- //w.println(NonGui.getString("TEXT_help"));
- }
-
-}
Index: core/src/org/netbeans/core/CoreBridgeImpl.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/core/CoreBridgeImpl.java,v
retrieving revision 1.2
diff -u -r1.2 CoreBridgeImpl.java
--- core/src/org/netbeans/core/CoreBridgeImpl.java 4 Jun 2005 05:11:04 -0000 1.2
+++ core/src/org/netbeans/core/CoreBridgeImpl.java 2 Sep 2005 20:38:28 -0000
@@ -12,6 +12,11 @@
*/
package org.netbeans.core;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import org.netbeans.api.sendopts.CommandException;
import org.netbeans.core.startup.Main;
import org.netbeans.core.startup.ManifestSection;
@@ -19,7 +24,12 @@
*
* @author Jaroslav Tulach
*/
-public final class CoreBridgeImpl extends org.netbeans.core.startup.CoreBridge {
+public final class CoreBridgeImpl extends org.netbeans.core.startup.CoreBridge
+implements Runnable {
+ /** counts the number of CLI invocations */
+ private int numberOfCLIInvocations;
+
+
protected void attachToCategory (Object category) {
ModuleActions.attachTo(category);
}
@@ -89,4 +99,50 @@
public void lookupCacheStore (org.openide.util.Lookup l) throws java.io.IOException {
LookupCache.store (l);
}
+
+ public void cliUsage(PrintWriter printWriter) {
+ // nothing for now
+ }
+
+ public int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file) {
+ try {
+ org.netbeans.api.sendopts.CommandLine.getDefault().parse(
+ string, inputStream, outputStream, file
+ );
+ for (int i = 0; i < string.length; i++) {
+ string[i] = null;
+ }
+ } catch (CommandException ex) {
+ ex.printStackTrace();
+ return ex.getExitCode();
+ }
+
+ if (numberOfCLIInvocations++ == 0) return 0;
+
+ /*
+ for (int i = 0; i < args.length; i++) {
+ if ("--nofront".equals (args[i])) {
+ return 0;
+ }
+ }
+ */
+ javax.swing.SwingUtilities.invokeLater (this);
+
+ return 0;
+ }
+
+ public void run () {
+ java.awt.Frame f = org.openide.windows.WindowManager.getDefault ().getMainWindow ();
+
+ // makes sure the frame is visible
+ f.setVisible(true);
+ // uniconifies the frame if it is inconified
+ if ((f.getExtendedState () & java.awt.Frame.ICONIFIED) != 0) {
+ f.setExtendedState (~java.awt.Frame.ICONIFIED & f.getExtendedState ());
+ }
+ // moves it to front and requests focus
+ f.toFront ();
+
+ }
+
}
Index: core/startup/src/META-INF/services/org.netbeans.CLIHandler
===================================================================
RCS file: /cvs/core/startup/src/META-INF/services/org.netbeans.CLIHandler,v
retrieving revision 1.3
diff -u -r1.3 org.netbeans.CLIHandler
--- core/startup/src/META-INF/services/org.netbeans.CLIHandler 29 Jul 2005 03:51:14 -0000 1.3
+++ core/startup/src/META-INF/services/org.netbeans.CLIHandler 2 Sep 2005 20:38:29 -0000
@@ -1,2 +1,3 @@
org.netbeans.core.startup.CLIOptions
+org.netbeans.core.startup.CLICoreBridge
org.netbeans.core.startup.CLITestModuleReload
Index: core/startup/src/org/netbeans/core/startup/CLICoreBridge.java
===================================================================
RCS file: core/startup/src/org/netbeans/core/startup/CLICoreBridge.java
diff -N core/startup/src/org/netbeans/core/startup/CLICoreBridge.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/startup/src/org/netbeans/core/startup/CLICoreBridge.java 2 Sep 2005 20:38:29 -0000
@@ -0,0 +1,53 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.core.startup;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.*;
+import java.io.*;
+import java.security.*;
+import java.util.Locale;
+import javax.swing.*;
+import javax.swing.border.*;
+
+import org.netbeans.CLIHandler;
+
+import org.openide.util.NbBundle;
+
+/**
+ * Handler for core.jar options.
+ * @author Jaroslav Tulach
+ */
+public class CLICoreBridge extends CLIHandler {
+ /**
+ * Create a default handler.
+ */
+ public CLICoreBridge() {
+ super(WHEN_INIT);
+ }
+
+ protected int cli(Args arguments) {
+ return CoreBridge.getDefault().cli(
+ arguments.getArguments(),
+ arguments.getInputStream(),
+ arguments.getOutputStream(),
+ arguments.getCurrentDirectory()
+ );
+ }
+
+ protected void usage(PrintWriter w) {
+ CoreBridge.getDefault().cliUsage(w);
+ }
+}
Index: core/startup/src/org/netbeans/core/startup/CoreBridge.java
===================================================================
RCS file: /cvs/core/startup/src/org/netbeans/core/startup/CoreBridge.java,v
retrieving revision 1.2
diff -u -r1.2 CoreBridge.java
--- core/startup/src/org/netbeans/core/startup/CoreBridge.java 7 Jun 2005 04:45:59 -0000 1.2
+++ core/startup/src/org/netbeans/core/startup/CoreBridge.java 2 Sep 2005 20:38:29 -0000
@@ -12,6 +12,10 @@
*/
package org.netbeans.core.startup;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
import org.openide.util.Lookup;
/** Interface to environment that the Module system needs around itself.
@@ -116,4 +120,8 @@
public abstract void setStatusText (String status);
public abstract void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL);
+
+ public abstract void cliUsage(PrintWriter printWriter);
+
+ public abstract int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file);
}
Index: core/startup/test/unit/src/org/netbeans/core/startup/FakeBridge.java
===================================================================
RCS file: /cvs/core/startup/test/unit/src/org/netbeans/core/startup/FakeBridge.java,v
retrieving revision 1.3
diff -u -r1.3 FakeBridge.java
--- core/startup/test/unit/src/org/netbeans/core/startup/FakeBridge.java 4 Jun 2005 21:59:12 -0000 1.3
+++ core/startup/test/unit/src/org/netbeans/core/startup/FakeBridge.java 2 Sep 2005 20:38:30 -0000
@@ -12,6 +12,10 @@
*/
package org.netbeans.core.startup;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
import java.net.URL;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
@@ -71,5 +75,12 @@
public void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL) {
throw new UnsupportedOperationException();
+ }
+
+ public void cliUsage(PrintWriter printWriter) {
+ }
+
+ public int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file) {
+ return 0;
}
}
Index: utilities/build.xml
===================================================================
RCS file: /cvs/utilities/build.xml,v
retrieving revision 1.54
diff -u -r1.54 build.xml
--- utilities/build.xml 11 Jun 2005 07:01:14 -0000 1.54
+++ utilities/build.xml 2 Sep 2005 20:38:35 -0000
@@ -12,29 +12,5 @@
Microsystems, Inc. All Rights Reserved.
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: utilities/manifest.mf
===================================================================
RCS file: /cvs/utilities/manifest.mf,v
retrieving revision 1.59
diff -u -r1.59 manifest.mf
--- utilities/manifest.mf 6 Apr 2005 00:06:57 -0000 1.59
+++ utilities/manifest.mf 2 Sep 2005 20:38:35 -0000
@@ -4,7 +4,7 @@
OpenIDE-Module-Specification-Version: 1.19
OpenIDE-Module-Install: org/netbeans/modules/utilities/Installer.class
OpenIDE-Module-Layer: org/netbeans/modules/utilities/Layer.xml
-OpenIDE-Module-Requires: org.openide.windows.IOProvider, org.openide.modules.InstalledFileLocator
+OpenIDE-Module-Requires: org.openide.modules.InstalledFileLocator, org.openide.windows.IOProvider
Name: org/netbeans/modules/url/URLDataLoader.class
OpenIDE-Module-Class: Loader
Index: utilities/nbproject/project.xml
===================================================================
RCS file: /cvs/utilities/nbproject/project.xml,v
retrieving revision 1.13
diff -u -r1.13 project.xml
--- utilities/nbproject/project.xml 24 Aug 2005 12:15:14 -0000 1.13
+++ utilities/nbproject/project.xml 2 Sep 2005 20:38:36 -0000
@@ -18,15 +18,23 @@
org.netbeans.modules.utilities
- org.openide.filesystems
+ org.netbeans.api.progress
- 6.2
+ 1
- org.openide.util
+ org.netbeans.modules.sendopts
+
+
+
+ 1.0
+
+
+
+ org.openide.actions
@@ -34,7 +42,7 @@
- org.openide.modules
+ org.openide.awt
@@ -42,7 +50,7 @@
- org.openide.nodes
+ org.openide.dialogs
@@ -58,7 +66,7 @@
- org.openide.awt
+ org.openide.filesystems
@@ -66,23 +74,23 @@
- org.openide.dialogs
+ org.openide.io
- 6.2
+ 1.0
- org.openide.options
+ org.openide.loaders
- 6.2
+ 5.1
- org.openide.windows
+ org.openide.modules
@@ -90,7 +98,7 @@
- org.openide.text
+ org.openide.nodes
@@ -98,7 +106,7 @@
- org.openide.actions
+ org.openide.options
@@ -106,38 +114,38 @@
- org.openide.io
+ org.openide.text
- 1.0
+ 6.2
- org.openide.loaders
+ org.openide.util
- 5.1
+ 6.2
- org.openidex.util
-
+ org.openide.windows
+
- 3
- 3.3
+ 6.2
-
+
- org.netbeans.api.progress
+ org.openidex.util
- 1
+ 3
+ 3.3
-
+
Index: utilities/src/META-INF/services/org.netbeans.modules.openfile.cli.Callback
===================================================================
RCS file: utilities/src/META-INF/services/org.netbeans.modules.openfile.cli.Callback
diff -N utilities/src/META-INF/services/org.netbeans.modules.openfile.cli.Callback
--- utilities/src/META-INF/services/org.netbeans.modules.openfile.cli.Callback 11 Sep 2003 17:46:55 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-org.netbeans.modules.openfile.CallbackImpl
Index: utilities/src/META-INF/services/org.netbeans.spi.sendopts.OptionProvider
===================================================================
RCS file: utilities/src/META-INF/services/org.netbeans.spi.sendopts.OptionProvider
diff -N utilities/src/META-INF/services/org.netbeans.spi.sendopts.OptionProvider
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ utilities/src/META-INF/services/org.netbeans.spi.sendopts.OptionProvider 2 Sep 2005 20:38:36 -0000
@@ -0,0 +1 @@
+org.netbeans.modules.openfile.OptProvider
Index: utilities/src/org/netbeans/modules/openfile/CallbackImpl.java
===================================================================
RCS file: utilities/src/org/netbeans/modules/openfile/CallbackImpl.java
diff -N utilities/src/org/netbeans/modules/openfile/CallbackImpl.java
--- utilities/src/org/netbeans/modules/openfile/CallbackImpl.java 11 Sep 2003 17:46:56 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-/*
- * Sun Public License Notice
- *
- * The contents of this file are subject to the Sun Public License
- * Version 1.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://www.sun.com/
- *
- * The Original Code is NetBeans. The Initial Developer of the Original
- * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.modules.openfile;
-
-import java.io.File;
-import org.netbeans.modules.openfile.cli.Callback;
-
-/**
- * Provides module functionality to CLI handler.
- * @author Jesse Glick
- */
-public class CallbackImpl implements Callback {
-
- /**
- * A default instance.
- */
- public CallbackImpl() {}
-
- public boolean open(File f, int line, Callback.Waiter waiter) {
- return OpenFile.openFile(f, line, waiter);
- }
-
-}
Index: utilities/src/org/netbeans/modules/openfile/DefaultOpenFileImpl.java
===================================================================
RCS file: /cvs/utilities/src/org/netbeans/modules/openfile/DefaultOpenFileImpl.java,v
retrieving revision 1.13
diff -u -r1.13 DefaultOpenFileImpl.java
--- utilities/src/org/netbeans/modules/openfile/DefaultOpenFileImpl.java 19 Aug 2005 13:27:50 -0000 1.13
+++ utilities/src/org/netbeans/modules/openfile/DefaultOpenFileImpl.java 2 Sep 2005 20:38:38 -0000
@@ -26,7 +26,6 @@
import javax.swing.SwingUtilities;
import javax.swing.text.Element;
import javax.swing.text.StyledDocument;
-import org.netbeans.modules.openfile.cli.Callback;
import org.openide.DialogDisplayer;
import org.openide.ErrorManager;
import org.openide.NotifyDescriptor;
@@ -415,7 +414,7 @@
* (or {@link OpenCookie} or {@link ViewCookie}),
* or by showing it in the Explorer.
*/
- public boolean open(final FileObject fileObject, int line, Callback.Waiter waiter) {
+ public boolean open(final FileObject fileObject, int line, Object waiter) {
String fileName = fileObject.getNameExt();
Index: utilities/src/org/netbeans/modules/openfile/OpenFile.java
===================================================================
RCS file: /cvs/utilities/src/org/netbeans/modules/openfile/OpenFile.java,v
retrieving revision 1.59
diff -u -r1.59 OpenFile.java
--- utilities/src/org/netbeans/modules/openfile/OpenFile.java 12 Oct 2004 13:13:30 -0000 1.59
+++ utilities/src/org/netbeans/modules/openfile/OpenFile.java 2 Sep 2005 20:38:38 -0000
@@ -14,7 +14,6 @@
package org.netbeans.modules.openfile;
import java.io.File;
-import org.netbeans.modules.openfile.cli.Callback;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
@@ -66,7 +65,7 @@
* @return true on success, false on failure
* @usecase CallbackImpl, OpenFileAction
*/
- static boolean openFile(File file, int line, Callback.Waiter waiter) {
+ static boolean openFile(File file, int line, Object waiter) {
if (!checkFileExists(file)) {
return false;
}
Index: utilities/src/org/netbeans/modules/openfile/OpenFileImpl.java
===================================================================
RCS file: /cvs/utilities/src/org/netbeans/modules/openfile/OpenFileImpl.java,v
retrieving revision 1.4
diff -u -r1.4 OpenFileImpl.java
--- utilities/src/org/netbeans/modules/openfile/OpenFileImpl.java 11 Sep 2003 17:46:57 -0000 1.4
+++ utilities/src/org/netbeans/modules/openfile/OpenFileImpl.java 2 Sep 2005 20:38:38 -0000
@@ -17,7 +17,6 @@
import org.openide.filesystems.FileObject;
-import org.netbeans.modules.openfile.cli.Callback;
/**
* Interface for Open File implementations.
@@ -46,6 +45,6 @@
* @param waiter if not null, tell the waiter when the file is closed
* @return true on success, false on failure
*/
- boolean open(FileObject fileObject, int line, Callback.Waiter waiter);
+ boolean open(FileObject fileObject, int line, Object waiter);
}
Index: utilities/src/org/netbeans/modules/openfile/OptProvider.java
===================================================================
RCS file: utilities/src/org/netbeans/modules/openfile/OptProvider.java
diff -N utilities/src/org/netbeans/modules/openfile/OptProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ utilities/src/org/netbeans/modules/openfile/OptProvider.java 2 Sep 2005 20:38:39 -0000
@@ -0,0 +1,102 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.modules.openfile;
+
+import java.io.File;
+import java.io.PrintWriter;
+import org.netbeans.spi.sendopts.AdditionalArgumentsProcessor;
+import org.netbeans.spi.sendopts.Env;
+import org.netbeans.spi.sendopts.Option;
+import org.netbeans.spi.sendopts.OptionProvider;
+import org.openide.util.Lookup;
+
+/**
+ * A sendopts provider for Open File.
+ * @author Jaroslav Tulach
+ */
+public class OptProvider implements OptionProvider, AdditionalArgumentsProcessor {
+ /** option to open the file */
+ private Option open;
+
+ /**
+ * Create the provider.
+ */
+ public OptProvider() {
+ open = Option.additionalArguments((char)-1, "open", this); // NOI18N
+ }
+
+ public Option[] getOptions() {
+ return new Option[] { open };
+ }
+
+ private File findFile (File curDir, String name) {
+ File f = new File(name);
+ if (!f.isAbsolute()) {
+ f = new File(curDir, name);
+ }
+ return f;
+ }
+
+ private int openFile (File curDir, Env args, String[] argv, int i) {
+ String s = argv[i];
+ if (s == null) {
+ log("Missing argument to --open", args);
+ return 2;
+ }
+ argv[i] = null;
+ int line = -1;
+ File f = findFile (curDir, s);
+ if (!f.exists()) {
+ // Check if it is 1file:line syntax.
+ int idx = s.lastIndexOf(':'); // NOI18N
+ if (idx != -1) {
+ try {
+ line = Integer.parseInt(s.substring(idx + 1)) - 1;
+ f = findFile (curDir, s.substring(0, idx));
+ } catch (NumberFormatException e) {
+ // OK, leave as a filename
+ }
+ }
+ }
+ // Just make sure it was opened, then exit.
+ boolean success = OpenFile.openFile(f, line, null);
+ return success ? 0 : 1;
+ }
+
+
+ public void process(Option option, Env env, String[] argv) throws org.netbeans.api.sendopts.CommandException {
+ File curDir = env.getCurrentDirectory ();
+ for (int i = 0; i < argv.length; i++) {
+ int res = openFile (curDir, env, argv, i++);
+ if (res != 0) {
+ throw org.netbeans.api.sendopts.CommandException.exitCode(res);
+ }
+ }
+ }
+
+ private static void log(String msg, Env args) {
+ PrintWriter w = new PrintWriter(args.getOutputStream());
+ w.println(msg);
+ w.flush();
+ // don't close however - might be another user
+ }
+
+ protected void usage(PrintWriter w) {
+ w.println("OpenFile module options:");
+ w.println(" --open FILE open FILE.");
+ w.println(" --open FILE:LINE open FILE at line LINE (starting from 1).");
+ w.println("");
+ }
+
+}