public Section createControl(FormToolkit toolkit, Composite parent) {
    Section propSec = toolkit.createSection(parent, Section.TITLE_BAR | Section.EXPANDED);
    propSec.setText(_TITLE);

    // widgets
    Composite propSecCl = toolkit.createComposite(propSec, SWT.WRAP);
    Table propTable =
        toolkit.createTable(propSecCl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    selectButton = toolkit.createButton(propSecCl, "Select All", SWT.CHECK);
    selectButton.setSelection(false);
    verifyButton = toolkit.createButton(propSecCl, "Perform Verification", SWT.PUSH);

    // layout
    propSec.setClient(propSecCl);
    propSecCl.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gd.heightHint = propTable.getItemHeight() * 3;
    propTable.setLayoutData(gd);
    verifyButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));

    addListeners();
    makeViewer(propTable);
    makeVerifyAction();

    return propSec;
  }
  private void createButtons(Composite parent, FormToolkit toolkit) {
    fEnabledButton =
        toolkit.createButton(
            parent, Messages.DSServiceComponentSection_enabledButtonMessage, SWT.CHECK);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    fEnabledButton.setLayoutData(data);
    fEnabledButton.setEnabled(isEditable());
    fEnabledButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fModel.getDSComponent().setEnabled(fEnabledButton.getSelection());
          }
        });

    fImmediateButton =
        toolkit.createButton(
            parent, Messages.DSServiceComponentSection_immediateButtonMessage, SWT.CHECK);
    fImmediateButton.setLayoutData(data);
    fImmediateButton.setEnabled(isEditable());
    fImmediateButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fModel.getDSComponent().setImmediate(fImmediateButton.getSelection());
          }
        });
  }
  /** {@inheritDoc} */
  @Override
  protected void createFormCreationSection(Composite pParent, FormToolkit pToolkit) {
    // create the section
    String lSectionTitle = getCreationSectionTitle();
    Section lSection = pToolkit.createSection(pParent, Section.EXPANDED | Section.TITLE_BAR);
    lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (lSectionTitle != null) {
      lSection.setText(lSectionTitle);
    }

    ScrolledForm lInsideScrolledForm = pToolkit.createScrolledForm(lSection);
    lInsideScrolledForm.setExpandHorizontal(true);
    lInsideScrolledForm.setExpandVertical(true);
    Composite lBody = lInsideScrolledForm.getBody();

    GridLayout lLayout = new GridLayout();
    lLayout.numColumns = 3;
    lBody.setLayout(lLayout);

    // content of the section
    creationRadio = pToolkit.createButton(lBody, getCreationSectionRadioLabel(), SWT.RADIO);
    creationRadio.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    pToolkit.createLabel(lBody, getNewTypeNameLabel(), SWT.NONE);
    newTypeNameText = pToolkit.createText(lBody, "", SWT.BORDER);
    newTypeNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    newTypeNameText.setFocus();

    // manage type selection
    pToolkit.createLabel(lBody, getNewTypeContainerNameLabel(), SWT.NONE);
    newTypeContainerNameText =
        pToolkit.createText(
            lBody, labelProvider.getText(newTypeContainer), SWT.BORDER | SWT.READ_ONLY);
    newTypeContainerNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    newTypeContainerButton = pToolkit.createButton(lBody, "...", SWT.FLAT);
    Image image = Activator.getInstance().getImage(containerType.getEClass());
    if (containerEClass != null) {
      image = Activator.getInstance().getImage(containerEClass);
    }
    newTypeContainerButton.setImage(image);
    newTypeContainerButton.setLayoutData(new GridData(SWT.NONE));

    pToolkit.createLabel(lBody, getNewTypeKindLabel(), SWT.NONE);
    newTypeKindCombo = new Combo(lBody, SWT.DROP_DOWN | SWT.READ_ONLY);
    newTypeKindComboViewer = new ComboViewer(newTypeKindCombo);
    pToolkit.adapt(newTypeKindCombo);
    newTypeKindCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    newTypeKindComboViewer.setLabelProvider(new ElementTypeLabelProvider());
    newTypeKindComboViewer.add(valueTypeKind);
    newTypeKindComboViewer.setSelection(new StructuredSelection(valueTypeKind[0]));

    lInsideScrolledForm.reflow(true);
    lSection.setClient(lInsideScrolledForm);
  }
  protected void createAttributesControlPanel(Composite container, FormToolkit widgetFactory) {
    Composite result = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    result.setLayout(layout);
    addAttributes =
        widgetFactory.createButton(
            result, EntityrelationMessages.PropertiesEditionPart_AddListViewerLabel, SWT.NONE);
    GridData addData = new GridData(GridData.FILL_HORIZONTAL);
    addAttributes.setLayoutData(addData);
    addAttributes.addSelectionListener(
        new SelectionAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            addAttributes();
          }
        });
    EditingUtils.setID(
        addAttributes, EntityrelationViewsRepository.Identifier.Properties.attributes);
    EditingUtils.setEEFtype(addAttributes, "eef::ReferencesTable::addbutton"); // $NON-NLS-1$
    removeAttributes =
        widgetFactory.createButton(
            result, EntityrelationMessages.PropertiesEditionPart_RemoveListViewerLabel, SWT.NONE);
    GridData removeData = new GridData(GridData.FILL_HORIZONTAL);
    removeAttributes.setLayoutData(removeData);
    removeAttributes.addSelectionListener(
        new SelectionAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            if (attributes.getSelection() instanceof IStructuredSelection) {
              removeAttributes((IStructuredSelection) attributes.getSelection());
            }
          }
        });
    EditingUtils.setID(
        removeAttributes, EntityrelationViewsRepository.Identifier.Properties.attributes);
    EditingUtils.setEEFtype(removeAttributes, "eef::ReferencesTable::removebutton"); // $NON-NLS-1$
    // Start of user code for createAttributesControlPanel

    // End of user code
  }
