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.

Bug 113903 - netbeans --open doesn't work on the Mac
Summary: netbeans --open doesn't work on the Mac
Status: RESOLVED WORKSFORME
Alias: None
Product: utilities
Classification: Unclassified
Component: Open File (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Andrey Yamkovoy
URL:
Keywords:
: 117768 144593 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-08-27 21:23 UTC by Torbjorn Norbye
Modified: 2009-05-25 21:06 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2007-08-27 21:23:42 UTC
I've tried

netbeans --open /tmp/foo.txt

(and foo.java etc.).  The IDE fronts, but the file doesn't open. From then on, the IDE is hosed; the menus still work,
and the event dispatch thread appears to be normal, but the editor explorer windows won't accept any key clicks; they
won't accept focus etc.

It seems to work fine on Linux. (This is with a fresh build as of today, Aug 27).
Comment 1 Antonin Nebuzelsky 2007-08-28 10:32:40 UTC
Milosi, can you reproduce on your Mac?
Comment 2 Milos Kleint 2007-08-28 11:58:41 UTC
It seems to behave as tor described. However it seems like i'm getting the clicks through. 
After issue-ing the --open command, I tried clicking the tabs. Nothing changed visually in the window, but the OS window
label seemed to reflect the changes in global selection and updated the title.

A workaround for the issue is to resize the main window. Then everything starts repainting and the actual file that was
opened this way appears.
Most probably an issue with apple's JDK.

-> P3
Comment 3 Milos Kleint 2007-10-22 09:32:24 UTC
I've tried on my linux box and it actually shows the same signs as on macosx. The window system doesn't repaint and one
has to resize the main window to actually see the opened file tab.

reassigning to utilities. it doesn't look like it's related to macosx.
Comment 4 Marian Petras 2007-10-22 09:51:11 UTC
*** Issue 117768 has been marked as a duplicate of this issue. ***
Comment 5 Marian Petras 2007-10-22 09:53:24 UTC
This might be a threading issue, possible related to bug #61996.
Comment 6 Marian Petras 2008-04-21 17:02:12 UTC
Tor, can you reproduce this bug in some recent build of NetBeans? I tried it several times both on Linux and on MacOS X
and it worked. I also looked into the source code and found nothing suspicious.

If you can reproduce it, I would like to know whether you also specified the line number on the command line (e.g.
netbeans --open /tmp/foo.txt:14).
Comment 7 Torbjorn Norbye 2008-04-21 18:48:01 UTC
Yes, I still see the problem - this time on OSX Leopard (when I first filed it, I was on OSX Tiger).

There are several other people on the CC - can any of you reproduce this too?

I open up NetBeans, with a terminal in front of it. In the terminal I did netbeans --userdir <myuserdir> --open
localfile (where the localfile is a file without a path prefix, in the current directory).

The first time I did it, I didn't think it worked - because the NetBeans window did not front (and I had many other
windows on top of it).   I think --open should force the window to front.

The second time I fronted the NetBeans window and then put the terminal window on top of it (but I could see the editor
area). I repeated it again - and this time nothing appeared to happen. I fronted the window - still nothing. Then I
resized the window, and immediately the new tab appeared.
Comment 8 Marian Petras 2008-04-22 08:42:56 UTC
I can reproduce it now (on Mac OS X).
Comment 9 Marian Petras 2008-04-22 08:45:24 UTC
It works if 'netbeans --open <file>' is used for starting a new instance of NetBeans.
It fails if 'netbeans --open <file>' just opens the file in an already running instance.
Comment 10 Marian Petras 2008-04-23 17:18:23 UTC
This bug is really strange. When some routine for opening file is initiated while handling the command-line arguments,
it does not work (until the IDE's main window is resized). If the same routine is initiated directly from the IDE, e.g.
by pressing a toolbar button, it works.

To confirm this, I created a simple test in class org.netbeans.modules.openfile.Handler, which handles the command-line
argument "--open <filename>":

    protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                openFoo();
            }
        });
    }

    public static void openFoo() {
        System.out.println("called openFoo()");
        FileObject fileObject = FileUtil.toFileObject(new File("/tmp/foo.txt"));
        DataObject dataObj;
        try {
            dataObj = DataObject.find(fileObject);
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
            return;
        }
        Node node = dataObj.getNodeDelegate();
        Action action = ((ContextAwareAction) node.getPreferredAction())
                        .createContextAwareInstance(Lookups.singleton(node));
        action.actionPerformed(new ActionEvent(node, 0, ""));                                 
    }

When call of openFoo() is initiated by the handler, it does not work - you will see the symptoms described in this bug
report.

For testing purposes, I created a very simple action and put it to the IDE toolbar:

public final class TestAction extends CallableSystemAction {

    public void performAction() {
        assert EventQueue.isDispatchThread();
        Handler.openFoo();
    }

    //here are other methods, like getName(), iconResource(), etc.

}

When openFoo() is called from this action, a new tab appears in the IDE - immediately!

In both cases, openFoo() is called from the event-dispatching thread. When the call is initiated from the command-line
handler, the tab does not appear until the main window is resized. When the same call is initiated from some UI action,
the tab appears immediately.

I have no idea what is wrong. Yarda, could you shed some light on this mystery? Keep in mind that this is 100%
reproducible on MacOS X but hardly reproducible on other systems.
Comment 11 Milos Kleint 2008-08-26 19:55:03 UTC
*** Issue 144593 has been marked as a duplicate of this issue. ***
Comment 12 richpoirier 2008-08-30 02:28:58 UTC
Any progress on this bug? I can still reproduce it on Mac OS 10.5 in the latest nightly build. I've patched RSpactor to
open files in Netbeans (http://github.com/richpoirier/rspactor/tree/master) but I always have to hit
command+shift+return to "unfreeze" the window after opening a file. Not having to do this would be awesome :)
Comment 13 Alexey Butenko 2009-04-01 15:33:48 UTC
I've tried with recent build in Leopard.
And with new instance it is working OK.
When netbeans already opened, new window opened when bring IDE to the front.
Comment 14 Alexey Butenko 2009-04-01 15:35:57 UTC
So in my opinion it is become duplicate of 61996
Comment 15 Alexey Butenko 2009-04-02 12:42:03 UTC
Discussed with Andrey and agree that this issue is not duplicate of 61996, because initial issue was that IDE fronts, but file doesn't open.
Since on recent build it is working I'm closing it as WORKSFORME. Please verify and reopen if necessary.