org.eclipse.core.commands.ExecutionException Java Examples

The following examples show how to use org.eclipse.core.commands.ExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CopyTraceHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    // Get selection already validated by handler in plugin.xml
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    if (!(selection instanceof IStructuredSelection)) {
        return null;
    }
    TmfTraceElement trace = (TmfTraceElement) ((IStructuredSelection) selection).getFirstElement();

    // Fire the Copy Trace dialog
    Shell shell = HandlerUtil.getActiveShellChecked(event);
    CopyTraceDialog dialog = new CopyTraceDialog(shell, trace);
    dialog.open();

    return null;
}
 
Example #2
Source File: CompartmentChildCreateCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {

	View view =
		ViewService.getInstance().createView(
				viewDescriptor.getViewKind(),
				viewDescriptor.getElementAdapter(),
				containerView,
				viewDescriptor.getSemanticHint(),
				index,
				viewDescriptor.isPersisted(),
				viewDescriptor.getPreferencesHint());
	Assert.isNotNull(view, "failed to create a view"); //$NON-NLS-1$
	viewDescriptor.setView(view);

	return CommandResult.newOKCommandResult(viewDescriptor);
}
 
Example #3
Source File: EditEigenleistungUi.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	try {
		// get the parameter
		String param = event.getParameter(PARAMETERID);
		IVerrechenbar verrechenbar =
			(IVerrechenbar) event.getCommand().getParameterType(PARAMETERID)
				.getValueConverter().convertToObject(param);
		// create and open the dialog with the parameter
		Shell parent = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
		EigenLeistungDialog dialog = new EigenLeistungDialog(parent, verrechenbar);
		dialog.open();
	} catch (Exception ex) {
		throw new RuntimeException(COMMANDID, ex);
	}
	return null;
}
 
Example #4
Source File: BaseControlViewHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Refreshes the session information based on given session (in CommandParameter)
 * @param param - command parameter containing the session to refresh
 */
protected void refresh(final @NonNull CommandParameter param) {
    Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                param.getSession().getConfigurationFromNode(monitor);
            } catch (ExecutionException e) {
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.schedule();
}
 
Example #5
Source File: RemoveConnectionHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
            .getActivePage().getSelection();
	if(selection instanceof TreeSelection) {
		TreeSelection treeSelection = (TreeSelection) selection;
		if(treeSelection.getFirstElement() instanceof File) {
			File file = (File) treeSelection.getFirstElement();
			if(file.getFileExtension().equals("bib")){
				WorkspaceBibTexEntry entry = wm.getWorkspaceBibTexEntryByUri(file.getLocationURI());
				if(entry != null) {
					if(entry.getMendeleyFolder() != null) {
						// by setting the MendeleyFolder of a WorkspaceBibTexEntry to null, the connection will be removed
						entry.setMendeleyFolder(null);
						decoratorManager.update("de.tudresden.slr.model.mendeley.decorators.MendeleyOverlayDecorator");
					}
				}
			}
		}
	}
	return null;
}
 
Example #6
Source File: NeedReviewSegmentHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof XLIFFEditorImplWithNatTable) {
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		XLFHandler handler = xliffEditor.getXLFHandler();
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		boolean isNeedReview = true;
		//先判断所有的选择文本段的是否锁定状态
		for(String rowId : selectedRowIds){
			if (!handler.isNeedReview(rowId)) {
				isNeedReview = false;
				break;
			}
		}
		NattableUtil util = NattableUtil.getInstance(xliffEditor);
		util.changIsQuestionState(selectedRowIds, isNeedReview ? "no" : "yes");
	}
	return null;
}
 
Example #7
Source File: SplitTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term termToSplit = (Term) currentSelection.getFirstElement();
		if (selectionValid(termToSplit)) {
			SplitTermDialog dialog = new SplitTermDialog(null, termToSplit.getName());
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermSplitter.split(termToSplit, dialog.getDefaultTermName(), dialog.getFurtherTermNames());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected term must not have children.", null));
		}
	}
	return null;
}
 
Example #8
Source File: ShowPreviousNoteHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousNoteSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一个带批注的文本段。");
	}

	return null;
}
 
Example #9
Source File: ShowViewHandler.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public final Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked ( event );

    final Object value = event.getParameter ( PARAMETER_NAME_VIEW_ID );

    try
    {
        final String[] viewIds = ( (String)value ).split ( ":" );
        if ( viewIds.length == 1 )
        {
            openView ( viewIds[0], null, window );
        }
        else if ( viewIds.length == 2 )
        {
            openView ( viewIds[0], viewIds[1], window );
        }
    }
    catch ( final PartInitException e )
    {
        throw new ExecutionException ( "Part could not be initialized", e ); //$NON-NLS-1$
    }

    return null;
}
 
