use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape in project jbosstools-hibernate by jbosstools.
the class MoveGuideCommand method undo.
public void undo() {
guide.setPosition(guide.getPosition() - pDelta);
Iterator<OrmShape> iter = guide.getParts().iterator();
while (iter.hasNext()) {
OrmShape part = (OrmShape) iter.next();
Point location = part.getLocation().getCopy();
if (guide.isHorizontal()) {
location.y -= pDelta;
} else {
location.x -= pDelta;
}
part.setLocation(location);
}
}
use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape in project jbosstools-hibernate by jbosstools.
the class ShapesXYLayoutEditPolicy method createChangeConstraintCommand.
/**
* @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart, java.lang.Object)
*/
protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) {
if (!(child instanceof OrmShapeEditPart && constraint instanceof Rectangle)) {
return super.createChangeConstraintCommand(request, child, constraint);
}
OrmShape part = (OrmShape) child.getModel();
Command result = new ShapeSetConstraintCommand(part, request, ((Rectangle) constraint).getLocation());
if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) {
Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
if (guidePos != null) {
result = chainGuideAttachmentCommand(request, part, result, true);
} else if (part.getHorizontalGuide() != null) {
// SnapToGuides didn't provide a horizontal guide, but this part is attached
// to a horizontal guide. Now we check to see if the part is attached to
// the guide along the edge being resized. If that is the case, we need to
// detach the part from the guide; otherwise, we leave it alone.
int alignment = part.getHorizontalGuide().getAlignment(part);
int edgeBeingResized = 0;
if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
edgeBeingResized = -1;
} else {
edgeBeingResized = 1;
}
if (alignment == edgeBeingResized) {
result = result.chain(new ChangeGuideCommand(part, true));
}
}
}
if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
if (guidePos != null) {
result = chainGuideAttachmentCommand(request, part, result, false);
} else if (part.getVerticalGuide() != null) {
int alignment = part.getVerticalGuide().getAlignment(part);
int edgeBeingResized = 0;
if ((request.getResizeDirection() & PositionConstants.WEST) != 0) {
edgeBeingResized = -1;
} else {
edgeBeingResized = 1;
}
if (alignment == edgeBeingResized) {
result = result.chain(new ChangeGuideCommand(part, false));
}
}
}
if (request.getType().equals(REQ_MOVE_CHILDREN) || request.getType().equals(REQ_ALIGN_CHILDREN)) {
result = chainGuideAttachmentCommand(request, part, result, true);
result = chainGuideAttachmentCommand(request, part, result, false);
result = chainGuideDetachmentCommand(request, part, result, true);
result = chainGuideDetachmentCommand(request, part, result, false);
}
return result;
}
use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape in project jbosstools-hibernate by jbosstools.
the class ShapeHideAction 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;
}
use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape 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;
}
use of org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape in project jbosstools-hibernate by jbosstools.
the class MoveGuideCommand method execute.
public void execute() {
guide.setPosition(guide.getPosition() + pDelta);
Iterator<OrmShape> iter = guide.getParts().iterator();
while (iter.hasNext()) {
OrmShape part = iter.next();
Point location = part.getLocation().getCopy();
if (guide.isHorizontal()) {
location.y += pDelta;
} else {
location.x += pDelta;
}
part.setLocation(location);
}
}
Aggregations