private void addListeners() {
   m_suiteText.addModifyListener(MODIFY_LISTENER);
   m_testText.addModifyListener(MODIFY_LISTENER);
   m_selectionCombo.addModifyListener(MODIFY_LISTENER);
   m_parallelCombo.addModifyListener(MODIFY_LISTENER);
   m_threadCountText.addModifyListener(MODIFY_LISTENER);
 }
  private void createPoolGroup(Composite comp, ValidationHandler validationHandler) {
    Group poolGroup;
    GridData gd;
    Label label;

    poolGroup = new Group(comp, SWT.SHADOW_NONE);
    poolGroup.setText("Pool");
    poolGroup.setLayout(new GridLayout(2, false));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    poolGroup.setLayoutData(gd);

    label = new Label(poolGroup, SWT.NONE);
    label.setText("Target:");

    targetCombo = new Combo(poolGroup, SWT.READ_ONLY);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = convertHorizontalDLUsToPixels(180);
    targetCombo.setLayoutData(gd);
    for (Iterator i = targets.iterator(); i.hasNext(); ) {
      Target target = (Target) i.next();
      targetCombo.add(target.toString());
    }
    targetCombo.addModifyListener(validationHandler);

    label = new Label(poolGroup, SWT.NONE);
    label.setText("Pool ID:");

    poolIdText = new Text(poolGroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    poolIdText.setLayoutData(gd);
    poolIdText.addModifyListener(validationHandler);
  }
  private void getComboAttribute(Composite composite) {
    comboAttribute = new Combo(composite, SWT.READ_ONLY);
    comboAttribute.setText(Messages.getString("UpdateAttributeDialog.3")); // $NON-NLS-1$
    comboAttribute.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    Object firstElement = selection.get(0);
    if (firstElement instanceof EObject) {
      AttributeConfiguration configuration =
          RequirementUtils.getAttributeConfiguration(((EObject) firstElement).eResource());

      List<String> labelList = new ArrayList<String>();
      for (ConfiguratedAttribute anAttribute : configuration.getListAttributes()) {
        labelList.add(anAttribute.getName());
        comboAttribute.setData(anAttribute.getName(), anAttribute.getListValue());
      }

      comboAttribute.setItems(labelList.toArray(new String[0]));
      comboAttribute.addSelectionListener(new AttributeSelectionListener());
      comboAttribute.addModifyListener(
          new ModifyListener() {
            public void modifyText(ModifyEvent event) {
              attributeNameModified();
            }
          });
    }
  }
  private void createToolCombo(Composite top) {
    Composite comboTop = new Composite(top, SWT.NONE);
    comboTop.setLayout(new GridLayout(2, false));
    Label toolLabel = new Label(comboTop, SWT.NONE);
    toolLabel.setText(Messages.getString("ValgrindOptionsTab.Tool_to_run")); // $NON-NLS-1$
    toolsCombo = new Combo(comboTop, SWT.READ_ONLY);
    tools = getPlugin().getRegisteredToolIDs();

    String[] names = new String[tools.length];
    for (int i = 0; i < names.length; i++) {
      names[i] = capitalize(getPlugin().getToolName(tools[i]));
    }
    toolsCombo.setItems(names);

    toolsCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            // user selected change, set defaults in new tool
            if (!isInitializing) {
              initDefaults = true;
              int ix = toolsCombo.getSelectionIndex();
              tool = tools[ix];
              handleToolChanged();
              updateLaunchConfigurationDialog();
            }
          }
        });
  }
  /** {@inheritDoc} */
  @Override
  protected void hookListeners() {
    super.hookListeners();

    // listener to select invocation type
    ModifyListener newTypeKindListener =
        new ModifyListener() {

          /**
           * @see
           *     org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
           */
          public void modifyText(ModifyEvent e) {
            ISelection sel = newTypeKindComboViewer.getSelection();
            if (sel instanceof StructuredSelection) {
              Object type = ((StructuredSelection) sel).getFirstElement();
              if (type instanceof IElementType) {
                newTypeKind = (IElementType) type;
              } else {
                newTypeKind = null;
              }

              // reset name
              setNewTypeName(null);
            }
          }
        };
    newTypeKindCombo.addModifyListener(newTypeKindListener);
  }
 public void undo() {
   if (listener != null) combo.removeModifyListener(listener);
   wc.setAttribute(key, oldVal);
   if (combo != null && !combo.isDisposed()) combo.setText(oldVal);
   if (listener != null) combo.addModifyListener(listener);
   postOp(POST_UNDO);
 }
  protected Control createDialogArea(final Composite parent) {
    Composite container = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);
    Group group = new Group(container, SWT.None);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    layout = new GridLayout();
    layout.numColumns = 2;
    group.setLayout(layout);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    container.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(gd);

    Label urlLabel = new Label(group, SWT.NONE);
    GridData gd_urlLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_urlLabel.widthHint = 100;
    urlLabel.setLayoutData(gd_urlLabel);
    urlLabel.setText("URL ");

    Text urlText = new Text(group, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    urlText.setLayoutData(gd);

    urlText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            Text url = (Text) event.widget;
            serverUrl = url.getText();
            setServerUrl(serverUrl);
          }
        });

    Label pathLabel = new Label(group, SWT.NONE);
    pathLabel.setText("Path ");

    urlText.setText("https://localhost:9443");

    pathText = new Combo(group, SWT.NONE);
    pathText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent arg0) {
            updateSelectedPath();
          }
        });
    pathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    pathText.removeAll();
    List<String> defaultPaths = getDefaultPaths();
    for (String path : defaultPaths) {
      pathText.add(path);
    }
    pathText.select(getDefaultPathId());
    updateSelectedPath();
    return super.createDialogArea(parent);
  }
 public IStatus redo() {
   if (listener != null) combo.removeModifyListener(listener);
   wc.setAttribute(key, newVal);
   if (combo != null && !combo.isDisposed()) combo.setText(newVal);
   if (listener != null) combo.addModifyListener(listener);
   postOp(POST_REDO);
   return Status.OK_STATUS;
 }
  /** Add listeners to widgets */
  private void hookListeners() {
    if (creationDirectionCombo != null && directionComboViewer != null) {
      // listener to select invocation type
      ModifyListener lTypeListener =
          new ModifyListener() {

            /**
             * @see
             *     org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
            public void modifyText(ModifyEvent e) {
              ISelection sel = directionComboViewer.getSelection();
              if (sel instanceof StructuredSelection) {
                String firstElement = ((StructuredSelection) sel).getFirstElement().toString();
                selectedDirection = ParameterDirectionKind.getByName(firstElement);
              } else {
                selectedDirection = null;
              }
              // reset name
              setInvokedName(null);
              refreshOkButton();
            }
          };
      creationDirectionCombo.addModifyListener(lTypeListener);
    }
    // listener to invocation element name
    ModifyListener lNameListener =
        new ModifyListener() {

          /**
           * @see
           *     org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
           */
          public void modifyText(ModifyEvent e) {
            setInvokedName(creationNameText.getText());
          }
        };
    creationNameText.addModifyListener(lNameListener);
    // listener to select new element parent
    SelectionListener selectParentBtnListener =
        new SelectionAdapter() {

          /**
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleChooseType();
            // reset name if not set
            if (selectedName == null) {
              setInvokedName(null);
            }
            refreshOkButton();
          }
        };
    creationTypeButton.addSelectionListener(selectParentBtnListener);
  }
  /*
   * (non-Javadoc)
   * @see  it.baeyens.avreclipse.ui.editors.targets.AbstractTargetConfigurationEditorPart#createSectionContent
   * (org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
   */
  @Override
  protected void createSectionContent(Composite parent, FormToolkit toolkit) {
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 12;
    parent.setLayout(layout);

    //
    // The MCU Combo
    //
    toolkit.createLabel(parent, "MCU type:");
    fMCUcombo = new Combo(parent, SWT.READ_ONLY);
    toolkit.adapt(fMCUcombo, true, true);
    fMCUcombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false));
    fMCUcombo.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            String mcuid = AVRMCUidConverter.name2id(fMCUcombo.getText());
            getTargetConfiguration().setMCU(mcuid);
            refreshMessages();
            getManagedForm().dirtyStateChanged();
          }
        });

    //
    // The FCPU Combo
    //
    toolkit.createLabel(parent, "MCU clock frequency:");
    fFCPUcombo = new Combo(parent, SWT.NONE);
    toolkit.adapt(fFCPUcombo, true, true);
    fFCPUcombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false));
    fFCPUcombo.setTextLimit(9); // max. 999 MHz
    fFCPUcombo.setToolTipText("Target Hardware Clock Frequency in Hz");
    fFCPUcombo.setVisibleItemCount(FCPU_VALUES.length);
    fFCPUcombo.setItems(FCPU_VALUES);

    fFCPUcombo.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            getTargetConfiguration().setFCPU(Integer.parseInt(fFCPUcombo.getText()));
            getManagedForm().dirtyStateChanged();
          }
        });

    // The verify listener to restrict the input to integers
    fFCPUcombo.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            String text = event.text;
            if (!text.matches("[0-9]*")) {
              event.doit = false;
            }
          }
        });
  }
 private void createUIListenersCategoryCombo() {
   fCategoryCombo.addModifyListener(
       new ModifyListener() {
         @Override
         public void modifyText(ModifyEvent e) {
           fDataCategoryName = fCategoryCombo.getText();
         }
       });
 }
    CheckboxHandler(Control control1, Control control2, Button checkbox) {
      if (control1 instanceof Text) {
        ((Text) control1).addModifyListener(this);
      } else if (control1 instanceof Combo) {
        ((Combo) control1).addModifyListener(this);
      } else {
        throw new IllegalArgumentException();
      }

      if (control2 instanceof Text) {
        ((Text) control2).addModifyListener(this);
      } else if (control2 instanceof Combo) {
        ((Combo) control2).addModifyListener(this);
      } else if (control2 != null) {
        throw new IllegalArgumentException();
      }

      this.control1 = control1;
      this.control2 = control2;
      this.checkbox = checkbox;
    }
  /** This method initializes cReference */
  private void createCReference() {
    GridData gridData13 = new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);

    cReference = JOE_Cbo_SettingForm_Reference.Control(new Combo(group1, SWT.NONE));
    cReference.setLayoutData(gridData13); // Generated
    cReference.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            applySettingStatus();
          }
        });
  }