示例#5
0
  private void createRelayCheck(Composite parent, Result notReferenced, FormToolkit toolkit) {
    Label l = toolkit.createLabel(parent, "Is Relay Port:", SWT.NONE);
    l.setLayoutData(new GridData(SWT.NONE));

    relayCheck = toolkit.createButton(parent, "", SWT.CHECK);
    relayCheck.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    relayCheck.setSelection(relay);
    relayCheck.setEnabled(notReferenced.isOk());

    RelayValidator validator = new RelayValidator();
    UpdateValueStrategy t2m = new UpdateValueStrategy();
    t2m.setAfterConvertValidator(validator);
    t2m.setBeforeSetValidator(validator);
    UpdateValueStrategy m2t = new UpdateValueStrategy();
    m2t.setAfterConvertValidator(validator);
    m2t.setBeforeSetValidator(validator);

    getBindingContext()
        .bindValue(
            SWTObservables.observeSelection(relayCheck),
            PojoObservables.observeValue(this, "relay"),
            t2m,
            m2t);

    if (notReferenced.isOk()) createDecorator(relayCheck, "");
    else createInfoDecorator(relayCheck, notReferenced.getMsg());
  }
 private Button createButton(Composite parent, FormToolkit toolkit, String label) {
   Button button = toolkit.createButton(parent, label, SWT.CHECK);
   GridData gd = new GridData();
   gd.horizontalSpan = F_NUM_COLUMNS;
   button.setLayoutData(gd);
   return button;
 }
  protected Composite createMaxOccurComp(Composite parent, FormToolkit toolkit) {
    fMaxLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_maxOccurLabel);
    fMaxLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    Composite comp = toolkit.createComposite(parent);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    comp.setLayoutData(gd);

    fMaxOccurSpinner = new Spinner(comp, SWT.BORDER);
    fMaxOccurSpinner.setMinimum(1);
    fMaxOccurSpinner.setMaximum(999);
    fMaxOccurSpinner.setIncrement(1);

    fUnboundSelect =
        toolkit.createButton(comp, PDEUIMessages.AbstractSchemaDetails_unboundedButton, SWT.CHECK);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fUnboundSelect.setLayoutData(gd);
    fUnboundSelect.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (blockListeners()) return;
            fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && isEditableElement());
          }
        });

    return comp;
  }
  private void createUI24SmoothPulse(final Composite parent) {

    /*
     * image: pulse
     */
    _iconPulse = new CLabel(parent, SWT.NONE);
    GridDataFactory.fillDefaults().indent(16, 0).applyTo(_iconPulse);
    _iconPulse.setBackground(_tk.getColors().getBackground());
    _iconPulse.setImage(_imagePulse);

    /*
     * checkbox: smooth speed
     */
    _chkIsPulseSmoothing =
        _tk.createButton(parent, Messages.TourChart_Smoothing_Checkbox_IsPulseSmoothing, SWT.CHECK);
    GridDataFactory.fillDefaults() //
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(_chkIsPulseSmoothing);
    _chkIsPulseSmoothing.addSelectionListener(_selectionListener);
    _chkIsPulseSmoothing.setToolTipText(
        Messages.TourChart_Smoothing_Checkbox_IsPulseSmoothing_Tooltip);

    /*
     * spinner: speed tau
     */
    _spinnerPulseTau = new Spinner(parent, SWT.BORDER);
    GridDataFactory.fillDefaults() //
        .align(SWT.BEGINNING, SWT.FILL)
        .applyTo(_spinnerPulseTau);
    _spinnerPulseTau.setDigits(1);
    _spinnerPulseTau.setMinimum(1);
    _spinnerPulseTau.setMaximum(MAX_TAU);
    _spinnerPulseTau.addSelectionListener(_selectionListener);
    _spinnerPulseTau.addMouseWheelListener(_spinnerMouseWheelListener);
  }
  protected void createTestRTControlPanel(Composite container, FormToolkit widgetFactory) {
    Composite result = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    result.setLayout(layout);
    addTestRT =
        widgetFactory.createButton(
            result, NonregMessages.PropertiesEditionPart_AddListViewerLabel, SWT.NONE);
    GridData addData = new GridData(GridData.FILL_HORIZONTAL);
    addTestRT.setLayoutData(addData);
    addTestRT.addSelectionListener(
        new SelectionAdapter() {

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            addTestRT();
            testRT.refresh();
          }
        });
    removeTestRT =
        widgetFactory.createButton(
            result, NonregMessages.PropertiesEditionPart_RemoveListViewerLabel, SWT.NONE);
    GridData removeData = new GridData(GridData.FILL_HORIZONTAL);
    removeTestRT.setLayoutData(removeData);
    removeTestRT.addSelectionListener(
        new SelectionAdapter() {

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            if (testRT.getSelection() instanceof IStructuredSelection) {
              IStructuredSelection selection = (IStructuredSelection) testRT.getSelection();
              removeTestRT(selection);
              testRT.refresh();
            }
          }
        });
  }
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    section.setLayoutData(data);

    section.setText(PDEUIMessages.IntroSection_sectionText);
    section.setDescription(PDEUIMessages.IntroSection_sectionDescription);

    boolean canCreateNew = TargetPlatformHelper.getTargetVersion() >= NEW_INTRO_SUPPORT_VERSION;

    Composite client = toolkit.createComposite(section);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, canCreateNew ? 3 : 2));
    client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = toolkit.createLabel(client, PDEUIMessages.IntroSection_introLabel, SWT.WRAP);
    GridData td = new GridData();
    td.horizontalSpan = canCreateNew ? 3 : 2;
    label.setLayoutData(td);

    Label introLabel = toolkit.createLabel(client, PDEUIMessages.IntroSection_introInput);
    introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fIntroCombo = new ComboPart();
    fIntroCombo.createControl(client, toolkit, SWT.READ_ONLY);
    td = new GridData(GridData.FILL_HORIZONTAL);
    fIntroCombo.getControl().setLayoutData(td);
    loadManifestAndIntroIds(false);
    if (fAvailableIntroIds != null) fIntroCombo.setItems(fAvailableIntroIds);
    fIntroCombo.add(""); // $NON-NLS-1$
    fIntroCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleSelection();
          }
        });

    if (canCreateNew) {
      Button button = toolkit.createButton(client, PDEUIMessages.IntroSection_new, SWT.PUSH);
      button.setEnabled(isEditable());
      button.setLayoutData(new GridData(GridData.FILL));
      button.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleNewIntro();
            }
          });
    }

    fIntroCombo.getControl().setEnabled(isEditable());

    toolkit.paintBordersFor(client);
    section.setClient(client);
    // Register to be notified when the model changes
    getModel().addModelChangedListener(this);
  }
示例#11
0
 public IExtendableIntValueView create(
     String text, FormToolkit toolkit, final IInteractiveTrait trait) {
   final Button favoredButton = toolkit.createButton(parent, null, SWT.TOGGLE);
   initListening(trait, favoredButton);
   Color background = toolkit.getColors().getBackground();
   createLabel(background, createGridData()).setText(text);
   final CanvasIntValueDisplay view =
       new CanvasIntValueDisplay(
           background, parent, passiveImage, activeImage, trait.getMaximalValue());
   new TraitPresenter().initPresentation(trait, view);
   return view;
 }
