Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.CellEditor


    }

    @Override
    protected CellEditor getCellEditor(Object element) {
        try{
            final CellEditor result = doGetCellEditor(element);
            if (result!=null) {
                Field field = asField(element);
                view.setLastValueEdited(field.getPropertyName(), field.getNewPropertyName(), columnId);
            }
            return result;
View Full Code Here


                return new DateTimeCellEditor(tableViewer.getTable(), getNode(), field.getPropertyName());
            }
            if (field.getPropertyType()==PropertyType.BOOLEAN) {
                return new ComboBoxCellEditor(tableViewer.getTable(), new String[] {"false", "true"}, SWT.READ_ONLY);
            }
            CellEditor editor;
            if (field.getPropertyName().equals("jcr:primaryType")) {
                editor = new TextCellEditor(tableViewer.getTable()) {
                    @Override
                    protected Control createControl(Composite parent) {
                        Text text = (Text) super.createControl(parent);
                        Repository repository = ServerUtil.getDefaultRepository(getNode().getProject());
                        NodeTypeRegistry ntManager = (repository==null) ? null : repository.getNodeTypeRegistry();
                        if (ntManager == null) {
                            return text;
                        }
                        try {
                            Collection<String> types = ntManager.getAllowedPrimaryChildNodeTypes(getNode().getParent().getPrimaryType());
                            SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(types.toArray(new String[0]));
                            proposalProvider.setFiltering(true);
                            ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(),
                                    proposalProvider, null, null);
                            adapter.setPropagateKeys(true);
                            adapter
                                    .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
                            return text;
                        } catch (RepositoryException e) {
                            return text;
                        }
                    }
                };
            } else {
                editor = new TextCellEditor(tableViewer.getTable());
            }
            // value might require a validator depending on the property type
            int propertyType = getNode().getPropertyType(field.getPropertyName());
            switch(propertyType) {
            case PropertyType.STRING:
            case PropertyType.NAME: {
                // no validator needed, any string is OK (for now)
                //TODO: check jcr rules for name
                break;
            }
            case PropertyType.DECIMAL: {
                editor.setValidator(new DecimalValidator(editor));
                break;
            }
            default: {
                // for the rest, no check implemented yet
                //TODO
View Full Code Here

        /* add table-textcelleditors key and traverse listeners */
        CellEditor[] cellEditors = fTableViewer.getCellEditors();
        if (cellEditors != null) {
            for (int colIndex = 0; colIndex < cellEditors.length; colIndex++) {
                CellEditor cellEditor = cellEditors[colIndex];
                if (cellEditor != null) {
                    // cellEditor.getControl().addKeyListener(new
                    // CellEditorKeyListener(this, cellEditor, colIndex));
                    cellEditor.getControl().addTraverseListener(new CellEditorTraverseListener(this, cellEditor, colIndex));
                }
            }
        }
    }
View Full Code Here

        private final CellEditor editor;

        public VersionEditingSupport(TableViewer viewer) {
            super(viewer);

            final CellEditor textEditor = new TextCellEditor(viewer.getTable());
            textEditor.setValidator(new ICellEditorValidator() {
                @Override
                public String isValid(Object value) {
                    String versionStr = String.valueOf(value);
                    Version v = Version.emptyVersion;

                    try {
                        v = Version.parseVersion(String.valueOf(value));
                    } catch (IllegalArgumentException iae) {
                        return MessageFormat.format(Messages.PackageInfoDialog_VersionInvalid, versionStr);
                    }

                    if (v == Version.emptyVersion) {
                        return Messages.PackageInfoDialog_VersionMissing;
                    }

                    return null;
                }
            });
            textEditor.addListener(new ICellEditorListener() {
                @Override
                public void editorValueChanged(boolean oldValidState, boolean newValidState) {
                    if (newValidState) {
                        validate();
                    } else {
                        setMessage(textEditor.getErrorMessage(), IMessageProvider.ERROR);
                    }
                }

                @Override
                public void cancelEditor() {
View Full Code Here

      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.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

                offset = 0;
            }
        }

        for( int i = 0; i < editors.length - offset; i++ ) {
            final CellEditor editor = editors[i + offset];
            if (editor == null)
                continue;
            if (listener != null && listener[i] != null)
                editor.addListener(listener[i]);
            editor.addListener(new DisplayErrorCellListener(editor));
        }
    }
View Full Code Here

                offset = 0;
            }
        }

        for( int i = 0; i < editors.length - offset; i++ ) {
            CellEditor editor = editors[i + offset];
            if (editor == null)
                continue;
            if (validators != null && validators[i] != null)
                editor.setValidator(validators[i]);
            else
                editor.setValidator(new AttributeValidator(schema.getDescriptor(i), schema));
        }
    }
View Full Code Here

public class LongEditor implements ICellEditorFactory {
  private static final long serialVersionUID = -4403435758517308113L;

 
  public CellEditor createPropertyEditor(Object bean, Composite parent) {
    CellEditor editor = new TextCellEditor(parent);
    editor.setValidator(new LongCellEditorValidator());
    return editor;
  }
View Full Code Here

public class RectangleEditor extends RectangleWrapper implements ICellEditorFactory {
  private static final long serialVersionUID = -4403435758517308113L;

 
  public CellEditor createPropertyEditor(Object bean, Composite parent) {
    CellEditor editor = new TextCellEditor(parent);
    editor.setValidator(new RectangleCellEditorValidator());
    return editor;
  }
View Full Code Here

public class DimensionEditor extends DimensionWrapper implements ICellEditorFactory {
  private static final long serialVersionUID = -4403435758517308113L;

 
  public CellEditor createPropertyEditor(Object bean, Composite parent) {
    CellEditor editor = new TextCellEditor(parent);
    editor.setValidator(new DimensionCellEditorValidator());
    return editor;
  }
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.