@Override
    protected void doDrawCellContent(
        GC gc, org.eclipse.swt.graphics.Rectangle rect, int row, int col) {

      PropertyRow propertyRow = (PropertyRow) contentProvider.getRowContent(row);
      if (!(propertyRow instanceof Descriptor)) return;

      IItemPropertyDescriptor propertyDescriptor =
          ((Descriptor) propertyRow).getItemPropertyDescriptor();
      Object propertyValue = propertyDescriptor.getPropertyValue(contentProvider.getElement());
      IItemLabelProvider labelProvider = propertyDescriptor.getLabelProvider(propertyValue);
      Image image =
          ExtendedImageRegistry.getInstance().getImage(labelProvider.getImage(propertyValue));

      drawTextImage(
          gc,
          " " + propertyRow.toString(),
          alignment,
          image,
          alignment,
          rect.x + 2,
          rect.y + 1,
          rect.width - 1,
          rect.height - 1);
    }
 @Override
 protected void applyCaption() {
   final IItemPropertyDescriptor itemPropertyDescriptor =
       VaadinRendererUtil.getItemPropertyDescriptor(
           getVElement().getDomainModelReference().getIterator().next());
   label.setCaption(itemPropertyDescriptor.getDisplayName(null));
 }
  /**
   * Fetches the list of available values for the feature.
   *
   * @return The list of available values for the feature.
   */
  protected List<?> getChoiceOfValues() {
    List<?> values = Collections.emptyList();
    List<IItemPropertyDescriptor> propertyDescriptors = getDescriptors();
    for (Iterator<IItemPropertyDescriptor> iterator = propertyDescriptors.iterator();
        iterator.hasNext(); ) {
      IItemPropertyDescriptor propertyDescriptor = iterator.next();
      if (((EStructuralFeature) propertyDescriptor.getFeature(eObject)) == getFeature())
        values = new ArrayList<Object>(propertyDescriptor.getChoiceOfValues(eObject));
    }

    // Start of user code choice of values
    // End of user code choice of values
    return values;
  }
 @Override
 public int canRender(IItemPropertyDescriptor itemPropertyDescriptor, EObject modelElement) {
   Object feature = itemPropertyDescriptor.getFeature(modelElement);
   if (feature instanceof EReference
       && !((EReference) feature).isMany()
       && EObject.class.isAssignableFrom(((EReference) feature).getEType().getInstanceClass())) {
     return PRIORITY;
   }
   return AbstractMEControl.DO_NOT_RENDER;
 }
예제 #5
0
  public ILabelProvider getLabelProvider() {
    final IItemLabelProvider itemLabelProvider = itemPropertyDescriptor.getLabelProvider(object);
    return new LabelProvider() {
      @Override
      public String getText(Object object) {
        return itemLabelProvider.getText(object);
      }

      @Override
      public Image getImage(Object object) {
        return ExtendedImageRegistry.getInstance().getImage(itemLabelProvider.getImage(object));
      }
    };
  }
예제 #6
0
  protected CellEditor createEDataTypeCellEditor(final EDataType eDataType, Composite composite) {
    if (itemPropertyDescriptor.isMultiLine(object)) {
      return new ExtendedDialogCellEditor(composite, getEditLabelProvider()) {
        protected EDataTypeValueHandler valueHandler = new EDataTypeValueHandler(eDataType);

        @Override
        protected Object openDialogBox(Control cellEditorWindow) {
          InputDialog dialog =
              new MultiLineInputDialog(
                  cellEditorWindow.getShell(),
                  EMFEditUIPlugin.INSTANCE.getString(
                      "_UI_FeatureEditorDialog_title",
                      new Object[] {getDisplayName(), getEditLabelProvider().getText(object)}),
                  EMFEditUIPlugin.INSTANCE.getString("_UI_MultiLineInputDialog_message"),
                  valueHandler.toString(getValue()),
                  valueHandler);
          return dialog.open() == Window.OK ? valueHandler.toValue(dialog.getValue()) : null;
        }
      };
    }
    return new EDataTypeCellEditor(eDataType, composite);
  }
예제 #7
0
 public Object getId() {
   return itemPropertyDescriptor.getId(object);
 }
예제 #8
0
 /**
  * Provides direct access to the underlying feature object.
  *
  * @since 2.9
  */
 public Object getFeature() {
   return itemPropertyDescriptor.getFeature(object);
 }
예제 #9
0
 public Object getHelpContextIds() {
   return itemPropertyDescriptor.getHelpContextIds(object);
 }
