Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[graphiti-dev] DiagramComposite example

Hi,

I'm working in a couple examples, based on the chess one, and I've run into some issues. First of all, I'm totally unable to show anything in the view. I'm sure I'm missing something obvious, since I just get an empty composite. The relevant code I'm using within the ViewPart is this:

URI diagramURI = URI.createPlatformResourceURI(resource.getFullPath().toString(), true);
IDiagramEditorInput input = new DiagramEditorInput(diagramURI,
"org.eclipse.graphiti.examples.chess.ChessDiagramTypeProvider");

DiagramComposite diagramComposite = new DiagramComposite(this, parent, SWT.BORDER);
diagramComposite.setInput(input);

Please tell me if I have to call some method in DiagramComposite, or I'm just doing something terribly wrong. I've tried createControl, initializeGraphicalViewer, createGraphicalViewer, configureGraphicalViewer, layout, update and anything else I could thought of.

On the other hand, I've also tried putting the composite inside a Dialog. There I've had more troubles, since DiagramComposite expects an IWorkbenchPart, and there's none available. Since it's there only for behavioral concerns, I've successfully passed null to the constructor and checked its use within the architecture, to prevent NPEs. Successfully, that's it, up to the point where I'm presented with an empty composite, just as in the ViewPart. Once somebody (Patrick, Michael) points me the mistake I'm making, I think I'd be able to show a diagram in both a view and a dialog.

Then we should think if we must pass the IWorkbenchPart to the constructor. By doing so, the behavior of the view is pretty much tied to the diagram. This works well if this is a view with just a diagram, but wouldn't play nice with other Controls or the possibility of using it in a Dialog. If we provide two constructors, with and without IWP, or even just a setter (setWorkbenchPart), we could have two possible behaviors: if setted, graphiti is the "owner" of the IWorkbenchPart. We could set the title, the selection provider, the actions... everything. Otherwise, we should suppose that we are not in control, and not even try to do this things, thus playing nice with any other Controls that lay around us. This would also allow for two different diagrams in the same view, since none of them would try to own it.

What do you think?

Regards,
Félix

Back to the top