Home » Modeling » Graphiti » View dependency tree during debugging - Is Graphiti the right tool?
View dependency tree during debugging - Is Graphiti the right tool? [message #1236210] |
Sun, 26 January 2014 15:38 |
Michael H. Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Hello,
I am absolutely new to Eclipse plugin development, but I now got a task to implement some functionality in Eclipse and I came across Graphiti, which looks like the right tool for implementation.
So here is the task: During debugging there should be a view, which shows the dependency tree of some special objects and which is updated when stepping through the source code.
I head a look into Zest and it looked right for this task, because it is for graph visualization. But a future implementation step could be to detach the dependency graph from the running debugger into a standalone graph and offer functionality to modify the graph. SO I would need some graph editing functionality, which Zest is not usable for. So I came across Graphiti for the editing part.
So my ideas for implementation within Graphiti are now as following:
- Create a POJO domain model for the graph.
- Implement the visualization for the model.
- When the debugger reaches a breakpoint, the domain model is created/updated and shown in a view.
- Do not implement any editing features or persistence, because it is not needed in the first step.
Can someone here in the community tell me, if this is feasible? Is there anything that I overlooked, which might be a no-go? Can I use the Graphiti framework without using persistence?
Thanks for Your toughts in advance
Michael
|
|
|
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1236716 is a reply to message #1236210] |
Mon, 27 January 2014 23:13 |
Michael H. Messages: 13 Registered: July 2009 |
Junior Member |
|
|
As there are a huge number of views on this topic but no reply so far, I try to answer my questions with my current knowledge.
Can someone here in the community tell me, if this is feasible?
Yes, I think it is feasible, when I work around some of the default features.
Is there anything that I overlooked, which might be a no-go?
So far, I did not find any no-go.
Can I use the Graphiti framework without using persistence?
Yes, it works.
But now I have some additional, more concrete and implementation-related questions, which I hope to get some feedback here.
I use the DiagramComposite class for rendering the graph in a ViewPart object. I set a dummy URI as the editor input
public void createPartControl(final Composite parent) {
diagramComposite = new DiagramComposite(this, parent, SWT.NONE);
diagramComposite.setLayout(new FillLayout());
diagramComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
diagramComposite.setInput(new DiagramEditorInput(URI.createURI(""), DiagramTypeProvider.PROVIDER_ID)); //$NON-NLS-1$
}
and let my PersistencyBehaviour class return an empty diagram
public class CustomPersistencyBehavior extends DefaultPersistencyBehavior {
public CustomPersistencyBehavior(final CustomDiagramBehavior db) {
super(db);
}
@Override
public Diagram loadDiagram(final URI uri) {
return Graphiti.getPeService().createDiagram(DiagramTypeProvider.TYPE_ID, "Title", true); //$NON-NLS-1$
}
}
Q1: In the context menu of the graph I reduced the entries to "Export Diagrams..." and the submenu "Input Methods". How can I remove the submenu? I was not able to figure it out so far.
Q2: For my understanding I can take the empty diagram and fill it by programmatically creating all the shapes of my dependency tree (like shown in the AddFeatures of the examples). Am I right with this and is this all I need to do?
Thank You again in advance
|
|
| | |
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1237696 is a reply to message #1237008] |
Thu, 30 January 2014 11:02 |
Michael H. Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Michael Wenz wrote on Tue, 28 January 2014 17:00>Q2: For my understanding I can take the empty diagram and fill it by
>programmatically creating all the shapes of my dependency tree (like shown
>in
>the AddFeatures of the examples). Am I right with this and is this all I
>need to do?
I guess yes, after adding the shapes to the diagram and opening the editor
(or refreshing an open editor) the shapes will appear.
I am stuck in this task. I do not get anything drawn in the diagram so far.
I have the following method, which should draw a shape with the name of the variable. The diagram is initially empty:
public void setVariable(final IVariable var) {
try {
final Diagram d = diagramComposite.getDiagramTypeProvider().getDiagram();
{
final IColorConstant CLASS_TEXT_FOREGROUND = new ColorConstant(51, 51, 153);
final IPeService pe = Graphiti.getPeService();
final IGaService ga = Graphiti.getGaService();
// create shape for text
final Shape shape = pe.createShape(d, false);
// create and set text graphics algorithm
final Text text = ga.createDefaultText(d, shape, var.getName());
text.setForeground(ga.manageColor(d, CLASS_TEXT_FOREGROUND));
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
final Font textFont = text.getFont();
final Font managedFont = ga.manageFont(d, textFont.getName(), textFont.getSize(), textFont.isItalic(), true);
text.setFont(managedFont);
ga.setLocationAndSize(text, 10, 10, 150, 20);
// create link and wire it
diagramComposite.getDiagramTypeProvider().getFeatureProvider().link(shape, new Object());
}
diagramComposite.getDiagramBehavior().getRefreshBehavior().refresh();
}
catch (final Exception e) {
throw new RuntimeException(e);
}
}
Can someone see, what I am doing wrong here?
|
|
| | |
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1238639 is a reply to message #1236210] |
Sun, 02 February 2014 00:18 |
Michael H. Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Sorry, I again need to ask You for help. I am getting mad in the meanwhile, because I do not get my simple example to work.
What should happen: I have a view called "DependencyTreeView". When debugging a Java Application, You can select a variable in the Variable-View and get an entry in the context menu called "Open Dependency Tree". This opens the "DependencyTreeView" and calls the method "setVariable", which should paint a shape in the diagram with the name of the select variable.
What happens:The view is shown, but it is always empty.
I am not able to find out what I am doing wrong. Therefore I attach the whole plugin project and hope somebody takes the challenge to tell me, what I need to change.
public void setVariable(final IVariable var) {
try {
final Diagram d = diagramComposite.getDiagramTypeProvider().getDiagram();
final IFeatureProvider fp = diagramComposite.getDiagramTypeProvider().getFeatureProvider();
final Variable addedClass = new Variable(var.getName());
// Create the context information
final AddContext addContext = new AddContext();
addContext.setNewObject(addedClass);
addContext.setTargetContainer(d);
addContext.setX(20);
addContext.setY(20);
final IAddFeature addFeature = fp.getAddFeature(addContext);
if (addFeature.canAdd(addContext)) {
addFeature.add(addContext);
}
diagramComposite.redraw();
// diagramComposite.getDiagramBehavior().refresh();
}
catch (final Exception e) {
throw new RuntimeException(e);
}
}
For the AddVariableFeature I reused the code from the "TutorialAddEClassFeature", which has the name of the selected variable written as text.
In addition I have a PersistencyBehaviour, which returns an empty diagram and does not save anything, because everything is hold in memory:
public class CustomPersistencyBehavior extends DefaultPersistencyBehavior {
public CustomPersistencyBehavior(final CustomDiagramBehavior db) {
super(db);
}
@Override
public void saveDiagram(final IProgressMonitor monitor) {
// do nothing
}
@Override
public Diagram loadDiagram(final URI uri) {
return Graphiti.getPeService().createDiagram(CustomTypeProvider.TYPE_ID, "Dependency Tree", true); //$NON-NLS-1$
}
}
[Updated on: Sun, 02 February 2014 00:35] Report message to a moderator
|
|
|
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1238941 is a reply to message #1236210] |
Sun, 02 February 2014 23:39 |
Soeren M Messages: 77 Registered: September 2011 |
Member |
|
|
I dont know if u know it, but the Variables were added.
And I think I know why you are not able to see them, but I cant fix it.
I think the view is too small or sth makes the variables too big.
If u add the following to it, you will know what I mean:
RoundedRectangle roundedRectangle; // need to access it later
final IGaService gaService = Graphiti.getGaService();
// create and set graphics algorithm
roundedRectangle = gaService.createRoundedRectangle(d, 5, 5);
roundedRectangle.setForeground(Graphiti.getGaService().manageColor(d, new ColorConstant(255, 0, 0)));
roundedRectangle.setBackground(Graphiti.getGaService().manageColor(d, new ColorConstant(255, 0, 0)));
roundedRectangle.setLineWidth(2);
gaService.setLocationAndSize(roundedRectangle, 10, 10, 100, 50);
everything will turn red, so it is visible, but just too big.
I hope you can fix it.
|
|
| | | | |
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1241214 is a reply to message #1241156] |
Fri, 07 February 2014 16:36 |
Michael H. Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Michael Wenz wrote on Fri, 07 February 2014 16:04You will have to create the diagram elements as children of the diagram and the resource the editor is working
on. And this will mean you have to use its editing domain, resource set and
wrap changes into transactions.
Dear Michael, thanks for Your answer. I would b very glad if You could have a look into the attached plugin project.
Basically I have the action class ShowDependencyTree, which is an action on a selected variable in the debug view after reaching a breakpoint. It activates the View (not the editor!), which contains the DiagramComposite, and calls the method setVariable():
public void setVariable(final IVariable var) {
try {
final Diagram d = diagramComposite.getDiagramTypeProvider().getDiagram();
final IFeatureProvider fp = diagramComposite.getDiagramTypeProvider().getFeatureProvider();
final Variable addedClass = new Variable(var.getName());
// Create the context information
final AddContext addContext = new AddContext();
addContext.setNewObject(addedClass);
addContext.setTargetContainer(d);
addContext.setX(20);
addContext.setY(20);
final IAddFeature addFeature = fp.getAddFeature(addContext);
if (addFeature.canAdd(addContext)) {
addFeature.add(addContext);
}
diagramComposite.getDiagramBehavior().refresh();
}
catch (final Exception e) {
throw new RuntimeException(e);
}
}
This method reuses the AddFeature to add a shape. In general this works, when using a editor. For testing I created a diagram with the wizard and was able to use the CreateFeature in the editor, which worked just fine.
I debugged up and down, but I was not able to find the root cause, why it is not working as I expected it. I do not have an editor, but the DiagramComposite, and I do not know how to correctly retrieve the resource, editing domain, resource set and transaction.
[Updated on: Fri, 07 February 2014 16:37] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Sep 22 16:02:37 GMT 2024
Powered by FUDForum. Page generated in 0.06737 seconds
|