use of org.eclipse.gef.GraphicalEditPart in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method getResizeChildrenCommand.
// This has been overriden to fix a bug when handle bounds does not equal with bounds. For example, polyline figue.
/* (non-Javadoc)
* @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getResizeChildrenCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
*/
@Override
protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
CompoundCommand resize = new CompoundCommand();
Command c;
GraphicalEditPart child;
List<?> children = request.getEditParts();
for (int i = 0; i < children.size(); i++) {
child = (GraphicalEditPart) children.get(i);
c = createChangeConstraintCommand(request, child, translateToModelConstraint(getConstraintForResize(request, child)));
resize.add(c);
}
return resize.unwrap();
}
use of org.eclipse.gef.GraphicalEditPart in project dbeaver by serge-rider.
the class PropertyAwarePart method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
String property = evt.getPropertyName();
if (ERDObject.CHILD.equals(property)) {
handleChildChange(evt);
}
if (ERDObject.REORDER.equals(property)) {
handleReorderChange(evt);
} else if (ERDObject.OUTPUT.equals(property)) {
handleOutputChange(evt);
} else if (ERDObject.INPUT.equals(property)) {
handleInputChange(evt);
} else if (ERDObject.NAME.equals(property)) {
commitNameChange(evt);
}
//not use the Graph animation, if automatic layout is being used
if (ERDObject.NAME.equals(property)) {
GraphicalEditPart graphicalEditPart = (GraphicalEditPart) (getViewer().getContents());
IFigure partFigure = graphicalEditPart.getFigure();
partFigure.getUpdateManager().performUpdate();
}
}
use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.
the class GefViewerKeyHandler method moveHANodesByKey.
/**
* move figures by keyboard.
*
* @param event KeyEvent
* @return if handled the event return true else return false.
*/
private boolean moveHANodesByKey(KeyEvent event) {
List<?> selectedEditParts = getViewer().getSelectedEditParts();
boolean flag = false;
for (Object obj : selectedEditParts) {
if (!(obj instanceof HANodePart)) {
continue;
}
GraphicalEditPart editPart = (GraphicalEditPart) obj;
Command command = null;
if ((event.stateMask & SWT.ALT) == 0 && (event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
HANode node = (HANode) editPart.getModel();
ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
request.setLocation(node.getLocation());
request.setEditParts(editPart);
//get move delta
Point moveDelta = null;
switch(event.keyCode) {
case SWT.ARROW_LEFT:
moveDelta = new Point(-1, 0);
break;
case SWT.ARROW_RIGHT:
moveDelta = new Point(1, 0);
break;
case SWT.ARROW_UP:
moveDelta = new Point(0, -1);
break;
case SWT.ARROW_DOWN:
moveDelta = new Point(0, 1);
break;
default:
return true;
}
request.setMoveDelta(moveDelta);
command = editPart.getCommand(request);
}
if (command != null && !(command instanceof UnexecutableCommand)) {
command.execute();
flag = true;
}
}
return flag;
}
use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.
the class NodePart method refreshVisuals.
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
*/
protected void refreshVisuals() {
Node node = (Node) getModel();
Point loc = node.getLocation();
Dimension size = new Dimension(node.getSize());
Rectangle rectangle = new Rectangle(loc, size);
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.
the class HANodePart method refreshVisuals.
/**
* Refreshes this EditPart's <i>visuals</i>. This method is called by
* {@link #refresh()}, and may also be called in response to notifications
* from the model.
*/
protected void refreshVisuals() {
HANode node = (HANode) getModel();
Point loc = node.getLocation();
((AbstractMonitorFigure) getFigure()).setMinimized(isMinimized());
//figure's size is stable
Rectangle rectangle = new Rectangle(loc, figure.getSize());
GraphicalEditPart graphicalEditPart = (GraphicalEditPart) getParent();
graphicalEditPart.setLayoutConstraint(this, getFigure(), rectangle);
getFigure().repaint();
}
Aggregations