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 Project: tmxeditor8   Author: heartsome   File: NeedReviewSegmentHandler.java    License: 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 #2
Source Project: bonita-studio   Author: bonitasoft   File: CompartmentChildCreateCommand.java    License: 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 Project: slr-toolkit   Author: sebastiangoetz   File: SplitTermHandler.java    License: 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 #4
Source Project: neoscada   Author: eclipse   File: ShowViewHandler.java    License: 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 #5
Source Project: tmxeditor8   Author: heartsome   File: NotSendToTMHandler.java    License: 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 #6
Source Project: tracecompass   Author: tracecompass   File: CopyTraceHandler.java    License: 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 #7
Source Project: translationstudio8   Author: heartsome   File: ShowNextUntranslatedHandler.java    License: 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 #8
Source Project: gama   Author: gama-platform   File: EditorMenu.java    License: 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 #9
Source Project: tracecompass   Author: tracecompass   File: LTTngControlServiceMi3LTTng211.java    License: 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 #10
Source Project: translationstudio8   Author: heartsome   File: ShowPreviousNoteHandler.java    License: 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 #11
Source Project: tracecompass   Author: tracecompass   File: BaseControlViewHandler.java    License: 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 #12
Source Project: elexis-3-core   Author: elexis   File: EditEigenleistungUi.java    License: 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 #13
Source Project: slr-toolkit   Author: sebastiangoetz   File: RemoveConnectionHandler.java    License: 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 #14
Source Project: bonita-studio   Author: bonitasoft   File: InclusiveGatewayCreateCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void doConfigure(InclusiveGateway 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 #15
Source Project: tmxeditor8   Author: heartsome   File: TmxValidateHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	Shell shell = HandlerUtil.getActiveShell(event);
	TmxValidatorDialog dialog = new TmxValidatorDialog(shell);
	dialog.open();
	return null;
}
 
Example #16
Source Project: gef   Author: eclipse   File: BendContentOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	// TODO (bug #493515): retrieve current bend points from
	// bendableContentPart and only
	// call bendContent if a change occurred.
	bendableContentPart.setContentBendPoints(initialBendPoints);
	// TODO: validate bending worked
	return Status.OK_STATUS;
}
 
Example #17
Source Project: gef   Author: eclipse   File: AddSnapToStrategyOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	if (!model.snapToStrategiesProperty().contains(strategy)) {
		model.snapToStrategiesProperty().add(strategy);
	}
	return Status.OK_STATUS;
}
 
Example #18
Source Project: bonita-studio   Author: bonitasoft   File: SendTaskCreateCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void doConfigure(SendTask 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 #19
Source Project: bonita-studio   Author: bonitasoft   File: SmallCoolBarHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	MWindow model = ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getModel();
	EModelService modelService = model.getContext().get(EModelService.class);
	MToolControl bonitaCoolBar = (MToolControl) modelService.find(
			"BonitaCoolbar", model);
	if(bonitaCoolBar != null){
		CoolbarToolControl coolbarControl = (CoolbarToolControl) bonitaCoolBar.getObject();
		coolbarControl.minimizeCoolbar();
	}
	return null;
}
 
Example #20
Source Project: bonita-studio   Author: bonitasoft   File: ProcessEnablementProblemsDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected IStatus openConfigureDialog() throws ExecutionException {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command cmd = service.getCommand("org.bonitasoft.studio.configuration.configure");
    Map<String, Object> parameters = new HashMap<String, Object>();
    String configuration = ConfigurationPlugin.getDefault().getPreferenceStore().getString(ConfigurationPreferenceConstants.DEFAULT_CONFIGURATION);
    parameters.put("configuration", configuration);
    parameters.put("process", process);
    return (IStatus) new ConfigureHandler().execute(new ExecutionEvent(cmd, parameters, null, null));
}
 
Example #21
Source Project: APICloud-Studio   Author: apicloudcom   File: FindBarActions.java    License: 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 != null)
	{
		dec.setVisible(false);
	}
	return null;
}
 
Example #22
Source Project: gef   Author: eclipse   File: ChangeContentsOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	if (!viewer.getContents().equals(newContents)) {
		viewer.getContents().setAll(newContents);
	}
	return Status.OK_STATUS;
}
 
