[openide-dev] how to open a TopComponent without making it active

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[openide-dev] how to open a TopComponent without making it active

Luan O'Carroll-3
Is it possible to open a TopComponent without making it active?

When opening a particular file type I open a number of other supporting
files within the editor but the new files become active and grab the
focus. I would like to prevent them doing so or at least make the 'main'
window active.

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active

Ayub Khan
comments inline...

Luan O'Carroll wrote:

> Is it possible to open a TopComponent without making it active?
>
> When opening a particular file type I open a number of other
> supporting files within the editor but the new files become active and
> grab the focus. I would like to prevent them doing so or at least make
> the 'main' window active.

to make main window active (if that main window diplayname can be
identified from rest)

        String tcName="MyMainWindow";
        TopComponent.Registry reg = TopComponent.getRegistry();
        Set opened=reg.getOpened();
        for (Iterator it = opened.iterator(); it.hasNext(); ) {
            TopComponent tc = (TopComponent)it.next();
            String displayName=tc.getDisplayName();
            if (displayName!=null && displayName.contains(tcName) )
                tc.open();
            }
        }
Thanks
Ayub

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active - correction

Ayub Khan
correction...

       String tcName="MyMainWindow";
       TopComponent.Registry reg = TopComponent.getRegistry();
       Set opened=reg.getOpened();
       for (Iterator it = opened.iterator(); it.hasNext(); ) {
           TopComponent tc = (TopComponent)it.next();
           String displayName=tc.getDisplayName();
           if (displayName!=null && displayName.contains(tcName))
               tc.requestActive();    <--- correction here, I meant
requestActive() instead of open()
           }
       }

Ayub Khan wrote:

> comments inline...
>
> Luan O'Carroll wrote:
>
>> Is it possible to open a TopComponent without making it active?
>>
>> When opening a particular file type I open a number of other
>> supporting files within the editor but the new files become active
>> and grab the focus. I would like to prevent them doing so or at least
>> make the 'main' window active.
>
>
> to make main window active (if that main window diplayname can be
> identified from rest)
>
>        String tcName="MyMainWindow";
>        TopComponent.Registry reg = TopComponent.getRegistry();
>        Set opened=reg.getOpened();
>        for (Iterator it = opened.iterator(); it.hasNext(); ) {
>            TopComponent tc = (TopComponent)it.next();
>            String displayName=tc.getDisplayName();
>            if (displayName!=null && displayName.contains(tcName) )
>                tc.open();
>            }
>        }
> Thanks
> Ayub
>

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active - correction

Luan O'Carroll-3
Thanks Ayub,

But my problem isn't getting a reference to the TopComponent, it's more
of a timing issue.

When the 'main' component is opened it is active but as part of the
opening process other windows are open and later become active. If  I
call requestActive during this process then it has no effect as the
'main' component is already active.

Part of my problem may be that this opening of other files is initiated
in the 'main' component's componentActivated method. I guess I could
spawn a background thread and have it call requestActive but I don't
know when the other files have finished their process of opening and
grabbing focus.

-Luan


Ayub Khan wrote:

> correction...
>
>       String tcName="MyMainWindow";
>       TopComponent.Registry reg = TopComponent.getRegistry();
>       Set opened=reg.getOpened();
>       for (Iterator it = opened.iterator(); it.hasNext(); ) {
>           TopComponent tc = (TopComponent)it.next();
>           String displayName=tc.getDisplayName();
>           if (displayName!=null && displayName.contains(tcName))
>               tc.requestActive();    <--- correction here, I meant
> requestActive() instead of open()
>           }
>       }
>
> Ayub Khan wrote:
>
>> comments inline...
>>
>> Luan O'Carroll wrote:
>>
>>> Is it possible to open a TopComponent without making it active?
>>>
>>> When opening a particular file type I open a number of other
>>> supporting files within the editor but the new files become active
>>> and grab the focus. I would like to prevent them doing so or at
>>> least make the 'main' window active.
>>
>>
>>
>> to make main window active (if that main window diplayname can be
>> identified from rest)
>>
>>        String tcName="MyMainWindow";
>>        TopComponent.Registry reg = TopComponent.getRegistry();
>>        Set opened=reg.getOpened();
>>        for (Iterator it = opened.iterator(); it.hasNext(); ) {
>>            TopComponent tc = (TopComponent)it.next();
>>            String displayName=tc.getDisplayName();
>>            if (displayName!=null && displayName.contains(tcName) )
>>                tc.open();
>>            }
>>        }
>> Thanks
>> Ayub
>>
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active - correction