Example #10
Source File: LTTngControlServiceMi3LTTng211.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testListContext211() throws ExecutionException {
    ((LTTngControlService)fService).setVersion("2.11.0");
    fShell.setScenario(SCEN_LIST_CONTEXT_211);

    List<String> availContexts = fService.getContextList(new NullProgressMonitor());
    assertNotNull(availContexts);
    assertEquals(12, availContexts.size());

    Set<String> expectedContexts = new HashSet<>();
    expectedContexts.add("pid");
    expectedContexts.add("procname");
    expectedContexts.add("prio");
    expectedContexts.add("nice");
    expectedContexts.add("vpid");
    expectedContexts.add("tid");
    expectedContexts.add("pthread_id");
    expectedContexts.add("vtid");
    expectedContexts.add("ppid");
    expectedContexts.add("vppid");
    expectedContexts.add("perf:cpu:cpu-cycles");
    expectedContexts.add("perf:cpu:cycles");

    assertTrue(expectedContexts.containsAll(availContexts));
}
 
Example #11
Source File: NotSendToTMHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof XLIFFEditorImplWithNatTable) {
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		if (selectedRowIds != null && selectedRowIds.size() > 0) {
			boolean isSendtoTm = true;
			XLFHandler handler = xliffEditor.getXLFHandler();
			for (String rowId : selectedRowIds) {
				if (!handler.isSendToTM(rowId) && isSendtoTm) {
					isSendtoTm = false;
					break;
				}
			}
			NattableUtil util = NattableUtil.getInstance(xliffEditor);
			util.changeSendToTmState(selectedRowIds, isSendtoTm ? "yes" : "no");
		}
	}
	return null;
}
 
Example #12
Source File: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param menu
 */
private void createValidate(final Menu menu) {
	final MenuItem validate = new MenuItem(menu, SWT.PUSH);
	validate.setText(" Validate");
	validate.setImage(GamaIcons.create("build.project2").image());
	validate.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			try {
				WorkbenchHelper.runCommand("msi.gama.lang.gaml.Gaml.validate");
			} catch (final ExecutionException e1) {
				e1.printStackTrace();
			}
		}
	});

}
 
Example #13
Source File: ShowNextUntranslatedHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int lastSelectedRow = selectedRows[selectedRows.length - 1];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getNextUntranslatedSegmentIndex(lastSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在下一未翻译文本段。");
	}

	return null;
}
 
Example #14
Source File: LTTngControlServiceTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGetKernelProviderNoUst1() {
    try {
        fShell.setScenario(SCEN_LIST_WITH_NO_UST1);
        List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor());

        // Verify Provider info
        assertNotNull(providerList);
        assertEquals(0, providerList.size());

    } catch (ExecutionException e) {
        fail(e.toString());
    }
}
 
Example #15
Source File: LoadTemplateCommand.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	// get the selection
	Brief template = null;
	ISelection selection =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	if (selection != null) {
		IStructuredSelection strucSelection = (IStructuredSelection) selection;
		Object firstElement = strucSelection.getFirstElement();
		if (firstElement != null && firstElement instanceof TextTemplate) {
			TextTemplate textTemplate = (TextTemplate) firstElement;
			template = textTemplate.getTemplate();
		}
	}
	
	// show template in textview
	try {
		if (template == null) {
			SWTHelper.alert(ch.elexis.core.ui.commands.Messages.LoadTemplateCommand_Error,
				ch.elexis.core.ui.commands.Messages.LoadTemplateCommand_NoTextTemplate);
			return null;
		}
		IWorkbenchPage activePage =
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		TextView textView = (TextView) activePage.showView(TextView.ID);
		if (!textView.openDocument(template)) {
			SWTHelper.alert(Messages.BriefAuswahlErrorHeading, //$NON-NLS-1$
				Messages.BriefAuswahlCouldNotLoadText); //$NON-NLS-1$
		}
	} catch (PartInitException e) {
		logger.error("Could not open TextView", e);
		ExHandler.handle(e);
	}
	return null;
}
 
Example #16
Source File: XLIFFEditorImplWithNatTable.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void insertCell(int rowIndex, int columnIndex, String insertText) throws ExecutionException {
	StyledTextCellEditor editor = HsMultiActiveCellEditor.getTargetStyledEditor();
	int editorRowIndex = editor.getRowIndex();
	if (!isHorizontalLayout) {
		editorRowIndex = editorRowIndex / 2;
	}
	if (editor != null && editorRowIndex == rowIndex && editor.getColumnIndex() == columnIndex) {
		editor.insertCanonicalValue(insertText);
		editor.viewer.getTextWidget().forceFocus();
	}
}
 
