Building custom layout managers for Graphiti [message #1735849] |
Thu, 23 June 2016 09:24  |
Eclipse User |
|
|
|
Hello!
I have recently stumbled upon an issue in a tool I have developed about 6 months ago. The tool employed an existing extension point in ELK, at the time, entitled:
<extension
point="org.eclipse.elk.core.service.layoutManagers">
<manager
class="CustomGraphitiLayoutManager ">
</manager>
</extension>
and my implementation:
public class CustomGraphitiLayoutManager extends GraphitiDiagramLayoutManager{
@Override
protected boolean isNodeShape(final Shape shape) {
return true;
}
@Override
protected KNode createNode(final LayoutMapping mapping, final KNode parentNode,
final Shape shape) {
final KNode node = super.createNode(mapping, parentNode, shape);
final KShapeLayout nodeLayout = node.getData(KShapeLayout.class);
nodeLayout.setProperty(LayoutOptions.DIRECTION, Direction.DOWN);
nodeLayout.setProperty(LayoutOptions.LAYOUT_HIERARCHY, true);
return node;
}
}
With the given setup, I get the following issues:
* Unknown extension point: 'org.eclipse.elk.core.layoutManagers' in plugin.xml
* The GraphitiDiagramLayoutManager class no longer exists or has been renamed or moved
* The LayoutOptions no longer exists ( I have managed to fix that by replacing it with CoreOptions, but I am not sure it is the correct solution)
I am basically interested in getting a correct specification for creating and registering a custom graphiti diagram layout manager, within the correct extension point.
The only source I could find seems to not be up to date:
https://www.eclipse.org/elk/getting-started.php
|
|
|
Re: Building custom layout managers for Graphiti [message #1735857 is a reply to message #1735849] |
Thu, 23 June 2016 10:37   |
Eclipse User |
|
|
|
Hi Alex!
The ELK infrastructure has changed quite a bit since we became an Eclipse project. Layout managers are an area that was affected by those changes. But fear not, the fix should be easy.
First, the extension point has been replaced by a new extension point called org.eclipse.elk.core.service.layoutConnectors. The new extension point does not expect you to register a layout manager (or layout connectors, as they are called now), but a class that implements ISetup. That class is basically responsible for providing bindings between interfaces and implementing classes for a dependency injector. In short: this is where you will actually say that your CustomGraphitiLayoutConnector should be used. You can find an example implementation in our default Graphiti layout code.
The transition from layout manager to layout connector should be straightforward. Again, our default implementation may provide some clues.
Finally, the LayoutOptions class has indeed be renamed to CoreOptions for reasons that I would probably bore you with. 
Sorry that the Getting Started Guide mislead you, I didn't get around to updating that yet. However, our GitHub wiki is steadily growing and already contains a lot of documentation. Please let me know if any information are hard to find or hard to understand.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04602 seconds