Search in sources :

Example 66 with EditPart

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;
}
Also used : AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ChangeOrderCommand(org.csstudio.opibuilder.commands.ChangeOrderCommand) EditPart(org.eclipse.gef.EditPart) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 67 with EditPart

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;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) EditPart(org.eclipse.gef.EditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 68 with EditPart

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;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) EditPart(org.eclipse.gef.EditPart)

Example 69 with EditPart

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;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) VString(org.diirt.vtype.VString)

Example 70 with EditPart

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);
            }
        }
    }
}
Also used : EditableLabel(com.cubrid.common.ui.er.figures.EditableLabel) Relationship(com.cubrid.common.ui.er.model.Relationship) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) EditPart(org.eclipse.gef.EditPart)

Aggregations

EditPart (org.eclipse.gef.EditPart)132 List (java.util.List)50 ArrayList (java.util.ArrayList)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)26 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 Point (org.eclipse.draw2d.geometry.Point)17 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 Command (org.eclipse.gef.commands.Command)16 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)15 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 RootEditPart (org.eclipse.gef.RootEditPart)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)10 INode (org.talend.core.model.process.INode)10