use of org.eclipse.gef.EditPart in project yamcs-studio by yamcs.
the class WidgetTreeContainerEditPolicy method getMoveChildrenCommand.
@Override
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
CompoundCommand command = new CompoundCommand();
@SuppressWarnings("rawtypes") List editparts = request.getEditParts();
@SuppressWarnings("rawtypes") List children = getHost().getChildren();
int newIndex = findIndexOfTreeItemAt(request.getLocation());
int tempIndex = newIndex;
for (int i = 0; i < editparts.size(); i++) {
EditPart child = (EditPart) editparts.get(editparts.size() - 1 - i);
int oldIndex = children.indexOf(child);
if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
command.add(UnexecutableCommand.INSTANCE);
return command;
} else if (oldIndex <= tempIndex) {
tempIndex--;
}
command.add(new ChangeOrderCommand(tempIndex, (AbstractContainerModel) getHost().getModel(), (AbstractWidgetModel) child.getModel()));
}
return command;
}
use of org.eclipse.gef.EditPart in project yamcs-studio by yamcs.
the class WidgetTreeContainerEditPolicy method getAddCommand.
@Override
protected Command getAddCommand(ChangeBoundsRequest request) {
CompoundCommand cmd = new CompoundCommand();
@SuppressWarnings("rawtypes") List editparts = request.getEditParts();
int index = findIndexOfTreeItemAt(request.getLocation());
for (int i = 0; i < editparts.size(); i++) {
EditPart child = (EditPart) editparts.get(index >= 0 ? editparts.size() - 1 - i : i);
if (isAncestor(child, getHost())) {
cmd.add(UnexecutableCommand.INSTANCE);
} else {
AbstractWidgetModel childModel = (AbstractWidgetModel) child.getModel();
cmd.add(createCreateCommand(childModel, new Rectangle(new Point(), childModel.getSize()), index, "Reparent Widgets"));
}
}
return cmd;
}
use of org.eclipse.gef.EditPart in project yamcs-studio by yamcs.
the class WidgetTreeEditPolicy method getMoveCommand.
protected Command getMoveCommand(ChangeBoundsRequest req) {
EditPart parent = getHost().getParent();
if (parent != null) {
ChangeBoundsRequest request = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
// request.setEditParts(getHost());
request.setEditParts(req.getEditParts());
request.setLocation(req.getLocation());
// $NON-NLS-1$
req.setType("");
return parent.getCommand(request);
}
return UnexecutableCommand.INSTANCE;
}
use of org.eclipse.gef.EditPart in project yamcs-studio by yamcs.
the class ArrayEditPart method createChild.
@Override
protected EditPart createChild(Object model) {
final AbstractWidgetModel child = (AbstractWidgetModel) model;
for (String propId : child.getAllPropertyIDs()) child.getProperty(propId).addPropertyChangeListener(syncPropertiesListener);
final EditPart result = super.createChild(model);
UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {
@Override
public void run() {
hookChild(result, getChildren().indexOf(result), true);
}
});
return result;
}
use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class RelationshipPart method handleDeleteConnection.
public void handleDeleteConnection() {
Relationship relations = (Relationship) this.getModel();
TablePart sourceTablePart = (TablePart) this.getSource();
TablePart targetTablePart = (TablePart) this.getTarget();
// set source and target columns
if (sourceTablePart != null) {
List<EditPart> children = sourceTablePart.getChildren();
for (EditPart child : children) {
if (!(child instanceof ColumnPart)) {
continue;
}
ColumnPart columnPart = (ColumnPart) child;
ERTableColumn column = (ERTableColumn) columnPart.getModel();
if (relations.getReferenceColumns().contains(column.getName())) {
EditableLabel columnLable = (EditableLabel) columnPart.getFigure();
columnLable.setFontProtrude(false);
}
}
}
// target
if (targetTablePart != null) {
List<EditPart> children = targetTablePart.getChildren();
for (EditPart child : children) {
if (!(child instanceof ColumnPart)) {
continue;
}
ColumnPart columnPart = (ColumnPart) child;
ERTableColumn column = (ERTableColumn) columnPart.getModel();
if (relations.getReferencedPKs().contains(column.getName())) {
EditableLabel columnLable = (EditableLabel) columnPart.getFigure();
columnLable.setFontProtrude(false);
}
}
}
}
Aggregations