How can I close a property window in an application developed with RCP? - eclipse-rcp

I'm having a bit of a trouble modifying an application that I have inherited from another party. The application is a Front End made with Eclipse RCP, and I have to modify one of its property windows so when I click a Save button it will not just save the data to my database, but also close that property window.
I can't find a way to reference the window itself so I can invoke a method like "window.close();", would anyone have a hint by any chance?
Thank you.

Related

Refresh windows in netbeans RCP

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

Programmatically affecting load order of perspectives

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.

Eclipse SearchDialog Changes as soon as the Dialog is being called

My Requirement is like to change the Eclipse Default SearchDialog, so as soon as any user opens the Eclipse Menu , Search>Search, the window/wizard opens should be the customized one ,
How to make this scenario possible.
Is there any Extension point which handles all startup operation for a wizard, so that I could call that and any time the dialog is getting called , I will override and make my changes.
By using org.eclipse.search.searchResultViewPages extension point you can define your own search result page and other required class to contribute to the built-in Eclipse search "mechanism".

How can I make my Eclipse RCP app's keyboard shortcuts (accelerators) work immediately after startup?

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.

Execute code when loading an Eclipse perspective

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.