2

I'm implementing a GEF editor and am facing the following problem.

There are two types of EditPart: 1) GraphEditPart, 2) NodeEditPart. My editor extends GraphicalEditor, as I'm not needing a palette at all. I use SimpleRootEditPart for the GraphicalViewer.

GraphEditPart has a figure of type Layer, which is layed out with FlowLayout. Its model children are Nodes, which should be displayed according to FlowLayout, i.e., one after the other, with "line breaks" when a node figure (a Label) would move beyond the visible part of the GraphicalViewer. This would be the point where usually the horizontal scrollbar appears. To suppress the scrollbars, I have set layer.setPreferredSize(new Dimension(getViewer().getControl().getSize())). This works well enough, so that when I resize the application window to a smaller size, the editor are gets smaller, and the node figures perform a quasi "line break" a la FlowLayout.

However, if I have a lot of nodes in the graph, I want to display the vertical scrollbar, because as it is now, the nodes just disappear below the bottom end of the screen.

So basically, the behaviour I want to achieve is like that of a text editor, which scrolls down if you just enter enough text (like the WYSIWYG text editor here on stackoverflow)...

I have tried to set the scrollbar visible by calling ((FigureCanvas) getViewer()).getControl.setVerticalScrollbarVisibility(FigureCanvas.AUTOMATIC)), but to no avail.

Baz
  • 36,440
  • 11
  • 68
  • 94
QueNuevo
  • 105
  • 12

1 Answers1

0

I think the problem is that your are using a SimpleRootEditPart, which doesn't support scrolling. Try changing this to ScalableRootEditPart or even ScalableFreeformRootEditPart (that is what I am using). The call you are doing affects the control that contains the edit part, but since GEF manages it's own view, your call has no effect.

vainolo
  • 6,907
  • 4
  • 24
  • 47
  • Isn't scrolling a feature of the `GraphicalViewer`'s `Control`? If I'm correct, the default `Control` for `ScrollingGraphicalViewer` (in turn the default viewer for all GEF editors in the type hierarchy downwards from `Graphical Editor` I think) is `FigureCanvas` (the API docs call it a "scrolling Canvas" anyway). Well, at least FigureCanvas provides static fields for scrollbar visibility. @QueNuevo: vainolo is right in that your call cannot have any effect. Have you tried dynamically calculating the preferred size based on the `Bounds` of the children? Does this have an effect? – s.d May 16 '14 at 00:09
  • I did some digging in the code @s.d , and I think GEF has it's own scrolling mechanism that is not controlled by the Eclipse UI. But I'm a but rusty on eclipse lately so I may be wrong. Anyway, I always use the classes above and scrolling works. – vainolo May 18 '14 at 07:47