Search in sources :

Example 1 with ToggleShapeVisibleStateCommand

use of org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand in project jbosstools-hibernate by jbosstools.

the class ShapeShowAction method getCommand.

public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<OrmShape> selectedShape = new ArrayList<OrmShape>();
    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 OrmShape) {
            OrmShape ormShape = (OrmShape) obj;
            if (!ormShape.isVisible()) {
                selectedShape.add(ormShape);
            }
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeVisibleStateCommand(selectedShape, null));
    }
    return cc;
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) ToggleShapeVisibleStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 2 with ToggleShapeVisibleStateCommand

use of org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand in project jbosstools-hibernate by jbosstools.

the class ToggleShapeVisibleStateAction method getCommand.

@SuppressWarnings("unchecked")
public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<OrmShape> selectedShape = new ArrayList<OrmShape>();
    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 OrmShape) {
            selectedShape.add((OrmShape) obj);
        }
    }
    OrmShape 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 OrmShape) {
            primalElement = (OrmShape) obj;
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeVisibleStateCommand(selectedShape, primalElement));
    }
    return cc;
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ToggleShapeVisibleStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 3 with ToggleShapeVisibleStateCommand

use of org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand in project jbosstools-hibernate by jbosstools.

the class ShapeHideAction method getCommand.

public Command getCommand() {
    CompoundCommand cc = new CompoundCommand();
    if (getSelectedObjects().isEmpty()) {
        return cc;
    }
    List<OrmShape> selectedShape = new ArrayList<OrmShape>();
    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 OrmShape) {
            OrmShape ormShape = (OrmShape) obj;
            if (ormShape.isVisible()) {
                selectedShape.add(ormShape);
            }
        }
    }
    if (selectedShape.size() > 0) {
        cc.add(new ToggleShapeVisibleStateCommand(selectedShape, null));
    }
    return cc;
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ArrayList(java.util.ArrayList) ToggleShapeVisibleStateCommand(org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

ArrayList (java.util.ArrayList)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 AbstractTreeEditPart (org.eclipse.gef.editparts.AbstractTreeEditPart)3 ToggleShapeVisibleStateCommand (org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand)3 OrmShape (org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape)3 OrmEditPart (org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart)3 Iterator (java.util.Iterator)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1