Child Shells?

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Child Shells?

Postby riz1ali » Thu Dec 06, 2007 3:37 pm

Hi,

I have a main shell and I tried creating a child shell but when I go to the design view in Swt Designer, the property editor shows two "(Shells)". This is confusing because I don't know which one is the main shell and which one is the child shell.

Here is the code:

Code: Select all
public class Main extends Shell {

   public static void main(String args[]) {
      
         try {
            Display display = Display.getDefault();
            Main shell = new Main(display, SWT.SHELL_TRIM);
            shell.open();
            while (!shell.isDisposed()) {
               if (!display.readAndDispatch())
                  display.sleep();
            }
         } catch (Exception e) {
            // e.printStackTrace();
         }
   }

   public Main(Display display, int style) {
      super(display, style);
      createContents();
   }

   protected void createContents() {
   
   }

   @Override
   protected void checkSubclass() {
      // Disable the check that prevents subclassing of SWT components
      
   }

}

class Child extends Shell {

   public Child(Display display, int style) {
      super(display, style);
      createContents();
   }

   protected void createContents() {
   
   }

   @Override
   protected void checkSubclass() {
      // Disable the check that prevents subclassing of SWT components
      
   }

}


If I create the child shell without extending the shell class, Swt Designer correctly displays the name of the child shell in property editor.

Here is the code:

Code: Select all
class childShell {

   Shell child;
   Shell parent;
   
   childShell(Shell master) {
      this.parent = master;
      this.child = new Shell(Display.getCurrent(), SWT.SHELL_TRIM);

   }
   
}


So, what is the best way to create a child shell?

Thanks.
riz1ali
 
Posts: 4
Joined: Thu Dec 06, 2007 1:55 pm

Postby Konstantin.Scheglov » Fri Dec 07, 2007 12:59 pm

You just do not very good thing. Having more than one class is is general bad style. So, best way - extract "child" Shell in separate compilation unit.
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk

Postby Eric Clayberg » Sat Dec 08, 2007 8:20 am

Note that Designer only supports public components that are JavaBean compliant as stated in the Designer FAQ.

As Konstantin stated, your custom Shell class needs to be in its own public compilation unit.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests