Search in sources :

Example 1 with ExpandableShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape in project jbosstools-hibernate by jbosstools.

the class ShapeCollapseAction method canPerformAction.

private boolean canPerformAction() {
    boolean res = false;
    if (getSelectedObjects().isEmpty()) {
        return res;
    }
    Iterator<?> it = getSelectedObjects().iterator();
    while (it.hasNext() && !res) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof ExpandableShape) {
            ExpandableShape es = (ExpandableShape) obj;
            if (es.isExpanded()) {
                res = true;
            }
        }
    }
    return res;
}
Also used : ExpandableShape(org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart)

Example 2 with ExpandableShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape in project jbosstools-hibernate by jbosstools.

the class ShapeExpandAction method getCommand.

public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
    Iterator<?> it = getSelectedObjects().iterator();
    while (it.hasNext()) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof ExpandableShape) {
            ExpandableShape es = (ExpandableShape) obj;
            if (!es.isExpanded()) {
                selectedShape.add(es);
            }
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeExpandStateCommand(selectedShape, null));
    }
    return cc;
}
Also used : ExpandableShape(org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) ToggleShapeExpandStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeExpandStateCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 3 with ExpandableShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape in project jbosstools-hibernate by jbosstools.

the class ToggleShapeExpandStateCommand method undo.

public void undo() {
    for (int i = 0; i < selectedShape.size(); i++) {
        ExpandableShape shape = selectedShape.get(i);
        shape.setExpanded(selectedShapeStates.get(i));
    }
}
Also used : ExpandableShape(org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape)

Example 4 with ExpandableShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape in project jbosstools-hibernate by jbosstools.

the class ToggleShapeExpandStateAction method getCommand.

public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
    Iterator<?> it = getSelectedObjects().iterator();
    while (it.hasNext()) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof ExpandableShape) {
            selectedShape.add((ExpandableShape) obj);
        }
    }
    ExpandableShape primalElement = null;
    if (getSelection() instanceof IStructuredSelection) {
        Object firstElement = ((IStructuredSelection) getSelection()).getFirstElement();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof ExpandableShape) {
            primalElement = (ExpandableShape) obj;
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeExpandStateCommand(selectedShape, primalElement));
    }
    return cc;
}
Also used : ExpandableShape(org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ToggleShapeExpandStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeExpandStateCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 5 with ExpandableShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape in project jbosstools-hibernate by jbosstools.

the class ShapeCollapseAction method getCommand.

public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<ExpandableShape> selectedShape = new ArrayList<ExpandableShape>();
    Iterator<?> it = getSelectedObjects().iterator();
    while (it.hasNext()) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof ExpandableShape) {
            ExpandableShape es = (ExpandableShape) obj;
            if (es.isExpanded()) {
                selectedShape.add(es);
            }
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeExpandStateCommand(selectedShape, null));
    }
    return cc;
}
Also used : ExpandableShape(org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) ToggleShapeExpandStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeExpandStateCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

ExpandableShape (org.jboss.tools.hibernate.ui.diagram.editors.model.ExpandableShape)7 AbstractTreeEditPart (org.eclipse.gef.editparts.AbstractTreeEditPart)6 OrmEditPart (org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart)6 ArrayList (java.util.ArrayList)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 ToggleShapeExpandStateCommand (org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeExpandStateCommand)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IAction (org.eclipse.jface.action.IAction)1 Separator (org.eclipse.jface.action.Separator)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)1 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)1 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)1 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)1 OrmShape (org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape)1 Shape (org.jboss.tools.hibernate.ui.diagram.editors.model.Shape)1