Example #1
0
    @Override
    protected CellEditor getCellEditor(Object element) {
      if (element instanceof RedDeerLauncherProperties) {
        RedDeerLauncherProperties property = (RedDeerLauncherProperties) element;

        if (property.getProperty().getType() == RedDeerPropertyType.TEXT) {
          TextCellEditor te = new TextCellEditor((Composite) getViewer().getControl());
          te.addListener(new CustomCellEditorListener(te, element));
          return te;
        } else if (property.getProperty().getType() == RedDeerPropertyType.FLOAT) {
          TextCellEditor te = new TextCellEditor((Composite) getViewer().getControl());
          te.addListener(new CustomCellEditorListener(te, element));
          return te;
        } else {
          ComboBoxViewerCellEditor cellEditor =
              new ComboBoxViewerCellEditor((Composite) getViewer().getControl(), SWT.READ_ONLY);
          cellEditor.setLabelProvider(new ColumnLabelProvider());
          cellEditor.setContentProvider(new ArrayContentProvider());
          cellEditor.setInput(property.getProperty().getSupportedValues());
          cellEditor.addListener(new CustomCellEditorListener(cellEditor, element));
          return cellEditor;
        }
      }
      return null;
    }
Example #2
0
 @Override
 protected CellEditor getCellEditor(Object element) {
   final TextCellEditor result = new TextCellEditor(viewer.getTable());
   result.setValidator(new NumberCellValidator());
   result.addListener(new CellEditorListener(shell, result));
   return result;
 }
    @Override
    protected CellEditor getCellEditor(Object element) {

      final TextCellEditor textCellEditor = new TextCellEditor(viewer.getTable());

      textCellEditor.addListener(
          new ICellEditorListener() {

            public void editorValueChanged(boolean oldValidState, boolean newValidState) {

              if (wizardPage != null) {

                String str = textCellEditor.getValue().toString().trim();

                if (isPropertyValid(str)) {
                  wizardPage.setMessage(null);
                } else {

                  if (str.length() > 0) {
                    wizardPage.setMessage(
                        MessageFormat.format(
                            Messages.DefaultDataAdapterEditorComposite_alredyExistingMessage,
                            new Object[] {str}), // $NON-NLS-1$ //$NON-NLS-2$
                        IMessageProvider.ERROR);
                  } else {
                    wizardPage.setMessage(
                        Messages.DefaultDataAdapterEditorComposite_specifyNameMessage,
                        IMessageProvider.ERROR);
                  }
                }
              }
            }

            public void cancelEditor() {
              // nothing
            }

            public void applyEditorValue() {

              // clean any left message
              if (wizardPage != null) {
                wizardPage.setMessage(null);
              }
            }
          });

      return textCellEditor;
    }