org.eclipse.ui.actions.WorkspaceModifyOperation#org.eclipse.core.commands.ExecutionException源码实例Demo

下面列出了org.eclipse.ui.actions.WorkspaceModifyOperation#org.eclipse.core.commands.ExecutionException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tmxeditor8   文件: NeedReviewSegmentHandler.java
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;
}
 
@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);
}
 
源代码3 项目: slr-toolkit   文件: SplitTermHandler.java
@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;
}
 
源代码4 项目: neoscada   文件: ShowViewHandler.java
@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;
}
 
源代码5 项目: tmxeditor8   文件: NotSendToTMHandler.java
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;
}
 
源代码6 项目: tracecompass   文件: CopyTraceHandler.java
@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;
}
 
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;
}
 
源代码8 项目: gama   文件: EditorMenu.java
/**
 * @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();
			}
		}
	});

}
 
@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));
}
 
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;
}
 
源代码11 项目: tracecompass   文件: BaseControlViewHandler.java
/**
 * 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();
}
 
源代码12 项目: elexis-3-core   文件: EditEigenleistungUi.java
@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;
}
 
源代码13 项目: slr-toolkit   文件: RemoveConnectionHandler.java
@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;
}
 
/**
* @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);
	}
}
 
源代码15 项目: tmxeditor8   文件: TmxValidateHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	Shell shell = HandlerUtil.getActiveShell(event);
	TmxValidatorDialog dialog = new TmxValidatorDialog(shell);
	dialog.open();
	return null;
}
 
源代码16 项目: gef   文件: BendContentOperation.java
@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;
}
 
源代码17 项目: gef   文件: AddSnapToStrategyOperation.java
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	if (!model.snapToStrategiesProperty().contains(strategy)) {
		model.snapToStrategiesProperty().add(strategy);
	}
	return Status.OK_STATUS;
}
 
源代码18 项目: bonita-studio   文件: SendTaskCreateCommand.java
/**
* @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);
	}
}
 
源代码19 项目: bonita-studio   文件: SmallCoolBarHandler.java
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;
}
 
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));
}
 
源代码21 项目: APICloud-Studio   文件: FindBarActions.java
public Object execute(ExecutionEvent event) throws ExecutionException
{
	FindBarDecorator dec = findBarDecorator.get();
	if (dec != null)
	{
		dec.setVisible(false);
	}
	return null;
}
 
源代码22 项目: gef   文件: ChangeContentsOperation.java
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	if (!viewer.getContents().equals(newContents)) {
		viewer.getContents().setAll(newContents);
	}
	return Status.OK_STATUS;
}
 
源代码23 项目: txtUML   文件: TxtUMLToCppHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

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

	return null;
}
 
源代码24 项目: xds-ide   文件: StandardResourceActionHandler.java
/**
    * {@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;
   }
 
源代码25 项目: neoscada   文件: OpenChartViewWithParameters.java
@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;
}
 
/**
 * 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;
}
 
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;
}
 
源代码28 项目: tracecompass   文件: AddContextOnDomainHandler.java
@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);
    }
}
 
@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;
}
 
源代码30 项目: bonita-studio   文件: Task2CreateCommand.java
/**
* @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);
	}
}