| //------------------------------------------------------------------------------ |
| // 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.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.epf.library.configuration.ConfigurationHelper; |
| import org.eclipse.epf.library.layout.ElementLayoutManager; |
| import org.eclipse.epf.library.layout.util.XmlElement; |
| |
| import com.ibm.uma.MethodElement; |
| import com.ibm.uma.Role; |
| import com.ibm.uma.WorkProduct; |
| import com.ibm.uma.util.AssociationHelper; |
| |
| /** |
| * The element layout for an Artifact. |
| * |
| * @author Kelvin Low |
| * @since 1.0 |
| */ |
| public class WorkProductLayout extends AbstractElementLayout { |
| |
| public WorkProductLayout() { |
| super(); |
| } |
| |
| public void init(ElementLayoutManager layoutManager, MethodElement element) { |
| super.__init(layoutManager, element); |
| } |
| |
| public XmlElement getXmlElement(boolean includeReferences) { |
| XmlElement elementXml = super.getXmlElement(includeReferences); |
| if (includeReferences) { |
| |
| // no this will lose the contributor |
| // Role responsibleRole = |
| // AssociationHelper.getResponsibleRole((WorkProduct)super.element); |
| Role responsibleRole = (Role) ConfigurationHelper |
| .calc01FeatureValue(super.element, |
| AssociationHelper.WorkProduct_ResponsibleRole, |
| layoutManager.getConfiguration()); |
| if (responsibleRole != null) { |
| MethodElement role = ConfigurationHelper.getCalculatedElement( |
| (MethodElement) responsibleRole, layoutManager |
| .getConfiguration()); |
| if (role != null) { |
| String roleName = ((Role) role).getPresentationName(); |
| if (roleName == null || roleName.length() == 0) { |
| roleName = role.getName(); |
| } |
| elementXml.setAttribute("responsibleRoleName", roleName); //$NON-NLS-1$ |
| addReference(elementXml, "responsibleRole", role); //$NON-NLS-1$ |
| } |
| } |
| |
| List modifyRoles = AssociationHelper |
| .getModifiedBy((WorkProduct) super.element); |
| modifyRoles = ConfigurationHelper.getCalculatedElements( |
| modifyRoles, layoutManager.getConfiguration()); |
| addReferences(elementXml, "modifyRoles", modifyRoles); //$NON-NLS-1$ |
| |
| MethodElement domain = ConfigurationHelper.calc01FeatureValue( |
| super.element, AssociationHelper.WorkProduct_Domain, |
| layoutManager.getConfiguration()); |
| addReference(elementXml, "domain", domain); //$NON-NLS-1$ |
| |
| List workProductTypes = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.WorkProduct_WorkProductTypes, |
| layoutManager.getConfiguration(), workProductTypes); |
| addReferences(elementXml, "workProductTypes", workProductTypes); //$NON-NLS-1$ |
| |
| List mandatoryInputToTasks = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.WorkProduct_MandatoryInputTo_Tasks, |
| layoutManager.getConfiguration(), mandatoryInputToTasks); |
| addReferences(elementXml, |
| "mandatoryInputToTasks", mandatoryInputToTasks); //$NON-NLS-1$ |
| |
| List optionalInputToTasks = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.WorkProduct_OptionalInputTo_Tasks, |
| layoutManager.getConfiguration(), optionalInputToTasks); |
| addReferences(elementXml, |
| "optionalInputToTasks", optionalInputToTasks); //$NON-NLS-1$ |
| |
| List outputFromTasks = new ArrayList(); |
| ConfigurationHelper.calculateOppositeFeature(super.element, |
| AssociationHelper.WorkProduct_OutputFrom_Tasks, |
| layoutManager.getConfiguration(), outputFromTasks); |
| addReferences(elementXml, "outputFromTasks", outputFromTasks); //$NON-NLS-1$ |
| } |
| return elementXml; |
| } |
| |
| } |