Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » The parent Shell problem in XWT(childShell.getParent() is null when using XWT.load(Object parent, URL file))
icon5.gif  The parent Shell problem in XWT [message #818871] Mon, 12 March 2012 08:15 Go to next message
Tiger Huang is currently offline Tiger HuangFriend
Messages: 3
Registered: March 2012
Junior Member
Hey Guys,

I encountered a problem in using XWT.load(Object parent, URL file). I have two .xwt files which correspond to respective shells as shown below:

----- main_shell.xwt -----
<Shell
    name="Shell"
    text="Main Shell"
    bounds="0,0,640,480">
</Shell>


----- child_shell.xwt -----
<Shell
    x:style="SHELL_TRIM|APPLICATION_MODAL"
    name="Shell"
    text="Child Shell"
    bounds="0,0,640,480">
</Shell>


I was trying to load child_shell.xwt as the child of main_shell.xwt using the following code:

----- MainShell.java -----
public class MainShell {
    public static void main(String[] args) {
        Shell mainShell = (Shell)XWT.load(new File("main_shell.xwt").toURI().toURL());
        mainShell.open();
        
        // do something...
        
        Shell childShell = (Shell)XWT.load(mainShell, new File("child_shell.xwt").toURI().toURL());
        childShell.open();
        
        System.out.print(childShell.getParent()); // <--- I got "null" here, but it should be "Shell {Main Shell}", right?
        
        while (!mainShell.isDisposed()) {
            if (!mainShell.getDisplay().readAndDispatch()) {
                mainShell.getDisplay().sleep();
            }
        }
    }
}


I called
Shell childShell = (Shell)XWT.load(mainShell, new File("child_shell.xwt").toURI().toURL());

but mainShell won't be the parent of childShell. The problem is that the child shell becomes a independent shell and shows in the windows task bar next to the main shell separately. Is there any way to fix this issue?

The libraries I applied are:
com.ibm.icu_4.2.1.v20100412.jar
org.eclipse.core.databinding.observable_1.3.0.I20100601-0800.jar
org.eclipse.core.databinding_1.3.100.I20100601-0800.jar
org.eclipse.e4.xwt_0.9.1.v20110603.jar
org.eclipse.jface.databinding_1.4.0.I20100601-0800.jar
org.pushingpixels.trident_1.2.0.v20110609-1700.jar

Tiger

[Updated on: Wed, 14 March 2012 04:17]

Report message to a moderator

Re: The parent Shell problem in XWT [message #823966 is a reply to message #818871] Mon, 19 March 2012 04:49 Go to previous message
Tiger Huang is currently offline Tiger HuangFriend
Messages: 3
Registered: March 2012
Junior Member
Hi all,

I've fixed this issue by modifying the source and rebuilding it locally.

At line #458 in org/eclipse/e4/xwt/javabean/ResourceLoader.java

Original:
shell = new Shell(display, styleValue);


Modified:
if(parent != null && parent instanceof Shell && metaclass.getType() == Shell.class) {
    shell = new Shell((Shell) parent, styleValue);
} else {
    shell = new Shell(display, styleValue);
}


BR,
Tiger

[Updated on: Mon, 19 March 2012 05:19]

Report message to a moderator

Previous Topic:Dependency to compatibility layer in org.eclipse.e4.ui.workbench.addons.swt, MinMaxAddon...why?
Next Topic:IEventBroker without data
Goto Forum:
  


Current Time: Tue Mar 19 11:24:59 GMT 2024

Powered by FUDForum. Page generated in 0.01971 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top