Example #23
Source Project: txtUML   Author: ELTE-Soft   File: TxtUMLToCppHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	WizardDialog wizardDialog = new WizardDialog(null, new TxtUMLToCppWizard());
	wizardDialog.open();

	return null;
}
 
Example #24
Source Project: xds-ide   Author: excelsior-oss   File: StandardResourceActionHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
    * {@inheritDoc}
    */
@Override
   public Object execute(ExecutionEvent event) throws ExecutionException {
       ISelection selection = HandlerUtil.getCurrentSelection(event);
       if (selection instanceof IStructuredSelection) {
       	action.selectionChanged((IStructuredSelection)selection);
       }
       action.run();
       return null;
   }
 
Example #25
Source Project: neoscada   Author: eclipse   File: OpenChartViewWithParameters.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final String connectionId = event.getParameter ( "org.eclipse.scada.ui.chart.connectionId" ); //$NON-NLS-1$
    final String connectionString = event.getParameter ( "org.eclipse.scada.ui.chart.connectionString" ); //$NON-NLS-1$
    final String itemId = event.getParameter ( "org.eclipse.scada.ui.chart.itemId" ); //$NON-NLS-1$
    final String itemType = event.getParameter ( "org.eclipse.scada.ui.chart.itemType" ); //$NON-NLS-1$

    if ( connectionId == null && connectionString == null )
    {
        throw new ExecutionException ( "No connection ID or string set" );
    }
    if ( itemType == null )
    {
        throw new ExecutionException ( "Item type is not set" );
    }

    final Chart configuration = makeConfiguration ( event );

    if ( "da".equals ( itemType ) ) //$NON-NLS-1$
    {
        openDaChartView ( Arrays.asList ( new Item ( connectionId != null ? connectionId : connectionString, itemId, connectionId != null ? Type.ID : Type.URI ) ), configuration );
    }
    else if ( "hd".equals ( itemType ) ) //$NON-NLS-1$
    {
        openHdChartView ( Arrays.asList ( new org.eclipse.scada.hd.ui.connection.data.Item ( connectionId != null ? connectionId : connectionString, itemId, connectionId != null ? org.eclipse.scada.hd.ui.connection.data.Item.Type.ID : org.eclipse.scada.hd.ui.connection.data.Item.Type.URI ) ), configuration );
    }
    else
    {
        throw new ExecutionException ( String.format ( "The item type '%s' is unsupported", itemType ) );
    }

    return null;
}
 
Example #26
Source Project: translationstudio8   Author: heartsome   File: ChangeXliffEditorModelHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * the command has been executed, so extract extract the needed information from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	IEditorPart editor = workbenchPage.getActiveEditor();
	if (editor == null) {
		return null;
	}
	if (editor instanceof IHSEditor) {
		IHSEditor xliffEditor = (IHSEditor) editor;
		xliffEditor.changeModel();
	}
	return null;
}
 
Example #27
Source Project: bonita-studio   Author: bonitasoft   File: VerticalArrangeCommandHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	VerticalArrangeAction action = new VerticalArrangeAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), true) ;
	action.init();
	action.refresh();
	action.run();
	action.dispose();
	return null;
}
 
Example #28
Source Project: tracecompass   Author: tracecompass   File: AddContextOnDomainHandler.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addContexts(CommandParameter param, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
    if (param instanceof DomainCommandParameter) {
        TraceDomainComponent domain = ((DomainCommandParameter)param).getDomain();
        domain.addContexts(contextNames, monitor);
    }
}
 
Example #29
Source Project: developer-studio   Author: wso2   File: UpdateFeaturesCommandHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
	Job updateJob = new UpdateCheckerJob(updateManager);
	updateJob.schedule();
	updateJob.addJobChangeListener(new UpdateCheckerJobListener(
			updateManager, ActiveTab.UPDATE_FEATURES, false));
	try {
		PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getActivePage().showView(IProgressConstants.PROGRESS_VIEW_ID);
	} catch (PartInitException e) {
		log.error(e);
	}
	return null;
}
 
Example #30
Source Project: bonita-studio   Author: bonitasoft   File: Task2CreateCommand.java    License: 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);
	}
}