How initially scroll when editor opens? [message #1005021] |
Thu, 24 January 2013 10:33 |
|
I'm developing an GEF-based editor.
It displays a diagram with a timeline and I would like to have it "scrolled" to a position corresponding to today's date when the editor opens.
I've implemented an action that scrolls the diagram but can someone help me figure out where this can be done when the editor is opened?
The "go to today" action basically does:
int todayOffset = getOffsetFromStart();
FigureCanvas canvas = (FigureCanvas) ppEditor.getGraphicalViewer().getControl();
canvas.scrollToX(todayOffset);
Thanks,
--Fredrik
|
|
|
|
Re: How initially scroll when editor opens? [message #1007356 is a reply to message #1005449] |
Tue, 05 February 2013 15:40 |
|
Tried this without success. Seems to be too early somehow.
For a simpler example I tried it with the Shapes example and got the same problem:
It only scrolls a little bit.
Any ideas on what is wrong?
In the ShapesEditor:
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new ShapesEditPartFactory());
viewer.setRootEditPart(new MyScalableFreeformRootEditPart());
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
and then the new "RootEditPart":
public class MyScalableFreeformRootEditPart extends
ScalableFreeformRootEditPart {
@Override
public void setContents(EditPart editpart) {
super.setContents(editpart);
scrollToStart(editpart);
}
/**
* @param programPlan
*
*/
private void scrollToStart(EditPart editpart) {
FigureCanvas canvas = (FigureCanvas) editpart.getViewer().getControl();
int theOffset = 80;
canvas.scrollToX(theOffset);
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03689 seconds