Example #14
0
  private void addFileNameControls(Composite group) {
    // grid layout with 2 columns

    // Line with label, combo and button
    Label label = new Label(group, SWT.LEAD);
    label.setText(SearchMessages.SearchPage_fileNamePatterns_text);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    label.setFont(group.getFont());

    fExtensions = new Combo(group, SWT.SINGLE | SWT.BORDER);
    fExtensions.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateOKStatus();
          }
        });
    GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
    data.widthHint = convertWidthInCharsToPixels(50);
    fExtensions.setLayoutData(data);
    fExtensions.setFont(group.getFont());

    Button button = new Button(group, SWT.PUSH);
    button.setText(SearchMessages.SearchPage_browse);
    GridData gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1);
    gridData.widthHint = SWTUtil.getButtonWidthHint(button);
    button.setLayoutData(gridData);
    button.setFont(group.getFont());

    fFileTypeEditor = new FileTypeEditor(fExtensions, button);

    // Text line which explains the special characters
    Label description = new Label(group, SWT.LEAD);
    description.setText(SearchMessages.SearchPage_fileNamePatterns_hint);
    description.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    description.setFont(group.getFont());

    fSearchDerivedCheckbox = new Button(group, SWT.CHECK);
    fSearchDerivedCheckbox.setText(SearchMessages.TextSearchPage_searchDerived_label);

    fSearchDerivedCheckbox.setSelection(fSearchDerived);
    fSearchDerivedCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fSearchDerived = fSearchDerivedCheckbox.getSelection();
            writeConfiguration();
          }
        });
    fSearchDerivedCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    fSearchDerivedCheckbox.setFont(group.getFont());
  }
  private void createProjectCombo(Composite _parent) {
    GridDataFactory grabHor = GridDataFactory.fillDefaults().grab(true, false);
    Composite parent = new Composite(_parent, SWT.NONE);
    parent.setLayout(new GridLayout(3, false));

    grabHor.applyTo(parent);

    Label label = new Label(parent, SWT.NONE);
    label.setText("Project");

    projectCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    List<GradleProject> projects = getGradleProjects();
    String[] items = new String[projects.size()];
    int i = 0;
    for (GradleProject p : projects) {
      items[i++] = p.getName();
    }
    projectCombo.setItems(items);

    if (project != null) {
      projectCombo.setText(project.getName());
    }

    projectCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            projectComboChanged();
          }
        });

    refreshButton = new Button(parent, SWT.PUSH);
    refreshButton.setText("Refresh");
    refreshButton.setToolTipText("Rebuild the gradle model and refresh the task list");
    refreshButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            try {
              GradleProject currentProject = project;
              if (currentProject != null) {
                currentProject.requestGradleModelRefresh();
                taskSelectionTreeViewer.refresh();
              }
            } catch (CoreException e) {
              GradleCore.log(e);
            }
          }
        });

    grabHor.align(SWT.RIGHT, SWT.CENTER).applyTo(refreshButton);
  }
