use of org.eclipse.gmf.runtime.notation.Edge in project tdi-studio-se by Talend.
the class BusinessReorientConnectionViewCommand method doExecuteWithResult.
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) {
//$NON-NLS-1$
assert null != edgeAdaptor : "Null child in BusinessReorientConnectionViewCommand";
Edge edge = (Edge) getEdgeAdaptor().getAdapter(Edge.class);
//$NON-NLS-1$
assert null != edge : "Null edge in BusinessReorientConnectionViewCommand";
View tempView = edge.getSource();
edge.setSource(edge.getTarget());
edge.setTarget(tempView);
return CommandResult.newOKCommandResult();
}
use of org.eclipse.gmf.runtime.notation.Edge in project tdi-studio-se by Talend.
the class BusinessProcessCanonicalEditPolicy method refreshConnections.
/**
* @generated
*/
private Collection refreshConnections() {
try {
collectAllLinks(getDiagram());
Collection existingLinks = new LinkedList(getDiagram().getEdges());
for (Iterator diagramLinks = existingLinks.iterator(); diagramLinks.hasNext(); ) {
Edge nextDiagramLink = (Edge) diagramLinks.next();
EObject diagramLinkObject = nextDiagramLink.getElement();
EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
int diagramLinkVisualID = BusinessVisualIDRegistry.getVisualID(nextDiagramLink);
for (Iterator modelLinkDescriptors = myLinkDescriptors.iterator(); modelLinkDescriptors.hasNext(); ) {
LinkDescriptor nextLinkDescriptor = (LinkDescriptor) modelLinkDescriptors.next();
if (diagramLinkObject == nextLinkDescriptor.getLinkElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
diagramLinks.remove();
modelLinkDescriptors.remove();
}
}
}
deleteViews(existingLinks.iterator());
return createConnections(myLinkDescriptors);
} finally {
myLinkDescriptors.clear();
myEObject2ViewMap.clear();
}
}
use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.
the class SimulationImageRenderer method highlightElements.
public void highlightElements(final List<? extends EObject> objects, final Diagram diagram) {
AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(TransactionUtil.getEditingDomain(diagram), "", null) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
// Init colors from preferences
RGB rgbForeGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR);
RGB rgbBackGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR);
RGB rgbTransitionActive = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR);
Color color = new Color(Display.getDefault(), rgbForeGround);
Integer foreGround = FigureUtilities.colorToInteger(color);
color.dispose();
color = new Color(Display.getDefault(), rgbBackGround);
Integer background = FigureUtilities.colorToInteger(color);
color.dispose();
color = new Color(Display.getDefault(), rgbTransitionActive);
Integer transitionActive = FigureUtilities.colorToInteger(color);
color.dispose();
// Set styling
TreeIterator<EObject> eAllContents = diagram.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof View) {
for (EObject elementToHighlight : objects) {
EObject element = null;
if (next instanceof Node) {
element = ((Node) next).getElement();
} else if (next instanceof Edge) {
element = ((Edge) next).getElement();
}
if (element == null) {
// next instanceof BasicDecorationNode || next instanceof Shape
continue;
}
if (EcoreUtil.getURI(elementToHighlight).equals(EcoreUtil.getURI(element))) {
if (next instanceof Node) {
ShapeStyle style = (ShapeStyle) ((Node) next).getStyle(NotationPackage.Literals.SHAPE_STYLE);
if (style != null) {
style.setFillColor(background);
style.setLineColor(foreGround);
}
} else if (next instanceof Edge) {
ConnectorStyle style = (ConnectorStyle) ((View) next).getStyle(NotationPackage.Literals.CONNECTOR_STYLE);
if (style != null) {
style.setLineColor(transitionActive);
}
}
}
}
}
}
return CommandResult.newOKCommandResult();
}
};
try {
cmd.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createEntryExitPoints.
@SuppressWarnings("unchecked")
protected void createEntryExitPoints(Diagram subdiagram) {
TreeIterator<EObject> eAllContents = subdiagram.eAllContents();
List<Edge> entryPointsToCreate = new ArrayList<Edge>();
List<Edge> exitPointstoCreate = new ArrayList<Edge>();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof View) {
EList<Edge> targetEdges = ((View) next).getTargetEdges();
for (Edge edge : targetEdges) {
if (!EcoreUtil.isAncestor(subdiagram, edge.getSource()))
entryPointsToCreate.add(edge);
}
EList<Edge> sourceEdges = ((View) next).getSourceEdges();
for (Edge edge : sourceEdges) {
if (!EcoreUtil.isAncestor(subdiagram, edge.getTarget()))
exitPointstoCreate.add(edge);
}
}
}
for (Edge edge : entryPointsToCreate) {
createEntryPoint(edge, subdiagram);
}
for (Edge edge : exitPointstoCreate) {
createExitPoint(edge, subdiagram);
}
}
use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.
the class NotationClipboardOperationHelper method getOverrideChildPasteOperation.
/**
* By default, don't provide any child paste override behaviour.
*
* @return <code>null</code>, always
*/
public OverridePasteChildOperation getOverrideChildPasteOperation(PasteChildOperation overriddenChildPasteOperation) {
if (shouldAllowPaste(overriddenChildPasteOperation)) {
EObject eObject = overriddenChildPasteOperation.getEObject();
if (eObject instanceof org.eclipse.gmf.runtime.notation.Node) {
org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) eObject;
EObject element = node.getElement();
if ((element != null)) {
return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, true);
} else {
return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, false);
}
} else if (eObject instanceof Edge) {
return new ConnectorViewPasteOperation(overriddenChildPasteOperation);
} else if (eObject instanceof Diagram) {
return new DiagramPasteOperation(overriddenChildPasteOperation);
}
}
return null;
}
Aggregations