Search in sources :

Example 1 with RulerEditPartFactory

use of org.eclipse.gef.internal.ui.rulers.RulerEditPartFactory in project archi by archimatetool.

the class RulerComposite method createRulerContainer.

private GraphicalViewer createRulerContainer(int orientation) {
    ScrollingGraphicalViewer viewer = new RulerViewer();
    final boolean isHorizontal = orientation == PositionConstants.NORTH || orientation == PositionConstants.SOUTH;
    // Finish initializing the viewer
    viewer.setRootEditPart(new RulerRootEditPart(isHorizontal));
    viewer.setEditPartFactory(new RulerEditPartFactory(diagramViewer));
    viewer.createControl(this);
    ((GraphicalEditPart) viewer.getRootEditPart()).getFigure().setBorder(new RulerBorder(isHorizontal));
    viewer.setProperty(GraphicalViewer.class.toString(), diagramViewer);
    // Configure the viewer's control
    FigureCanvas canvas = (FigureCanvas) viewer.getControl();
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    if (font == null) {
        FontData[] data = canvas.getFont().getFontData();
        for (int i = 0; i < data.length; i++) {
            data[i].setHeight(data[i].getHeight() - 1);
        }
        font = new Font(Display.getCurrent(), data);
    }
    canvas.setFont(font);
    if (isHorizontal) {
        canvas.getViewport().setHorizontalRangeModel(editor.getViewport().getHorizontalRangeModel());
    } else {
        canvas.getViewport().setVerticalRangeModel(editor.getViewport().getVerticalRangeModel());
    }
    // Add the viewer to the rulerEditDomain
    if (rulerEditDomain == null) {
        rulerEditDomain = new EditDomain();
        rulerEditDomain.setCommandStack(diagramViewer.getEditDomain().getCommandStack());
    }
    rulerEditDomain.addViewer(viewer);
    return viewer;
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) GraphicalViewer(org.eclipse.gef.GraphicalViewer) EditDomain(org.eclipse.gef.EditDomain) FontData(org.eclipse.swt.graphics.FontData) RulerRootEditPart(org.eclipse.gef.internal.ui.rulers.RulerRootEditPart) Font(org.eclipse.swt.graphics.Font) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) FigureCanvas(org.eclipse.draw2d.FigureCanvas) RulerEditPartFactory(org.eclipse.gef.internal.ui.rulers.RulerEditPartFactory)

Aggregations

FigureCanvas (org.eclipse.draw2d.FigureCanvas)1 EditDomain (org.eclipse.gef.EditDomain)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 RulerEditPartFactory (org.eclipse.gef.internal.ui.rulers.RulerEditPartFactory)1 RulerRootEditPart (org.eclipse.gef.internal.ui.rulers.RulerRootEditPart)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1