Java Code Examples for org.eclipse.ui.handlers.HandlerUtil#getActiveShell()
The following examples show how to use
org.eclipse.ui.handlers.HandlerUtil#getActiveShell() .
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: ExportHandler.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
/** * Tries to load the wizard for the LaTex export. If a project can be loaded, it will be opened. */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { if(tryLoadingProjectFiles(event)) { Shell activeShell = HandlerUtil.getActiveShell(event); IWizard wizard = new LatexExportWizard(); WizardDialog wizardDialog = new WizardDialog(activeShell, wizard); wizardDialog.open(); } else { // String errorMessage = "No taxonomy is present. Please load a taxonomy to be able to use the LaTex export."; // if (!ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy().isPresent()) { // MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", // errorMessage); // return null; // } else { // // } } return null; }
Example 2
Source File: OpenXtextElementHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell activeShell = HandlerUtil.getActiveShell(event); ListDialog searchDialog = createSearchDialog(event, activeShell, searchEngine); int result = searchDialog.open(); if (result == Window.OK) { try { Object[] selections = searchDialog.getResult(); if (selections != null && selections.length > 0) { Object selection = selections[0]; if (selection instanceof IEObjectDescription) { IEObjectDescription selectedObjectDescription = (IEObjectDescription) selection; uriEditorOpener.open(selectedObjectDescription.getEObjectURI(), true); } } } catch (Exception e) { LOG.error("Error opening editor", e); throw new ExecutionException("Error opening editor", e); } } return null; }
Example 3
Source File: SRXConfigrationHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); Shell shell = HandlerUtil.getActiveShell(event); // String srxConfigLocation = ADConstants.configLocation + File.separator + ADConstants.AD_SRXConfigFolder; // // 首先验证本次所要用到的SRX(分段规则)文件是否存在于工作空间中。如果没有,那么将相关文件拷贝到指定工作空间的目录 // File srxConfigFolderFile = new File(srxConfigLocation); // // 如果不存在,则将安装文件中的相关配置文件复制到工作工间 // if (!srxConfigFolderFile.exists() || !srxConfigFolderFile.isDirectory() // || new File(srxConfigLocation).list().length <= 0) { // String srcLocation = Platform.getConfigurationLocation().getURL().getPath() + "net.heartsome.cat.converter" // + System.getProperty("file.separator") + "srx"; // try { // ResourceUtils.copyDirectory(new File(srcLocation), new File(srxConfigLocation)); // } catch (Exception e) { // e.printStackTrace(); // } // // File _srxConfigFolderFile = new File(srxConfigLocation); // if (!_srxConfigFolderFile.exists() || !_srxConfigFolderFile.isDirectory()) { // MessageDialog.openInformation(shell, Messages.getString("handlers.SRXConfigrationHandler.msgTitle"), // Messages.getString("handlers.SRXConfigrationHandler.msg")); // return null; // } // } SrxConfigurationDialog dialog = new SrxConfigurationDialog(shell); dialog.open(); return null; }
Example 4
Source File: MethodGeneratorHandler.java From jenerate with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell parentShell = HandlerUtil.getActiveShell(event); IEditorPart editor = HandlerUtil.getActiveEditor(event); ISelection currentSelection = HandlerUtil.getCurrentSelection(event); IWorkingCopyManager manager = JavaUI.getWorkingCopyManager(); ICompilationUnit compilationUnit = manager.getWorkingCopy(editor.getEditorInput()); generate(event.getCommand().getId(), currentSelection, compilationUnit, parentShell); return null; }
Example 5
Source File: AboutHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShell(event); String version = System.getProperty("TSEdition"); String version2 = System.getProperty("TSVersionDate"); if (version == null || version2 == null || version.equals("") || version2.equals("")) { MessageDialog.openInformation(shell, Messages.getString("dialog.AboutDialog.msgTitle"), Messages.getString("dialog.AboutDialog.msg")); PlatformUI.getWorkbench().close(); } else { AboutDialog dialog = new AboutDialog(shell); dialog.open(); } return null; }
Example 6
Source File: ExportTbxHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { SystemResourceUtil.load(); ExportTbxDialog dialog = new ExportTbxDialog(HandlerUtil.getActiveShell(event)); dialog.open(); return null; }
Example 7
Source File: OpenLocalDocumentsHandler.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException{ if (LocalDocumentServiceHolder.getService().isPresent()) { LocalDocumentsDialog dialog = new LocalDocumentsDialog(HandlerUtil.getActiveShell(event), LocalDocumentServiceHolder.getService().get()); dialog.open(); } return null; }
Example 8
Source File: AttachSourcesHandler.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
@Override public Object execute( ExecutionEvent event ) throws ExecutionException { Shell activeShell = HandlerUtil.getActiveShell(event); IWizard wizard = new AttachSourcesWizard(); WizardDialog dialog = new WizardDialog(activeShell, wizard); dialog.open(); return null; }
Example 9
Source File: SettingsHandler.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { SettingsDialog settingsDialog = new SettingsDialog(HandlerUtil.getActiveShell(event), SWT.DIALOG_TRIM); try { IViewPart part = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView("chart.view.chartview"); settingsDialog.setViewPart(part); } catch (PartInitException e) { e.printStackTrace(); } settingsDialog.open(); return null; }
Example 10
Source File: MergeTmxHanlder.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { MergeTmxDialog dialog = new MergeTmxDialog(HandlerUtil.getActiveShell(event)); dialog.open(); return null; }
Example 11
Source File: ExtensionWizardHandler.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell activeShell = HandlerUtil.getActiveShell(event); NewExtensionWizard newWizard = new NewExtensionWizard(); newWizard.setCurrentSelection(HandlerUtil.getCurrentSelection(event)); WizardDialog dialog = new WizardDialog(activeShell, newWizard); dialog.open(); return null; }
Example 12
Source File: EditTemplatePropertiesHandler.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { final Shell shell = HandlerUtil.getActiveShell(event); final ISelection selection = HandlerUtil.getCurrentSelection(event); if (!selection.isEmpty() && selection instanceof IStructuredSelection) { final IFile templateFile = (IFile) ((IStructuredSelection) selection).getFirstElement(); final URI templateURI = URI.createPlatformResourceURI(templateFile.getFullPath().toString(), true); WizardDialog dialog = new WizardDialog(shell, new TemplateCustomPropertiesWizard(templateURI)) { @Override public void create() { super.create(); getShell().setText("Template properties"); } @Override public void showPage(IWizardPage page) { super.showPage(page); getShell().setText("Template properties"); } }; dialog.open(); } return null; }
Example 13
Source File: PairFileHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { PairFileBean bean = new PairFileBean(); PairFileDialog dialog = new PairFileDialog(HandlerUtil.getActiveShell(event), bean); if (Dialog.OK == dialog.open()) { } return null; }
Example 14
Source File: ValidateHandler.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override protected void execute(ExecutionEvent event, final Generation generation) { final Shell shell = HandlerUtil.getActiveShell(event); final Job job = new ValidateJob(generation, shell); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(); }
Example 15
Source File: XmlConverterConfigurationHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { root = ResourcesPlugin.getWorkspace().getRoot(); String configFileLocation = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).toOSString(); Shell shell = HandlerUtil.getActiveShell(event); // 首先验证安装文件中本次所需要的文件是否转存至工作工间,如果没有,就转过去。 File xmlConfigFolderFile = new File(configFileLocation); String tgtLocation = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).toOSString(); // 如果不存在,则将安装文件中的相关配置文件复制到工作工间 if (!xmlConfigFolderFile.exists() || !xmlConfigFolderFile.isDirectory() || new File(tgtLocation).list().length <= 0) { String srcLocation = Platform.getConfigurationLocation().getURL().getPath() + "net.heartsome.cat.converter" + System.getProperty("file.separator") + "ini"; try { ResourceUtils.copyDirectory(new File(srcLocation), new File(tgtLocation)); } catch (Exception e) { LOGGER.error("", e); } File _xmlConfigFolderFile = new File(configFileLocation); if (!_xmlConfigFolderFile.exists() || !_xmlConfigFolderFile.isDirectory()) { MessageDialog.openInformation(shell, Messages.getString("handlers.XmlConverterConfigurationHandler.msgTitle"), Messages.getString("handlers.XmlConverterConfigurationHandler.msg")); return null; } } XmlConverterConfigurationDialog dialog = new XmlConverterConfigurationDialog(shell, configFileLocation); dialog.open(); return null; }
Example 16
Source File: ImportExternal.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public Object execute(ExecutionEvent event) throws ExecutionException { XLIFFEditorImplWithNatTable xliffEditor = null; final Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { xliffEditor = (XLIFFEditorImplWithNatTable) editor; } if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) { // 导航视图处于激活状态 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view"); StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider() .getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) { // nattable 处于激活状态 IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); IEditorInput editorInput = ((IEditorPart) part).getEditorInput(); IFile iFile = (IFile) editorInput.getAdapter(IFile.class); if (xliffEditor.isMultiFile()) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2")); return null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } final ImportConfig config = new ImportConfig(); config.setShell(shell); config.set_xliff(file == null ? "" : file.getFullPath().toOSString()); config.setXliffEditor(xliffEditor); config.setXliffFile(file == null ? "" : ResourceUtils.iFileToOSPath(file)); HsMultiActiveCellEditor.commit(true); ImportExternalDialog dialog = new ImportExternalDialog(shell, xliffEditor, config); if (Dialog.OK == dialog.open()) { config.doImport(); if (xliffEditor != null) { // reopen if need if (xliffEditor.getXLFHandler().getVnMap().get(config.getXliffFile()) != null) { Map<String, Object> resultMap = xliffEditor.getXLFHandler().openFile(config.getXliffFile()); if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap .get(Constant.RETURNVALUE_RESULT)) { // 打开文件失败。 MessageDialog.openWarning( shell, Messages.getString("all.dialog.warning"), MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff())); LOGGER.error(MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff())); return null; } xliffEditor.reloadData(); HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor); } } } return null; }
Example 17
Source File: ImportRTFHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { String tshelp = System.getProperties().getProperty("TSHelp"); String tsstate = System.getProperties().getProperty("TSState"); if (tshelp == null || !"true".equals(tshelp) || tsstate == null || !"true".equals(tsstate)) { LoggerFactory.getLogger(ImportRTFHandler.class).error("Exception:key hs008 is lost.(Can't find the key)"); System.exit(0); } XLIFFEditorImplWithNatTable xliffEditor = null; Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { xliffEditor = (XLIFFEditorImplWithNatTable) editor; } if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) { // 导航视图处于激活状态 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view"); StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider() .getSelection(); // ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("handler.ImportRTFHandler.msg.title"), Messages.getString("handler.ImportRTFHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) { // nattable 处于激活状态 IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); IEditorInput editorInput = ((IEditorPart) part).getEditorInput(); IFile iFile = (IFile) editorInput.getAdapter(IFile.class); if (xliffEditor.isMultiFile()) { MessageDialog.openInformation(shell, Messages.getString("handler.ImportRTFHandler.msg.title"), Messages.getString("handler.ImportRTFHandler.msg2")); return null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } ImportRTFDialog dialog = new ImportRTFDialog(shell, xliffEditor, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file)); dialog.open(); return null; }
Example 18
Source File: CSV2TMXConverterHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { CSV2TMXConverterDialog dialog = new CSV2TMXConverterDialog(HandlerUtil.getActiveShell(event)); dialog.open(); return null; }
Example 19
Source File: CSV2TMXConverterHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { CSV2TMXConverterDialog dialog = new CSV2TMXConverterDialog(HandlerUtil.getActiveShell(event)); dialog.open(); return null; }
Example 20
Source File: AbstractExportHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public boolean initExportConfig(ExecutionEvent event) throws ExecutionException { config = new ExportConfig(); Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {// 导航视图处于激活状态 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view"); StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider() .getSelection(); if (selection != null && !selection.isEmpty()) { for (Object obj : selection.toList()) { if (obj instanceof IFile) { addXLFFile((IFile) obj); } else if (obj instanceof IFolder) { traversalFile((IFolder) obj); } else if (obj instanceof IProject) { IProject proj = (IProject) obj; traversalFile(proj.getFolder(XLF)); } } if (config.getProjects() == null || config.getProjects().size() < 1) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("xlf2tmx.info.notfoundxlf")); return false; } } } else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {// nattable 处于激活状态 IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); IEditorInput editorInput = ((IEditorPart) part).getEditorInput(); IFile iFile = (IFile) editorInput.getAdapter(IFile.class); IEditorPart editor = HandlerUtil.getActiveEditor(event); IXliffEditor xliffEditor = (IXliffEditor) editor; if (xliffEditor.isMultiFile()) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxHandler.msg2")); return false; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { addXLFFile(iFile); } } return true; }