/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 SAP AG. | |
* 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: | |
* SAP AG - initial API, implementation and documentation | |
* | |
* </copyright> | |
* | |
*******************************************************************************/ | |
package org.eclipse.fmc.blockdiagram.editor.meta.features.add; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.features.context.IAddContext; | |
import org.eclipse.graphiti.mm.algorithms.Polyline; | |
import org.eclipse.graphiti.mm.pictograms.CompositeConnection; | |
import org.eclipse.graphiti.mm.pictograms.Connection; | |
import org.eclipse.graphiti.mm.pictograms.CurvedConnection; | |
import org.eclipse.graphiti.services.Graphiti; | |
import org.eclipse.graphiti.services.IGaService; | |
import org.eclipse.graphiti.services.IPeService; | |
import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle; | |
import org.eclipse.fmc.mm.Access; | |
import org.eclipse.fmc.mm.AccessType; | |
/** | |
* Feature Class for adding the graphical representation of an existing access | |
* business object. | |
* | |
* @author Patrick Jahnke | |
* | |
*/ | |
public class AccessAddMetaFeature extends | |
org.eclipse.fmc.blockdiagram.editor.features.add.AccessAddFeature { | |
/** | |
* Constructor just calls the super constructor. | |
* | |
* @param fp | |
* The IFeatureProvider. | |
* @param style | |
* The Shape Style. | |
*/ | |
public AccessAddMetaFeature(IFeatureProvider fp, ConnectionStyle style) { | |
super(fp, style); | |
} | |
/** | |
* Decorate the access connection with the right properties (draw a second | |
* connection if the access object represent a read and write access). | |
*/ | |
protected void addDomainModelContent(IAddContext context, Connection con, | |
Polyline line) { | |
if (context.getNewObject() instanceof Access) { | |
Access access = (Access) context.getNewObject(); | |
if (access.getType() == AccessType.RW) { | |
IGaService ga = Graphiti.getGaService(); | |
IPeService pe = Graphiti.getPeService(); | |
CompositeConnection compCon = (CompositeConnection) con; | |
CurvedConnection curved1 = pe.createCurvedConnection( | |
new double[] { 0.50d, 50d }, getDiagram()); | |
CurvedConnection curved2 = pe.createCurvedConnection( | |
new double[] { 0.50d, -50d }, getDiagram()); | |
compCon.getChildren().add(curved1); | |
compCon.getChildren().add(curved2); | |
ga.createPolyline(curved1); | |
ga.createPolyline(curved2); | |
createArrowDecorator(getDiagram(), curved1, true); | |
createArrowDecorator(getDiagram(), curved2, false); | |
line.setLineVisible(false); | |
} else if (access.getType() != AccessType.UNSPECIFIED) { | |
createArrowDecorator(getDiagram(), con, true); | |
} | |
} | |
} | |
} |