Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Concepts/Form/Example"

< Scout‎ | Concepts‎ | Form
m (+ScoutPage)
m (+reindent code)
Line 4: Line 4:
  
 
  public class PersonForm extends AbstractForm{
 
  public class PersonForm extends AbstractForm{
 
+
 
   public PersonForm(){
 
   public PersonForm(){
  }
+
  }
 
+
 
 
   /**
 
   /**
 
   * This method and all other getConfigured* and exec* methods can be written manually  
 
   * This method and all other getConfigured* and exec* methods can be written manually  
 
   * or via the property editor in the scout sdk view
 
   * or via the property editor in the scout sdk view
 
   */
 
   */
  @Override
+
  @Override
  protected String getConfiguredTitle(){
+
  protected String getConfiguredTitle(){
    return Texts.get("MailReader");
+
    return Texts.get("MailReader");
  }
+
  }
 
+
 
 
+
 
 
   public MainBox getMainBox(){
 
   public MainBox getMainBox(){
    return (MainBox)getRootGroupBox();
+
    return (MainBox)getRootGroupBox();
  }
+
  }
 
+
 
  public FirstNameField getFirstNameField(){
+
  public FirstNameField getFirstNameField(){
    return getFieldByClass(FirstNameField.class);
+
    return getFieldByClass(FirstNameField.class);
  }
+
  }
 
+
 
 
   public LastNameField getLastNameField(){
 
   public LastNameField getLastNameField(){
    return getFieldByClass(LastNameField.class);
+
    return getFieldByClass(LastNameField.class);
  }
+
  }
 
+
 
  public OkButton getOkButton(){
+
  public OkButton getOkButton(){
    return getFieldByClass(OkButton.class);
+
    return getFieldByClass(OkButton.class);
  }
+
  }
 
+
 
 
   public CancelButton getCancelButton(){
 
   public CancelButton getCancelButton(){
    return getFieldByClass(CancelButton.class);
+
    return getFieldByClass(CancelButton.class);
  }
+
  }
 
+
 
 
   /**
 
   /**
 
   * Start the form with the create handler
 
   * Start the form with the create handler
 
   */
 
   */
  public void startCreate() throws ProcessingException{
+
  public void startCreate() throws ProcessingException{
    startInternal(new CreateHandler());
+
    startInternal(new CreateHandler());
  }
+
  }
 
+
 
 
   /**
 
   /**
 
   * Start the form with the modify handler
 
   * Start the form with the modify handler
 
   */
 
   */
  public void startModify() throws ProcessingException{
+
  public void startModify() throws ProcessingException{
    startInternal(new ModifyHandler());
+
    startInternal(new ModifyHandler());
  }
+
  }
 
+
 
<br>
+
 
 
+
 
   @Order(10)
 
   @Order(10)
  public class MainBox extends AbstractGroupBox{
+
  public class MainBox extends AbstractGroupBox{
 
+
   
 
     @Order(10)
 
     @Order(10)
    public class FirstNameField extends AbstractStringField{
+
    public class FirstNameField extends AbstractStringField{
      @Override
+
      @Override
      protected String getConfiguredLabel(){
+
      protected String getConfiguredLabel(){
        return Texts.get("FirstName");
+
        return Texts.get("FirstName");
      }
+
      }
    }
+
    }
   
+
   
 
+
 
     @Order(20)
 
     @Order(20)
    public class LastNameField extends AbstractStringField{
+
    public class LastNameField extends AbstractStringField{
      @Override
+
      @Override
      protected String getConfiguredLabel(){
+
      protected String getConfiguredLabel(){
        return Texts.get("LastName");
+
        return Texts.get("LastName");
      }
+
      }
    }
+
    }
   
+
   
 
+
 
     @Order(30)
 
     @Order(30)
    public class OkButton extends AbstractOkButton{
+
    public class OkButton extends AbstractOkButton{
    }
+
    }
   
+
   
    @Order(40)
+
    @Order(40)
    public class CancelButton extends AbstractCancelButton{
+
    public class CancelButton extends AbstractCancelButton{
    }
+
    }
   
+
 
  }
+
  }
 
+
 
<br>
+
 
+
 
   /**
 
   /**
 
   * This is the form handler when started with .startCreate();
 
   * This is the form handler when started with .startCreate();
 
   */
 
   */
  public class CreateHandler extends AbstractFormHandler{
+
  public class CreateHandler extends AbstractFormHandler{
    protected void execLoad() throws ProcessingException{
+
    protected void execLoad() throws ProcessingException{
      //...
+
      //...
    }
+
    }
 
+
 
 
     protected void execStore() throws ProcessingException{
 
     protected void execStore() throws ProcessingException{
      //...
+
      //...
    }
+
    }
  }
+
  }
 
+
 
 
   /**
 
   /**
 
   * This is the form handler when started with .startModify();
 
   * This is the form handler when started with .startModify();
 
   */
 
   */
  public class ModifyHandler extends AbstractFormHandler{
+
  public class ModifyHandler extends AbstractFormHandler{
    protected void execLoad() throws ProcessingException{
+
    protected void execLoad() throws ProcessingException{
      //...
+
      //...
    }
+
    }
 
+
   
 
     protected void execStore() throws ProcessingException{
 
     protected void execStore() throws ProcessingException{
      //...
+
      //...
    }
+
    }
  }
+
  }
 
+
 
  }
 
  }
  

