<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Creating your own Perspective-Switcher - A first try</title>
	<link>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/</link>
	<description>rich client 2.0</description>
	<pubDate>Sat, 04 Feb 2012 13:26:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Replacing the Perspective-Switcher in RCP apps &#171; EclipseSource Blog</title>
		<link>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-52596</link>
		<pubDate>Tue, 31 Mar 2009 04:42:17 +0000</pubDate>
		<guid>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-52596</guid>
					<description>[...] PS: If you want to trade off more screen real-estate for a fancier switcher you can use a &amp;#8217;standalone&amp;#8217; view or a composite that is placed around the page contents. Tom Seidel has the details on his blog. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] PS: If you want to trade off more screen real-estate for a fancier switcher you can use a &#8217;standalone&#8217; view or a composite that is placed around the page contents. Tom Seidel has the details on his blog. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Tom Seidel</title>
		<link>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-305</link>
		<pubDate>Tue, 13 Mar 2007 17:58:38 +0000</pubDate>
		<guid>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-305</guid>
					<description>Yes, you're right.
Thanks for your addition</description>
		<content:encoded><![CDATA[<p>Yes, you&#8217;re right.<br />
Thanks for your addition
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mickey</title>
		<link>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-304</link>
		<pubDate>Tue, 13 Mar 2007 17:41:19 +0000</pubDate>
		<guid>http://www.richclient2.de/2006_08_29/creating-your-own-perspective-switcher-a-first-try/#comment-304</guid>
					<description>Well this could be achieved if you create your own ApplicationWorkbenchWindowAdvisor like I did it to create logo for my RCP application, but you can use it for this task too. You can find what I mean if you look at http://birosoft.zexxo.net/demo/UpdateDemo.htm
. ApplicationLogo class in my case is a simple composite.

Source example:

package com.birosoft.workday.platform.intro;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.internal.WorkbenchWindow;
import org.eclipse.ui.internal.progress.ProgressRegion;

import com.birosoft.workday.platform.Activator;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
	private Control logo;

	private Control toolbar;

	private Control page;

	private Control statusline;

	private ProgressRegion progressRegion;

	public ApplicationWorkbenchWindowAdvisor(
			IWorkbenchWindowConfigurer configurer) {
		super(configurer);
	}

	public ActionBarAdvisor createActionBarAdvisor(
			IActionBarConfigurer configurer) {
		return new ApplicationActionBarAdvisor(configurer);
	}

	public void preWindowOpen() {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		Preferences prefs = Activator.getDefault().getPluginPreferences();
		if (prefs.getInt(Application.APP_WIN_WIDTH) == 0
				&amp;#124;&amp;#124; prefs.getInt(Application.APP_WIN_HEIGHT) == 0) {
			configurer.setInitialSize(new Point(800, 600));
		} else {
			int width = prefs.getInt(Application.APP_WIN_WIDTH);
			int height = prefs.getInt(Application.APP_WIN_HEIGHT);
			configurer.setInitialSize(new Point(width, height));
		}
		configurer.setShowCoolBar(true);
		configurer.setShowStatusLine(true);
		configurer.setShowProgressIndicator(true);
		configurer.setTitle(&quot;Birosoft Workday Client - &quot;
				+ Application.getCurrentClient().toString() + &quot; (&quot;
				+ Application.getUsername() + &quot;)&quot;);
	}

	public void postWindowOpen() {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		Preferences prefs = Activator.getDefault().getPluginPreferences();
		if (prefs.getInt(Application.APP_WIN_POS_X) == 0
				&amp;#124;&amp;#124; prefs.getInt(Application.APP_WIN_POS_Y) == 0) {
			configurer.getWindow().getShell().setLocation(0, 0);
		} else {
			int x = prefs.getInt(Application.APP_WIN_POS_X);
			int y = prefs.getInt(Application.APP_WIN_POS_Y);
			configurer.getWindow().getShell().setLocation(x, y);
		}
	}

	@Override
	public void postWindowClose() {
		Preferences prefs = Activator.getDefault().getPluginPreferences();
		Point size = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getShell().getSize();
		prefs.setValue(Application.APP_WIN_WIDTH, size.x);
		prefs.setValue(Application.APP_WIN_HEIGHT, size.y);
		Point position = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getShell().getLocation();
		prefs.setValue(Application.APP_WIN_POS_X, position.x);
		prefs.setValue(Application.APP_WIN_POS_Y, position.y);
		super.postWindowClose();
	}

	public void createWindowContents(Shell shell) {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		Menu menu = configurer.createMenuBar();
		shell.setMenuBar(menu);
		FormLayout layout = new FormLayout();
		layout.marginWidth = 0;
		layout.marginHeight = 0;
		shell.setLayout(layout);
		logo = new ApplicationLogo(
				getWindowConfigurer().getWindow().getShell(), SWT.NONE);
		Application.setApplicationLogo(((ApplicationLogo) logo));
		toolbar = configurer.createCoolBarControl(shell);
		((CoolBar) toolbar).setLocked(true);
		page = configurer.createPageComposite(shell);
		statusline = configurer.createStatusLineControl(shell);
		createProgressIndicator(shell);

		// The layout method does the work of connecting the
		// controls together.
		layoutNormal();
	}

	private void layoutNormal() {
		// APPLOGO
		FormData data = new FormData();
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		logo.setLayoutData(data);
		// TOOLBAR
		data = new FormData();
		data.top = new FormAttachment(logo, 5, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(page, 0, SWT.LEFT);
		toolbar.setLayoutData(data);
		// STATUS LINE
		data = new FormData();
		data.bottom = new FormAttachment(100, 0);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		statusline.setLayoutData(data);
		// PAGE CONTENTS
		data = new FormData();
		data.top = new FormAttachment(logo, 5, SWT.BOTTOM);
		// data.left = new FormAttachment(toolbar, 0, SWT.RIGHT);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(100, -5);
		data.bottom = new FormAttachment(statusline);
		page.setLayoutData(data);
		layout();
	}

	private void layout() {
		getWindowConfigurer().getWindow().getShell().layout(true);
		if (page != null) {
			((Composite) page).layout(true);
		}
	}

	/**
	 * Create the progress indicator for the receiver.
	 * @param shell	the parent shell
	 */
	private void createProgressIndicator(Shell shell) {
		if (getWindowConfigurer().getShowProgressIndicator()) {
			WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer()
					.getWindow();
			progressRegion = new ProgressRegion();
			progressRegion.createContents(shell, window);
		}
	}

}</description>
		<content:encoded><![CDATA[<p>Well this could be achieved if you create your own ApplicationWorkbenchWindowAdvisor like I did it to create logo for my RCP application, but you can use it for this task too. You can find what I mean if you look at <a href='http://birosoft.zexxo.net/demo/UpdateDemo.htm' rel='nofollow'>http://birosoft.zexxo.net/demo/UpdateDemo.htm</a><br />
. ApplicationLogo class in my case is a simple composite.</p>
<p>Source example:</p>
<p>package com.birosoft.workday.platform.intro;</p>
<p>import org.eclipse.core.runtime.Preferences;<br />
import org.eclipse.swt.SWT;<br />
import org.eclipse.swt.graphics.Point;<br />
import org.eclipse.swt.layout.FormAttachment;<br />
import org.eclipse.swt.layout.FormData;<br />
import org.eclipse.swt.layout.FormLayout;<br />
import org.eclipse.swt.widgets.Composite;<br />
import org.eclipse.swt.widgets.Control;<br />
import org.eclipse.swt.widgets.CoolBar;<br />
import org.eclipse.swt.widgets.Menu;<br />
import org.eclipse.swt.widgets.Shell;<br />
import org.eclipse.ui.PlatformUI;<br />
import org.eclipse.ui.application.ActionBarAdvisor;<br />
import org.eclipse.ui.application.IActionBarConfigurer;<br />
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;<br />
import org.eclipse.ui.application.WorkbenchWindowAdvisor;<br />
import org.eclipse.ui.internal.WorkbenchWindow;<br />
import org.eclipse.ui.internal.progress.ProgressRegion;</p>
<p>import com.birosoft.workday.platform.Activator;</p>
<p>public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {<br />
	private Control logo;</p>
<p>	private Control toolbar;</p>
<p>	private Control page;</p>
<p>	private Control statusline;</p>
<p>	private ProgressRegion progressRegion;</p>
<p>	public ApplicationWorkbenchWindowAdvisor(<br />
			IWorkbenchWindowConfigurer configurer) {<br />
		super(configurer);<br />
	}</p>
<p>	public ActionBarAdvisor createActionBarAdvisor(<br />
			IActionBarConfigurer configurer) {<br />
		return new ApplicationActionBarAdvisor(configurer);<br />
	}</p>
<p>	public void preWindowOpen() {<br />
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();<br />
		Preferences prefs = Activator.getDefault().getPluginPreferences();<br />
		if (prefs.getInt(Application.APP_WIN_WIDTH) == 0<br />
				|| prefs.getInt(Application.APP_WIN_HEIGHT) == 0) {<br />
			configurer.setInitialSize(new Point(800, 600));<br />
		} else {<br />
			int width = prefs.getInt(Application.APP_WIN_WIDTH);<br />
			int height = prefs.getInt(Application.APP_WIN_HEIGHT);<br />
			configurer.setInitialSize(new Point(width, height));<br />
		}<br />
		configurer.setShowCoolBar(true);<br />
		configurer.setShowStatusLine(true);<br />
		configurer.setShowProgressIndicator(true);<br />
		configurer.setTitle(&#8221;Birosoft Workday Client - &#8221;<br />
				+ Application.getCurrentClient().toString() + &#8221; (&#8221;<br />
				+ Application.getUsername() + &#8220;)&#8221;);<br />
	}</p>
<p>	public void postWindowOpen() {<br />
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();<br />
		Preferences prefs = Activator.getDefault().getPluginPreferences();<br />
		if (prefs.getInt(Application.APP_WIN_POS_X) == 0<br />
				|| prefs.getInt(Application.APP_WIN_POS_Y) == 0) {<br />
			configurer.getWindow().getShell().setLocation(0, 0);<br />
		} else {<br />
			int x = prefs.getInt(Application.APP_WIN_POS_X);<br />
			int y = prefs.getInt(Application.APP_WIN_POS_Y);<br />
			configurer.getWindow().getShell().setLocation(x, y);<br />
		}<br />
	}</p>
<p>	@Override<br />
	public void postWindowClose() {<br />
		Preferences prefs = Activator.getDefault().getPluginPreferences();<br />
		Point size = PlatformUI.getWorkbench().getActiveWorkbenchWindow()<br />
				.getShell().getSize();<br />
		prefs.setValue(Application.APP_WIN_WIDTH, size.x);<br />
		prefs.setValue(Application.APP_WIN_HEIGHT, size.y);<br />
		Point position = PlatformUI.getWorkbench().getActiveWorkbenchWindow()<br />
				.getShell().getLocation();<br />
		prefs.setValue(Application.APP_WIN_POS_X, position.x);<br />
		prefs.setValue(Application.APP_WIN_POS_Y, position.y);<br />
		super.postWindowClose();<br />
	}</p>
<p>	public void createWindowContents(Shell shell) {<br />
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();<br />
		Menu menu = configurer.createMenuBar();<br />
		shell.setMenuBar(menu);<br />
		FormLayout layout = new FormLayout();<br />
		layout.marginWidth = 0;<br />
		layout.marginHeight = 0;<br />
		shell.setLayout(layout);<br />
		logo = new ApplicationLogo(<br />
				getWindowConfigurer().getWindow().getShell(), SWT.NONE);<br />
		Application.setApplicationLogo(((ApplicationLogo) logo));<br />
		toolbar = configurer.createCoolBarControl(shell);<br />
		((CoolBar) toolbar).setLocked(true);<br />
		page = configurer.createPageComposite(shell);<br />
		statusline = configurer.createStatusLineControl(shell);<br />
		createProgressIndicator(shell);</p>
<p>		// The layout method does the work of connecting the<br />
		// controls together.<br />
		layoutNormal();<br />
	}</p>
<p>	private void layoutNormal() {<br />
		// APPLOGO<br />
		FormData data = new FormData();<br />
		data.top = new FormAttachment(0, 0);<br />
		data.left = new FormAttachment(0, 0);<br />
		data.right = new FormAttachment(100, 0);<br />
		logo.setLayoutData(data);<br />
		// TOOLBAR<br />
		data = new FormData();<br />
		data.top = new FormAttachment(logo, 5, SWT.BOTTOM);<br />
		data.left = new FormAttachment(0, 0);<br />
		data.right = new FormAttachment(page, 0, SWT.LEFT);<br />
		toolbar.setLayoutData(data);<br />
		// STATUS LINE<br />
		data = new FormData();<br />
		data.bottom = new FormAttachment(100, 0);<br />
		data.left = new FormAttachment(0, 0);<br />
		data.right = new FormAttachment(100, 0);<br />
		statusline.setLayoutData(data);<br />
		// PAGE CONTENTS<br />
		data = new FormData();<br />
		data.top = new FormAttachment(logo, 5, SWT.BOTTOM);<br />
		// data.left = new FormAttachment(toolbar, 0, SWT.RIGHT);<br />
		data.left = new FormAttachment(0, 5);<br />
		data.right = new FormAttachment(100, -5);<br />
		data.bottom = new FormAttachment(statusline);<br />
		page.setLayoutData(data);<br />
		layout();<br />
	}</p>
<p>	private void layout() {<br />
		getWindowConfigurer().getWindow().getShell().layout(true);<br />
		if (page != null) {<br />
			((Composite) page).layout(true);<br />
		}<br />
	}</p>
<p>	/**<br />
	 * Create the progress indicator for the receiver.<br />
	 * @param shell	the parent shell<br />
	 */<br />
	private void createProgressIndicator(Shell shell) {<br />
		if (getWindowConfigurer().getShowProgressIndicator()) {<br />
			WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer()<br />
					.getWindow();<br />
			progressRegion = new ProgressRegion();<br />
			progressRegion.createContents(shell, window);<br />
		}<br />
	}</p>
<p>}
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