Ayub Khan
comments inline..

Luan O'Carroll wrote:

> Thanks Ayub,
>
> But my problem isn't getting a reference to the TopComponent, it's
> more of a timing issue.
>
> When the 'main' component is opened it is active but as part of the
> opening process other windows are open and later become active. If  I
> call requestActive during this process then it has no effect as the
> 'main' component is already active.
>
> Part of my problem may be that this opening of other files is
> initiated in the 'main' component's componentActivated method. I guess
> I could spawn a background thread and have it call requestActive but I
> don't know when the other files have finished their process of opening
> and grabbing focus.

//Trick is to queue up process using SwingUtilities.invokeLater(). This
guarantees sequencing of operations (atleast what I
//have understood from the past experience

public class MyMainClass{              

public void openMainWindow(){

//I don't know how you open all windows. I am assuming that all your
files that
//are grouped by a Custom DataObjectLoader. So invoking ec.open does
open all. I may be wrong.
//Anyway this is just an illustration how all these might be synchronized
SwingUtilities.invokeLater(
                    new Runnable()
                    {
                        public void run()
                        {
                               DataObject d=DataObject.find(fo);
                               EditorCookie ec=d.getEditorCookie();
                               ec.open();
                        }
                    }
);
                 
//Now request active main window
SwingUtilities.invokeLater(
                    new Runnable()
                    {
                        public void run()
                        {
                             String tcName="MyMainWindow";
                             TopComponent.Registry reg =
TopComponent.getRegistry();
                             Set opened=reg.getOpened();
                             for (Iterator it = opened.iterator();
it.hasNext(); ) {
                                   TopComponent tc =
(TopComponent)it.next();
                                   String displayName=tc.getDisplayName();
                                   if (displayName!=null &&
displayName.contains(tcName))
                                         tc.requestActive();
                             }
                        }
                    }
);

}
}

>
>
> -Luan
>
>
> Ayub Khan wrote:
>
>> correction...
>>
>>       String tcName="MyMainWindow";
>>       TopComponent.Registry reg = TopComponent.getRegistry();
>>       Set opened=reg.getOpened();
>>       for (Iterator it = opened.iterator(); it.hasNext(); ) {
>>           TopComponent tc = (TopComponent)it.next();
>>           String displayName=tc.getDisplayName();
>>           if (displayName!=null && displayName.contains(tcName))
>>               tc.requestActive();    <--- correction here, I meant
>> requestActive() instead of open()
>>           }
>>       }
>>
>> Ayub Khan wrote:
>>
>>> comments inline...
>>>
>>> Luan O'Carroll wrote:
>>>
>>>> Is it possible to open a TopComponent without making it active?
>>>>
>>>> When opening a particular file type I open a number of other
>>>> supporting files within the editor but the new files become active
>>>> and grab the focus. I would like to prevent them doing so or at
>>>> least make the 'main' window active.
>>>
>>>
>>>
>>>
>>> to make main window active (if that main window diplayname can be
>>> identified from rest)
>>>
>>>        String tcName="MyMainWindow";
>>>        TopComponent.Registry reg = TopComponent.getRegistry();
>>>        Set opened=reg.getOpened();
>>>        for (Iterator it = opened.iterator(); it.hasNext(); ) {
>>>            TopComponent tc = (TopComponent)it.next();
>>>            String displayName=tc.getDisplayName();
>>>            if (displayName!=null && displayName.contains(tcName) )
>>>                tc.open();
>>>            }
>>>        }
>>> Thanks
>>> Ayub
>>>
>>
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active - correction

Luan O'Carroll-3
That's pretty much what I have....


