| //------------------------------------------------------------------------------ |
| // 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.dataexchange.internal.importing; |
| |
| import org.eclipse.epf.dataexchange.importing.LibraryService; |
| import org.eclipse.epf.dataexchange.importing.PluginService; |
| import org.eclipse.epf.library.services.LibraryProcessor; |
| import org.eclipse.epf.library.util.ModelStorage; |
| |
| import com.ibm.uma.MethodConfiguration; |
| import com.ibm.uma.MethodLibrary; |
| import com.ibm.uma.MethodPlugin; |
| import com.ibm.uma.UmaFactory; |
| |
| /** |
| * Library service for importing external library/plugins into the current library. |
| * |
| * @author Jinhua Xi |
| * @since 1.0 |
| * |
| */ |
| public class LibraryServiceImpl implements LibraryService { |
| |
| LibraryProcessor proc; |
| |
| public LibraryServiceImpl() |
| { |
| proc = LibraryProcessor.getInstance(); |
| } |
| |
| public MethodPlugin createPlugin(String name, String guid) { |
| |
| MethodPlugin plugin = UmaFactory.eINSTANCE.createMethodPlugin(); |
| plugin.setName(name); |
| plugin.setGuid(guid); |
| |
| // initialize the plugin |
| plugin = ModelStorage.initialize(plugin); |
| |
| // MUST save the plugin before process anything else |
| proc.addMethodPlugin(plugin); |
| |
| return plugin; |
| } |
| |
| public MethodConfiguration createConfiguration(String name, String guid) { |
| MethodConfiguration config = UmaFactory.eINSTANCE.createMethodConfiguration(); |
| config.setName(name); |
| config.setGuid(guid); |
| |
| MethodLibrary library = proc.getLibrary(); |
| boolean oldNotify = library.eDeliver(); |
| try |
| { |
| library.eSetDeliver(false); |
| library.getPredefinedConfigurations().add(config); |
| } |
| finally { |
| library.eSetDeliver(oldNotify); |
| } |
| |
| return config; |
| } |
| |
| /** |
| * create a plugin service for the specified plugin |
| * @param plugin MethodPlugin |
| * @return PluginService |
| */ |
| public PluginService createPluginService(MethodPlugin plugin) { |
| return new PluginServiceImpl(plugin); |
| } |
| } |