Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Problem to modify diagram element in Java Class (Change the path of an image as container node style.)
icon8.gif  Problem to modify diagram element in Java Class [message #1499561] Fri, 05 December 2014 08:18 Go to next message
Didier Cormier is currently offline Didier CormierFriend
Messages: 6
Registered: October 2014
Junior Member
Hi all,

I create a representation (graph) in a Java External Class. The representation has a NodeContainer with a WorkspaceImage style.

For the creation of the new diagram I'm using:
DRepresentation newrepresentation = DialectManager.INSTANCE
.createRepresentation(myDiagramName, myObject ,description, session, new NullProgressMonitor());

After creation, I try to change the path of the image used for the node container
List<DDiagramElement> contents =((DSemanticDiagram)newrepresentation).getDiagramElements();
ListIterator<DDiagramElement> elts = contents.listIterator();

while (elts.hasNext()) {
DDiagramElement elt = elts.next();
if (elt instanceof DNodeContainer) {
Style style = elt.getStyle();
if ( style instanceof WorkspaceImage ) {
// try to modify the path of Image used by ContainerNode
((WorkspaceImage)style).setWorkspacePath( myNewPath );
}
}
}
DialectUIManager.INSTANCE.openEditor(session, newrepresentation, new NullProgressMonitor());

In debug mode, the new path is well modified but in the diagram opened : the node use the default path (not the path I try to dynamicaly inject)

If someone has a solution ?

[Updated on: Fri, 05 December 2014 09:17]

Report message to a moderator

Re: Problem to modify diagram element in Java Class [message #1500065 is a reply to message #1499561] Fri, 05 December 2014 17:02 Go to previous messageGo to next message
Philippe Dul is currently offline Philippe DulFriend
Messages: 25
Registered: November 2013
Junior Member
Hi,

Its because you have customized the image path programmatically.
By default, when a diagram is refreshed, Sirius will re-apply all the style attributes as they are defined in the VSM (odesign file) . To let Sirius do what you want, you have to specify that the path has been customized for all your containers.

while (elts.hasNext()) {
  DDiagramElement elt = elts.next();
  if (elt instanceof DNodeContainer) {
  Style style = elt.getStyle();
  if ( style instanceof WorkspaceImage ) {
    WorkspaceImage wstyle = (WorkspaceImage)style;
    wstyle.setWorkspacePath( myNewPath );
    wstyle.getCustomFeatures().add(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName());
  }
}

Re: Problem to modify diagram element in Java Class [message #1503171 is a reply to message #1500065] Mon, 08 December 2014 08:14 Go to previous message
Didier Cormier is currently offline Didier CormierFriend
Messages: 6
Registered: October 2014
Junior Member
Hi,

thank you for your solution : it's work.
Previous Topic:Using pre-defined types in Sirius
Next Topic:error icon on file not visible
Goto Forum:
  


Current Time: Fri Mar 29 07:46:29 GMT 2024

Powered by FUDForum. Page generated in 0.07095 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top