Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Main window size and position
Main window size and position [message #483277] Mon, 31 August 2009 20:41 Go to next message
Michael Schmidt is currently offline Michael SchmidtFriend
Messages: 45
Registered: July 2009
Member
I have worked with eclipse rcp for years. I see how to set the default
size of the main window but not the default position (I want the main
window to open centered on the screen). I also would like the main window
size and position to persist but I do not want other state information to
persist. Therefore, I do not want to use setSaveAndRestore(). Can this
be done easily?
Re: Main window size and position [message #483298 is a reply to message #483277] Mon, 31 August 2009 21:18 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Michael,

This works like a dream:

package com.weltevree.salvo.application.internal;
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
{

<snip>

@Override
public void postWindowOpen() {
super.postWindowOpen();
int x = PlatformUI.getPreferenceStore().getInt("posx");
int y = PlatformUI.getPreferenceStore().getInt("posy");
getWindowConfigurer().getWindow().getShell().setLocation(
x == 0 ? 800 : x, y == 0 ? 300 : y);
}

@Override
public boolean preWindowShellClose() {
int x = getWindowConfigurer().getWindow().getShell().getLocation().x ;
int y = getWindowConfigurer().getWindow().getShell().getLocation().y ;

PlatformUI.getPreferenceStore().setValue("posx", x);
PlatformUI.getPreferenceStore().setValue("posy", y);
return super.preWindowShellClose();

}
}

--

Best regards,

Wim Jongman
Posted with Salvo, the Eclipse based newsreader... On OSX!!

> I have worked with eclipse rcp for years. I see how to set the default
> size of the main window but not the default position (I want the main
> window to open centered on the screen). I also would like the main window
> size and position to persist but I do not want other state information to
> persist. Therefore, I do not want to use setSaveAndRestore(). Can this
> be done easily?
Re: Main window size and position [message #483304 is a reply to message #483277] Mon, 31 August 2009 22:04 Go to previous message
Michael Schmidt is currently offline Michael SchmidtFriend
Messages: 45
Registered: July 2009
Member
Thanks so much!
Previous Topic:KeyBindings don't work after product is exported
Next Topic:StatusLineContributionItem positioning
Goto Forum:
  


Current Time: Wed Feb 05 14:09:50 GMT 2025

Powered by FUDForum. Page generated in 0.03202 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top