Esempio n. 1
0
  private static void createIconCombo(Composite parent, final EmoticonImage icon) {
    Label label = new Label(parent, SWT.NONE);
    label.setText("Icon:");

    final Combo combo = new Combo(parent, SWT.NONE);
    combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    if (icon.image != null) combo.setText(icon.image.path);

    combo.addListener(
        SWT.FocusIn,
        new Listener() {
          public void handleEvent(Event event) {
            if (combo.getItemCount() > 0) return;

            inGuiSetCommand = true;

            for (ImageFile file : mep.images) combo.add(file.path);

            inGuiSetCommand = false;
          }
        });

    DelayedListener listener =
        new DelayedListener(
            new Listener() {
              public void handleEvent(Event e) {
                if (combo.getText().trim().length() <= 0) icon.image = null;
                else icon.image = mep.createTemporaryImage(combo.getText(), icon.protocol);
                fillFramesHolder(icon, false);
              }
            });
    combo.addListener(SWT.Selection, listener.fast());
    combo.addListener(SWT.Modify, listener.delayed());
  }
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    container.setLayout(new GridLayout(1, false));

    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    Label lblMetaModelThe = new Label(composite, SWT.NONE);
    GridData gd_lblMetaModelThe = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblMetaModelThe.widthHint = 270;
    lblMetaModelThe.setLayoutData(gd_lblMetaModelThe);
    lblMetaModelThe.setText("Meta model the Helper conforms to:");

    comboMM = new Combo(composite, SWT.NONE);
    GridData gd_comboMM = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboMM.widthHint = 330;
    comboMM.setLayoutData(gd_comboMM);

    Composite composite_1 = new Composite(container, SWT.NONE);
    composite_1.setLayout(new GridLayout(2, false));

    Label lblMetaModelType = new Label(composite_1, SWT.NONE);
    GridData gd_lblMetaModelType = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblMetaModelType.widthHint = 270;
    lblMetaModelType.setLayoutData(gd_lblMetaModelType);
    lblMetaModelType.setText("Meta model type of the input port:");

    comboInput = new Combo(composite_1, SWT.NONE);
    comboInput.setEnabled(false);
    GridData gd_comboInput = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboInput.widthHint = 330;
    comboInput.setLayoutData(gd_comboInput);

    Composite composite_2 = new Composite(container, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));

    Label lblMetaModelType_1 = new Label(composite_2, SWT.NONE);
    GridData gd_lblMetaModelType_1 = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblMetaModelType_1.widthHint = 270;
    lblMetaModelType_1.setLayoutData(gd_lblMetaModelType_1);
    lblMetaModelType_1.setText("Meta model type of the output port:");

    comboOutput = new Combo(composite_2, SWT.NONE);
    comboOutput.setEnabled(false);
    GridData gd_comboOutput = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboOutput.widthHint = 330;
    comboOutput.setLayoutData(gd_comboOutput);

    setComboMM();
    comboMM.setFocus();
    comboMM.addListener(SWT.Modify, this);
    comboInput.addListener(SWT.Modify, this);
    comboOutput.addListener(SWT.Modify, this);

    this.setPageComplete(false);
  }
Esempio n. 3
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Combo combo = new Combo(shell, SWT.NONE);
   combo.setItems(new String[] {"A-1", "B-1", "C-1"});
   Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
   text.setText("some text");
   combo.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   text.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  private void addListenerrs() {
    add.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            onAddClicked();
          }
        });

    delete.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            onDeleteClicked();
          }
        });

    Listener selectionListener =
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            if (event.type == SWT.Selection) {
              updateButtonsState();
            }
          }
        };
    availableConfigsCombo.addListener(SWT.Selection, selectionListener);
    selectedConfigsList.addListener(SWT.Selection, selectionListener);
  }
Esempio n. 5
0
  /**
   * Must be called after createProjectDropDownMenu, since we need to figure out the selected
   * project.
   *
   * @author stolz
   */
  protected void createProductDropDownMenu(TabListener myListener, Composite comp) {
    Group group = createGroup(comp, "ABS Product", 1, 1, GridData.FILL_HORIZONTAL);

    productDropDown = new Combo(group, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    GridData gridData = new GridData();
    gridData.widthHint = 200;
    productDropDown.setLayoutData(gridData);

    productDropDown.addListener(SWT.Selection, myListener);
  }
Esempio n. 6
0
  protected void createProjectDropDownMenu(TabListener myListener, Composite comp) {
    Group group = createGroup(comp, "ABS Project", 1, 1, GridData.FILL_HORIZONTAL);

    projectDropDown = new Combo(group, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    GridData gridData = new GridData();
    gridData.widthHint = 200;
    projectDropDown.setLayoutData(gridData);

    projectDropDown.addListener(SWT.Selection, myListener);
    /* Refresh products everytime the project is changed */
    projectDropDown.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            fillProductDropDownMenue(null);
            updateErrors();
          }
        });
  }