public class MyClass extends CloneableTopComponent
{
  public void componentActivated()
  {
          // Check some stuff
         
          // Open some other files....
          SwingUtilities.invokeLater(
                   new Runnable()
                   {
                       public void run()
                       {
                              DataObject d=DataObject.find(fo);
                              EditorCookie ec=d.getEditorCookie();
                              ec.open();
                       }
                   }
           );
           //Now request active main window
           SwingUtilities.invokeLater(
                   new Runnable()
                   {
                       public void run()
                       {
                            requestActive();
                        }
                   }
           }
}

But it doesn't seem to work. If I put breakpoints at various points in
the code I can see that the EditorCookie.open doesn't update the UI
immediately so I guess that the SwingUtilities.invoke later stuff gets
processed before the EditorCookie finishes its update?

Luan

Ayub Khan wrote:

> comments inline..
>
> Luan O'Carroll wrote:
>
>> Thanks Ayub,
>>
>> But my problem isn't getting a reference to the TopComponent, it's
>> more of a timing issue.
>>
>> When the 'main' component is opened it is active but as part of the
>> opening process other windows are open and later become active. If  I
>> call requestActive during this process then it has no effect as the
>> 'main' component is already active.
>>
>> Part of my problem may be that this opening of other files is
>> initiated in the 'main' component's componentActivated method. I
>> guess I could spawn a background thread and have it call
>> requestActive but I don't know when the other files have finished
>> their process of opening and grabbing focus.
>
>
> //Trick is to queue up process using SwingUtilities.invokeLater().
> This guarantees sequencing of operations (atleast what I
> //have understood from the past experience
>
> public class MyMainClass{            
> public void openMainWindow(){
>
> //I don't know how you open all windows. I am assuming that all your
> files that
> //are grouped by a Custom DataObjectLoader. So invoking ec.open does
> open all. I may be wrong.
> //Anyway this is just an illustration how all these might be synchronized
> SwingUtilities.invokeLater(
>                    new Runnable()
>                    {
>                        public void run()
>                        {
>                               DataObject d=DataObject.find(fo);
>                               EditorCookie ec=d.getEditorCookie();
>                               ec.open();
>                        }
>                    }
> );
>                  //Now request active main window
> SwingUtilities.invokeLater(
>                    new Runnable()
>                    {
>                        public void run()
>                        {
>                             String tcName="MyMainWindow";
>                             TopComponent.Registry reg =
> TopComponent.getRegistry();
>                             Set opened=reg.getOpened();
>                             for (Iterator it = opened.iterator();
> it.hasNext(); ) {
>                                   TopComponent tc =
> (TopComponent)it.next();
>                                   String displayName=tc.getDisplayName();
>                                   if (displayName!=null &&
> displayName.contains(tcName))
>                                         tc.requestActive();
>                             }
>                        }
>                    }
> );
>
> }
> }



Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active -another approach

Ayub Khan
public class MyClass extends CloneableTopComponent
{

    int totalFileCount=0;
    int count=0;
     public void componentActivated()
     {
        // Check some stuff
        // Open some other files....

        DataObject d=DataObject.find(fo);
       
        //estimate how may windows (useful only if total #files = tatal
#windows)
        Set files=d.files();
        if(files!=null)
            totalFileCount=files.size();

        //add PropertyChangeListener              
        EditorCookie.Observable eoc = (EditorCookie.Observable)
            d.getCookie(EditorCookie.Observable.class);
        if(eoc!=null)        
            eoc.addPropertyChangeListener(this);

        //now open editor          
        EditorCookie ec=d.getEditorCookie();
        ec.open();
    }


    /**
    * propertyChange
    *
    * @param    event
    */
    public void propertyChange(PropertyChangeEvent event)
    {
        if
(EditorCookie.Observable.PROP_OPENED_PANES.equals(event.getPropertyName()))
        {
            count++;
            if(count==totalFileCount) //done opening editor panes
            {
               requestActive();
               count=0;
            }
        }
    }                            
}

Thanks
Ayub


Luan O'Carroll wrote:

> That's pretty much what I have....
>
>
> public class MyClass extends CloneableTopComponent
> {
>  public void componentActivated()
>  {
>          // Check some stuff
>                  // Open some other files....
>          SwingUtilities.invokeLater(
>                   new Runnable()
>                   {
>                       public void run()
>                       {
>                              DataObject d=DataObject.find(fo);
>                              EditorCookie ec=d.getEditorCookie();
>                              ec.open();
>                       }
>                   }
>           );
>           //Now request active main window
>           SwingUtilities.invokeLater(
>                   new Runnable()
>                   {
>                       public void run()
>                       {
>                            requestActive();
>                        }
>                   }
>           }
> }
>
> But it doesn't seem to work. If I put breakpoints at various points in
> the code I can see that the EditorCookie.open doesn't update the UI
> immediately so I guess that the SwingUtilities.invoke later stuff gets
> processed before the EditorCookie finishes its update?
>
> Luan
>
> Ayub Khan wrote:
>
>> comments inline..
>>
>> Luan O'Carroll wrote:
>>
>>> Thanks Ayub,
>>>
>>> But my problem isn't getting a reference to the TopComponent, it's
>>> more of a timing issue.
>>>
>>> When the 'main' component is opened it is active but as part of the
>>> opening process other windows are open and later become active. If  
>>> I call requestActive during this process then it has no effect as
>>> the 'main' component is already active.
>>>
>>> Part of my problem may be that this opening of other files is
>>> initiated in the 'main' component's componentActivated method. I
>>> guess I could spawn a background thread and have it call
>>> requestActive but I don't know when the other files have finished
>>> their process of opening and grabbing focus.
>>
>>
>>
>> //Trick is to queue up process using SwingUtilities.invokeLater().
>> This guarantees sequencing of operations (atleast what I
>> //have understood from the past experience
>>
>> public class MyMainClass{             public void openMainWindow(){
>>
>> //I don't know how you open all windows. I am assuming that all your
>> files that
>> //are grouped by a Custom DataObjectLoader. So invoking ec.open does
>> open all. I may be wrong.
>> //Anyway this is just an illustration how all these might be
>> synchronized
>> SwingUtilities.invokeLater(
>>                    new Runnable()
>>                    {
>>                        public void run()
>>                        {
>>                               DataObject d=DataObject.find(fo);
>>                               EditorCookie ec=d.getEditorCookie();
>>                               ec.open();
>>                        }
>>                    }
>> );
>>                  //Now request active main window
>> SwingUtilities.invokeLater(
>>                    new Runnable()
>>                    {
>>                        public void run()
>>                        {
>>                             String tcName="MyMainWindow";
>>                             TopComponent.Registry reg =
>> TopComponent.getRegistry();
>>                             Set opened=reg.getOpened();
>>                             for (Iterator it = opened.iterator();
>> it.hasNext(); ) {
>>                                   TopComponent tc =
>> (TopComponent)it.next();
>>                                   String
>> displayName=tc.getDisplayName();
>>                                   if (displayName!=null &&
>> displayName.contains(tcName))
>>                                         tc.requestActive();
>>                             }
>>                        }
>>                    }
>> );
>>
>> }
>> }
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active - correction

Marek Slama
In reply to this post by Luan O'Carroll-3
Luan O'Carroll wrote:

> Thanks Ayub,
>
> But my problem isn't getting a reference to the TopComponent, it's
> more of a timing issue.
>
> When the 'main' component is opened it is active but as part of the
> opening process other windows are open and later become active. If  I
> call requestActive during this process then it has no effect as the
> 'main' component is already active.
>
> Part of my problem may be that this opening of other files is
> initiated in the 'main' component's componentActivated method. I guess
> I could spawn a background thread and have it call requestActive but I
> don't know when the other files have finished their process of opening
> and grabbing focus.
>
> -Luan
>
>
> Ayub Khan wrote:
>
>> correction...
>>
>>       String tcName="MyMainWindow";
>>       TopComponent.Registry reg = TopComponent.getRegistry();
>>       Set opened=reg.getOpened();
>>       for (Iterator it = opened.iterator(); it.hasNext(); ) {
>>           TopComponent tc = (TopComponent)it.next();
>>           String displayName=tc.getDisplayName();
>>           if (displayName!=null && displayName.contains(tcName))
>>               tc.requestActive();    <--- correction here, I meant
>> requestActive() instead of open()
>>           }
>>       }
>>
>> Ayub Khan wrote:
>>
>>> comments inline...
>>>
>>> Luan O'Carroll wrote:
>>>
>>>> Is it possible to open a TopComponent without making it active?
>>>>
>>>> When opening a particular file type I open a number of other
>>>> supporting files within the editor but the new files become active
>>>> and grab the focus. I would like to prevent them doing so or at
>>>> least make the 'main' window active.
>>>
>>>
I think the easiest solution is to call open on 'support' files first
and then open 'main' component if possible. I do not think it is possible
to open component without activating it.

Marek.

>>>
>>>
>>> to make main window active (if that main window diplayname can be
>>> identified from rest)
>>>
>>>        String tcName="MyMainWindow";
>>>        TopComponent.Registry reg = TopComponent.getRegistry();
>>>        Set opened=reg.getOpened();
>>>        for (Iterator it = opened.iterator(); it.hasNext(); ) {
>>>            TopComponent tc = (TopComponent)it.next();
>>>            String displayName=tc.getDisplayName();
>>>            if (displayName!=null && displayName.contains(tcName) )
>>>                tc.open();
>>>            }
>>>        }
>>> Thanks
>>> Ayub
>>>
>>
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

[openide-dev] Re: how to open a TopComponent without making it active - correction

Tim Boudreau
Marek Slama wrote:
> I think the easiest solution is to call open on 'support' files first
> and then open 'main' component if possible. I do not think it is possible
> to open component without activating it.

This was not correct, at least the last time I demoed it.  In one of the
tutorials on module building that I do, in the first step we just call
OurNewTopComponent.open(), and then later I have the students add the
call to requestActive().  Without it, the tab is added but neither
fronted nor activated.

open() should do what it says and no more;  the same with
requestVisible(), the same with requestActive().  If this has changed
recently, that's a bug.

It's entirely possible for a TC to do something on its own, like
override its open() method to call requestActive() or to summarily
requestFocus() on some component inside it - but a vanilla TopComponent
should not do anything of the sort.

-Tim

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] Re: how to open a TopComponent without making it active - correction

Marek Slama
Tim Boudreau wrote:

> Marek Slama wrote:
>
>> I think the easiest solution is to call open on 'support' files first
>> and then open 'main' component if possible. I do not think it is
>> possible
>> to open component without activating it.
>
>
> This was not correct, at least the last time I demoed it.  In one of
> the tutorials on module building that I do, in the first step we just
> call OurNewTopComponent.open(), and then later I have the students add
> the call to requestActive().  Without it, the tab is added but neither
> fronted nor activated.
>
> open() should do what it says and no more;  the same with
> requestVisible(), the same with requestActive().  If this has changed
> recently, that's a bug.
>
> It's entirely possible for a TC to do something on its own, like
> override its open() method to call requestActive() or to summarily
> requestFocus() on some component inside it - but a vanilla
> TopComponent should not do anything of the sort.
>
> -Tim
>
In such case it is possible that components you are opening overwrite
TC.open() to activate themselves. I think some window system developer
should give us exact info how it works now.

Marek.
Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] how to open a TopComponent without making it active -another approach

