/******************************************************************************* * Copyright (c) 2011, 2012 Red Hat, Inc. * All rights reserved. * This program is 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: * Red Hat, Inc. - initial API and implementation * * @author Innar Made ******************************************************************************/ package org.eclipse.bpmn2.modeler.ui.features.event.definitions; import org.eclipse.bpmn2.BaseElement; import org.eclipse.bpmn2.Bpmn2Package; import org.eclipse.bpmn2.TerminateEventDefinition; import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractCreateEventDefinitionFeature; import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractEventDefinitionFeatureContainer; import org.eclipse.bpmn2.modeler.core.features.event.definitions.DecorationAlgorithm; import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil; import org.eclipse.bpmn2.modeler.core.utils.ShapeDecoratorUtil; import org.eclipse.bpmn2.modeler.core.utils.StyleUtil; import org.eclipse.bpmn2.modeler.core.utils.StyleUtil.FillStyle; import org.eclipse.bpmn2.modeler.ui.ImageProvider; import org.eclipse.emf.ecore.EClass; import org.eclipse.graphiti.features.ICreateFeature; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.mm.algorithms.Ellipse; import org.eclipse.graphiti.mm.pictograms.ContainerShape; import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; public class TerminateEventDefinitionFeatureContainer extends AbstractEventDefinitionFeatureContainer { @Override public boolean canApplyTo(Object o) { return super.canApplyTo(o) && o instanceof TerminateEventDefinition; } @Override public ICreateFeature getCreateFeature(IFeatureProvider fp) { return new CreateTerminateEventDefinition(fp); } @Override protected Shape drawForStart(DecorationAlgorithm algorithm, ContainerShape shape) { return null; // NOT ALLOWED ACCORDING TO SPEC } @Override protected Shape drawForEnd(DecorationAlgorithm algorithm, ContainerShape shape) { return draw(shape); } @Override protected Shape drawForThrow(DecorationAlgorithm algorithm, ContainerShape shape) { return null; // NOT ALLOWED ACCORDING TO SPEC } @Override protected Shape drawForCatch(DecorationAlgorithm algorithm, ContainerShape shape) { return null; // NOT ALLOWED ACCORDING TO SPEC } @Override protected Shape drawForBoundary(DecorationAlgorithm algorithm, ContainerShape shape) { return null; // NOT ALLOWED ACCORDING TO SPEC } public static Shape draw(ContainerShape shape) { BaseElement be = BusinessObjectUtil.getFirstElementOfType(shape, BaseElement.class, true); Shape terminateShape = Graphiti.getPeService().createShape(shape, false); Ellipse ellispe = ShapeDecoratorUtil.createEventTerminate(terminateShape); StyleUtil.setFillStyle(ellispe, FillStyle.FILL_STYLE_FOREGROUND); StyleUtil.applyStyle(ellispe, be); return terminateShape; } public static class CreateTerminateEventDefinition extends AbstractCreateEventDefinitionFeature<TerminateEventDefinition> { public CreateTerminateEventDefinition(IFeatureProvider fp) { super(fp); } @Override protected String getStencilImageId() { return ImageProvider.IMG_16_TERMINATE; } /* (non-Javadoc) * @see org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateFeature#getBusinessObjectClass() */ @Override public EClass getBusinessObjectClass() { return Bpmn2Package.eINSTANCE.getTerminateEventDefinition(); } } }