コード例 #1
0
 public void setVisible(boolean visible) {
   super.setVisible(visible);
   if (defaultButton != null && !defaultButton.isDisposed()) {
     defaultButton.setVisible(visible);
   }
   if (addButton != null && !addButton.isDisposed()) {
     addButton.setVisible(visible);
   }
   if (removeButton != null && !removeButton.isDisposed()) {
     removeButton.setVisible(visible);
   }
   text.getParent().pack();
   text.getParent().layout();
 }
コード例 #2
0
  /* (non-Javadoc)
   * @see org.eclipse.bpmn2.modeler.ui.property.editors.ObjectEditor#createControl(org.eclipse.swt.widgets.Composite, java.lang.String, int)
   */
  @Override
  protected Control createControl(Composite composite, String label, int style) {
    super.createControl(composite, label, style);

    // we assume that the "Edit" button will handle editing of this read-only text field
    text.setEditable(false);
    GridData textLayoutData = (GridData) text.getLayoutData();
    textLayoutData.horizontalSpan = 1;
    boolean multiLine = ((style & SWT.MULTI) != 0);

    Composite buttons = new Composite(composite, SWT.NONE);
    buttons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    buttons.setLayout(new FillLayout((style & SWT.MULTI) != 0 ? SWT.VERTICAL : SWT.HORIZONTAL));

    if (canAdd()) {
      addButton = getToolkit().createButton(buttons, null, SWT.PUSH);
      addButton.setImage(Activator.getDefault().getImage(IConstants.ICON_ADD_20));
      if (multiLine) textLayoutData.heightHint += 25;
    }

    if (canRemove()) {
      removeButton = getToolkit().createButton(buttons, null, SWT.PUSH);
      removeButton.setImage(Activator.getDefault().getImage(IConstants.ICON_REMOVE_20));
      if (multiLine) textLayoutData.heightHint += 25;
    }

    defaultButton = getToolkit().createButton(buttons, null, SWT.PUSH);
    defaultButton.setImage(Activator.getDefault().getImage(IConstants.ICON_EDIT_20));

    updateText();

    SelectionAdapter editListener =
        new SelectionAdapter() {

          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            int id = ID_DEFAULT_BUTTON;
            if (e.widget == addButton) id = ID_ADD_BUTTON;
            else if (e.widget == removeButton) id = ID_REMOVE_BUTTON;
            buttonClicked(id);
          }
        };
    defaultButton.addSelectionListener(editListener);
    if (canAdd()) addButton.addSelectionListener(editListener);
    if (canRemove()) removeButton.addSelectionListener(editListener);

    return text;
  }
コード例 #3
0
 public void dispose() {
   super.dispose();
   if (defaultButton != null && !defaultButton.isDisposed()) {
     defaultButton.dispose();
     defaultButton = null;
   }
   if (addButton != null && !addButton.isDisposed()) {
     addButton.dispose();
     addButton = null;
   }
   if (removeButton != null && !removeButton.isDisposed()) {
     removeButton.dispose();
     removeButton = null;
   }
 }