Luan O'Carroll-3
In reply to this post by Ayub Khan
Thanks again,

I tried that to no effect. I even put the requestActive and a
requestVisible call into a background thread called 10 seconds later
just to see what would happen but to no effect.

For now I've managed to suppress the problem by changing the behavior :-(

Luan

Ayub Khan wrote:

> public class MyClass extends CloneableTopComponent
> {
>
>    int totalFileCount=0;
>    int count=0;
>     public void componentActivated()
>     {
>        // Check some stuff
>        // Open some other files....
>
>        DataObject d=DataObject.find(fo);
>              //estimate how may windows (useful only if total #files =
> tatal #windows)
>        Set files=d.files();
>        if(files!=null)
>            totalFileCount=files.size();
>
>        //add PropertyChangeListener                      
> EditorCookie.Observable eoc = (EditorCookie.Observable)
>            d.getCookie(EditorCookie.Observable.class);
>        if(eoc!=null)                    
> eoc.addPropertyChangeListener(this);
>
>        //now open editor                 EditorCookie
> ec=d.getEditorCookie();
>        ec.open();
>    }
>
>
>    /**
>    * propertyChange
>    *
>    * @param    event
>    */
>    public void propertyChange(PropertyChangeEvent event)
>    {
>        if
> (EditorCookie.Observable.PROP_OPENED_PANES.equals(event.getPropertyName()))
>
>        {
>            count++;
>            if(count==totalFileCount) //done opening editor panes
>            {
>               requestActive();
>               count=0;
>            }
>        }
>    }                            }
>
> Thanks
> Ayub
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] Re: how to open a TopComponent without making it active - correction

