Create diagram with elements within [message #683505] |
Mon, 13 June 2011 22:12 |
Filipe Araujo Messages: 4 Registered: June 2011 |
Junior Member |
|
|
Hi,
I want to create a diagram with 3 pictograms elements by default, i'm trying this in a class that extends AbstractDrillDownFeature and in the method execute:
//run diagram
super.execute(context);
//try to insert the elements
CreateContext test = new CreateContext();
Diagram diag = getDiagram();
test.setTargetContainer(diag);
int res = 10;
for (FlowElement subFlowElement : subprocess.getFlowElements())
{
teste.setLocation(res, res);
teste.setSize(-1, -1);
res = res+40;
diag.eResource().getContents().add(subFlowElement);
link(container, subFlowElement);
addGraphicalRepresentation(teste, subFlowElement);
}
I initialized the flowelements (setnextid(), setname()) before the execute call. I've try also something like this but with no result:
// provide information to support direct-editing directly
// after object creation (must be activated additionally)
final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
// set container shape for direct editing after object creation
directEditingInfo.setMainPictogramElement(containerShape);
// set shape and graphics algorithm where the editor for
// direct editing shall be opened after object creation
directEditingInfo.setPictogramElement(shape);
directEditingInfo.setGraphicsAlgorithm(text);
Thank you very much i would appreciate any help.
Filipe Araújo
[Updated on: Mon, 13 June 2011 23:16] Report message to a moderator
|
|
|
Re: New diagram with elements within [message #683691 is a reply to message #683505] |
Tue, 14 June 2011 08:50 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
I assume you would like to create a new Diagram and create the new elements
in there? What you do with the coding below is adding the stuff to the
current diagram (getDiagram returns the currently opened diagram). Besides
the concrete location inside the diagram is missing.
You might want to take a look into the classes
CreateDiagramWithAllClassesHandler and AddAllClassesCommand in the Graphiti
tutorial; they create a new diagram and add stuff to it (actually they do it
from the explorer, but this should very similarly also be possible from
within a feature).
HTH,
Michael
"Filipe Araujo" schrieb im Newsbeitrag
news:it61fi$vqf$1@news.eclipse.org...
Hi,
I want to create a diagram with 3 pictograms elements by default, i'm
trying this in the override of execute of the class
AbstractDrillDownFeature:
//run diagram
super.execute(context);
//try to insert the elements
CreateContext test = new CreateContext();
Diagram diag = getDiagram();
test.setTargetContainer(diag);
int res = 10;
for (FlowElement subFlowElement : subprocess.getFlowElements())
{
teste.setLocation(res, res);
teste.setSize(-1, -1);
res = res+40;
diag.eResource().getContents().add(subFlowElement);
link(container, subFlowElement);
addGraphicalRepresentation(teste, subFlowElement);
}
I initialized the flowelements (setnextid(), setname()) before the execute
call. I've try also something like this but with no result:
// provide information to support direct-editing directly
// after object creation (must be activated additionally)
final IDirectEditingInfo directEditingInfo =
getFeatureProvider().getDirectEditingInfo();
// set container shape for direct editing after object creation
directEditingInfo.setMainPictogramElement(containerShape);
// set shape and graphics algorithm where the editor for
// direct editing shall be opened after object creation
directEditingInfo.setPictogramElement(shape);
directEditingInfo.setGraphicsAlgorithm(text);
Thank you very much i would appreciate any help.
Filipe Araújo
|
|
|
|
|
Re: New diagram with elements within [message #684376 is a reply to message #684326] |
Wed, 15 June 2011 14:02 |
Filipe Araujo Messages: 4 Registered: June 2011 |
Junior Member |
|
|
I don't understand how can i insert the graphical shape of the elements, i.e, i created the method getDiagrams(), getNewDiagram(), getExistingDiagram() like the tutorial, after super.execute(context) the diagram opens then I write something like this:
CreateContext teste = new CreateContext();
Diagram diag = getDiagrams().iterator().next();
teste.setTargetContainer(diag);
int res = 10;
for (FlowElement subFlowElement : subprocess.getFlowElements())
{
teste.setLocation(res, res);
teste.setSize(-1, -1);
res = res+40;
diag.eResource().getContents().add(subFlowElement);
addGraphicalRepresentation(teste, subFlowElement);
}
the diagram is recognized in getDiagrams() but when I call addGraphical.. the shapes don't appear. How can I get the active diagram?
getDiagram() gives me the diagram parent.
Like I said before I want to create the elements when I expand to a sub-workflow, with a class that extends AbstractDrillDownFeature.
[Updated on: Wed, 15 June 2011 14:06] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03283 seconds