So, I'm working on an Eclipse Plugin which includes a custom view based on analysis of source code. The majority of the time, it works great. However, if I quit Eclipse with that view open, when I reopen it, it runs into an error with either IWorkbenchWindow.getActivePage() or IWorkbenchPage.getEditorReferences() returning null. This inconsistency seems to be because the view has the focus when Eclipse quits and is the first thing that Eclipse tries to reconstruct on start up. the focus is on a non-window shell (I don't fully understand this, but that's what this said). Is there a workaround so that I can ensure that Eclipse fully loads its IWorkbenchWindow before my custom plugin regardless of what has the focus when Eclipse closes?
Thanks
You can consider using the site instead: getSite().getPage()...
Tonny Madsen pointed out in the comments that, from within a View, I can access the Active Page from getSite().getPage(), which solved the issues.
Related
I have to use eclipse 3.1. I'm using it in an Ubuntu 11.04 VM (VMWare). It seems that every view I use is initially blank/empty until I close and reopen it. This is annoying but I can deal with it.
The problem is this trick doesn't work with the view for source code files.
Has anyone ever seen a similar issue? Are there any work-arounds?
I don't know if it is related. But the main menu is also initially missing. If I resize the application window, the main menu reappears.
This is a known issue with newer Linux desktops when using older versions of Eclipse.
The GTK widget set changed the default way it renders widgets. This causes versions of Eclipse that were compiled against the old GTK library to experience empty views like you saw as well as problems with ignoring some mouse clicks on buttons.
If you set this environment variable before launching Workbench then it should resolve the problem:
export GDK_NATIVE_WINDOWS=1
I verified this on Ubuntu 11.04 with Workbench 2.6 and the problem went away after I set the variable.
Best regards,
Rob
Our Eclipse RCP application was originally built in the 3.1/3.2 era and was running on 3.2 until we switched to 3.6 recently. Its IApplication runs via PlatformUI.createAndRunWorkbench(...). The WorkbenchAdvisor we pass to that function overridescreateWorkbenchWindowAdvisor(...) to return a WorkbenchWindowAdvisor whose createActionBarAdvisor(...) returns an ActionBarAdvisor.
This ActionBarAdvisor's makeActions(...) creates and register()s a bunch of org.eclipse.jface.action.Actions, many of which do things like setAccelerator(SWT.CTRL | 'O'); in their constructors. The Actions are subsequently installed in the ActionBarAdvisor's fillMenuBar(...) and fillCoolBar(...) methods.
The problem we are having (now that we are on Eclipse RCP 3.6) is that these accelerators don't seem to be active until their menus are shown (even if no action is taken besides closing the menu again).
We see a relevant bug but are having some difficulty understanding how to apply its remedy to our situation. We recognize that instead of Actions we "ought" to be using commands, handlers, and key bindings. But we're hoping we don't have to go down that path just yet.
How can we make our accelerators "live" as soon as the application starts up?
If you don't choose to use o.e.ui.bindings extension point, then there isn't a better way. You should only force update the menuManager yourself as you have done in your answer.
As #Prakash mentioned, if you want to keep down that path in your RCP app you must render all of the main menus to see your accelerators.
There is a partial upgrade path that will get you on the right track to commands without forcing a complete switch over right away. For each action in your menu, define a command with an id and define a binding to the shortcut you want in your plugin.xml. Then, when you create the action in your ActionBarAdvisor, don't set the accelerator. Set the IAction.setActionDefinitionId(*) to the command id, can call register(action);
Then you no longer need to use menuManager.updateAll(true) to eagerly render all of your main menu.
After hunting around and experimenting a bit trying to apply the advice from the bug, we added the following to our WorkbenchWindowAdvisor, which seems to have done the trick:
#Override
public void postWindowCreate() {
getWindowConfigurer().getActionBarConfigurer().getMenuManager().updateAll(true);
}
We have no idea how well this fits with the Workbench's design expectations; there could be a better way.
I have a issue with new Intellij IDEA 10 and Scala plugin. The editor is permanently freezes when I'm typing anything in the Scala source files. In the other files (java and other) editor works good.
Structure view, scala inspection and show members features are switched off. Heap size increased to 1Gb(the IDE actually used just a half of it).
Any suggestions?
There should be a series of thread dumps in the logs directory (~/Library/Logs/IntelliJIdea10 on MacOS X, ~/.IntelliJIdea10/system/log on Linux, %USERHOME%/.IntelliJIdea10/system/log on Windows). Please file a YouTrack issue at http://youtrack.jetbrains.net/ and attach the thread dump files to it.
I had a similar problem with IDEA 9. After lots of searching, I found a strange solution: Deactivate the toolbar and/or navigation bar. (Menu: View -> Toolbar, Navigation Bar)
This actually solved it for me. The explanation was that IDEA had a problem rebuilding the icons in those bars somehow and would sometimes get stuck. I don't know if the problem persists with IDEA 10, and I don't know if it will fix your problem. But maybe you want to give it a try. Deactivate those two bars, restart IDEA and see if those interruptions come again.
IntelliJ is just a Java application, so take advantage of the diagnostic tools for the JVM.
Capture a thread dump during one of the editor lock ups using jstack, as described here. You could also use jconsole or jvisualvm.
I'm creating an Eclipse plug-in which amongst other things creates a new perspective. I want to I execute some code when the perspective loads. Previously I was doing this through createInitialLayout of IPerspectiveFactory but then I realized that this is for defining the page layout only and is usually called when when launching the perspective for the first time only.
How can I specify some code to execute whenever the perspective is displayed? (e.g. when it is loaded as the default perspective by Eclipse)
Thanks and regards,
Krt_Malta
Check the documentation for the IPerspectiveListener interface or the PerspectiveAdapter class, the perspective lifecycle events are explained there.
I often end up with lots of empty panes in Eclipse that can only be minimized but not destroyed. How do I close these?
Update:
In this screenshot you can see two minimized on the upper left and several on the right hand side. In the center are four more. They only seem to be restorable in the Debug mode.
http://img406.imageshack.us/img406/9900/eclipse1.png
this happened to me, too. What worked for me (based on FilmJ and douncon's comments) was to open a class file, then drag that tab over the top of the empty pane.
Select Window -> Reset Perspective. That should reset the current perspective (what you call "mode") to its' initial state, (hopefully) closing all irrelevant views.
Something seems terribly wrong with your Eclipse. Maybe you should reinstall it. It is possible that you installed a buggy plugin.
First of all, what do you mean by pane? Eclipse has:
Windows (Eclipse itself, e.g. instance)
Documents (tabs)
Views (properties, tasks, explorer, etc)
If by 'pane' you mean document editors, you have problems either with your Eclipse version or most likely one of the installed plugins.
Each View also can be closed (except maybe some project types (perspectives) of which I'm not aware). For CDT (C/C++) you can close practically everything.
I'll recommend you download latest Eclipse version with no plugins, extract it to different folder, and check if that happens again. If yes, please explain more in details (like Eclipse version, perspective you are using, any side plugins, etc).
Also a good places are Eclipse community forum, mailing list and bugz :-)
I had the same problem. For me it helped to go into the right perspective and activate the functionality that caused the window in the first place. Once I reactivated the functionality, in my case "QNX Memory Analysis perspective", I was able to close all the windows one by one.
The conclusion is you have to refill the empty windows with content and then you will be able to close them properly.
So, it's really very easy for this to happen, if you open an editor that's incompatible with the existing editor, you can often end up having to place it outside of the tab list in one of your editor panes, then you might clear or copy that, typically while trying to add that view to a tab list.
In any case, what it's done is create a new editor, and all you need to do is drag some file to that empty editor window giving it some form of context, then close it.
I had the same issue. I followed #zvikico, but instead of just resetting, I first reset and then closed all the perspectives. Please follow the following to fix the problem. It worked for me:
Window -> Perspective -> Reset perspective..
After resetting follow below:
Window -> Perspective -> Close All Perspectives