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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations