@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; }
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)); } }; }
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); }
public Object getId() { return itemPropertyDescriptor.getId(object); }
/** * Provides direct access to the underlying feature object. * * @since 2.9 */ public Object getFeature() { return itemPropertyDescriptor.getFeature(object); }
public Object getHelpContextIds() { return itemPropertyDescriptor.getHelpContextIds(object); }
public String[] getFilterFlags() { return itemPropertyDescriptor.getFilterFlags(object); }
public String getDisplayName() { return itemPropertyDescriptor.getDisplayName(object); }
public String getDescription() { return itemPropertyDescriptor.getDescription(object); }
public String getCategory() { return itemPropertyDescriptor.getCategory(object); }
/** * 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; }