org.eclipse.ui.PlatformUI Java Examples
The following examples show how to use
org.eclipse.ui.PlatformUI.
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: CreateSubdiagramCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public boolean isEnabled() { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (activeWorkbenchWindow == null) return false; ISelection selection = activeWorkbenchWindow.getActivePage().getSelection(); if (selection == null) return false; Node unwrap = unwrap(selection); if (unwrap == null) { return false; } State state = (State) unwrap.getElement(); if (state==null || state.isComposite()) return false; BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(unwrap); if (inlineStyle != null && !inlineStyle.isBooleanValue()) return false; return super.isEnabled(); }
Example #2
Source File: ProcessDiagramUpdateCommand.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() != 1) { return null; } if (structuredSelection.getFirstElement() instanceof EditPart && ((EditPart) structuredSelection.getFirstElement()).getModel() instanceof View) { EObject modelElement = ((View) ((EditPart) structuredSelection.getFirstElement()).getModel()) .getElement(); List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement); for (Iterator it = editPolicies.iterator(); it.hasNext();) { CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next(); nextEditPolicy.refresh(); } } } return null; }
Example #3
Source File: ImportProjectWizardPage2.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 获取所有已经被打开的文件 * @return */ private Map<IFile, IEditorPart> getAllOpenedIFile(){ Map<IFile, IEditorPart> openedIfileMap = new HashMap<IFile, IEditorPart>(); IEditorReference[] referenceArray = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); for(IEditorReference reference : referenceArray){ IEditorPart editor = reference.getEditor(true); // 如果这是一个 nattable 编辑器 if (XLIFF_EDITOR_ID.equals(editor.getSite().getId())) { IXliffEditor xlfEditor = (IXliffEditor)editor; if (xlfEditor.isMultiFile()) { for(File file : xlfEditor.getMultiFileList()){ openedIfileMap.put(ResourceUtils.fileToIFile(file.getAbsolutePath()), editor); } }else { openedIfileMap.put(((FileEditorInput)editor.getEditorInput()).getFile(), editor); } }else { // 其他情况,直接将文件丢进去就行了 openedIfileMap.put(((FileEditorInput)editor.getEditorInput()).getFile(), editor); } } return openedIfileMap; }
Example #4
Source File: DefaultTemplateProjectCreator.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { SubMonitor subMonitor = SubMonitor.convert(monitor, projectFactories.size()); try { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); for (ProjectFactory projectFactory : projectFactories) { projectFactory.setWorkbench(workbench); projectFactory.setWorkspace(workspace); projectFactory.createProject(subMonitor, null); subMonitor.worked(1); } } finally { subMonitor.done(); } }
Example #5
Source File: RouteTreeLabelProvider.java From eip-designer with Apache License 2.0 | 6 votes |
@Override public Image getImage(Object element) { if (element instanceof IProject) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT); } if (element instanceof IResource) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); } if (element instanceof Route) { Bundle bundle = FrameworkUtil.getBundle(RouteTreeLabelProvider.class); URL url = FileLocator.find(bundle, new Path("icons/obj16/Route.gif"), null); ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url); return imageDcr.createImage(); } return null; }
Example #6
Source File: XtextPluginImages.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private static final void initializeImageMaps() { if(imagesInitialized) return; annotationImagesFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, get(OBJ_FIXABLE_ERROR)); annotationImagesFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, get(OBJ_FIXABLE_WARNING)); annotationImagesFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, get(OBJ_FIXABLE_INFO)); ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages(); Image error = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); Image warning = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); Image info = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); annotationImagesNonFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, error); annotationImagesNonFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, warning); annotationImagesNonFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, info); Display display = Display.getCurrent(); annotationImagesDeleted.put(XtextEditor.ERROR_ANNOTATION_TYPE, new Image(display, error, SWT.IMAGE_GRAY)); annotationImagesDeleted.put(XtextEditor.WARNING_ANNOTATION_TYPE, new Image(display, warning, SWT.IMAGE_GRAY)); annotationImagesDeleted.put(XtextEditor.INFO_ANNOTATION_TYPE, new Image(display, info, SWT.IMAGE_GRAY)); imagesInitialized = true; }
Example #7
Source File: WakaTime.java From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static String getActiveProject() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return null; if (window.getPartService() == null) return null; if (window.getPartService().getActivePart() == null) return null; if (window.getPartService().getActivePart().getSite() == null) return null; if (window.getPartService().getActivePart().getSite().getPage() == null) return null; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return null; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return null; IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput(); IProject project = null; if (input instanceof FileEditorInput) { project = ((FileEditorInput)input).getFile().getProject(); } if (project == null) return null; return project.getName(); }
Example #8
Source File: WorkspaceAction.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Most SVN workspace actions modify the workspace and thus should * save dirty editors. * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors() */ protected boolean needsToSaveDirtyEditors() { IResource[] selectedResources = getSelectedResources(); if (selectedResources != null && selectedResources.length > 0) { IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); for (IEditorReference editorReference : editorReferences) { if (editorReference.isDirty()) { try { IEditorInput editorInput = editorReference.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFile file = ((IFileEditorInput)editorInput).getFile(); if (needsToSave(file, selectedResources)) { return true; } } } catch (PartInitException e) {} } } } return false; }
Example #9
Source File: PromoteTempWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void createControl(Composite parent) { Composite result= new Composite(parent, SWT.NONE); setControl(result); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.verticalSpacing= 8; result.setLayout(layout); addFieldNameField(result); addVisibilityControl(result); addInitizeInRadioButtonGroup(result); addDeclareStaticCheckbox(result); addDeclareFinalCheckbox(result); Dialog.applyDialogFont(result); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROMOTE_TEMP_TO_FIELD_WIZARD_PAGE); updateStatus(); }
Example #10
Source File: EditorUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns an array of all editors that have an unsaved content. If the identical content is * presented in more than one editor, only one of those editor parts is part of the result. * @param skipNonResourceEditors if <code>true</code>, editors whose inputs do not adapt to {@link IResource} * are not saved * * @return an array of dirty editor parts * @since 3.4 */ public static IEditorPart[] getDirtyEditors(boolean skipNonResourceEditors) { Set<IEditorInput> inputs= new HashSet<IEditorInput>(); List<IEditorPart> result= new ArrayList<IEditorPart>(0); IWorkbench workbench= PlatformUI.getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchPage[] pages= windows[i].getPages(); for (int x= 0; x < pages.length; x++) { IEditorPart[] editors= pages[x].getDirtyEditors(); for (int z= 0; z < editors.length; z++) { IEditorPart ep= editors[z]; IEditorInput input= ep.getEditorInput(); if (inputs.add(input)) { if (!skipNonResourceEditors || isResourceEditorInput(input)) { result.add(ep); } } } } } return result.toArray(new IEditorPart[result.size()]); }
Example #11
Source File: XFindPanel.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
protected ToolItem createClose(final ToolBar bar) { final ToolItem close = new ToolItem(bar, SWT.PUSH); final ImageDescriptor image = PlatformUI.getWorkbench() .getSharedImages() .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE); if (image != null) close.setImage(image.createImage()); close.setToolTipText(Messages.XFindPanel_Close_tooltip); //$NON-NLS-1$ close.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { hidePanel(); } }); return close; }
Example #12
Source File: LayoutActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public LayoutAction(PackageExplorerPart packageExplorer, boolean flat) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ fIsFlatLayout= flat; fPackageExplorer= packageExplorer; if (fIsFlatLayout) { setText(PackagesMessages.LayoutActionGroup_flatLayoutAction_label); JavaPluginImages.setLocalImageDescriptors(this, "flatLayout.gif"); //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION); } else { setText(PackagesMessages.LayoutActionGroup_hierarchicalLayoutAction_label); JavaPluginImages.setLocalImageDescriptors(this, "hierarchicalLayout.gif"); //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION); } setChecked(packageExplorer.isFlatLayout() == fIsFlatLayout); }
Example #13
Source File: WordsFA.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 输出字数统计结果到结果窗体中 * @param WordsFAResultMap */ public void printWordsFAReslut() { String htmlPath = createFAResultHtml(); try { model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e1) { e1.printStackTrace(); } final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath)); if (PlatformUI.getWorkbench().isClosing()) { return; } Display.getDefault().asyncExec(new Runnable() { public void run() { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true); } catch (PartInitException e) { logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log5"), e); e.printStackTrace(); } } }); }
Example #14
Source File: XLIFFEditor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 启动编辑器。 * * @param site * the site * @param input * the input * @throws PartInitException * the part init exception * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, * org.eclipse.ui.IEditorInput) */ public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("init(IEditorSite site, IEditorInput input)"); } setSite(site); setInput(input); // 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性 setPartName(input.getName()); Image oldTitleImage = titleImage; if (input != null) { IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null; titleImage = imageDesc != null ? imageDesc.createImage() : null; } setTitleImage(titleImage); if (oldTitleImage != null && !oldTitleImage.isDisposed()) { oldTitleImage.dispose(); } getSite().setSelectionProvider(this); }
Example #15
Source File: TermViewerBodyMenu.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
IProject getCurentProject() { IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if (null == activeEditor) { return null; } if (activeEditor instanceof IXliffEditor) { IFile file = ((FileEditorInput) activeEditor.getEditorInput()).getFile(); return file.getProject(); } return null; }
Example #16
Source File: KeyController2.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("restriction") public void filterDupliteBind(){ IWorkbench workbench = PlatformUI.getWorkbench(); IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); BindingService service =(BindingService)bindingService; BindingManager bindingManager = service.getBindingManager(); //service.getBindingManager(). Binding[] bindings = bindingManager.getBindings(); List<Binding> bindTemp = new ArrayList<Binding>(); List<String> ids = new ArrayList<String>(); for(Binding bind : bindings){ if(null ==bind){ continue; } ParameterizedCommand command = bind.getParameterizedCommand(); if(null == command){ continue; } String id = command.getId(); if(!ids.contains(id)){ ids.add(id); bindTemp.add(bind); } } bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()])); }
Example #17
Source File: AddJavaDocStubAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new <code>AddJavaDocStubAction</code>. The action requires * that the selection provided by the site's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param site the site providing context information for this action */ public AddJavaDocStubAction(IWorkbenchSite site) { super(site); setText(ActionMessages.AddJavaDocStubAction_label); setDescription(ActionMessages.AddJavaDocStubAction_description); setToolTipText(ActionMessages.AddJavaDocStubAction_tooltip); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ADD_JAVADOC_STUB_ACTION); }
Example #18
Source File: CorrectionCommandHandler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String getShortCutString(String proposalId) { if (proposalId != null) { IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); if (bindingService != null) { TriggerSequence[] activeBindingsFor= bindingService.getActiveBindingsFor(proposalId); if (activeBindingsFor.length > 0) { return activeBindingsFor[0].format(); } } } return null; }
Example #19
Source File: LangContentAssistProcessor.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected KeySequence getGroupingIterationBinding() { IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); TriggerSequence binding = bindingSvc.getBestActiveBindingFor( ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); if(binding instanceof KeySequence) return (KeySequence) binding; return null; }
Example #20
Source File: JavadocHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public BackAction(BrowserInformationControl infoControl) { fInfoControl= infoControl; setText(JavaHoverMessages.JavadocHover_back); ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK)); setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED)); update(); }
Example #21
Source File: TypeScriptEditor.java From typescript.java with MIT License | 5 votes |
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); if (isMarkingOccurrences()) { installOccurrencesFinder(false); } PlatformUI.getWorkbench().addWindowListener(fActivationListener); editorSelectionChangedListener = new EditorSelectionChangedListener(); editorSelectionChangedListener.install(getSelectionProvider()); // if (isActivateCodeLenses()) { // installCodeLenses(); // } }
Example #22
Source File: DebugStartupClass.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Returns the current active report editor in current active page or * current active workbench. * * @return */ public static FormEditor getActiveReportEditor( ) { IWorkbenchWindow window = PlatformUI.getWorkbench( ) .getActiveWorkbenchWindow( ); if ( window != null ) { IWorkbenchPage pg = window.getActivePage( ); if ( pg != null ) { IEditorPart editor = pg.getActiveEditor( ); if ( editor != null ) { if ( editor instanceof ReportEditorProxy ) { IEditorPart part = ( (ReportEditorProxy) editor ).getEditorPart( ); if ( part instanceof FormEditor ) { return (FormEditor) part; } } else if ( editor instanceof FormEditor ) { return (FormEditor) editor; } } } } return null; }
Example #23
Source File: OpenEngineLogCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Boolean execute(final ExecutionEvent event) throws ExecutionException { final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final File logFile = BOSWebServerManager.getInstance().getBonitaLogFile(); if (logFile != null && logFile.exists()) { IFileStore fileStore; try { fileStore = EFS.getLocalFileSystem().getStore(logFile.toURI()); final File localFile = fileStore.toLocalFile(EFS.NONE, Repository.NULL_PROGRESS_MONITOR); final long fileSize = localFile.length(); if (fileSize < MAX_FILE_SIZE) { IDE.openEditorOnFileStore(page, fileStore); } else { Program textEditor = Program.findProgram("log"); if (textEditor == null) { textEditor = Program.findProgram("txt"); } if (textEditor != null) { final boolean success = textEditor.execute(localFile.getAbsolutePath()); if (!success) { showWarningMessage(localFile); } } else { showWarningMessage(localFile); } } return Boolean.TRUE; } catch (final Exception e) { BonitaStudioLog.error(e); return Boolean.FALSE; } } else { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.unableTofindLogTitle, Messages.unableTofindLogMessage); return Boolean.FALSE; } }
Example #24
Source File: DeleteDiagramWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected MainProcess getDiagramInEditor() { if (PlatformUI.getWorkbench().getWorkbenchWindows() == null || PlatformUI.getWorkbench().getWorkbenchWindows().length == 0) { return null; } final IEditorPart editor = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getActiveEditor(); final boolean isADiagram = editor != null && editor instanceof DiagramEditor; if (isADiagram) { final EObject root = ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement(); final MainProcess mainProc = ModelHelper.getMainProcess(root); return mainProc; } return null; }
Example #25
Source File: AcceptTerm7.java From translationstudio8 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 { IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView( "net.heartsome.cat.ts.ui.term.view.termView"); if (viewPart != null && viewPart instanceof ITermViewPart) { ITermViewPart matchView = (ITermViewPart) viewPart; matchView.acceptTermByIndex(6); } return null; }
Example #26
Source File: CascadingParameterGroupNodeProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
protected boolean performEdit( ReportElementHandle handle ) { CascadingParametersDialog dialog = new CascadingParametersDialog( PlatformUI.getWorkbench( ) .getDisplay( ) .getActiveShell( ), Messages.getString("ParameterNodeProvider.dial.title.editCascading") ); //$NON-NLS-1$ dialog.setInput( handle ); return dialog.open( ) == Dialog.OK; }
Example #27
Source File: PopupAppender.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected void append(LoggingEvent event) { if (event == null || !event.getLevel().isGreaterOrEqual(Level.ERROR)) return; if (!PlatformUI.isWorkbenchRunning() || openPopupCount.get() >= MAX_POPUPS) { return; } try { openPopupCount.incrementAndGet(); new PopupTokenWatch().start(); String message = event.getMessage() != null ? event.getMessage().toString() + "<br/>" : ""; message += "<b>See the log file (under Help)" + " for further information.</b>"; Popup.error("An internal error occurred", message); } catch (Exception e) { // If the creation of the popup creates an error itself // handle it here. if (failureCounter.incrementAndGet() > 3) { log.warn("Showing of failed error popups " + "stopped because of repetetive failures"); } else { log.error("Show message failed", e); } } }
Example #28
Source File: OpenTraceHandler.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isEnabled() { // Check if we are closing down final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return false; } // Get the selection final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final IWorkbenchPart part = page.getActivePart(); if (part == null) { return false; } final ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); if (selectionProvider == null) { return false; } final ISelection selection = selectionProvider.getSelection(); // Make sure there is only one selection and that it is a trace fTrace = null; if (selection instanceof TreeSelection) { final TreeSelection sel = (TreeSelection) selection; // There should be only one item selected as per the plugin.xml final Object element = sel.getFirstElement(); if (element instanceof TmfTraceElement) { fTrace = (TmfTraceElement) element; } } // We only enable opening from the Traces folder for now return (fTrace != null); }
Example #29
Source File: ExtensionContextInjectionFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static IEclipseContext workbenchContext() { if (PlatformUI.isWorkbenchRunning()) { final Workbench workbench = (Workbench) PlatformUI.getWorkbench(); if (workbench != null) { final IEclipseContext context = workbench.getContext(); checkNotNull(context, "Workbench eclipse context is null"); return context; } throw new IllegalStateException("No workbench available"); } return headlessContext(); }
Example #30
Source File: TmxEditorViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public void init(IViewSite site) throws PartInitException { super.init(site); this.openCloseListener = new ArrayList<TmxEditorOpenCloseListener>(); undoRedoActionGroup = new UndoRedoActionGroup(getSite(), getSite().getWorkbenchWindow().getWorkbench() .getOperationSupport().getUndoContext(), true); PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener); }