示例#12
0
 private void createLaunchersOption(Composite client, FormToolkit toolkit) {
   fLaunchersButton =
       toolkit.createButton(client, PDEUIMessages.ProductInfoSection_launchers, SWT.CHECK);
   GridData data = new GridData(GridData.FILL_HORIZONTAL);
   data.horizontalSpan = 2;
   fLaunchersButton.setLayoutData(data);
   fLaunchersButton.setEnabled(isEditable());
   fLaunchersButton.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           getProduct().setIncludeLaunchers(fLaunchersButton.getSelection());
         }
       });
 }
 protected Button[] createTrueFalseButtons(Composite parent, FormToolkit toolkit, int colSpan) {
   Composite comp = toolkit.createComposite(parent, SWT.NONE);
   GridLayout gl = new GridLayout(2, false);
   gl.marginHeight = gl.marginWidth = 0;
   comp.setLayout(gl);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = colSpan;
   gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
   comp.setLayoutData(gd);
   Button tButton = toolkit.createButton(comp, BOOLS[0], SWT.RADIO);
   Button fButton = toolkit.createButton(comp, BOOLS[1], SWT.RADIO);
   gd = new GridData();
   gd.horizontalIndent = 20;
   fButton.setLayoutData(gd);
   return new Button[] {tButton, fButton};
 }
  public NodeInspectableContainer(InspectorView parent, SceneNode target) {
    super(parent, target);

    int editorId = editorContext.editorId;
    addDisposeListener(e -> EventService.unsubscribe(editorId, this));
    EventService.subscribe(editorId, this);

    addDisposeListener(e -> Workbench.deactivate(this));
    Workbench.activate(this);

    FormToolkit toolkit = GurellaStudioPlugin.getToolkit();
    toolkit.adapt(this);

    Composite body = getBody();
    GridLayoutFactory.fillDefaults().numColumns(4).extendedMargins(0, 10, 4, 0).applyTo(body);

    Label nameLabel = toolkit.createLabel(body, " Name: ");
    nameLabel.setLayoutData(new GridData(BEGINNING, CENTER, false, false));

    nameText = UiUtils.createText(body);
    nameText.setText(target.getName());
    nameText.setLayoutData(new GridData(FILL, BEGINNING, true, false));
    nameChangedlLstener = e -> nodeNameChanged();
    nameText.addListener(SWT.Modify, nameChangedlLstener);

    enabledCheck = toolkit.createButton(body, "Enabled", CHECK);
    enabledCheck.setLayoutData(new GridData(END, CENTER, false, false));
    enabledCheck.setSelection(target.isEnabled());
    nodeEnabledListener = e -> nodeEnabledChanged();
    enabledCheck.addListener(SWT.Selection, nodeEnabledListener);

    menuButton = toolkit.createLabel(body, " ", NONE);
    menuButton.setImage(GurellaStudioPlugin.createImage("icons/menu.png"));
    menuButton.setLayoutData(new GridData(END, CENTER, false, false));
    menuButton.addListener(SWT.MouseUp, e -> showMenu());

    componentsComposite = toolkit.createComposite(body);
    GridLayout componentsLayout = new GridLayout(1, false);
    componentsLayout.marginHeight = 0;
    componentsLayout.marginWidth = 0;
    componentsComposite.setLayout(componentsLayout);
    componentsComposite.setLayoutData(new GridData(FILL, FILL, true, true, 4, 1));

    UiUtils.paintBordersFor(body);
    initComponentContainers();
    layout(true, true);
  }
 /**
  * Create the section to ask the user to create a parameter.
  *
  * @param pParent the section's parent widget
  * @param pToolkit the form toolkit
  */
 protected void createParameterSection(Composite pParent, FormToolkit pToolkit) {
   // create the section
   String lSectionTitle = getCreationTitle();
   Section lSection = pToolkit.createSection(pParent, Section.EXPANDED | Section.TITLE_BAR);
   lSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   if (lSectionTitle != null) {
     lSection.setText(lSectionTitle);
   }
   ImageHyperlink componentHelp =
       HelpComponentFactory.createHelpComponent(
           lSection, pToolkit, CustomMessages.CreateParameterDialog_ParameterCreationHelp, true);
   lSection.setTextClient(componentHelp);
   ScrolledForm lInsideScrolledForm = pToolkit.createScrolledForm(lSection);
   lInsideScrolledForm.setExpandHorizontal(true);
   lInsideScrolledForm.setExpandVertical(true);
   Composite lBody = lInsideScrolledForm.getBody();
   GridLayout lLayout = new GridLayout();
   lLayout.numColumns = 3;
   lBody.setLayout(lLayout);
   // content of the section
   pToolkit.createLabel(lBody, getNameLabel(), SWT.NONE);
   creationNameText = pToolkit.createText(lBody, "", SWT.BORDER);
   creationNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
   creationNameText.setFocus();
   // manage type selection
   pToolkit.createLabel(lBody, getTypeLabel(), SWT.NONE);
   creationTypeText =
       pToolkit.createText(lBody, labelProvider.getText(selectedType), SWT.BORDER | SWT.READ_ONLY);
   creationTypeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   creationTypeButton = pToolkit.createButton(lBody, "...", SWT.FLAT);
   Image image = getTypeImage();
   creationTypeButton.setImage(image);
   creationTypeButton.setLayoutData(new GridData(SWT.NONE));
   // manage direction selection
   pToolkit.createLabel(lBody, getDirectionLabel(), SWT.NONE);
   creationDirectionCombo = new Combo(lBody, SWT.DROP_DOWN | SWT.READ_ONLY);
   directionComboViewer = new ComboViewer(creationDirectionCombo);
   pToolkit.adapt(creationDirectionCombo);
   creationDirectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
   directionComboViewer.setLabelProvider(labelProvider);
   directionComboViewer.add(getPossibleDirections());
   // initialize selection
   directionComboViewer.setSelection(new StructuredSelection(getDefaultDirection()));
   selectedDirection = ParameterDirectionKind.getByName(getDefaultDirection());
   lInsideScrolledForm.reflow(true);
   lSection.setClient(lInsideScrolledForm);
 }
 @Override
 protected void addActionButtons(Composite buttonComposite) {
   FormToolkit toolkit = new FormToolkit(buttonComposite.getDisplay());
   submitButton = toolkit.createButton(buttonComposite, LABEL_SUMBIT, SWT.NONE);
   GridData submitButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
   submitButtonData.widthHint = 100;
   submitButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_SUBMIT));
   submitButton.setLayoutData(submitButtonData);
   submitButton.addListener(
       SWT.Selection,
       new Listener() {
         public void handleEvent(Event e) {
           submitToRepository();
         }
       });
   submitButton.setToolTipText("Submit to " + this.repository.getRepositoryUrl());
 }
  protected Composite createInterface_Checkbox(FormToolkit widgetFactory, Composite parent) {
    interface_ =
        widgetFactory.createButton(
            parent,
            getDescription(
                EcoreViewsRepository.EClass.Properties.Abstraction.interface_,
                EcoreMessages.EClassPropertiesEditionPart_Interface_Label),
            SWT.CHECK);
    interface_.addSelectionListener(
        new SelectionAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            if (propertiesEditionComponent != null)
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      EClassPropertiesEditionPartForm.this,
                      EcoreViewsRepository.EClass.Properties.Abstraction.interface_,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      new Boolean(interface_.getSelection())));
          }
        });
    GridData interface_Data = new GridData(GridData.FILL_HORIZONTAL);
    interface_Data.horizontalSpan = 2;
    interface_.setLayoutData(interface_Data);
    EditingUtils.setID(interface_, EcoreViewsRepository.EClass.Properties.Abstraction.interface_);
    EditingUtils.setEEFtype(interface_, "eef::Checkbox"); // $NON-NLS-1$
    FormUtils.createHelpButton(
        widgetFactory,
        parent,
        propertiesEditionComponent.getHelpContent(
            EcoreViewsRepository.EClass.Properties.Abstraction.interface_,
            EcoreViewsRepository.FORM_KIND),
        null); //$NON-NLS-1$
    // Start of user code for createInterface_Checkbox

    // End of user code
    return parent;
  }