Example #16
0
  @Test
  public void testRenderAddModifyListener() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {}
        });
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "Modify"));
  }
  private void getComboValue(Composite composite) {
    final Label labelComboValue = new Label(composite, SWT.NONE);
    labelComboValue.setText(Messages.getString("UpdateAttributeDialog.5")); // $NON-NLS-1$
    labelComboValue.setLayoutData(new GridData(SWT.NONE, SWT.CENTER, false, false));

    comboValue = new Combo(composite, 1);
    comboValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    comboValue.setItems(new String[0]);
    comboValue.setEnabled(false);
    comboValue.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            attributeValueModified();
          }
        });
  }
Example #18
0
  @Test
  public void testRenderModifyListenerUnchanged() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {}
        });
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "modify"));
  }
 private void createComboValueComposite(String[] items) {
   if (!(value instanceof Combo)) {
     Composite parent = value.getParent();
     if (value != null) {
       value.dispose();
     }
     value = new Combo(parent, SWT.BORDER | SWT.LEAD | SWT.DROP_DOWN | SWT.READ_ONLY);
     GridData bgd = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
     bgd.horizontalSpan = 2;
     value.setLayoutData(bgd);
     ((Combo) value).setItems(items);
     ((Combo) value).addModifyListener(modifyListener);
     if (items != null && items.length > 0) {
       ((Combo) value).select(0);
     }
     parent.layout();
   }
 }
  /**
   * Creates the lower group with the fields to choose the resource confirmation and the target XML
   * file.
   *
   * @param content A composite with a 1-column grid layout
   */
  private void createResFileGroup(Composite content) {

    Group group = new Group(content, SWT.NONE);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setText("XML resource to edit");

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    group.setLayout(layout);

    // line: selection of the res config

    Label label;
    label = new Label(group, SWT.NONE);
    label.setText("&Configuration:");

    mConfigSelector = new ConfigurationSelector(group, false /*deviceMode*/);
    GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    gd.horizontalSpan = 2;
    gd.widthHint = ConfigurationSelector.WIDTH_HINT;
    gd.heightHint = ConfigurationSelector.HEIGHT_HINT;
    mConfigSelector.setLayoutData(gd);
    OnConfigSelectorUpdated onConfigSelectorUpdated = new OnConfigSelectorUpdated();
    mConfigSelector.setOnChangeListener(onConfigSelectorUpdated);

    // line: selection of the output file

    label = new Label(group, SWT.NONE);
    label.setText("Resource &file:");

    mResFileCombo = new Combo(group, SWT.DROP_DOWN);
    mResFileCombo.select(0);
    mResFileCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mResFileCombo.addModifyListener(onConfigSelectorUpdated);

    // set output file name to the last one used

    String projPath = mProject.getFullPath().toPortableString();
    String filePath = sLastResFilePath.get(projPath);

    mResFileCombo.setText(filePath != null ? filePath : DEFAULT_RES_FILE_PATH);
    onConfigSelectorUpdated.run();
  }
 /**
  * Create widgets to enable user to input data for fields of text or number type
  *
  * @param parent composite where the widgets will be attached to
  * @param monkeyOption the corresponding monkey option
  */
 private void createWidgetsForTextOrNumberType(
     final Composite parent, final MonkeyOption monkeyOption) {
   // create input text
   if ((monkeyOption.getPreDefinedValues() == null)
       || (monkeyOption.getPreDefinedValues().size() == 0)) {
     final Text inputText = new Text(parent, SWT.SINGLE | SWT.BORDER);
     inputText.setText(monkeyOption.getValue());
     monkeyOption.setValueWidget(inputText);
     inputText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
     inputText.addModifyListener(
         new ModifyListener() {
           @Override
           public void modifyText(ModifyEvent e) {
             monkeyOption.setValue(inputText.getText());
             notifyCompositeChangeListeners();
           }
         });
   }
   // create combobox
   else {
     final Combo combo = new Combo(parent, SWT.READ_ONLY);
     monkeyOption.setValueWidget(combo);
     int selectedIndex = 0;
     for (String preDefinedValue : monkeyOption.getPreDefinedValues()) {
       combo.add(preDefinedValue);
       if (monkeyOption.getValue().equals(preDefinedValue)) {
         combo.select(selectedIndex);
       } else {
         selectedIndex++;
       }
     }
     combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
     combo.addModifyListener(
         new ModifyListener() {
           @Override
           public void modifyText(ModifyEvent e) {
             monkeyOption.setValue(combo.getText());
             notifyCompositeChangeListeners();
           }
         });
   }
 }
  protected Combo createGroupText(Composite panel, PaletteEntry entry) throws Exception {
    PaletteContainer container = entry.getParent();
    Combo group = new Combo(panel, SWT.SINGLE);
    String[] favoriteGroupNames = PaletteBuilder.getInstance().getFavoriteGroupNames();
    group.setItems(favoriteGroupNames);
    String label = getEntry().getParent().getLabel();
    List groups = Arrays.asList(favoriteGroupNames);
    String current = entry.getParent().getLabel();
    if (groups.contains(current)) {
      group.select(groups.indexOf(label));
    }

    group.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            handleGroupChanged(((Combo) e.getSource()).getText());
          }
        });
    return group;
  }
  protected void addComboBox(
      Composite composite, String label, String key, int textLimit, int indentation) {
    Label labelControl = new Label(composite, SWT.NONE);
    labelControl.setText(label);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalIndent = indentation;
    labelControl.setLayoutData(gd);

    Combo comboControl =
        new Combo(
            composite,
            SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); // TODO: When will the combo be disposed?
    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    if (textLimit != NO_TEXT_LIMIT) {
      gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
      comboControl.setTextLimit(textLimit);
    }
    comboControl.setLayoutData(gd);
    fComboBoxes.put(comboControl, key);
    comboControl.addModifyListener(fComboBoxListener); // TODO: When will the listener be removed?
  }
  private Control createExpression(final Composite parent) {
    final Composite result = new Composite(parent, SWT.NONE);
    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    result.setLayout(layout);

    // Pattern text + info
    final Label label = new Label(result, SWT.LEFT);
    label.setText("Expression"); // SearchMessages.SearchPage_expression_label
    // );
    label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));

    // Pattern combo
    fPattern = new Combo(result, SWT.SINGLE | SWT.BORDER);
    fPattern.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("synthetic-access")
          @Override
          public void widgetSelected(final SelectionEvent e) {
            handlePatternSelected();
            updateOKStatus();
          }
        });
    fPattern.addModifyListener(
        new ModifyListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void modifyText(final ModifyEvent e) {
            doPatternModified();
            updateOKStatus();
          }
        });
    // TextFieldNavigationHandler.install(fPattern);
    final GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
    data.widthHint = convertWidthInCharsToPixels(50);
    fPattern.setLayoutData(data);

    return result;
  }
