Search in sources :

Example 1 with OrmShape

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

the class ShapeShowAction 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 OrmShape) {
            OrmShape ormShape = (OrmShape) obj;
            Object ormElement = ormShape.getOrmElement();
            if (ormElement instanceof IPersistentClass || ormElement instanceof ITable) {
                if (!ormShape.isVisible()) {
                    res = true;
                }
            }
        }
    }
    return res;
}
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) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 2 with OrmShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape 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 3 with OrmShape

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

the class ToggleShapeVisibleStateAction method canPerformAction.

@SuppressWarnings("unchecked")
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 OrmShape) {
            Object ormElement = ((OrmShape) obj).getOrmElement();
            if (ormElement instanceof IPersistentClass || ormElement instanceof ITable) {
                res = true;
            }
        }
    }
    return res;
}
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) Iterator(java.util.Iterator) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 4 with OrmShape

use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape 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 5 with OrmShape

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

the class DeleteGuideCommand method undo.

public void undo() {
    parent.addGuide(guide);
    Iterator<OrmShape> iter = oldParts.keySet().iterator();
    while (iter.hasNext()) {
        OrmShape part = iter.next();
        guide.attachPart(part, oldParts.get(part).intValue());
    }
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape)

Aggregations

OrmShape (org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape)12 AbstractTreeEditPart (org.eclipse.gef.editparts.AbstractTreeEditPart)7 OrmEditPart (org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart)7 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)5 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)5 ArrayList (java.util.ArrayList)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 ToggleShapeVisibleStateCommand (org.jboss.tools.hibernate.ui.diagram.editors.command.ToggleShapeVisibleStateCommand)3 Iterator (java.util.Iterator)2 Point (org.eclipse.draw2d.geometry.Point)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 Command (org.eclipse.gef.commands.Command)1 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 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)1 ChangeGuideCommand (org.jboss.tools.hibernate.ui.diagram.editors.command.ChangeGuideCommand)1 ShapeSetConstraintCommand (org.jboss.tools.hibernate.ui.diagram.editors.command.ShapeSetConstraintCommand)1