Getting started (GEF + ELK) [message #1794100] |
Thu, 23 August 2018 10:00  |
Eclipse User |
|
|
|
Hello guys and thank your for developing ELK.
I have a GEF project and want ELK to integrate the project so that I can define Layout Algorithms and, more importantly, to define the number and labels for each node inputs/outputs.
However, I'm having difficulties with the "getting started" phase. With that said, can someone please provide me with a link to some GEF/ELK project examples? I'm looking online and I can't seem to find any.
Thank you in advance.
[Updated on: Thu, 23 August 2018 12:47] by Moderator
|
|
|
|
|
|
|
Re: Getting started (GEF + ELK) [message #1794156 is a reply to message #1794136] |
Fri, 24 August 2018 11:12   |
Eclipse User |
|
|
|
I tried for 6 hours and couldn't integrate ELK with GEF. Please help me.
Please provide some really small example of GEF+ELK if possible.
I already have my Module implementing MvcFxModule, so I have no idea of what I need to do to implement a new binding for IDiagramLayoutConnector and ILayoutConfigurationStore.Provider.
This is what I have in my module:
public class MapModule extends MvcFxModule {
@Override
protected void bindIContentPartFactoryAsContentViewerAdapter(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(MapPartsFactory.class);
}
/**
*
* @param adapterMapBinder
*/
protected void bindMapNodePartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// bind anchor provider used to create the connection anchors
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(MapAnchorProvider.class);
// bind a geometry provider, which is used in our anchor provider
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ShapeOutlineProvider.class);
/**
* We need to tell GEF, how to render the hover and selection feedback for our
* parts. We do this by binding two providers to the MapNodePart.
*/
// provides a hover feedback to the shape, used by the HoverBehavior
AdapterKey<?> role = AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_GEOMETRY_PROVIDER);
adapterMapBinder.addBinding(role).to(ShapeOutlineProvider.class);
// provides a selection feedback to the shape
role = AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_FEEDBACK_GEOMETRY_PROVIDER);
adapterMapBinder.addBinding(role).to(ShapeBoundsProvider.class);
// support moving nodes via mouse drag
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformPolicy.class);
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);
// bind create connection handler
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateMapConnectionOnClickHandler.class);
// bind the context menu policy to the part
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ShowMapNodeContextMenuOnClickHandler.class);
}
@Override
protected void configure() {
// start the default configuration
super.configure();
bindMapNodePartAdapters(AdapterMaps.getAdapterMapBinder(binder(), MapNodePart.class));
binder().bind(IDiagramLayoutConnector.class).to(GEFDiagramLayoutConnector.class);
}
@Override
protected void bindAbstractContentPartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindAbstractContentPartAdapters(adapterMapBinder);
// binding the HoverOnHoverPolicy to every part
// if a mouse is moving above a part it is set to the HoverModel
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(HoverOnHoverHandler.class);
// add the focus and select policy to every part, listening to clicks
// and changing the focus and selection model
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(FocusAndSelectOnClickHandler.class);
}
/**
* {@link HoverBehavior} listens to changes in the HoverModel and updates the
* graphical representation. The behaviors for selection and focus are already
* bound in the superclass.
*/
@Override
protected void bindIRootPartAdaptersForContentViewer(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindIRootPartAdaptersForContentViewer(adapterMapBinder);
// support creation of nodes via mouse click
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateMapNodeOnClickHandler.class);
// adding the creation feedback behavior
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateConnectionFeedbackBehavior.class);
}
@Override
protected void bindIViewerAdaptersForContentViewer(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindIViewerAdaptersForContentViewer(adapterMapBinder);
// bind the model to the content viewer
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ItemCreation.class);
// binding the creation feedback part factory using the role that is specified in the behavior
AdapterKey<?> role = AdapterKey.role(CreateConnectionFeedbackBehavior.CREATE_FEEDBACK_PART_FACTORY);
adapterMapBinder.addBinding(role).to(CreateConnectionFeedbackFactory.class);
}
|
|
|
|
|
|
|
Re: Getting started (GEF + ELK) [message #1795081 is a reply to message #1794437] |
Fri, 14 September 2018 03:51  |
Eclipse User |
|
|
|
The injector is not created directly. Instead you register your layout setup with the layoutConnectors extension point.
I've never tried to apply layout to a GEF5 diagram, so I cannot help there. You should ask the GEF developers what is the best way to programmatically set a layout in your diagram.
|
|
|
Powered by
FUDForum. Page generated in 0.07699 seconds