Example #25
0
    /**
     *
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
    public void createControl(Composite parent) {
      Composite composite = new Composite(parent, SWT.NONE);
      {
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.verticalSpacing = 12;
        composite.setLayout(layout);

        GridData data = new GridData();
        data.verticalAlignment = GridData.FILL;
        data.grabExcessVerticalSpace = true;
        data.horizontalAlignment = GridData.FILL;
        composite.setLayoutData(data);
      }

      Label containerLabel = new Label(composite, SWT.LEFT);
      {
        containerLabel.setText(WebPageEditorPlugin.INSTANCE.getString("_UI_ModelObject"));

        GridData data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        containerLabel.setLayoutData(data);
      }

      initialObjectField = new Combo(composite, SWT.BORDER);
      {
        GridData data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.grabExcessHorizontalSpace = true;
        initialObjectField.setLayoutData(data);
      }

      for (String objectName : getInitialObjectNames()) {
        initialObjectField.add(getLabel(objectName));
      }

      if (initialObjectField.getItemCount() == 1) {
        initialObjectField.select(0);
      }
      initialObjectField.addModifyListener(validator);

      Label encodingLabel = new Label(composite, SWT.LEFT);
      {
        encodingLabel.setText(WebPageEditorPlugin.INSTANCE.getString("_UI_XMLEncoding"));

        GridData data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        encodingLabel.setLayoutData(data);
      }
      encodingField = new Combo(composite, SWT.BORDER);
      {
        GridData data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.grabExcessHorizontalSpace = true;
        encodingField.setLayoutData(data);
      }

      for (String encoding : getEncodings()) {
        encodingField.add(encoding);
      }

      encodingField.select(0);
      encodingField.addModifyListener(validator);

      setPageComplete(validatePage());
      setControl(composite);
    }
 /**
  * addModifyListener to the combo and the checkbox.
  *
  * @param listener
  */
 public void addModifyListener(ModifyListener listener) {
   combo.addModifyListener(listener);
 }
