I use CNF to make a view like Project Explorer in my RCP app. I'm done showing new menu and its submenu when user right clicks on a project in the view.
But when user click on a submenu (for this case, a method library going to be created), I need to know which project object that user has right-clicked on.
My question is how can I do that? Please help me.
Thank you all,
Nautilus
I think the wiki page E4/EAS/Selection should provide a way to query the right selection.
In Eclipse 3.x, the org.eclipse.ui.ISelectionService allows workbench parts to query the active selection in addition to attaching listeners for monitoring selection changes.
(see this example)
In the e4 world, selection is propagated with the ESelectionService.
Thank VonC,
Now I got the resource object that user has right-clicked on by doing this:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
CommonNavigator view = (CommonNavigator)page.findView("spe.ui.navigator.view");
selection = (IStructuredSelection) view.getSite().getSelectionProvider().getSelection();
But I'm really not happy completely with the solution. Note that I open a INewWizard after the action. In the INewWizard we have public void init(IWorkbench workbench, IStructuredSelection selection). I really want to use this method but I don't how to make it work.
Please, someone help me.
Thanks
Related
I know that there is a feature in Eclipse that shows the class name of the active element of the eclipse interface (for example, the class of the element selected with mouse). It is used to debug client plugin extensions, but I don't remember how to call it..
How can I get this feature? Which key combination I can use?
Thanks,
Michele.
You are probably thinking of the Plug-in Spy plug-in. Press Alt+Shift+F1 to see to details about the current selection. Alt+Shift+F2 lets to find out information about menu items.
I am creatng an netbeans RCP Application.
But i have one problem when opening the windows.
I have dynamicly data from the database, in different tables.
When i first open the window, the data is correct, but when i open it again, then the data has duplicated.
I even tested it with an buttonaction to change an label name, and when i close and open the window, then the new name will be displayed. How can i get it to work to show only the correct data.
I have tried different methodes to repaint an panel, updateui etc. but nothing changes.
Can somebody point me in the right direction?
Thanx in advance!
can you send some pieces of code?
If you use "open action" via annotation, then only one instance of the topcomponent will be created.
IF you use new TopComponent direct, then all is on your hand.
May be, you should use swingworker or utilities.attachInitJob
Jirka
How do I remove the "Quick Access" text entry from Juno's CDT toolbar? I never use it and it consumes valuable space on my laptop screen.
This bug Make "Quick access" optional and hidden by default covers it. It looks like it is not currently possible, I suggest you add your interest to the bug.
I looked for an answer to this question because Quick Access took a full row in the toolbar. Instead of removing it (Which requires too much hacking for my taste), I just removed a few toolbar buttons that I didn't use anyway, and the Quick Access shifted up among the rest of the buttons taking only an acceptable amount of space.
There is really no need for that many buttons for any one perspective. They should fit unless your screen is tiny. Customise this in Window -> Customize Prespective...
Here is a quick hack which doesn't require any plugin installation, instead you just need to add a few lines to your current layout's CSS file. Works perfectly for me in v4.2.2
Navigate to <ECLIPSE_HOME>/plugins/org.eclipse.platform_<VERSION>/css then open up the CSS file of whichever layout you are using, e.g. mine was e4_default.css. Now append the following snippet to the file:
#SearchField {
visibility:hidden;
}
Now just restart Eclipse and the box is gone.
*Edit
It appears that the layout file e4_basestyle.css is used universally, regardless of your current layout. Thus you should be able to add the above snippet to that file and this fix will be persistent, even if you change layouts.
In Luna this has been fixed.
You can just right click on Quick Access toolbar and click hide to hide it. Refer last few comments in https://bugs.eclipse.org/bugs/show_bug.cgi?id=362420
A solution inspired from :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319991
(With eclipse Juno 4.2) Just add this piece of code to your ApplicationWorkbenchWindowAdvisor class and call the method from preWindowOpen().
private void hideQuickAccess() {
UIJob job = new UIJob("hide quick access") {
#Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
if (window instanceof WorkbenchWindow) {
MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
for (MTrimElement element : topTrim.getChildren()) {
if ("SearchField".equals(element.getElementId())) {
((Control) element.getWidget()).dispose();
break;
}
}
}
return Status.OK_STATUS;
}
};
job.schedule();
It might not work unless changing the accessibility rule of the org.eclipse.e4.ui.model.workbench.source_0.10.1.v20120523-1955.jar.
To change this option, go to the Java build Path menu, find the jar, expand it and the option will appear.
NB: I'm not sure about the entailment of this last change, it could be 'not clean'.
Check out this plugin: https://github.com/atlanto/eclipse-4.x-filler#hide-quick-access-plug-in
Works with Eclipse Kepler release.
This plug-in adds a functionality to hide/show Quick Access textbox in the main toolbar.
Window ☞ Hide Quick Access
Solution for Version: Oxygen Release (4.7.0):
Save the icons you are constantly using by dragging them off the "Toolbar" e.g. left/right/under to the Editor.
Then toggle: Window > Appearance > Hide/Show Toolbar
Done. :)
Type "toggle toolbar" in the quick access window (yes, that very thing that annoys us) and it'll be gone. C.f.
I have an eclipse RCP application that uses and Editor Area. I have a few things that I would like to do programatically but cannot find any documentation:
1) Do not restore editor sash layout. I.e., I like to use rcp saveAndRestore functionality, but for my perspectives, views, and other momentos. I do not however want to restore the editor area multiple tab groups at all. I choose not to implement the IPersistableEditor interface, and therefore my editor sessions are not restored, but when my application restarts, it still has split windows (swt sashes for multiple tab groups), etc, and i wish it was just 1 editor area tab group like default.
2) I would like to programaticaly split/duplicate an editor into another tab group, for example I would like a button that says "Split Horizontal" and that opens a new editor in a new tab group beside the current one.
Any help is much appreciated! Happy Coding!
/P
1) Funny, seems like a bug in the platform.
You can explicitly close all editors upon workbench window close. One option to do this would be to override the preWindowShellClose method in your WorkbenchWindowAdvisor:
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
#Override
public boolean preWindowShellClose() {
getWindowConfigurer().getWindow().getActivePage().closeAllEditors(true);
return super.preWindowShellClose();
}
}
If you don't have access to the ApplicationWorkbenchWindowAdvisor, you can try to do the same with the IPerspectiveListenerX
2) I think there is no public API for this. The editor area behavior is defined in the presentation factory (see org.eclipse.ui.presentationFactories extension-point). You could clone the RCP standard presentation and implement the desired split-editor-area-on-demand functionality.
I want to develope plug-ins in eclipse,the function of the plug-ins is when right-click menu the button opens a perspective.I find the class which is "openPerspectiveMenu" has not been used,please tell me the alternative.
thank you!
The way to open a perspective programmatically is to call:
IWorkbench.showPerspective(String perspectiveId,
IWorkbenchWindow window)
throws WorkbenchException
Javadoc here.
See http://wiki.eclipse.org/FAQ_How_do_I_show_a_given_perspective%3F for details.