Luan O'Carroll-3
In reply to this post by Tim Boudreau
Tim Boudreau wrote:

> Marek Slama wrote:
>
>> I think the easiest solution is to call open on 'support' files first
>> and then open 'main' component if possible. I do not think it is
>> possible
>> to open component without activating it.
>
>
> This was not correct, at least the last time I demoed it.  In one of
> the tutorials on module building that I do, in the first step we just
> call OurNewTopComponent.open(), and then later I have the students add
> the call to requestActive().  Without it, the tab is added but neither
> fronted nor activated.
>
> open() should do what it says and no more;  the same with
> requestVisible(), the same with requestActive().  If this has changed
> recently, that's a bug.
>
> It's entirely possible for a TC to do something on its own, like
> override its open() method to call requestActive() or to summarily
> requestFocus() on some component inside it - but a vanilla
> TopComponent should not do anything of the sort.
>
> -Tim
>
>
>
>
The behavior seems to be ok when the TopComponent is first opened but
not when I close one of the 'other' windows and my 'main' window becomes
active again. I've scanned my code for calls to requestActive and
requestVisible but no such instances are called to activate the 'other'
window, there's just the call to EditorCookie.open as far as I can tell.

Of course it's entirely possible that there is a bug in my code but I
don't see anything reported in the log file. For test purposes I tried
creating a background thread to activate the window by calling  request
active after a few seconds but it had no effect.

