| //------------------------------------------------------------------------------ |
| // 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.layout.elements; |
| |
| import java.io.File; |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.List; |
| import java.util.Map; |
| |
| import org.eclipse.epf.library.configuration.ConfigurationHelper; |
| import org.eclipse.epf.library.layout.ElementLayoutManager; |
| import org.eclipse.epf.library.layout.diagram.MethodElementDiagram; |
| import org.eclipse.epf.library.layout.diagram.RoleDiagramPublisher; |
| import org.eclipse.epf.library.layout.util.XmlElement; |
| |
| import com.ibm.uma.MethodElement; |
| import com.ibm.uma.util.AssociationHelper; |
| |
| /** |
| * The element layout for a Role. |
| * |
| * @author Jinhua Xi |
| * @author Kelvin Low |
| * @since 1.0 |
| */ |
| public class RoleLayout extends AbstractElementLayout { |
| |
| protected Map referenceMap = new HashMap(); |
| |
| public RoleLayout() { |
| super(); |
| } |
| |
| public void init(ElementLayoutManager layoutManager, MethodElement element) { |
| super.__init(layoutManager, element); |
| } |
| |
| public XmlElement getXmlElement(boolean includeReferences) { |
| XmlElement elementXml = super.getXmlElement(includeReferences); |
| if (includeReferences) { |
| List performs = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.Role_Primary_Tasks, layoutManager |
| .getConfiguration(), performs); |
| referenceMap.put("performs", performs); //$NON-NLS-1$ |
| |
| List additionallyPerforms = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.Role_Secondary_Tasks, layoutManager |
| .getConfiguration(), additionallyPerforms); |
| // referenceMap.put("additionallyPerforms", additionallyPerforms); |
| // //$NON-NLS-1$ |
| addReferences(elementXml, |
| "additionallyPerforms", additionallyPerforms); //$NON-NLS-1$ |
| RoleDiagramPublisher diagramPublisher = new RoleDiagramPublisher(); |
| MethodElementDiagram diagram = diagramPublisher.publish(this, |
| new File(layoutManager.getPublishDir())); |
| elementXml.setContent("diagram", diagram.getHTML()); //$NON-NLS-1$ |
| |
| List roleSets = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.Role_RoleSets, layoutManager |
| .getConfiguration(), roleSets); |
| addReferences(elementXml, "roleSets", roleSets); //$NON-NLS-1$ |
| } |
| return elementXml; |
| } |
| |
| public List getPerforms() { |
| return (List) referenceMap.get("performs"); //$NON-NLS-1$ |
| } |
| |
| public List getAdditionallyPerforms() { |
| return (List) referenceMap.get("additionallyPerforms"); //$NON-NLS-1$ |
| } |
| |
| public List getResponsibleFor() { |
| return (List) referenceMap.get("responsibleFor"); //$NON-NLS-1$ |
| } |
| |
| public List getModifies() { |
| return (List) referenceMap.get("modifies"); //$NON-NLS-1$ |
| } |
| |
| /** |
| * some layout need to have the feature values for further processing. So |
| * this method will be called when a feature is calculated in this abstract |
| * class |
| * |
| * @param name |
| * @param value |
| */ |
| protected void notifyFeatureValue(String name, Object value) { |
| referenceMap.put(name, value); |
| } |
| |
| } |