MDIManager: is it possible to set a window as active?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MDIManager: is it possible to set a window as active?

Andrés Maneiro
Hello devs,

I'm adding from code a new document to my project: a Table document.
But, once done, I'd like the View document to be set as active *and* in
the foreground.

The code I'm playing with:

  ---
   //creates a table document, suppose projecTable has proper values
   Table myTable = new Table();
   myTable.setModel(projectTable);

   //add document to MDIManager
   PluginServices.getMDIManager().addWindow(myTable);

   //move frame containing the table to the back
   JInternalFrame frame = (JInternalFrame)
       myTable.getRootPane().getParent();
   frame.toBack();

  ---

At this point the situation is:

* myTable is at the bottom of the stack (meaning, in the backround)
   checked with the method:
   PluginServices.getMDIManager().getOrderedWindows()

* myTable is the active window - checked with the method
   PluginServices.getMDIManager().getActiveWindow().

Is that a bug? What I'd expect is that the foregroung window is the
active, which is not. How can I set the active window in the MDIManager?

best,
amaneiro
_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: MDIManager: is it possible to set a window as active?

Andrés Maneiro
After reviewing MDIManager.java and NewSkin.java I've came with this
code in NewSkin.java (with the proper declaration of the method in the
interface MDIManager):

---

   public void setActiveWindow(IWindow w) {
     JInternalFrame frame = null;
       if (w instanceof BaseView) {
         frame = (JInternalFrame)
           ((BaseView) w).getRootPane().getParent();
         panel.setSelectedFrame(frame);
       } else if (w instanceof Table) {
           frame = (JInternalFrame)
               ((Table) w).getRootPane().getParent();
              panel.setSelectedFrame(frame);
       }
   }

---

So, after did that, I got to use it:

  ---
    //creates a table document, suppose projecTable has proper values
    Table myTable = new Table();
    myTable.setModel(projectTable);

    //add document to MDIManager
    PluginServices.getMDIManager().addWindow(myTable);

    //move frame containing the table to the back
    JInternalFrame frame = (JInternalFrame)
    myTable.getRootPane().getParent();
    frame.toBack();
    PluginServices.getMDIManager().setActive(myView);
    //just assume that myView is a proper BaseView

  ---

With the code above, after executing setActive method the result of
PluginServices.getMDIManager().getActiveWindow() gives myView as a result.

But, out of the blue, in later executions (without my code loading any
table), the method PluginServices.getMDIManager().getActiveWindow() will
return myTable again. Any hint why?

best,
amaneiro


On 26/05/11 17:31, Andrés Maneiro wrote:

> Hello devs,
>
> I'm adding from code a new document to my project: a Table document.
> But, once done, I'd like the View document to be set as active *and* in
> the foreground.
>
> The code I'm playing with:
>
> ---
> //creates a table document, suppose projecTable has proper values
> Table myTable = new Table();
> myTable.setModel(projectTable);
>
> //add document to MDIManager
> PluginServices.getMDIManager().addWindow(myTable);
>
> //move frame containing the table to the back
> JInternalFrame frame = (JInternalFrame)
> myTable.getRootPane().getParent();
> frame.toBack();
>
> ---
>
> At this point the situation is:
>
> * myTable is at the bottom of the stack (meaning, in the backround)
> checked with the method:
> PluginServices.getMDIManager().getOrderedWindows()
>
> * myTable is the active window - checked with the method
> PluginServices.getMDIManager().getActiveWindow().
>
> Is that a bug? What I'd expect is that the foregroung window is the
> active, which is not. How can I set the active window in the MDIManager?
>
> best,
> amaneiro
_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: MDIManager: is it possible to set a window as active?

Andrés Maneiro
Shared here the workaround I'm using to make this to work (as a further
reminder on how to do it):

  ---

    //creates a table document, suppose projecTable has proper values
    Table myTable = new Table();
    myTable.setModel(projectTable);

    //add document to MDIManager
    PluginServices.getMDIManager().addWindow(myTable);

    //move frame containing the table to the back
    JInternalFrame frame = (JInternalFrame)
    myTable.getRootPane().getParent();
    frame.toBack();
    frame.setSelected(false);
    JInternalFrame frameBaseView =
      (JInternalFrame) myView.getRootPane().getParent();
    frameBaseView.setSelected(true);

  ---

Although it works, it will be great has, as developer, a way for setting
as active a gvsig document by means of the API.

best,
amaneiro


On 26/05/11 19:31, Andrés Maneiro wrote:

> After reviewing MDIManager.java and NewSkin.java I've came with this
> code in NewSkin.java (with the proper declaration of the method in the
> interface MDIManager):
>
> ---
>
> public void setActiveWindow(IWindow w) {
> JInternalFrame frame = null;
> if (w instanceof BaseView) {
> frame = (JInternalFrame)
> ((BaseView) w).getRootPane().getParent();
> panel.setSelectedFrame(frame);
> } else if (w instanceof Table) {
> frame = (JInternalFrame)
> ((Table) w).getRootPane().getParent();
> panel.setSelectedFrame(frame);
> }
> }
>
> ---
>
> So, after did that, I got to use it:
>
> ---
> //creates a table document, suppose projecTable has proper values
> Table myTable = new Table();
> myTable.setModel(projectTable);
>
> //add document to MDIManager
> PluginServices.getMDIManager().addWindow(myTable);
>
> //move frame containing the table to the back
> JInternalFrame frame = (JInternalFrame)
> myTable.getRootPane().getParent();
> frame.toBack();
> PluginServices.getMDIManager().setActive(myView);
> //just assume that myView is a proper BaseView
>
> ---
>
> With the code above, after executing setActive method the result of
> PluginServices.getMDIManager().getActiveWindow() gives myView as a result.
>
> But, out of the blue, in later executions (without my code loading any
> table), the method PluginServices.getMDIManager().getActiveWindow() will
> return myTable again. Any hint why?
>
> best,
> amaneiro
>
>
> On 26/05/11 17:31, Andrés Maneiro wrote:
>> Hello devs,
>>
>> I'm adding from code a new document to my project: a Table document.
>> But, once done, I'd like the View document to be set as active *and* in
>> the foreground.
>>
>> The code I'm playing with:
>>
>> ---
>> //creates a table document, suppose projecTable has proper values
>> Table myTable = new Table();
>> myTable.setModel(projectTable);
>>
>> //add document to MDIManager
>> PluginServices.getMDIManager().addWindow(myTable);
>>
>> //move frame containing the table to the back
>> JInternalFrame frame = (JInternalFrame)
>> myTable.getRootPane().getParent();
>> frame.toBack();
>>
>> ---
>>
>> At this point the situation is:
>>
>> * myTable is at the bottom of the stack (meaning, in the backround)
>> checked with the method:
>> PluginServices.getMDIManager().getOrderedWindows()
>>
>> * myTable is the active window - checked with the method
>> PluginServices.getMDIManager().getActiveWindow().
>>
>> Is that a bug? What I'd expect is that the foregroung window is the
>> active, which is not. How can I set the active window in the MDIManager?
>>
>> best,
>> amaneiro
_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel