use of org.eclipse.gmf.runtime.notation.ConnectorStyle 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.ConnectorStyle in project statecharts by Yakindu.
the class SetLabelsOffsetOperation method isEdgeWithObliqueRoutingStyle.
public static boolean isEdgeWithObliqueRoutingStyle(org.eclipse.gef.ConnectionEditPart part) {
Edge edge = (Edge) part.getModel();
ConnectorStyle style = (ConnectorStyle) edge.getStyle(NotationPackage.Literals.CONNECTOR_STYLE);
if (style != null) {
return Routing.MANUAL_LITERAL == style.getRouting();
}
return false;
}
Aggregations