Java Code Examples for org.eclipse.core.commands.ExecutionEvent#getParameter()
The following examples show how to use
org.eclipse.core.commands.ExecutionEvent#getParameter() .
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: OpenViewHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * the command has been executed, so extract extract the needed information from the application context. */ public Object execute(ExecutionEvent event) throws ExecutionException { String viewId = event.getParameter("ViewId"); if (viewId == null) { return null; } IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart view = workbenchPage.findView(viewId); if (view == null) { try { workbenchPage.showView(viewId); } catch (PartInitException e) { e.printStackTrace(); } } else { workbenchPage.hideView(view); } // ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); // commandService.refreshElements(event.getCommand().getId(), null); return null; }
Example 2
Source File: ApproveSegmentHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { final XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; List<String> rowIds = xliffEditor.getSelectedRowIds(); if (rowIds.size() == 0) { return null; } String parameter = event.getParameter("approveSegment"); if (parameter != null) { HsMultiActiveCellEditor.commit(true); NattableUtil util = NattableUtil.getInstance(xliffEditor); util.approveTransUnits(parameter.equalsIgnoreCase("approveAndJumpNext")); // 执行批准 } } return null; }
Example 3
Source File: Execute.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart activePart = HandlerUtil.getActivePart(event); if (activePart != null) { String commandID = event.getCommand().getId(); ResourceType resourceType = ResourceType.getFromEnum(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.resource")); CommandType commandType = CommandType.getFromAction(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.type")); String commandValue = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.value"); String commandWorkingDir = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.workingdir"); CommandTokenizer commandTokenizer = CommandTokenizer.getFromEnum(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.tokenizer")); ActionDelegate action = EditorPropertyTester.getActionExactResourceType(activePart, resourceType); if (action != null) { action.setResourceType(resourceType); action.setCommandType(commandType); action.setCommandValue(commandValue); action.setCommandWorkingDir(commandWorkingDir); action.setCommandTokenizer(commandTokenizer); Action act = new Action(commandID); action.run((IAction)act); } action = null; } else { Activator.logError("HandlerUtil.getActivePart() returns null: see Eclipse platform bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=242246", null); } return null; }
Example 4
Source File: ApproveSegmentHandler.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { final XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; List<String> rowIds = xliffEditor.getSelectedRowIds(); if (rowIds.size() == 0) { return null; } String parameter = event.getParameter("approveSegment"); if (parameter != null) { HsMultiActiveCellEditor.commit(true); NattableUtil util = NattableUtil.getInstance(xliffEditor); util.approveTransUnits(parameter.equalsIgnoreCase("approveAndJumpNext")); // 执行批准 } } return null; }
Example 5
Source File: OpenSpecificProcessCommand.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IRepository repository = RepositoryManager.getInstance().getCurrentRepository() ; diagramSotre = (DiagramRepositoryStore) repository.getRepositoryStore(DiagramRepositoryStore.class) ; try { if (event.getParameter(PARAMETER_PROCESS_NAME) != null && event.getParameter(PARAMETER_PROCESS_VERSION) != null) { for(IRepositoryFileStore file : diagramSotre.getChildren()){ for(AbstractProcess p : ((DiagramFileStore)file).getProcesses()){ if(p.getName().equals(event.getParameter(PARAMETER_PROCESS_NAME)) && p.getVersion().equals(event.getParameter(PARAMETER_PROCESS_VERSION))){ file.open(); return null ; } } } } else { return null; } } catch (Exception ex) { throw new ExecutionException("Could not open process", ex); } return null; }
Example 6
Source File: RepeatCommandSupport.java From e4macs with Eclipse Public License 1.0 | 6 votes |
protected void storeCount(ExecutionEvent event) { String universalArg = event.getParameter(UNIVERSAL_ARG); if (universalArg != null && universalArg.length() > 0) { try { Integer count = Integer.parseInt(universalArg); if (repeater != null) { @SuppressWarnings("unchecked") Map<String,Object> params = (Map<String,Object>)repeater.getParams(); if (params.isEmpty()) { params = new HashMap<String,Object>(); repeater.setParams(params); } params.put(UNIVERSAL_ARG, count); } } catch (NumberFormatException e) {} // ignore if invalid number } }
Example 7
Source File: EditLabItemUi.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException{ try { // get the parameter String param = event.getParameter(PARAMETERID); PersistentObject labitem = (PersistentObject) event.getCommand().getParameterType(PARAMETERID) .getValueConverter().convertToObject(param); // create and open the dialog with the parameter Shell parent = HandlerUtil.getActiveShell(event); EditLabItem dialog = new EditLabItem(parent, (LabItem) labitem); dialog.open(); } catch (Exception ex) { throw new RuntimeException(COMMANDID, ex); } return null; }
Example 8
Source File: KbdMacroLoadHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent) */ @Override protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event) throws BadLocationException { fileCompletions = null; if (!KbdMacroSupport.getInstance().isDefining() && !KbdMacroSupport.getInstance().isExecuting()) { String macroName = event.getParameter(NAME_ARG); boolean forceIt = (event.getParameter(FORCE_ARG) != null ? Boolean.valueOf(event.getParameter(FORCE_ARG)) : false); if (macroName != null && macroName.length() > 0) { File file = macroFile(macroName); if (file.exists()) { loadMacro(editor,macroName,file,forceIt); } else { asyncShowMessage(editor, String.format(MACRO_MISSING, macroName), true); } } else { mbState = this.nameState(); return mbState.run(editor); } } else { asyncShowMessage(editor, BAD_MACRO_STATE, true); } return NO_OFFSET; }
Example 9
Source File: ShowDetailDialog.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings ( "unchecked" ) @Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final String detailViewId = event.getParameter ( "org.eclipse.scada.vi.details.showDetailDialog.id" ); final Map<String, String> parameters = (Map<String, String>)event.getObjectParameterForExecution ( "org.eclipse.scada.vi.details.showDetailDialog.parameters" ); try { if ( this.useWaitShell ) { openWithWaitShell ( getShell (), detailViewId, parameters ); } else { open ( getShell (), detailViewId, parameters ); } } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, "Failed to open detail view", e ), StatusManager.SHOW ); } return null; }
Example 10
Source File: EditEigenleistungUi.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@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 11
Source File: ExpandLevelHandler.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { // assumes to expand to level 1 if not specified int level = 1; String levelStr = event.getParameter(LEVEL); if (levelStr != null) { level = Integer.parseInt(levelStr); } IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof ContentOutline) { IPage page = ((ContentOutline) part).getCurrentPage(); if (page instanceof CommonOutlinePage) { CommonOutlinePage outlinePage = (CommonOutlinePage) page; // we want to expand to the specified level and collapse everything below outlinePage.collapseAll(); outlinePage.expandToLevel(level); } } return null; }
Example 12
Source File: SwitchPerspectiveHandler.java From tlaplus with MIT License | 5 votes |
public Object execute(final ExecutionEvent event) throws ExecutionException { final String perspectiveId = event.getParameter(PARAM_PERSPECTIVE_ID); if (perspectiveId == null) { return null; } // in theory, we're already in the correct state if (UIHelper.getActivePerspectiveId().equals(perspectiveId)) { return null; } final ICommandService service = (ICommandService) HandlerUtil.getActiveWorkbenchWindowChecked(event).getService( ICommandService.class); /** * opens a perspective by name */ UIHelper.runUIAsync(new Runnable() { public void run() { UIHelper.switchPerspective(perspectiveId); // update our radio button states ... get the service from // a place that's most appropriate // but do it in the same thread, and AFTER the UI has been updated service.refreshElements(event.getCommand().getId(), null); } }); return null; }
Example 13
Source File: OpenChartViewWithParameters.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private Chart makeConfiguration ( final ExecutionEvent event ) { final String queryTimespec = event.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ); //$NON-NLS-1$ final Chart configuration = Charts.makeDefaultConfiguration (); final XAxis x = configuration.getSelectedXAxis ().get ( 0 ); final YAxis y = configuration.getSelectedYAxis ().get ( 0 ); if ( queryTimespec != null && !queryTimespec.isEmpty () ) { final String toks[] = queryTimespec.split ( "[: ]+" ); //$NON-NLS-1$ final long now = System.currentTimeMillis (); final int left = Integer.parseInt ( toks[0] ); final int right = Integer.parseInt ( toks[1] ); x.setMinimum ( now - left ); x.setMaximum ( now + right ); if ( toks.length >= 4 ) { final double min = Double.parseDouble ( toks[2] ); final double max = Double.parseDouble ( toks[3] ); y.setMinimum ( min ); y.setMaximum ( max ); } } Charts.addCompositeQuality ( configuration ); return configuration; }
Example 14
Source File: GotoXBookmarkHandler.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
@Override public Object execute (ExecutionEvent event) throws ExecutionException { String markerNumber = event.getParameter("com.excelsior.xds.xbookmarks.commands.xBookmarkNumber"); //$NON-NLS-1$ gotoBookmark(Integer.parseInt(markerNumber)); return null; }
Example 15
Source File: OpenModuleHandler.java From tlaplus with MIT License | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { String moduleName = event.getParameter(PARAM_MODULE); openModule(moduleName); return null; }
Example 16
Source File: InstallOrganizationHandler.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { if (event != null) { final String id = event.getParameter("artifact"); final IRepositoryStore<?> organizationStore = RepositoryManager.getInstance() .getRepositoryStore(OrganizationRepositoryStore.class); IRepositoryFileStore file = organizationStore.getChild(id, true); if (file == null) { BonitaStudioLog.warning("Organization : " + id + " not found !", ActorsPlugin.PLUGIN_ID); final List<? extends IRepositoryFileStore> organizationFiles = organizationStore.getChildren(); if (organizationFiles.isEmpty()) { BonitaStudioLog.warning("No organization found in repository", ActorsPlugin.PLUGIN_ID); return null; } else { file = organizationFiles.get(0); } } Organization organization; try { organization = (Organization) file.getContent(); } catch (final ReadFileStoreException e1) { throw new ExecutionException("Failed to read organization content", e1); } final PublishOrganizationOperation op = publishOperation(organization); try { op.run(Repository.NULL_PROGRESS_MONITOR); } catch (final Exception e) { if (PlatformUI.isWorkbenchRunning()) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { new BonitaErrorDialog(Display.getDefault().getActiveShell(), "Error", "An error occured during synchronization", e).open(); } }); } throw new ExecutionException("", e); } } return null; }
Example 17
Source File: NumberOrTagConsisQAHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { boolean isMultiFile = false; IFile multiTempIFile = null; IEditorPart editorPart = HandlerUtil.getActiveEditor(event); // 改为布局 if (editorPart != null && editorPart instanceof XLIFFEditorImplWithNatTable) { String qaItem = event.getParameter("qaItemId"); XLIFFEditorImplWithNatTable nattable = (XLIFFEditorImplWithNatTable) editorPart; ArrayList<IFile> selectIFiles = new ArrayList<IFile>(); FileEditorInput input = (FileEditorInput) nattable.getEditorInput(); // 首先判断是否是合并打开的文件 if (nattable.isMultiFile()) { isMultiFile = true; } if (isMultiFile) { multiTempIFile = input.getFile(); List<String> multiFilesList = new XLFHandler().getMultiFiles(multiTempIFile); for (String filePath : multiFilesList) { selectIFiles.add(ResourceUtils.fileToIFile(filePath)); } } else { selectIFiles.add(input.getFile()); } QAModel model = new QAModel(); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); shell = window.getShell(); // 先调用方法,查看品质检查结果视图是否处于显示状态,如果是显示的,就删除数据 IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart view = workbenchPage.findView(QAResultViewPart.ID); if (view != null) { // 运行时,将结果视图中列表的数据清除 ((QAResultViewPart) view).clearTableData(); } QAResult qaResult = new QAResult(); // 存储品质检查的检查项 // model.setBatchQAItemIdList(getBatchQAItems()); // 存储品质检查的检查时不包括的文本段 model.setNotInclude(getNotIncludePara()); // 给品质检查结果视图发出通告,本次检查对象为合并打开文件 qaResult.firePropertyChange(isMultiFile, new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile)); if (isMultiFile) { model.setMuliFiles(true); model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles,multiTempIFile)); } else { model.setMuliFiles(false); } boolean isNumberQA = false; if (QAConstant.QA_NUMBER.equals(qaItem)) { isNumberQA = true; } else if (QAConstant.QA_TAG.equals(qaItem)) { isNumberQA = false; } List<String> fileList = new ArrayList<String>(); for(IFile iFIle : selectIFiles){ fileList.add(iFIle.getLocation().toOSString()); } qaResult.setFilePathList(fileList); HsMultiActiveCellEditor.commit(true); beginQA(selectIFiles, model, isNumberQA, qaResult); } return null; }
Example 18
Source File: CloneModelHandlerDelegate.java From tlaplus with MIT License | 4 votes |
/** * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { final TLCSpec spec = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class); Model model = null; /* * First try to get the model from the parameters. It is an optional * parameter, so it may not have been set. */ final String paramModelName = (String) event.getParameter(PARAM_MODEL_NAME); final String paramForeignModelName = (String) event.getParameter(PARAM_FOREIGN_FULLY_QUALIFIED_MODEL_NAME); final boolean isForeignClone = (paramForeignModelName != null); if (paramModelName != null) { // The name is given which means the user clicked the main menu // instead of the spec explorer. Under the constraint that only ever // a single spec can be open, lookup the current spec to eventually // get the corresponding model. model = spec.getModel(paramModelName); } else if (isForeignClone) { model = TLCModelFactory.getByName(paramForeignModelName); } else { /* * No parameter try to get it from active navigator if any */ final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection != null && selection instanceof IStructuredSelection) { // model model = (Model) ((IStructuredSelection) selection).getFirstElement(); } } if (model != null) { final InputDialog dialog = new InputDialog(UIHelper.getShellProvider().getShell(), "Clone model...", "Please input the new name of the model", spec.getModelNameSuggestion(model), new ModelNameValidator(spec)); dialog.setBlockOnOpen(true); if (dialog.open() == Window.OK) { final String chosenName = dialog.getValue(); if (isForeignClone) { if (model.copyIntoForeignSpec(spec, chosenName) == null) { throw new ExecutionException("Failed to copy with name " + chosenName + " from model " + model.getName() + " in spec " + model.getSpec().getName()); } } else { if (model.copy(chosenName) == null) { throw new ExecutionException("Failed to copy with name " + chosenName + " from model " + model.getName()); } } // Open the previously created model final Map<String, String> parameters = new HashMap<String, String>(); parameters.put(OpenModelHandler.PARAM_MODEL_NAME, chosenName); UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters); } } return null; }
Example 19
Source File: NumberOrTagConsisQAHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { boolean isMultiFile = false; IFile multiTempIFile = null; IEditorPart editorPart = HandlerUtil.getActiveEditor(event); // 改为布局 if (editorPart != null && editorPart instanceof XLIFFEditorImplWithNatTable) { String qaItem = event.getParameter("qaItemId"); XLIFFEditorImplWithNatTable nattable = (XLIFFEditorImplWithNatTable) editorPart; ArrayList<IFile> selectIFiles = new ArrayList<IFile>(); FileEditorInput input = (FileEditorInput) nattable.getEditorInput(); // 首先判断是否是合并打开的文件 if (nattable.isMultiFile()) { isMultiFile = true; } if (isMultiFile) { multiTempIFile = input.getFile(); List<String> multiFilesList = new XLFHandler().getMultiFiles(multiTempIFile); for (String filePath : multiFilesList) { selectIFiles.add(ResourceUtils.fileToIFile(filePath)); } } else { selectIFiles.add(input.getFile()); } QAModel model = new QAModel(); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); shell = window.getShell(); // 先调用方法,查看品质检查结果视图是否处于显示状态,如果是显示的,就删除数据 IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart view = workbenchPage.findView(QAResultViewPart.ID); if (view != null) { // 运行时,将结果视图中列表的数据清除 ((QAResultViewPart) view).clearTableData(); } QAResult qaResult = new QAResult(); // 存储品质检查的检查项 // model.setBatchQAItemIdList(getBatchQAItems()); // 存储品质检查的检查时不包括的文本段 model.setNotInclude(getNotIncludePara()); // 给品质检查结果视图发出通告,本次检查对象为合并打开文件 qaResult.firePropertyChange(isMultiFile, new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile)); if (isMultiFile) { model.setMuliFiles(true); model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles,multiTempIFile)); } else { model.setMuliFiles(false); } boolean isNumberQA = false; if (QAConstant.QA_NUMBER.equals(qaItem)) { isNumberQA = true; } else if (QAConstant.QA_TAG.equals(qaItem)) { isNumberQA = false; } HsMultiActiveCellEditor.commit(true); beginQA(selectIFiles, model, isNumberQA, qaResult); } return null; }
Example 20
Source File: JumpToNextHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { String jumpToNext = event.getParameter("JumpNextSegment"); if (jumpToNext == null) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int lastSelectRow = selectedRows[selectedRows.length - 1]; XLFHandler handler = xliffEditor.getXLFHandler(); int nextRow = -1; Shell shell = HandlerUtil.getActiveShell(event); if (jumpToNext.equalsIgnoreCase("JumpNextNonTranslation")) { // 下一未翻译文本段 nextRow = handler.getNextUntranslatedSegmentIndex(lastSelectRow); if (nextRow == -1) { MessageDialog.openInformation(shell, Messages.getString("handler.JumpToNextHandler.msgTitle"), Messages.getString("handler.JumpToNextHandler.msg1")); return null; } } else if (jumpToNext.equalsIgnoreCase("JumpNextQuestion")) { // 下一带疑问文本段 nextRow = handler.getNextQuestionSegmentIndex(lastSelectRow); if (nextRow == -1) { MessageDialog.openInformation(shell, Messages.getString("handler.JumpToNextHandler.msgTitle"), Messages.getString("handler.JumpToNextHandler.msg2")); return null; } } else if (jumpToNext.equalsIgnoreCase("JumpNextNote")) { // 下一带标注文本段 nextRow = handler.getNextNoteSegmentIndex(lastSelectRow); if (nextRow == -1) { MessageDialog.openInformation(shell, Messages.getString("handler.JumpToNextHandler.msgTitle"), Messages.getString("handler.JumpToNextHandler.msg3")); return null; } } xliffEditor.jumpToRow(nextRow); } return null; }