Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Scout/HowTo/3.7/Create a Dialog

< Scout‎ | HowTo‎ | 3.7

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

Your application features a table of data, eg. sub-agreements. You want three menus:

  1. New sub-agreement...
  2. Edit sub-agreement...
  3. Delete sub-agreement

When creating a new sub-agreement, you want to show the sub-agreement dialog with no data. When the user clicks the OK button, the data should be inserted into a table.

When editing an existing sub-agreement, you want to show the sub-agreement dialog, loading existing data and showing it to the user, and when the user clicks the OK button, the data in the table should be updated.

When deleting an existing sub-agreement, you want to show a little confirmation message before the data is deleted from the table.

All data modification (insert, update, and delete) should happen on the server. The client will just call the appropriate methods provided by a process service.

Dialog with Fields and Buttons

  1. In your projects, find the Forms folder and create a new form. Provide a name (for humans) and a type name (a Java class).
  2. In the form's MainBox, create a field, an OK button, and a Cancel button.

Without an OK button you will not be able to save any changes.

Without a Cancel button you will not be able to close the dialog (unless you provide other means of closing it).

Connecting a Process Service

Loading and storing data is typically done with a Scout Process Service. (Scout Process Service). The process service loads the data in a so called formData-object which is known by the client and the server. After filling the formData-object it is sent to the client where it will be imported into the form.
To connect our form with such a process service you need to do the steps below (this assumes that you already have created a process service).

  1. Create a NEW and a MODIFY handler for your form.
  2. Override the execLoad-Method and call the service to load the data.
  3. Override the execStore-Method and call the service to store the data.

Steps 2 and 3 don't have do be done manually if you create the handler with the scout-sdk. Also the formData is created automatically.

Calling the Dialog from a Menu

This assumes you already have a created a Scout Table Page.

  1. Find the table page, drill down to your table, and create the three new menus we mentioned at the top of the page.
  2. The New menu must be visible even if no existing sub-agreement has been selected. Deselect the Single Selection Action checkbox in order to allow that.
  3. The Delete menu must allow multiple selection. Select the Multi Selection Action checkbox in order to allow that.
  4. Create an Exec Action for your menus.

New: Note how we make sure to wait until the user is finished.

If the user changed anything, we're going to reload the page.

     @Override
     public void execAction()  throws ProcessingException {
       SubAgreementForm form = new SubAgreementForm();
       form.setParentProjectType(getParentProjectType());
       form.startNew();
       form.waitFor();
       if(form.isFormStored()){
         reloadPage();
       }
     }

Modify: Note how we make sure to wait until the user is finished.

If the user changed anything, we're going to reload the page.

     @Override
     public void execAction() throws ProcessingException{
       SubAgreementForm form = new SubAgreementForm();
       form.setParentProjectType(getParentProjectType());
       form.startModify();
       form.waitFor();
       if(form.isFormStored()){
         reloadPage();
       }
     }

Delete: We do some more heavy lifting here because we don't need to show a dialog. We figure out how many rows have been selected, then we call a process service to delete them. It returns the number of rows deleted. If the numbers don't match, we got an error somewhere on the way.

Reload the page if necessary.

     if(MessageBox.showDeleteConfirmationMessage(getTypeColumn()
        .getSelectedDisplayTexts())) {
       ISubAgreementsProcessService svc = SERVICES.getService(ISubAgreementsProcessService.class);
       int sel=getTypeColumn().getSelectedValues().length;
       int del=svc.remove(getProjectNo(), getTypeColumnColumn().getSelectedValues());
       if(sel!=del) {
         MessageBox.showOkMessage(Texts.get("DeleteMenu"),
         Texts.get("DeleteNotComplete"), null);
       }
       if (del>0) {
         reloadPage();
       }
     }

Back to the top