Esempio n. 7
0
  @Test
  public void testListenDefaultSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addListener(SWT.DefaultSelection, mock(Listener.class));
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "Selection"));
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "DefaultSelection"));
  }
Esempio n. 8
0
  @Test
  public void testRemoveListenSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Listener listener = mock(Listener.class);
    combo.addListener(SWT.Selection, listener);
    Fixture.preserveWidgets();

    combo.removeListener(SWT.Selection, listener);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.FALSE, message.findListenProperty(combo, "Selection"));
  }
  public void createContent(Composite parent) {
    controlTypeChooser = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
    controlTypeChooser.setVisibleItemCount(30);
    controlTypeChooser.addListener(
        SWT.Selection,
        new Listener() {

          public void handleEvent(Event e) {
            List<Listener> listeners =
                DefaultParameterDialogControlTypeHelper.this.listeners.get(SWT.Selection);
            if (listeners == null) return;
            for (int i = 0; i < listeners.size(); i++) listeners.get(i).handleEvent(e);
          }
        });
  }
  /**
   * creates the control area for the priority
   *
   * @param control the parent composite
   */
  protected void createPriorityControl(Composite control) {
    final Label priorityLabel = new Label(control, SWT.NONE);
    priorityLabel.setText(Messages.Local_Palette_Priority);
    priorityLabel.setToolTipText(Messages.Local_Palette_Priority_Tooltip);

    // choice widget among priority values
    priorityCombo = new Combo(control, SWT.READ_ONLY);
    priorityCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    priorityCombo.setToolTipText(Messages.Local_Palette_Priority_Tooltip);
    priorityCombo.setItems(priorityList);

    // initialize, then add the listener...
    initialPopulatePriorityField();

    priorityCombo.addListener(SWT.Modify, this);
  }
  @Override
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout();
    int ncol = 3;
    gl.numColumns = ncol;
    GridData gridData = new GridData();
    new Label(composite, SWT.NONE).setText("Diagram Name:");
    diagramName = new Text(composite, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = ncol - 1;
    diagramName.setLayoutData(gridData);
    gridData.horizontalAlignment = GridData.BEGINNING;
    IWizardPage prePage = this.getPreviousPage();
    if (prePage instanceof WizardNewFileCreationPage) {
      WizardNewFileCreationPage p = (WizardNewFileCreationPage) prePage;
      String filename = p.getFileName();
      String subString = filename.substring(0, filename.length() - 18);
      diagramName.setText(subString);
    }
    gridData.widthHint = GridData.HORIZONTAL_ALIGN_FILL;
    gridData.minimumWidth = GridData.HORIZONTAL_ALIGN_FILL;
    new Label(composite, SWT.NONE).setText("NamespaceURI:");
    namespaceURI = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    for (String s : RegistryUtil.getNamepsaceURIS()) {
      namespaceURI.add(s);
    }
    namespaceURI.setLayoutData(gridData);
    namespaceURI.addListener(SWT.Selection, new MyListener());

    new Label(composite, SWT.NONE).setText("Connection Visualization:");
    connectionVisualization = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    for (MappingVisualization m : MappingVisualization.values()) {
      connectionVisualization.add(m.getLiteral());
    }
    if (connectionVisualization.getItemCount() > 0) {
      connectionVisualization.select(0);
    }
    connectionVisualization.setLayoutData(gridData);
    composite.setLayout(gl);
    setControl(composite);
  }
  private void editItem(final TableItem item) {
    NamespacedProperty expression =
        ((PublishEventMediatorAttributeImpl) item.getData()).getAttributeExpression();

    // value type table editor
    valueTypeEditor = initTableEditor(valueTypeEditor, item.getParent());
    cmbValueType = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbValueType.setItems(
        new String[] {
          AttributeValueType.STRING.getLiteral(), AttributeValueType.EXPRESSION.getLiteral()
        });
    cmbValueType.setText(item.getText(2));
    valueTypeEditor.setEditor(cmbValueType, item, 2);

    item.getParent().redraw();
    item.getParent().layout();
    cmbValueType.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {
            item.setText(2, cmbValueType.getText());
          }
        });

    attributeValueEditor = initTableEditor(attributeValueEditor, item.getParent());
    attributeValue = new PropertyText(item.getParent(), SWT.NONE, cmbValueType);
    attributeValue.addProperties(item.getText(1), expression);
    attributeValueEditor.setEditor(attributeValue, item, 1);
    item.getParent().redraw();
    item.getParent().layout();
    attributeValue.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            item.setText(1, attributeValue.getText());
            Object property = attributeValue.getProperty();
            if (property instanceof NamespacedProperty) {
              item.setData(EXPRESSION_DATA, (NamespacedProperty) property);
            }
          }
        });
  }
  private void createProjectRoot(final Composite workArea) {
    final Composite projectRootGroup = new Composite(workArea, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 10).applyTo(projectRootGroup);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.FILL)
        .applyTo(projectRootGroup);

    final Label directoryLabel = new Label(projectRootGroup, SWT.NULL);
    directoryLabel.setText("Select root directory:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(directoryLabel);

    directoryPathField = new Combo(projectRootGroup, SWT.BORDER);
    PixelConverter pixelConverter = new PixelConverter(directoryPathField);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .hint(pixelConverter.convertWidthInCharsToPixels(25), SWT.DEFAULT)
        .applyTo(directoryPathField);

    final Button browseDirectoriesButton = new Button(projectRootGroup, SWT.PUSH);
    browseDirectoriesButton.setText("Browse...");
    GridDataFactory.fillDefaults().applyTo(browseDirectoriesButton);
    browseDirectoriesButton.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            handleBrowseButtonPressed();
          }
        });

    directoryPathField.addListener(
        SWT.Selection,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            updateProjectsList(directoryPathField.getText());
          }
        });
  }
