當前位置: 首頁>>代碼示例>>Java>>正文


Java IItemPropertySource.getPropertyDescriptor方法代碼示例

本文整理匯總了Java中org.eclipse.emf.edit.provider.IItemPropertySource.getPropertyDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java IItemPropertySource.getPropertyDescriptor方法的具體用法?Java IItemPropertySource.getPropertyDescriptor怎麽用?Java IItemPropertySource.getPropertyDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.edit.provider.IItemPropertySource的用法示例。


在下文中一共展示了IItemPropertySource.getPropertyDescriptor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFeatureDescriptor

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
/**
 * Given an object and one of its EStructuralFeatures, return the property descriptor for the feature. Assumes that the
 * PropertyDescriptor's propertyID is the EStructuralFeature's name.
 * 
 * @param object
 * @param feature
 * @return the property descriptor for the feature
 */
public static IItemPropertyDescriptor getFeatureDescriptor(Object object, EStructuralFeature feature) {
	IItemPropertySource source = adapt(object, IItemPropertySource.class);
	if (source == null) {
		String objectName = null;
		if (object instanceof EObject) {
			objectName = getDisplayName((EObject)object);
		} else if (object == null) {
			objectName = "null";
		} else {
			objectName = object.toString();
		}
		LogUtil.warnOnce("Could not find a property source for " + objectName);
		return null;
	}
	return source.getPropertyDescriptor(object, feature.getName());
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:25,代碼來源:EMFUtils.java

示例2: getDisplayName

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
public static String getDisplayName(EObject target, EStructuralFeature feature) {
	String displayName = getAnnotation(feature, ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_DISPLAY_NAME);
	if (displayName == null) {
		displayName = getAnnotation(feature, ANNOTATION_SOURCE_DESCRIPTOR, ANNOTATION_DESCRIPTOR_DISPLAY_NAME);
	}
	if (displayName == null) {
		IItemPropertySource source = adapt(target, IItemPropertySource.class);
		if (source != null) {
			IItemPropertyDescriptor itemPropertyDescriptor = source.getPropertyDescriptor(target, feature);
			if (itemPropertyDescriptor != null) {
				displayName = itemPropertyDescriptor.getDisplayName(feature);
			}
		}
	}
	if (displayName == null) {
		displayName = feature.getName();
	}
	return displayName;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:20,代碼來源:EMFUtils.java

示例3: getAttributeValue

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private static String getAttributeValue(Object object, EAttribute eAttribute) {
	IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
	IItemPropertyDescriptor startPD = source.getPropertyDescriptor(object, eAttribute);
	// First check the instance name
	IStringifier stringifier = EMFUtils.getStringifier(eAttribute);
	if (startPD != null) {
		Object value = EMFUtils.getPropertyValue(startPD, object);
		if (value instanceof Collection) {
			StringBuffer buffer = new StringBuffer();
			Collection collection = (Collection)value;
			for (Iterator i=collection.iterator(); i.hasNext(); ) {
				Object o = i.next();
				buffer.append(stringifier.getDisplayString(o));
				if (i.hasNext()) {
					buffer.append(", ");
				}
			}
			return buffer.toString();
		}
		return stringifier.getDisplayString(value);
	}
	return "";
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:24,代碼來源:TooltipShellBuilder.java

示例4: getReferenceParameter

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private static String getReferenceParameter(EPlanElement ePlanElement, EReferenceParameter eStructuralFeature) {
	IItemPropertySource source = EMFUtils.adapt(ePlanElement, IItemPropertySource.class);
	IItemPropertyDescriptor startPD = source.getPropertyDescriptor(ePlanElement, eStructuralFeature);
	// First check the instance name
	if (startPD != null) {
		Object value = EMFUtils.getPropertyValue(startPD, ePlanElement);
		if (value != null && StringifierRegistry.hasRegisteredStringifier(eStructuralFeature.getName())) {
			IStringifier stringifier = StringifierRegistry.getStringifier(eStructuralFeature.getName());
			return stringifier.getDisplayString(value);
		}
		if(value instanceof EcoreEList) {
			List<String> valueList = new ArrayList<String>();
			for (Object o : ((EcoreEList) value).toArray()) {
				valueList.add(getChoiceText(eStructuralFeature, o));
			}
			return EEnumStringifier.formatString(valueList.toString());
		}
	}
	return "";
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:21,代碼來源:TooltipShellBuilder.java

示例5: getChoiceOfValues

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
protected List<String> getChoiceOfValues(EPlanElement element, EStructuralFeature feature) {
	
	if(choiceOfValues == null) {
		EClassifier eType = feature.getEType();
		if(eType instanceof EEnumImpl) {
			choices = ((EEnumImpl) eType).getELiterals();				
		} else {
			IItemPropertySource itemPropertySource = EMFUtils.adapt(element, IItemPropertySource.class);
			IItemPropertyDescriptor pd = itemPropertySource.getPropertyDescriptor(element, feature);
			choices = pd.getChoiceOfValues(element);
		}
		choiceOfValues = getList(choices);
	}
	
	return choiceOfValues;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:17,代碼來源:MultiselectCellEditor.java

示例6: runWithEvent

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
@Override
public void runWithEvent(Event event) {
	MenuItem item = (MenuItem) event.widget;
	boolean selected = item.getSelection();
	String label = "Edit " + getDisplayName();
	CompositeOperation op = new CompositeOperation(label);
	for (EObject object : getObjects()) {
		if (object instanceof EPlanElement) {
			IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
			if (source != null) {
				IItemPropertyDescriptor pd = source.getPropertyDescriptor(object, getFeature());
				op.add(getOperation(object, pd, selected, !selected));
			}
		}
	}
	IUndoContext undoContext = getUndoContext();
	CommonUtils.execute(op, undoContext);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:19,代碼來源:BooleanAction.java

示例7: getDisplayName

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
/**
 * Use to get the nicely formatted display version of a feature/attribute name. 
 * @param feature the feature whose name is to be returned, nicely formatted of course
 * @param eObject the element to which the feature belongs
 * @param data typically eObject.getData()
 * @return a nice display name version of the feature name, or null if none is available.
 */
public static String getDisplayName(EStructuralFeature feature , EObject eObject, EObject data) {
	String displayName = null;
	IItemPropertySource itemPropertySource = EMFUtils.adapt(eObject, IItemPropertySource.class);
	if(itemPropertySource != null) {
		IItemPropertyDescriptor itemPropertyDescriptor = itemPropertySource.getPropertyDescriptor(eObject, feature);
		if(itemPropertyDescriptor != null) {
			displayName = itemPropertyDescriptor.getDisplayName(eObject);
		}						
	}
	
	Object name = eObject.eGet(feature);
	if(name != null) {
		displayName = name.toString();
	}
	
	return displayName;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:25,代碼來源:EPlanUtils.java

示例8: getText

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
protected String getText(EPlanElement pe, String key) {
	if (TimelinePreferencePage.P_DECORATOR_TEXT_KEY_NONE.equals(key)) {
		return null;
	}
	
	if (PlanTextDecoratorFieldProvider.P_DECORATOR_TEXT_KEY_NAME.equals(key)) {
		return pe.getName();
	}
	
	if (PlanTextDecoratorFieldProvider.P_DECORATOR_TEXT_KEY_NOTES.equals(key)) {
		return pe.getMember(CommonMember.class).getNotes();
	}
	
	EObject object = pe.getData();
	IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
	if (source != null) {
		EStructuralFeature f = object.eClass().getEStructuralFeature(key);
		if (f != null) {
			IItemPropertyDescriptor pd = source.getPropertyDescriptor(object, f);
			if (pd != null) {
				IItemLabelProvider lp = pd.getLabelProvider(object);
				if (lp != null) {
					Object value = pd.getPropertyValue(object);
					if (value instanceof PropertyValueWrapper) {
						value = ((PropertyValueWrapper)value).getEditableValue(object);
					}
					return lp.getText(value);
				}
			}
		}
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:34,代碼來源:TemporalNodeDecoratorTextEditPolicy.java

示例9: buildFeatureRow

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private String buildFeatureRow(EAttribute feature) {
	TemporalNodeEditPart ep = (TemporalNodeEditPart) getHost();
	Object model = ep.getModel();
	IItemPropertySource source = EMFUtils.adapt(model, IItemPropertySource.class);
	IItemPropertyDescriptor startPD = source.getPropertyDescriptor(model, feature);
	
	// First check the instance name
	IStringifier stringifier = EMFUtils.getStringifier(feature);
	
	Object value = EMFUtils.getPropertyValue(startPD, model);
	return "<TR><TD>"+startPD.getDisplayName(model)+"</TD><TD>"+stringifier.getDisplayString(value)+"</TD></TR>";
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:14,代碼來源:TemporalNodeToolTipPolicy.java

示例10: getReferenceParameterValue

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private static Object getReferenceParameterValue(EPlanElement ePlanElement, EReferenceParameter eStructuralFeature) {
	IItemPropertySource source = EMFUtils.adapt(ePlanElement, IItemPropertySource.class);
	IItemPropertyDescriptor startPD = source.getPropertyDescriptor(ePlanElement, eStructuralFeature);
	if (startPD != null) {
		return EMFUtils.getPropertyValue(startPD, ePlanElement);
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:9,代碼來源:TooltipShellBuilder.java

示例11: createBinding

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
@Override
public Binding createBinding(DetailProviderParameter p) {
	FormToolkit toolkit = p.getDetailFormToolkit();
	Composite parent = p.getParent();
	EObject target = p.getTarget();
	if (target instanceof MultiEObject) {
		LogUtil.warnOnce("multiselection not supported for rule set binding factory");
		return null;
	}
	if (!(target instanceof RuleAdvisorMember)) {
		LogUtil.warn("couldn't generate rule set binding for: " + target);
		return null;
	}
	RuleAdvisorMember member = (RuleAdvisorMember)target;
	WaiverPropertiesEntry rulesEntry = WaiverUtils.getWaiverEntry(member, RuleAdvisorMember.RULE_WAIVERS_KEY, false);
	EPlanElement element = member.getPlanElement();
	IItemPropertyDescriptor pd = p.getPropertyDescriptor();
	boolean isEditable = pd.canSetProperty(member);
	EMFDetailUtils.createLabel(parent, toolkit, member, pd);
	RulesSelector selector = RulesSelectorFactoryRegistry.getRulesSelectorFactory(parent, element);
	Button button = selector.getButton();
	button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	button.setEnabled(isEditable);
	toolkit.adapt(button, true, true);
	IItemPropertySource source = EMFUtils.adapt(rulesEntry, IItemPropertySource.class);
	pd = source.getPropertyDescriptor(rulesEntry, "value");
	p.setTarget(rulesEntry);
	p.setPropertyDescriptor(pd);
	EMFDetailUtils.bindControlViability(p, new Control[] {button});
	return EMFDetailUtils.bindEMFUndoable(p, new RuleSetSelectorObservableValue(selector));
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:32,代碼來源:RuleSetBindingFactory.java

示例12: runWithEvent

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
@Override
public void runWithEvent(Event event) {
	String label = "Edit " + getDisplayName();
	CompositeOperation op = new CompositeOperation(label);
	for (EObject object : getObjects()) {
		if (object instanceof EPlanElement) {
			IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
			if (source != null) {
				IItemPropertyDescriptor pd = source.getPropertyDescriptor(object, getFeature());
				Object propertyValue = EMFUtils.getPropertyValue(pd, object);
				if (pd.isMany(object)) {
					@SuppressWarnings("unchecked")
					EList<EObject> oldValue = new BasicEList<EObject>((Collection<EObject>) propertyValue);
					EList<EObject> newValue = new BasicEList<EObject>(oldValue);
					if (isChecked()) {
						newValue.remove(value);
					} else if (!newValue.contains(value)) {
						newValue.add((EObject) value);
					}
					op.add(getOperation(object, pd, oldValue, newValue));
				} else {
					op.add(getOperation(object, pd, propertyValue, value));
				}
			}
		}
	}
	IUndoContext undoContext = getUndoContext();
	CommonUtils.execute(op, undoContext);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:30,代碼來源:ValueAction.java

示例13: getPropertyDescriptor

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private static IItemPropertyDescriptor getPropertyDescriptor(EObject object, EStructuralFeature feature) {
	IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
	if (source != null) {
		return source.getPropertyDescriptor(object, feature);
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:8,代碼來源:PlanEditorContextMenuBuilder.java

示例14: getObjectDefFeatureValue

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private String getObjectDefFeatureValue(EObject object, String fieldName, EStructuralFeature feature) {
	IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
	IItemPropertyDescriptor pd = source.getPropertyDescriptor(object, feature);
	if (pd != null) {
		Object propertyValue = EMFUtils.getPropertyValue(pd, object);
		if (propertyValue != null && StringifierRegistry.hasRegisteredStringifier(fieldName)) {
			IStringifier<Object> stringifier = StringifierRegistry.getStringifier(fieldName);
			return stringifier.getDisplayString(propertyValue);
		}
	}
	return "";
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:13,代碼來源:PlanIndexer.java

示例15: getNameToEStructuralFeatureMap

import org.eclipse.emf.edit.provider.IItemPropertySource; //導入方法依賴的package包/類
private static WeakHashMap<String, EStructuralFeature> getNameToEStructuralFeatureMap(EPlanElement ePlanElement) {
	IItemPropertySource itemPropertySource = EMFUtils.adapt(ePlanElement, IItemPropertySource.class);
	WeakHashMap<String, EStructuralFeature> nameToStructuralFeatureMap = new WeakHashMap<String, EStructuralFeature>();
	EList<EMember> eMembers = ePlanElement.getMembers();
	// gather all of the attributes
	List<EStructuralFeature> allEStructuralFeatures = new ArrayList<EStructuralFeature>();
	for (EMember eMember : eMembers) {
		allEStructuralFeatures.addAll(eMember.eClass().getEAllStructuralFeatures());
	}
	EObject data = ePlanElement.getData();
	if (data != null) {
		allEStructuralFeatures.addAll(data.eClass().getEAllStructuralFeatures());
	}
	
	// build the map
	for (EStructuralFeature eStructuralFeature : allEStructuralFeatures) {
		IItemPropertyDescriptor descriptor = itemPropertySource.getPropertyDescriptor(ePlanElement, eStructuralFeature);
		if (descriptor == null) {
			continue;
		}
		String nameKey = descriptor.getDisplayName(ePlanElement);
		boolean foundTooltipAttribute = false;
		for (String tooltipAttribute : supportedTooltipAttributes) {
			if (tooltipAttribute.startsWith(nameKey)) {
				foundTooltipAttribute = true;
				int barIndex = tooltipAttribute.indexOf(':');
				if (barIndex > -1) {
					String nestedAttributeName = tooltipAttribute.substring(barIndex + 1).trim();
					EClassifier type = eStructuralFeature.getEType();
					if (type instanceof ObjectDef) {
						for (EAttribute nestedAttribute : ((ObjectDef)type).getEAllAttributes()) {
							String nestedDisplayName = ParameterDescriptor.getInstance().getDisplayName(nestedAttribute);
							if (nestedDisplayName.equals(nestedAttributeName)) {
								nameToStructuralFeatureMap.put(nestedDisplayName, nestedAttribute);
							}
						}
					}
				}
			}
		}
		if (!foundTooltipAttribute) {
			nameKey = eStructuralFeature.getName();
		}
		if (nameKey != null) {
			nameToStructuralFeatureMap.put(nameKey, eStructuralFeature);
		}
	}
	return nameToStructuralFeatureMap;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:50,代碼來源:TooltipShellBuilder.java


注:本文中的org.eclipse.emf.edit.provider.IItemPropertySource.getPropertyDescriptor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。