This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 57611
Collapse All | Expand All

(-)core/nbproject/project.xml (+8 lines)
Lines 36-41 Link Here
36
                    </run-dependency>
36
                    </run-dependency>
37
                </dependency>
37
                </dependency>
38
                <dependency>
38
                <dependency>
39
                    <code-name-base>org.netbeans.modules.sendopts</code-name-base>
40
                    <build-prerequisite/>
41
                    <compile-dependency/>
42
                    <run-dependency>
43
                        <specification-version>1.0</specification-version>
44
                    </run-dependency>
45
                </dependency>
46
                <dependency>
39
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
47
                    <code-name-base>org.netbeans.swing.plaf</code-name-base>
40
                    <build-prerequisite/>
48
                    <build-prerequisite/>
41
                    <compile-dependency/>
49
                    <compile-dependency/>
(-)core/src/META-INF/services/org.netbeans.CLIHandler (-1 lines)
Removed Link Here
1
org.netbeans.core.CLIOptions2
(-)core/src/org/netbeans/core/CLIOptions2.java (-73 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core;
15
16
import org.netbeans.CLIHandler;
17
18
/**
19
 * Shows the main window, so it is fronted when second instance of
20
 * NetBeans tries to start.
21
 *
22
 * @author Jaroslav Tulach
23
 */
24
public class CLIOptions2 extends CLIHandler implements Runnable {
25
    /** number of invocations */
26
    private int cnt;
27
28
    /**
29
     * Create a default handler.
30
     */
31
    public CLIOptions2 () {
32
        super(WHEN_INIT);
33
    }
34
    
35
    protected int cli(Args arguments) {
36
        return cli(arguments.getArguments());
37
    }
38
    
39
    final int cli(String[] args) {
40
        if (cnt++ == 0) return 0;
41
        
42
        /*
43
        for (int i = 0; i < args.length; i++) {
44
            if ("--nofront".equals (args[i])) {
45
                return 0;
46
            }
47
        }
48
         */
49
        javax.swing.SwingUtilities.invokeLater (this);
50
        
51
        return 0;
52
    }
53
    
54
    public void run () {
55
        java.awt.Frame f = org.openide.windows.WindowManager.getDefault ().getMainWindow ();
56
57
        // makes sure the frame is visible
58
        f.setVisible(true);
59
        // uniconifies the frame if it is inconified
60
        if ((f.getExtendedState () & java.awt.Frame.ICONIFIED) != 0) {
61
            f.setExtendedState (~java.awt.Frame.ICONIFIED & f.getExtendedState ());
62
        }
63
        // moves it to front and requests focus
64
        f.toFront ();
65
        
66
    }
67
    
68
    
69
    protected void usage(java.io.PrintWriter w) {
70
        //w.println(NonGui.getString("TEXT_help"));
71
    }
72
    
73
}
(-)core/src/org/netbeans/core/CoreBridgeImpl.java (-1 / +57 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.core;
13
package org.netbeans.core;
14
14
15
import java.io.File;
16
import java.io.InputStream;
17
import java.io.OutputStream;
18
import java.io.PrintWriter;
19
import org.netbeans.api.sendopts.CommandException;
15
import org.netbeans.core.startup.Main;
20
import org.netbeans.core.startup.Main;
16
import org.netbeans.core.startup.ManifestSection;
21
import org.netbeans.core.startup.ManifestSection;
17
22
Lines 19-25 Link Here
19
 *
24
 *
20
 * @author Jaroslav Tulach
25
 * @author Jaroslav Tulach
21
 */
26
 */
22
public final class CoreBridgeImpl extends org.netbeans.core.startup.CoreBridge {
27
public final class CoreBridgeImpl extends org.netbeans.core.startup.CoreBridge 
28
implements Runnable {
29
    /** counts the number of CLI invocations */
30
    private int numberOfCLIInvocations;
31
    
32
    
23
    protected void attachToCategory (Object category) {
33
    protected void attachToCategory (Object category) {
24
        ModuleActions.attachTo(category);
34
        ModuleActions.attachTo(category);
25
    }
35
    }
Lines 89-92 Link Here
89
    public void lookupCacheStore (org.openide.util.Lookup l) throws java.io.IOException {
99
    public void lookupCacheStore (org.openide.util.Lookup l) throws java.io.IOException {
90
        LookupCache.store (l);
100
        LookupCache.store (l);
91
    }
101
    }
102
103
    public void cliUsage(PrintWriter printWriter) {
104
        // nothing for now
105
    }
106
107
    public int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file) {
108
        try {
109
            org.netbeans.api.sendopts.CommandLine.getDefault().parse(
110
                string, inputStream, outputStream, file
111
            );
112
            for (int i = 0; i < string.length; i++) {
113
                string[i] = null;
114
            }
115
        } catch (CommandException ex) {
116
            ex.printStackTrace();
117
            return ex.getExitCode();
118
        }
119
        
120
        if (numberOfCLIInvocations++ == 0) return 0;
121
        
122
        /*
123
        for (int i = 0; i < args.length; i++) {
124
            if ("--nofront".equals (args[i])) {
125
                return 0;
126
            }
127
        }
128
         */
129
        javax.swing.SwingUtilities.invokeLater (this);
130
        
131
        return 0;
132
    }
133
    
134
    public void run () {
135
        java.awt.Frame f = org.openide.windows.WindowManager.getDefault ().getMainWindow ();
136
137
        // makes sure the frame is visible
138
        f.setVisible(true);
139
        // uniconifies the frame if it is inconified
140
        if ((f.getExtendedState () & java.awt.Frame.ICONIFIED) != 0) {
141
            f.setExtendedState (~java.awt.Frame.ICONIFIED & f.getExtendedState ());
142
        }
143
        // moves it to front and requests focus
144
        f.toFront ();
145
        
146
    }
147
    
92
}
148
}
(-)core/startup/src/META-INF/services/org.netbeans.CLIHandler (+1 lines)
Lines 1-2 Link Here
1
org.netbeans.core.startup.CLIOptions
1
org.netbeans.core.startup.CLIOptions
2
org.netbeans.core.startup.CLICoreBridge
2
org.netbeans.core.startup.CLITestModuleReload
3
org.netbeans.core.startup.CLITestModuleReload
(-)core/startup/src/org/netbeans/core/startup/CLICoreBridge.java (+53 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.startup;
15
16
import java.awt.*;
17
import java.awt.event.*;
18
import java.beans.*;
19
import java.io.*;
20
import java.security.*;
21
import java.util.Locale;
22
import javax.swing.*;
23
import javax.swing.border.*;
24
25
import org.netbeans.CLIHandler;
26
27
import org.openide.util.NbBundle;
28
29
/**
30
 * Handler for core.jar options.
31
 * @author Jaroslav Tulach
32
 */
33
public class CLICoreBridge extends CLIHandler {
34
    /**
35
     * Create a default handler.
36
     */
37
    public CLICoreBridge() {
38
        super(WHEN_INIT);
39
    }
40
    
41
    protected int cli(Args arguments) {
42
        return CoreBridge.getDefault().cli(
43
            arguments.getArguments(), 
44
            arguments.getInputStream(), 
45
            arguments.getOutputStream(), 
46
            arguments.getCurrentDirectory()
47
        );
48
    }
49
50
    protected void usage(PrintWriter w) {
51
        CoreBridge.getDefault().cliUsage(w);
52
    }
53
}
(-)core/startup/src/org/netbeans/core/startup/CoreBridge.java (+8 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.core.startup;
13
package org.netbeans.core.startup;
14
14
15
import java.io.File;
16
import java.io.InputStream;
17
import java.io.OutputStream;
18
import java.io.PrintWriter;
15
import org.openide.util.Lookup;
19
import org.openide.util.Lookup;
16
20
17
/** Interface to environment that the Module system needs around itself.
21
/** Interface to environment that the Module system needs around itself.
Lines 116-119 Link Here
116
    public abstract void setStatusText (String status);
120
    public abstract void setStatusText (String status);
117
    
121
    
118
    public abstract void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL);
122
    public abstract void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL);
123
124
    public abstract void cliUsage(PrintWriter printWriter);
125
126
    public abstract int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file);
119
}
127
}
(-)core/startup/test/unit/src/org/netbeans/core/startup/FakeBridge.java (+11 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.core.startup;
13
package org.netbeans.core.startup;
14
14
15
import java.io.File;
16
import java.io.InputStream;
17
import java.io.OutputStream;
18
import java.io.PrintWriter;
15
import java.net.URL;
19
import java.net.URL;
16
import junit.framework.Assert;
20
import junit.framework.Assert;
17
import junit.framework.AssertionFailedError;
21
import junit.framework.AssertionFailedError;
Lines 71-75 Link Here
71
    
75
    
72
    public void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL) {
76
    public void initializePlaf (Class uiClass, int uiFontSize, java.net.URL themeURL) {
73
        throw new UnsupportedOperationException();
77
        throw new UnsupportedOperationException();
78
    }
79
80
    public void cliUsage(PrintWriter printWriter) {
81
    }
82
83
    public int cli(String[] string, InputStream inputStream, OutputStream outputStream, File file) {
84
        return 0;
74
    }
85
    }
75
}
86
}
(-)utilities/build.xml (-24 lines)
Lines 12-40 Link Here
12
Microsystems, Inc. All Rights Reserved.
12
Microsystems, Inc. All Rights Reserved.
13
-->
13
-->
14
<project name="utilities" default="netbeans" basedir=".">
14
<project name="utilities" default="netbeans" basedir=".">
15
16
    <import file="../nbbuild/templates/projectized.xml"/>
15
    <import file="../nbbuild/templates/projectized.xml"/>
17
18
    <target name="compile-cli" depends="init">
19
        <mkdir dir="build/cliclasses"/>
20
        <javac srcdir="clisrc" destdir="build/cliclasses" deprecation="${build.compiler.deprecation}" debug="${build.compiler.debug}" source="1.4">
21
            <classpath path="${cp.cli}"/>
22
        </javac>
23
        <copy todir="build/cliclasses">
24
            <fileset dir="clisrc" excludesfile="../nbbuild/standard-jar-excludes.txt"/>
25
        </copy>
26
    </target>
27
28
    <target name="jar-cli" depends="init,compile-cli">
29
        <mkdir dir="${cluster}/core" />
30
        <jar jarfile="${cluster}/core/org-netbeans-modules-utilities-cli.jar"
31
             compress="false">
32
            <fileset dir="build/cliclasses"/>
33
        </jar>
34
    </target>
35
36
    <target name="compile" depends="jar-cli,projectized-common.compile"/>
37
38
    <target name="netbeans-extra" depends="jar-cli"/>
39
40
</project>
16
</project>
(-)utilities/manifest.mf (-1 / +1 lines)
Lines 4-10 Link Here
4
OpenIDE-Module-Specification-Version: 1.19
4
OpenIDE-Module-Specification-Version: 1.19
5
OpenIDE-Module-Install: org/netbeans/modules/utilities/Installer.class
5
OpenIDE-Module-Install: org/netbeans/modules/utilities/Installer.class
6
OpenIDE-Module-Layer: org/netbeans/modules/utilities/Layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/utilities/Layer.xml
7
OpenIDE-Module-Requires: org.openide.windows.IOProvider, org.openide.modules.InstalledFileLocator
7
OpenIDE-Module-Requires:  org.openide.modules.InstalledFileLocator, org.openide.windows.IOProvider
8
8
9
Name: org/netbeans/modules/url/URLDataLoader.class
9
Name: org/netbeans/modules/url/URLDataLoader.class
10
OpenIDE-Module-Class: Loader
10
OpenIDE-Module-Class: Loader
(-)utilities/nbproject/project.xml (-25 / +33 lines)
Lines 18-32 Link Here
18
            <code-name-base>org.netbeans.modules.utilities</code-name-base>
18
            <code-name-base>org.netbeans.modules.utilities</code-name-base>
19
            <module-dependencies>
19
            <module-dependencies>
20
                <dependency>
20
                <dependency>
21
                    <code-name-base>org.openide.filesystems</code-name-base>
21
                    <code-name-base>org.netbeans.api.progress</code-name-base>
22
                    <build-prerequisite/>
22
                    <build-prerequisite/>
23
                    <compile-dependency/>
23
                    <compile-dependency/>
24
                    <run-dependency>
24
                    <run-dependency>
25
                        <specification-version>6.2</specification-version>
25
                        <release-version>1</release-version>
26
                    </run-dependency>
26
                    </run-dependency>
27
                </dependency>
27
                </dependency>
28
                <dependency>
28
                <dependency>
29
                    <code-name-base>org.openide.util</code-name-base>
29
                    <code-name-base>org.netbeans.modules.sendopts</code-name-base>
30
                    <build-prerequisite/>
31
                    <compile-dependency/>
32
                    <run-dependency>
33
                        <specification-version>1.0</specification-version>
34
                    </run-dependency>
35
                </dependency>
36
                <dependency>
37
                    <code-name-base>org.openide.actions</code-name-base>
30
                    <build-prerequisite/>
38
                    <build-prerequisite/>
31
                    <compile-dependency/>
39
                    <compile-dependency/>
32
                    <run-dependency>
40
                    <run-dependency>
Lines 34-40 Link Here
34
                    </run-dependency>
42
                    </run-dependency>
35
                </dependency>
43
                </dependency>
36
                <dependency>
44
                <dependency>
37
                    <code-name-base>org.openide.modules</code-name-base>
45
                    <code-name-base>org.openide.awt</code-name-base>
38
                    <build-prerequisite/>
46
                    <build-prerequisite/>
39
                    <compile-dependency/>
47
                    <compile-dependency/>
40
                    <run-dependency>
48
                    <run-dependency>
Lines 42-48 Link Here
42
                    </run-dependency>
50
                    </run-dependency>
43
                </dependency>
51
                </dependency>
44
                <dependency>
52
                <dependency>
45
                    <code-name-base>org.openide.nodes</code-name-base>
53
                    <code-name-base>org.openide.dialogs</code-name-base>
46
                    <build-prerequisite/>
54
                    <build-prerequisite/>
47
                    <compile-dependency/>
55
                    <compile-dependency/>
48
                    <run-dependency>
56
                    <run-dependency>
Lines 58-64 Link Here
58
                    </run-dependency>
66
                    </run-dependency>
59
                </dependency>
67
                </dependency>
60
                <dependency>
68
                <dependency>
61
                    <code-name-base>org.openide.awt</code-name-base>
69
                    <code-name-base>org.openide.filesystems</code-name-base>
62
                    <build-prerequisite/>
70
                    <build-prerequisite/>
63
                    <compile-dependency/>
71
                    <compile-dependency/>
64
                    <run-dependency>
72
                    <run-dependency>
Lines 66-88 Link Here
66
                    </run-dependency>
74
                    </run-dependency>
67
                </dependency>
75
                </dependency>
68
                <dependency>
76
                <dependency>
69
                    <code-name-base>org.openide.dialogs</code-name-base>
77
                    <code-name-base>org.openide.io</code-name-base>
70
                    <build-prerequisite/>
78
                    <build-prerequisite/>
71
                    <compile-dependency/>
79
                    <compile-dependency/>
72
                    <run-dependency>
80
                    <run-dependency>
73
                        <specification-version>6.2</specification-version>
81
                        <specification-version>1.0</specification-version>
74
                    </run-dependency>
82
                    </run-dependency>
75
                </dependency>
83
                </dependency>
76
                <dependency>
84
                <dependency>
77
                    <code-name-base>org.openide.options</code-name-base>
85
                    <code-name-base>org.openide.loaders</code-name-base>
78
                    <build-prerequisite/>
86
                    <build-prerequisite/>
79
                    <compile-dependency/>
87
                    <compile-dependency/>
80
                    <run-dependency>
88
                    <run-dependency>
81
                        <specification-version>6.2</specification-version>
89
                        <specification-version>5.1</specification-version>
82
                    </run-dependency>
90
                    </run-dependency>
83
                </dependency>
91
                </dependency>
84
                <dependency>
92
                <dependency>
85
                    <code-name-base>org.openide.windows</code-name-base>
93
                    <code-name-base>org.openide.modules</code-name-base>
86
                    <build-prerequisite/>
94
                    <build-prerequisite/>
87
                    <compile-dependency/>
95
                    <compile-dependency/>
88
                    <run-dependency>
96
                    <run-dependency>
Lines 90-96 Link Here
90
                    </run-dependency>
98
                    </run-dependency>
91
                </dependency>
99
                </dependency>
92
                <dependency>
100
                <dependency>
93
                    <code-name-base>org.openide.text</code-name-base>
101
                    <code-name-base>org.openide.nodes</code-name-base>
94
                    <build-prerequisite/>
102
                    <build-prerequisite/>
95
                    <compile-dependency/>
103
                    <compile-dependency/>
96
                    <run-dependency>
104
                    <run-dependency>
Lines 98-104 Link Here
98
                    </run-dependency>
106
                    </run-dependency>
99
                </dependency>
107
                </dependency>
100
                <dependency>
108
                <dependency>
101
                    <code-name-base>org.openide.actions</code-name-base>
109
                    <code-name-base>org.openide.options</code-name-base>
102
                    <build-prerequisite/>
110
                    <build-prerequisite/>
103
                    <compile-dependency/>
111
                    <compile-dependency/>
104
                    <run-dependency>
112
                    <run-dependency>
Lines 106-143 Link Here
106
                    </run-dependency>
114
                    </run-dependency>
107
                </dependency>
115
                </dependency>
108
                <dependency>
116
                <dependency>
109
                    <code-name-base>org.openide.io</code-name-base>
117
                    <code-name-base>org.openide.text</code-name-base>
110
                    <build-prerequisite/>
118
                    <build-prerequisite/>
111
                    <compile-dependency/>
119
                    <compile-dependency/>
112
                    <run-dependency>
120
                    <run-dependency>
113
                        <specification-version>1.0</specification-version>
121
                        <specification-version>6.2</specification-version>
114
                    </run-dependency>
122
                    </run-dependency>
115
                </dependency>
123
                </dependency>
116
                <dependency>
124
                <dependency>
117
                    <code-name-base>org.openide.loaders</code-name-base>
125
                    <code-name-base>org.openide.util</code-name-base>
118
                    <build-prerequisite/>
126
                    <build-prerequisite/>
119
                    <compile-dependency/>
127
                    <compile-dependency/>
120
                    <run-dependency>
128
                    <run-dependency>
121
                        <specification-version>5.1</specification-version>
129
                        <specification-version>6.2</specification-version>
122
                    </run-dependency>
130
                    </run-dependency>
123
                </dependency>
131
                </dependency>
124
                <dependency>
132
                <dependency>
125
                    <code-name-base>org.openidex.util</code-name-base>
133
                    <code-name-base>org.openide.windows</code-name-base>
126
                    <build-prerequisite/> 
134
                    <build-prerequisite/>
127
                    <compile-dependency/>
135
                    <compile-dependency/>
128
                    <run-dependency>
136
                    <run-dependency>
129
                        <release-version>3</release-version>
137
                        <specification-version>6.2</specification-version>
130
                        <specification-version>3.3</specification-version>
131
                    </run-dependency>
138
                    </run-dependency>
132
                </dependency>                      
139
                </dependency>
133
                <dependency>
140
                <dependency>
134
                    <code-name-base>org.netbeans.api.progress</code-name-base>
141
                    <code-name-base>org.openidex.util</code-name-base>
135
                    <build-prerequisite/>
142
                    <build-prerequisite/>
136
                    <compile-dependency/>
143
                    <compile-dependency/>
137
                    <run-dependency>
144
                    <run-dependency>
138
                        <release-version>1</release-version>
145
                        <release-version>3</release-version>
146
                        <specification-version>3.3</specification-version>
139
                    </run-dependency>
147
                    </run-dependency>
140
                </dependency>          
148
                </dependency>
141
            </module-dependencies>
149
            </module-dependencies>
142
            <public-packages>
150
            <public-packages>
143
                <!-- friend API - used by Utilities/Project -->
151
                <!-- friend API - used by Utilities/Project -->
(-)utilities/src/META-INF/services/org.netbeans.modules.openfile.cli.Callback (-1 lines)
Removed Link Here
1
org.netbeans.modules.openfile.CallbackImpl
(-)utilities/src/META-INF/services/org.netbeans.spi.sendopts.OptionProvider (+1 lines)
Added Link Here
1
org.netbeans.modules.openfile.OptProvider
(-)utilities/src/org/netbeans/modules/openfile/CallbackImpl.java (-34 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.openfile;
15
16
import java.io.File;
17
import org.netbeans.modules.openfile.cli.Callback;
18
19
/**
20
 * Provides module functionality to CLI handler.
21
 * @author Jesse Glick
22
 */
23
public class CallbackImpl implements Callback {
24
    
25
    /**
26
     * A default instance.
27
     */
28
    public CallbackImpl() {}
29
    
30
    public boolean open(File f, int line, Callback.Waiter waiter) {
31
        return OpenFile.openFile(f, line, waiter);
32
    }
33
    
34
}
(-)utilities/src/org/netbeans/modules/openfile/DefaultOpenFileImpl.java (-2 / +1 lines)
Lines 26-32 Link Here
26
import javax.swing.SwingUtilities;
26
import javax.swing.SwingUtilities;
27
import javax.swing.text.Element;
27
import javax.swing.text.Element;
28
import javax.swing.text.StyledDocument;
28
import javax.swing.text.StyledDocument;
29
import org.netbeans.modules.openfile.cli.Callback;
30
import org.openide.DialogDisplayer;
29
import org.openide.DialogDisplayer;
31
import org.openide.ErrorManager;
30
import org.openide.ErrorManager;
32
import org.openide.NotifyDescriptor;
31
import org.openide.NotifyDescriptor;
Lines 415-421 Link Here
415
     * (or {@link OpenCookie} or {@link ViewCookie}),
414
     * (or {@link OpenCookie} or {@link ViewCookie}),
416
     * or by showing it in the Explorer.
415
     * or by showing it in the Explorer.
417
     */
416
     */
418
    public boolean open(final FileObject fileObject, int line, Callback.Waiter waiter) {
417
    public boolean open(final FileObject fileObject, int line, Object waiter) {
419
418
420
        String fileName = fileObject.getNameExt();
419
        String fileName = fileObject.getNameExt();
421
                  
420
                  
(-)utilities/src/org/netbeans/modules/openfile/OpenFile.java (-2 / +1 lines)
Lines 14-20 Link Here
14
package org.netbeans.modules.openfile;
14
package org.netbeans.modules.openfile;
15
15
16
import java.io.File;
16
import java.io.File;
17
import org.netbeans.modules.openfile.cli.Callback;
18
17
19
import org.openide.DialogDisplayer;
18
import org.openide.DialogDisplayer;
20
import org.openide.NotifyDescriptor;
19
import org.openide.NotifyDescriptor;
Lines 66-72 Link Here
66
     * @return true on success, false on failure
65
     * @return true on success, false on failure
67
     * @usecase CallbackImpl, OpenFileAction
66
     * @usecase CallbackImpl, OpenFileAction
68
     */
67
     */
69
    static boolean openFile(File file, int line, Callback.Waiter waiter) {
68
    static boolean openFile(File file, int line, Object waiter) {
70
        if (!checkFileExists(file)) {
69
        if (!checkFileExists(file)) {
71
            return false;
70
            return false;
72
        }
71
        }
(-)utilities/src/org/netbeans/modules/openfile/OpenFileImpl.java (-2 / +1 lines)
Lines 17-23 Link Here
17
17
18
import org.openide.filesystems.FileObject;
18
import org.openide.filesystems.FileObject;
19
19
20
import org.netbeans.modules.openfile.cli.Callback;
21
20
22
/**
21
/**
23
 * Interface for Open File implementations.
22
 * Interface for Open File implementations.
Lines 46-51 Link Here
46
     * @param waiter if not null, tell the waiter when the file is closed
45
     * @param waiter if not null, tell the waiter when the file is closed
47
     * @return true on success, false on failure
46
     * @return true on success, false on failure
48
     */
47
     */
49
    boolean open(FileObject fileObject, int line, Callback.Waiter waiter);
48
    boolean open(FileObject fileObject, int line, Object waiter);
50
49
51
}
50
}
(-)utilities/src/org/netbeans/modules/openfile/OptProvider.java (+102 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.openfile;
15
16
import java.io.File;
17
import java.io.PrintWriter;
18
import org.netbeans.spi.sendopts.AdditionalArgumentsProcessor;
19
import org.netbeans.spi.sendopts.Env;
20
import org.netbeans.spi.sendopts.Option;
21
import org.netbeans.spi.sendopts.OptionProvider;
22
import org.openide.util.Lookup;
23
24
/**
25
 * A sendopts provider for Open File.
26
 * @author Jaroslav Tulach
27
 */
28
public class OptProvider implements OptionProvider, AdditionalArgumentsProcessor {
29
    /** option to open the file */
30
    private Option open;
31
    
32
    /**
33
     * Create the provider.
34
     */
35
    public OptProvider() {
36
        open = Option.additionalArguments((char)-1, "open", this); // NOI18N
37
    }
38
39
    public Option[] getOptions() {
40
        return new Option[] { open };
41
    }
42
    
43
    private File findFile (File curDir, String name) {
44
        File f = new File(name);
45
        if (!f.isAbsolute()) {
46
            f = new File(curDir, name);
47
        }
48
        return f;
49
    }
50
    
51
    private int openFile (File curDir, Env args, String[] argv, int i) {
52
        String s = argv[i];
53
        if (s == null) {
54
            log("Missing argument to --open", args);
55
            return 2;
56
        }
57
        argv[i] = null;
58
        int line = -1;
59
        File f = findFile (curDir, s);
60
        if (!f.exists()) {
61
            // Check if it is 1file:line syntax.
62
            int idx = s.lastIndexOf(':'); // NOI18N
63
            if (idx != -1) {
64
                try {
65
                    line = Integer.parseInt(s.substring(idx + 1)) - 1;
66
                    f = findFile (curDir, s.substring(0, idx));
67
                } catch (NumberFormatException e) {
68
                    // OK, leave as a filename
69
                }
70
            }
71
        }
72
        // Just make sure it was opened, then exit.
73
        boolean success = OpenFile.openFile(f, line, null);
74
        return success ? 0 : 1;
75
    }
76
    
77
78
    public void process(Option option, Env env, String[] argv) throws org.netbeans.api.sendopts.CommandException {
79
        File curDir = env.getCurrentDirectory ();
80
        for (int i = 0; i < argv.length; i++) {
81
            int res = openFile (curDir, env, argv, i++);
82
            if (res != 0) {
83
                throw org.netbeans.api.sendopts.CommandException.exitCode(res);
84
            }
85
        }
86
    }
87
    
88
    private static void log(String msg, Env args) {
89
        PrintWriter w = new PrintWriter(args.getOutputStream());
90
        w.println(msg);
91
        w.flush();
92
        // don't close however - might be another user
93
    }
94
    
95
    protected void usage(PrintWriter w) {
96
        w.println("OpenFile module options:");
97
        w.println("  --open FILE           open FILE.");
98
        w.println("  --open FILE:LINE      open FILE at line LINE (starting from 1).");
99
        w.println("");
100
    }
101
102
}

Return to bug 57611