Esempio n. 14
0
  private static void createProtoCombo(
      final Composite parent, String protocol, final Composite main, final Group group) {
    protoCombo = new Combo(parent, SWT.READ_ONLY);
    protoCombo.setLayoutData(gridData(GridData.FILL_HORIZONTAL, 2, 1));
    protoCombo.add("All protocols");
    for (String p : protocols) protoCombo.add(p);
    protoCombo.select(protocol == null ? 0 : protoCombo.indexOf(protocol));
    protoCombo.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            runAllDelayedListeners();

            String proto = getCurrentSelectedProtocol();

            group.dispose();

            createEmoticonsGroup(main, proto);

            shell.layout();
          }
        });
  }
  @Override
  public void create(Composite parent, Listener listener) {
    normalizationGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
    normalizationGroup.setText("Normalize to standard scores");
    normalizationGroup.setLayout(new GridLayout(2, false));
    normalizationGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    Label normalizationExplanationLabel = new Label(normalizationGroup, SWT.WRAP);
    normalizationExplanationLabel.setText(
        "Replace the raw values with standard scores (z-scores). The data of a column or a row (choose below) will be transformed to have a mean of 0 and a standard deviation of 1.");
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gridData.widthHint = 600;
    normalizationExplanationLabel.setLayoutData(gridData);
    useNormalizationButton = new Button(normalizationGroup, SWT.CHECK);
    useNormalizationButton.setText("Standardize for ");
    useNormalizationButton.addListener(SWT.Selection, listener);
    useNormalizationButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            useNormalizationButtonSelected();
          }
        });
    useNormalizationButton.setSelection(false);

    normalizationTargetCombo = new Combo(normalizationGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gridData = new GridData(SWT.LEFT, SWT.FILL, false, true);
    gridData.widthHint = 120;
    normalizationTargetCombo.setLayoutData(gridData);
    normalizationTargetCombo.addListener(SWT.Modify, listener);
    normalizationTargetCombo.setItems(new String[] {rowsName, columnsName});
    normalizationTargetCombo.select(0);
    normalizationTargetCombo.setEnabled(true);
    normalizationGroup.layout(true, true);
  }
Esempio n. 16
0
  protected void contentForCDT(Composite composite) {
    GridData gd;

    if (showsConfig()) {
      // Add a config selection area
      Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
      gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
      gd.grabExcessHorizontalSpace = true;
      gd.widthHint = 150;
      configGroup.setLayoutData(gd);
      configGroup.setLayout(new GridLayout(3, false));

      Label configLabel = new Label(configGroup, SWT.NONE);
      configLabel.setText(Messages.AbstractPage_6);
      configLabel.setLayoutData(new GridData(GridData.BEGINNING));

      configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
      configSelector.addListener(
          SWT.Selection,
          new Listener() {
            @Override
            public void handleEvent(Event e) {
              handleConfigSelection();
            }
          });
      gd = new GridData(GridData.FILL_BOTH);
      configSelector.setLayoutData(gd);

      if (!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG)) {
        manageButton = new Button(configGroup, SWT.PUSH);
        manageButton.setText(Messages.AbstractPage_12);
        gd = new GridData(GridData.END);
        gd.minimumWidth = 150;
        manageButton.setLayoutData(gd);
        manageButton.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                IProject[] obs = new IProject[] {getProject()};
                IConfigManager cm = ManageConfigSelector.getManager(obs);
                if (cm != null && cm.manage(obs, false)) {
                  cfgDescs = null;
                  populateConfigurations();
                }
              }
            });
      } else { // dummy object to avoid breaking layout
        new Label(configGroup, SWT.NONE).setLayoutData(new GridData(GridData.END));
      }

      errPane = new Composite(configGroup, SWT.NONE);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 3;
      errPane.setLayoutData(gd);
      GridLayout gl = new GridLayout(2, false);
      gl.marginHeight = 0;
      gl.marginWidth = 0;
      gl.verticalSpacing = 0;
      gl.horizontalSpacing = 0;
      errPane.setLayout(gl);

      errIcon = new Label(errPane, SWT.LEFT);
      errIcon.setLayoutData(new GridData(GridData.BEGINNING));
      errIcon.setImage(IMG_WARN);

      errMessage = new Text(errPane, SWT.LEFT | SWT.READ_ONLY);
      errMessage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      if (isForFolder() || isForFile()) {
        excludeFromBuildCheck = new Button(configGroup, SWT.CHECK);
        excludeFromBuildCheck.setText(Messages.AbstractPage_7);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 3;
        excludeFromBuildCheck.setLayoutData(gd);
        excludeFromBuildCheck.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                ICResourceDescription rcDescription = getResDesc();
                rcDescription.setExcluded(excludeFromBuildCheck.getSelection());
                if (currentTab instanceof AbstractCPropertyTab) {
                  ((AbstractCPropertyTab) currentTab).updateData(rcDescription);
                }
              }
            });
      }
    }

    //	Update the contents of the configuration widget
    populateConfigurations();
    if (excludeFromBuildCheck != null) {
      excludeFromBuildCheck.setSelection(getResDesc().isExcluded());
    }
    //	Create the Specific objects for each page
    createWidgets(composite);
  }
