@Override public boolean hasChildren(Object object) { if (object != null && object instanceof TreeNodeWrapper) { TreeNodeWrapper treeNodeWrapper = (TreeNodeWrapper) object; if (treeNodeWrapper.getObject() != null && treeNodeWrapper.getObject() instanceof BTSConfig) { Object realItem = ((TreeNodeWrapper) object).getObject(); IItemLabelProvider realItemItemprovider = getRealItemItemProvider(treeNodeWrapper, realItem); return ((ItemProviderAdapter) realItemItemprovider).hasChildren(realItem); } } return super.hasChildren(object); }
/** * Returns the type name for the given object. * The type name is retrieved from the edit plug-in, * which provides type names for all types (classes). * * @param eObject the object the type name to get for * @return the type name for the given object, null if an error occurred */ public static String getTypeName(EObject eObject) { // Get the key name of this object for the translated string // by using the objects interface name. String className = eObject.eClass().getName(); String key = "_UI_" + className + "_type"; String result = null; try { ItemProviderAdapter itemProvider = getItemProvider(eObject); result = itemProvider.getString(key); } catch (MissingResourceException e) { System.err.println("Error: Missing Resource for " + className + "! Did you forget to register the adapter factory?"); } return result; }
private StringBuffer appendType(final StringBuffer text, final Type type) { if (type == null) { return text; } return ((ILabelAppender) adapterFactory.adapt(type, ItemProviderAdapter.class)).appendLabel( text.append(" (of type "), type).append(')'); }
/** * Returns the new child descriptor for creating a new child of the given feature for the given object. * * @param eObject the object a child should created for * @param childFeature the feature of the children * @return the {@link CommandParameter} (new child descriptor) */ public static CommandParameter getNewChildDescriptor(EObject eObject, EStructuralFeature childFeature) { EditingDomain editingDomain = getEditingDomain(eObject); ItemProviderAdapter itemProvider = getItemProvider(eObject); for (Object object : itemProvider.getNewChildDescriptors(eObject, editingDomain, null)) { CommandParameter childDescriptor = (CommandParameter) object; if (childDescriptor.getFeature() == childFeature) { return childDescriptor; } } return null; }
/** * Returns the property descriptor for the feature of the given object. * * @param object the object containing the feature * @param feature the feature/property * @return the {@link IItemPropertyDescriptor} for the feature of the given object */ public static IItemPropertyDescriptor getPropertyDescriptor(EObject object, EStructuralFeature feature) { ItemProviderAdapter itemProvider = getItemProvider(object); return itemProvider.getPropertyDescriptor(object, feature); }
/** * Returns the item provider for the given object. * * @param object the object the item provider is requested for * @return the {@link ItemProviderAdapter} for the given object */ public static ItemProviderAdapter getItemProvider(EObject object) { return (ItemProviderAdapter) getAdapterFactory(object).adapt(object, IItemPropertySource.class); }
/** * Adds the given listener to the item provider of the given object. * Make sure to remove the listener when not needed anymore. * * @param object the object * @param listener the listener */ public static void addListenerFor(EObject object, INotifyChangedListener listener) { ItemProviderAdapter itemProvider = getItemProvider(object); itemProvider.addListener(listener); }
/** * Removes the given listener from the item provider of the given object. * * @param object the object * @param listener the listener */ public static void removeListenerFor(EObject object, INotifyChangedListener listener) { ItemProviderAdapter itemProvider = getItemProvider(object); itemProvider.removeListener(listener); }