control declaration

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

control declaration

Postby PapaStahl » Fri Oct 03, 2003 8:05 am

Hi Konstantin,

I really think the swt-designer is great.
Here's one suggestion to improve the "control in Block" issue that will also help to later access the control's values:

Can the designer code add the declaration for the new control at the beginning of the class and only instantiate them in the blocks?

Here's a sample of the output I'd like to see:

Code: Select all

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

/**
* @author Christian (with SWT-Designer base)
*
*/
public class RTFNext {

   public static void main(String[] args) {
      final Display display = new Display();
      final Shell shell = new Shell();
      final Label label; //<--- put the declaration here
      final Text text;   //<--- put the declaration here
      final Button button; //<--- put the declaration here
      shell.setLayout(new FillLayout(SWT.VERTICAL));
      shell.setText("SWT Application");
      shell.setBounds(50,100,50,100);
      {
         label = new Label(shell, SWT.NONE);
         label.setText("Your Input:");
      }
      {
         text = new Text(shell, SWT.BORDER);
         text.setText("");
      }
      {
         button = new Button(shell, SWT.NONE);
         button.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
               MessageBox msg = new MessageBox(shell);
               msg.setText("What you typed:");
               msg.setMessage(text.getText());
               msg.open();
            }
         });
         button.setToolTipText("Click Now!");
         button.setText("OK (Click Me)");
      }
      // DESIGNER: Add controls before this line.
      shell.open();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }
   }
}

:D
Thanks,
Christian
PapaStahl
 
Posts: 5
Joined: Fri Oct 03, 2003 7:30 am
Location: Charlotte, NC

Postby admin » Sun Oct 05, 2003 11:40 pm

May be you don't know this, but Designer can convert local variable in block into field in class, so you will able to access control from any point of class. And also you can do so only for controls to that you really need access.
admin
Moderator
 
Posts: 166
Joined: Thu Jul 24, 2003 12:25 am

Postby PapaStahl » Mon Oct 06, 2003 7:51 am

You're right. I didn't know! :-)

I looked at the designer again, but still can't see it. Is it a professional feature?

Thanks,
:-)
Christian
PapaStahl
 
Posts: 5
Joined: Fri Oct 03, 2003 7:30 am
Location: Charlotte, NC

Postby Eric Clayberg » Mon Oct 06, 2003 5:11 pm

I looked at the designer again, but still can't see it.


There are two toolbar buttons above the inspector pane. The first allows you to jump to the source code for the current control. The second converts local variables to fields and back again.
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

Postby PapaStahl » Thu Oct 09, 2003 1:13 pm

Great!

Thank you!

:D
PapaStahl
 
Posts: 5
Joined: Fri Oct 03, 2003 7:30 am
Location: Charlotte, NC


Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot] and 1 guest