Esempio n. 17
0
  // --------------------------------------------------------------------------------
  public void init2() {
    parent.setLayout(new FormLayout());

    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);

    tree = new Tree(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);

    FormData d1 = new FormData();
    d1.top = new FormAttachment(0, 1);
    d1.left = new FormAttachment(0, 1);
    d1.right = new FormAttachment(100, -1);
    d1.bottom = new FormAttachment(100, -1);
    tree.setLayoutData(d1);

    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Data Type");

    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            onSashResize();
          }
        });

    FormData fd_composite1 = new FormData();
    fd_composite1.top = new FormAttachment(0, 1);
    fd_composite1.bottom = new FormAttachment(0, 35);
    fd_composite1.right = new FormAttachment(100, -1);
    fd_composite1.left = new FormAttachment(0, 1);
    editorComposite.setLayoutData(fd_composite1);
    editorComposite.setLayout(new FormLayout());
    Label nameLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_nameLabel = new FormData();
    fd_nameLabel.right = new FormAttachment(0, 66);
    fd_nameLabel.bottom = new FormAttachment(0, 32);
    fd_nameLabel.top = new FormAttachment(0, 12);
    fd_nameLabel.left = new FormAttachment(0, 10);
    nameLabel.setLayoutData(fd_nameLabel);
    nameLabel.setText("Name :");
    Label valueLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_valueLabel = new FormData();
    fd_valueLabel.top = new FormAttachment(nameLabel, 15);
    fd_valueLabel.left = new FormAttachment(0, 10);
    fd_valueLabel.bottom = new FormAttachment(nameLabel, 34, SWT.BOTTOM);
    fd_valueLabel.right = new FormAttachment(nameLabel, 0, SWT.RIGHT);
    valueLabel.setLayoutData(fd_valueLabel);
    valueLabel.setText("Value :");

    valueText =
        new Text(
            editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    valueText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            verifyData();
          }
        });
    valueText.setEnabled(false);
    valueText.setEditable(false);
    FormData fd_valueText = new FormData();
    fd_valueText.top = new FormAttachment(nameLabel, 5);
    fd_valueText.bottom = new FormAttachment(100, -80);
    fd_valueText.right = new FormAttachment(100, -20);
    fd_valueText.left = new FormAttachment(valueLabel, 0, SWT.RIGHT);
    valueText.setLayoutData(fd_valueText);

    updateButton = new Button(editorComposite, SWT.NONE);
    updateButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            onUpdateButtonSelect();
          }
        });
    updateButton.setEnabled(false);
    FormData fd_updateButton = new FormData();
    fd_updateButton.left = new FormAttachment(100, -120);
    fd_updateButton.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    updateButton.setLayoutData(fd_updateButton);
    updateButton.setText("Update");

    typeCombo = new Combo(editorComposite, SWT.READ_ONLY);
    fd_updateButton.top = new FormAttachment(typeCombo, 10);
    typeCombo.setEnabled(false);
    FormData fd_typeList = new FormData();
    fd_typeList.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_typeList.top = new FormAttachment(valueText, 5, SWT.BOTTOM);
    // fd_typeList.bottom = new FormAttachment(valueText, 30, SWT.BOTTOM);
    fd_typeList.right = new FormAttachment(valueText, 170, SWT.LEFT);
    typeCombo.setLayoutData(fd_typeList);

    typeCombo.add("Double");
    typeCombo.add("Integer");
    typeCombo.add("Long");
    typeCombo.add("String");
    typeCombo.add("List (BasicDBList)");
    typeCombo.add("Map (BasicDBObject)");
    typeCombo.add("Date");
    typeCombo.add("ObjectId");
    typeCombo.add("JavaScript code");
    typeCombo.add("Binary data");
    typeCombo.add("Boolean");
    typeCombo.add("Null");
    typeCombo.add("Regular expression");
    typeCombo.add("Symbol");
    typeCombo.add("JavaScript code with scope");
    typeCombo.add("Timestamp");
    typeCombo.add("Min key");
    typeCombo.add("Max key");

    typeCombo.addListener(SWT.Selection, this);

    typeComboIndexMap.put(Double.class, new Integer(0));
    typeComboIndexMap.put(Integer.class, new Integer(1));
    typeComboIndexMap.put(Long.class, new Integer(2));
    typeComboIndexMap.put(String.class, new Integer(3));
    typeComboIndexMap.put(com.mongodb.BasicDBList.class, new Integer(4));
    typeComboIndexMap.put(com.mongodb.BasicDBObject.class, new Integer(5));
    typeComboIndexMap.put(java.util.Date.class, new Integer(6));
    typeComboIndexMap.put(org.bson.types.ObjectId.class, new Integer(7));
    typeComboIndexMap.put(org.bson.types.Code.class, new Integer(8));
    typeComboIndexMap.put(byte[].class, new Integer(9));
    typeComboIndexMap.put(Boolean.class, new Integer(10));
    typeComboIndexMap.put(java.util.regex.Pattern.class, new Integer(12));
    typeComboIndexMap.put(org.bson.types.Symbol.class, new Integer(13));
    typeComboIndexMap.put(org.bson.types.CodeWScope.class, new Integer(14));
    typeComboIndexMap.put(org.bson.types.BSONTimestamp.class, new Integer(15));
    typeComboIndexMap.put(org.bson.types.MinKey.class, new Integer(16));
    typeComboIndexMap.put(org.bson.types.MaxKey.class, new Integer(17));

    Label typeLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_typeLabel = new FormData();
    fd_typeLabel.top = new FormAttachment(typeCombo, 3, SWT.TOP);
    fd_typeLabel.left = new FormAttachment(nameLabel, 0, SWT.LEFT);
    typeLabel.setLayoutData(fd_typeLabel);
    typeLabel.setText("Type :");

    nameText = new Text(editorComposite, SWT.READ_ONLY);
    nameText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
    FormData fd_nameText = new FormData();
    fd_nameText.top = new FormAttachment(nameLabel, -2, SWT.TOP);
    fd_nameText.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_nameText.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    nameText.setLayoutData(fd_nameText);

    MSwtUtil.getTreeColumnWidthFromProperties("documentTree", tree, prop, new int[] {150, 150});

    // listeners
    tree.addListener(SWT.MouseDoubleClick, this);
    tree.addListener(SWT.Selection, this);
    tree.addListener(SWT.KeyDown, this);
    MSwtUtil.addListenerToTreeColumns2(tree, this);

    documentImage = MUtil.getImage(parent.getShell().getDisplay(), "table.png");
    oidImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_star.png");
    intImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_blue.png");
    longImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_red.png");
    doubleImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_orange.png");
    stringImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_green.png");
    dateImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_white.png");
    boolImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_yellow.png");
    listImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_blue.png");
    mapImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_green.png");
    nullImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_black.png");
    jsImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_right.png");

    if (prop.containsKey(DOCUMENT_COMPOSITE_WEIGHT)) {

      (new Thread() {
            public void run() {
              // System.out.println( "e" );
              MSystemUtil.sleep(0);
              // System.out.println( "a" );
              shell
                  .getDisplay()
                  .asyncExec(
                      new Runnable() {
                        public void run() { // ----
                          // debug( "--" + prop.getIntArrayProperty( DOCUMENT_COMPOSITE_WEIGHT )[ 0
                          // ] );
                          sashForm.setWeights(prop.getIntArrayProperty(DOCUMENT_COMPOSITE_WEIGHT));
                        }
                      }); // ----
            }
          })
          .start();

    } else {
      sashForm.setWeights(new int[] {70, 30});
    }
    initializedTime = System.currentTimeMillis();
  }
  private void editItem(final TableItem item) {
    final ArgumentWrapper wrapper = (ArgumentWrapper) item.getData();

    argumentTypeEditor = initTableEditor(argumentTypeEditor, item.getParent());
    cmbArgumentType = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbArgumentType.setItems(new String[] {LITERAL_VALUE, LITERAL_EXPRESSION});
    cmbArgumentType.setText(item.getText(0));
    argumentTypeEditor.setEditor(cmbArgumentType, item, 0);
    item.getParent().redraw();
    item.getParent().layout();
    cmbArgumentType.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {
            item.setText(0, cmbArgumentType.getText());
            if (cmbArgumentType.getSelectionIndex() == 1) {
              wrapper.setExpression(true);
              item.setText(1, wrapper.getArgumentExpression().getPropertyValue());

              String evalString = MediaType.XML.toString();
              if (wrapper.getEvaluator() != null) {
                evalString = wrapper.getEvaluator().toString();
              }
              item.setText(2, evalString);
              cmbArgumentEvaluator.setText(evalString);
              cmbArgumentEvaluator.setEnabled(true);
            } else {
              wrapper.setExpression(false);
              item.setText(1, wrapper.getArgumentValue());
              item.setText(2, "");
              cmbArgumentEvaluator.setText("");
              cmbArgumentEvaluator.setEnabled(false);
            }
          }
        });

    argumentValueEditor = initTableEditor(argumentValueEditor, item.getParent());
    argumentValue = new PropertyText(item.getParent(), SWT.NONE, cmbArgumentType);
    argumentValue.addProperties(wrapper.getArgumentValue(), wrapper.getArgumentExpression());
    argumentValueEditor.setEditor(argumentValue, item, 1);
    item.getParent().redraw();
    item.getParent().layout();
    argumentValue.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            item.setText(1, argumentValue.getText());
            Object property = argumentValue.getProperty();
            if (property instanceof NamespacedProperty) {
              /*					if (wrapper.getEvaluator() == MediaType.XML) {
              	wrapper.setArgumentExpression((NamespacedProperty)property);
              } else if (wrapper.getEvaluator() == MediaType.JSON){
              	String modifiedText = argumentValue.getText();
              	NamespacedProperty namespacedProperty = (NamespacedProperty)property;
              	namespacedProperty.setPropertyValue(modifiedText);
              	wrapper.setArgumentExpression(namespacedProperty);
              }*/
              wrapper.setArgumentExpression((NamespacedProperty) property);
            } else {
              wrapper.setArgumentValue(property.toString());
            }
          }
        });

    argumentEvaluatorEditor = initTableEditor(argumentEvaluatorEditor, item.getParent());
    cmbArgumentEvaluator = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbArgumentEvaluator.setItems(new String[] {LITERAL_XML, LITERAL_JSON});
    cmbArgumentEvaluator.setText(item.getText(2));
    argumentEvaluatorEditor.setEditor(cmbArgumentEvaluator, item, 2);
    cmbArgumentEvaluator.setEnabled(wrapper.isExpression());
    item.getParent().redraw();
    item.getParent().layout();
    cmbArgumentEvaluator.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {

            item.setText(2, cmbArgumentEvaluator.getText());
            if (cmbArgumentEvaluator.getSelectionIndex() == 0) {
              wrapper.setEvaluator(MediaType.XML);
              // argumentValue.setForcefullInlineEditing(false);
            } else {
              wrapper.setEvaluator(MediaType.JSON);
              // argumentValue.setForcefullInlineEditing(true);
            }
          }
        });

    /*		if (wrapper.isExpression()) {
    	if (wrapper.getEvaluator() == MediaType.XML){
    		argumentValue.setForcefullInlineEditing(false);
    	} else if (wrapper.getEvaluator() == MediaType.JSON){
    		argumentValue.setForcefullInlineEditing(true);
    	}
    }*/
  }
