Using an operation to change the style of elements in my model using an action call/operation [message #1841566] |
Thu, 20 May 2021 15:51  |
Eclipse User |
|
|
|
Hi,
I have an operation that is defined in my metamodel that is accessed via java action call from a popup menu in my model. What I want to do is to be able to change the border of the elements that are returned from my operation. Not sure if it would be better to be done in the java action or the operation, or for that matter how to actually change the style of the elements using java. Any help or suggestions?
[Updated on: Fri, 21 May 2021 09:24] by Moderator
|
|
|
|
|
|
|
|
|
|
Re: Using an operation to change the style of elements in my model using an action call/operation [message #1841904 is a reply to message #1841785] |
Wed, 02 June 2021 12:59  |
Eclipse User |
|
|
|
I figured out a workaround for the issue of there being multiples of the same element within a set. Still not sure why it was happening but it's working well enough now.
I do have another follow-up question now however. For my editor I can create multiple viewpoints of the same semantic model. All of these viewpoints are unsynchronized so that the user can then drag and drop the specific elements that they want to use, edit, and manipulate without having to navigate the whole model. My issue now is when I try to change the border color of the nodes. Since the viewpoints are all unsynchronized I assumed that the border changes would happen locally within the viewpoint where the method is being called. But for whatever reason when the method is called it changes the color randomly throughout all the viewpoints and sometimes won't change the color at all. And then when I try a containerStyle.getBordercolor() returns that the RGB values have been changed despite not showing up in my model. Any idea about how to resolve this to get the changes to happen locally to the viewpoint and not randomly throughout the model?
This is the code that I came up with to change the color recursively throughout my model based on the element that I want:
public void forwardImpactAnalysis() {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
EList<? extends Input> inputs = this.getInput();
Iterator<? extends Input> itInput = inputs.iterator();
while (itInput.hasNext()) {
Input nextInput = itInput.next();
EList<? extends Output> outputs = nextInput.getTgt().getOutput();
Iterator<? extends Output> itOutput = outputs.iterator();
while (itOutput.hasNext()) {
Data dataOutput = (Data) itOutput.next().getTgt();
//This line will return the same element that is put in, but instead of as an ecore class it will be of a sirius class that will allow for the manipulation of the concrete syntax in the model instance.
Set<? extends DSemanticDecorator> result = (Set<? extends DSemanticDecorator>) new EObjectQuery(
dataOutput).getInverseReferences(ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET);
DDiagramElementContainer myContainer = (DDiagramElementContainer) result.iterator().next();
ContainerStyle containerStyle = myContainer.getOwnedStyle();
RGBValues newBorderColor = RGBValues.create(255, 0, 0);
containerStyle.setBorderColor(newBorderColor);
containerStyle.getCustomFeatures().add(DiagramPackage.Literals.BORDERED_STYLE__BORDER_COLOR.getName());
dataOutput.forwardImpactAnalysis();
}
}
//throw new UnsupportedOperationException();
}
|
|
|
Powered by
FUDForum. Page generated in 0.05146 seconds