Search in sources :

Example 46 with Command

use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.

the class ErDiagramItemDeleteAction method createDeleteCommand.

public Command createDeleteCommand(List objects) {
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
    deleteReq.setEditParts(objects);
    EditPart object = (EditPart) objects.get(0);
    Command cmd = object.getCommand(deleteReq);
    return cmd;
}
Also used : Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) EditPart(org.eclipse.gef.EditPart)

Example 47 with Command

use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.

the class ConfigOptionController method createControl.

@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    //$NON-NLS-1$
    Button theBtn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    theBtn.setBackground(subComposite.getBackground());
    if (param.getDisplayName().equals("")) {
        //$NON-NLS-1$
        theBtn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    } else {
        theBtn.setText(param.getDisplayName());
    }
    FormData data = new FormData();
    if (isInWizard()) {
        if (lastControl != null) {
            data.right = new FormAttachment(lastControl, 0);
        } else {
            data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
        }
    } else {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, 0);
        } else {
            data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
        }
    }
    data.top = new FormAttachment(0, top);
    theBtn.setLayoutData(data);
    theBtn.setEnabled(!param.isReadOnly());
    theBtn.setData(param);
    hashCurControls.put(param.getName(), theBtn);
    theBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Command cmd = createCommand((Button) e.getSource());
            executeCommand(cmd);
        }
    });
    Point initialSize = theBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            refresh(param, true);
        }
    });
    return theBtn;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Button(org.eclipse.swt.widgets.Button) Command(org.eclipse.gef.commands.Command) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 48 with Command

use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.

the class CamelEditorDropTargetListener method handleDrop.

@Override
protected void handleDrop() {
    if (!checkSelectionSource()) {
        return;
    }
    updateTargetRequest();
    updateTargetEditPart();
    if (selectSourceList.get(0) instanceof PaletteEditPart && getTargetRequest() instanceof CreateRequest) {
        if (getTargetEditPart() instanceof ProcessPart) {
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
        }
        return;
    }
    if (isContextSource) {
        createContext();
    } else {
        if (!(getTargetEditPart() instanceof NodeContainerPart)) {
            try {
                createNewComponent(getCurrentEvent());
            } catch (OperationCanceledException e) {
                return;
            }
        }
    }
    // in case after drag/drop the editor is dirty but can not get focus
    if (editor.isDirty()) {
        editor.setFocus();
    }
    this.eraseTargetFeedback();
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateRequest(org.eclipse.gef.requests.CreateRequest) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart)

Example 49 with Command

use of org.eclipse.gef.commands.Command in project cubrid-manager by CUBRID.

the class DeleteAction method buildDeleteCommands.

public Command buildDeleteCommands(List<EditPart> parts) {
    if (parts == null || parts.size() == 0) {
        return null;
    }
    GroupRequest delRequest = new GroupRequest(RequestConstants.REQ_DELETE);
    delRequest.setEditParts(parts);
    CompoundCommand compCommands = new CompoundCommand(RequestConstants.REQ_DELETE);
    for (EditPart part : parts) {
        Command cmd = part.getCommand(delRequest);
        if (cmd != null) {
            compCommands.add(cmd);
        }
    }
    return compCommands;
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) EditPart(org.eclipse.gef.EditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 50 with Command

use of org.eclipse.gef.commands.Command in project cubrid-manager by CUBRID.

the class GefViewerKeyHandler method deleteHANodeByKey.

/**
	 * delete node by delete key,do not suppurt multi selected.
	 * 
	 * @param event KeyEvent
	 * @return if delete node return true,else return false
	 */
private boolean deleteHANodeByKey(KeyEvent event) {
    if (event.keyCode == SWT.DEL && getViewer().getSelectedEditParts().size() == 1) {
        GroupRequest deleteRequest = new GroupRequest(RequestConstants.REQ_DELETE);
        GraphicalEditPart editPart = getFocusEditPart();
        deleteRequest.setEditParts(editPart);
        Command command = editPart.getCommand(deleteRequest);
        if (command != null && !(command instanceof UnexecutableCommand)) {
            command.execute();
            return true;
        }
    }
    return false;
}
Also used : UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand)

Aggregations

Command (org.eclipse.gef.commands.Command)100 ArrayList (java.util.ArrayList)38 List (java.util.List)35 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)35 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)28 IElementParameter (org.talend.core.model.process.IElementParameter)22 Node (org.talend.designer.core.ui.editor.nodes.Node)20 INode (org.talend.core.model.process.INode)17 EditPart (org.eclipse.gef.EditPart)15 CommandStack (org.eclipse.gef.commands.CommandStack)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)14 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 RepositoryNode (org.talend.repository.model.RepositoryNode)13 RepositoryChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand)12 Request (org.eclipse.gef.Request)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11