Esempio n. 19
0
  public VolumeViewToolBar(
      final SimpleToolBar toolbar,
      final VolumeViewer viewer,
      final ViewCanvasImplementor viewCanvas) {
    _viewer = viewer;
    _viewCanvas = viewCanvas;

    // Add a color selector for choosing the background color.
    // _colorSelector = toolbar.addColorSelector(_viewer.getBackgroundViewColor());
    // _colorSelector.getButton().setToolTipText("Select background color");
    // _colorSelector.addListener(new IPropertyChangeListener() {
    //
    //  /**
    //   * Invoked when a color is chosen in the color selector.
    //   * @param event the property change event.
    //   */
    //  public void propertyChange(final PropertyChangeEvent event) {
    //    final RGB newColor = _colorSelector.getColorValue();
    //    _viewer.setBackgroundViewColor(newColor);
    //  }
    // });

    // Add a combo for selecting the z-domain.
    _zDomainCombo =
        toolbar.addCombo(
            "Domain",
            new String[] {VolumeViewZDomain.TIME.getText(), VolumeViewZDomain.DEPTH.getText()});
    _zDomainCombo.select(0);
    _zDomainCombo.addListener(
        SWT.Selection,
        new Listener() {

          public void handleEvent(final Event event) {
            final String zDomainStr = _zDomainCombo.getText();
            final VolumeViewZDomain zDomain = VolumeViewZDomain.lookup(zDomainStr);
            if (zDomain != null) {
              _viewer.setCurrentDomain(zDomain.getDomain());
            }
          }
        });

    // Add a combo for selecting the z-scaling.
    _zScalingCombo =
        toolbar.addCombo(
            "Z-Scaling",
            new String[] {".001", ".01", ".1", ".5", "1", "2", "5", "10", "20", "50", "100"});
    _zScalingCombo.select(4);
    _zScalingCombo.addListener(
        SWT.Selection,
        new Listener() {

          public void handleEvent(final Event event) {
            final String zScalingStr = _zScalingCombo.getText();
            final double zScaling = Double.parseDouble(zScalingStr);
            _viewer.setExaggeration(zScaling);
          }
        });

    // Add a toggle for setting the projection method.
    _setOrthographicProjection = new SetOrthgraphicProjection(_viewCanvas);
    _setPerspectiveProjection = new SetPerspectiveProjection(_viewCanvas);
    _projectionToggle =
        toolbar.addToggleButton(_setOrthographicProjection, _setPerspectiveProjection);

    // Add a toggle for turning on/off the pick location.
    _hidePickLoc = new ShowPickLocation(_viewCanvas, false);
    _showPickLoc = new ShowPickLocation(_viewCanvas, true);
    _showPickLocToggle = toolbar.addToggleButton(_showPickLoc, _hidePickLoc, false);

    // Add a button for editing the light source.
    final Action lightAction = new EditLightSource(_viewer);
    toolbar.addPushButton(lightAction);

    toolbar.addPushButton(
        new Action() {

          @Override
          public void run() {
            new LightSettingsDialog(_viewer).open();
          }
        });

    toolbar.getToolBar().pack(true);
  }
