eclipse-rcp

Save an Eclipse editor programmatically

别等时光非礼了梦想. 提交于 2019-11-28 02:05:40
I am developing a plug-in. On clicking a button, I'd like to call the save method of Eclipse or call the save button on Eclipse toolbar. What is the way to do it? org.eclipse.ui.PlatformUI.getWorkbench().saveAll(..) should do the trick. If you want to save the active editor, please try IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart editor = page.getActiveEditor(); page.saveEditor(editor, true /* confirm */); Note that the elements in the navigation path may be null. I use this to save dirty editors for one or more projects: //Save all

Exception while trying to run eclipse product

十年热恋 提交于 2019-11-28 02:04:08
问题 I got the below exception while trying to run an eclipse product which exported without errors java.lang.NullPointerException at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.<init> any clue? Full stack trace: !SESSION 2013-07-23 02:08:52.676 ----------------------------------------------- eclipse.buildId=unknown java.version=1.7.0_21 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US Command-line arguments: -os linux -ws gtk -arch x86_64

Using ProgressMonitorDialog in Eclipse 4 properly

戏子无情 提交于 2019-11-28 01:09:47
问题 I have a set of APIs that do file operations e.g. saveToFile(CustomObject objectToSave); Since a file operation could be lengthy I decided that some indication should be shown to the user e.g. progress bar. I read about a ProgressMonitorDialog and so I tried it, but it doesn't exactly work as I need (or better I don't know how to use it properly). Currently I do: ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(theShell); try { progressDialog.run(false, true, new

How to remove a Category from Import wizard in Eclipse-RCP?

家住魔仙堡 提交于 2019-11-27 19:27:36
问题 I need to add an import wizard into my eclipse-rcp app. For that I would like to use existing wizard with only my categories. I found couple of examples in the Internet, but they didn't help much. My problem is that I have not only my category, but also the General category. I would like to remove it, if possible. Actually I have found one solution here, but it seems, that it is not working. I've tried to put provided code snippet in WorkbrenchWindowAdvisor and in ActionBarAdvisor and even

Change Menu Items Programmatically From Eclipse Plugin

限于喜欢 提交于 2019-11-27 18:50:52
I would like to be able to completely remove menu items upon startup of my eclipse plugin application. What I want to do is be able to add these menu items later depending on business logic based off of the user's actions. Is there a way to do this? I've looked at using contributions, but I feel like it's not going to be exactly what I want. If it can do what I need it to do, how do I go about using them? Thanks in advance for any assistance. Rich Seller You can obtain the Menu from the MenuManager and then modify the contributions. This snippet shows how to access the menu manager and remove

How to find out which feature contains a needed plug-in on an Eclipse download site

北城余情 提交于 2019-11-27 17:37:22
When developing an RCP application against a target platform, I ( and others ) often come across dependencies which need to be added from the Eclipse releases software site. Whenever a plug-in is included in my IDE, but not in my target platform, and I try to run the application from the product definition I get a warning screen, informing me that such and such bundle cannot be resolved. "No problem, just add the feature containing the plug-in from the Eclipse download site to the target platform, and add the needed plug-in to the Plug-in Project / Feature Project, whathaveyou...." But, AFAIK,

Recursively list all files in eclipse workspace programmatically

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:50:13
I am getting workspace by calling ResourcesPlugin.getWorkspace().getRoot() . How I can list all files(IFile) recursively in the workspace. The root, projects and folders in a workspace all implement the IContainer interface. Call IContainer.members() to get all the resources in the container. Something like: void processContainer(IContainer container) throws CoreException { IResource [] members = container.members(); for (IResource member : members) { if (member instanceof IContainer) processContainer((IContainer)member); else if (member instanceof IFile) processFile((IFile)member); } } 来源:

How remove pop-up menu contributions in eclipse RCP

妖精的绣舞 提交于 2019-11-27 15:14:58
I'm working in a RCP application and I have a view which data model are instances of IResources. When popup menu is visible I find commands contributed by others plugins I would like to remove. Sample of code: 1 MenuManager menuManager = new MenuManager(); 2 mm.setRemoveAllWhenShown(true); 3 Menu menu = menuManager.createContextMenu(this.treeViewer.getControl()); 4 this.treeViewer.getControl().setMenu(menu); 5 getSite().registerContextMenu(menuManager, this.treeViewer); If I comment line 5 context menu doesn't appear. Is posible use menu-contribution from plugin.xml and remove contributions of

How to launch the default (native) application for a given file from Java?

本秂侑毒 提交于 2019-11-27 14:13:13
I am displaying a list of files; i.e. xls, doc, pdf, odt etc., in my Java application (Eclipse RCP). When the user clicks on the file, I want to launch the appropriate (according to what the OS thinks) native application, just like it happens in Windows Explorer or the Finder. And while I am here: It would be nice to also display the same icons that Finder or Explorer use for the different file types. Is there a library or Eclipse plugin for this? Joseph Gordon What you want is java.awt.Desktop : Desktop.getDesktop().open( file ); I have found an API in Eclipse's SWT now that seems to do the

How to get the selected node in the package explorer from an Eclipse plugin

烂漫一生 提交于 2019-11-27 13:46:49
问题 I'm writing an Eclipse command plugin and want to retrieve the currently selected node in the package explorer view. I want to be able to get the absolute filepath, where the selected node resides on the filesystem (i.e. c:\eclipse\test.html), from the returned result. How do I do this ? 回答1: The first step is to get a selection service, e.g. from any view or editor like this: ISelectionService service = getSite().getWorkbenchWindow() .getSelectionService(); Or, as VonC wrote, you could get