package net.heartsome.cat.te.tmxeditor.editor;
  void addControls(final Composite parent) {
    Label desc = new Label(parent, SWT.LEFT | SWT.WRAP);
    desc.setText("The Ceylon builder compiles Ceylon source contained in the project.");

    enableBuilderButton = new Button(parent, SWT.PUSH);
    enableBuilderButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    enableBuilderButton.setText("Enable Ceylon Builder");
    enableBuilderButton.setEnabled(!builderEnabled && getSelectedProject().isOpen());
    enableBuilderButton.setImage(
        CeylonPlugin.getInstance().getImageRegistry().get(CeylonResources.ELE32));
    // enableBuilder.setSize(40, 40);

    Label sep = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData sgd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    sep.setLayoutData(sgd);

    Composite composite = new Composite(parent, SWT.NONE);
    GridData gdb = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gdb.grabExcessHorizontalSpace = true;
    composite.setLayoutData(gdb);
    GridLayout layoutb = new GridLayout();
    layoutb.numColumns = 1;
    layoutb.marginBottom = 1;
    composite.setLayout(layoutb);

    addCharacterEncodingLabel(composite);

    offlineButton = new Button(composite, SWT.CHECK);
    offlineButton.setText("Work offline (disable connection to remote module repositories)");
    offlineButton.setEnabled(builderEnabled);
    offlineButton.setSelection(offlineOption != null && offlineOption);
    offlineButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            if (offlineOption == null) {
              offlineOption = true;
            } else {
              offlineOption = !offlineOption;
            }
          }
        });

    final Group platformGroup = new Group(parent, SWT.NONE);
    platformGroup.setText("Target virtual machine");
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.grabExcessHorizontalSpace = true;
    platformGroup.setLayoutData(gd);
    GridLayout layout = new GridLayout();

    layout.numColumns = 1;
    layout.marginBottom = 1;
    platformGroup.setLayout(layout);

    compileToJava = new Button(platformGroup, SWT.CHECK);
    compileToJava.setText("Compile project for JVM");
    compileToJava.setSelection(backendJava);
    compileToJava.setEnabled(builderEnabled);

    compileToJs = new Button(platformGroup, SWT.CHECK);
    compileToJs.setText("Compile project to JavaScript");
    compileToJs.setSelection(backendJs);
    compileToJs.setEnabled(builderEnabled);

    Group troubleGroup = new Group(parent, SWT.NONE);
    troubleGroup.setText("Troubleshooting");
    troubleGroup.setLayout(new GridLayout(1, false));
    GridData gd3 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd3.grabExcessHorizontalSpace = true;
    troubleGroup.setLayoutData(gd3);

    astAwareIncrementalBuidsButton = new Button(troubleGroup, SWT.CHECK);
    astAwareIncrementalBuidsButton.setText("Disable structure-aware incremental compilation");
    astAwareIncrementalBuidsButton.setSelection(!astAwareIncrementalBuids);
    astAwareIncrementalBuidsButton.setEnabled(builderEnabled);

    final Button logButton = new Button(troubleGroup, SWT.CHECK);
    logButton.setText("Log compiler activity to Eclipse console");
    boolean loggingEnabled = verbose != null && !verbose.isEmpty();
    logButton.setSelection(loggingEnabled);
    logButton.setEnabled(builderEnabled);

    final Composite verbosityOptions = new Composite(troubleGroup, SWT.NONE);
    verbosityOptions.setLayout(new GridLayout(2, false));
    final GridData gd4 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd4.grabExcessHorizontalSpace = true;
    verbosityOptions.setLayoutData(gd4);
    gd4.exclude = !loggingEnabled;
    verbosityOptions.setVisible(loggingEnabled);
    verbosityOptions.setEnabled(loggingEnabled);

    final Label verbosityLabel = new Label(verbosityOptions, SWT.NONE);
    verbosityLabel.setText("Verbosity level");

    verboseText = new Combo(verbosityOptions, SWT.DROP_DOWN);
    verboseText.add("code");
    verboseText.add("ast");
    verboseText.add("loader");
    verboseText.add("cmr");
    verboseText.add("all");
    GridData vgd = new GridData();
    vgd.grabExcessHorizontalSpace = true;
    vgd.minimumWidth = 75;
    verboseText.setLayoutData(vgd);
    verboseText.setTextLimit(20);
    if (loggingEnabled) {
      verboseText.setText(verbose);
    }
    verboseText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            String str = verboseText.getText();
            if (str == null || str.isEmpty()) {
              verbose = null;
            } else {
              verbose = str.trim();
            }
          }
        });

    logButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean selected = logButton.getSelection();
            verbose = selected ? verboseText.getText() : null;
            verboseText.setEnabled(selected);
            ((GridData) verbosityOptions.getLayoutData()).exclude = !selected;
            verbosityOptions.setVisible(selected);
            verbosityOptions.setEnabled(selected);
            verboseText.setVisible(selected);
            parent.layout();
          }
        });

    enableBuilderButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            new CeylonNature().addToProject(getSelectedProject());
            enableBuilderButton.setEnabled(false);
            astAwareIncrementalBuidsButton.setEnabled(true);
            compileToJs.setEnabled(true);
            compileToJava.setEnabled(true);
            offlineButton.setEnabled(true);
            logButton.setEnabled(true);
            builderEnabled = true;
          }
        });

    astAwareIncrementalBuidsButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            astAwareIncrementalBuids = !astAwareIncrementalBuids;
          }
        });

    compileToJava.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            backendJava = !backendJava;
          }
        });

    compileToJs.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            backendJs = !backendJs;
          }
        });

    Link buildPathsPageLink = new Link(parent, 0);
    buildPathsPageLink.setText("See '<a>Build Paths</a>' to configure project build paths.");
    buildPathsPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonBuildPathsPropertiesPage.ID, null);
          }
        });

    Link openRepoPageLink = new Link(parent, 0);
    openRepoPageLink.setText(
        "See '<a>Module Repositories</a>' to configure project module repositores.");
    openRepoPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonRepoPropertiesPage.ID, null);
          }
        });

    Link warningsPageLink = new Link(parent, 0);
    warningsPageLink.setText("See '<a>Warnings</a>' to enable or disable warnings.");
    warningsPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonWarningsPropertiesPage.ID, null);
          }
        });
  }
