Eclipse RCP application - multi-window design for multiple monitors - eclipse

Question about Eclipse RCP and whole perspective/view/editor design - what is the best way to create application which will display multiple windows on multiple monitors? Tutorials and book I've seen always pack RCP/SWT design into views inside perspective within single application window.
Should one window rule all others or they all should be equal (closing last one exits application)? How deal with the perspectives and views? Are there any other things we should know?
Environment: Eclipse Ganymede, Windows XP.

A single Eclipse workbench can create multiple windows. Each window is laid out using a perspective, so different windows could be set to different perspectives, or the same perspective, and you can switch perspectives in each window independently of the other windows.
You can also set input for each window. This is useful if each window is working on different data (for example, each window could be connected to a different server or could be showing data from different databases that all have the same schema but different data).
It may be that you are using windows only so that you can see different perspectives of the same data on different monitors. In that case you do not need to programatically create the windows but need only add the action supplied by the workbench. This can be done by modifying your ActionBarAdvisor class:
add to the field declarations:
private IWorkbenchAction newWindowAction;
add to the code where you make the actions (typically a method called makeActions):
newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
register(newWindowAction);
add to the code where you create the menus:
menu.add(newWindowAction);
where menu is typically the Window menu. If you don't have a Window menu already in your application and would like to create one, the following line will work:
MenuManager menu = new MenuManager(
"&Window",
IWorkbenchActionConstants.M_WINDOW);
This will give you a menu item that will create a new window in the same way as the Window->New Window menu item in the Eclipse IDE.
If, on the other hand, you want each window to show different data then you will need to open the new windows programatically. This allows you to set different input for each window. You will need a line of code something like:
IWorkbenchPage newPage = window.openPage(inputObject);
where inputObject contains information that identifies the data shown in the window. If you want to set the initial perspective this can be done by calling setPerspective on the page.
You will want to set the title in each window:
newPage.getWorkbenchWindow().getShell().setText(windowTitle);
where windowTitle is a string describing the input to the window.
You can fetch the input for a window as follows:
window.getActivePage().getInput()
You can then cast this to whatever class you are using as your window input.

Related

Differentiate multiple instances of NetBeans by customizing the title of the window

Using --userdir and --cachedir options when launching NetBeans makes it possible to launch multiple independent instances.
However, I didn't find a way to customize the title of the window of each instance to be able to differentiate them easily. For now I gave them a different icon, but it's not enough.

How do I verify that a window is the topmost window using UIAutomation?

I've searched for solutions in many forums but they all tell me that usign the WindowPattern and checkign the topmost value should return true if the window is on top. However, this isn't the case for me. I am testing an application that is housed within a tab in outlok. A user can then click within the application and open a new window. I'd like to verify this window is in the foreground. Also.. this is a WPF application so I cant grab separate handles for new windows that open.
thanks
This might be a terminology problem: 'Topmost' has a special meaning in Win32 (See description of WS_EX_TOPMOST here), which basically means "floats above other ordinary windows" - it's typically used for things like tooltips, menu popups, notification balloons and the like, which float above all other windows on the screen. It's rarely by actual application windows.
An application can be the currently foreground window, above other windows, but not have this property.
An alternate approach to see if the window is in the foreground is to see if it is or contains the contains the current focus or active window.

Programatically manipulating the Eclipse RCP EditorArea Sashes

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.

Eclipse Plugin for Tearout Panels Support

Is there a plugin for Eclipse where I can tear panels out of the main window so I can view them on a separate monitor?
Visual Studio 2010 supports this feature natively.
You don't need a plugin for this - Eclipse supports it by default. You can do it with everything but the main editor window* (the Java text editor, for example).
Simply right-click on any view, then click "Detached". From there, you can move it anywhere across your desktop - including additional monitors.
This will actually create a new floating panel / view group. You can drag add or drag additional views into this same view group, if you'd prefer to have only one detached group to keep track of instead of many.
*If you want to open multiple editor windows, use Window / New Window. This will produce a new window that includes a new main editor window, as well as a default set of views that can also be customized or detached, etc. (I agree, it's not the most ideal, but it works for my needs.) Additional details concerning this are available at https://bugs.eclipse.org/bugs/show_bug.cgi?id=8886 - which seems to indicate that this has been further improved in 4.1 (not yet mainstream).

Eclipse - how to simultaneously switch working set for project explorer, call hierarchy, and search?

Whenever I switch working sets in the project explorer, the working set does not switch for the search and call hierarchy views, so I end up with search results from the wrong working set if I forget to switch those over manually.
Is there a shortcut for switching working sets in all those tools simultaneously?
Thanks!
There is a special working set concept in Eclipse called Window working set which is basically a 'centralized' way of managing your working sets.
You can set up your working sets in Window / Working Sets. Most views which have support for working sets have an option to select this special working set (as you can see here). After finishing the setup you can turn on/off your active working set in Window / Working Sets and all views are automatically use the changed values.
Project explorer, call hierarchy and search support this feature.
To obtain some automation with Working Sets I suggest the following...
First of all a premise. All the views that support Working Sets ask you to select which one they are going to refer to. In the selection dialog, usually, you will find the name of the currently defined Working Sets AND the label Window Working Sets. The latter is, as Csaba_H was saying, some sort of centralized Working Set manager.
Therefore, make sure that every time you need to select a Working Set, your Window Working Set label is selected instead (in the search it's the last input field, press the Choose button...in the Package Explorer, it's the first entry above your WSs).
This is important because when you now change the WS selection within the Window Working Sets (sorry, a lot of WS here), you will automatically change all of them! You will see the Package Explorer change, for example.
As said here already, you can change it through Window -> Working Sets (if the entry is not there, just Window -> Customize Perspective... -> Command Groups Availability tab -> tick on Window Working Set). Not only that, now you can assign a shortcut under Window -> Preferences -> General -> Key -> Select Working Sets (category Window) and use the shortcut to open the selection dialog and change WS from there!
Hope it helps.
Not sure there is a direct way, but what you can try is (just for testing) to associate one perspective to one working set.
I.e. define a package explorer, a search view and a call hierarchy view:
all set to working set WS1 in perspective P1.
all set to working set WS2 in perspective P2.
That way, you should be able to switch perspective, effectively switching working set at the same time.