/** * 2014 Urs Zeidler */ package de.urszeidler.eclipse.shr5.provider; import java.util.Collection; import java.util.List; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; import org.eclipse.emf.edit.provider.IItemLabelProvider; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; import org.eclipse.emf.edit.provider.ITreeItemContentProvider; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ItemProviderAdapter; import org.eclipse.emf.edit.provider.ViewerNotification; import org.eclipse.swt.graphics.Image; import de.urszeidler.eclipse.shr5.AutoSoft; import de.urszeidler.eclipse.shr5.Beschreibbar; import de.urszeidler.eclipse.shr5.Shr5Factory; import de.urszeidler.eclipse.shr5.Shr5Package; import de.urszeidler.eclipse.shr5.util.AdapterFactoryUtil; import de.urszeidler.eclipse.shr5.util.Shr5EditingTools; /** * This is the item provider adapter for a {@link de.urszeidler.eclipse.shr5.AutoSoft} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public class AutoSoftItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { /** * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public AutoSoftItemProvider(AdapterFactory adapterFactory) { super(adapterFactory); } /** * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { if (itemPropertyDescriptors == null) { super.getPropertyDescriptors(object); addWertPropertyDescriptor(object); addVerfuegbarkeitPropertyDescriptor(object); addWertValuePropertyDescriptor(object); addBeschreibungPropertyDescriptor(object); addImagePropertyDescriptor(object); addNamePropertyDescriptor(object); addParentIdPropertyDescriptor(object); addPagePropertyDescriptor(object); addSrcBookPropertyDescriptor(object); addRatingPropertyDescriptor(object); addSkillPropertyDescriptor(object); addWeaponPropertyDescriptor(object); addModelPropertyDescriptor(object); } return itemPropertyDescriptors; } /** * This adds a property descriptor for the Wert feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addWertPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_GeldWert_wert_feature"), getString("_UI_GeldWert_wert_description"), Shr5Package.Literals.GELD_WERT__WERT, false, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Verfuegbarkeit feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addVerfuegbarkeitPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_GeldWert_verfuegbarkeit_feature"), getString("_UI_PropertyDescriptor_description", "_UI_GeldWert_verfuegbarkeit_feature", "_UI_GeldWert_type"), Shr5Package.Literals.GELD_WERT__VERFUEGBARKEIT, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Wert Value feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addWertValuePropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_GeldWert_wertValue_feature"), getString("_UI_GeldWert_wertValue_description"), Shr5Package.Literals.GELD_WERT__WERT_VALUE, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Beschreibung feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addBeschreibungPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Beschreibbar_beschreibung_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Beschreibbar_beschreibung_feature", "_UI_Beschreibbar_type"), Shr5Package.Literals.BESCHREIBBAR__BESCHREIBUNG, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Image feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addImagePropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Beschreibbar_image_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Beschreibbar_image_feature", "_UI_Beschreibbar_type"), Shr5Package.Literals.BESCHREIBBAR__IMAGE, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Name feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addNamePropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Beschreibbar_name_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Beschreibbar_name_feature", "_UI_Beschreibbar_type"), Shr5Package.Literals.BESCHREIBBAR__NAME, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Parent Id feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addParentIdPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Identifiable_parentId_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Identifiable_parentId_feature", "_UI_Identifiable_type"), Shr5Package.Literals.IDENTIFIABLE__PARENT_ID, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Page feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addPagePropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Quelle_page_feature"), getString("_UI_Quelle_page_description"), Shr5Package.Literals.QUELLE__PAGE, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Src Book feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addSrcBookPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_Quelle_srcBook_feature"), getString("_UI_Quelle_srcBook_description"), Shr5Package.Literals.QUELLE__SRC_BOOK, true, false, true, null, null, null)); } /** * This adds a property descriptor for the Rating feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addRatingPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_AutoSoft_rating_feature"), getString("_UI_PropertyDescriptor_description", "_UI_AutoSoft_rating_feature", "_UI_AutoSoft_type"), Shr5Package.Literals.AUTO_SOFT__RATING, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); } /** * This adds a property descriptor for the Skill feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addSkillPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_AutoSoft_skill_feature"), getString("_UI_PropertyDescriptor_description", "_UI_AutoSoft_skill_feature", "_UI_AutoSoft_type"), Shr5Package.Literals.AUTO_SOFT__SKILL, true, false, true, null, null, null)); } /** * This adds a property descriptor for the Weapon feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addWeaponPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_AutoSoft_weapon_feature"), getString("_UI_PropertyDescriptor_description", "_UI_AutoSoft_weapon_feature", "_UI_AutoSoft_type"), Shr5Package.Literals.AUTO_SOFT__WEAPON, true, false, true, null, null, null)); } /** * This adds a property descriptor for the Model feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void addModelPropertyDescriptor(Object object) { itemPropertyDescriptors.add (createItemPropertyDescriptor (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_AutoSoft_model_feature"), getString("_UI_AutoSoft_model_description"), Shr5Package.Literals.AUTO_SOFT__MODEL, true, false, true, null, null, null)); } /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { if (childrenFeatures == null) { super.getChildrenFeatures(object); childrenFeatures.add(Shr5Package.Literals.IDENTIFIABLE__LOCALIZATIONS); } return childrenFeatures; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EStructuralFeature getChildFeature(Object object, Object child) { // Check the type of the specified child object and return the proper feature to use for // adding (see {@link AddCommand}) it as a child. return super.getChildFeature(object, child); } /** * This returns AutoSoft.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated not */ @Override public Object getImage(Object object) { Beschreibbar beschreibbar = (Beschreibbar) object; if (beschreibbar.getImage() != null) { Image image = AdapterFactoryUtil.getInstance().getImageScaledBy(16, beschreibbar.getImage()); if (image != null) return image; } return overlayImage(object, getResourceLocator().getImage("full/obj16/AutoSoft")); } /** * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated not */ @Override public String getText(Object object) { AutoSoft autoSoft = (AutoSoft)object; String label = autoSoft.getName(); final ComposeableAdapterFactory factory = ((ComposeableAdapterFactory)this.adapterFactory).getRootAdapterFactory(); final String unset = getString("_UI_Unset_text"); String model = Shr5EditingTools.getLabelForEObject(factory, unset, autoSoft.getModel()); String weapon = Shr5EditingTools.getLabelForEObject(factory, unset, autoSoft.getWeapon()); String skill = Shr5EditingTools.getLabelForEObject(factory, unset, autoSoft.getSkill()); String text = label == null || label.length() == 0 ? getString("_UI_AutoSoft_type") : getString("_UI_AutoSoft_type") + " " + label; if(autoSoft.getModel()==null && autoSoft.getModel()==null) return String.format("%s [%s]", text,skill); return String.format("%s [%s,%s,%s]", text,skill,model,weapon); } /** * This handles model notifications by calling {@link #updateChildren} to update any cached * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void notifyChanged(Notification notification) { updateChildren(notification); switch (notification.getFeatureID(AutoSoft.class)) { case Shr5Package.AUTO_SOFT__WERT: case Shr5Package.AUTO_SOFT__VERFUEGBARKEIT: case Shr5Package.AUTO_SOFT__WERT_VALUE: case Shr5Package.AUTO_SOFT__BESCHREIBUNG: case Shr5Package.AUTO_SOFT__IMAGE: case Shr5Package.AUTO_SOFT__NAME: case Shr5Package.AUTO_SOFT__PARENT_ID: case Shr5Package.AUTO_SOFT__PAGE: case Shr5Package.AUTO_SOFT__RATING: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case Shr5Package.AUTO_SOFT__LOCALIZATIONS: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } super.notifyChanged(notification); } /** * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children * that can be created under this object. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { super.collectNewChildDescriptors(newChildDescriptors, object); newChildDescriptors.add (createChildParameter (Shr5Package.Literals.IDENTIFIABLE__LOCALIZATIONS, Shr5Factory.eINSTANCE.createLocalization())); } /** * Return the resource locator for this item provider's resources. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public ResourceLocator getResourceLocator() { return Shr5EditPlugin.INSTANCE; } }