Is there any way I can debug this to see what is going on with the
requestActive call?

-Luan

Reply | Threaded
Open this post in threaded view
|

Re: [openide-dev] Re: how to open a TopComponent without making it active - correction

Marek Slama
Luan O'Carroll wrote:

> Tim Boudreau wrote:
>
>> Marek Slama wrote:
>>
>>> I think the easiest solution is to call open on 'support' files
>>> first and then open 'main' component if possible. I do not think it
>>> is possible
>>> to open component without activating it.
>>
>>
>>
>> This was not correct, at least the last time I demoed it.  In one of
>> the tutorials on module building that I do, in the first step we just
>> call OurNewTopComponent.open(), and then later I have the students
>> add the call to requestActive().  Without it, the tab is added but
>> neither fronted nor activated.
>>
>> open() should do what it says and no more;  the same with
>> requestVisible(), the same with requestActive().  If this has changed
>> recently, that's a bug.
>>
>> It's entirely possible for a TC to do something on its own, like
>> override its open() method to call requestActive() or to summarily
>> requestFocus() on some component inside it - but a vanilla
>> TopComponent should not do anything of the sort.
>>
>> -Tim
>>
>>
>>
>>
> The behavior seems to be ok when the TopComponent is first opened but
> not when I close one of the 'other' windows and my 'main' window
> becomes active again. I've scanned my code for calls to requestActive
> and requestVisible but no such instances are called to activate the
> 'other' window, there's just the call to EditorCookie.open as far as I
> can tell.
>
> Of course it's entirely possible that there is a bug in my code but I
> don't see anything reported in the log file. For test purposes I tried
> creating a background thread to activate the window by calling  
> request active after a few seconds but it had no effect.
>
> Is there any way I can debug this to see what is going on with the
> requestActive call?
>
> -Luan
>
You can add log to TopComponent.requestFocus(), requestFocusInWindow(),
requestActive(). Then rebuild openide-windows module.
After modification just run ant from openide/windows (on current trunk).
On NB 4.1 openide.jar might not be split into separate jars yet
so you will need to rebuild whole openide.jar by running ant from
openide dir. This will rebuild jar to nbbuild/netbeans.

Or if you could provide us with some sample module to reproduce your
problem I could try to investigate it.
(You can send sample directly to me or you can create issue in
Issuezilla and attach it there - it would be better as it would be
tracked at one place.)

Marek.

Reply | Threaded
Open this post in threaded view
|

[openide-dev] Re: how to open a TopComponent without making it active -another approach

Tim Boudreau
In reply to this post by Luan O'Carroll-3
Luan O'Carroll wrote:
> Thanks again,
>
> I tried that to no effect. I even put the requestActive and a
> requestVisible call into a background thread called 10 seconds later
> just to see what would happen but to no effect.
>
> For now I've managed to suppress the problem by changing the behavior :-(

I'd suggest finding out where the call to requestActive() is coming from
and filing a bug.  If the call is from OpenCookie.open(), it is correct
and requestActive() should be getting called.  But on general principle,
TC.open() should open the component and no more.

Now, whether that can be changed for editor tabs without de-facto
breaking compatibility is another question.  But problems like you are
having are exactly the reason one should never conflate things like
opening with shifting selection with shifting focus - at some point it
will bite.  If you can track down the problem, I think it would be a
perfectly legitimate bug to file.

Marek suggested patching TopComponent to call Thread.dumpStack() in
requestActive(), and reproducing your problem with the patched jar.  I'd
second that suggestion - getting an actual fix to the problem will be
much more reliable in the long run than depending on call ordering,
which is more or less what you're doing when you do it with a bunch of
invokeLaters().

-Tim