Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.CellEditor


      if (element instanceof FeatureValue) {
        FeatureValue value = (FeatureValue) element;

        if (value.getFeature().getRange().isPrimitive()) {

          CellEditor editor;

          if (value.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
            editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
                    SWT.READ_ONLY);
          }
          else {
            editor = new TextCellEditor(viewer.getTree());
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
                    .getPrimitiveClass(value.getFeatureStructure().getCAS().getTypeSystem(), value.getFeature())));
          }

          return editor;
        }
        else {
          return null;
        }
      } else if (element instanceof ArrayValue) {

        ArrayValue arrayValue = (ArrayValue) element;

        FeatureStructure arrayFS = arrayValue.getFeatureStructure();

        CellEditor editor;

        if (arrayFS instanceof BooleanArrayFS) {
          editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
                  SWT.READ_ONLY);
          editor.setStyle(SWT.READ_ONLY);
        }
        else {
          editor = new TextCellEditor(viewer.getTree());

          if (arrayFS instanceof ByteArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Byte.class));
          }
          else if (arrayFS instanceof ShortArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Short.class));
          }
          else if (arrayFS instanceof IntArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Integer.class));
          }
          else if (arrayFS instanceof LongArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Long.class));
          }
          else if (arrayFS instanceof FloatArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Float.class));
          }
          else if (arrayFS instanceof DoubleArrayFS) {
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Double.class));
          }
          else if (arrayFS instanceof StringArrayFS) {
            // no validator needed
          }
          else {
View Full Code Here


        ICellEditorProvider cellEditorProvider = (ICellEditorProvider) cellModifier;
        Object data = treeItem.getData();
        if (fColumnProperties.length > column) {
          String property = fColumnProperties[column];
          if (cellModifier.canModify(data, property)) {
            CellEditor newCellEditor = cellEditorProvider.getCellEditor(data, column);
            if (newCellEditor != null) {
              // The control that will be the editor must be a
              // child of the columnPosition
              Control control = newCellEditor.getControl();
              if (control != null) {
                cellEditorState = new CellEditorState(newCellEditor, control, treeItem, column, property);
                cellEditorState.activate();
              }
            }
View Full Code Here

                {
                    IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
                    IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
                    Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

                    CellEditor cellEditor = valueEditor.getCellEditor();
                    cellEditor.setValue( oldRawValue );
                    cellEditor.activate();
                    Object newRawValue = cellEditor.getValue();

                    if ( newRawValue != null )
                    {
                        String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
View Full Code Here

        {
            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
            IValue value = new Value( attribute, "" ); //$NON-NLS-1$
            Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
           
            CellEditor cellEditor = valueEditor.getCellEditor();
            cellEditor.setValue( oldRawValue );
            cellEditor.activate();
            Object newRawValue = cellEditor.getValue();
           
            if ( newRawValue != null )
            {
                String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
               
View Full Code Here

            {
                IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
                IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
                Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
               
                CellEditor cellEditor = valueEditor.getCellEditor();
                cellEditor.setValue( oldRawValue );
                cellEditor.activate();
                Object newRawValue = cellEditor.getValue();
               
                if ( newRawValue != null )
                {
                    String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
                   
View Full Code Here

                IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
                IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
                Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

                CellEditor cellEditor = valueEditor.getCellEditor();
                cellEditor.setValue( oldRawValue );
                cellEditor.activate();
                Object newRawValue = cellEditor.getValue();

                if ( newRawValue != null )
                {
                    String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
View Full Code Here

    {
        IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
        IValue value = new Value( attribute, "" ); //$NON-NLS-1$
        Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

        CellEditor cellEditor = valueEditor.getCellEditor();
        cellEditor.setValue( oldRawValue );
        cellEditor.activate();
        Object newRawValue = cellEditor.getValue();

        if ( newRawValue != null )
        {
            String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
View Full Code Here

        {
            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
            IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
            Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

            CellEditor cellEditor = valueEditor.getCellEditor();
            cellEditor.setValue( oldRawValue );
            cellEditor.activate();
            Object newRawValue = cellEditor.getValue();

            if ( newRawValue != null )
            {
                String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
View Full Code Here

  /**
   * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
   */
  protected void initCellEditor() {
    CellEditor editor = getCellEditor();

    final Text text = (Text) editor.getControl();

    verifyListener = new VerifyListener() {
      public void verifyText(VerifyEvent event) {
        Text text = (Text) getCellEditor().getControl();
        String oldText = text.getText();
        String newText = oldText.substring(0, event.start) + event.text
            + oldText.substring(event.end, oldText.length());

        GC gc = new GC(text);
        Point size = gc.textExtent(newText);
        gc.dispose();
        if (size.x == 0) {
          size.x = size.y;
        } else {
          size = text.computeSize(size.x, size.y);
        }

        // String error =
        // getCellEditor().getValidator().isValid(newText);
        // if (error == null || error.isEmpty()) {
        // text.setBackground(text.getParent().getBackground());
        // } else {
        // text.setBackground(ColorConstants.red);
        // }

        text.setSize(size.x, size.y);
      }
    };
    text.addVerifyListener(verifyListener);

    String initialLabelText = vertexLabel.getText();
    editor.setValue(initialLabelText);
  }
View Full Code Here

*/
public class VertexDirectEditPolicy extends DirectEditPolicy {

  @Override
  protected Command getDirectEditCommand(DirectEditRequest request) {
    CellEditor editor = request.getCellEditor();
    editor.setValidator(new ICellEditorValidator() {

      @Override
      public String isValid(Object value) {
        VertexEditPart part = (VertexEditPart) getHost();
        Vertex vertex = (Vertex) part.getModel();
        Graph graph = vertex.getParent();

        String vertexId = (String) value;
        if (vertexId.isEmpty()) {
          return "";
        }

        vertex = graph.findVertex(vertexId);
        if (vertex != null && !vertex.equals(getHost().getModel())) {
          return "A vertex already exists with the same identifier";
        }

        return null;
      }

    });

    Vertex vertex = (Vertex) getHost().getModel();
    if (editor.getValidator().isValid(editor.getValue()) == null) {
      VertexRenameCommand cmd = new VertexRenameCommand(vertex);
      cmd.setName((String) editor.getValue());
      return cmd;
    } else {
      String id = (String) vertex.getValue(ObjectType.PARAMETER_ID);
      VertexFigure figure = (VertexFigure) getHostFigure();
      figure.getLabelId().setText(id);
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.CellEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.