Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » View dependency tree during debugging - Is Graphiti the right tool?
icon5.gif  View dependency tree during debugging - Is Graphiti the right tool? [message #1236210] Sun, 26 January 2014 15:38 Go to next message
Michael H. is currently offline Michael H.Friend
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 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
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 #1237008 is a reply to message #1236716] Tue, 28 January 2014 16:00 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Michael,

>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.

Not sure where that submenu comes from, input methods seems not to be
related to Graphiti. Have you installed any other plugins to your Eclipse
that might add this?

>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. It seems that is all
you want to achieve for now...

Michael
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1237018 is a reply to message #1237008] Tue, 28 January 2014 16:25 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
Thanks for Your reply and thanks for telling me, that I am on the right way.

Michael Wenz wrote on Tue, 28 January 2014 17:00
>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.

Not sure where that submenu comes from, input methods seems not to be
related to Graphiti. Have you installed any other plugins to your Eclipse
that might add this?

I found something in this forum at http://www.eclipse.org/forums/index.php/mv/msg/77471/241233/#msg_241233. It is a Linux issue throughout the whole platform.
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 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
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 #1237816 is a reply to message #1236210] Thu, 30 January 2014 17:19 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I am not sure if its possible like this?
If I want to add sth to my diagram I do it like this:

AddContext addContext = new AddContext();
addContext.setNewObject(eObj);
addContext.setLocation(x, y);	
addContext.setTargetContainer((ContainerShape) targetContainer);
		
IAddFeature addFeature = fp.getAddFeature(addContext);
if (addFeature.canAdd(addContext)) {
    addFeature.add(addContext);
}


Maybe it works that way...
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1237867 is a reply to message #1237816] Thu, 30 January 2014 20:23 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
OK, I think I understood.
I need to use the features to get all the things done. I will try it this way.
I thought I can create the diagram completely from scratch, which seems to be wrong.
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 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
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 Go to previous messageGo to next message
Soeren M is currently offline Soeren MFriend
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 #1239165 is a reply to message #1238941] Mon, 03 February 2014 14:38 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
Thanks for Your answer, but actually this seems to set the background color of the whole diagram, not for the reactangle, which is also not understandable to me.

Does someone know, what is going on there?
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1239207 is a reply to message #1239165] Mon, 03 February 2014 16:40 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
For testing the procedure I created a simple add feature like in the tutorial, created a diagram of this type via the wizard and created a Variable from the palette. This is working fine as expected. So from general editor point of view it seems to be working.

But obviously creating a in memory diagram from scratch seems to cause problems. Do I need to working with the EMF utilities like editing domain, resource sets, etc.? If so, can someone explain to me, what I need to do, because I do not have any idea about these mechanism.
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1240446 is a reply to message #1239207] Thu, 06 February 2014 13:32 Go to previous messageGo to next message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
Hi all,

can someone give me any hint, what I need to do?
I debugged forward and backward, but was not able to find a solution.

Thanks for Your help in advance
Michael
Re: View dependency tree during debugging - Is Graphiti the right tool? [message #1241156 is a reply to message #1240446] Fri, 07 February 2014 15:04 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Michael,

not sure what exactly you are trying to do...

Working in memory should not be the problem here, at least that's what the
editor does as long as it is not saved. You 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.

Not sure if that is what you targeted with your last question if if it
helps...

Michael
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 Go to previous message
Michael H. is currently offline Michael H.Friend
Messages: 13
Registered: July 2009
Junior Member
Michael Wenz wrote on Fri, 07 February 2014 16:04
You 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

Previous Topic:How to perform mouse hover in and out in graphiti elements
Next Topic:Connection without Bussiness Object to display a Reference?
Goto Forum:
  


Current Time: Tue Apr 16 13:44:36 GMT 2024

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

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

Back to the top