Exemplo n.º 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;
    }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 protected CellEditor[] getCellEditors() throws ApplicationException {
   if (cellEditors != null) return cellEditors;
   if ((gridStyle & IGridViewer.fullEditable) == 0) {
     String[] columnNames = getColumnNames();
     cellEditors = new CellEditor[columnNames.length];
     for (int i = 0; i < columnNames.length; i++) {
       TextCellEditor tce = new TextCellEditor(tableViewer.getTable());
       Text text = (Text) tce.getControl();
       text.setEditable(false);
       cellEditors[i] = tce;
     }
   } else {
     List attrib_list = CompositeMapUtil.getArrayAttrs(data);
     cellEditors = new CellEditor[attrib_list.size()];
     int id = 0;
     for (Iterator it = attrib_list.iterator(); it.hasNext(); ) {
       Attribute attrib = (Attribute) it.next();
       ICellEditor cellEditor =
           CellEditorFactory.getInstance().createCellEditor(this, attrib, null, null);
       if (cellEditor != null) {
         cellEditors[id++] = cellEditor.getCellEditor();
         addEditor(attrib.getLocalName(), cellEditor);
       } else {
         cellEditors[id++] = new TextCellEditor(tableViewer.getTable());
       }
     }
   }
   return cellEditors;
 }
    @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;
    }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
   */
  @Override
  protected CellEditor getCellEditor(final Object element) {
    TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE);
    editor.setValidator(
        new ICellEditorValidator() {

          @Override
          public String isValid(Object value) {
            String desc = (String) value;
            if (desc.length() > 255) {
              return Messages.descTooLong;
            }
            return null;
          }
        });
    return editor;
  }
 private void cellEditorClassKeyReleasedOccured(KeyEvent keyEvent) {
   if (keyEvent.character == '\u001b') { // Escape character
     ((IShowInvisibleCellEditorMethods) textCellEditor).fireCancelEditor();
   } else if (keyEvent.character == '\r') { // Return key
     ((IShowInvisibleCellEditorMethods) textCellEditor).fireApplyEditorValue();
     textCellEditor.deactivate();
   }
 }
Exemplo n.º 7
0
  @Override
  protected void doSetFocus() {
    super.doSetFocus();

    if (!_selectAll) {
      final Text text = getControl();
      text.setSelection(text.getText().length());
    }
  }
Exemplo n.º 8
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.jface.viewers.ICellEditorListener#editorValueChanged(boolean, boolean)
  */
 @Override
 public void editorValueChanged(boolean oldValidState, boolean newValidState) {
   if (!newValidState) {
     // If it is an invalid input, then display a tool tip showing the error.
     if (tooltip == null) {
       tooltip = new DefaultToolTip(editor.getControl(), ToolTip.RECREATE, true);
       tooltip.setImage(UIPlugin.getImage(ImageConsts.ERROR_IMAGE));
     }
     tooltip.setText(editor.getErrorMessage());
     Control control = editor.getControl();
     Point pOnScr = control.getSize();
     pOnScr.x = 0;
     tooltip.show(pOnScr);
   } else {
     // Dispose the tool tip if it is valid.
     disposeToolTip();
   }
 }
Exemplo n.º 9
0
  @Override
  public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);

    _selectAll = true;
    if (activationEvent.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED) {
      switch (activationEvent.character) {
        case ' ':
          break;

        case SWT.BS:
        case SWT.DEL:
          getControl().setText("");
          _selectAll = false;
          break;

        default:
          final String value = new String(new char[] {activationEvent.character});
          getControl().setText(value);
          _selectAll = false;
      }
    }
  }
Exemplo n.º 10
0
 @Override
 protected void editOccured(ModifyEvent e) {
   validateAsValue = false;
   super.editOccured(e);
   validateAsValue = true;
 }
Exemplo n.º 11
0
 @Override
 public void doSetValue(Object value) {
   value = valueHandler.toString(value);
   super.doSetValue(value);
 }
Exemplo n.º 12
0
 @Override
 protected void doSetValue(Object value) {
   if (value == null) value = "";
   else value = ModelUtil.getStringWrapperValue(value);
   super.doSetValue(value);
 }
Exemplo n.º 13
0
 @Override
 public void doSetValue(Object value) {
   super.doSetValue(value.toString());
 }