public void commit(boolean onSave) {
    fNameText.commit();
    fLabelText.commit();
    fDescriptionText.commit();

    super.commit(onSave);
  }
 private void setValue(String property) {
   if (fCurrentCategoryDefinition == null) {
     clearField(property);
   } else {
     if (property.equals(PROPERTY_NAME))
       fNameText.setValue(fCurrentCategoryDefinition.getName(), true);
     else if (property.equals(PROPERTY_TYPE))
       fLabelText.setValue(fCurrentCategoryDefinition.getLabel(), true);
     else if (property.equals(PROPERTY_DESC)) {
       ISiteDescription siteDesc = fCurrentCategoryDefinition.getDescription();
       if (siteDesc == null) {
         clearField(property);
       } else {
         fDescriptionText.setValue(siteDesc.getText(), true);
       }
     }
   }
 }
  private void update() {
    fBlockNotification = true;

    if (fInput != null) {
      fNameText.setValue(fInput.getName(), true);
      fVersionText.setValue(fInput.getVersion(), true);
      fOptionalButton.setSelection(fInput.isOptional());
      int searchLocation = fInput.getSearchLocation();
      fSearchRootButton.setSelection(searchLocation == IFeatureChild.ROOT);
      fSearchSelfButton.setSelection(searchLocation == IFeatureChild.SELF);
      fSearchBothButton.setSelection(searchLocation == IFeatureChild.BOTH);
    } else {
      fNameText.setValue(null, true);
      fVersionText.setValue(null, true);
      fOptionalButton.setSelection(false);
      fSearchRootButton.setSelection(true);
      fSearchSelfButton.setSelection(false);
      fSearchBothButton.setSelection(false);
    }
    boolean editable = fInput != null && isEditable();
    fNameText.setEditable(editable);
    fVersionText.setEditable(editable);
    fOptionalButton.setEnabled(editable);
    fSearchRootButton.setEnabled(editable);
    fSearchSelfButton.setEnabled(editable);
    fSearchBothButton.setEnabled(editable);

    fBlockNotification = false;
  }
 public void cancelEdit() {
   fNameText.cancelEdit();
   fLabelText.cancelEdit();
   fDescriptionText.cancelEdit();
   super.cancelEdit();
 }
 public void setFocus() {
   if (fNameText != null) fNameText.getText().setFocus();
 }
 private void limitTextWidth(FormEntry entry) {
   GridData gd = (GridData) entry.getText().getLayoutData();
   gd.widthHint = 30;
 }
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    Composite container = toolkit.createComposite(section);
    container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
    container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    GridData data = new GridData(GridData.FILL_BOTH);
    section.setLayoutData(data);

    fNameText = new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_name, null, false);
    fNameText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            try {
              if (text.getValue().length() <= 0 || alreadyExists(text.getValue())) {
                setValue(PROPERTY_NAME);
                String message = MDEUIMessages.CategoryDetails_alreadyExists;
                MessageDialog.openError(
                    MDEPlugin.getActiveWorkbenchShell(),
                    MDEUIMessages.CategoryDetails_alreadyExists_title,
                    message);
              } else {
                applyValue(PROPERTY_NAME, text.getValue());
              }
            } catch (CoreException e) {
              MDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fNameText);
    fNameText.setEditable(isEditable());

    fLabelText =
        new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_label, null, false);
    fLabelText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(PROPERTY_TYPE, text.getValue());
            } catch (CoreException e) {
              MDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fLabelText);
    fLabelText.setEditable(isEditable());

    fDescriptionText =
        new FormEntry(container, toolkit, MDEUIMessages.CategoryDetails_desc, SWT.WRAP | SWT.MULTI);
    fDescriptionText.getText().setLayoutData(new GridData(GridData.FILL_BOTH));

    fDescriptionText.getLabel().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    fDescriptionText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(PROPERTY_DESC, text.getValue());
            } catch (CoreException e) {
              MDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fDescriptionText);
    fDescriptionText.setEditable(isEditable());
    toolkit.paintBordersFor(container);
    section.setClient(container);

    ISiteModel model = (ISiteModel) getPage().getModel();
    if (model != null) model.addModelChangedListener(this);
  }
 private void clearFields() {
   fNameText.setValue(null, true);
   fLabelText.setValue(null, true);
   fDescriptionText.setValue(null, true);
 }
 private void clearField(String property) {
   if (property.equals(PROPERTY_NAME)) fNameText.setValue(null, true);
   else if (property.equals(PROPERTY_TYPE)) fLabelText.setValue(null, true);
   else if (property.equals(PROPERTY_DESC)) fDescriptionText.setValue(null, true);
 }
  public void createClient(Section section, FormToolkit toolkit) {

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

    Composite container = toolkit.createComposite(section);
    container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 2));

    fNameText =
        new FormEntry(
            container,
            toolkit,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_featureLabel,
            null,
            false);
    fNameText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setName(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fNameText.setEditable(isEditable());

    fVersionText =
        new FormEntry(
            container, toolkit, MDEUIMessages.FeatureEditor_SpecSection_version, null, false);
    fVersionText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setVersion(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fVersionText.setEditable(isEditable());

    fOptionalButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_optional, SWT.CHECK);

    TableWrapData gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fOptionalButton.setLayoutData(gd);
    fOptionalButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                fInput.setOptional(fOptionalButton.getSelection());
              } catch (CoreException ce) {
              }
            }
          }
        });
    Label fSearchLocationDescLabel =
        toolkit.createLabel(
            container,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_searchLocation,
            SWT.WRAP);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fSearchLocationDescLabel.setLayoutData(gd);

    fSearchRootButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_root, SWT.RADIO);
    fSearchRootButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchRootButton.setLayoutData(gd);
    fSearchRootButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchRootButton.getSelection()) fInput.setSearchLocation(IFeatureChild.ROOT);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchSelfButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_self, SWT.RADIO);
    fSearchSelfButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchSelfButton.setLayoutData(gd);
    fSearchSelfButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchSelfButton.getSelection()) fInput.setSearchLocation(IFeatureChild.SELF);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchBothButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_both, SWT.RADIO);
    fSearchBothButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchBothButton.setLayoutData(gd);
    fSearchBothButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchBothButton.getSelection()) fInput.setSearchLocation(IFeatureChild.BOTH);
              } catch (CoreException ce) {
              }
            }
          }
        });

    toolkit.paintBordersFor(container);
    section.setClient(container);
  }
 public void commit(boolean onSave) {
   fNameText.commit();
   fVersionText.commit();
   super.commit(onSave);
 }
 public void cancelEdit() {
   fNameText.cancelEdit();
   fVersionText.cancelEdit();
   super.cancelEdit();
 }