How to move the an eclipse-rcp window in the center of a desktop screen
Tech-Today

How to move the an eclipse-rcp window in the center of a desktop screen


Using eclipse-rcp HelloWorld Example

To be able to do this we need to override the WorkbenchWindowAdvisor's postWindowCreate method in the ApplicationWorkbenchWindowAdvisor class.
 @Override
/**
* ostWindowCreate - called after the window has been created, either from an
* initial state or from a restored state; used to adjust the window
*/
public void postWindowCreate() {
super.postWindowCreate();
//get the workbench window
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
Display display = configurer.getWindow().getWorkbench().getDisplay();
//get the desktop window
Shell shell = configurer.getWindow().getShell();
Rectangle rectBounds = display.getBounds();

int minWidth = 600;
int minHeight = 400;
int x = 400;
int y = 100;

//note: for multi-monitors negative x value is returned
if(rectBounds.x > 0) { //single monitor
// This formulae calculate the shell's Left ant Top
x = (rectBounds.width - minWidth) / 2;
y = (rectBounds.height - minHeight) / 2;
} else { //assumption 2 monitors that's why rectBounds.width is divided by 2
x = (rectBounds.width / 2 - minWidth) / 2;
y = (rectBounds.height - minHeight) / 2;
}

// based on the above calculations, set the window location
shell.setBounds(x, y, minWidth, minHeight);
}




- Iphone Xcode - Create A Simple Uiscrollview
Finally getting acquainted with iPhone's xcode. Now I'll build a simple window base application to demo the UIScrollView features. 1.) Create a new window base application, named it MyScroll. It should create 2 files: a.) MyScrollAppDelegate.h...

- Add Eclipse-rcp's Views Short List, Perspective Short List In The Org.eclipse.ui.menus Plugin Via Dynamic Compoundcontributionitem Class
Recently, I've encountered a problem wherein I wanted to display the eclipse-rcp's list of view, perspective etc using the extension org.eclipse.ui.menus. The problem can easily solved by the ApplicationActionBarAdvisor, see the code below: private...

- Create A New Eclipse-rcp Preference Page By Code When A Listener Is Invoked
Objective: -To create an eclipse-rcp preference page without using the preference extension, all is done in code. This is done by creating a customized button with a SelectionListener, and eventually that action will call a customized preference page....

- Eclipse-rcp Shows A Blank Perspective When Adding View Dynamically And Overriding The Applicationworkbenchadvisor's Initialize Method
How to recreate the problem: 1.) create a new Hello World plugin project in eclipse rcp 2.) add extension org.eclipse.ui.views in plugin.xml->Extensions 3.) right click the extension and select New->view 4.) enter an id and a class name 5.) right...

- How To Add And Enable A Menu Button Using The Eclipse Rcp Extension (by Code And Using The Plugin Ui Interface)
How to add and enable a menu button using the eclipse rcp extension (by code and using the plugin UI Interface) To learn eclipse-rcp, I keep on reading, try some tutorials available on the net. My favorite is this one: http://www.vogella.de/articles/RichClientPlatform/article.html,...



Tech-Today








.