예제 #10
0
 public String[] getFilterFlags() {
   return itemPropertyDescriptor.getFilterFlags(object);
 }
예제 #11
0
 public String getDisplayName() {
   return itemPropertyDescriptor.getDisplayName(object);
 }
예제 #12
0
 public String getDescription() {
   return itemPropertyDescriptor.getDescription(object);
 }
예제 #13
0
 public String getCategory() {
   return itemPropertyDescriptor.getCategory(object);
 }
예제 #14
0
  /**
   * This returns the cell editor that will be used to edit the value of this property. This default
   * implementation determines the type of cell editor from the nature of the structural feature.
   */
  public CellEditor createPropertyEditor(Composite composite) {
    if (!itemPropertyDescriptor.canSetProperty(object)) {
      return null;
    }

    CellEditor result = null;

    Object genericFeature = itemPropertyDescriptor.getFeature(object);
    if (genericFeature instanceof EReference[]) {
      result =
          new ExtendedComboBoxCellEditor(
              composite,
              new ArrayList<Object>(itemPropertyDescriptor.getChoiceOfValues(object)),
              getEditLabelProvider(),
              itemPropertyDescriptor.isSortChoices(object));
    } else if (genericFeature instanceof EStructuralFeature) {
      final EStructuralFeature feature = (EStructuralFeature) genericFeature;
      final EClassifier eType = feature.getEType();
      final Collection<?> choiceOfValues = itemPropertyDescriptor.getChoiceOfValues(object);
      if (choiceOfValues != null) {
        if (itemPropertyDescriptor.isMany(object)) {
          boolean valid = true;
          for (Object choice : choiceOfValues) {
            if (!eType.isInstance(choice)) {
              valid = false;
              break;
            }
          }

          if (valid) {
            final ILabelProvider editLabelProvider = getEditLabelProvider();
            result =
                new ExtendedDialogCellEditor(composite, editLabelProvider) {
                  @Override
                  protected Object openDialogBox(Control cellEditorWindow) {
                    FeatureEditorDialog dialog =
                        new FeatureEditorDialog(
                            cellEditorWindow.getShell(),
                            editLabelProvider,
                            object,
                            feature.getEType(),
                            (List<?>) doGetValue(),
                            getDisplayName(),
                            new ArrayList<Object>(choiceOfValues),
                            false,
                            itemPropertyDescriptor.isSortChoices(object),
                            feature.isUnique());
                    dialog.open();
                    return dialog.getResult();
                  }
                };
          }
        }

        if (result == null) {
          result =
              new ExtendedComboBoxCellEditor(
                  composite,
                  new ArrayList<Object>(choiceOfValues),
                  getEditLabelProvider(),
                  itemPropertyDescriptor.isSortChoices(object));
        }
      } else if (eType instanceof EDataType) {
        EDataType eDataType = (EDataType) eType;
        if (eDataType.isSerializable()) {
          if (itemPropertyDescriptor.isMany(object)) {
            final ILabelProvider editLabelProvider = getEditLabelProvider();
            result =
                new ExtendedDialogCellEditor(composite, editLabelProvider) {
                  @Override
                  protected Object openDialogBox(Control cellEditorWindow) {
                    FeatureEditorDialog dialog =
                        new FeatureEditorDialog(
                            cellEditorWindow.getShell(),
                            editLabelProvider,
                            object,
                            feature.getEType(),
                            (List<?>) doGetValue(),
                            getDisplayName(),
                            null,
                            itemPropertyDescriptor.isMultiLine(object),
                            false,
                            feature.isUnique());
                    dialog.open();
                    return dialog.getResult();
                  }
                };
          } else if (eDataType.getInstanceClass() == Boolean.class) {
            result =
                new ExtendedComboBoxCellEditor(
                    composite,
                    Arrays.asList(new Object[] {null, Boolean.FALSE, Boolean.TRUE}),
                    getEditLabelProvider(),
                    itemPropertyDescriptor.isSortChoices(object));
          } else if (eDataType.getInstanceClass() == Boolean.TYPE) {
            result =
                new ExtendedComboBoxCellEditor(
                    composite,
                    Arrays.asList(new Object[] {Boolean.FALSE, Boolean.TRUE}),
                    getEditLabelProvider(),
                    itemPropertyDescriptor.isSortChoices(object));
          } else {
            result = createEDataTypeCellEditor(eDataType, composite);
          }
        }
      }
    }

    return result;
  }