| //------------------------------------------------------------------------------ |
| // Copyright (c) 2005, 2006 IBM Corporation and others. |
| // 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: |
| // IBM Corporation - initial implementation |
| //------------------------------------------------------------------------------ |
| package org.eclipse.epf.library.edit.navigator; |
| |
| import java.util.ArrayList; |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.command.Command; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.edit.command.CopyCommand.Helper; |
| import org.eclipse.emf.edit.domain.EditingDomain; |
| import org.eclipse.epf.library.edit.LibraryEditPlugin; |
| import org.eclipse.epf.library.edit.command.MethodElementAddCommand; |
| import org.eclipse.epf.uma.MethodLibrary; |
| import org.eclipse.epf.uma.UmaFactory; |
| import org.eclipse.epf.uma.UmaPackage; |
| import org.eclipse.epf.uma.edit.command.MethodElementCreateCopyCommand; |
| import org.eclipse.epf.uma.edit.command.MethodElementInitializeCopyCommand; |
| |
| /** |
| * The item provider adapter for a method library. |
| * |
| * @author Phong Nguyen Le |
| * @author Kelvin Low |
| * @since 1.0 |
| */ |
| public class MethodLibraryItemProvider extends |
| org.eclipse.epf.uma.provider.MethodLibraryItemProvider { |
| |
| private ConfigurationsItemProvider configurations; |
| |
| //private ProcessFamiliesItemProvider procFamilies; |
| |
| /** |
| * Creates a new instance. |
| */ |
| public MethodLibraryItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildrenFeatures(java.lang.Object) |
| */ |
| public Collection getChildrenFeatures(Object object) { |
| if (childrenFeatures == null) { |
| childrenFeatures = new ArrayList(); |
| childrenFeatures.add(UmaPackage.eINSTANCE |
| .getMethodLibrary_MethodPlugins()); |
| } |
| return childrenFeatures; |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#collectNewChildDescriptors(java.util.Collection, |
| * java.lang.Object) |
| */ |
| protected void collectNewChildDescriptors(Collection newChildDescriptors, |
| Object object) { |
| newChildDescriptors.add(createChildParameter(UmaPackage.eINSTANCE |
| .getMethodLibrary_MethodPlugins(), UmaFactory.eINSTANCE |
| .createMethodPlugin())); |
| } |
| |
| public Collection getChildren(Object object) { |
| Collection children = super.getChildren(object); |
| if (configurations == null) { |
| configurations = new ConfigurationsItemProvider(adapterFactory, |
| (MethodLibrary) object, LibraryEditPlugin.INSTANCE |
| .getString("_UI_Configurations_text")); //$NON-NLS-1$ |
| } |
| children.add(configurations); |
| |
| // Remove 'Process Families' until it is fully implemented |
| // |
| // if(procFamilies == null) { |
| // procFamilies = new ProcessFamiliesItemProvider(adapterFactory, |
| // (MethodLibrary) object, |
| // LibraryEditPlugin.INSTANCE.getString("_UI_ProcessFamilies_text")); |
| // } |
| // children.add(procFamilies); |
| |
| return children; |
| } |
| |
| public Object getConfigurations() { |
| return configurations; |
| } |
| |
| public Object getProcessFamilies() { |
| //return procFamilies; |
| return null; |
| } |
| |
| protected Command createInitializeCopyCommand(EditingDomain domain, |
| EObject owner, Helper helper) { |
| return new MethodElementInitializeCopyCommand(domain, owner, helper); |
| } |
| |
| protected Command createCreateCopyCommand(EditingDomain domain, |
| EObject owner, Helper helper) { |
| return new MethodElementCreateCopyCommand(domain, owner, helper); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#createAddCommand(org.eclipse.emf.edit.domain.EditingDomain, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, java.util.Collection, int) |
| */ |
| protected Command createAddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Collection collection, int index) { |
| return new MethodElementAddCommand(super.createAddCommand(domain, owner, feature, collection, index)); |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose() |
| */ |
| public void dispose() { |
| if (configurations != null) { |
| configurations.dispose(); |
| configurations = null; |
| } |
| /* |
| if (procFamilies != null) { |
| procFamilies.dispose(); |
| procFamilies = null; |
| } |
| */ |
| super.dispose(); |
| } |
| |
| } |