示例#18
0
    @Override
    protected Control createDialogArea(Composite parent) {

      getShell().setText("Betroffene Bahn(en) bearbeiten");

      Composite container = (Composite) super.createDialogArea(parent);
      container.setLayout(new FillLayout(SWT.HORIZONTAL));

      parentForm = formToolkit.createForm(container);
      formToolkit.paintBordersFor(parentForm);
      formToolkit.decorateFormHeading(parentForm);
      parentForm.setText("Betroffene Bahn(en) bearbeiten");

      parentForm.getBody().setLayout(new GridLayout(1, true));

      for (Integer i = 1; i <= 6; i++) {

        final Button trackButton =
            formToolkit.createButton(parentForm.getBody(), "Bahn 1", SWT.CHECK);
        trackButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
        trackButton.setText("Bahn " + i.toString());

        if (bandAction.getTrack().contains(i)) trackButton.setSelection(true);

        trackButton.setData(TRACK_KEY, i);

        trackButton.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                if (((Button) e.widget).getSelection()) {
                  bandAction.getTrack().add((Integer) e.widget.getData(TRACK_KEY));
                } else {
                  bandAction.getTrack().remove((Integer) e.widget.getData(TRACK_KEY));
                }
              }
            });

        if (i == 2 || i == 4) {
          Label seperator =
              formToolkit.createLabel(parentForm.getBody(), "", SWT.SEPARATOR | SWT.HORIZONTAL);
          seperator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        }
      }
      return container;
    }
  /**
   * Create the buttons for the settings transfer.
   *
   * @param toolkit
   * @param sectionClient
   * @return boolean <code>true</code> if any were selected
   */
  private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {

    IConfigurationElement[] settings = SettingsTransfer.getSettingsTransfers();

    String[] enabledSettings =
        getEnabledSettings(
            IDEWorkbenchPlugin.getDefault().getDialogSettings().getSection(WORKBENCH_SETTINGS));

    for (int i = 0; i < settings.length; i++) {
      final IConfigurationElement settingsTransfer = settings[i];
      final Button button =
          toolkit.createButton(sectionClient, settings[i].getAttribute(ATT_NAME), SWT.CHECK);

      String helpId = settings[i].getAttribute(ATT_HELP_CONTEXT);

      if (helpId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(button, helpId);

      if (enabledSettings != null && enabledSettings.length > 0) {

        String id = settings[i].getAttribute(ATT_ID);
        for (int j = 0; j < enabledSettings.length; j++) {
          if (enabledSettings[j].equals(id)) {
            button.setSelection(true);
            selectedSettings.add(settingsTransfer);
            break;
          }
        }
      }

      button.setBackground(sectionClient.getBackground());
      button.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              if (button.getSelection()) selectedSettings.add(settingsTransfer);
              else selectedSettings.remove(settingsTransfer);
            }
          });
    }
    return enabledSettings != null && enabledSettings.length > 0;
  }
  private void createButtonSection(Composite editorComposite, FormToolkit toolkit) {

    Section section = toolkit.createSection(editorComposite, ExpandableComposite.NO_TITLE);
    section.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite buttonSection = toolkit.createComposite(section);
    section.setClient(buttonSection);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    buttonSection.setLayout(layout);

    Button search_button = toolkit.createButton(buttonSection, "Search", SWT.PUSH | SWT.CENTER);
    search_button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {

            m_sform.reflow(true);
            firePropertyChange(IEditorPart.PROP_DIRTY);

            String sparql_query = m_SparqlQueryHelper.constructQuery();
            String[] vars = {"?news"};
            QueryWrapper query = new QueryWrapper(sparql_query, vars);

            long selectiontime = System.currentTimeMillis();
            Object[] selection = {ExploreEnvironment.F_SEARCH, query, selectiontime, null};
            m_selectionProvider.setSelection(new StructuredSelection(selection));
          }
        });

    //		TODO combine NewsSearch with StoredQueryView. a 'save' option would be nice ...
    //		Button save_button = toolkit.createButton(buttonSection,"Save",SWT.PUSH | SWT.CENTER);
    //		save_button.addSelectionListener(new SelectionAdapter() {
    //			@Override
    //			public void widgetSelected(SelectionEvent e) {

    //				m_sform.reflow(true);
    //				markDirty(true);
    //				firePropertyChange(IEditorPart.PROP_DIRTY);
    //			}
    //		});
  }
  protected Composite createRefreshCheckbox(FormToolkit widgetFactory, Composite parent) {
    refresh =
        widgetFactory.createButton(
            parent,
            getDescription(
                FlowViewsRepository.ViewState.Properties.refresh,
                FlowMessages.ViewStatePropertiesEditionPart_RefreshLabel),
            SWT.CHECK);
    refresh.addSelectionListener(
        new SelectionAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            if (propertiesEditionComponent != null)
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      ViewStatePropertiesEditionPartForm.this,
                      FlowViewsRepository.ViewState.Properties.refresh,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      new Boolean(refresh.getSelection())));
          }
        });
    GridData refreshData = new GridData(GridData.FILL_HORIZONTAL);
    refreshData.horizontalSpan = 2;
    refresh.setLayoutData(refreshData);
    EditingUtils.setID(refresh, FlowViewsRepository.ViewState.Properties.refresh);
    EditingUtils.setEEFtype(refresh, "eef::Checkbox"); // $NON-NLS-1$
    FormUtils.createHelpButton(
        widgetFactory,
        parent,
        propertiesEditionComponent.getHelpContent(
            FlowViewsRepository.ViewState.Properties.refresh, FlowViewsRepository.FORM_KIND),
        null); //$NON-NLS-1$
    return parent;
  }
  protected void createSpeedFiltersEntry(
      Composite parent, FormToolkit toolkit, IActionBars actionBars) {
    SWTUtil.createLabel(parent, StringPool.EMPTY, 1);

    GridData td = new GridData();
    td.horizontalSpan = 5;

    speedFilters = toolkit.createButton(parent, Msgs.speedFilters, SWT.CHECK);

    speedFilters.setLayoutData(td);
    speedFilters.setEnabled(isEditable());
    speedFilters.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            if (!speedFilterEnabledModifying) {
              getModel().setSpeedFiltersEnabled(speedFilters.getSelection());
            }
          }
        });
  }
