/******************************************************************************* * 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.EscalationEventDefinition; 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.Polygon; import org.eclipse.graphiti.mm.pictograms.ContainerShape; import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; public class EscalationEventDefinitionContainer extends AbstractEventDefinitionFeatureContainer { @Override public boolean canApplyTo(Object o) { return super.canApplyTo(o) && o instanceof EscalationEventDefinition; } @Override public ICreateFeature getCreateFeature(IFeatureProvider fp) { return new CreateEscalationEventDefinition(fp); } @Override protected Shape drawForStart(DecorationAlgorithm algorithm, ContainerShape shape) { return draw(shape); } @Override protected Shape drawForEnd(DecorationAlgorithm algorithm, ContainerShape shape) { return drawFilled(shape); } @Override protected Shape drawForThrow(DecorationAlgorithm algorithm, ContainerShape shape) { return drawFilled(shape); } @Override protected Shape drawForCatch(DecorationAlgorithm algorithm, ContainerShape shape) { return null; // NOT ALLOWED ACCORDING TO SPEC } @Override protected Shape drawForBoundary(DecorationAlgorithm algorithm, ContainerShape shape) { return draw(shape); } public static Shape draw(ContainerShape shape) { BaseElement be = BusinessObjectUtil.getFirstBaseElement(shape); Shape escalationShape = Graphiti.getPeService().createShape(shape, false); Polygon escalation = ShapeDecoratorUtil.createEventEscalation(escalationShape); StyleUtil.setFillStyle(escalation, FillStyle.FILL_STYLE_BACKGROUND); StyleUtil.applyStyle(escalation, be); return escalationShape; } public static Shape drawFilled(ContainerShape shape) { BaseElement be = BusinessObjectUtil.getFirstBaseElement(shape); Shape escalationShape = Graphiti.getPeService().createShape(shape, false); Polygon escalation = ShapeDecoratorUtil.createEventEscalation(escalationShape); StyleUtil.setFillStyle(escalation, FillStyle.FILL_STYLE_FOREGROUND); StyleUtil.applyStyle(escalation, be); return escalationShape; } public static class CreateEscalationEventDefinition extends AbstractCreateEventDefinitionFeature<EscalationEventDefinition> { public CreateEscalationEventDefinition(IFeatureProvider fp) { super(fp); } @Override protected String getStencilImageId() { return ImageProvider.IMG_16_ESCAlATION; } /* (non-Javadoc) * @see org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateFeature#getBusinessObjectClass() */ @Override public EClass getBusinessObjectClass() { return Bpmn2Package.eINSTANCE.getEscalationEventDefinition(); } } }