/** Method for creating Stream Direction Group */
  protected void createStreamDirectionGroup(
      int horizontalSpan, int verticalSpan, boolean isBothButton) {
    streamDirectionGroup = new Group(shell, SWT.NONE);
    streamDirectionGroup.setText("Stream direction");
    GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = verticalSpan;
    streamDirectionGroup.setLayoutData(gridData);
    streamDirectionGroup.setLayout(new GridLayout());

    // Downstream Radio Button

    downstreamButton = new Button(streamDirectionGroup, SWT.RADIO);
    downstreamButton.setText("Downstream");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    downstreamButton.setLayoutData(gridData);

    // Upstream Radio Button

    upstreamButton = new Button(streamDirectionGroup, SWT.RADIO);
    upstreamButton.setText("Upstream");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    upstreamButton.setLayoutData(gridData);

    // Downstream & Upstream Radio Button
    if (isBothButton) {
      bothButton = new Button(streamDirectionGroup, SWT.RADIO);
      bothButton.setText("Both");
      gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
      bothButton.setLayoutData(gridData);
    }
  }
  protected void createLimitTypesGroup() {
    GridData gridData; // Group for lengthLimitButton and shortestPlusKButton

    Group limitTypeGroup = new Group(shell, SWT.NONE);
    limitTypeGroup.setText("Stop distance");
    gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = 2;
    gridData.verticalSpan = 2;
    limitTypeGroup.setLayoutData(gridData);
    limitTypeGroup.setLayout(new GridLayout(2, true));

    // Length limit radio button

    lengthLimitLabel = new Label(limitTypeGroup, SWT.NONE);
    lengthLimitLabel.setText("Length limit");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    lengthLimitLabel.setLayoutData(gridData);

    // Length limit text

    lengthLimit = new Text(limitTypeGroup, SWT.BORDER);
    lengthLimit.addKeyListener(keyAdapter);
    gridData = new GridData(GridData.FILL, GridData.CENTER, false, false);
    lengthLimit.setLayoutData(gridData);

    // Shortest+k radio button

    shortestPlusKButton = new Button(limitTypeGroup, SWT.CHECK);
    shortestPlusKButton.setText("Shortest+k");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    shortestPlusKButton.setLayoutData(gridData);
    shortestPlusKButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            shortestPlusK.setEnabled(shortestPlusKButton.getSelection());
          }
        });

    // Shortest+k text

    shortestPlusK = new Text(limitTypeGroup, SWT.BORDER);
    shortestPlusK.addKeyListener(keyAdapter);
    gridData = new GridData(GridData.FILL, GridData.CENTER, false, false);
    shortestPlusK.setLayoutData(gridData);

    // Strict check box

    strictButton = new Button(shell, SWT.CHECK | SWT.WRAP);
    strictButton.setText("Ignore source-source/target-target paths");
    gridData = new GridData(GridData.CENTER, GridData.CENTER, false, false);
    gridData.verticalSpan = 2;
    gridData.horizontalSpan = 4;
    strictButton.setLayoutData(gridData);
  }
  private Composite createScrollArea(Composite parent) {
    Group container = new Group(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 6;
    container.setLayout(layout);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    container.setLayoutData(gd);
    container.setText(PDEUIMessages.ImportWizard_DetailedPage_filter);

    Label filterLabel = new Label(container, SWT.NONE);
    filterLabel.setText(PDEUIMessages.ImportWizard_DetailedPage_search);

    fFilterText = new Text(container, SWT.BORDER);
    fFilterText.setText(""); // $NON-NLS-1$
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fFilterText.setLayoutData(gd);

    return container;
  }
  /** Method for creating Result View Group */
  protected void createResultViewGroup(int horizontalSpan, int verticalSpan) {
    resultViewGroup = new Group(shell, SWT.NONE);
    resultViewGroup.setText("Show result in");
    GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = verticalSpan;
    resultViewGroup.setLayoutData(gridData);
    resultViewGroup.setLayout(new GridLayout());

    // Current View Radio Button

    currentViewButton = new Button(resultViewGroup, SWT.RADIO);
    currentViewButton.setText("Current view");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    currentViewButton.setLayoutData(gridData);

    // New View Radio Button

    newViewButton = new Button(resultViewGroup, SWT.RADIO);
    newViewButton.setText("New view");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    newViewButton.setLayoutData(gridData);
  }
 private void createGroup(Composite parent, String title, String position, Object layout) {
   Group comp = new Group(parent, SWT.PUSH | SWT.NO_BACKGROUND | SWT.SHADOW_OUT);
   comp.setText(title.length() == 0 ? "\"\"" : title);
   comp.setLayoutData(layout != null ? layout : position);
   createComp(comp);
 }
  private Control createArgumentsGroup(Composite parent) {
    Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);

    SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1);

    Group programGroup =
        SWTFactory.createGroup(
            container,
            PDEUIMessages.JavaArgumentsTab_progamArgsGroup,
            1,
            1,
            GridData.FILL_HORIZONTAL);

    fProgramArgs =
        SWTFactory.createText(
            programGroup,
            SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL,
            1,
            200,
            60,
            GridData.FILL_BOTH);
    fProgramArgs.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
          }
        });

    Composite programButtons =
        SWTFactory.createComposite(programGroup, 1, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);

    Button programVars =
        SWTFactory.createPushButton(
            programButtons,
            PDEUIMessages.JavaArgumentsTab_programVariables,
            null,
            GridData.HORIZONTAL_ALIGN_END);
    programVars.addSelectionListener(getVariablesListener(fProgramArgs));

    Group vmGroup = new Group(container, SWT.NONE);
    vmGroup.setLayout(new GridLayout(1, false));
    vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
    vmGroup.setFont(container.getFont());

    fVMArgs =
        SWTFactory.createText(
            vmGroup,
            SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL,
            1,
            200,
            60,
            GridData.FILL_BOTH);
    fVMArgs.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
          }
        });

    Composite buttons =
        SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);

    Button vmArgs =
        SWTFactory.createPushButton(
            buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END);
    vmArgs.addSelectionListener(getVMArgsListener(fVMArgs));

    Button vmVars =
        SWTFactory.createPushButton(
            buttons,
            PDEUIMessages.JavaArgumentsTab_vmVariables,
            null,
            GridData.HORIZONTAL_ALIGN_END);
    vmVars.addSelectionListener(getVariablesListener(fVMArgs));
    return container;
  }
  protected void createExeCancDefGroup(final QueryOptionsPack opt, int horizontalSpan) {
    // Group for execute, cancel and default buttons

    exeCancelDefaultGroup = new Group(shell, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, false, false);
    gridData.horizontalSpan = horizontalSpan;
    exeCancelDefaultGroup.setLayoutData(gridData);
    exeCancelDefaultGroup.setLayout(new GridLayout(4, true));

    if (forSIF) {
      sifTypeButton = new Button(exeCancelDefaultGroup, SWT.NONE);
      sifTypeButton.setBackground(new Color(null, 255, 255, 255));
      gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
      sifTypeButton.setLayoutData(gridData);
      sifTypeButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent arg0) {
              ArrayList<SIFType> selection = new ArrayList<SIFType>(selectedTypes);
              ExportToSIFL3Dialog dialog =
                  new ExportToSIFL3Dialog(
                      main.getShell(),
                      org.gvt.model.sifl3.SIFGraph.getPossibleRuleTypes(),
                      selection);

              if (dialog.open()) {
                selectedTypes.clear();
                selectedTypes.addAll(selection);
                updateSIFTypeButtonText();
              }
            }
          });
      if (selectedTypes == null) selectedTypes = new ArrayList<SIFType>();
      updateSIFTypeButtonText();
    }

    // Execute Button

    executeButton = new Button(exeCancelDefaultGroup, SWT.NONE);
    executeButton.setText("Execute");
    gridData = new GridData(GridData.END, GridData.CENTER, true, false);
    executeButton.setLayoutData(gridData);
    executeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            // if no entity is added, show error
            if ((sourceElg != null && getAddedSourceEntities().isEmpty())
                || (sourceST != null && sourceST.getSymbols().isEmpty())) {
              MessageDialog.openError(main.getShell(), "Error!", "Add Source Molecule!");

              return;
            }
            if ((targetElg != null && getAddedTargetEntities().isEmpty())
                || (targetST != null && targetST.getSymbols().isEmpty())) {
              MessageDialog.openError(main.getShell(), "Error!", "Add Target Molecule!");

              return;
            }

            if (forSIF && selectedTypes.isEmpty()) {
              MessageDialog.openError(
                  main.getShell(), "Error!", "Please select at least one interaction type.");

              return;
            }

            // Check for unknown gene symbols
            java.util.List<String> unkwn = getUnknownSymbols();
            if (!unkwn.isEmpty()) {
              String s = "";
              for (String us : unkwn) s += " " + us;

              MessageDialog.openError(
                  main.getShell(),
                  "Error!",
                  "Unknown symbol" + (unkwn.size() > 1 ? "s" : "") + ": " + s);

              return;
            }

            // store values in dialog to optionsPack
            storeValuesToOptionsPack(opt);

            // execute is selected
            opt.setCancel(false);

            shell.close();
          }
        });

    // Cancel Button

    cancelButton = new Button(exeCancelDefaultGroup, SWT.NONE);
    gridData = new GridData(GridData.CENTER, GridData.CENTER, true, false);
    createCancelButton(gridData);

    // Default Button

    defaultButton = new Button(exeCancelDefaultGroup, SWT.NONE);
    defaultButton.setText("Default");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
    defaultButton.setLayoutData(gridData);
    defaultButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            // set default values of dialog
            setDefaultQueryDialogOptions();
          }
        });
  }