Example #17
Source File: ProcessEnablementProblemsDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == 0) {
        try {
            close();
            setReturnCode(openConfigureDialog().isOK() ? IDialogConstants.OK_ID : IDialogConstants.CANCEL_ID);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
    } else {
        super.buttonPressed(buttonId);
    }
}
 
Example #18
Source File: SourceCreateCommand.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	Source newElement = CrossflowFactory.eINSTANCE.createSource();

	Workflow owner = (Workflow) getElementToEdit();
	owner.getTasks().add(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #19
Source File: ToggleXtextNatureCommand.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelection(event);
	if (selection instanceof IStructuredSelection) {
		for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it.hasNext();) {
			IProject project = Adapters.adapt(it.next(), IProject.class);
			if (project != null) {
				toggleNature(project);
			}
		}
	}
	return null;
}
 
Example #20
Source File: AcceptMatch2.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/** (non-Javadoc)
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
			"net.heartsome.cat.ts.ui.translation.view.matchview");		
	if (viewPart != null && viewPart instanceof IMatchViewPart) {				
		IMatchViewPart matchView = (IMatchViewPart) viewPart;
		matchView.acceptMatchByIndex(1);
	}
	return null;
}
 
Example #21
Source File: IntermediateErrorCatchEvent4CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IntermediateErrorCatchEvent newElement = ProcessFactory.eINSTANCE.createIntermediateErrorCatchEvent();

	Activity owner = (Activity) getElementToEdit();
	owner.getBoundaryIntermediateEvents().add(newElement);

	ElementInitializers.getInstance().init_IntermediateErrorCatchEvent_3032(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #22
Source File: FindBarActions.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	FindBarDecorator dec = findBarDecorator.get();
	if (dec.isFindTextActive())
	{
		dec.inputNewline(dec.textFind);
	}
	else if (dec.isReplaceTextActive())
	{
		dec.inputNewline(dec.textReplace);
	}
	return null;
}
 
Example #23
Source File: ResizeContentOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	if (!resizableContentPart.getContentSize().equals(finalSize)) {
		resizableContentPart.setContentSize(finalSize);
	}
	return Status.OK_STATUS;
}
 
Example #24
Source File: RevealOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	// store the viewport translation
	tx = viewer.getCanvas().getHorizontalScrollOffset();
	ty = viewer.getCanvas().getVerticalScrollOffset();
	viewer.reveal(part);
	return Status.OK_STATUS;
}
 
Example #25
Source File: FileOpen.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	final FileDialog dialog = new FileDialog(shell, SWT.OPEN);
	dialog.setFilterExtensions(new String[] { "*.gaml", "*.experiment", "*.*" });
	dialog.setFilterNames(new String[] { "GAML model files", "GAML experiment files", "All Files" });
	final String fileSelected = dialog.open();

	if (fileSelected != null && GamlFileExtension.isAny(fileSelected)) {
		// Perform Action, like open the file.
		WorkspaceModelsManager.instance.openModelPassedAsArgument(fileSelected);
	}
	return null;
}
 
Example #26
Source File: XORGatewayCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	XORGateway newElement = ProcessFactory.eINSTANCE.createXORGateway();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_XORGateway_2008(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #27
Source File: BendVisualOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus undo(IProgressMonitor monitor,
		org.eclipse.core.runtime.IAdaptable info)
		throws ExecutionException {
	part.setVisualBendPoints(initialBendPoints);
	return Status.OK_STATUS;
}
 
Example #28
Source File: AcceptMatch3.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/** (non-Javadoc)
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
			"net.heartsome.cat.ts.ui.translation.view.matchview");		
	if (viewPart != null && viewPart instanceof IMatchViewPart) {				
		IMatchViewPart matchView = (IMatchViewPart) viewPart;
		matchView.acceptMatchByIndex(2);
	}
	return null;
}
 
Example #29
Source File: Task2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void doConfigure(Task newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
	ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
	configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
	configureRequest.addParameters(getRequest().getParameters());
	ICommand configureCommand = elementType.getEditCommand(configureRequest);
	if (configureCommand != null && configureCommand.canExecute()) {
		configureCommand.execute(monitor, info);
	}
}
 
Example #30
Source File: ToggleTextNodesHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	Command command = event.getCommand();
	boolean oldValue = HandlerUtil.toggleCommandState(command);
	HTMLPreferenceUtil.setShowTextNodesInOutline(!oldValue);

	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof AbstractThemeableEditor)
	{
		CommonOutlinePage page = ((AbstractThemeableEditor) editor).getOutlinePage();
		page.refresh();
	}
	return null;
}