Search in sources :

Example 1 with LayoutManager

use of org.openlca.app.editors.graphical.layout.LayoutManager in project olca-app by GreenDelta.

the class GraphEditor method initializeGraphicalViewer.

@Override
protected void initializeGraphicalViewer() {
    var viewer = getGraphicalViewer();
    viewer.setRootEditPart(new ScalableRootEditPart() {

        @Override
        protected LayeredPane createPrintableLayers() {
            var pane = new LayeredPane();
            var models = new Layer();
            models.setOpaque(false);
            models.setLayoutManager(new StackLayout());
            pane.add(models, PRIMARY_LAYER);
            // add the connection layer on top of the
            // model layer
            var connections = new ConnectionLayer();
            connections.setPreferredSize(new Dimension(5, 5));
            pane.add(connections, CONNECTION_LAYER);
            return pane;
        }
    });
    GraphDropListener.on(this);
    viewer.getEditDomain().setActiveTool(new PanningSelectionTool());
    viewer.setContents(model);
    var zoom = getZoomManager();
    zoom.setZoomLevels(ZOOM_LEVELS);
    zoom.setZoomAnimationStyle(ZoomManager.ANIMATE_ZOOM_IN_OUT);
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON);
    // load the graph settings
    var fileApplied = GraphFile.apply(this);
    if (!fileApplied) {
        // no saved settings applied =>
        // try to find a good configuration
        var system = systemEditor.getModel();
        if (system.referenceProcess != null) {
            var refNode = model.getProcessNode(system.referenceProcess.id);
            if (refNode != null) {
                refNode.expandLeft();
                refNode.expandRight();
            }
        }
        // initialize the tree layout
        if (model != null && model.figure != null) {
            var layout = model.figure.getLayoutManager();
            if (layout instanceof LayoutManager) {
                ((LayoutManager) layout).layout(model.figure, LayoutType.TREE_LAYOUT);
            }
        }
    }
}
Also used : LayoutManager(org.openlca.app.editors.graphical.layout.LayoutManager) LayeredPane(org.eclipse.draw2d.LayeredPane) ScalableRootEditPart(org.eclipse.gef.editparts.ScalableRootEditPart) StackLayout(org.eclipse.draw2d.StackLayout) PanningSelectionTool(org.eclipse.gef.tools.PanningSelectionTool) Dimension(org.eclipse.draw2d.geometry.Dimension) Layer(org.eclipse.draw2d.Layer) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer)

Example 2 with LayoutManager

use of org.openlca.app.editors.graphical.layout.LayoutManager in project olca-app by GreenDelta.

the class ProductSystemPart method createEditPolicies.

@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new LayoutPolicy());
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() {
    });
    LayoutManager manager = new LayoutManager(getModel());
    getFigure().setLayoutManager(manager);
}
Also used : ComponentEditPolicy(org.eclipse.gef.editpolicies.ComponentEditPolicy) LayoutManager(org.openlca.app.editors.graphical.layout.LayoutManager) LayoutPolicy(org.openlca.app.editors.graphical.policy.LayoutPolicy)

Example 3 with LayoutManager

use of org.openlca.app.editors.graphical.layout.LayoutManager in project olca-app by GreenDelta.

the class MassCreationCommand method execute.

@Override
public void execute() {
    for (RootDescriptor process : toCreate) addNode(process);
    for (ProcessLink newLink : newLinks) link(newLink);
    for (ProcessNode node : sysNode.getChildren()) if (node.figure.isVisible())
        oldConstraints.put(node.figure, node.figure.getBounds().getCopy());
    ((LayoutManager) sysNode.figure.getLayoutManager()).layout(sysNode.figure, sysNode.editor.getLayoutType());
    sysNode.editor.setDirty();
    if (sysNode.editor.getOutline() != null)
        sysNode.editor.getOutline().refresh();
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) LayoutManager(org.openlca.app.editors.graphical.layout.LayoutManager) ProcessNode(org.openlca.app.editors.graphical.model.ProcessNode) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Aggregations

LayoutManager (org.openlca.app.editors.graphical.layout.LayoutManager)3 ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)1 Layer (org.eclipse.draw2d.Layer)1 LayeredPane (org.eclipse.draw2d.LayeredPane)1 StackLayout (org.eclipse.draw2d.StackLayout)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 ScalableRootEditPart (org.eclipse.gef.editparts.ScalableRootEditPart)1 ComponentEditPolicy (org.eclipse.gef.editpolicies.ComponentEditPolicy)1 PanningSelectionTool (org.eclipse.gef.tools.PanningSelectionTool)1 ProcessNode (org.openlca.app.editors.graphical.model.ProcessNode)1 LayoutPolicy (org.openlca.app.editors.graphical.policy.LayoutPolicy)1 ProcessLink (org.openlca.core.model.ProcessLink)1 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)1