| /* |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| * Loetz GmbH&Co.KG |
| * |
| */ |
| package org.eclipse.osbp.vaadin.emf.data; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; |
| |
| // TODO: Auto-generated Javadoc |
| /** |
| * A wrapper class that holds the {@link EObject} and its |
| * {@link IItemPropertyDescriptor} in a common context.<br> |
| * And provides delegate methods to the {@link IItemPropertyDescriptor}. |
| */ |
| public class EmfItemPropertyDescritor { |
| |
| /** The e object. */ |
| private final EObject eObject; |
| |
| /** The descriptor. */ |
| private final IItemPropertyDescriptor descriptor; |
| |
| /** |
| * Instantiates a new emf item property descritor. |
| * |
| * @param eObject |
| * the e object |
| * @param descriptor |
| * the descriptor |
| */ |
| public EmfItemPropertyDescritor(EObject eObject, |
| IItemPropertyDescriptor descriptor) { |
| super(); |
| this.eObject = eObject; |
| this.descriptor = descriptor; |
| } |
| |
| /** |
| * Gets the e object. |
| * |
| * @return the e object |
| */ |
| public EObject getEObject() { |
| return eObject; |
| } |
| |
| /** |
| * Gets the descriptor. |
| * |
| * @return the descriptor |
| */ |
| public IItemPropertyDescriptor getDescriptor() { |
| return descriptor; |
| } |
| |
| /** |
| * Returns the String representation. |
| * |
| * @return the text |
| */ |
| public String getText() { |
| ItemPropertyDescriptor.PropertyValueWrapper value = (PropertyValueWrapper) descriptor |
| .getPropertyValue(eObject); |
| return value != null ? value.getText(eObject) : ""; |
| } |
| |
| /** |
| * Returns the editable value representation. |
| * |
| * @return the editable value |
| */ |
| public Object getEditableValue() { |
| ItemPropertyDescriptor.PropertyValueWrapper value = (PropertyValueWrapper) descriptor |
| .getPropertyValue(eObject); |
| return value != null ? value.getEditableValue(eObject) : null; |
| } |
| |
| /** |
| * Gets the property value. |
| * |
| * @return the property value |
| */ |
| public Object getPropertyValue() { |
| return descriptor.getPropertyValue(eObject); |
| } |
| |
| /** |
| * Checks if is property set. |
| * |
| * @return true, if is property set |
| */ |
| public boolean isPropertySet() { |
| return descriptor.isPropertySet(eObject); |
| } |
| |
| /** |
| * Can set property. |
| * |
| * @return true, if successful |
| */ |
| public boolean canSetProperty() { |
| return descriptor.canSetProperty(eObject); |
| } |
| |
| /** |
| * Reset property value. |
| */ |
| public void resetPropertyValue() { |
| descriptor.resetPropertyValue(eObject); |
| } |
| |
| /** |
| * Sets the property value. |
| * |
| * @param value |
| * the new property value |
| */ |
| public void setPropertyValue(Object value) { |
| descriptor.setPropertyValue(eObject, value); |
| } |
| |
| /** |
| * Gets the category. |
| * |
| * @return the category |
| */ |
| public String getCategory() { |
| return descriptor.getCategory(eObject); |
| } |
| |
| /** |
| * Gets the description. |
| * |
| * @return the description |
| */ |
| public String getDescription() { |
| return descriptor.getDescription(eObject); |
| } |
| |
| /** |
| * Gets the display name. |
| * |
| * @return the display name |
| */ |
| public String getDisplayName() { |
| return descriptor.getDisplayName(eObject); |
| } |
| |
| /** |
| * Gets the filter flags. |
| * |
| * @return the filter flags |
| */ |
| public String[] getFilterFlags() { |
| return descriptor.getFilterFlags(eObject); |
| } |
| |
| /** |
| * Gets the help context ids. |
| * |
| * @return the help context ids |
| */ |
| public Object getHelpContextIds() { |
| return descriptor.getHelpContextIds(eObject); |
| } |
| |
| /** |
| * Gets the id. |
| * |
| * @return the id |
| */ |
| public String getId() { |
| return descriptor.getId(eObject); |
| } |
| |
| /** |
| * Gets the label provider. |
| * |
| * @return the label provider |
| */ |
| public IItemLabelProvider getLabelProvider() { |
| return descriptor.getLabelProvider(eObject); |
| } |
| |
| /** |
| * Checks if is compatible with. |
| * |
| * @param anotherObject |
| * the another object |
| * @param anotherPropertyDescriptor |
| * the another property descriptor |
| * @return true, if is compatible with |
| */ |
| public boolean isCompatibleWith(Object anotherObject, |
| IItemPropertyDescriptor anotherPropertyDescriptor) { |
| return descriptor.isCompatibleWith(eObject, anotherObject, |
| anotherPropertyDescriptor); |
| } |
| |
| /** |
| * Gets the feature. |
| * |
| * @return the feature |
| */ |
| public Object getFeature() { |
| return descriptor.getFeature(eObject); |
| } |
| |
| /** |
| * Checks if is many. |
| * |
| * @return true, if is many |
| */ |
| public boolean isMany() { |
| return descriptor.isMany(eObject); |
| } |
| |
| /** |
| * Gets the choice of values. |
| * |
| * @return the choice of values |
| */ |
| public Collection<?> getChoiceOfValues() { |
| return descriptor.getChoiceOfValues(eObject); |
| } |
| |
| /** |
| * Checks if is multi line. |
| * |
| * @return true, if is multi line |
| */ |
| public boolean isMultiLine() { |
| return descriptor.isMultiLine(eObject); |
| } |
| |
| /** |
| * Checks if is sort choices. |
| * |
| * @return true, if is sort choices |
| */ |
| public boolean isSortChoices() { |
| return descriptor.isSortChoices(eObject); |
| } |
| |
| } |