use of org.eclipse.core.commands.ExecutionException in project azure-tools-for-java by Microsoft.
the class WANewCertificate method onExecute.
public Object onExecute(ExecutionEvent event) throws ExecutionException {
try {
NewCertificateDialogData data = new NewCertificateDialogData();
/*
* third parameter is jdkPath
* as its toolbar button, do not refer any project for JDK path
* just pass empty string.
*/
NewCertificateDialog dialog = new NewCertificateDialog(PluginUtil.getParentShell(), data, "");
// Open the dialog
dialog.open();
} catch (Exception e) {
PluginUtil.displayErrorDialogAndLog(PluginUtil.getParentShell(), Messages.newCertDlgCrtErTtl, Messages.newCertMsg, e);
Activator.getDefault().log(Messages.newCertMsg, e);
}
return null;
}
use of org.eclipse.core.commands.ExecutionException in project tdi-studio-se by Talend.
the class DeleteAssignmentAction method doRun.
@Override
protected void doRun() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof BusinessDiagramEditor) {
BusinessDiagramEditor editor = (BusinessDiagramEditor) activeEditor;
ISelection selection2 = editor.getSelection();
EObject element = null;
Object firstElement = ((IStructuredSelection) selection2).getFirstElement();
if (firstElement instanceof BusinessItemShapeEditPart) {
BusinessItemShapeEditPart editpart = (BusinessItemShapeEditPart) firstElement;
element = ((Node) editpart.getModel()).getElement();
} else if (firstElement instanceof BaseBusinessItemRelationShipEditPart) {
BaseBusinessItemRelationShipEditPart editpart = (BaseBusinessItemRelationShipEditPart) firstElement;
element = ((EdgeImpl) editpart.getModel()).getElement();
}
if (element instanceof BusinessItem) {
BusinessItem businessItem = (BusinessItem) element;
DeleteAssignmentCommand command = new DeleteAssignmentCommand(businessItem, selection);
try {
command.execute(null, null);
} catch (ExecutionException e) {
ExceptionHandler.process(e);
}
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IEditorReference editors : page.getEditorReferences()) {
CorePlugin.getDefault().getDiagramModelService().refreshBusinessModel(editors);
}
}
}
}
use of org.eclipse.core.commands.ExecutionException in project tdi-studio-se by Talend.
the class DiagramModelService method setBusinessItemAlignment.
public void setBusinessItemAlignment(BusinessAlignment alignment, BusinessAlignment alignmentGroup, Object part) {
if (part instanceof BusinessItemShapeEditPart) {
BusinessItem item = (BusinessItem) ((Node) ((BusinessItemShapeEditPart) part).getModel()).getElement();
ChangeBusinessItemAlignmentCommand command = new ChangeBusinessItemAlignmentCommand(item, alignment, alignmentGroup);
try {
command.execute(null, null);
} catch (ExecutionException e) {
}
((BusinessItemShapeEditPart) part).refreshVisuals();
}
}
use of org.eclipse.core.commands.ExecutionException in project tdi-studio-se by Talend.
the class BusinessNewDiagramFileWizard method performFinish.
/**
* @generated
*/
public boolean performFinish() {
IFile diagramFile = myFileCreationPage.createNewFile();
try {
//$NON-NLS-1$
diagramFile.setCharset("UTF-8", new NullProgressMonitor());
} catch (CoreException e) {
//$NON-NLS-1$
BusinessDiagramEditorPlugin.getInstance().logError("Unable to set charset for diagram file", e);
}
ResourceSet resourceSet = myEditingDomain.getResourceSet();
final Resource diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFile.getFullPath().toString()));
List affectedFiles = new LinkedList();
affectedFiles.add(mySelectedModelFile);
affectedFiles.add(diagramFile);
AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, //$NON-NLS-1$
"Initializing diagram contents", //$NON-NLS-1$
affectedFiles) {
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
int diagramVID = BusinessVisualIDRegistry.getDiagramVisualID(myDiagramRoot);
if (diagramVID != BusinessProcessEditPart.VISUAL_ID) {
//$NON-NLS-1$
return CommandResult.newErrorCommandResult("Incorrect model object stored as a root resource object");
}
Diagram diagram = ViewService.createDiagram(myDiagramRoot, BusinessProcessEditPart.MODEL_ID, BusinessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
diagramResource.getContents().add(diagram);
diagramResource.getContents().add(diagram.getElement());
return CommandResult.newOKCommandResult();
}
};
try {
OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
diagramResource.save(Collections.EMPTY_MAP);
IDE.openEditor(myWorkbenchPage, diagramFile);
} catch (ExecutionException e) {
//$NON-NLS-1$
BusinessDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e);
} catch (IOException ex) {
BusinessDiagramEditorPlugin.getInstance().logError("Save operation failed for: " + diagramFile.getFullPath().toString(), //$NON-NLS-1$
ex);
} catch (PartInitException ex) {
//$NON-NLS-1$
BusinessDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex);
}
return true;
}
use of org.eclipse.core.commands.ExecutionException in project tdi-studio-se by Talend.
the class ClipboardActionHandler method getCommand.
@Override
public ICommand getCommand(IGlobalActionContext cntxt) {
IWorkbenchPart part = cntxt.getActivePart();
if (!(part instanceof IDiagramWorkbenchPart)) {
return null;
}
IDiagramWorkbenchPart workbenchPart = (IDiagramWorkbenchPart) part;
DiagramEditPart diagramEditPart = workbenchPart.getDiagramEditPart();
ICommand command = null;
String actionId = cntxt.getActionId();
if (actionId.equals(GlobalActionId.COPY)) {
command = getCopyCommand(cntxt, workbenchPart, false);
transfer(cntxt.getSelection());
isCut = false;
older = workbenchPart;
orginalCopyFrom = workbenchPart;
clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
} else if (actionId.equals(GlobalActionId.CUT) && cntxt.getSelection() != null) {
saveCut(cntxt.getSelection());
command = getCutCommand(cntxt, workbenchPart);
transfer(cntxt.getSelection());
isCut = true;
older = workbenchPart;
clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
} else if (actionId.equals(GlobalActionId.SAVE)) {
if (workbenchPart instanceof IEditorPart) {
IEditorPart editorPart = (IEditorPart) workbenchPart;
if (editorPart.isDirty()) {
IWorkbenchPage page = editorPart.getSite().getPage();
page.saveEditor(editorPart, false);
}
}
}
if (actionId.equals(GlobalActionId.PASTE)) {
// diagramPart.getDiagramGraphicalViewer().setSelection(new
// StructuredSelection(diagramPart.getDiagramEditPart()));
PasteViewRequest pasteReq = createPasteViewRequest();
CommandStack cs = workbenchPart.getDiagramEditDomain().getDiagramCommandStack();
IStructuredSelection selection = (IStructuredSelection) cntxt.getSelection();
if (!(selection.getFirstElement() instanceof BusinessProcessEditPart)) {
selection = new StructuredSelection(workbenchPart.getDiagramEditPart());
}
Object[] objects = selection.toArray();
Collection returnValues = null;
if (objects.length == 1) {
Command paste = ((EditPart) objects[0]).getCommand(pasteReq);
if (paste != null) {
cs.execute(paste);
workbenchPart.getDiagramEditPart().getFigure().invalidate();
workbenchPart.getDiagramEditPart().getFigure().validate();
returnValues = DiagramCommandStack.getReturnValues(paste);
// selectAddedObject(diagramPart.getDiagramGraphicalViewer(), returnValues);
}
}
Object elements = TemplateTransfer.getInstance().getObject();
if (elements instanceof List) {
List<BusinessItem> list = (List<BusinessItem>) elements;
boolean inEditors = false;
if (older != workbenchPart) {
inEditors = true;
} else if (!this.isCut && orginalCopyFrom != workbenchPart) {
// bug 16065 fixed, by xtan. to resolve the copy(A)/parse(B)/parse(B)/parse(B)... problem.
inEditors = true;
}
// always keep the last one as the current selection.
older = workbenchPart;
GmfPastCommand pastBusiness = new GmfPastCommand((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement(), list, diagramEditPart, this.cutItemIds, this.isCut | inEditors);
pastBusiness.setClonedSourceProcessItemsList(clonedSourceProcessItemsList);
try {
pastBusiness.execute(null, null);
} catch (ExecutionException e) {
ExceptionHandler.process(e);
}
}
if (returnValues != null) {
selectAddedObject(workbenchPart.getDiagramGraphicalViewer(), returnValues);
}
return null;
}
return command;
}
Aggregations