示例#23
0
 private void createScalingControls(Composite client) {
   final Scale scale = new Scale(client, SWT.NONE);
   scale.setMinimum(1);
   scale.setMaximum(100);
   scale.setSelection(50);
   scale.setPageIncrement(5);
   scale.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           int selection = scale.getSelection();
           if (selection > 50) {
             selection = selection - 50;
             scaleFactor.setText(String.valueOf(1.0d * selection));
           } else if (selection == 50) {
             scaleFactor.setText(String.valueOf(1.0d));
           } else {
             selection = 50 - selection;
             scaleFactor.setText(String.valueOf(1.0d / selection));
           }
           applyScaleFactor();
         }
       });
   GridDataFactory.fillDefaults().span(3, 0).applyTo(scale);
   Label label = kit.createLabel(client, "scale factor: ");
   GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
   scaleFactor = kit.createText(client, "1.0");
   GridDataFactory.fillDefaults().grab(true, false).applyTo(scaleFactor);
   final Button setScale = kit.createButton(client, "apply", SWT.PUSH);
   setScale.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           applyScaleFactor();
         }
       });
   GridDataFactory.fillDefaults().applyTo(setScale);
 }
  private void createUI26SmoothAltitude(final Composite parent) {

    /*
     * image: altitude
     */
    _iconAltitude = new CLabel(parent, SWT.NONE);
    GridDataFactory.fillDefaults().indent(16, 0).applyTo(_iconAltitude);
    _iconAltitude.setBackground(_tk.getColors().getBackground());
    _iconAltitude.setImage(_imageAltitude);

    /*
     * checkbox: smooth altitude
     */
    _chkIsAltitudeSmoothing =
        _tk.createButton(
            parent, Messages.TourChart_Smoothing_Checkbox_IsAltitudeSmoothing, SWT.CHECK);
    GridDataFactory.fillDefaults() //
        .align(SWT.FILL, SWT.CENTER)
        .span(2, 1)
        .applyTo(_chkIsAltitudeSmoothing);
    _chkIsAltitudeSmoothing.setToolTipText(
        Messages.TourChart_Smoothing_Checkbox_IsAltitudeSmoothing_Tooltip);
    _chkIsAltitudeSmoothing.addSelectionListener(_selectionListener);
  }
  private void createFormImplSection(final ScrolledForm form, FormToolkit toolkit) {
    /* Task Implementation Section */
    Section implSection = toolkit.createSection(form.getBody(), Section.TWISTIE | Section.EXPANDED);
    implSection.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    implSection.setToggleColor(toolkit.getColors().getColor(FormColors.SEPARATOR));
    toolkit.createCompositeSeparator(implSection);
    GridData taskGroupGridData = new GridData();
    taskGroupGridData.horizontalSpan = 3;
    taskGroupGridData.horizontalAlignment = GridData.FILL;
    taskGroupGridData.grabExcessHorizontalSpace = true;
    implSection.setLayoutData(taskGroupGridData);
    implSection.addExpansionListener(
        new ExpansionAdapter() {
          public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(false);
          }
        });
    implSection.setText(Messages.getString("ScheduledTaskPage.section.impl"));
    // implSection.setLayoutData(new TableWrapData(TableWrapData.FILL));

    Composite implSectionClient = toolkit.createComposite(implSection);
    implSectionClient.setLayout(new GridLayout());

    toolkit.createLabel(implSectionClient, "Task Implementation");
    GridData taskImplGridData = new GridData();
    taskImplGridData.horizontalSpan = 3;
    taskImplGridData.horizontalAlignment = GridData.FILL;
    taskImplGridData.grabExcessHorizontalSpace = true;
    taskImpl =
        toolkit.createText(implSectionClient, "org.apache.synapse.startup.tasks.MessageInjector");
    taskImpl.setLayoutData(taskImplGridData);
    taskImpl.setBackground(new Color(null, 229, 236, 253));
    taskImpl.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            setSave(true);
            updateDirtyState();
          }
        });
    // taskImpl.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));

    Button taskImplButton =
        toolkit.createButton(implSectionClient, "Task Implementation Properties", SWT.PUSH);
    taskImplButton.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Shell shell = Display.getDefault().getActiveShell();
            TaskPropertyDialog taskPropDialog =
                new TaskPropertyDialog(shell, getTaskImpl().getText(), getTaskPropertyList());
            taskPropDialog.setBlockOnOpen(true);
            taskPropDialog.open();
            taskPropertyList = taskPropDialog.getTaskPropertyList();
            setSave(true);
            updateDirtyState();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            // TODO Auto-generated method stub

          }
        });

    setTaskPropertyList(taskPropertyList);

    implSection.setClient(implSectionClient);
  }
  @Override
  public void createPartControl(Composite parent) {
    // TODO Auto-generated method stub
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText("MetaData Editor:");

    toolkit.decorateFormHeading(form);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.minimumWidth = 200;
    //		FormLayout gridLayout = new FormLayout();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 5;
    form.getBody().setLayout(gridLayout);

    FormData formDate = new FormData();
    formDate.height = 250;
    formDate.width = 300;

    FormData formDate0 = new FormData();
    formDate0.height = 150;
    formDate0.width = 300;
    FormData formDate2 = new FormData();
    formDate2.height = 550;
    formDate2.width = 550;

    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Attribute Modifier");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new FormLayout());
    section.setClient(sectionClient);

    GridData gridData2 = new GridData();
    gridData2.verticalSpan = 2;
    section.setLayoutData(gridData2);

    Section section2 = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section2.setText("Collector");
    Composite sectionClient2 = toolkit.createComposite(section2);
    sectionClient2.setLayout(new FormLayout());
    section2.setClient(sectionClient2);

    Section section3 = toolkit.createSection(form.getBody(), Section.TITLE_BAR); // printStackTrace
    section3.setText("Collection Code");
    Composite sectionClient3 = toolkit.createComposite(section3);
    sectionClient3.setLayout(new FormLayout());
    section3.setClient(sectionClient3);

    final Table table2 =
        toolkit.createTable(
            sectionClient2, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table2.setHeaderVisible(true);

    final Button submitCollectionCode = toolkit.createButton(sectionClient2, "submit", SWT.None);

    TableColumn column01 = new TableColumn(table2, SWT.NONE);
    column01.setWidth(25);
    column01.setText("#");
    TableColumn column02 = new TableColumn(table2, SWT.NONE);
    column02.setWidth(100);
    column02.setText("Name");
    TableColumn column03 = new TableColumn(table2, SWT.NONE);
    column03.setWidth(100);
    column03.setText("Collection No");
    table2.setLayoutData(formDate);
    int index = 1;
    for (SpecCollectorMap map : spec.getSpecCollectorMaps()) {
      Collector c = map.getCollector();
      TableItem item = new TableItem(table2, SWT.FULL_SELECTION);
      item.setData("collector", c);
      item.setText(0, index + "");
      index++;
      item.setText(1, c.getCollectorFullName()); // c.exe
      if (spec.getRecordNumber() == null) {
        item.setText(2, "");
      } else item.setText(2, spec.getRecordNumber());

      table2.setSelection(index);
    }

    table2.addListener(
        SWT.MouseDoubleClick,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            int ret;
            for (final TableItem item : table2.getItems()) {

              for (int i = 0; i < table2.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Collector c = (Collector) item.getData("collector");
                  CollectorModDialog dialog =
                      new CollectorModDialog(Display.getDefault().getActiveShell(), c);
                  ret = dialog.open();
                }
              }
            }
          }
        });
    final Table table3 =
        toolkit.createTable(
            sectionClient3, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table3.setHeaderVisible(true);

    TableColumn column31 = new TableColumn(table3, SWT.NONE);
    column31.setWidth(25);
    column31.setText("#");
    TableColumn column32 = new TableColumn(table3, SWT.NONE);
    column32.setWidth(50);
    column32.setText("Collection Code");
    TableColumn column33 = new TableColumn(table3, SWT.NONE);
    column33.setWidth(150);
    column33.setText("Collection Info");
    table3.setLayoutData(formDate0);

    Collection ccc = this.spec.getCollection();

    TableItem item31 = new TableItem(table3, SWT.NONE);
    item31.setText(0, "1");
    if (ccc != null) {
      if (ccc.getCollectionCode() == null) ccc.setCollectionCode("");
      if (ccc.getCollectionInfo() == null) ccc.setCollectionInfo("");
      item31.setText(1, ccc.getCollectionCode());
      item31.setText(2, ccc.getCollectionInfo());
    }

    final TableEditor collectionEditor = new TableEditor(table3);
    collectionEditor.horizontalAlignment = SWT.LEFT;
    collectionEditor.grabHorizontal = true;
    collectionEditor.minimumWidth = 50;
    collectionSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = collectionEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    table3.addSelectionListener(collectionSelectionListener);
    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {}
            }
          }
        };

    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table3.getItems()) {

              for (int i = 0; i < table3.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Control oldEditor = collectionEditor.getEditor();
                  if (oldEditor != null) oldEditor.dispose();

                  final Combo newEditor = new Combo(table3, SWT.NONE);
                  DataUtilsService service = new DataUtilsService();
                  DataUtilsDelegate delegate = service.getDataUtilsPort();
                  final List<Collection> collections = delegate.getCollections();
                  for (Collection col : collections) {
                    newEditor.add(col.getCollectionCode());
                  }

                  newEditor.addDisposeListener(
                      new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e) {
                          // TODO Auto-generated method stub
                          Combo combo = (Combo) collectionEditor.getEditor();
                          Collection collection = collections.get(combo.getSelectionIndex());
                          collectionEditor.getItem().setText(1, collection.getCollectionCode());
                          collectionEditor.getItem().setText(2, collection.getCollectionInfo());
                          collectionEditor
                              .getItem()
                              .setBackground(new Color(Display.getCurrent(), 255, 250, 160));

                          String methodName = (String) item.getData();
                        }
                      });

                  newEditor.setFocus();
                  collectionEditor.setEditor(newEditor, item, 1);
                }
              }
            }
          }
        };
    table3.addListener(SWT.MouseDoubleClick, tableListener2);

    final Table table =
        toolkit.createTable(sectionClient, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLayoutData(formDate2);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Name");
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(250);
    column2.setText("Data");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(100);

    //		table.setLayoutData(gridData);
    /*
    		final TableItem itemName = new TableItem(table,SWT.NONE);
    		itemName.setText(0,"Scientific Name:");
    		final TableItem itemFamily = new TableItem(table, SWT.NONE);
    		itemFamily.setText(0, "Family:");
    		itemFamily.setData("setFamily");
    		final TableItem itemGenus = new TableItem(table, SWT.NONE);
    		itemGenus.setText(0, "Genus:");
    		itemGenus.setData("setGenus");
    		final TableItem itemSpecies = new TableItem(table, SWT.NONE);
    		itemSpecies.setText(0, "Species:");
    		itemSpecies.setData("setSpecies");
    		final TableItem itemCollectAt = new TableItem(table, SWT.NONE);
    		itemCollectAt.setText(0, "Collect At:");
    		itemCollectAt.setData("setCountry");
    		final TableItem itemCollectAtDarwin = new TableItem(table, SWT.NONE);
    		itemCollectAtDarwin.setText(0, "Name in Darwin's time:");
    		itemCollectAtDarwin.setData("setDcountry");
    		final TableItem itemSheetNote = new TableItem(table, SWT.NONE);
    		itemSheetNote.setText(0, "Sheet Notes:");
    		itemSheetNote.setData("setSheetNotes");
    		final TableItem itemState = new TableItem(table, SWT.NONE);
    		itemState.setText(0, "State:");
    		itemState.setData("setStateProvince");
    		final TableItem itemTown = new TableItem(table, SWT.NONE);
    		itemTown.setText(0, "Town:");
    		itemTown.setData("setTown");


    		itemName.setText(1,spec.getScientificName());
    		itemFamily.setText(1, spec.getFamily());
    		itemGenus.setText(1, spec.getGenus());
    		itemSpecies.setText(1, spec.getSpecificEpithet());
    		itemCollectAt.setText(1, spec.getCountry());
    		itemCollectAtDarwin.setText(1, spec.getDarwinCountry());
    		itemSheetNote.setText(1, spec.getSheetNotes());
    		itemState.setText(1, spec.getStateProvince());
    		itemTown.setText(1, spec.getTown());
    */

    try {
      Element root = this.configXml.selectElement("system/editor");
      for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        if (root.getChildNodes().item(i).getNodeType() == Element.ELEMENT_NODE) {
          Element child = (Element) root.getChildNodes().item(i);
          System.out.println("child name = " + child.getAttribute("field"));
          if (child.getAttribute("display").equals("true")) {
            final TableItem itemName = new TableItem(table, SWT.NONE);
            System.out.println(itemName);
            itemName.setData("set" + child.getAttribute("field"));
            itemName.setData("editable", child.getAttribute("editable"));
            itemName.setData("type", child.getAttribute("type"));
            itemName.setText(0, child.getAttribute("name"));
            if (child.getAttribute("field").equals("RecordNumber")) {
              System.out.println(child.getAttribute("editable"));
            }
            Method m;

            try {
              m = spec.getClass().getMethod("get" + child.getAttribute("field"));
              System.out.println("function name = " + m.getName());
              if (child.getAttribute("type").equals("date")) {
                XMLGregorianCalendar cal = (XMLGregorianCalendar) m.invoke(spec);

                String calstr = "";
                if (cal != null) {
                  calstr = cal.toString();
                  itemName.setText(1, calstr);
                  itemName.setData("date", cal);
                }
              } else if (child.getAttribute("type").equals("string")) {
                String str = (String) m.invoke(spec);
                if (str == null) {
                  str = "";
                }
                itemName.setText(1, str);
              } else if (child.getAttribute("type").equals("int")) {
                Integer inte = (Integer) m.invoke(spec);
                itemName.setText(1, inte + "");
              }
            } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              System.out.println("field==" + child.getAttribute("field"));
              //						e.printStackTrace();
            } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (XmlToolException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    final Button submitButton = toolkit.createButton(form.getBody(), "submit", SWT.None);
    submitButton.setEnabled(false);
    final Label label2 = new Label(form.getBody(), SWT.NONE);
    label2.setData("name", "label2");
    label2.setText("Modification Save Successfully");
    label2.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label2.setForeground(new Color(Display.getCurrent(), 0, 128, 64));
    label2.setVisible(false);

    final Label label3 = new Label(form.getBody(), SWT.NONE);
    label3.setData("name", "label2");
    label3.setText("Modification Save Error!");
    label3.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label3.setForeground(new Color(Display.getCurrent(), 128, 0, 0));
    label3.setVisible(false);

    final Label label4 = new Label(form.getBody(), SWT.NONE);
    label4.setData("name", "label4");
    label4.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label4.setForeground(new Color(Display.getCurrent(), 200, 0, 0));
    label4.setVisible(false);

    final TableEditor edit = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    edit.horizontalAlignment = SWT.LEFT;
    edit.grabHorizontal = true;
    edit.minimumWidth = 50;
    // editing the second column
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };
    table.addSelectionListener(tableSelectionListener);
    tableListener =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {
                for (int i = 0; i < table.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    Control oldEditor = editor.getEditor();
                    if (oldEditor != null) oldEditor.dispose();

                    if (item.getData("type").equals("int")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {Integer.parseInt(text.getText())});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    }

                    if (item.getData("type").equals("string")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {text.getText()});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    } else if (item.getData("type").equals("date")) {
                      CalendarCombo calendar = new CalendarCombo(table, SWT.CALENDAR);
                      XMLGregorianCalendar cal = (XMLGregorianCalendar) item.getData("date");
                      if (cal == null) {
                        calendar.setDate(new Date(System.currentTimeMillis()));
                      } else {
                        GregorianCalendar ca = cal.toGregorianCalendar();
                        calendar.setDate(ca.getTime());
                      }
                      //
                      calendar.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              CalendarCombo cc = (CalendarCombo) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, cc.getDateAsString());

                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(cc.getDate().getTime());
                                    XMLGregorianCalendar date2 =
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
                                    m.invoke(spec, new Object[] {date2});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (DatatypeConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });

                      calendar.setFocus();
                      editor.setEditor(calendar, item, EDITABLECOLUMN);
                      break;
                    }
                  }
                } // for
              }
            }
          }
        };
    table.addListener(SWT.MouseDoubleClick, tableListener);
    submitButton.setLayoutData(gridData);
    buttonSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              //					Specimen speca = null;
              //					for(IWorkbenchPage p : pages){
              //						IViewReference ivrs [] = p.getViewReferences();
              //						for(IViewReference ivr : ivrs){
              //							if(ivr.getId().equals("TestView.view")){
              //								View v = (View)ivr.getView(true);
              //								speca = v.getGallery().getSelection()[0].getData("spec", spec);
              //								if(spec.getMissingInfo()==0){
              //									v.getGallery().getSelection()[0].setBackground(new
              // Color(Display.getCurrent(), 255,255,255));
              //								}
              //								break;
              //							}
              //						}
              //					}
              DataUtilsService service = new DataUtilsService(); // Missing
              DataUtilsDelegate delegate = service.getDataUtilsPort();
              //					Specimen ss = delegate.getSpecimenById(spec.getSpecimenId());//getView

              List<SpecCollectorMap> scms = delegate.getScms(spec.getSpecimenId());
              //					System.out.println(ss.getSpecimenId()+"***"+scms.size());
              if (spec == null) {
                System.out.println("NULL ID!");
              }
              if (scms == null) {
                System.out.println("NULL SCMS!");
              }
              String scmIds = "";
              int index = 0;
              for (SpecCollectorMap scm : scms) {
                if (index == 0) {
                  scmIds += scm.getSpecCollectorMapId();
                } else {
                  scmIds += ("-" + scm.getSpecCollectorMapId());
                }
                index++;
              }
              System.out.println("scmIds = " + scmIds);
              System.out.println("specimen Id = " + spec.getSpecimenId());
              if (scmIds.equals("")) scmIds = "0";
              Specimen updatedSpecimen = delegate.updateSpecimen(spec, scmIds);
              for (TableItem item : table.getItems()) {
                item.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                submitButton.setEnabled(false);
              }
              IWorkbenchPage pages[] = getEditorSite().getWorkbenchWindow().getPages();
              for (IWorkbenchPage p : pages) {
                IViewReference ivrs[] = p.getViewReferences();
                for (IViewReference ivr : ivrs) {
                  if (ivr.getId().equals("TestView.view")) {
                    View v = (View) ivr.getView(true);
                    v.getGallery().getSelection()[0].setData(updatedSpecimen);
                    if (spec.getMissingInfo() == 0) {
                      v.getGallery()
                          .getSelection()[0]
                          .setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                    }
                    spec = updatedSpecimen;
                    break;
                  }
                }
              }
              label2.setVisible(true);
              label3.setVisible(false);
              label4.setVisible(false);
            } catch (Exception e) {
              label2.setVisible(false);
              label3.setVisible(true);
              //					label4.setText(e.getMessage());
              label4.setVisible(true);
              e.printStackTrace();
            }
          }
        }; // scientific name inserting
    submitButton.addSelectionListener(buttonSelectionListener);
    System.out.println(Platform.getInstallLocation().getURL().getPath());
    System.out.println(Platform.getInstanceLocation().getURL().getPath());
    Image image = ImageFactory.loadImage(Display.getCurrent(), ImageFactory.ACTION_SYNC);
    IStatusLineManager manager = this.getEditorSite().getActionBars().getStatusLineManager();
    Action toggleBotton =
        new SyncIDropAction("Sync with iDrop", ImageDescriptor.createFromImage(image), manager);
    if (spec.getIdropSync() == null || spec.getIdropSync() == 0) {
      toggleBotton.setEnabled(true);
    } else toggleBotton.setEnabled(true);
    form.getToolBarManager().add(toggleBotton);
    form.getToolBarManager().update(true);
  }
  /**
   * DOC smallet ConnectionsComposite constructor comment.
   *
   * @param parent
   * @param style
   */
  public ConnectionFormComposite(
      Composite parent,
      int style,
      ConnectionsListComposite connectionsListComposite,
      ConnectionsDialog dialog) {
    super(parent, style);
    this.dialog = dialog;
    this.connectionsListComposite = connectionsListComposite;

    toolkit = new FormToolkit(this.getDisplay());
    toolkit.setBackground(ColorConstants.white);
    Composite formBody = toolkit.createComposite(this);
    formBody.setBackground(ColorConstants.white);

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    setLayout(layout);
    formBody.setLayoutData(new GridData(GridData.FILL_BOTH));

    formBody.setLayout(new GridLayout(3, false));
    GridDataFactory formDefaultFactory = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER);
    // Repository
    Label repositoryLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(repositoryLabel);

    repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY);
    repositoryCombo.setContentProvider(ArrayContentProvider.getInstance());
    repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider());
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(repositoryCombo.getControl());

    // Name
    Label nameLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(nameLabel);

    nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(nameText);

    // Comment
    Label descriptionLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(descriptionLabel);

    descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(descriptionText);

    // User
    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck();
    Label userLabel;
    if (usesMailCheck) {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$
    } else {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$
    }

    formDefaultFactory.copy().applyTo(userLabel);

    userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(userText);

    // Password
    passwordLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(passwordLabel);

    passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(passwordText);

    Label workSpaceLabel =
        toolkit.createLabel(
            formBody, Messages.getString("ConnectionFormComposite.WORKSPACE")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(workSpaceLabel);

    Composite wsCompo = toolkit.createComposite(formBody);
    GridLayout wsCompoLayout = new GridLayout(2, false);
    wsCompoLayout.marginHeight = 0;
    wsCompoLayout.marginWidth = 0;

    wsCompo.setLayout(wsCompoLayout);
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(wsCompo);

    workSpaceText = toolkit.createText(wsCompo, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).applyTo(workSpaceText);

    workSpaceButton = toolkit.createButton(wsCompo, null, SWT.PUSH);
    workSpaceButton.setToolTipText(
        Messages.getString("ConnectionFormComposite.SELECT_WORKSPACE")); // $NON-NLS-1$
    workSpaceButton.setImage(ImageProvider.getImage(EImage.THREE_DOTS_ICON));
    GridDataFactory.fillDefaults().applyTo(workSpaceButton);

    List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider();
    for (IRepositoryFactory current : availableRepositories) {
      Map<String, LabelText> list = new HashMap<String, LabelText>();
      Map<String, LabelText> listRequired = new HashMap<String, LabelText>();
      Map<String, Button> listButtons = new HashMap<String, Button>();
      Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>();
      dynamicControls.put(current, list);
      dynamicRequiredControls.put(current, listRequired);
      dynamicButtons.put(current, listButtons);
      dynamicChoices.put(current, listChoices);

      for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) {
        Label label = toolkit.createLabel(formBody, currentChoiceBean.getName());
        formDefaultFactory.copy().applyTo(label);

        Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY);
        for (String label1 : currentChoiceBean.getChoices().values()) {
          combo.add(label1);
        }

        formDefaultFactory.copy().grab(true, false).applyTo(combo);

        listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo));
      }

      for (DynamicFieldBean currentField : current.getFields()) {
        int textStyle = SWT.BORDER;
        if (currentField.isPassword()) {
          textStyle = textStyle | SWT.PASSWORD;
        }
        Label label = toolkit.createLabel(formBody, currentField.getName());
        formDefaultFactory.copy().align(SWT.FILL, SWT.CENTER).applyTo(label);

        Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$

        formDefaultFactory.copy().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(text);
        LabelText labelText = new LabelText(label, text);
        if (currentField.isRequired()) {
          listRequired.put(currentField.getId(), labelText);
        }
        list.put(currentField.getId(), labelText);
      }

      for (final DynamicButtonBean currentButtonBean : current.getButtons()) {
        Button button = new Button(formBody, SWT.PUSH);
        button.setText(currentButtonBean.getName());
        button.addSelectionListener(new DelegateSelectionListener(currentButtonBean));
        formDefaultFactory.copy().align(SWT.RIGHT, SWT.CENTER).applyTo(button);

        listButtons.put(currentButtonBean.getId(), button);
      }
    }

    Label seperator = new Label(formBody, SWT.NONE);
    seperator.setVisible(false);
    GridData seperatorGridData = new GridData();
    seperatorGridData.horizontalSpan = 3;
    seperatorGridData.heightHint = 0;
    seperator.setLayoutData(seperatorGridData);
    Label placeHolder = new Label(formBody, SWT.NONE);
    // add delete buttons
    deleteProjectsButton = new Button(formBody, SWT.NONE);
    deleteProjectsButton.setText(
        Messages.getString("ConnectionFormComposite.deleteExistingProject")); // $NON-NLS-1$
    GridData deleteButtonGridData = new GridData();
    deleteButtonGridData.widthHint = LoginDialogV2.getNewButtonSize(deleteProjectsButton).x;
    deleteButtonGridData.horizontalSpan = 2;
    deleteProjectsButton.setLayoutData(deleteButtonGridData);

    addListeners();
    addWorkSpaceListener();
    fillLists();
    showHideDynamicsControls();
    showHideTexts();
    // validateFields();
  }
示例#28
0
  /** {@inheritDoc} */
  public Composite createControls(Composite parent, FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.TITLE_BAR);
    section.setText("Sampling Rate");
    section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);

    GridLayout layout = new GridLayout(4, false);
    layout.marginLeft = 10;
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(SWT.MAX, SWT.DEFAULT);
    gridData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(gridData);

    final Label sliderLabel = toolkit.createLabel(composite, "no sensitivity selected", SWT.LEFT);
    GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
    data.widthHint = sliderLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    sliderLabel.setLayoutData(data);

    slider = new Scale(composite, SWT.HORIZONTAL);
    toolkit.adapt(slider, true, true);
    slider.setMinimum(0);
    slider.setMaximum(Sensitivity.values().length - 1);
    slider.setIncrement(1);
    slider.setSize(200, 10);
    slider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    slider.addSelectionListener(
        new SelectionAdapter() {
          /** {@inheritDoc} */
          @Override
          public void widgetSelected(SelectionEvent event) {
            Sensitivity sensitivity = Sensitivity.fromOrd(slider.getSelection());

            switch (sensitivity) {
              case NO_SENSITIVITY:
                sliderLabel.setText("no sensitivity selected");
                break;
              case VERY_FINE:
                sliderLabel.setText("very fine");
                break;
              case FINE:
                sliderLabel.setText("fine");
                break;
              case MEDIUM:
                sliderLabel.setText("medium");
                break;
              case COARSE:
                sliderLabel.setText("coarse");
                break;
              case VERY_COARSE:
                sliderLabel.setText("very coarse");
                break;
              default:
                break;
            }
          }
        });
    slider.setSelection(DEFAULT_SENSITIVITY.ordinal());
    slider.notifyListeners(SWT.Selection, null);

    Label modeLabel = toolkit.createLabel(composite, "Sampling Rate Mode: ", SWT.LEFT);
    modeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    timeframeModeButton = toolkit.createButton(composite, "Timeframe dividing", SWT.RADIO);
    timeframeModeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    timeframeModeButton.setSelection(true);

    return composite;
  }
  protected void createFeaturesSection(FormToolkit toolkit, Composite parent) {
    final Section features =
        toolkit.createSection(
            parent,
            ExpandableComposite.TITLE_BAR
                | ExpandableComposite.TWISTIE
                | ExpandableComposite.EXPANDED);
    features.setText("Features Available");
    features.setLayout(new GridLayout());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    // gd.heightHint = 100;
    features.setLayoutData(gd);

    createFeaturesToolbar(toolkit, features);

    featureComposite = toolkit.createComposite(features);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    featureComposite.setLayoutData(gd);
    featureComposite.setLayout(new GridLayout());

    pageBook = new PageBook(featureComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    pageBook.setLayoutData(gd);

    discoveryViewer = new DiscoveryViewer(getSite(), this);
    discoveryViewer.setShowConnectorDescriptorKindFilter(false);
    discoveryViewer.setShowInstalledFilterEnabled(true);
    discoveryViewer.setDirectoryUrl(
        ProjectExamplesActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
    discoveryViewer.createControl(pageBook);
    discoveryViewer.setEnvironment(getEnvironment());
    discoveryViewer.addFilter(
        new ViewerFilter() {

          @Override
          public boolean select(Viewer viewer, Object parentElement, Object element) {
            DiscoveryConnector connector = (DiscoveryConnector) element;
            // System.out.println(connector.getId());
            if (connector.getId().equals("org.eclipse.mylyn.discovery.tests.connectorDescriptor1")
                || connector.getId().equals("org.eclipse.mylyn.discovery.test1")
                || connector.getId().equals("org.eclipse.mylyn.discovery.2tests")
                || connector.getId().equals("org.eclipse.mylyn.trac")) {
              // System.out.println("filtered " + connector.getId());
              return false;
            }
            return true;
          }
        });

    Control discoveryControl = discoveryViewer.getControl();
    adapt(toolkit, discoveryControl);
    if (discoveryControl instanceof Composite) {
      ((Composite) discoveryControl).setLayout(new GridLayout());
    }
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    discoveryControl.setLayoutData(gd);

    loadingComposite = createLoadingComposite(toolkit, pageBook);

    form.addControlListener(
        new ControlAdapter() {

          @Override
          public void controlResized(ControlEvent e) {
            GridData gridData = (GridData) featureComposite.getLayoutData();
            Point size = form.getSize();
            gridData.heightHint = size.y - 25;
            gridData.widthHint = size.x - 25;
            gridData.grabExcessVerticalSpace = true;

            gridData = (GridData) features.getLayoutData();
            gridData.heightHint = size.y - 20;
            gridData.widthHint = size.x - 20;
            gridData.grabExcessVerticalSpace = false;
            form.reflow(true);
            form.redraw();
          }
        });

    installButton = toolkit.createButton(featureComposite, "Install", SWT.PUSH);
    installButton.setEnabled(false);
    installButton.setImage(JBossCentralActivator.getDefault().getImage(ICON_INSTALL));
    installButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            installAction.run();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    discoveryViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            installAction.setEnabled(discoveryViewer.getInstallableConnectors().size() > 0);
            installButton.setEnabled(discoveryViewer.getInstallableConnectors().size() > 0);
          }
        });
    features.setClient(featureComposite);
    showLoading();
    pageBook.pack(true);

    RefreshDiscoveryJob refreshDiscoveryJob = RefreshDiscoveryJob.INSTANCE;
    refreshJobChangeListener = new RefreshJobChangeListener();
    refreshDiscoveryJob.addJobChangeListener(refreshJobChangeListener);
    refreshDiscoveryJob.schedule();
  }