Esempio n. 20
0
  /** @see OpenGLTab#createControls(Composite) */
  void createControls(Composite composite) {
    Group movementGroup = new Group(composite, SWT.NONE);
    movementGroup.setText("Translation");
    movementGroup.setLayout(new GridLayout(2, false));

    new Label(movementGroup, SWT.NONE).setText("X:");
    final Slider xMove = new Slider(movementGroup, SWT.NONE);
    xMove.setIncrement(1);
    xMove.setMaximum(12);
    xMove.setMinimum(0);
    xMove.setThumb(2);
    xMove.setPageIncrement(2);
    xMove.setSelection(5);
    xMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            xPos = xMove.getSelection() - 5;
          }
        });

    new Label(movementGroup, SWT.NONE).setText("Y:");
    final Slider yMove = new Slider(movementGroup, SWT.NONE);
    yMove.setIncrement(1);
    yMove.setMaximum(12);
    yMove.setMinimum(0);
    yMove.setThumb(2);
    yMove.setPageIncrement(2);
    yMove.setSelection(5);
    yMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            yPos = yMove.getSelection() - 5;
          }
        });

    new Label(movementGroup, SWT.NONE).setText("Z:");
    final Slider zMove = new Slider(movementGroup, SWT.NONE);
    zMove.setIncrement(1);
    zMove.setMaximum(24);
    zMove.setMinimum(0);
    zMove.setThumb(4);
    zMove.setPageIncrement(2);
    zMove.setSelection(10);
    zMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            zPos = zMove.getSelection() - 25;
          }
        });

    Composite fogTypesGroup = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fogTypesGroup.setLayout(layout);
    fogTypesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    new Label(fogTypesGroup, SWT.NONE).setText("Fog Types:");
    final Combo fogTypeCombo = new Combo(fogTypesGroup, SWT.READ_ONLY);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.grabExcessHorizontalSpace = true;
    fogTypeCombo.setLayoutData(data);
    fogTypeCombo.setItems(FOG_NAMES);
    fogTypeCombo.select(0);

    new Label(composite, SWT.NONE).setText("Fog Density:");
    final Slider fogDensitySlider = new Slider(composite, SWT.NONE);
    fogDensitySlider.setIncrement(1);
    fogDensitySlider.setMaximum(32);
    fogDensitySlider.setMinimum(0);
    fogDensitySlider.setThumb(2);
    fogDensitySlider.setPageIncrement(5);
    fogDensitySlider.setSelection(0);
    fogDensitySlider.setEnabled(false);
    fogDensitySlider.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            float fogDensity = ((float) fogDensitySlider.getSelection()) / 100;
            GL.glFogf(GL.GL_FOG_DENSITY, fogDensity);
          }
        });
    fogTypeCombo.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            int currentSelection = fogTypeCombo.getSelectionIndex();
            // fog type GL.GL_LINEAR does not utilize fogDensity, but the other fog types do
            fogDensitySlider.setEnabled(currentSelection != 0);
            GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[currentSelection]);
          }
        });
  }
    private void createFileSelectionArea(Composite workArea) {
      Composite composite = new Composite(workArea, SWT.NULL);
      composite.setLayout(new GridLayout());
      composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      GridLayout layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      composite.setLayout(layout);

      Label label = new Label(composite, SWT.NONE);
      label.setText(Messages.ServiceConfigurationImportWizard_2);

      fileCombo = new Combo(composite, SWT.DROP_DOWN);
      GridData comboData = new GridData(GridData.FILL_HORIZONTAL);
      comboData.verticalAlignment = GridData.CENTER;
      comboData.grabExcessVerticalSpace = false;
      comboData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
      fileCombo.setLayoutData(comboData);
      file = FilenameStore.getSuggestedDefault();
      fileCombo.setItems(FilenameStore.getHistory());
      fileCombo.setText(file);
      fileCombo.addListener(
          SWT.Modify,
          new Listener() {
            public void handleEvent(Event event) {
              file = fileCombo.getText();
              updateEnablement();
            }
          });

      browseButton = new Button(composite, SWT.PUSH);
      browseButton.setText(Messages.ServiceConfigurationImportWizard_3);
      GridData data = new GridData();
      data.horizontalAlignment = GridData.FILL;
      int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
      data.widthHint =
          Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
      browseButton.setLayoutData(data);
      browseButton.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {
              FileDialog d = new FileDialog(getShell(), SWT.OPEN);
              d.setFilterExtensions(new String[] {"*.cfg", "*"}); // $NON-NLS-1$ //$NON-NLS-2$
              d.setFilterNames(
                  new String[] {
                    Messages.ServiceConfigurationImportWizard_4,
                    Messages.ServiceConfigurationImportWizard_5
                  });
              String fileName = getFileName();
              if (fileName != null && fileName.length() > 0) {
                int separator =
                    fileName.lastIndexOf(
                        System.getProperty("file.separator").charAt(0)); // $NON-NLS-1$
                if (separator != -1) {
                  fileName = fileName.substring(0, separator);
                }
              } else {
                fileName = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
              }
              d.setFilterPath(fileName);
              String f = d.open();
              if (f != null) {
                fileCombo.setText(f);
                file = f;
                updateConfigurations(file);
              }
            }
          });
    }
 private void createTextFields(Composite container) {
   Label label;
   GridData gridData;
   Group group;
   GridLayout layout;
   // - Project -
   group = new Group(container, SWT.NONE);
   group.setText("Project Data");
   layout = new GridLayout();
   layout.numColumns = 2;
   group.setLayout(layout);
   gridData = new GridData(GridData.FILL_HORIZONTAL);
   group.setLayoutData(gridData);
   // col:1
   label = new Label(group, SWT.NONE);
   label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   label.setText("Target project (*):");
   // col:2
   projectCombo = new Combo(group, SWT.READ_ONLY);
   final GridData projectComboData = new GridData(GridData.FILL_HORIZONTAL);
   projectCombo.setLayoutData(projectComboData);
   // projectCombo.setText("Select Project");
   projectCombo.addListener(SWT.Selection, this);
   // - Refactoring Data -
   group = new Group(container, SWT.NONE);
   group.setText("Refactoring Data");
   layout = new GridLayout();
   layout.numColumns = 2;
   group.setLayout(layout);
   gridData = new GridData(GridData.FILL_HORIZONTAL);
   group.setLayoutData(gridData);
   // - Name -
   // col:1
   label = new Label(group, SWT.NONE);
   label.setText("Name (*):");
   label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   // col:2
   nameTextField = new Text(group, SWT.BORDER);
   nameTextField.addListener(SWT.Modify, this);
   nameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   // - Id -
   // col:1
   label = new Label(group, SWT.NONE);
   label.setText("Refactoring ID (*):");
   label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   // col:2
   idTextField = new Text(group, SWT.BORDER);
   idTextField.addListener(SWT.Modify, this);
   idTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   //		// - Description - TODO
   //		// col:1
   //		label = new Label(group, SWT.NONE);
   //		label.setText("Description:");
   //		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   //		// col:2
   //		descriptionTextField = new Text(group, SWT.BORDER);
   //		descriptionTextField.addListener(SWT.Modify, this);
   //		descriptionTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   // - Source -
   group = new Group(container, SWT.NONE);
   group.setText("Meta Model and Context Type");
   layout = new GridLayout();
   layout.numColumns = 2;
   group.setLayout(layout);
   gridData = new GridData(GridData.FILL_HORIZONTAL);
   group.setLayoutData(gridData);
   // - Metamodel -
   // col:1
   label = new Label(group, SWT.NONE);
   label.setText("Meta model (*):");
   label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   // col:2
   metamodelCombo = new Combo(group, SWT.BORDER);
   metamodelCombo.addListener(SWT.Selection, this);
   // - Context -
   // col:1
   label = new Label(group, SWT.NONE);
   label.setText("Context type (*):");
   label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
   // col:2
   contextCombo = new Combo(group, SWT.BORDER);
   contextCombo.addListener(SWT.Selection, this);
 }