Spring Integration

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

Spring Integration

Postby dkichline » Mon Feb 25, 2008 11:59 am

I am building a main dialog that creates a default shell. Then I wrote a separate selectionAdapter to handle the Menu Selection logic instead of embedding it directly in the Dialog Class. If in the createContents method the this.shell = new Shell(), the wysiwyg editor works. If I create the shell else where, via spring and then set the shell variable the wysiwyg does not work.

Do I have to create the Shell in there, or is there a way to work around this?
dkichline
 
Posts: 2
Joined: Mon Feb 25, 2008 11:55 am

Re: Spring Integration

Postby Eric Clayberg » Mon Feb 25, 2008 5:21 pm

Please post an example of exactly what you are trying to do.
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

Re: Spring Integration

Postby dkichline » Mon Feb 25, 2008 7:38 pm

Code: Select all
package com.penske.architect.apps.queryrunner.swt;

import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.penske.architect.apps.queryrunner.swt.events.MainMenuSelectionAdapter;
import com.penske.architect.apps.queryrunner.swt.events.MainTreeAdapter;
import com.penske.architect.apps.queryrunner.swt.events.MainTreeSelectionAdapter;

public class QueryRunnerApplication {
   private static final Logger logger = Logger.getLogger(QueryRunnerApplication.class);

   private Shell shell;

   private Tree tree = null;

   private Table table = null;

   private MainTreeAdapter mainTreeAdapter = null;

   private MainTreeSelectionAdapter mainTreeSelectionAdapter = null;

   private MainMenuSelectionAdapter mainMenuSelectionAdapter = null;

   /**
    * Launch the application
    *
    * @param args
    */
   public static void main(String[] args) {
      ApplicationContext applicationContext = new FileSystemXmlApplicationContext("classpath:/applicationContext*.xml");

      try {
         QueryRunnerApplication window = (QueryRunnerApplication) applicationContext.getBean("queryRunnerApp");
         window.open();
      }
      catch (Throwable th) {
         logger.fatal("There was an unhandled exception", th);
      }
   }

   /**
    * Open the window
    */
   public void open() {
      final Display display = Display.getDefault();
      createContents();
      shell.open();
      shell.layout();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }
   }

   /**
    * Create contents of the window
    */
   protected void createContents() {
      shell.setSize(805, 427);
      shell.setText("Query Runner");

      tree.addSelectionListener(this.mainTreeSelectionAdapter);
      this.tree.addTreeListener(this.mainTreeAdapter);
      this.tree.setBounds(10, 10, 320, 341);

      this.table.setLinesVisible(true);
      this.table.setHeaderVisible(true);
      this.table.setBounds(336, 10, 451, 341);

      final TableColumn nameTableColumn = new TableColumn(this.table, SWT.NONE);
      nameTableColumn.setWidth(100);
      nameTableColumn.setText("Name");

      final TableColumn valueTableColumn = new TableColumn(this.table, SWT.NONE);
      valueTableColumn.setWidth(351);
      valueTableColumn.setText("Value");

      TreeItem root = new TreeItem(this.tree, SWT.NONE);
      root.setText("Servers");
      root.setItemCount(1);
      root.setData(MainTreeAdapter.SERVERS);

      final Menu menu = new Menu(shell, SWT.BAR);
      shell.setMenuBar(menu);

      final MenuItem fileSubmenuMenuItem = new MenuItem(menu, SWT.CASCADE);
      fileSubmenuMenuItem.setText("&File");

      final Menu menu_1 = new Menu(fileSubmenuMenuItem);
      fileSubmenuMenuItem.setMenu(menu_1);

      final MenuItem ItemMenuItem = new MenuItem(menu_1, SWT.NONE);
      ItemMenuItem.addSelectionListener(this.mainMenuSelectionAdapter);
      ItemMenuItem.setText("E&xit");
      ItemMenuItem.setData(MainMenuSelectionAdapter.FILE_EXIT);

      final MenuItem createMenuItem = new MenuItem(menu, SWT.CASCADE);
      createMenuItem.setText("&Create");

      final Menu menu_2 = new Menu(createMenuItem);
      createMenuItem.setMenu(menu_2);

      final MenuItem createServerMenuItem = new MenuItem(menu_2, SWT.NONE);
      createServerMenuItem.addSelectionListener(this.mainMenuSelectionAdapter);
      createServerMenuItem.setText("Server");
      createServerMenuItem.setData(MainMenuSelectionAdapter.CREATE_SERVER);
   }

   public void setMainTreeAdapter(MainTreeAdapter mainTreeAdapter) {
      this.mainTreeAdapter = mainTreeAdapter;
   }

   public void setMainTreeSelectionAdapter(MainTreeSelectionAdapter mainTreeSelectionAdapter) {
      this.mainTreeSelectionAdapter = mainTreeSelectionAdapter;
   }

   public void setMainMenuSelectionAdapter(MainMenuSelectionAdapter mainMenuSelectionAdapter) {
      this.mainMenuSelectionAdapter = mainMenuSelectionAdapter;
   }

   public void setShell(Shell shell) {
      this.shell = shell;
   }

   public void setTree(Tree tree) {
      this.tree = tree;
   }

   public void setTable(Table table) {
      this.table = table;
   }
}


The details of the applicationContext is not important here. What to focus on is that the Shell, Tree and Table have public set methods. And these attributes are set prior to the createContents methods is called.

I understand that I will not be able to modify styles through the tool, but I would expect to be able to view the screen and the controls. When I do the above I get the following error: "Designer was unable to find any GUI elements in your source. Check that the open compilation unit is a GUI class."

Thanks,

Don Kichline
dkichline
 
Posts: 2
Joined: Mon Feb 25, 2008 11:55 am

Re: Spring Integration

Postby Eric Clayberg » Mon Feb 25, 2008 8:35 pm

Designer can only edit what is statically defined within your class. Dynamic, runtime behavior that may or may not take place can't be considered.

In your example, you don't actually create a shell, so there is nothing to edit.

If you want to edit this class in Designer, you need to create the Shell within the class itself. This can easily be done in design-time specific behavior that is ignored at runtime.
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