Saving style changes [message #1456694] |
Thu, 30 October 2014 16:28 |
Koen Staal Messages: 70 Registered: October 2014 |
Member |
|
|
When double clicking on a bordered node i want to "highlight" connected edges by changing the color and width. However it doesnt get saved. Everytime i double click the node the property red of strokelayout is 0 again.
Any suggestions?
private void showEdgeConnections(DNodeSpec nodeSpec){
System.out.println(nodeSpec.getIncomingEdges().get(0).getOwnedStyle().getStrokeColor().getRed());
for (DEdge dEdge : nodeSpec.getIncomingEdges()) {
changeColor(dEdge);
}
for (DEdge dEdge : nodeSpec.getOutgoingEdges()) {
changeColor(dEdge);
}
System.out.println(nodeSpec.getIncomingEdges().get(0).getOwnedStyle().getStrokeColor().getRed());
}
private void changeColor(DEdge dEdge) {
EdgeStyle style = dEdge.getOwnedStyle();
style.setSize(5);
RGBValues lineColor = style.getStrokeColor();
lineColor.setRed(255);
lineColor.setBlue(0);
lineColor.setGreen(0);
style.setStrokeColor(lineColor);
dEdge.setOwnedStyle(style);
}
[Updated on: Fri, 31 October 2014 07:20] Report message to a moderator
|
|
|
Re: Saving style changes [message #1457365 is a reply to message #1456694] |
Fri, 31 October 2014 08:48 |
|
Le 30/10/2014 17:28, Koen Staal a écrit :
> When double clicking on a bordered node i want to "highlight" connected
> edges by changing the color and width. However it doesnt get saved.
> Everytime i double click the node the property red of strokelayout is 0
> again.
> Any suggestions?
This is because by default when the representation is refreshed Sirius
re-applies all the style attributes as they are defined in the mapping
from the VSM. This is what you want as the default behavior (and part of
what allows instant feedback when you edit the VSM in the workspace).
You can disable this by marking the features your code changes as
"customized", so that the next refresh will keep these as you set them,
and will not overwrite them with the values from the VSM.
To do this you need to add code like this:
style.getCustomFeatures().add(DiagramPackage.Literals.EDGE_STYLE__SIZE.getName());
style.getCustomFeatures().add(DiagramPackage.Literals.EDGE_STYLE__STROKE_COLOR.getName());
The "customFeatures" stores the names of the EStructuralFeatures of the
style which have been explicitly customized and are left alone by the
refresh.
--
Pierre-Charles David - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.03955 seconds