Revision as of 01:23, 2 July 2010

The Scout documentation has been moved to https://eclipsescout.github.io/.

To get an idea consider a form with only a title and two string fields. This form is displayed as a complete SWT form with SWT fields when using the SWT GUI Plug-In. It can also be displayed using the Swing GUI Plug-In, or (in development) using the apache wicket GUI Plug-In to serve the form from the server as a web page.

public class PersonForm extends AbstractForm{

  public PersonForm(){
  }
  
  /**
  * This method and all other getConfigured* and exec* methods can be written manually 
  * or via the property editor in the scout sdk view
  */
  @Override
  protected String getConfiguredTitle(){
    return Texts.get("MailReader");
  }
  
  
  public MainBox getMainBox(){
    return (MainBox)getRootGroupBox();
  }
  
  public FirstNameField getFirstNameField(){
    return getFieldByClass(FirstNameField.class);
  }
  
  public LastNameField getLastNameField(){
    return getFieldByClass(LastNameField.class);
  }
  
  public OkButton getOkButton(){
    return getFieldByClass(OkButton.class);
  }
  
  public CancelButton getCancelButton(){
    return getFieldByClass(CancelButton.class);
  }
  
  /**
  * Start the form with the create handler
  */
  public void startCreate() throws ProcessingException{
    startInternal(new CreateHandler());
  }
  
  /**
  * Start the form with the modify handler
  */
  public void startModify() throws ProcessingException{
    startInternal(new ModifyHandler());
  }
  
  
  @Order(10)
  public class MainBox extends AbstractGroupBox{
    
    @Order(10)
    public class FirstNameField extends AbstractStringField{
      @Override
      protected String getConfiguredLabel(){
        return Texts.get("FirstName");
      }
    }
    
    @Order(20)
    public class LastNameField extends AbstractStringField{
      @Override
      protected String getConfiguredLabel(){
        return Texts.get("LastName");
      }
    }
    
    @Order(30)
    public class OkButton extends AbstractOkButton{
    }
    
    @Order(40)
    public class CancelButton extends AbstractCancelButton{
    }
  
  }
  
  /**
  * This is the form handler when started with .startCreate();
  */
  public class CreateHandler extends AbstractFormHandler{
    protected void execLoad() throws ProcessingException{
      //...
    }
  
    protected void execStore() throws ProcessingException{
      //...
    }
  }
  
  /**
  * This is the form handler when started with .startModify();
  */
  public class ModifyHandler extends AbstractFormHandler{
    protected void execLoad() throws ProcessingException{
      //...
    }
    
    protected void execStore() throws ProcessingException{
      //...
    }
  }
}

Back to Scout Main Concepts

Back to the top