示例#30
0
  /**
   * Create contents of the master details block
   *
   * @param managedForm
   * @param parent
   */
  @Override
  protected void createMasterPart(final IManagedForm managedForm, Composite parent) {
    FormToolkit toolkit = managedForm.getToolkit();

    final Section entriesSection =
        toolkit.createSection(parent, Section.EXPANDED | Section.TITLE_BAR);
    entriesSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    entriesSection.setText("Entries");
    entriesSection.marginWidth = 7;
    entriesSection.marginHeight = 7;

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 5;
    layout.marginHeight = 5;

    composite = toolkit.createComposite(entriesSection, SWT.WRAP);
    composite.setLayout(layout);

    filterFuzzyButton = toolkit.createButton(composite, "Show only fuzzy entries", SWT.CHECK);
    filterFuzzyButton.addSelectionListener(
        new SelectionListener() {

          public void widgetDefaultSelected(final SelectionEvent e) {}

          public void widgetSelected(final SelectionEvent e) {
            if (filterFuzzyButton.getSelection()) {
              viewer.addFilter(fuzzyFilter);
            } else {
              ViewerFilter[] filters = viewer.getFilters();
              List<ViewerFilter> list = Arrays.asList(filters);
              if (list.contains(fuzzyFilter)) {
                viewer.removeFilter(fuzzyFilter);
              }
            }
          }
        });

    filterUntranslatedButton =
        toolkit.createButton(composite, "Show only untranslated entries", SWT.CHECK);
    filterUntranslatedButton.addSelectionListener(
        new SelectionListener() {

          public void widgetDefaultSelected(final SelectionEvent e) {}

          public void widgetSelected(final SelectionEvent e) {
            if (filterUntranslatedButton.getSelection()) {
              viewer.addFilter(untranslatedFilter);
            } else {
              ViewerFilter[] filters = viewer.getFilters();
              List<ViewerFilter> list = Arrays.asList(filters);
              if (list.contains(untranslatedFilter)) {
                viewer.removeFilter(untranslatedFilter);
              }
            }
          }
        });

    table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gd.heightHint = 100;
    table.setLayoutData(gd);

    final TableColumn columnFuzzy = new TableColumn(table, SWT.NONE);
    columnFuzzy.setWidth(20);
    columnFuzzy.setText(this.columnNames[0]);
    columnFuzzy.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            createSort(EntrySorter.SORT_FUZZY);
            table.setSortColumn(columnFuzzy);
          }
        });

    final TableColumn columnMsgId = new TableColumn(table, SWT.NONE);
    columnMsgId.setWidth(300);
    columnMsgId.setText(this.columnNames[1]);
    columnMsgId.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            createSort(EntrySorter.SORT_MSG_ID);
            table.setSortColumn(columnMsgId);
          }
        });

    final TableColumn columnMsgStr = new TableColumn(table, SWT.NONE);
    columnMsgStr.setWidth(300);
    columnMsgStr.setText(this.columnNames[2]);
    columnMsgStr.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            createSort(EntrySorter.SORT_MSG_STR);
            table.setSortColumn(columnMsgStr);
          }
        });

    toolkit.paintBordersFor(composite);
    entriesSection.setClient(composite);

    final SectionPart spart = new SectionPart(entriesSection);
    managedForm.addPart(spart);
    createViewer(managedForm, spart);

    this.fuzzyFilter = new FuzzyFilter();
    this.untranslatedFilter = new UntranslatedFilter();

    this.createPopupMenu();
  }