Example #29
0
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    composite.setLayout(gridLayout);

    Label urlLabel = new Label(composite, SWT.NONE);
    urlLabel.setText(Messages.Wizard_WW_Description);
    GridData gridLabel = new GridData();
    urlLabel.setLayoutData(gridLabel);

    // region Enter URL
    btnUrl = new Button(composite, SWT.RADIO);
    btnUrl.addSelectionListener(radioSelectionListener);
    btnUrl.setSelection(true);
    btnUrl.setText(Messages.Wizard_WW_Url);

    comboUrl = new Combo(composite, SWT.BORDER);
    comboUrl.setItems(getRecentURLs());
    comboUrl.setVisibleItemCount(RecentHistory.DEFAULT_LIMIT);

    GridData gridDataCombo = new GridData(GridData.FILL_HORIZONTAL);
    gridDataCombo.widthHint = 400;
    comboUrl.setLayoutData(gridDataCombo);

    // For Drag 'n Drop as well as for general selections
    // look for a url as part of the selection
    Map<String, Serializable> params = defaultParams(); // based on selection
    setDefaultUrl(getURL(params));

    comboUrl.addModifyListener(this);
    // endregion

    // region Select local file
    btnLocalFile = new Button(composite, SWT.RADIO);
    btnLocalFile.setText(Messages.Wizard_WW_LocalFile);

    Composite row = new Composite(composite, SWT.NONE);
    row.setLayout(new RowLayout(SWT.HORIZONTAL));

    txtLocalFile = new Text(row, SWT.BORDER);
    txtLocalFile.setLayoutData(new RowData(350, 20));

    btnOpenFileDialog = new Button(row, SWT.PUSH);
    btnOpenFileDialog.setText(Messages.Wizard_WW_SelectFile);
    final Shell shell = parent.getShell();
    btnOpenFileDialog.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(shell, SWT.OPEN);
            fd.setText(Messages.Wizard_WW_SelectFile);
            setLastUsedPath(fd);

            // Set filter on XML-files
            String[] filterExtensions = {"*.xml"}; // $NON-NLS-1$
            String[] filterNames = {"NASA WorldWind Configuration File (*.xml)"}; // $NON-NLS-1$
            fd.setFilterExtensions(filterExtensions);
            fd.setFilterNames(filterNames);

            // Open the dialog
            String selectedFile = fd.open();

            if (selectedFile != null) {
              txtLocalFile.setText(selectedFile);
              saveLastUsedPath(fd.getFilterPath());

              modifyText(null);
            }
          }

          private void saveLastUsedPath(String path) {
            if (settings != null && path != null) {
              settings.put(WW_PATH, path);
            }
          }

          private void setLastUsedPath(FileDialog fd) {
            if (settings != null) {
              fd.setFilterPath(settings.get(WW_PATH));
            }
          }
        });
    // endregion

    radioSelectionListener.widgetSelected(null);

    setControl(composite);
    getWizard().getContainer().updateButtons();

    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              public void run() {
                EndConnectionState currentState = getState();
                Map<IService, Throwable> errors = currentState.getErrors();
                if (errors != null && !errors.isEmpty()) {
                  for (Map.Entry<IService, Throwable> entry : errors.entrySet()) {
                    if (entry.getKey() instanceof WWService) {
                      Throwable value = entry.getValue();
                      String message =
                          Messages.Wizard_WW_ConnectionProblem + value.getLocalizedMessage();
                      setErrorMessage(message);
                    }
                  }
                }
              }
            });
  }
  /** @param composite */
  private void createInstallationDirectoryGroup(Composite parent) {
    Group instDirGroup =
        NSISWizardDialogUtil.createGroup(
            parent, 2, "installation.directory.group.label", null, false); // $NON-NLS-1$

    NSISWizardSettings settings = mWizard.getSettings();

    ((GridData)
                NSISWizardDialogUtil.createLabel(
                        instDirGroup, "installation.directory.label", true, null, isScriptWizard())
                    .getLayoutData())
            .horizontalSpan =
        1; //$NON-NLS-1$

    final Composite instDirComposite = new Composite(instDirGroup, SWT.NONE);
    instDirComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final StackLayout instDirLayout = new StackLayout();
    instDirComposite.setLayout(instDirLayout);
    final Combo instDirCombo =
        NSISWizardDialogUtil.createCombo(
            instDirComposite,
            1,
            NSISWizardUtil.getPathConstantsAndVariables(settings.getTargetPlatform()),
            settings.getInstallDir(),
            false,
            true,
            null);
    final Text instDirText =
        NSISWizardDialogUtil.createText(instDirComposite, settings.getInstallDir(), 1, true, null);
    instDirLayout.topControl = instDirCombo;

    Runnable r =
        new Runnable() {
          private String mInstDirParent = ""; // $NON-NLS-1$

          private void updateInstDir(NSISWizardSettings settings) {
            Control topControl;
            if (isMultiUser()) {
              if (settings.getInstallDir().startsWith(mInstDirParent)) {
                String instDir = settings.getInstallDir().substring(mInstDirParent.length());
                settings.setInstallDir(instDir);
                instDirText.setText(instDir);
              }
              topControl = instDirText;
            } else {
              if (!settings.getInstallDir().startsWith(mInstDirParent)) {
                String instDir = mInstDirParent + settings.getInstallDir();
                settings.setInstallDir(instDir);
                instDirCombo.setText(instDir);
              }
              topControl = instDirCombo;
            }
            if (instDirLayout.topControl != topControl) {
              instDirLayout.topControl = topControl;
              instDirComposite.layout(true);
            }
            validateField(INSTDIR_CHECK);
          }

          public void run() {
            final PropertyChangeListener propertyListener =
                new PropertyChangeListener() {
                  public void propertyChange(PropertyChangeEvent evt) {
                    if (NSISWizardSettings.INSTALLER_TYPE.equals(evt.getPropertyName())
                        || NSISWizardSettings.MULTIUSER_INSTALLATION.equals(
                            evt.getPropertyName())) {
                      updateInstDir(mWizard.getSettings());
                    } else if (NSISWizardSettings.INSTALL_DIR.equals(evt.getPropertyName())) {
                      if (!isMultiUser()) {
                        setInstDirParent(mWizard.getSettings());
                      }
                    }
                  }
                };
            final INSISWizardSettingsListener settingsListener =
                new INSISWizardSettingsListener() {
                  public void settingsChanged(
                      NSISWizardSettings oldSettings, final NSISWizardSettings newSettings) {
                    if (oldSettings != null) {
                      oldSettings.removePropertyChangeListener(propertyListener);
                    }
                    setInstDirParent(newSettings);
                    if (newSettings != null) {
                      newSettings.addPropertyChangeListener(propertyListener);
                    }
                    updateInstDir(newSettings);
                  }
                };
            mWizard.addSettingsListener(settingsListener);
            mWizard.getSettings().addPropertyChangeListener(propertyListener);
            instDirCombo.addDisposeListener(
                new DisposeListener() {
                  public void widgetDisposed(DisposeEvent e) {
                    mWizard.getSettings().removePropertyChangeListener(propertyListener);
                    mWizard.removeSettingsListener(settingsListener);
                  }
                });
            setInstDirParent(mWizard.getSettings());
            updateInstDir(mWizard.getSettings());
          }

          private void setInstDirParent(NSISWizardSettings settings) {
            mInstDirParent = ""; // $NON-NLS-1$
            if (settings != null) {
              String instDir = settings.getInstallDir();
              if (!Common.isEmpty(instDir)) {
                int n = instDir.lastIndexOf('\\');
                if (n > 0 && n < instDir.length() - 1) {
                  mInstDirParent = instDir.substring(0, n + 1);
                }
              }
            }
          }
        };

    r.run();

    GridData gd = (GridData) instDirCombo.getLayoutData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    instDirCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String text = ((Combo) e.widget).getText();
            mWizard.getSettings().setInstallDir(text);
            validateField(INSTDIR_CHECK);
          }
        });
    instDirText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String text = ((Text) e.widget).getText();
            mWizard.getSettings().setInstallDir(text);
            validateField(INSTDIR_CHECK);
          }
        });

    final Button changeInstDir =
        NSISWizardDialogUtil.createCheckBox(
            instDirGroup,
            "change.installation.directory.label", //$NON-NLS-1$
            settings.isChangeInstallDir(),
            (settings.getInstallerType() != INSTALLER_TYPE_SILENT),
            null,
            false);
    changeInstDir.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setChangeInstallDir(((Button) e.widget).getSelection());
          }
        });

    addPageChangedRunnable(
        new Runnable() {
          public void run() {
            if (isCurrentPage()) {
              NSISWizardSettings settings = mWizard.getSettings();
              instDirCombo.setText(settings.getInstallDir());
              changeInstDir.setEnabled(settings.getInstallerType() != INSTALLER_TYPE_SILENT);
            }
          }
        });

    final PropertyChangeListener propertyListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            if (NSISWizardSettings.TARGET_PLATFORM.equals(evt.getPropertyName())) {
              NSISWizardDialogUtil.populateCombo(
                  instDirCombo,
                  NSISWizardUtil.getPathConstantsAndVariables(
                      ((Integer) evt.getNewValue()).intValue()),
                  ((NSISWizardSettings) evt.getSource()).getInstallDir());
            }
          }
        };
    settings.addPropertyChangeListener(propertyListener);
    final INSISWizardSettingsListener listener =
        new INSISWizardSettingsListener() {
          public void settingsChanged(
              NSISWizardSettings oldSettings, NSISWizardSettings newSettings) {
            if (oldSettings != null) {
              oldSettings.removePropertyChangeListener(propertyListener);
            }
            instDirCombo.setText(newSettings.getInstallDir());
            changeInstDir.setSelection(newSettings.isChangeInstallDir());
            changeInstDir.setEnabled(newSettings.getInstallerType() != INSTALLER_TYPE_SILENT);
            newSettings.addPropertyChangeListener(propertyListener);
          }
        };
    mWizard.addSettingsListener(listener);

    instDirGroup.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            mWizard.removeSettingsListener(listener);
            mWizard.getSettings().removePropertyChangeListener(propertyListener);
          }
        });
  }