Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 123209 Details for
Bug 261795
Interaction design API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch that contains the contribution
interactiondesignAPI_patch.txt (text/plain), 399.02 KB, created by
Holger Staudacher
on 2009-01-21 06:23:00 EST
(
hide
)
Description:
Patch that contains the contribution
Filename:
MIME Type:
Creator:
Holger Staudacher
Created:
2009-01-21 06:23:00 EST
Size:
399.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchWindowConfigurer.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindowConfigurer.java,v >retrieving revision 1.2 >diff -u -r1.2 WorkbenchWindowConfigurer.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchWindowConfigurer.java 21 Apr 2008 07:59:10 -0000 1.2 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchWindowConfigurer.java 21 Jan 2009 09:57:26 -0000 >@@ -13,7 +13,11 @@ > import java.util.HashMap; > import java.util.Map; > >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.CoolBarManager; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.IContributionItem; >@@ -25,6 +29,8 @@ > import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem; > import org.eclipse.jface.window.Window; > import org.eclipse.osgi.util.TextProcessor; >+import org.eclipse.rwt.branding.AbstractBranding; >+import org.eclipse.rwt.internal.branding.BrandingUtil; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Composite; >@@ -578,28 +584,70 @@ > * factory default presentation factory is used. > */ > private AbstractPresentationFactory createDefaultPresentationFactory() { >- final String factoryId = ((Workbench) window.getWorkbench()) >- .getPresentationId(); >- >- if (factoryId != null && factoryId.length() > 0) { >- final AbstractPresentationFactory [] factory = new AbstractPresentationFactory[1]; >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- factory[0] = WorkbenchPlugin.getDefault() >- .getPresentationFactory(factoryId); >- } >- }); >- >- if (factory[0] != null) { >- return factory[0]; >+ // RAP [hs] patched for interactiondesign API >+ String tempId = getBrandingPresentationFactoryId(); >+ if( tempId == null ) { >+ tempId = ( ( Workbench ) window.getWorkbench() ).getPresentationId(); >+ } >+ final String factoryId = tempId; >+ >+ if (factoryId != null && factoryId.length() > 0) { >+ final AbstractPresentationFactory [] factory = new AbstractPresentationFactory[1]; >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ factory[0] = WorkbenchPlugin.getDefault() >+ .getPresentationFactory(factoryId); >+ } >+ }); >+ >+ if (factory[0] != null) { >+ return factory[0]; >+ } >+ } >+ // presentation ID must be a bogus value, reset it to the default >+ PrefUtil.getAPIPreferenceStore().setValue( >+ IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID, >+ IWorkbenchConstants.DEFAULT_PRESENTATION_ID); >+ return new WorkbenchPresentationFactory(); >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private String getBrandingPresentationFactoryId() { >+ String result = null; >+ AbstractBranding branding = BrandingUtil.findBranding(); >+ if( branding != null ) { >+ String brandingId = branding.getId(); >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ final String id = "org.eclipse.rap.ui.branding"; >+ IExtensionPoint brandingPoint = registry.getExtensionPoint( id ); >+ if( brandingPoint != null ) { >+ IConfigurationElement[] elements >+ = brandingPoint.getConfigurationElements(); >+ boolean found = false; >+ for( int i = 0; i < elements.length && !found; i++ ) { >+ String tempId = elements[ i ].getAttribute( "id" ); >+ if( tempId.equals( brandingId ) ) { >+ found = true; >+ result = loadBrandingPresentationFactoryId( elements[ i ] ); > } >+ } > } >- // presentation ID must be a bogus value, reset it to the default >- PrefUtil.getAPIPreferenceStore().setValue( >- IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID, >- IWorkbenchConstants.DEFAULT_PRESENTATION_ID); >- return new WorkbenchPresentationFactory(); >+ } >+ return result; >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private String loadBrandingPresentationFactoryId( >+ final IConfigurationElement element ) >+ { >+ String result = null; >+ IConfigurationElement[] factory >+ = element.getChildren( "presentationFactory" ); >+ if( factory.length > 0 ) { >+ result = factory[ 0 ].getAttribute( "id" ); >+ } >+ return result; > } > > /* (non-Javadoc) >Index: Eclipse UI/org/eclipse/ui/internal/ViewPane.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java,v >retrieving revision 1.3 >diff -u -r1.3 ViewPane.java >--- Eclipse UI/org/eclipse/ui/internal/ViewPane.java 24 Apr 2008 16:46:04 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/internal/ViewPane.java 21 Jan 2009 09:57:25 -0000 >@@ -317,10 +317,16 @@ > * @see ViewActionBars > */ > public MenuManager getMenuManager() { >- if (isvMenuMgr == null) { >- isvMenuMgr = new PaneMenuManager(); >- } >- return isvMenuMgr; >+ if( isvMenuMgr == null ) { >+ WorkbenchWindow window = page.window; >+ // RAP [hs] patched for interactiondesign API >+ if( window.getConfigurablePresentationFactory() != null ) { >+ isvMenuMgr = window.createPartMenuManager(); >+ } else { >+ isvMenuMgr = new PaneMenuManager(); >+ } >+ } >+ return isvMenuMgr; > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/PartStack.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java,v >retrieving revision 1.4 >diff -u -r1.4 PartStack.java >--- Eclipse UI/org/eclipse/ui/internal/PartStack.java 29 Apr 2008 16:02:34 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/PartStack.java 21 Jan 2009 09:57:25 -0000 >@@ -29,27 +29,20 @@ > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.util.Geometry; > import org.eclipse.osgi.util.NLS; >-//import org.eclipse.swt.graphics.Cursor; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >-//import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.IPersistable; > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.IWorkbenchPartReference; > import org.eclipse.ui.IWorkbenchPreferenceConstants; >-//import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.XMLMemento; > import org.eclipse.ui.internal.StartupThreading.StartupRunnable; >-//import org.eclipse.ui.internal.dnd.AbstractDropTarget; >-//import org.eclipse.ui.internal.dnd.DragUtil; >-//import org.eclipse.ui.internal.dnd.IDropTarget; > import org.eclipse.ui.internal.dnd.SwtUtil; >-//import org.eclipse.ui.internal.intro.IIntroConstants; > import org.eclipse.ui.internal.layout.ITrimManager; > import org.eclipse.ui.internal.layout.IWindowTrim; > import org.eclipse.ui.internal.presentations.PresentablePart; >@@ -60,7 +53,6 @@ > import org.eclipse.ui.presentations.AbstractPresentationFactory; > import org.eclipse.ui.presentations.IPresentablePart; > import org.eclipse.ui.presentations.IStackPresentationSite; >-//import org.eclipse.ui.presentations.StackDropResult; > import org.eclipse.ui.presentations.StackPresentation; > > /** >@@ -168,9 +160,15 @@ > return (IPresentablePart[]) parts.toArray(new IPresentablePart[parts.size()]); > } > >- public String getProperty(String id) { >- return PartStack.this.getProperty(id); >+ public String getProperty(String id) { >+ // RAP [hs] patched for interactiondesign API >+ String result = PartStack.this.getProperty(id); >+ if( id.equals( "id" )) >+ result = PartStack.this.getID(); >+ return result; > } >+ >+ > }; > > // RAP [rh] PartStackDropResult disabled since DnD support is missing >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java,v >retrieving revision 1.10 >diff -u -r1.10 WorkbenchWindow.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java 29 Apr 2008 16:02:34 -0000 1.10 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java 21 Jan 2009 09:57:26 -0000 >@@ -1,16 +1,6 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- > package org.eclipse.ui.internal; > >+ > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; > import java.util.HashMap; >@@ -54,6 +44,8 @@ > import org.eclipse.jface.window.Window; > import org.eclipse.osgi.util.NLS; > import org.eclipse.osgi.util.TextProcessor; >+import org.eclipse.rap.ui.interactiondesign.IWindowComposer; >+import org.eclipse.rap.ui.interactiondesign.PresentationFactory; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.custom.CBanner; >@@ -88,7 +80,6 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchPartReference; >-//import org.eclipse.ui.IWorkbenchPreferenceConstants; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.WorkbenchException; >@@ -105,7 +96,6 @@ > import org.eclipse.ui.internal.dnd.SwtUtil; > import org.eclipse.ui.internal.handlers.ActionCommandMappingService; > import org.eclipse.ui.internal.handlers.IActionCommandMappingService; >-//import org.eclipse.ui.internal.intro.IIntroConstants; > import org.eclipse.ui.internal.layout.CacheWrapper; > import org.eclipse.ui.internal.layout.ITrimManager; > import org.eclipse.ui.internal.layout.IWindowTrim; >@@ -130,7 +120,6 @@ > import org.eclipse.ui.internal.services.ServiceLocator; > import org.eclipse.ui.internal.tweaklets.Tweaklets; > import org.eclipse.ui.internal.tweaklets.WorkbenchImplementation; >-//import org.eclipse.ui.internal.util.PrefUtil; > import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.menus.IMenuService; > import org.eclipse.ui.menus.MenuUtil; >@@ -140,3722 +129,3819 @@ > * A window within the workbench. > */ > public class WorkbenchWindow extends ApplicationWindow implements >- IWorkbenchWindow { >+ IWorkbenchWindow { > >- private WorkbenchWindowAdvisor windowAdvisor; >+ private WorkbenchWindowAdvisor windowAdvisor; > >- private ActionBarAdvisor actionBarAdvisor; >+ private ActionBarAdvisor actionBarAdvisor; > >- private int number; >+ private int number; > >- private PageList pageList = new PageList(); >+ private PageList pageList = new PageList(); > >- private PageListenerList pageListeners = new PageListenerList(); >+ private PageListenerList pageListeners = new PageListenerList(); > >- private PerspectiveListenerList perspectiveListeners = new PerspectiveListenerList(); >+ private PerspectiveListenerList perspectiveListeners = new PerspectiveListenerList(); > >- private WWinPartService partService = new WWinPartService(this); >+ private WWinPartService partService = new WWinPartService(this); > >- private ActionPresentation actionPresentation; >+ private ActionPresentation actionPresentation; > >- private WWinActionBars actionBars; >+ private WWinActionBars actionBars; > >- private boolean updateDisabled = true; >+ private boolean updateDisabled = true; > >- private boolean closing = false; >+ private boolean closing = false; > >- private boolean shellActivated = false; >+ private boolean shellActivated = false; > >- private FastViewBar fastViewBar; >+ private FastViewBar fastViewBar; > >- private PerspectiveSwitcher perspectiveSwitcher = null; >+ private PerspectiveSwitcher perspectiveSwitcher = null; > >- private TrimLayout defaultLayout; >+ private TrimLayout defaultLayout; > >- ProgressRegion progressRegion = null; >+ ProgressRegion progressRegion = null; > >- // Legacy (3.2) contribution handling >- private TrimBarManager2 trimMgr2 = null; >- >- // 3.3 Trim Contribution handling >- private TrimContributionManager trimContributionMgr = null; >- >- /** >- * The map of services maintained by the workbench window. These services >- * are initialized during workbench window during the >- * {@link #configureShell(Shell)}. >- */ >- private final ServiceLocator serviceLocator; >+ // Legacy (3.2) contribution handling >+ private TrimBarManager2 trimMgr2 = null; >+ >+ // 3.3 Trim Contribution handling >+ private TrimContributionManager trimContributionMgr = null; >+ >+ /** >+ * The map of services maintained by the workbench window. These services >+ * are initialized during workbench window during the >+ * {@link #configureShell(Shell)}. >+ */ >+ private final ServiceLocator serviceLocator; > > // RAP [rh] HeapStatus not supported >-// private HeapStatus heapStatus; >+// private HeapStatus heapStatus; > >-// private WindowTrimProxy heapStatusTrim = null; >+// private WindowTrimProxy heapStatusTrim = null; > >- private boolean emptyWindowContentsCreated = false; >+ private boolean emptyWindowContentsCreated = false; > >- private Control emptyWindowContents; >+ private Control emptyWindowContents; > >- private Rectangle normalBounds; >- >- private boolean asMaximizedState = false; >- >- private CBanner topBar; >- >- private IWindowTrim topBarTrim; >- >- // Previous shell size. Used to prevent the CBanner from triggering >- // redundant layouts >- private Point lastShellSize = new Point(0, 0); >- >- /** >- * The composite under which workbench pages create their controls. >- */ >- private Composite pageComposite; >- >- /** >- * Bit flags indication which submenus (New, Show Views, ...) this window >- * contains. Initially none. >- */ >- private int submenus = 0x00; >- >- /** >- * Object for configuring this workbench window. Lazily initialized to an >- * instance unique to this window. >- */ >- private WorkbenchWindowConfigurer windowConfigurer = null; >- >- /** >- * List of generic property listeners. >- */ >- private ListenerList genericPropertyListeners = new ListenerList(); >- >- // RAP [bm]: detached windows >-// private ShellPool detachedWindowShells; >- // RAPEND: [bm] >- >- static final String TEXT_DELIMITERS = TextProcessor.getDefaultDelimiters() + "-"; //$NON-NLS-1$ >- >- // constants for shortcut bar group ids >- static final String GRP_PAGES = "pages"; //$NON-NLS-1$ >- >- static final String GRP_PERSPECTIVES = "perspectives"; //$NON-NLS-1$ >- >- static final String GRP_FAST_VIEWS = "fastViews"; //$NON-NLS-1$ >- >- // static fields for inner classes. >- static final int VGAP = 0; >- >- static final int CLIENT_INSET = 3; >- >- static final int BAR_SIZE = 23; >- >- /** >- * Coolbar visibility change property. >- */ >- public static final String PROP_COOLBAR_VISIBLE = "coolbarVisible"; //$NON-NLS-1$ >- >- /** >- * Perspective bar visibility change property. >- */ >- public static final String PROP_PERSPECTIVEBAR_VISIBLE = "perspectiveBarVisible"; //$NON-NLS-1$ >- >- /** >- * Constant (bit mask) indicating which the Show View submenu is probably >- * present somewhere in this window. >- * >- * @see #addSubmenu >- */ >- public static final int SHOW_VIEW_SUBMENU = 0x01; >- >- /** >- * Constant (bit mask) indicating which the Open Perspective submenu is >- * probably present somewhere in this window. >- * >- * @see #addSubmenu >- */ >- public static final int OPEN_PERSPECTIVE_SUBMENU = 0x02; >- >- /** >- * Constant (bit mask) indicating which the New Wizard submenu is probably >- * present somewhere in this window. >- * >- * @see #addSubmenu >- */ >- public static final int NEW_WIZARD_SUBMENU = 0x04; >- >- /** >- * Remembers that this window contains the given submenu. >- * >- * @param type >- * the type of submenu, one of: >- * {@link #NEW_WIZARD_SUBMENU NEW_WIZARD_SUBMENU}, >- * {@link #OPEN_PERSPECTIVE_SUBMENU OPEN_PERSPECTIVE_SUBMENU}, >- * {@link #SHOW_VIEW_SUBMENU SHOW_VIEW_SUBMENU} >- * @see #containsSubmenu >- */ >- public void addSubmenu(int type) { >- submenus |= type; >- } >- >- /** >- * Checks to see if this window contains the given type of submenu. >- * >- * @param type >- * the type of submenu, one of: >- * {@link #NEW_WIZARD_SUBMENU NEW_WIZARD_SUBMENU}, >- * {@link #OPEN_PERSPECTIVE_SUBMENU OPEN_PERSPECTIVE_SUBMENU}, >- * {@link #SHOW_VIEW_SUBMENU SHOW_VIEW_SUBMENU} >- * @return <code>true</code> if window contains submenu, >- * <code>false</code> otherwise >- * @see #addSubmenu >- */ >- public boolean containsSubmenu(int type) { >- return ((submenus & type) != 0); >- } >- >- /** >- * Constant indicating that all the actions bars should be filled. >- */ >- private static final int FILL_ALL_ACTION_BARS = ActionBarAdvisor.FILL_MENU_BAR >- | ActionBarAdvisor.FILL_COOL_BAR >- | ActionBarAdvisor.FILL_STATUS_LINE; >- >- /** >- * Creates and initializes a new workbench window. >- * >- * @param number >- * the number for the window >- */ >- public WorkbenchWindow(int number) { >- super(null); >- this.number = number; >- >- // Make sure there is a workbench. This call will throw >- // an exception if workbench not created yet. >- final IWorkbench workbench = PlatformUI.getWorkbench(); >- IServiceLocatorCreator slc = (IServiceLocatorCreator) workbench >- .getService(IServiceLocatorCreator.class); >- this.serviceLocator = (ServiceLocator) slc >- .createServiceLocator(workbench, null); >- initializeDefaultServices(); >- >- // Add contribution managers that are exposed to other plugins. >- addMenuBar(); >- addCoolBar(SWT.NONE); // style is unused >- addStatusLine(); >- >- // register with the tracker >- getExtensionTracker() >- .registerHandler( >- actionSetHandler, >- ExtensionTracker >- .createExtensionPointFilter(getActionSetExtensionPoint())); >- >- fireWindowOpening(); >- >- // set the shell style >- setShellStyle(getWindowConfigurer().getShellStyle()); >- >- // Fill the action bars >- fillActionBars(FILL_ALL_ACTION_BARS); >- } >- >- /** >- * Return the action set extension point. >- * >- * @return the action set extension point >- */ >- private IExtensionPoint getActionSetExtensionPoint() { >- // RAP [bm]: >-// return Platform.getExtensionRegistry().getExtensionPoint( >-// PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_ACTION_SETS); >- return Platform.getExtensionRegistry().getExtensionPoint( >- PlatformUI.PLUGIN_EXTENSION_NAME_SPACE, IWorkbenchRegistryConstants.PL_ACTION_SETS); >- >- } >- >- /** >- * Return the style bits for the shortcut bar. >- * >- * @return int >- */ >- protected int perspectiveBarStyle() { >- return SWT.FLAT | SWT.WRAP | SWT.RIGHT | SWT.HORIZONTAL; >- } >- >- // RAP [bm]: not used >-// private TrimDropTarget trimDropTarget; >- // RAPEND: [bm] >- >- private boolean coolBarVisible = true; >- >- private boolean perspectiveBarVisible = true; >- >- private boolean fastViewBarVisible = true; >- >- private boolean statusLineVisible = true; >- >- private IWindowTrim statusLineTrim = null; >- >- /** >- * The handlers for global actions that were last submitted to the workbench >- * command support. This is a map of command identifiers to >- * <code>ActionHandler</code>. This map is never <code>null</code>, >- * and is never empty as long as at least one global action has been >- * registered. >- */ >- private Map globalActionHandlersByCommandId = new HashMap(); >- >- /** >- * The list of handler submissions submitted to the workbench command >- * support. This list may be empty, but it is never <code>null</code>. >- */ >- private List handlerActivations = new ArrayList(); >- >- /** >- * The number of large updates that are currently going on. If this is >- * number is greater than zero, then UI updateActionBars is a no-op. >- */ >- private int largeUpdates = 0; >- >- private IExtensionTracker tracker; >- >- private IExtensionChangeHandler actionSetHandler = new IExtensionChangeHandler() { >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamichelpers.IExtensionTracker, >- * org.eclipse.core.runtime.IExtension) >- */ >- public void addExtension(IExtensionTracker tracker, IExtension extension) { >- // this assumes that the workbench-level tracker will have already >- // updated the registry >- >- ArrayList setsToActivate = new ArrayList(); >- // look for all new sets that are on by default. Examine the tracker >- // at the workbench level to see what descriptors are registered >- // against this extension >- Object[] registeredObjects = getWorkbench().getExtensionTracker() >- .getObjects(extension); >- for (int i = 0; i < registeredObjects.length; i++) { >- if (registeredObjects[i] instanceof IActionSetDescriptor) { >- IActionSetDescriptor desc = (IActionSetDescriptor) registeredObjects[i]; >- if (desc.isInitiallyVisible()) { >- setsToActivate.add(desc); >- } >- } >- } >- >- // if none of the new sets are marked as initially visible, abort. >- if (setsToActivate.isEmpty()) { >- return; >- } >- >- IActionSetDescriptor[] descriptors = (IActionSetDescriptor[]) setsToActivate >- .toArray(new IActionSetDescriptor[setsToActivate.size()]); >- >- WorkbenchPage page = getActiveWorkbenchPage(); >- if (page != null) { >- Perspective[] perspectives = page.getOpenInternalPerspectives(); >- >- for (int i = 0; i < perspectives.length; i++) { >- perspectives[i].turnOnActionSets(descriptors); >- } >- } >- >- updateActionSets(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, >- * java.lang.Object[]) >- */ >- public void removeExtension(IExtension extension, Object[] objects) { >- // remove the contributions from the window bars and dispose of the >- // actions >- for (int i = 0; i < objects.length; i++) { >- if (objects[i] instanceof PluginActionSetBuilder.Binding) { >- PluginActionSetBuilder.Binding binding = (PluginActionSetBuilder.Binding) objects[i]; >- binding.builder.removeActionExtensions(binding.set, >- binding.window); >- binding.set.dispose(); >- } >- } >- >- // update all opened perspectives >- Perspective[] perspectives = getActiveWorkbenchPage() >- .getOpenInternalPerspectives(); >- boolean updateNeeded = true; >- IContextService contextService = (IContextService) getService(IContextService.class); >- try { >- contextService.activateContext(ContextAuthority.DEFER_EVENTS); >- >- for (int i = 0; i < perspectives.length; i++) { >- for (int j = 0; j < objects.length; j++) { >- if (objects[j] instanceof IActionSetDescriptor) { >- perspectives[i] >- .removeActionSet((IActionSetDescriptor) objects[j]); >- getActionPresentation().removeActionSet( >- (IActionSetDescriptor) objects[j]); >- } >- } >- } >- } finally { >- contextService.activateContext(ContextAuthority.SEND_EVENTS); >- } >- >- if (updateNeeded) { >- // refresh the window >- updateActionSets(); >- } >- } >- }; >- >- void registerGlobalAction(IAction globalAction) { >- String commandId = globalAction.getActionDefinitionId(); >- >- if (commandId != null) { >- final Object value = globalActionHandlersByCommandId.get(commandId); >- if (value instanceof ActionHandler) { >- // This handler is about to get clobbered, so dispose it. >- final ActionHandler handler = (ActionHandler) value; >- handler.dispose(); >- } >- >- if (globalAction instanceof CommandAction) { >- final String actionId = globalAction.getId(); >- if (actionId != null) { >- final IActionCommandMappingService mappingService = (IActionCommandMappingService) serviceLocator >- .getService(IActionCommandMappingService.class); >- mappingService.map(actionId, commandId); >- } >- } else { >- globalActionHandlersByCommandId.put(commandId, >- new ActionHandler(globalAction)); >- } >- } >- >- submitGlobalActions(); >- } >- >- /** >- * <p> >- * Submits the action handlers for action set actions and global actions. >- * Global actions are given priority, so that if a global action and an >- * action set action both handle the same command, the global action is >- * given priority. >- * </p> >- * <p> >- * These submissions are submitted as <code>Priority.LEGACY</code>, which >- * means that they are the lowest priority. This means that if a higher >- * priority submission handles the same command under the same conditions, >- * that that submission will become the handler. >- * </p> >- */ >- void submitGlobalActions() { >- final IHandlerService handlerService = (IHandlerService) getWorkbench().getService(IHandlerService.class); >- >- /* >- * Mash the action sets and global actions together, with global actions >- * taking priority. >- */ >- Map handlersByCommandId = new HashMap(); >- handlersByCommandId.putAll(globalActionHandlersByCommandId); >- >- List newHandlers = new ArrayList(handlersByCommandId.size()); >- >- Iterator existingIter = handlerActivations.iterator(); >- while (existingIter.hasNext()) { >- IHandlerActivation next = (IHandlerActivation) existingIter.next(); >- >- String cmdId = next.getCommandId(); >- >- Object handler = handlersByCommandId.get(cmdId); >- if (handler == next.getHandler()) { >- handlersByCommandId.remove(cmdId); >- newHandlers.add(next); >- } else { >- handlerService.deactivateHandler(next); >- } >- } >- >- final Shell shell = getShell(); >- if (shell != null) { >- final Expression expression = new ActiveShellExpression(shell); >- for (Iterator iterator = handlersByCommandId.entrySet().iterator(); iterator >- .hasNext();) { >- Map.Entry entry = (Map.Entry) iterator.next(); >- String commandId = (String) entry.getKey(); >- IHandler handler = (IHandler) entry.getValue(); >- newHandlers.add(handlerService.activateHandler(commandId, >- handler, expression)); >- } >- } >- >- handlerActivations = newHandlers; >- } >- >- /** >- * Add a generic property listener. >- * >- * @param listener the listener to add >- */ >- public void addPropertyChangeListener(IPropertyChangeListener listener) { >- genericPropertyListeners.add(listener); >- } >- >- /** >- * Removes a generic property listener. >- * >- * @param listener the listener to remove >- */ >- public void removePropertyChangeListener(IPropertyChangeListener listener) { >- genericPropertyListeners.remove(listener); >- } >- >- private void firePropertyChanged(final String property, final Object oldValue, final Object newValue) { >- PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue); >- Object[] listeners = genericPropertyListeners.getListeners(); >- for (int i = 0; i < listeners.length; i++) { >- IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; >- listener.propertyChange(event); >- } >- } >- >- /* >- * Adds an listener to the part service. >- */ >- public void addPageListener(IPageListener l) { >- pageListeners.addPageListener(l); >- } >- >- /** >- * @see org.eclipse.ui.IPageService >- */ >- public void addPerspectiveListener(org.eclipse.ui.IPerspectiveListener l) { >- perspectiveListeners.addPerspectiveListener(l); >- } >- >- /** >- * Configures this window to have a perspecive bar. Does nothing if it >- * already has one. >- */ >- protected void addPerspectiveBar(int style) { >- Assert.isTrue(perspectiveSwitcher == null); >- perspectiveSwitcher = new PerspectiveSwitcher(this, topBar, style); >- } >- >- /** >- * Close the window. >- * >- * Assumes that busy cursor is active. >- */ >- private boolean busyClose() { >- // Whether the window was actually closed or not >- boolean windowClosed = false; >- >- // Setup internal flags to indicate window is in >- // progress of closing and no update should be done. >- closing = true; >- updateDisabled = true; >- >- try { >- // Only do the check if it is OK to close if we are not closing >- // via the workbench as the workbench will check this itself. >- Workbench workbench = getWorkbenchImpl(); >- int count = workbench.getWorkbenchWindowCount(); >- // also check for starting - if the first window dies on startup >- // then we'll need to open a default window. >- if (!workbench.isStarting() >- && !workbench.isClosing() >- && count <= 1 >- && workbench.getWorkbenchConfigurer() >- .getExitOnLastWindowClose()) { >- windowClosed = workbench.close(); >- } else { >- if (okToClose()) { >- windowClosed = hardClose(); >- } >- } >- } finally { >- if (!windowClosed) { >- // Reset the internal flags if window was not closed. >- closing = false; >- updateDisabled = false; >- } >- } >- >- if (windowClosed && tracker != null) { >- tracker.close(); >- } >- >- return windowClosed; >- } >- >- /** >- * Opens a new page. Assumes that busy cursor is active. >- * <p> >- * <b>Note:</b> Since release 2.0, a window is limited to contain at most >- * one page. If a page exist in the window when this method is used, then >- * another window is created for the new page. Callers are strongly >- * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >- * programmatically show a perspective. >- * </p> >- */ >- protected IWorkbenchPage busyOpenPage(String perspID, IAdaptable input) >- throws WorkbenchException { >- IWorkbenchPage newPage = null; >- >- if (pageList.isEmpty()) { >- newPage = ((WorkbenchImplementation) Tweaklets >- .get(WorkbenchImplementation.KEY)).createWorkbenchPage(this, perspID, input); >- pageList.add(newPage); >- firePageOpened(newPage); >- setActivePage(newPage); >- } else { >- IWorkbenchWindow window = getWorkbench().openWorkbenchWindow( >- perspID, input); >- newPage = window.getActivePage(); >- } >- >- return newPage; >- } >- >- /** >- * @see Window >- */ >- public int open() { >- if (getPages().length == 0) { >- showEmptyWindowContents(); >- } >- fireWindowCreated(); >-// RAP [rh] Intro mechanism not supported >-// getWindowAdvisor().openIntro(); >- int result = super.open(); >+ private Rectangle normalBounds; > >- // It's time for a layout ... to insure that if TrimLayout >- // is in play, it updates all of the trim it's responsible >- // for. We have to do this before updating in order to get >- // the PerspectiveBar management correct...see defect 137334 >- getShell().layout(); >- >- fireWindowOpened(); >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.updatePerspectiveBar(); >- perspectiveSwitcher.updateBarParent(); >- } >- >- return result; >- } >- >- /* >- * (non-Javadoc) Method declared on Window. >- */ >- protected boolean canHandleShellCloseEvent() { >- if (!super.canHandleShellCloseEvent()) { >- return false; >- } >- // let the advisor or other interested parties >- // veto the user's explicit request to close the window >- return fireWindowShellClosing(); >- } >- >- /** >- * @see IWorkbenchWindow >- */ >- public boolean close() { >- final boolean[] ret = new boolean[1]; >- BusyIndicator.showWhile(null, new Runnable() { >- public void run() { >- ret[0] = busyClose(); >- } >- }); >- return ret[0]; >- } >- >- protected boolean isClosing() { >- return closing || getWorkbenchImpl().isClosing(); >- } >- >- /** >- * Return whether or not the coolbar layout is locked. >- */ >- protected boolean isCoolBarLocked() { >- ICoolBarManager cbm = getCoolBarManager2(); >- return cbm != null && cbm.getLockLayout(); >- } >+ private boolean asMaximizedState = false; > >- /** >- * Close all of the pages. >- */ >- private void closeAllPages() { >- // Deactivate active page. >- setActivePage(null); >- >- // Clone and deref all so that calls to getPages() returns >- // empty list (if call by pageClosed event handlers) >- PageList oldList = pageList; >- pageList = new PageList(); >- >- // Close all. >- Iterator itr = oldList.iterator(); >- while (itr.hasNext()) { >- WorkbenchPage page = (WorkbenchPage) itr.next(); >- firePageClosed(page); >- page.dispose(); >- } >- if (!closing) { >- showEmptyWindowContents(); >- } >- } >- >- /** >- * Save and close all of the pages. >- */ >- public void closeAllPages(boolean save) { >- if (save) { >- boolean ret = saveAllPages(true); >- if (!ret) { >- return; >- } >- } >- closeAllPages(); >- } >- >- /** >- * closePerspective method comment. >- */ >- protected boolean closePage(IWorkbenchPage in, boolean save) { >- // Validate the input. >- if (!pageList.contains(in)) { >- return false; >- } >- WorkbenchPage oldPage = (WorkbenchPage) in; >- >- // Save old perspective. >- if (save && oldPage.isSaveNeeded()) { >- if (!oldPage.saveAllEditors(true)) { >- return false; >- } >- } >- >- // If old page is activate deactivate. >- boolean oldIsActive = (oldPage == getActiveWorkbenchPage()); >- if (oldIsActive) { >- setActivePage(null); >- } >- >- // Close old page. >- pageList.remove(oldPage); >- firePageClosed(oldPage); >- oldPage.dispose(); >- >- // Activate new page. >- if (oldIsActive) { >- IWorkbenchPage newPage = pageList.getNextActive(); >- if (newPage != null) { >- setActivePage(newPage); >- } >- } >- if (!closing && pageList.isEmpty()) { >- showEmptyWindowContents(); >- } >- return true; >- } >- >- private void showEmptyWindowContents() { >- if (!emptyWindowContentsCreated) { >- Composite parent = getPageComposite(); >- emptyWindowContents = getWindowAdvisor().createEmptyWindowContents( >- parent); >- emptyWindowContentsCreated = true; >- // force the empty window composite to be layed out >- ((StackLayout) parent.getLayout()).topControl = emptyWindowContents; >- parent.layout(); >- } >- } >- >- private void hideEmptyWindowContents() { >- if (emptyWindowContentsCreated) { >- if (emptyWindowContents != null) { >- emptyWindowContents.dispose(); >- emptyWindowContents = null; >- getPageComposite().layout(); >- } >- emptyWindowContentsCreated = false; >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >- */ >- protected void configureShell(Shell shell) { >- super.configureShell(shell); >- >- // RAP [bm]: detached windows >-// detachedWindowShells = new ShellPool(shell, SWT.TOOL | SWT.TITLE >-// | SWT.MAX | SWT.RESIZE | getDefaultOrientation()); >- // RAPEND: [bm] >- >- String title = getWindowConfigurer().basicGetTitle(); >- if (title != null) { >- shell.setText(TextProcessor.process(title, TEXT_DELIMITERS)); >- } >+ private CBanner topBar; > >-// RAP [rh] IWorkbench#getHelpSystem() not implemented >-// final IWorkbench workbench = getWorkbench(); >-// workbench.getHelpSystem().setHelp(shell, >-// IWorkbenchHelpContextIds.WORKBENCH_WINDOW); >- >-// initializeDefaultServices(); >- final IContextService contextService = (IContextService) getWorkbench().getService(IContextService.class); >- contextService.registerShell(shell, IContextService.TYPE_WINDOW); >- >- trackShellActivation(shell); >- trackShellResize(shell); >- } >- >- // RAP [bm]: detached windows >-// /* package */ShellPool getDetachedWindowPool() { >-// return detachedWindowShells; >-// } >- // RAPEND: [bm] >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.window.ApplicationWindow#createTrimWidgets(org.eclipse.swt.widgets.Shell) >- */ >- protected void createTrimWidgets(Shell shell) { >- // do nothing -- trim widgets are created in createDefaultContents >- } >- >- /** >- * Creates and remembers the client composite, under which workbench pages >- * create their controls. >- */ >- protected Composite createPageComposite(Composite parent) { >- pageComposite = new Composite(parent, SWT.NONE); >- // use a StackLayout instead of a FillLayout (see bug 81460 [Workbench] >- // (regression) Close all perspectives, open Java perspective, layout >- // wrong) >- pageComposite.setLayout(new StackLayout()); >- return pageComposite; >- } >- >- /** >- * Creates the contents of the workbench window, including trim controls and >- * the client composite. This MUST create the client composite via a call to >- * <code>createClientComposite</code>. >- */ >- protected Control createContents(Composite parent) { >- // we know from Window.create that the parent is a Shell. >- getWindowAdvisor().createWindowContents((Shell) parent); >- // the page composite must be set by createWindowContents >- Assert >- .isNotNull(pageComposite, >- "createWindowContents must call configurer.createPageComposite"); //$NON-NLS-1$ >- return pageComposite; >- } >- >- /** >- * If the perspective bar is drawn on the top right corner of the window, >- * then this method changes its appearance from curved to square. This >- * should have its own preference, but for now it piggy-backs on the >- * SHOW_TRADITIONAL_STYLE_TABS preference. >- * >- * @param square >- * true for a square banner and false otherwise >- */ >- public void setBannerCurve(boolean square) { >- if (topBar != null) { >- topBar.setSimple(square); >- } >- } >- >- /** >- * Creates the default contents and layout of the shell. >- * >- * @param shell >- * the shell >- */ >- protected void createDefaultContents(final Shell shell) { >- defaultLayout = new TrimLayout(); >- shell.setLayout(defaultLayout); >- >- Menu menuBar = getMenuBarManager().createMenuBar(shell); >- if (getWindowConfigurer().getShowMenuBar()) { >- shell.setMenuBar(menuBar); >- } >- >- // Create the CBanner widget which parents both the Coolbar >- // and the perspective switcher, and supports some configurations >- // on the left right and bottom >- topBar = new CBanner(shell, SWT.NONE); >- topBarTrim = new WindowTrimProxy(topBar, >- "org.eclipse.ui.internal.WorkbenchWindow.topBar", //$NON-NLS-1$ >- WorkbenchMessages.get().TrimCommon_Main_TrimName, SWT.NONE, true); >- >- // the banner gets a curve along with the new tab style >- // TODO create a dedicated preference for this >- // RAP [bm]: not needed >-// setBannerCurve(PrefUtil.getAPIPreferenceStore().getBoolean( >-// IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); >- setBannerCurve(false); >- // RAPEND: [bm] >- >- CacheWrapper coolbarCacheWrapper = new CacheWrapper(topBar); >- >- final Control coolBar = createCoolBarControl(coolbarCacheWrapper >- .getControl()); >- // need to resize the shell, not just the coolbar's immediate >- // parent, if the coolbar wants to grow or shrink >- >- coolBar.addListener(SWT.Resize, new Listener() { >- public void handleEvent(Event event) { >- // If the user is dragging the sash then we will need to force >- // a resize. However, if the coolbar was resized programatically >- // then everything is already layed out correctly. There is no >- // direct way to tell the difference between these cases, >- // however >- // we take advantage of the fact that dragging the sash does not >- // change the size of the shell, and only force another layout >- // if the shell size is unchanged. >- Rectangle clientArea = shell.getClientArea(); >- >- if (lastShellSize.x == clientArea.width >- && lastShellSize.y == clientArea.height) { >- LayoutUtil.resize(coolBar); >- } >- >- lastShellSize.x = clientArea.width; >- lastShellSize.y = clientArea.height; >- } >- }); >- >- if (getWindowConfigurer().getShowCoolBar()) { >- topBar.setLeft(coolbarCacheWrapper.getControl()); >- } >- >- createStatusLine(shell); >- >- fastViewBar = new FastViewBar(this); >- fastViewBar.createControl(shell); >- >- if (getWindowConfigurer().getShowPerspectiveBar()) { >- addPerspectiveBar(perspectiveBarStyle()); >- perspectiveSwitcher.createControl(shell); >- } >+ private IWindowTrim topBarTrim; > >- createProgressIndicator(shell); >+ // Previous shell size. Used to prevent the CBanner from triggering >+ // redundant layouts >+ private Point lastShellSize = new Point(0, 0); > >-// RAP [rh] HeapStatus not supported >-// if (getShowHeapStatus()) { >-// createHeapStatus(shell); >-// } >- >- // Insert any contributed trim into the layout >- // Legacy (3.2) trim >- trimMgr2 = new TrimBarManager2(this); >- >- // 3.3 Trim contributions >- trimContributionMgr = new TrimContributionManager(this); >- >- // RAP [bm]: DnD >-// trimDropTarget = new TrimDropTarget(shell, this); >-// DragUtil.addDragTarget(shell, trimDropTarget); >-// DragUtil.addDragTarget(null, trimDropTarget); >- // RAPEND: [bm] >- >- // Create the client composite area (where page content goes). >- createPageComposite(shell); >- >- setLayoutDataForContents(); >- // System.err.println(defaultLayout.displayTrim()); >- } >+ /** >+ * The composite under which workbench pages create their controls. >+ */ >+ private Composite pageComposite; > >-// RAP [rh] HeapStatus not supported >-// /** >-// * Returns whether the heap status indicator should be shown. >-// * >-// * @return <code>true</code> to show the heap status indicator, >-// * <code>false</code> otherwise >-// */ >-// private boolean getShowHeapStatus() { >-// return // Show if the preference is set or debug option is on >-// PrefUtil.getAPIPreferenceStore().getBoolean( >-// IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR) >-// || Boolean.valueOf( >-// Platform.getDebugOption(PlatformUI.PLUGIN_ID >-// + "/perf/showHeapStatus")).booleanValue(); //$NON-NLS-1$ >-// } >-// >-// /** >-// * Creates the controls for the heap status indicator. >-// * >-// * @param parent >-// * the parent composite >-// */ >-// private void createHeapStatus(Composite parent) { >-// heapStatus = new HeapStatus(parent, PrefUtil >-// .getInternalPreferenceStore()); >-// >-// // Subclass the trim to allow closing... >-// heapStatusTrim = new WindowTrimProxy(heapStatus, >-// "org.eclipse.ui.internal.HeapStatus", //$NON-NLS-1$ >-// WorkbenchMessages.get().TrimCommon_HeapStatus_TrimName, SWT.BOTTOM >-// | SWT.TOP) { >-// >-// public void handleClose() { >-// getControl().dispose(); >-// } >-// >-// public boolean isCloseable() { >-// return true; >-// } >-// }; >-// } >- >- /** >- * <p> >- * Returns a new menu manager for this workbench window. This menu manager >- * will just be a proxy to the new command-based menu service. >- * </p> >- * <p> >- * Subclasses may override this method to customize the menu manager. >- * </p> >- * >- * @return a menu manager for this workbench window; never <code>null</code>. >- */ >- protected MenuManager createMenuManager() { >- return super.createMenuManager(); >- } >- >- /** >- * Set the perspective bar location >- * >- * @param location >- * the location to place the bar >- */ >- public void setPerspectiveBarLocation(String location) { >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.setPerspectiveBarLocation(location); >- } >- } >- >- /** >- * Notifies interested parties (namely the advisor) that the window is about >- * to be opened. >- */ >- private void fireWindowOpening() { >- // let the application do further configuration >- getWindowAdvisor().preWindowOpen(); >- } >- >- /** >- * Notifies interested parties (namely the advisor) that the window has been >- * restored from a previously saved state. >- * >- * @throws WorkbenchException >- * passed through from the advisor >- */ >- void fireWindowRestored() throws WorkbenchException { >- StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { >- public void runWithException() throws Throwable { >- getWindowAdvisor().postWindowRestore(); >- } >- }); >- } >- >- /** >- * Notifies interested parties (namely the advisor) that the window has been >- * created. >- */ >- private void fireWindowCreated() { >- getWindowAdvisor().postWindowCreate(); >- } >- >- /** >- * Notifies interested parties (namely the advisor and the window listeners) >- * that the window has been opened. >- */ >- private void fireWindowOpened() { >- getWorkbenchImpl().fireWindowOpened(this); >- getWindowAdvisor().postWindowOpen(); >- } >- >- /** >- * Notifies interested parties (namely the advisor) that the window's shell >- * is closing. Allows the close to be vetoed. >- * >- * @return <code>true</code> if the close should proceed, >- * <code>false</code> if it should be canceled >- */ >- private boolean fireWindowShellClosing() { >- return getWindowAdvisor().preWindowShellClose(); >- } >- >- /** >- * Notifies interested parties (namely the advisor and the window listeners) >- * that the window has been closed. >- */ >- private void fireWindowClosed() { >- // let the application do further deconfiguration >- getWindowAdvisor().postWindowClose(); >- getWorkbenchImpl().fireWindowClosed(this); >- } >- >- /** >- * Fires page activated >- */ >- private void firePageActivated(IWorkbenchPage page) { >- String label = null; // debugging only >- if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >- label = "activated " + page.getLabel(); //$NON-NLS-1$ >- } >- try { >- UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >- UIListenerLogging.logPageEvent(this, page, >- UIListenerLogging.WPE_PAGE_ACTIVATED); >- pageListeners.firePageActivated(page); >- partService.pageActivated(page); >- } finally { >- UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >- } >- } >- >- /** >- * Fires page closed >- */ >- private void firePageClosed(IWorkbenchPage page) { >- String label = null; // debugging only >- if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >- label = "closed " + page.getLabel(); //$NON-NLS-1$ >- } >- try { >- UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >- UIListenerLogging.logPageEvent(this, page, >- UIListenerLogging.WPE_PAGE_CLOSED); >- pageListeners.firePageClosed(page); >- partService.pageClosed(page); >- } finally { >- UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >- } >- >- } >- >- /** >- * Fires page opened >- */ >- private void firePageOpened(IWorkbenchPage page) { >- String label = null; // debugging only >- if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >- label = "opened " + page.getLabel(); //$NON-NLS-1$ >- } >- try { >- UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >- UIListenerLogging.logPageEvent(this, page, >- UIListenerLogging.WPE_PAGE_OPENED); >- pageListeners.firePageOpened(page); >- partService.pageOpened(page); >- } finally { >- UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >- } >- } >- >- /** >- * Fires perspective activated >- */ >- void firePerspectiveActivated(IWorkbenchPage page, >- IPerspectiveDescriptor perspective) { >- UIListenerLogging.logPerspectiveEvent(this, page, perspective, >- UIListenerLogging.PLE_PERSP_ACTIVATED); >- perspectiveListeners.firePerspectiveActivated(page, perspective); >- } >- >- /** >- * Fires perspective deactivated. >- */ >- void firePerspectivePreDeactivate(IWorkbenchPage page, >- IPerspectiveDescriptor perspective) { >- UIListenerLogging.logPerspectiveEvent(this, page, perspective, >- UIListenerLogging.PLE_PERSP_PRE_DEACTIVATE); >- perspectiveListeners.firePerspectivePreDeactivate(page, perspective); >- } >- >- /** >- * Fires perspective deactivated. >- */ >- void firePerspectiveDeactivated(IWorkbenchPage page, >- IPerspectiveDescriptor perspective) { >- UIListenerLogging.logPerspectiveEvent(this, page, perspective, >- UIListenerLogging.PLE_PERSP_DEACTIVATED); >- perspectiveListeners.firePerspectiveDeactivated(page, perspective); >- } >- >- /** >- * Fires perspective changed >- */ >- public void firePerspectiveChanged(IWorkbenchPage page, >- IPerspectiveDescriptor perspective, String changeId) { >- // Some callers call this even when there is no active perspective. >- // Just ignore this case. >- if (perspective != null) { >- UIListenerLogging.logPerspectiveChangedEvent(this, page, >- perspective, null, changeId); >- perspectiveListeners.firePerspectiveChanged(page, perspective, >- changeId); >- } >- } >- >- /** >- * Fires perspective changed for an affected part >- */ >- public void firePerspectiveChanged(IWorkbenchPage page, >- IPerspectiveDescriptor perspective, >- IWorkbenchPartReference partRef, String changeId) { >- // Some callers call this even when there is no active perspective. >- // Just ignore this case. >- if (perspective != null) { >- UIListenerLogging.logPerspectiveChangedEvent(this, page, >- perspective, partRef, changeId); >- perspectiveListeners.firePerspectiveChanged(page, perspective, >- partRef, changeId); >- } >- } >- >- /** >- * Fires perspective closed >- */ >- void firePerspectiveClosed(IWorkbenchPage page, >- IPerspectiveDescriptor perspective) { >- UIListenerLogging.logPerspectiveEvent(this, page, perspective, >- UIListenerLogging.PLE_PERSP_CLOSED); >- perspectiveListeners.firePerspectiveClosed(page, perspective); >- } >- >- /** >- * Fires perspective opened >- */ >- void firePerspectiveOpened(IWorkbenchPage page, >- IPerspectiveDescriptor perspective) { >- UIListenerLogging.logPerspectiveEvent(this, page, perspective, >- UIListenerLogging.PLE_PERSP_OPENED); >- perspectiveListeners.firePerspectiveOpened(page, perspective); >- } >- >- /** >- * Fires perspective saved as. >- */ >- void firePerspectiveSavedAs(IWorkbenchPage page, >- IPerspectiveDescriptor oldPerspective, >- IPerspectiveDescriptor newPerspective) { >- UIListenerLogging.logPerspectiveSavedAs(this, page, oldPerspective, >- newPerspective); >- perspectiveListeners.firePerspectiveSavedAs(page, oldPerspective, >- newPerspective); >- } >- >- /** >- * Returns the action bars for this window. >- */ >- public WWinActionBars getActionBars() { >- if (actionBars == null) { >- actionBars = new WWinActionBars(this); >- } >- return actionBars; >- } >- >- /** >- * Returns the active page. >- * >- * @return the active page >- */ >- public IWorkbenchPage getActivePage() { >- return pageList.getActive(); >- } >- >- /** >- * Returns the active workbench page. >- * >- * @return the active workbench page >- */ >- /* package */ >- WorkbenchPage getActiveWorkbenchPage() { >- return pageList.getActive(); >- } >- >- /** >- * Returns the page composite, under which the window's pages create their >- * controls. >- */ >- protected Composite getPageComposite() { >- return pageComposite; >- } >- >- /** >- * Answer the menu manager for this window. >- */ >- public MenuManager getMenuManager() { >- return getMenuBarManager(); >- } >- >- /** >- * Returns the number. This corresponds to a page number in a window or a >- * window number in the workbench. >- */ >- public int getNumber() { >- return number; >- } >- >- /** >- * Returns an array of the pages in the workbench window. >- * >- * @return an array of pages >- */ >- public IWorkbenchPage[] getPages() { >- return pageList.getPages(); >- } >- >- /** >- * @see IWorkbenchWindow >- */ >- public IPartService getPartService() { >- return partService; >- } >- >- /** >- * Returns the layout for the shell. >- * >- * @return the layout for the shell >- */ >- protected Layout getLayout() { >- return null; >- } >- >- /** >- * @see IWorkbenchWindow >- */ >- public ISelectionService getSelectionService() { >- return partService.getSelectionService(); >- } >- >- /** >- * Returns <code>true</code> when the window's shell is activated, >- * <code>false</code> when it's shell is deactivated >- * >- * @return boolean <code>true</code> when shell activated, >- * <code>false</code> when shell deactivated >- */ >- public boolean getShellActivated() { >- return shellActivated; >- } >- >- /** >- * Returns the status line manager for this window (if it has one). >- * >- * @return the status line manager, or <code>null</code> if this window >- * does not have a status line >- * @see ApplicationWindow#addStatusLine >- */ >- public StatusLineManager getStatusLineManager() { >- return super.getStatusLineManager(); >- } >- >- private IWindowTrim getStatusLineTrim() { >- if (statusLineTrim == null) { >- statusLineTrim = new WindowTrimProxy( >- getStatusLineManager().getControl(), >- "org.eclipse.jface.action.StatusLineManager", //$NON-NLS-1$ >- WorkbenchMessages.get().TrimCommon_StatusLine_TrimName, SWT.NONE, >- true); >- } >- return statusLineTrim; >- } >- >- /** >- * @see IWorkbenchWindow >- */ >- public IWorkbench getWorkbench() { >- return PlatformUI.getWorkbench(); >- } >- >- public String getToolbarLabel(String actionSetId) { >- ActionSetRegistry registry = WorkbenchPlugin.getDefault() >- .getActionSetRegistry(); >- IActionSetDescriptor actionSet = registry.findActionSet(actionSetId); >- if (actionSet != null) { >- return actionSet.getLabel(); >- } >- >- if (IWorkbenchActionConstants.TOOLBAR_FILE >- .equalsIgnoreCase(actionSetId)) { >- return WorkbenchMessages.get().WorkbenchWindow_FileToolbar; >- } >- >- if (IWorkbenchActionConstants.TOOLBAR_NAVIGATE >- .equalsIgnoreCase(actionSetId)) { >- return WorkbenchMessages.get().WorkbenchWindow_NavigateToolbar; >- } >- >- return null; >- } >- >- /** >- * Unconditionally close this window. Assumes the proper flags have been set >- * correctly (e.i. closing and updateDisabled) >- */ >- private boolean hardClose() { >- boolean result; >- try { >- // Clear the action sets, fix for bug 27416. >- getActionPresentation().clearActionSets(); >+ /** >+ * Bit flags indication which submenus (New, Show Views, ...) this window >+ * contains. Initially none. >+ */ >+ private int submenus = 0x00; > >- // Remove the handler submissions. Bug 64024. >- final IWorkbench workbench = getWorkbench(); >- final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class); >- handlerService.deactivateHandlers(handlerActivations); >- final Iterator activationItr = handlerActivations.iterator(); >- while (activationItr.hasNext()) { >- final IHandlerActivation activation = (IHandlerActivation) activationItr >- .next(); >- activation.getHandler().dispose(); >- } >- handlerActivations.clear(); >- globalActionHandlersByCommandId.clear(); >- >- // Remove the enabled submissions. Bug 64024. >- final IContextService contextService = (IContextService) workbench.getService(IContextService.class); >- contextService.unregisterShell(getShell()); >- >- closeAllPages(); >- >- fireWindowClosed(); >- >- // time to wipe our our populate >- IMenuService menuService = (IMenuService) workbench >- .getService(IMenuService.class); >- menuService >- .releaseContributions(((ContributionManager) getActionBars() >- .getMenuManager())); >- ICoolBarManager coolbar = getActionBars().getCoolBarManager(); >- if (coolbar != null) { >- menuService >- .releaseContributions(((ContributionManager) coolbar)); >- } >- >- getActionBarAdvisor().dispose(); >- getWindowAdvisor().dispose(); >- >- // RAP [bm]: detached windows >-// detachedWindowShells.dispose(); >- // RAPEND: [bm] >- >- // Bring down all of the services. >- serviceLocator.dispose(); >- >- // Null out the progress region. Bug 64024. >- progressRegion = null; >- >- // RAP [bm]: >-// // Remove drop targets >-// DragUtil.removeDragTarget(null, trimDropTarget); >-// DragUtil.removeDragTarget(getShell(), trimDropTarget); >-// trimDropTarget = null; >- // RAPEND: [bm] >- >- if (trimMgr2 != null) { >- trimMgr2.dispose(); >- trimMgr2 = null; >- } >- >- if (trimContributionMgr != null) { >- trimContributionMgr.dispose(); >- trimContributionMgr = null; >- } >- } finally { >- result = super.close(); >- } >- return result; >- } >- >- /** >- * @see IWorkbenchWindow >- */ >- public boolean isApplicationMenu(String menuID) { >- // delegate this question to the action bar advisor >- return getActionBarAdvisor().isApplicationMenu(menuID); >- } >- >- /** >- * Return whether or not the given id matches the id of the coolitems that >- * the application creates. >- */ >- /* package */ >- boolean isWorkbenchCoolItemId(String id) { >- return windowConfigurer.containsCoolItem(id); >- } >- >- /** >- * Locks/unlocks the CoolBar for the workbench. >- * >- * @param lock >- * whether the CoolBar should be locked or unlocked >- */ >- /* package */ >- void lockCoolBar(boolean lock) { >- getCoolBarManager2().setLockLayout(lock); >- } >+ /** >+ * Object for configuring this workbench window. Lazily initialized to an >+ * instance unique to this window. >+ */ >+ private WorkbenchWindowConfigurer windowConfigurer = null; >+ >+ /** >+ * List of generic property listeners. >+ */ >+ private ListenerList genericPropertyListeners = new ListenerList(); > >- /** >- * Makes the window visible and frontmost. >- */ >- void makeVisible() { >- Shell shell = getShell(); >- if (shell != null && !shell.isDisposed()) { >- // see bug 96700 and bug 4414 for a discussion on the use of open() >- // here >- shell.open(); >- } >- } >- >- /** >- * Called when this window is about to be closed. >- * >- * Subclasses may overide to add code that returns <code>false</code> to >- * prevent closing under certain conditions. >- */ >- public boolean okToClose() { >- // Save all of the editors. >- if (!getWorkbenchImpl().isClosing()) { >- if (!saveAllPages(true)) { >- return false; >- } >- } >- return true; >- } >- >- /** >- * Opens a new page. >- * <p> >- * <b>Note:</b> Since release 2.0, a window is limited to contain at most >- * one page. If a page exist in the window when this method is used, then >- * another window is created for the new page. Callers are strongly >- * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >- * programmatically show a perspective. >- * </p> >- */ >- public IWorkbenchPage openPage(final String perspId, final IAdaptable input) >- throws WorkbenchException { >- Assert.isNotNull(perspId); >- >- // Run op in busy cursor. >- final Object[] result = new Object[1]; >- BusyIndicator.showWhile(null, new Runnable() { >- public void run() { >- try { >- result[0] = busyOpenPage(perspId, input); >- } catch (WorkbenchException e) { >- result[0] = e; >- } >- } >- }); >- >- if (result[0] instanceof IWorkbenchPage) { >- return (IWorkbenchPage) result[0]; >- } else if (result[0] instanceof WorkbenchException) { >- throw (WorkbenchException) result[0]; >- } else { >- throw new WorkbenchException( >- WorkbenchMessages.get().WorkbenchWindow_exceptionMessage); >- } >- } >- >- /** >- * Opens a new page. >- * <p> >- * <b>Note:</b> Since release 2.0, a window is limited to contain at most >- * one page. If a page exist in the window when this method is used, then >- * another window is created for the new page. Callers are strongly >- * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >- * programmatically show a perspective. >- * </p> >- */ >- public IWorkbenchPage openPage(IAdaptable input) throws WorkbenchException { >- String perspId = getWorkbenchImpl().getPerspectiveRegistry() >- .getDefaultPerspective(); >- return openPage(perspId, input); >- } >- >- /* >- * Removes an listener from the part service. >- */ >- public void removePageListener(IPageListener l) { >- pageListeners.removePageListener(l); >- } >- >- /** >- * @see org.eclipse.ui.IPageService >- */ >- public void removePerspectiveListener(org.eclipse.ui.IPerspectiveListener l) { >- perspectiveListeners.removePerspectiveListener(l); >- } >- >- private IStatus unableToRestorePage(IMemento pageMem) { >- String pageName = pageMem.getString(IWorkbenchConstants.TAG_LABEL); >- if (pageName == null) { >- pageName = ""; //$NON-NLS-1$ >- } >- return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind( >- WorkbenchMessages.get().WorkbenchWindow_unableToRestorePerspective, >- pageName), null); >- } >- >- public IStatus restoreState(IMemento memento, >- IPerspectiveDescriptor activeDescriptor) { >- Assert.isNotNull(getShell()); >- >- final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, >- WorkbenchMessages.get().WorkbenchWindow_problemsRestoringWindow, null); >- >- // Restore the window advisor state. >- IMemento windowAdvisorState = memento >- .getChild(IWorkbenchConstants.TAG_WORKBENCH_WINDOW_ADVISOR); >- if (windowAdvisorState != null) { >- result.add(getWindowAdvisor().restoreState(windowAdvisorState)); >- } >- >- // Restore actionbar advisor state. >- IMemento actionBarAdvisorState = memento >- .getChild(IWorkbenchConstants.TAG_ACTION_BAR_ADVISOR); >- if (actionBarAdvisorState != null) { >- result.add(getActionBarAdvisor() >- .restoreState(actionBarAdvisorState)); >- } >- >- // Read window's bounds and state. >- final Rectangle [] displayBounds = new Rectangle[1]; >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() { >- displayBounds[0] = getShell().getDisplay().getBounds(); >- >- }}); >- final Rectangle shellBounds = new Rectangle(0, 0, 0, 0); >- >- final IMemento fastViewMem = memento >- .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >- if (fastViewMem != null) { >- if (fastViewBar != null) { >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() { >- fastViewBar.restoreState(fastViewMem); >- }}); >- >- } >- } >- Integer bigInt = memento.getInteger(IWorkbenchConstants.TAG_X); >- shellBounds.x = bigInt == null ? 0 : bigInt.intValue(); >- bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y); >- shellBounds.y = bigInt == null ? 0 : bigInt.intValue(); >- bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH); >- shellBounds.width = bigInt == null ? 0 : bigInt.intValue(); >- bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT); >- shellBounds.height = bigInt == null ? 0 : bigInt.intValue(); >- if (!shellBounds.isEmpty()) { >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() { >- if (!shellBounds.intersects(displayBounds[0])) { >- // RAP [bm]: Display#getClientArea >-// Rectangle clientArea = getShell().getDisplay().getClientArea(); >- Rectangle clientArea = getShell().getDisplay().getBounds(); >- // RAPEND: [bm] >- >- shellBounds.x = clientArea.x; >- shellBounds.y = clientArea.y; >- } >- getShell().setBounds(shellBounds); >- }}); >- } >- if ("true".equals(memento.getString(IWorkbenchConstants.TAG_MAXIMIZED))) { //$NON-NLS-1$ >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() { >- getShell().setMaximized(true); >- }}); >- >- } >- if ("true".equals(memento.getString(IWorkbenchConstants.TAG_MINIMIZED))) { //$NON-NLS-1$ >- // getShell().setMinimized(true); >- } >- >- // restore the width of the perspective bar >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.restoreState(memento); >- } >- >- // Restore the cool bar order by creating all the tool bar contribution >- // items >- // This needs to be done before pages are created to ensure proper >- // canonical creation >- // of cool items >- final ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >- if (coolBarMgr != null) { >- IMemento coolBarMem = memento >- .getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); >- if (coolBarMem != null) { >- // Check if the layout is locked >- final Integer lockedInt = coolBarMem >- .getInteger(IWorkbenchConstants.TAG_LOCKED); >- StartupThreading.runWithoutExceptions(new StartupRunnable(){ >- >- public void runWithException() { >- if ((lockedInt != null) && (lockedInt.intValue() == 1)) { >- coolBarMgr.setLockLayout(true); >- } else { >- coolBarMgr.setLockLayout(false); >- } >- }}); >- >- // The new layout of the cool bar manager >- ArrayList coolBarLayout = new ArrayList(); >- // Traverse through all the cool item in the memento >- IMemento contributionMems[] = coolBarMem >- .getChildren(IWorkbenchConstants.TAG_COOLITEM); >- for (int i = 0; i < contributionMems.length; i++) { >- IMemento contributionMem = contributionMems[i]; >- String type = contributionMem >- .getString(IWorkbenchConstants.TAG_ITEM_TYPE); >- if (type == null) { >- // Do not recognize that type >- continue; >- } >- String id = contributionMem >- .getString(IWorkbenchConstants.TAG_ID); >- >- // Prevent duplicate items from being read back in. >- IContributionItem existingItem = coolBarMgr.find(id); >- if ((id != null) && (existingItem != null)) { >- if (Policy.DEBUG_TOOLBAR_DISPOSAL) { >- System.out >- .println("Not loading duplicate cool bar item: " + id); //$NON-NLS-1$ >- } >- coolBarLayout.add(existingItem); >- continue; >- } >- IContributionItem newItem = null; >- if (type.equals(IWorkbenchConstants.TAG_TYPE_SEPARATOR)) { >- if (id != null) { >- newItem = new Separator(id); >- } else { >- newItem = new Separator(); >- } >- } else if (id != null) { >- if (type >- .equals(IWorkbenchConstants.TAG_TYPE_GROUPMARKER)) { >- newItem = new GroupMarker(id); >- >- } else if (type >- .equals(IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION) >- || type >- .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { >- >- // Get Width and height >- Integer width = contributionMem >- .getInteger(IWorkbenchConstants.TAG_ITEM_X); >- Integer height = contributionMem >- .getInteger(IWorkbenchConstants.TAG_ITEM_Y); >- // Look for the object in the current cool bar >- // manager >- IContributionItem oldItem = coolBarMgr.find(id); >- // If a tool bar contribution item already exists >- // for this id then use the old object >- if (oldItem != null) { >- newItem = oldItem; >- } else { >- IActionBarPresentationFactory actionBarPresentation = getActionBarPresentationFactory(); >- newItem = actionBarPresentation.createToolBarContributionItem( >- actionBarPresentation.createToolBarManager(), id); >- if (type >- .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { >- IToolBarContributionItem newToolBarItem = (IToolBarContributionItem) newItem; >- if (height != null) { >- newToolBarItem.setCurrentHeight(height >- .intValue()); >- } >- if (width != null) { >- newToolBarItem.setCurrentWidth(width >- .intValue()); >- } >- newItem = new PlaceholderContributionItem( >- newToolBarItem); >- } >- // make it invisible by default >- newItem.setVisible(false); >- // Need to add the item to the cool bar manager >- // so that its canonical order can be preserved >- IContributionItem refItem = findAlphabeticalOrder( >- IWorkbenchActionConstants.MB_ADDITIONS, >- id, coolBarMgr); >- if (refItem != null) { >- coolBarMgr.insertAfter(refItem.getId(), >- newItem); >- } else { >- coolBarMgr.add(newItem); >- } >- } >- // Set the current height and width >- if ((width != null) >- && (newItem instanceof IToolBarContributionItem)) { >- ((IToolBarContributionItem) newItem) >- .setCurrentWidth(width.intValue()); >- } >- if ((height != null) >- && (newItem instanceof IToolBarContributionItem)) { >- ((IToolBarContributionItem) newItem) >- .setCurrentHeight(height.intValue()); >- } >- } >- } >- // Add new item into cool bar manager >- if (newItem != null) { >- coolBarLayout.add(newItem); >- newItem.setParent(coolBarMgr); >- coolBarMgr.markDirty(); >- } >- } >- >- // We need to check if we have everything we need in the layout. >- final ArrayList finalLayout = new ArrayList(); >- IContributionItem[] existingItems = coolBarMgr.getItems(); >- for (int i = 0; i < existingItems.length; i++) { >- IContributionItem existingItem = existingItems[i]; >- >- /* >- * This line shouldn't be necessary, but is here for >- * robustness. >- */ >- if (existingItem == null) { >- continue; >- } >- >- boolean found = false; >- Iterator layoutItemItr = coolBarLayout.iterator(); >- while (layoutItemItr.hasNext()) { >- IContributionItem layoutItem = (IContributionItem) layoutItemItr >- .next(); >- if ((layoutItem != null) >- && (layoutItem.equals(existingItem))) { >- found = true; >- break; >- } >- } >- >- if (!found) { >- if (existingItem != null) { >- finalLayout.add(existingItem); >- } >- } >- } >- >- // Set the cool bar layout to the given layout. >- finalLayout.addAll(coolBarLayout); >- final IContributionItem[] itemsToSet = new IContributionItem[finalLayout >- .size()]; >- finalLayout.toArray(itemsToSet); >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() { >- coolBarMgr.setItems(itemsToSet); >- }}); >- >- } else { >- // For older workbenchs >- coolBarMem = memento >- .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT); >- if (coolBarMem != null) { >- // Restore an older layout >- restoreOldCoolBar(coolBarMem); >- } >- } >- } >- >- // Recreate each page in the window. >- IWorkbenchPage newActivePage = null; >- IMemento[] pageArray = memento >- .getChildren(IWorkbenchConstants.TAG_PAGE); >- for (int i = 0; i < pageArray.length; i++) { >- final IMemento pageMem = pageArray[i]; >- String strFocus = pageMem.getString(IWorkbenchConstants.TAG_FOCUS); >- if (strFocus == null || strFocus.length() == 0) { >- continue; >- } >- >- // Get the input factory. >- final IAdaptable [] input = new IAdaptable[1]; >- final IMemento inputMem = pageMem.getChild(IWorkbenchConstants.TAG_INPUT); >- if (inputMem != null) { >- final String factoryID = inputMem >- .getString(IWorkbenchConstants.TAG_FACTORY_ID); >- if (factoryID == null) { >- WorkbenchPlugin >- .log("Unable to restore page - no input factory ID."); //$NON-NLS-1$ >- result.add(unableToRestorePage(pageMem)); >- continue; >- } >- try { >- UIStats.start(UIStats.RESTORE_WORKBENCH, >- "WorkbenchPageFactory"); //$NON-NLS-1$ >- StartupThreading >- .runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- IElementFactory factory = PlatformUI >- .getWorkbench().getElementFactory( >- factoryID); >- if (factory == null) { >- WorkbenchPlugin >- .log("Unable to restore page - cannot instantiate input factory: " + factoryID); //$NON-NLS-1$ >- result >- .add(unableToRestorePage(pageMem)); >- return; >- } >- >- // Get the input element. >- input[0] = factory.createElement(inputMem); >- } >- }); >- >- if (input[0] == null) { >- WorkbenchPlugin >- .log("Unable to restore page - cannot instantiate input element: " + factoryID); //$NON-NLS-1$ >- result.add(unableToRestorePage(pageMem)); >- continue; >- } >- } finally { >- UIStats.end(UIStats.RESTORE_WORKBENCH, factoryID, >- "WorkbenchPageFactory"); //$NON-NLS-1$ >- } >- } >- // Open the perspective. >- final IAdaptable finalInput = input[0]; >- final WorkbenchPage [] newPage = new WorkbenchPage[1]; >- try { >- StartupThreading.runWithWorkbenchExceptions(new StartupRunnable(){ >- >- public void runWithException() throws WorkbenchException { >- newPage[0] = ((WorkbenchImplementation) Tweaklets >- .get(WorkbenchImplementation.KEY)).createWorkbenchPage(WorkbenchWindow.this, finalInput); >- }}); >- >- result.add(newPage[0].restoreState(pageMem, activeDescriptor)); >- pageList.add(newPage[0]); >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- firePageOpened(newPage[0]); >- }}); >- >- } catch (WorkbenchException e) { >- WorkbenchPlugin >- .log( >- "Unable to restore perspective - constructor failed.", e); //$NON-NLS-1$ >- result.add(e.getStatus()); >- continue; >- } >- >- if (strFocus != null && strFocus.length() > 0) { >- newActivePage = newPage[0]; >- } >- } >- >- // If there are no pages create a default. >- if (pageList.isEmpty()) { >- try { >- final String defPerspID = getWorkbenchImpl().getPerspectiveRegistry() >- .getDefaultPerspective(); >- if (defPerspID != null) { >- final WorkbenchPage [] newPage = new WorkbenchPage[1]; >- StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- newPage[0] = ((WorkbenchImplementation) Tweaklets >- .get(WorkbenchImplementation.KEY)).createWorkbenchPage(WorkbenchWindow.this, defPerspID, >- getDefaultPageInput()); >- }}); >- >- pageList.add(newPage[0]); >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- firePageOpened(newPage[0]); >- }}); >- } >- } catch (WorkbenchException e) { >- WorkbenchPlugin >- .log( >- "Unable to create default perspective - constructor failed.", e); //$NON-NLS-1$ >- result.add(e.getStatus()); >- String productName = WorkbenchPlugin.getDefault() >- .getProductName(); >- if (productName == null) { >- productName = ""; //$NON-NLS-1$ >- } >- getShell().setText(productName); >- } >- } >- >- // Set active page. >- if (newActivePage == null) { >- newActivePage = pageList.getNextActive(); >- } >- final IWorkbenchPage myPage = newActivePage; >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- setActivePage(myPage); >- }}); >- >+ // RAP [bm]: detached windows >+// private ShellPool detachedWindowShells; >+ // RAPEND: [bm] >+ >+ static final String TEXT_DELIMITERS = TextProcessor.getDefaultDelimiters() + "-"; //$NON-NLS-1$ > >-// RAP [rh] Intro mechanism not supported >-// final IMemento introMem = memento.getChild(IWorkbenchConstants.TAG_INTRO); >-// if (introMem != null) { >-// StartupThreading.runWithoutExceptions(new StartupRunnable() { >-// >-// public void runWithException() throws Throwable { >-// getWorkbench() >-// .getIntroManager() >-// .showIntro( >-// WorkbenchWindow.this, >-// Boolean >-// .valueOf( >-// introMem >-// .getString(IWorkbenchConstants.TAG_STANDBY)) >-// .booleanValue()); >-// } >-// }); >-// >-// } >- >- // Only restore the trim state if we're using the default layout >- if (defaultLayout != null) { >- // Restore the trim state. We pass in the 'root' >- // memento since we have to check for pre-3.2 >- // state. >- result.add(restoreTrimState(memento)); >- } >- >- return result; >- } >- >- /** >- * Restores cool item order from an old workbench. >- */ >- private boolean restoreOldCoolBar(IMemento coolbarMem) { >- // Make sure the tag exist >- if (coolbarMem == null) { >- return false; >- } >- ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >- // Check to see if layout is locked >- Integer locked = coolbarMem.getInteger(IWorkbenchConstants.TAG_LOCKED); >- boolean state = (locked != null) && (locked.intValue() == 1); >- coolBarMgr.setLockLayout(state); >- >- // Get the visual layout >- IMemento visibleLayout = coolbarMem >- .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT); >- ArrayList visibleWrapIndicies = new ArrayList(); >- ArrayList visibleItems = new ArrayList(); >- if (visibleLayout != null) { >- if (readLayout(visibleLayout, visibleItems, visibleWrapIndicies) == false) { >- return false; >- } >- } >- // Get the remembered layout >- IMemento rememberedLayout = coolbarMem >- .getChild(IWorkbenchConstants.TAG_LAYOUT); >- ArrayList rememberedWrapIndicies = new ArrayList(); >- ArrayList rememberedItems = new ArrayList(); >- if (rememberedLayout != null) { >- if (readLayout(rememberedLayout, rememberedItems, >- rememberedWrapIndicies) == false) { >- return false; >- } >- } >- >- // Create the objects >- if (visibleItems != null) { >- // Merge remembered layout into visible layout >- if (rememberedItems != null) { >- // Traverse through all the remembered items >- int currentIndex = 0; >- for (Iterator i = rememberedItems.iterator(); i.hasNext(); currentIndex++) { >- String id = (String) i.next(); >- int index = -1; >- for (Iterator iter = visibleItems.iterator(); iter >- .hasNext();) { >- String visibleId = (String) iter.next(); >- if (visibleId.equals(id)) { >- index = visibleItems.indexOf(visibleId); >- break; >- } >- } >- // The item is not in the visible list >- if (index == -1) { >- int insertAt = Math.max(0, Math.min(currentIndex, >- visibleItems.size())); >- boolean separateLine = false; >- // Check whether this item is on a separate line >- for (Iterator iter = rememberedWrapIndicies.iterator(); iter >- .hasNext();) { >- Integer wrapIndex = (Integer) iter.next(); >- if (wrapIndex.intValue() <= insertAt) { >- insertAt = visibleItems.size(); >- // Add new wrap index for this Item >- visibleWrapIndicies.add(new Integer(insertAt)); >- separateLine = true; >- } >- } >- // Add item to array list >- visibleItems.add(insertAt, id); >- // If the item was not on a separate line then adjust >- // the visible wrap indicies >- if (!separateLine) { >- // Adjust visible wrap indicies >- for (int j = 0; j < visibleWrapIndicies.size(); j++) { >- Integer index2 = (Integer) visibleWrapIndicies >- .get(j); >- if (index2.intValue() >= insertAt) { >- visibleWrapIndicies.set(j, new Integer( >- index2.intValue() + 1)); >- } >- } >- } >- } >- } >- } >- // The new layout of the cool bar manager >- ArrayList coolBarLayout = new ArrayList(visibleItems.size()); >- // Add all visible items to the layout object >- for (Iterator i = visibleItems.iterator(); i.hasNext();) { >- String id = (String) i.next(); >- // Look for the object in the current cool bar manager >- IContributionItem oldItem = null; >- IContributionItem newItem = null; >- if (id != null) { >- oldItem = coolBarMgr.find(id); >- } >- // If a tool bar contribution item already exists for this id >- // then use the old object >- if (oldItem instanceof IToolBarContributionItem) { >- newItem = oldItem; >- } else { >- IActionBarPresentationFactory actionBarPresentaiton = getActionBarPresentationFactory(); >- newItem = actionBarPresentaiton.createToolBarContributionItem( >- actionBarPresentaiton.createToolBarManager(), id); >- // make it invisible by default >- newItem.setVisible(false); >- // Need to add the item to the cool bar manager so that its >- // canonical order can be preserved >- IContributionItem refItem = findAlphabeticalOrder( >- IWorkbenchActionConstants.MB_ADDITIONS, id, >- coolBarMgr); >- if (refItem != null) { >- coolBarMgr.insertAfter(refItem.getId(), newItem); >- } else { >- coolBarMgr.add(newItem); >- } >- } >- // Add new item into cool bar manager >- if (newItem != null) { >- coolBarLayout.add(newItem); >- newItem.setParent(coolBarMgr); >- coolBarMgr.markDirty(); >- } >- } >- >- // Add separators to the displayed Items data structure >- int offset = 0; >- for (int i = 1; i < visibleWrapIndicies.size(); i++) { >- int insertAt = ((Integer) visibleWrapIndicies.get(i)) >- .intValue() >- + offset; >- coolBarLayout.add(insertAt, new Separator( >- CoolBarManager.USER_SEPARATOR)); >- offset++; >- } >- >- // Add any group markers in their appropriate places >- IContributionItem[] items = coolBarMgr.getItems(); >- for (int i = 0; i < items.length; i++) { >- IContributionItem item = items[i]; >- if (item.isGroupMarker()) { >- coolBarLayout.add(Math.max(Math >- .min(i, coolBarLayout.size()), 0), item); >- } >- } >- IContributionItem[] itemsToSet = new IContributionItem[coolBarLayout >- .size()]; >- coolBarLayout.toArray(itemsToSet); >- coolBarMgr.setItems(itemsToSet); >- } >- return true; >- } >- >- /** >- * Helper method used for restoring an old cool bar layout. This method >- * reads the memento and populatates the item id's and wrap indicies. >- */ >- private boolean readLayout(IMemento memento, ArrayList itemIds, >- ArrayList wrapIndicies) { >- // Get the Wrap indicies >- IMemento[] wraps = memento >- .getChildren(IWorkbenchConstants.TAG_ITEM_WRAP_INDEX); >- if (wraps == null) { >- return false; >- } >- for (int i = 0; i < wraps.length; i++) { >- IMemento wrapMem = wraps[i]; >- Integer index = wrapMem.getInteger(IWorkbenchConstants.TAG_INDEX); >- if (index == null) { >- return false; >- } >- wrapIndicies.add(index); >- } >- // Get the Item ids >- IMemento[] savedItems = memento >- .getChildren(IWorkbenchConstants.TAG_ITEM); >- if (savedItems == null) { >- return false; >- } >- for (int i = 0; i < savedItems.length; i++) { >- IMemento savedMem = savedItems[i]; >- String id = savedMem.getString(IWorkbenchConstants.TAG_ID); >- if (id == null) { >- return false; >- } >- itemIds.add(id); >- } >- return true; >- } >- >- /** >- * Returns the contribution item that the given contribution item should be >- * inserted after. >- * >- * @param startId >- * the location to start looking alphabetically. >- * @param itemId >- * the target item id. >- * @param mgr >- * the contribution manager. >- * @return the contribution item that the given items should be returned >- * after. >- */ >- private IContributionItem findAlphabeticalOrder(String startId, >- String itemId, IContributionManager mgr) { >- IContributionItem[] items = mgr.getItems(); >- int insertIndex = 0; >- >- // look for starting point >- while (insertIndex < items.length) { >- IContributionItem item = items[insertIndex]; >- if (item.getId() != null && item.getId().equals(startId)) { >- break; >- } >- ++insertIndex; >- } >- >- // Find the index that this item should be inserted in >- for (int i = insertIndex + 1; i < items.length; i++) { >- IContributionItem item = items[i]; >- String testId = item.getId(); >- >- if (item.isGroupMarker()) { >- break; >- } >- >- if (itemId != null && testId != null) { >- if (itemId.compareTo(testId) < 1) { >- break; >- } >- } >- insertIndex = i; >- } >- if (insertIndex >= items.length) { >- return null; >- } >- return items[insertIndex]; >- } >- >- /* >- * (non-Javadoc) Method declared on IRunnableContext. >- */ >- public void run(boolean fork, boolean cancelable, >- IRunnableWithProgress runnable) throws InvocationTargetException, >- InterruptedException { >- >- // RAP [bm]: >-// IWorkbenchContextSupport contextSupport = getWorkbench() >-// .getContextSupport(); >-// final boolean keyFilterEnabled = contextSupport.isKeyFilterEnabled(); >- >- Control fastViewBarControl = getFastViewBar() == null ? null >- : getFastViewBar().getControl(); >- boolean fastViewBarWasEnabled = fastViewBarControl == null ? false >- : fastViewBarControl.getEnabled(); >- >- Control perspectiveBarControl = getPerspectiveBar() == null ? null >- : getPerspectiveBar().getControl(); >- boolean perspectiveBarWasEnabled = perspectiveBarControl == null ? false >- : perspectiveBarControl.getEnabled(); >- >- // Cache for any diabled trim controls >- List disabledControls = null; >- >- try { >- if (fastViewBarControl != null && !fastViewBarControl.isDisposed()) { >- fastViewBarControl.setEnabled(false); >- } >- >- if (perspectiveBarControl != null >- && !perspectiveBarControl.isDisposed()) { >- perspectiveBarControl.setEnabled(false); >- } >- >- // RAP [bm]: >-// if (keyFilterEnabled) { >-// contextSupport.setKeyFilterEnabled(false); >-// } >- // RAPEND: [bm] >- >- // Disable all trim -except- the StatusLine >- if (defaultLayout != null) >- disabledControls = defaultLayout.disableTrim(getStatusLineTrim()); >- >- super.run(fork, cancelable, runnable); >- } finally { >- if (fastViewBarControl != null && !fastViewBarControl.isDisposed()) { >- fastViewBarControl.setEnabled(fastViewBarWasEnabled); >- } >- >- if (perspectiveBarControl != null >- && !perspectiveBarControl.isDisposed()) { >- perspectiveBarControl.setEnabled(perspectiveBarWasEnabled); >- } >- >- // RAP [bm]: >-// if (keyFilterEnabled) { >-// contextSupport.setKeyFilterEnabled(true); >-// } >- // RAPEND: [bm] >- >- // Re-enable any disabled trim >- if (defaultLayout != null && disabledControls != null) >- defaultLayout.enableTrim(disabledControls); >- } >- } >- >- /** >- * Save all of the pages. Returns true if the operation succeeded. >- */ >- private boolean saveAllPages(boolean bConfirm) { >- boolean bRet = true; >- Iterator itr = pageList.iterator(); >- while (bRet && itr.hasNext()) { >- WorkbenchPage page = (WorkbenchPage) itr.next(); >- bRet = page.saveAllEditors(bConfirm); >- } >- return bRet; >- } >- >- /** >- * @see IPersistable >- */ >- public IStatus saveState(IMemento memento) { >- >- MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, >- WorkbenchMessages.get().WorkbenchWindow_problemsSavingWindow, null); >- >- // Save the window's state and bounds. >- if (getShell().getMaximized() || asMaximizedState) { >- memento.putString(IWorkbenchConstants.TAG_MAXIMIZED, "true"); //$NON-NLS-1$ >- } >- if (getShell().getMinimized()) { >- memento.putString(IWorkbenchConstants.TAG_MINIMIZED, "true"); //$NON-NLS-1$ >- } >- if (normalBounds == null) { >- normalBounds = getShell().getBounds(); >- } >- IMemento fastViewBarMem = memento >- .createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >- if (fastViewBar != null) { >- fastViewBar.saveState(fastViewBarMem); >- } >- >- memento.putInteger(IWorkbenchConstants.TAG_X, normalBounds.x); >- memento.putInteger(IWorkbenchConstants.TAG_Y, normalBounds.y); >- memento.putInteger(IWorkbenchConstants.TAG_WIDTH, normalBounds.width); >- memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, normalBounds.height); >+ // constants for shortcut bar group ids >+ static final String GRP_PAGES = "pages"; //$NON-NLS-1$ > >-// RAP [rh] Intro mechanism not supported >-// IWorkbenchPage activePage = getActivePage(); >-// if (activePage != null >-// && activePage.findView(IIntroConstants.INTRO_VIEW_ID) != null) { >-// IMemento introMem = memento >-// .createChild(IWorkbenchConstants.TAG_INTRO); >-// boolean isStandby = getWorkbench() >-// .getIntroManager() >-// .isIntroStandby(getWorkbench().getIntroManager().getIntro()); >-// introMem.putString(IWorkbenchConstants.TAG_STANDBY, String >-// .valueOf(isStandby)); >-// } >- >- // save the width of the perspective bar >- IMemento persBarMem = memento >- .createChild(IWorkbenchConstants.TAG_PERSPECTIVE_BAR); >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.saveState(persBarMem); >- } >+ static final String GRP_PERSPECTIVES = "perspectives"; //$NON-NLS-1$ > >- // / Save the order of the cool bar contribution items >- ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >- if (coolBarMgr != null) { >- coolBarMgr.refresh(); >- IMemento coolBarMem = memento >- .createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); >- if (coolBarMgr.getLockLayout() == true) { >- coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1); >- } else { >- coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0); >- } >- IContributionItem[] items = coolBarMgr.getItems(); >- for (int i = 0; i < items.length; i++) { >- IMemento coolItemMem = coolBarMem >- .createChild(IWorkbenchConstants.TAG_COOLITEM); >- IContributionItem item = items[i]; >- // The id of the contribution item >- if (item.getId() != null) { >- coolItemMem.putString(IWorkbenchConstants.TAG_ID, item >- .getId()); >- } >- // Write out type and size if applicable >- if (item.isSeparator()) { >- coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, >- IWorkbenchConstants.TAG_TYPE_SEPARATOR); >- } else if (item.isGroupMarker() && !item.isSeparator()) { >- coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, >- IWorkbenchConstants.TAG_TYPE_GROUPMARKER); >- } else { >- if (item instanceof PlaceholderContributionItem) { >- coolItemMem.putString( >- IWorkbenchConstants.TAG_ITEM_TYPE, >- IWorkbenchConstants.TAG_TYPE_PLACEHOLDER); >- } else { >- // Store the identifier. >- coolItemMem >- .putString( >- IWorkbenchConstants.TAG_ITEM_TYPE, >- IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION); >- } >- >- /* >- * Retrieve a reasonable approximation of the height and >- * width, if possible. >- */ >- final int height; >- final int width; >- if (item instanceof IToolBarContributionItem) { >- IToolBarContributionItem toolBarItem = (IToolBarContributionItem) item; >- toolBarItem.saveWidgetState(); >- height = toolBarItem.getCurrentHeight(); >- width = toolBarItem.getCurrentWidth(); >- } else if (item instanceof PlaceholderContributionItem) { >- PlaceholderContributionItem placeholder = (PlaceholderContributionItem) item; >- height = placeholder.getHeight(); >- width = placeholder.getWidth(); >- } else { >- height = -1; >- width = -1; >- } >- >- // Store the height and width. >- coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_X, >- width); >- coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_Y, >- height); >- } >- } >- } >- >- // Save each page. >- Iterator itr = pageList.iterator(); >- while (itr.hasNext()) { >- WorkbenchPage page = (WorkbenchPage) itr.next(); >- >- // Save perspective. >- IMemento pageMem = memento >- .createChild(IWorkbenchConstants.TAG_PAGE); >- pageMem.putString(IWorkbenchConstants.TAG_LABEL, page.getLabel()); >- result.add(page.saveState(pageMem)); >- >- if (page == getActiveWorkbenchPage()) { >- pageMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$ >- } >- >- // Get the input. >- IAdaptable input = page.getInput(); >- if (input != null) { >- IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input, >- IPersistableElement.class); >- if (persistable == null) { >- WorkbenchPlugin >- .log("Unable to save page input: " //$NON-NLS-1$ >- + input >- + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$ >- } else { >- // Save input. >- IMemento inputMem = pageMem >- .createChild(IWorkbenchConstants.TAG_INPUT); >- inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID, >- persistable.getFactoryId()); >- persistable.saveState(inputMem); >- } >- } >- } >- >- // Save window advisor state. >- IMemento windowAdvisorState = memento >- .createChild(IWorkbenchConstants.TAG_WORKBENCH_WINDOW_ADVISOR); >- result.add(getWindowAdvisor().saveState(windowAdvisorState)); >- >- // Save actionbar advisor state. >- IMemento actionBarAdvisorState = memento >- .createChild(IWorkbenchConstants.TAG_ACTION_BAR_ADVISOR); >- result.add(getActionBarAdvisor().saveState(actionBarAdvisorState)); >- >- // Only save the trim state if we're using the default layout >- if (defaultLayout != null) { >- IMemento trimState = memento.createChild(IWorkbenchConstants.TAG_TRIM); >- result.add(saveTrimState(trimState)); >- } >- >- return result; >- } >- >- /** >- * Save the trim layout trim area and trim ordering. >- * >- * @param memento >- * the memento to update >- * @return the status, OK or not.. >- */ >- private IStatus saveTrimState(IMemento memento) { >- int[] ids = defaultLayout.getAreaIds(); >- for (int i = 0; i < ids.length; i++) { >- int id = ids[i]; >- List trim = defaultLayout.getAreaTrim(id); >- if (!trim.isEmpty()) { >- IMemento area = memento >- .createChild(IWorkbenchConstants.TAG_TRIM_AREA, Integer >- .toString(id)); >- Iterator d = trim.iterator(); >- while (d.hasNext()) { >- IWindowTrim item = (IWindowTrim) d.next(); >- area.createChild(IWorkbenchConstants.TAG_TRIM_ITEM, item >- .getId()); >- } >- } >- } >- return Status.OK_STATUS; >- } >- >- /** >- * Restore the trim layout state from the memento. >- * >- * @param memento >- * the 'root' Workbench memento to restore >- * @return the status, OK or not >- */ >- private IStatus restoreTrimState(IMemento memento) { >- // Determine if we have saved state. If we don't have any 3.2 >- // type state we're not done because the FastViewBar maintained >- // its own 'side' state in 3.1 so we'll honor its value >- IMemento trimState = memento.getChild(IWorkbenchConstants.TAG_TRIM); >- if (trimState != null) { >- // first pass sets up ordering for all trim areas >- IMemento[] areas = trimState >- .getChildren(IWorkbenchConstants.TAG_TRIM_AREA); >- >- // We need to remember all the trim that was repositioned >- // here so we can re-site -newly contributed- trim after >- // we're done >- final List knownIds = new ArrayList(); >- >- List[] trimOrder = new List[areas.length]; >- for (int i = 0; i < areas.length; i++) { >- trimOrder[i] = new ArrayList(); >- List preferredLocations = new ArrayList(); >- IMemento area = areas[i]; >- IMemento[] items = area >- .getChildren(IWorkbenchConstants.TAG_TRIM_ITEM); >- for (int j = 0; j < items.length; j++) { >- IMemento item = items[j]; >- String id = item.getID(); >- knownIds.add(id); >- preferredLocations.add(id); >- >- IWindowTrim t = defaultLayout.getTrim(id); >- if (t != null) { >- trimOrder[i].add(t); >- } >- } >- >- // Inform the TrimLayout of the preferred location for this area >- String areaIdString = areas[i].getID(); >- int areaId = Integer.parseInt(areaIdString); >- defaultLayout.setPreferredLocations(areaId, preferredLocations); >- } >- >- // second pass applies all of the window trim >- for (int i = 0; i < areas.length; i++) { >- IMemento area = areas[i]; >- final int id = Integer.parseInt(area.getID()); >- final List myTrimOrderList = trimOrder[i]; >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- defaultLayout.updateAreaTrim(id, myTrimOrderList, false); >- }}); >- >- } >- >- // get the trim manager to re-locate any -newly contributed- >- // trim widgets >- // Legacy (3.2) trim >- if (trimMgr2 != null) { >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- trimMgr2.updateLocations(knownIds); >- }}); >- >- } >- >- // 3.3 Trim Contributions >- if (trimContributionMgr != null) { >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- public void runWithException() throws Throwable { >- trimContributionMgr.updateLocations(knownIds); >- >- // Update the GUI with the new locations >- WorkbenchPage page = getActiveWorkbenchPage(); >- if (page != null) { >- Perspective perspective = page.getActivePerspective(); >- if (perspective != null) { >- // Ensure that only the upper/right editor stack has >- // min/max buttons >- page.getEditorPresentation().updateStackButtons(); >- >- // The perspective's onActivate manipulates the trim under the >- // new min/max story so cause it to refresh... >- perspective.onActivate(); >- } >- } >- }}); >- } >- } >- else { >- // No 3.2 state...check if the FVB has state >- IMemento fastViewMem = memento >- .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >- if (fastViewMem != null) { >- if (fastViewBar != null) { >- final Integer bigInt = fastViewMem.getInteger(IWorkbenchConstants.TAG_FAST_VIEW_SIDE); >- if (bigInt != null) { >- StartupThreading.runWithoutExceptions(new StartupRunnable() { >- >- public void runWithException() throws Throwable { >- fastViewBar.dock(bigInt.intValue()); >- getTrimManager().addTrim(bigInt.intValue(), fastViewBar); >- }}); >- >- } >- } >- } >- } >- >- return Status.OK_STATUS; >- } >- >- /** >- * Sets the active page within the window. >- * >- * @param in >- * identifies the new active page, or <code>null</code> for no >- * active page >- */ >- public void setActivePage(final IWorkbenchPage in) { >- if (getActiveWorkbenchPage() == in) { >- return; >- } >- >- // 1FVGTNR: ITPUI:WINNT - busy cursor for switching perspectives >- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { >- public void run() { >- // Deactivate old persp. >- WorkbenchPage currentPage = getActiveWorkbenchPage(); >- if (currentPage != null) { >- currentPage.onDeactivate(); >- } >- >- // Activate new persp. >- if (in == null || pageList.contains(in)) { >- pageList.setActive(in); >- } >- WorkbenchPage newPage = pageList.getActive(); >- Composite parent = getPageComposite(); >- StackLayout layout = (StackLayout) parent.getLayout(); >- if (newPage != null) { >- layout.topControl = newPage.getClientComposite(); >- parent.layout(); >- hideEmptyWindowContents(); >- newPage.onActivate(); >- firePageActivated(newPage); >- if (newPage.getPerspective() != null) { >- firePerspectiveActivated(newPage, newPage >- .getPerspective()); >- } >- } else { >- layout.topControl = null; >- parent.layout(); >- } >- >- updateFastViewBar(); >- >- if (isClosing()) { >- return; >- } >- >- updateDisabled = false; >- >- // Update action bars ( implicitly calls updateActionBars() ) >- updateActionSets(); >- submitGlobalActions(); >- >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.update(false); >- } >- >- getMenuManager().update(IAction.TEXT); >- } >- }); >- } >- >- /** >- * Returns whether or not children exist for the Window's toolbar control. >- * Overridden for coolbar support. >- * <p> >- * >- * @return boolean true if children exist, false otherwise >- */ >- protected boolean toolBarChildrenExist() { >- CoolBar coolBarControl = (CoolBar) getCoolBarControl(); >- return coolBarControl.getItemCount() > 0; >- } >- >- /** >- * Hooks a listener to track the activation and deactivation of the window's >- * shell. Notifies the active part and editor of the change >- */ >- private void trackShellActivation(Shell shell) { >- shell.addShellListener(new ShellAdapter() { >- public void shellActivated(ShellEvent event) { >- shellActivated = true; >- serviceLocator.activate(); >- getWorkbenchImpl().setActivatedWindow(WorkbenchWindow.this); >- WorkbenchPage currentPage = getActiveWorkbenchPage(); >- if (currentPage != null) { >- IWorkbenchPart part = currentPage.getActivePart(); >- if (part != null) { >- PartSite site = (PartSite) part.getSite(); >- site.getPane().shellActivated(); >- } >- IEditorPart editor = currentPage.getActiveEditor(); >- if (editor != null) { >- PartSite site = (PartSite) editor.getSite(); >- site.getPane().shellActivated(); >- } >- getWorkbenchImpl() >- .fireWindowActivated(WorkbenchWindow.this); >- } >- } >- >- public void shellDeactivated(ShellEvent event) { >- shellActivated = false; >- serviceLocator.deactivate(); >- WorkbenchPage currentPage = getActiveWorkbenchPage(); >- if (currentPage != null) { >- IWorkbenchPart part = currentPage.getActivePart(); >- if (part != null) { >- PartSite site = (PartSite) part.getSite(); >- site.getPane().shellDeactivated(); >- } >- IEditorPart editor = currentPage.getActiveEditor(); >- if (editor != null) { >- PartSite site = (PartSite) editor.getSite(); >- site.getPane().shellDeactivated(); >- } >- getWorkbenchImpl().fireWindowDeactivated( >- WorkbenchWindow.this); >- } >- } >- }); >- } >- >- /** >- * Hooks a listener to track the resize of the window's shell. Stores the >- * new bounds if in normal state - that is, not in minimized or maximized >- * state) >- */ >- private void trackShellResize(Shell newShell) { >- newShell.addControlListener(new ControlAdapter() { >- public void controlMoved(ControlEvent e) { >- saveBounds(); >- } >- >- public void controlResized(ControlEvent e) { >- saveBounds(); >- } >- >- private void saveBounds() { >- Shell shell = getShell(); >- if (shell == null) { >- return; >- } >- if (shell.isDisposed()) { >- return; >- } >- if (shell.getMinimized()) { >- return; >- } >- if (shell.getMaximized()) { >- asMaximizedState = true; >- return; >- } >- asMaximizedState = false; >- normalBounds = shell.getBounds(); >- } >- }); >- } >- >- /** >- * update the action bars. >- */ >- public void updateActionBars() { >- if (updateDisabled || updatesDeferred()) { >- return; >- } >- // updateAll required in order to enable accelerators on pull-down menus >- getMenuBarManager().update(false); >- >- // RAP [bm]: Composite#setLayoutDeferred >-// try { >-// getShell().setLayoutDeferred(true); >-// getCoolBarManager2().update(false); >-// } finally { >-// getShell().setLayoutDeferred(false); >-// } >- getCoolBarManager2().update(false); >- // RAPEND: [bm] >- >- getStatusLineManager().update(false); >- } >- >- /** >- * Returns true iff we are currently deferring UI processing due to a large >- * update >- * >- * @return true iff we are deferring UI updates. >- */ >- private boolean updatesDeferred() { >- return largeUpdates > 0; >- } >- >- /** >- * <p> >- * Indicates the start of a large update within this window. This is used to >- * disable CPU-intensive, change-sensitive services that were temporarily >- * disabled in the midst of large changes. This method should always be >- * called in tandem with <code>largeUpdateEnd</code>, and the event loop >- * should not be allowed to spin before that method is called. >- * </p> >- * <p> >- * Important: always use with <code>largeUpdateEnd</code>! >- * </p> >- */ >- public final void largeUpdateStart() { >- largeUpdates++; >- } >- >- /** >- * <p> >- * Indicates the end of a large update within this window. This is used to >- * re-enable services that were temporarily disabled in the midst of large >- * changes. This method should always be called in tandem with >- * <code>largeUpdateStart</code>, and the event loop should not be >- * allowed to spin before this method is called. >- * </p> >- * <p> >- * Important: always protect this call by using <code>finally</code>! >- * </p> >- */ >- public final void largeUpdateEnd() { >- if (--largeUpdates == 0) { >- updateActionBars(); >- } >- } >- >- /** >- * Update the visible action sets. This method is typically called from a >- * page when the user changes the visible action sets within the >- * prespective. >- */ >- public void updateActionSets() { >- if (updateDisabled) { >- return; >- } >- >- WorkbenchPage currentPage = getActiveWorkbenchPage(); >- if (currentPage == null) { >- getActionPresentation().clearActionSets(); >- } else { >- ICoolBarManager2 coolBarManager = (ICoolBarManager2) getCoolBarManager2(); >- if (coolBarManager != null) { >- coolBarManager.refresh(); >- } >- getActionPresentation().setActionSets( >- currentPage.getActionSets()); >- } >- fireActionSetsChanged(); >- updateActionBars(); >- >- // hide the launch menu if it is empty >- String path = IWorkbenchActionConstants.M_WINDOW >- + IWorkbenchActionConstants.SEP >- + IWorkbenchActionConstants.M_LAUNCH; >- IMenuManager manager = getMenuBarManager().findMenuUsingPath(path); >- IContributionItem item = getMenuBarManager().findUsingPath(path); >- >- if (manager == null || item == null) { >- return; >- } >- item.setVisible(manager.getItems().length >= 2); >- // there is a separator for the additions group thus >= 2 >- } >- >- private ListenerList actionSetListeners = null; >- >- private ListenerList backgroundSaveListeners = new ListenerList(ListenerList.IDENTITY); >- >- private final void fireActionSetsChanged() { >- if (actionSetListeners != null) { >- final Object[] listeners = actionSetListeners.getListeners(); >- for (int i = 0; i < listeners.length; i++) { >- final IActionSetsListener listener = (IActionSetsListener) listeners[i]; >- final WorkbenchPage currentPage = getActiveWorkbenchPage(); >- final IActionSetDescriptor[] newActionSets; >- if (currentPage == null) { >- newActionSets = null; >- } else { >- newActionSets = currentPage.getActionSets(); >- } >- final ActionSetsEvent event = new ActionSetsEvent(newActionSets); >- listener.actionSetsChanged(event); >- } >- } >- } >- >- final void addActionSetsListener(final IActionSetsListener listener) { >- if (actionSetListeners == null) { >- actionSetListeners = new ListenerList(); >- } >- >- actionSetListeners.add(listener); >- } >- >- final void removeActionSetsListener(final IActionSetsListener listener) { >- if (actionSetListeners != null) { >- actionSetListeners.remove(listener); >- if (actionSetListeners.isEmpty()) { >- actionSetListeners = null; >- } >- } >- } >- >- /** >- * Create the progress indicator for the receiver. >- * >- * @param shell >- * the parent shell >- */ >- private void createProgressIndicator(Shell shell) { >- if (getWindowConfigurer().getShowProgressIndicator()) { >- progressRegion = new ProgressRegion(); >- progressRegion.createContents(shell, this); >- } >- } >- >- class PageList { >- // List of pages in the order they were created; >- private List pagesInCreationOrder; >- >- // List of pages where the top is the last activated. >- private List pageInActivationOrder; >- >- // The page explicitly activated >- private Object active; >- >- public PageList() { >- pagesInCreationOrder = new ArrayList(4); >- pageInActivationOrder = new ArrayList(4); >- } >- >- public boolean add(Object object) { >- pagesInCreationOrder.add(object); >- pageInActivationOrder.add(0, object); >- // It will be moved to top only when activated. >- return true; >- } >- >- public Iterator iterator() { >- return pagesInCreationOrder.iterator(); >- } >- >- public boolean contains(Object object) { >- return pagesInCreationOrder.contains(object); >- } >- >- public boolean remove(Object object) { >- if (active == object) { >- active = null; >- } >- pageInActivationOrder.remove(object); >- return pagesInCreationOrder.remove(object); >- } >- >- public boolean isEmpty() { >- return pagesInCreationOrder.isEmpty(); >- } >- >- public IWorkbenchPage[] getPages() { >- int nSize = pagesInCreationOrder.size(); >- IWorkbenchPage[] retArray = new IWorkbenchPage[nSize]; >- pagesInCreationOrder.toArray(retArray); >- return retArray; >- } >- >- public void setActive(Object page) { >- if (active == page) { >- return; >- } >- >- active = page; >- >- if (page != null) { >- pageInActivationOrder.remove(page); >- pageInActivationOrder.add(page); >- } >- } >- >- public WorkbenchPage getActive() { >- return (WorkbenchPage) active; >- } >- >- public WorkbenchPage getNextActive() { >- if (active == null) { >- if (pageInActivationOrder.isEmpty()) { >- return null; >- } >- >- return (WorkbenchPage) pageInActivationOrder >- .get(pageInActivationOrder.size() - 1); >- } >- >- if (pageInActivationOrder.size() < 2) { >- return null; >- } >- >- return (WorkbenchPage) pageInActivationOrder >- .get(pageInActivationOrder.size() - 2); >- } >- } >- >- /** >- * Returns the unique object that applications use to configure this window. >- * <p> >- * IMPORTANT This method is declared package-private to prevent regular >- * plug-ins from downcasting IWorkbenchWindow to WorkbenchWindow and getting >- * hold of the workbench window configurer that would allow them to tamper >- * with the workbench window. The workbench window configurer is available >- * only to the application. >- * </p> >- */ >- /* package - DO NOT CHANGE */ >- WorkbenchWindowConfigurer getWindowConfigurer() { >- if (windowConfigurer == null) { >- // lazy initialize >- windowConfigurer = new WorkbenchWindowConfigurer(this); >- } >- return windowConfigurer; >- } >- >- /** >- * Returns the workbench advisor. Assumes the workbench has been created >- * already. >- * <p> >- * IMPORTANT This method is declared private to prevent regular plug-ins >- * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >- * the workbench advisor that would allow them to tamper with the workbench. >- * The workbench advisor is internal to the application. >- * </p> >- */ >- private/* private - DO NOT CHANGE */ >- WorkbenchAdvisor getAdvisor() { >- return getWorkbenchImpl().getAdvisor(); >- } >- >- /** >- * Returns the window advisor, creating a new one for this window if needed. >- * <p> >- * IMPORTANT This method is declared private to prevent regular plug-ins >- * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >- * the window advisor that would allow them to tamper with the window. The >- * window advisor is internal to the application. >- * </p> >- */ >- private/* private - DO NOT CHANGE */ >- WorkbenchWindowAdvisor getWindowAdvisor() { >- if (windowAdvisor == null) { >- windowAdvisor = getAdvisor().createWorkbenchWindowAdvisor( >- getWindowConfigurer()); >- Assert.isNotNull(windowAdvisor); >- } >- return windowAdvisor; >- } >- >- /** >- * Returns the action bar advisor, creating a new one for this window if >- * needed. >- * <p> >- * IMPORTANT This method is declared private to prevent regular plug-ins >- * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >- * the action bar advisor that would allow them to tamper with the window's >- * action bars. The action bar advisor is internal to the application. >- * </p> >- */ >- private/* private - DO NOT CHANGE */ >- ActionBarAdvisor getActionBarAdvisor() { >- if (actionBarAdvisor == null) { >- actionBarAdvisor = getWindowAdvisor().createActionBarAdvisor( >- getWindowConfigurer().getActionBarConfigurer()); >- Assert.isNotNull(actionBarAdvisor); >- } >- return actionBarAdvisor; >- } >- >- /* >- * Returns the IWorkbench implementation. >- */ >- private Workbench getWorkbenchImpl() { >- return Workbench.getInstance(); >- } >- >- /** >- * Fills the window's real action bars. >- * >- * @param flags >- * indicate which bars to fill >- */ >- public void fillActionBars(int flags) { >- Workbench workbench = getWorkbenchImpl(); >- workbench.largeUpdateStart(); >- try { >- getActionBarAdvisor().fillActionBars(flags); >- // >- // 3.3 start >- final IMenuService menuService = (IMenuService) serviceLocator >- .getService(IMenuService.class); >- menuService.populateContributionManager( >- (ContributionManager) getActionBars().getMenuManager(), >- MenuUtil.MAIN_MENU); >- ICoolBarManager coolbar = getActionBars().getCoolBarManager(); >- if (coolbar != null) { >- menuService.populateContributionManager( >- (ContributionManager) coolbar, >- MenuUtil.MAIN_TOOLBAR); >- } >- // 3.3 end >- } finally { >- workbench.largeUpdateEnd(); >- } >- } >- >- /** >- * Fills the window's proxy action bars. >- * >- * @param proxyBars >- * the proxy configurer >- * @param flags >- * indicate which bars to fill >- */ >- public void fillActionBars(IActionBarConfigurer2 proxyBars, int flags) { >- Assert.isNotNull(proxyBars); >- WorkbenchWindowConfigurer.WindowActionBarConfigurer wab = (WorkbenchWindowConfigurer.WindowActionBarConfigurer) getWindowConfigurer() >- .getActionBarConfigurer(); >- wab.setProxy(proxyBars); >- try { >- getActionBarAdvisor().fillActionBars( >- flags | ActionBarAdvisor.FILL_PROXY); >- } finally { >- wab.setProxy(null); >- } >- } >- >- /** >- * The <code>WorkbenchWindow</code> implementation of this method has the >- * same logic as <code>Window</code>'s implementation, but without the >- * resize check. We don't want to skip setting the bounds if the shell has >- * been resized since a free resize event occurs on Windows when the menubar >- * is set in configureShell. >- */ >- protected void initializeBounds() { >- Point size = getInitialSize(); >- Point location = getInitialLocation(size); >- getShell().setBounds( >- getConstrainedShellBounds(new Rectangle(location.x, location.y, >- size.x, size.y))); >- } >- >- /* >- * Unlike dialogs, the position of the workbench window is set by the user >- * and persisted across sessions. If the user wants to put the window >- * offscreen or spanning multiple monitors, let them (bug 74762) >- */ >- protected void constrainShellSize() { >- // As long as the shell is visible on some monitor, don't change it. >- Rectangle bounds = getShell().getBounds(); >- if (!SwtUtil.intersectsAnyMonitor(Display.getCurrent(), bounds)) { >- super.constrainShellSize(); >- } >- } >- >- /* >- * Unlike dialogs, the position of the workbench window is set by the user >- * and persisted across sessions. If the user wants to put the window >- * offscreen or spanning multiple monitors, let them (bug 74762) >- */ >- protected Point getInitialLocation(Point size) { >- Shell shell = getShell(); >- if (shell != null) { >- return shell.getLocation(); >- } >- >- return super.getInitialLocation(size); >- } >- >- /** >- * The <code>WorkbenchWindow</code> implementation of this method >- * delegates to the window configurer. >- */ >- protected Point getInitialSize() { >- return getWindowConfigurer().getInitialSize(); >- } >- >- /** >- * @param visible >- * whether the cool bar should be shown. This is only applicable >- * if the window configurer also wishes either the cool bar to be >- * visible. >- */ >- public void setCoolBarVisible(boolean visible) { >- boolean oldValue = coolBarVisible; >- coolBarVisible = visible; >- if (oldValue != coolBarVisible) { >- updateLayoutDataForContents(); >- } >- } >- >- /** >- * @return whether the cool bar should be shown. This is only applicable if >- * the window configurer also wishes either the cool bar to be >- * visible. >- */ >- public boolean getCoolBarVisible() { >- return coolBarVisible; >- } >- >- /** >- * @param visible >- * whether the perspective bar should be shown. This is only >- * applicable if the window configurer also wishes either the >- * perspective bar to be visible. >- */ >- public void setPerspectiveBarVisible(boolean visible) { >- boolean oldValue = perspectiveBarVisible; >- perspectiveBarVisible = visible; >- if (oldValue != perspectiveBarVisible) { >- updateLayoutDataForContents(); >- } >- } >- >- /** >- * @return whether the perspective bar should be shown. This is only >- * applicable if the window configurer also wishes either the >- * perspective bar to be visible. >- */ >- public boolean getPerspectiveBarVisible() { >- return perspectiveBarVisible; >- } >- >- /** >- * Tell the workbench window a visible state for the fastview bar. This is >- * only applicable if the window configurer also wishes the fast view bar to >- * be visible. >- * >- * @param visible >- * <code>true</code> or <code>false</code> >- */ >- public void setFastViewBarVisible(boolean visible) { >- boolean oldValue = fastViewBarVisible; >- fastViewBarVisible = visible; >- if (oldValue != fastViewBarVisible) { >- updateLayoutDataForContents(); >- } >- } >- >- /** >- * The workbench window take on the fastview bar. This is only applicable if >- * the window configurer also wishes the fast view bar to be visible. >- * >- * @return <code>true</code> if the workbench window thinks the fastview >- * bar should be visible. >- */ >- public boolean getFastViewBarVisible() { >- return fastViewBarVisible; >- } >- >- /** >- * @param visible >- * whether the perspective bar should be shown. This is only >- * applicable if the window configurer also wishes either the >- * perspective bar to be visible. >- */ >- public void setStatusLineVisible(boolean visible) { >- boolean oldValue = statusLineVisible; >- statusLineVisible = visible; >- if (oldValue != statusLineVisible) { >- updateLayoutDataForContents(); >- } >- } >- >- /** >- * @return whether the perspective bar should be shown. This is only >- * applicable if the window configurer also wishes either the >- * perspective bar to be visible. >- */ >- public boolean getStatusLineVisible() { >- return statusLineVisible; >- } >- >- /** >- * Note that this will only have an effect if the default implementation of >- * WorkbenchAdvisor.createWindowContents() has been invoked. >- * >- * called IWorkbench >- */ >- private void updateLayoutDataForContents() { >- if (defaultLayout == null) { >- return; >- } >- >- // @issue this is not ideal; coolbar and perspective shortcuts should be >- // separately configurable >- if ((getCoolBarVisible() && getWindowConfigurer().getShowCoolBar()) >- || (getPerspectiveBarVisible() && getWindowConfigurer() >- .getShowPerspectiveBar())) { >- if (defaultLayout.getTrim(topBarTrim.getId()) == null) { >- defaultLayout.addTrim(SWT.TOP, topBarTrim); >- } >- topBar.setVisible(true); >- } else { >- defaultLayout.removeTrim(topBarTrim); >- topBar.setVisible(false); >- } >- >- if (fastViewBar != null) { >- if (getFastViewBarVisible() >- && getWindowConfigurer().getShowFastViewBars()) { >- int side = fastViewBar.getSide(); >- >- if (defaultLayout.getTrim(fastViewBar.getId()) == null) { >- defaultLayout.addTrim(side, fastViewBar); >- } >- fastViewBar.getControl().setVisible(true); >- } else { >- defaultLayout.removeTrim(fastViewBar); >- fastViewBar.getControl().setVisible(false); >- } >- } >- >- if (getStatusLineVisible() && getWindowConfigurer().getShowStatusLine()) { >- if (defaultLayout.getTrim(getStatusLineTrim().getId()) == null) { >- defaultLayout.addTrim(SWT.BOTTOM, getStatusLineTrim()); >- } >- getStatusLineManager().getControl().setVisible(true); >- } else { >- defaultLayout.removeTrim(getStatusLineTrim()); >- getStatusLineManager().getControl().setVisible(false); >- } >+ static final String GRP_FAST_VIEWS = "fastViews"; //$NON-NLS-1$ > >-// RAP [rh] HeapStatus not supported >-// if (heapStatus != null) { >-// if (getShowHeapStatus()) { >-// if (heapStatus.getLayoutData() == null) { >-// heapStatusTrim.setWidthHint(heapStatus.computeSize( >-// SWT.DEFAULT, SWT.DEFAULT).x); >-// heapStatusTrim >-// .setHeightHint(getStatusLineManager().getControl() >-// .computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >-// } >-// >-// if (defaultLayout.getTrim(heapStatusTrim.getId()) == null) { >-// defaultLayout.addTrim(SWT.BOTTOM, heapStatusTrim); >-// } >-// heapStatus.setVisible(true); >-// } else { >-// >-// defaultLayout.removeTrim(heapStatusTrim); >-// heapStatus.setVisible(false); >-// } >-// } >- >- if (progressRegion != null) { >- if (getWindowConfigurer().getShowProgressIndicator()) { >- if (defaultLayout.getTrim(progressRegion.getId()) == null) { >- defaultLayout.addTrim(SWT.BOTTOM, progressRegion); >- } >- progressRegion.getControl().setVisible(true); >- } else { >- defaultLayout.removeTrim(progressRegion); >- progressRegion.getControl().setVisible(false); >- } >- } >- >- defaultLayout.setCenterControl(getPageComposite()); >- >- // Re-populate the trim elements >- if (trimMgr2 != null) >- trimMgr2.update(true, false, !topBar.getVisible()); >- if (trimContributionMgr != null) >- trimContributionMgr.update(true, !topBar.getVisible()); >- } >- >- public boolean getShowFastViewBars() { >- return getWindowConfigurer().getShowFastViewBars(); >- } >- >- /** >- * Set the layout data for the contents of the window. >- */ >- private void setLayoutDataForContents() { >- updateLayoutDataForContents(); >- } >- >- /** >- * Returns the fast view bar. >- */ >- public FastViewBar getFastViewBar() { >- return fastViewBar; >- } >- >- /** >- * Returns the perspective bar. >- * >- * @return Returns the perspective bar, or <code>null</code> if it has not >- * been initialized. >- */ >- public PerspectiveBarManager getPerspectiveBar() { >- return perspectiveSwitcher == null ? null : perspectiveSwitcher >- .getPerspectiveBar(); >- } >+ // static fields for inner classes. >+ static final int VGAP = 0; >+ >+ static final int CLIENT_INSET = 3; >+ >+ static final int BAR_SIZE = 23; > > /** >- * Returns the action presentation for dynamic UI >- * @return action presentation >+ * Coolbar visibility change property. > */ >- public ActionPresentation getActionPresentation() { >- if (actionPresentation == null) { >- actionPresentation = new ActionPresentation(this); >- } >- return actionPresentation; >+ public static final String PROP_COOLBAR_VISIBLE = "coolbarVisible"; //$NON-NLS-1$ >+ >+ /** >+ * Perspective bar visibility change property. >+ */ >+ public static final String PROP_PERSPECTIVEBAR_VISIBLE = "perspectiveBarVisible"; //$NON-NLS-1$ >+ >+ /** >+ * Constant (bit mask) indicating which the Show View submenu is probably >+ * present somewhere in this window. >+ * >+ * @see #addSubmenu >+ */ >+ public static final int SHOW_VIEW_SUBMENU = 0x01; >+ >+ /** >+ * Constant (bit mask) indicating which the Open Perspective submenu is >+ * probably present somewhere in this window. >+ * >+ * @see #addSubmenu >+ */ >+ public static final int OPEN_PERSPECTIVE_SUBMENU = 0x02; >+ >+ /** >+ * Constant (bit mask) indicating which the New Wizard submenu is probably >+ * present somewhere in this window. >+ * >+ * @see #addSubmenu >+ */ >+ public static final int NEW_WIZARD_SUBMENU = 0x04; >+ >+ /** >+ * Remembers that this window contains the given submenu. >+ * >+ * @param type >+ * the type of submenu, one of: >+ * {@link #NEW_WIZARD_SUBMENU NEW_WIZARD_SUBMENU}, >+ * {@link #OPEN_PERSPECTIVE_SUBMENU OPEN_PERSPECTIVE_SUBMENU}, >+ * {@link #SHOW_VIEW_SUBMENU SHOW_VIEW_SUBMENU} >+ * @see #containsSubmenu >+ */ >+ public void addSubmenu(int type) { >+ submenus |= type; >+ } >+ >+ /** >+ * Checks to see if this window contains the given type of submenu. >+ * >+ * @param type >+ * the type of submenu, one of: >+ * {@link #NEW_WIZARD_SUBMENU NEW_WIZARD_SUBMENU}, >+ * {@link #OPEN_PERSPECTIVE_SUBMENU OPEN_PERSPECTIVE_SUBMENU}, >+ * {@link #SHOW_VIEW_SUBMENU SHOW_VIEW_SUBMENU} >+ * @return <code>true</code> if window contains submenu, >+ * <code>false</code> otherwise >+ * @see #addSubmenu >+ */ >+ public boolean containsSubmenu(int type) { >+ return ((submenus & type) != 0); > } >+ >+ /** >+ * Constant indicating that all the actions bars should be filled. >+ */ >+ private static final int FILL_ALL_ACTION_BARS = ActionBarAdvisor.FILL_MENU_BAR >+ | ActionBarAdvisor.FILL_COOL_BAR >+ | ActionBarAdvisor.FILL_STATUS_LINE; > >+ > /** >- * Return the action bar presentation used for creating toolbars. This >- * is for internal use only, used for consistency with the window. >+ * Creates and initializes a new workbench window. > * >- * @return the presentation used. >+ * @param number >+ * the number for the window > */ >- public IActionBarPresentationFactory getActionBarPresentationFactory() { >- // allow replacement of the actionbar presentation >- IActionBarPresentationFactory actionBarPresentation; >- AbstractPresentationFactory presentationFactory = >- getWindowConfigurer().getPresentationFactory(); >- if (presentationFactory instanceof IActionBarPresentationFactory) { >- actionBarPresentation = ((IActionBarPresentationFactory) presentationFactory); >- } else { >- actionBarPresentation = new DefaultActionBarPresentationFactory(); >- } >- >- return actionBarPresentation; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.window.ApplicationWindow#showTopSeperator() >- */ >- protected boolean showTopSeperator() { >- return false; >- } >+ public WorkbenchWindow(int number) { >+ super(null); >+ this.number = number; >+ >+ >+ // Make sure there is a workbench. This call will throw >+ // an exception if workbench not created yet. >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ IServiceLocatorCreator slc = (IServiceLocatorCreator) workbench >+ .getService(IServiceLocatorCreator.class); >+ this.serviceLocator = (ServiceLocator) slc >+ .createServiceLocator(workbench, null); >+ initializeDefaultServices(); >+ >+ // Add contribution managers that are exposed to other plugins. >+ addMenuBar(); >+ addCoolBar(SWT.NONE); // style is unused >+ addStatusLine(); >+ >+ // register with the tracker >+ getExtensionTracker() >+ .registerHandler( >+ actionSetHandler, >+ ExtensionTracker >+ .createExtensionPointFilter(getActionSetExtensionPoint())); > >- /** >- * Returns a new cool bar manager for the window. >+ fireWindowOpening(); >+ >+ // set the shell style >+ setShellStyle(getWindowConfigurer().getShellStyle()); >+ >+ // Fill the action bars >+ fillActionBars(FILL_ALL_ACTION_BARS); >+ } >+ >+ /** >+ * Return the action set extension point. >+ * >+ * @return the action set extension point >+ */ >+ private IExtensionPoint getActionSetExtensionPoint() { >+ // RAP [bm]: >+// return Platform.getExtensionRegistry().getExtensionPoint( >+// PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_ACTION_SETS); >+ return Platform.getExtensionRegistry().getExtensionPoint( >+ PlatformUI.PLUGIN_EXTENSION_NAME_SPACE, IWorkbenchRegistryConstants.PL_ACTION_SETS); >+ >+ } >+ >+ /** >+ * Return the style bits for the shortcut bar. >+ * >+ * @return int >+ */ >+ protected int perspectiveBarStyle() { >+ return SWT.FLAT | SWT.WRAP | SWT.RIGHT | SWT.HORIZONTAL; >+ } >+ >+ // RAP [bm]: not used >+// private TrimDropTarget trimDropTarget; >+ // RAPEND: [bm] >+ >+ private boolean coolBarVisible = true; >+ >+ private boolean perspectiveBarVisible = true; >+ >+ private boolean fastViewBarVisible = true; >+ >+ private boolean statusLineVisible = true; >+ >+ private IWindowTrim statusLineTrim = null; >+ >+ /** >+ * The handlers for global actions that were last submitted to the workbench >+ * command support. This is a map of command identifiers to >+ * <code>ActionHandler</code>. This map is never <code>null</code>, >+ * and is never empty as long as at least one global action has been >+ * registered. >+ */ >+ private Map globalActionHandlersByCommandId = new HashMap(); >+ >+ /** >+ * The list of handler submissions submitted to the workbench command >+ * support. This list may be empty, but it is never <code>null</code>. >+ */ >+ private List handlerActivations = new ArrayList(); >+ >+ /** >+ * The number of large updates that are currently going on. If this is >+ * number is greater than zero, then UI updateActionBars is a no-op. >+ */ >+ private int largeUpdates = 0; >+ >+ private IExtensionTracker tracker; >+ >+ private IExtensionChangeHandler actionSetHandler = new IExtensionChangeHandler() { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamichelpers.IExtensionTracker, >+ * org.eclipse.core.runtime.IExtension) >+ */ >+ public void addExtension(IExtensionTracker tracker, IExtension extension) { >+ // this assumes that the workbench-level tracker will have already >+ // updated the registry >+ >+ ArrayList setsToActivate = new ArrayList(); >+ // look for all new sets that are on by default. Examine the tracker >+ // at the workbench level to see what descriptors are registered >+ // against this extension >+ Object[] registeredObjects = getWorkbench().getExtensionTracker() >+ .getObjects(extension); >+ for (int i = 0; i < registeredObjects.length; i++) { >+ if (registeredObjects[i] instanceof IActionSetDescriptor) { >+ IActionSetDescriptor desc = (IActionSetDescriptor) registeredObjects[i]; >+ if (desc.isInitiallyVisible()) { >+ setsToActivate.add(desc); >+ } >+ } >+ } >+ >+ // if none of the new sets are marked as initially visible, abort. >+ if (setsToActivate.isEmpty()) { >+ return; >+ } >+ >+ IActionSetDescriptor[] descriptors = (IActionSetDescriptor[]) setsToActivate >+ .toArray(new IActionSetDescriptor[setsToActivate.size()]); >+ >+ WorkbenchPage page = getActiveWorkbenchPage(); >+ if (page != null) { >+ Perspective[] perspectives = page.getOpenInternalPerspectives(); >+ >+ for (int i = 0; i < perspectives.length; i++) { >+ perspectives[i].turnOnActionSets(descriptors); >+ } >+ } >+ >+ updateActionSets(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, >+ * java.lang.Object[]) >+ */ >+ public void removeExtension(IExtension extension, Object[] objects) { >+ // remove the contributions from the window bars and dispose of the >+ // actions >+ for (int i = 0; i < objects.length; i++) { >+ if (objects[i] instanceof PluginActionSetBuilder.Binding) { >+ PluginActionSetBuilder.Binding binding = (PluginActionSetBuilder.Binding) objects[i]; >+ binding.builder.removeActionExtensions(binding.set, >+ binding.window); >+ binding.set.dispose(); >+ } >+ } >+ >+ // update all opened perspectives >+ Perspective[] perspectives = getActiveWorkbenchPage() >+ .getOpenInternalPerspectives(); >+ boolean updateNeeded = true; >+ IContextService contextService = (IContextService) getService(IContextService.class); >+ try { >+ contextService.activateContext(ContextAuthority.DEFER_EVENTS); >+ >+ for (int i = 0; i < perspectives.length; i++) { >+ for (int j = 0; j < objects.length; j++) { >+ if (objects[j] instanceof IActionSetDescriptor) { >+ perspectives[i] >+ .removeActionSet((IActionSetDescriptor) objects[j]); >+ getActionPresentation().removeActionSet( >+ (IActionSetDescriptor) objects[j]); >+ } >+ } >+ } >+ } finally { >+ contextService.activateContext(ContextAuthority.SEND_EVENTS); >+ } >+ >+ if (updateNeeded) { >+ // refresh the window >+ updateActionSets(); >+ } >+ } >+ }; >+ >+ void registerGlobalAction(IAction globalAction) { >+ String commandId = globalAction.getActionDefinitionId(); >+ >+ if (commandId != null) { >+ final Object value = globalActionHandlersByCommandId.get(commandId); >+ if (value instanceof ActionHandler) { >+ // This handler is about to get clobbered, so dispose it. >+ final ActionHandler handler = (ActionHandler) value; >+ handler.dispose(); >+ } >+ >+ if (globalAction instanceof CommandAction) { >+ final String actionId = globalAction.getId(); >+ if (actionId != null) { >+ final IActionCommandMappingService mappingService = (IActionCommandMappingService) serviceLocator >+ .getService(IActionCommandMappingService.class); >+ mappingService.map(actionId, commandId); >+ } >+ } else { >+ globalActionHandlersByCommandId.put(commandId, >+ new ActionHandler(globalAction)); >+ } >+ } >+ >+ submitGlobalActions(); >+ } >+ >+ /** > * <p> >- * Subclasses may override this method to customize the cool bar manager. >+ * Submits the action handlers for action set actions and global actions. >+ * Global actions are given priority, so that if a global action and an >+ * action set action both handle the same command, the global action is >+ * given priority. >+ * </p> >+ * <p> >+ * These submissions are submitted as <code>Priority.LEGACY</code>, which >+ * means that they are the lowest priority. This means that if a higher >+ * priority submission handles the same command under the same conditions, >+ * that that submission will become the handler. > * </p> >+ */ >+ void submitGlobalActions() { >+ final IHandlerService handlerService = (IHandlerService) getWorkbench().getService(IHandlerService.class); >+ >+ /* >+ * Mash the action sets and global actions together, with global actions >+ * taking priority. >+ */ >+ Map handlersByCommandId = new HashMap(); >+ handlersByCommandId.putAll(globalActionHandlersByCommandId); >+ >+ List newHandlers = new ArrayList(handlersByCommandId.size()); >+ >+ Iterator existingIter = handlerActivations.iterator(); >+ while (existingIter.hasNext()) { >+ IHandlerActivation next = (IHandlerActivation) existingIter.next(); >+ >+ String cmdId = next.getCommandId(); >+ >+ Object handler = handlersByCommandId.get(cmdId); >+ if (handler == next.getHandler()) { >+ handlersByCommandId.remove(cmdId); >+ newHandlers.add(next); >+ } else { >+ handlerService.deactivateHandler(next); >+ } >+ } >+ >+ final Shell shell = getShell(); >+ if (shell != null) { >+ final Expression expression = new ActiveShellExpression(shell); >+ for (Iterator iterator = handlersByCommandId.entrySet().iterator(); iterator >+ .hasNext();) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ String commandId = (String) entry.getKey(); >+ IHandler handler = (IHandler) entry.getValue(); >+ newHandlers.add(handlerService.activateHandler(commandId, >+ handler, expression)); >+ } >+ } >+ >+ handlerActivations = newHandlers; >+ } >+ >+ /** >+ * Add a generic property listener. > * >- * @return a cool bar manager >+ * @param listener the listener to add > */ >- protected ICoolBarManager createCoolBarManager2(int style) { >- return getActionBarPresentationFactory().createCoolBarManager(); >+ public void addPropertyChangeListener(IPropertyChangeListener listener) { >+ genericPropertyListeners.add(listener); >+ } >+ >+ /** >+ * Removes a generic property listener. >+ * >+ * @param listener the listener to remove >+ */ >+ public void removePropertyChangeListener(IPropertyChangeListener listener) { >+ genericPropertyListeners.remove(listener); >+ } >+ >+ private void firePropertyChanged(final String property, final Object oldValue, final Object newValue) { >+ PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue); >+ Object[] listeners = genericPropertyListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; >+ listener.propertyChange(event); >+ } >+ } >+ >+ /* >+ * Adds an listener to the part service. >+ */ >+ public void addPageListener(IPageListener l) { >+ pageListeners.addPageListener(l); > } > > /** >- * Returns a new tool bar manager for the window. >+ * @see org.eclipse.ui.IPageService >+ */ >+ public void addPerspectiveListener(org.eclipse.ui.IPerspectiveListener l) { >+ perspectiveListeners.addPerspectiveListener(l); >+ } >+ >+ /** >+ * Configures this window to have a perspecive bar. Does nothing if it >+ * already has one. >+ */ >+ protected void addPerspectiveBar(int style) { >+ Assert.isTrue(perspectiveSwitcher == null); >+ perspectiveSwitcher = new PerspectiveSwitcher(this, topBar, style); >+ } >+ >+ /** >+ * Close the window. >+ * >+ * Assumes that busy cursor is active. >+ */ >+ private boolean busyClose() { >+ // Whether the window was actually closed or not >+ boolean windowClosed = false; >+ >+ // Setup internal flags to indicate window is in >+ // progress of closing and no update should be done. >+ closing = true; >+ updateDisabled = true; >+ >+ try { >+ // Only do the check if it is OK to close if we are not closing >+ // via the workbench as the workbench will check this itself. >+ Workbench workbench = getWorkbenchImpl(); >+ int count = workbench.getWorkbenchWindowCount(); >+ // also check for starting - if the first window dies on startup >+ // then we'll need to open a default window. >+ if (!workbench.isStarting() >+ && !workbench.isClosing() >+ && count <= 1 >+ && workbench.getWorkbenchConfigurer() >+ .getExitOnLastWindowClose()) { >+ windowClosed = workbench.close(); >+ } else { >+ if (okToClose()) { >+ windowClosed = hardClose(); >+ } >+ } >+ } finally { >+ if (!windowClosed) { >+ // Reset the internal flags if window was not closed. >+ closing = false; >+ updateDisabled = false; >+ } >+ } >+ >+ if (windowClosed && tracker != null) { >+ tracker.close(); >+ } >+ >+ return windowClosed; >+ } >+ >+ /** >+ * Opens a new page. Assumes that busy cursor is active. > * <p> >- * Subclasses may override this method to customize the tool bar manager. >+ * <b>Note:</b> Since release 2.0, a window is limited to contain at most >+ * one page. If a page exist in the window when this method is used, then >+ * another window is created for the new page. Callers are strongly >+ * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >+ * programmatically show a perspective. > * </p> >- * @return a tool bar manager > */ >- protected IToolBarManager createToolBarManager2(int style) { >- return getActionBarPresentationFactory().createToolBarManager(); >+ protected IWorkbenchPage busyOpenPage(String perspID, IAdaptable input) >+ throws WorkbenchException { >+ IWorkbenchPage newPage = null; >+ >+ if (pageList.isEmpty()) { >+ newPage = ((WorkbenchImplementation) Tweaklets >+ .get(WorkbenchImplementation.KEY)).createWorkbenchPage(this, perspID, input); >+ pageList.add(newPage); >+ firePageOpened(newPage); >+ setActivePage(newPage); >+ } else { >+ IWorkbenchWindow window = getWorkbench().openWorkbenchWindow( >+ perspID, input); >+ newPage = window.getActivePage(); >+ } >+ >+ return newPage; > } >- >+ > /** >- * Delegate to the presentation factory. >- * >- * @see org.eclipse.jface.window.ApplicationWindow#createStatusLineManager >- */ >- protected StatusLineManager createStatusLineManager() { >- // @issue ApplicationWindow and WorkbenchWindow should allow full >- // IStatusLineManager >- return (StatusLineManager) getWindowConfigurer() >- .getPresentationFactory().createStatusLineManager(); >- } >- >- /** >- * Delegate to the presentation factory. >- * >- * @see org.eclipse.jface.window.ApplicationWindow#createStatusLine >- */ >- protected void createStatusLine(Shell shell) { >- getWindowConfigurer().getPresentationFactory().createStatusLineControl( >- getStatusLineManager(), shell); >- } >- >- /** >- * Updates the fast view bar, if present. TODO: The fast view bar should >- * update itself as necessary. All calls to this should be cleaned up. >- */ >- public void updateFastViewBar() { >- if (getFastViewBar() != null) { >- getFastViewBar().update(true); >- } >- } >- >- /** >- * @return Returns the progressRegion. >- */ >- public ProgressRegion getProgressRegion() { >- return progressRegion; >- } >- >- /** >- * Adds the given control to the specified side of this window's trim. >- * >- * @param trim >- * the bar's IWindowTrim >- * @param side >- * one of <code>SWT.LEFT</code>,<code>SWT.BOTTOM</code>, >- * or <code>SWT.RIGHT</code> (only LEFT has been tested) >- */ >- public void addToTrim(IWindowTrim trim, int side) { >- IWindowTrim reference = null; >- defaultLayout.addTrim(side, trim, reference); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.IWorkbenchWindow#getExtensionTracker() >- */ >- public IExtensionTracker getExtensionTracker() { >- if (tracker == null) { >- tracker = new UIExtensionTracker(getWorkbench().getDisplay()); >- } >- return tracker; >- } >- >- /** >- * Creates the perspective customization dialog. >- * >- * @param persp >- * perspective to customize >- * >- * @return a new perspective customization dialog >- */ >- public CustomizePerspectiveDialog createCustomizePerspectiveDialog( >- Perspective persp) { >- return new CustomizePerspectiveDialog(getWindowConfigurer(), persp); >- } >- >- /** >- * Returns the default page input for workbench pages opened in this window. >- * >- * @return the default page input or <code>null</code> if none >- */ >- IAdaptable getDefaultPageInput() { >- return getWorkbenchImpl().getDefaultPageInput(); >- } >- >- /** >- * Add a listener for perspective reordering. >- * >- * @param listener >- */ >- public void addPerspectiveReorderListener(IReorderListener listener) { >- if (perspectiveSwitcher != null) { >- perspectiveSwitcher.addReorderListener(listener); >- } >- } >- >-// RAP [rh] HeapStatus not supported >-// /** >-// * Show the heap status >-// * >-// * @param selection >-// */ >-// public void showHeapStatus(boolean selection) { >-// if (selection) { >-// if (heapStatus == null) { >-// createHeapStatus(getShell()); >-// updateLayoutDataForContents(); >-// getShell().layout(); >-// } >-// } else { >-// if (heapStatus != null) { >-// heapStatus.dispose(); >-// heapStatus = null; >-// } >-// } >-// >-// } >+ * @see Window >+ */ >+ public int open() { >+ if (getPages().length == 0) { >+ showEmptyWindowContents(); >+ } >+ fireWindowCreated(); >+// RAP [rh] Intro mechanism not supported >+// getWindowAdvisor().openIntro(); >+ int result = super.open(); >+ >+ // It's time for a layout ... to insure that if TrimLayout >+ // is in play, it updates all of the trim it's responsible >+ // for. We have to do this before updating in order to get >+ // the PerspectiveBar management correct...see defect 137334 >+ getShell().layout(); >+ >+ fireWindowOpened(); >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.updatePerspectiveBar(); >+ perspectiveSwitcher.updateBarParent(); >+ } >+ >+ return result; >+ } >+ >+ /* >+ * (non-Javadoc) Method declared on Window. >+ */ >+ protected boolean canHandleShellCloseEvent() { >+ if (!super.canHandleShellCloseEvent()) { >+ return false; >+ } >+ // let the advisor or other interested parties >+ // veto the user's explicit request to close the window >+ return fireWindowShellClosing(); >+ } >+ >+ /** >+ * @see IWorkbenchWindow >+ */ >+ public boolean close() { >+ final boolean[] ret = new boolean[1]; >+ BusyIndicator.showWhile(null, new Runnable() { >+ public void run() { >+ ret[0] = busyClose(); >+ } >+ }); >+ return ret[0]; >+ } >+ >+ protected boolean isClosing() { >+ return closing || getWorkbenchImpl().isClosing(); >+ } >+ >+ /** >+ * Return whether or not the coolbar layout is locked. >+ */ >+ protected boolean isCoolBarLocked() { >+ ICoolBarManager cbm = getCoolBarManager2(); >+ return cbm != null && cbm.getLockLayout(); >+ } >+ >+ /** >+ * Close all of the pages. >+ */ >+ private void closeAllPages() { >+ // Deactivate active page. >+ setActivePage(null); >+ >+ // Clone and deref all so that calls to getPages() returns >+ // empty list (if call by pageClosed event handlers) >+ PageList oldList = pageList; >+ pageList = new PageList(); >+ >+ // Close all. >+ Iterator itr = oldList.iterator(); >+ while (itr.hasNext()) { >+ WorkbenchPage page = (WorkbenchPage) itr.next(); >+ firePageClosed(page); >+ page.dispose(); >+ } >+ if (!closing) { >+ showEmptyWindowContents(); >+ } >+ } >+ >+ /** >+ * Save and close all of the pages. >+ */ >+ public void closeAllPages(boolean save) { >+ if (save) { >+ boolean ret = saveAllPages(true); >+ if (!ret) { >+ return; >+ } >+ } >+ closeAllPages(); >+ } >+ >+ /** >+ * closePerspective method comment. >+ */ >+ protected boolean closePage(IWorkbenchPage in, boolean save) { >+ // Validate the input. >+ if (!pageList.contains(in)) { >+ return false; >+ } >+ WorkbenchPage oldPage = (WorkbenchPage) in; >+ >+ // Save old perspective. >+ if (save && oldPage.isSaveNeeded()) { >+ if (!oldPage.saveAllEditors(true)) { >+ return false; >+ } >+ } >+ >+ // If old page is activate deactivate. >+ boolean oldIsActive = (oldPage == getActiveWorkbenchPage()); >+ if (oldIsActive) { >+ setActivePage(null); >+ } >+ >+ // Close old page. >+ pageList.remove(oldPage); >+ firePageClosed(oldPage); >+ oldPage.dispose(); >+ >+ // Activate new page. >+ if (oldIsActive) { >+ IWorkbenchPage newPage = pageList.getNextActive(); >+ if (newPage != null) { >+ setActivePage(newPage); >+ } >+ } >+ if (!closing && pageList.isEmpty()) { >+ showEmptyWindowContents(); >+ } >+ return true; >+ } >+ >+ private void showEmptyWindowContents() { >+ if (!emptyWindowContentsCreated) { >+ Composite parent = getPageComposite(); >+ emptyWindowContents = getWindowAdvisor().createEmptyWindowContents( >+ parent); >+ emptyWindowContentsCreated = true; >+ // force the empty window composite to be layed out >+ ((StackLayout) parent.getLayout()).topControl = emptyWindowContents; >+ parent.layout(); >+ } >+ } > >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.IWorkbenchWindow#getTrimManager() >- */ >- public ITrimManager getTrimManager() { >- return defaultLayout; >- } >- >- /** >- * Initializes all of the default command-based services for the workbench >- * window. >- */ >- private final void initializeDefaultServices() { >- serviceLocator.registerService(IWorkbenchWindow.class, this); >- >- final ActionCommandMappingService mappingService = new ActionCommandMappingService(); >- serviceLocator.registerService(IActionCommandMappingService.class, >- mappingService); >- >- final LegacyActionPersistence actionPersistence = new LegacyActionPersistence( >- this); >- serviceLocator.registerService(LegacyActionPersistence.class, >- actionPersistence); >- actionPersistence.read(); >- >- } >- >- public final Object getService(final Class key) { >- return serviceLocator.getService(key); >- } >- >- public final boolean hasService(final Class key) { >- return serviceLocator.hasService(key); >- } >- >- /** >- * Toggle the visibility of the coolbar/perspective bar. This method >- * respects the window configurer and will only toggle visibility if the >- * item in question was originally declared visible by the window advisor. >- */ >- public void toggleToolbarVisibility() { >- boolean coolbarVisible = getCoolBarVisible(); >- boolean perspectivebarVisible = getPerspectiveBarVisible(); >- // only toggle the visibility of the components that >- // were on initially >- if (getWindowConfigurer().getShowCoolBar()) { >- setCoolBarVisible(!coolbarVisible); >- firePropertyChanged(PROP_COOLBAR_VISIBLE, >- coolbarVisible ? Boolean.TRUE : Boolean.FALSE, >- !coolbarVisible ? Boolean.TRUE : Boolean.FALSE); >- } >- if (getWindowConfigurer().getShowPerspectiveBar()) { >- setPerspectiveBarVisible(!perspectivebarVisible); >- firePropertyChanged(PROP_PERSPECTIVEBAR_VISIBLE, >- coolbarVisible ? Boolean.TRUE : Boolean.FALSE, >- !coolbarVisible ? Boolean.TRUE : Boolean.FALSE); >- } >- getShell().layout(); >- } >- >- /*package*/ void addBackgroundSaveListener(IBackgroundSaveListener listener) { >- backgroundSaveListeners.add(listener); >- } >- >- /*package*/ void fireBackgroundSaveStarted() { >- Object[] listeners = backgroundSaveListeners.getListeners(); >- for (int i = 0; i < listeners.length; i++) { >- IBackgroundSaveListener listener = (IBackgroundSaveListener) listeners[i]; >- listener.handleBackgroundSaveStarted(); >- } >- } >- >- /*package*/ void removeBackgroundSaveListener(IBackgroundSaveListener listener) { >- backgroundSaveListeners.remove(listener); >- } >+ private void hideEmptyWindowContents() { >+ if (emptyWindowContentsCreated) { >+ if (emptyWindowContents != null) { >+ emptyWindowContents.dispose(); >+ emptyWindowContents = null; >+ getPageComposite().layout(); >+ } >+ emptyWindowContentsCreated = false; >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void configureShell(Shell shell) { >+ super.configureShell(shell); >+ >+ // RAP [bm]: detached windows >+// detachedWindowShells = new ShellPool(shell, SWT.TOOL | SWT.TITLE >+// | SWT.MAX | SWT.RESIZE | getDefaultOrientation()); >+ // RAPEND: [bm] >+ >+ String title = getWindowConfigurer().basicGetTitle(); >+ if (title != null) { >+ shell.setText(TextProcessor.process(title, TEXT_DELIMITERS)); >+ } >+ >+// RAP [rh] IWorkbench#getHelpSystem() not implemented >+// final IWorkbench workbench = getWorkbench(); >+// workbench.getHelpSystem().setHelp(shell, >+// IWorkbenchHelpContextIds.WORKBENCH_WINDOW); >+ >+// initializeDefaultServices(); >+ final IContextService contextService = (IContextService) getWorkbench().getService(IContextService.class); >+ contextService.registerShell(shell, IContextService.TYPE_WINDOW); >+ >+ trackShellActivation(shell); >+ trackShellResize(shell); >+ } >+ >+ // RAP [bm]: detached windows >+// /* package */ShellPool getDetachedWindowPool() { >+// return detachedWindowShells; >+// } >+ // RAPEND: [bm] >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.ApplicationWindow#createTrimWidgets(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void createTrimWidgets(Shell shell) { >+ // do nothing -- trim widgets are created in createDefaultContents >+ } >+ >+ /** >+ * Creates and remembers the client composite, under which workbench pages >+ * create their controls. >+ */ >+ protected Composite createPageComposite(Composite parent) { >+ pageComposite = new Composite(parent, SWT.NONE); >+ // use a StackLayout instead of a FillLayout (see bug 81460 [Workbench] >+ // (regression) Close all perspectives, open Java perspective, layout >+ // wrong) >+ pageComposite.setLayout(new StackLayout()); >+ return pageComposite; >+ } >+ >+ /** >+ * Creates the contents of the workbench window, including trim controls and >+ * the client composite. This MUST create the client composite via a call to >+ * <code>createClientComposite</code>. >+ */ >+ protected Control createContents(Composite parent) { >+ // RAP [hs] patched for interactiondesign API >+ if( getConfigurablePresentationFactory() != null ) { >+ defaultLayout = new TrimLayout(); >+ >+ Composite pageComp = createConfigurableDefaultContents( ( Shell ) parent ); >+ createPageComposite( pageComp ); >+ >+ } else { >+ // we know from Window.create that the parent is a Shell. >+ getWindowAdvisor().createWindowContents((Shell) parent); >+ // the page composite must be set by createWindowContents >+ } >+ Assert >+ .isNotNull(pageComposite, >+ "createWindowContents must call configurer.createPageComposite"); //$NON-NLS-1$ >+ return pageComposite; >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ public PresentationFactory getConfigurablePresentationFactory() { >+ PresentationFactory result = null; >+ WorkbenchWindowConfigurer configurer = getWindowConfigurer(); >+ AbstractPresentationFactory presentationFactory >+ = configurer.getPresentationFactory(); >+ if( presentationFactory instanceof PresentationFactory ) { >+ result = ( PresentationFactory ) presentationFactory; >+ } >+ return result; >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private Composite createConfigurableDefaultContents( Shell shell ) { >+ PresentationFactory presentationFactory >+ = getConfigurablePresentationFactory(); >+ IWindowComposer windowComposer >+ = presentationFactory.createWindowComposer(); >+ Composite result >+ = windowComposer.createWindowContents( shell, getWindowConfigurer() ); >+ return result; >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private void callConfigurablePreWindowOpen() { >+ PresentationFactory presentationFactory >+ = getConfigurablePresentationFactory(); >+ IWindowComposer windowComposer >+ = presentationFactory.createWindowComposer(); >+ windowComposer.preWindowOpen( getWindowConfigurer() ); >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private void callConfigurablePostWindowCreate() { >+ PresentationFactory presentationFactory >+ = getConfigurablePresentationFactory(); >+ IWindowComposer windowComposer >+ = presentationFactory.createWindowComposer(); >+ windowComposer.postWindowCreate( getWindowConfigurer() ); >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ private MenuManager createConfigurableMenuManager() { >+ PresentationFactory presentationFactory >+ = getConfigurablePresentationFactory(); >+ return presentationFactory.createMenuBarManager(); >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ MenuManager createPartMenuManager() { >+ PresentationFactory presentationFactory >+ = getConfigurablePresentationFactory(); >+ return presentationFactory.createPartMenuManager(); >+ } >+ >+ // RAP [hs] method introduced for interactiondesign API >+ public Composite changeWindowLayoutSet() { >+ Shell shell = getShell(); >+ Composite result = createConfigurableDefaultContents( shell ); >+ >+ getMenuBarManager().update( false ); >+ getCoolBarManager2().update( false ); >+ getStatusLineManager().update( true ); >+ >+ return result; >+ } >+ >+ >+ /** >+ * If the perspective bar is drawn on the top right corner of the window, >+ * then this method changes its appearance from curved to square. This >+ * should have its own preference, but for now it piggy-backs on the >+ * SHOW_TRADITIONAL_STYLE_TABS preference. >+ * >+ * @param square >+ * true for a square banner and false otherwise >+ */ >+ public void setBannerCurve(boolean square) { >+ if (topBar != null) { >+ topBar.setSimple(square); >+ } >+ } >+ >+ /** >+ * Creates the default contents and layout of the shell. >+ * >+ * @param shell >+ * the shell >+ */ >+ protected void createDefaultContents(final Shell shell) { >+ defaultLayout = new TrimLayout(); >+ shell.setLayout(defaultLayout); >+ >+ Menu menuBar = getMenuBarManager().createMenuBar(shell); >+ if (getWindowConfigurer().getShowMenuBar()) { >+ shell.setMenuBar(menuBar); >+ } >+ >+ // Create the CBanner widget which parents both the Coolbar >+ // and the perspective switcher, and supports some configurations >+ // on the left right and bottom >+ topBar = new CBanner(shell, SWT.NONE); >+ topBarTrim = new WindowTrimProxy(topBar, >+ "org.eclipse.ui.internal.WorkbenchWindow.topBar", //$NON-NLS-1$ >+ WorkbenchMessages.get().TrimCommon_Main_TrimName, SWT.NONE, true); >+ >+ // the banner gets a curve along with the new tab style >+ // TODO create a dedicated preference for this >+ // RAP [bm]: not needed >+// setBannerCurve(PrefUtil.getAPIPreferenceStore().getBoolean( >+// IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); >+ setBannerCurve(false); >+ // RAPEND: [bm] >+ >+ CacheWrapper coolbarCacheWrapper = new CacheWrapper(topBar); >+ >+ final Control coolBar = createCoolBarControl(coolbarCacheWrapper >+ .getControl()); >+ // need to resize the shell, not just the coolbar's immediate >+ // parent, if the coolbar wants to grow or shrink >+ >+ coolBar.addListener(SWT.Resize, new Listener() { >+ public void handleEvent(Event event) { >+ // If the user is dragging the sash then we will need to force >+ // a resize. However, if the coolbar was resized programatically >+ // then everything is already layed out correctly. There is no >+ // direct way to tell the difference between these cases, >+ // however >+ // we take advantage of the fact that dragging the sash does not >+ // change the size of the shell, and only force another layout >+ // if the shell size is unchanged. >+ Rectangle clientArea = shell.getClientArea(); >+ >+ if (lastShellSize.x == clientArea.width >+ && lastShellSize.y == clientArea.height) { >+ LayoutUtil.resize(coolBar); >+ } >+ >+ lastShellSize.x = clientArea.width; >+ lastShellSize.y = clientArea.height; >+ } >+ }); >+ >+ if (getWindowConfigurer().getShowCoolBar()) { >+ topBar.setLeft(coolbarCacheWrapper.getControl()); >+ } >+ >+ createStatusLine(shell); >+ >+ fastViewBar = new FastViewBar(this); >+ fastViewBar.createControl(shell); >+ >+ if (getWindowConfigurer().getShowPerspectiveBar()) { >+ addPerspectiveBar(perspectiveBarStyle()); >+ perspectiveSwitcher.createControl(shell); >+ } >+ >+ createProgressIndicator(shell); >+ >+// RAP [rh] HeapStatus not supported >+// if (getShowHeapStatus()) { >+// createHeapStatus(shell); >+// } >+ >+ // Insert any contributed trim into the layout >+ // Legacy (3.2) trim >+ trimMgr2 = new TrimBarManager2(this); >+ >+ // 3.3 Trim contributions >+ trimContributionMgr = new TrimContributionManager(this); >+ >+ // RAP [bm]: DnD >+// trimDropTarget = new TrimDropTarget(shell, this); >+// DragUtil.addDragTarget(shell, trimDropTarget); >+// DragUtil.addDragTarget(null, trimDropTarget); >+ // RAPEND: [bm] >+ >+ // Create the client composite area (where page content goes). >+ createPageComposite(shell); >+ >+ setLayoutDataForContents(); >+ // System.err.println(defaultLayout.displayTrim()); >+ } >+ >+// RAP [rh] HeapStatus not supported >+// /** >+// * Returns whether the heap status indicator should be shown. >+// * >+// * @return <code>true</code> to show the heap status indicator, >+// * <code>false</code> otherwise >+// */ >+// private boolean getShowHeapStatus() { >+// return // Show if the preference is set or debug option is on >+// PrefUtil.getAPIPreferenceStore().getBoolean( >+// IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR) >+// || Boolean.valueOf( >+// Platform.getDebugOption(PlatformUI.PLUGIN_ID >+// + "/perf/showHeapStatus")).booleanValue(); //$NON-NLS-1$ >+// } >+// >+// /** >+// * Creates the controls for the heap status indicator. >+// * >+// * @param parent >+// * the parent composite >+// */ >+// private void createHeapStatus(Composite parent) { >+// heapStatus = new HeapStatus(parent, PrefUtil >+// .getInternalPreferenceStore()); >+// >+// // Subclass the trim to allow closing... >+// heapStatusTrim = new WindowTrimProxy(heapStatus, >+// "org.eclipse.ui.internal.HeapStatus", //$NON-NLS-1$ >+// WorkbenchMessages.get().TrimCommon_HeapStatus_TrimName, SWT.BOTTOM >+// | SWT.TOP) { >+// >+// public void handleClose() { >+// getControl().dispose(); >+// } >+// >+// public boolean isCloseable() { >+// return true; >+// } >+// }; >+// } >+ >+ /** >+ * <p> >+ * Returns a new menu manager for this workbench window. This menu manager >+ * will just be a proxy to the new command-based menu service. >+ * </p> >+ * <p> >+ * Subclasses may override this method to customize the menu manager. >+ * </p> >+ * >+ * @return a menu manager for this workbench window; never <code>null</code>. >+ */ >+ protected MenuManager createMenuManager() { >+ MenuManager result = null; >+ // RAP [hs] patched for interactiondesign API >+ if( getConfigurablePresentationFactory() != null ) { >+ result = createConfigurableMenuManager(); >+ } >+ if( result == null ) { >+ result = super.createMenuManager(); >+ } >+ return result; >+ } >+ >+ /** >+ * Set the perspective bar location >+ * >+ * @param location >+ * the location to place the bar >+ */ >+ public void setPerspectiveBarLocation(String location) { >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.setPerspectiveBarLocation(location); >+ } >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor) that the window is about >+ * to be opened. >+ */ >+ private void fireWindowOpening() { >+ // RAP [hs] patched for interactiondesign API >+ if( getConfigurablePresentationFactory() != null ) { >+ callConfigurablePreWindowOpen(); >+ } else { >+ // let the application do further configuration >+ getWindowAdvisor().preWindowOpen(); >+ } >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor) that the window has been >+ * restored from a previously saved state. >+ * >+ * @throws WorkbenchException >+ * passed through from the advisor >+ */ >+ void fireWindowRestored() throws WorkbenchException { >+ StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { >+ public void runWithException() throws Throwable { >+ getWindowAdvisor().postWindowRestore(); >+ } >+ }); >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor) that the window has been >+ * created. >+ */ >+ private void fireWindowCreated() { >+ // RAP [hs] patched for interactiondesign API >+ if( getConfigurablePresentationFactory() != null ) { >+ callConfigurablePostWindowCreate(); >+ } else { >+ getWindowAdvisor().postWindowCreate(); >+ } >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor and the window listeners) >+ * that the window has been opened. >+ */ >+ private void fireWindowOpened() { >+ getWorkbenchImpl().fireWindowOpened(this); >+ getWindowAdvisor().postWindowOpen(); >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor) that the window's shell >+ * is closing. Allows the close to be vetoed. >+ * >+ * @return <code>true</code> if the close should proceed, >+ * <code>false</code> if it should be canceled >+ */ >+ private boolean fireWindowShellClosing() { >+ return getWindowAdvisor().preWindowShellClose(); >+ } >+ >+ /** >+ * Notifies interested parties (namely the advisor and the window listeners) >+ * that the window has been closed. >+ */ >+ private void fireWindowClosed() { >+ // let the application do further deconfiguration >+ getWindowAdvisor().postWindowClose(); >+ getWorkbenchImpl().fireWindowClosed(this); >+ } >+ >+ /** >+ * Fires page activated >+ */ >+ private void firePageActivated(IWorkbenchPage page) { >+ String label = null; // debugging only >+ if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >+ label = "activated " + page.getLabel(); //$NON-NLS-1$ >+ } >+ try { >+ UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >+ UIListenerLogging.logPageEvent(this, page, >+ UIListenerLogging.WPE_PAGE_ACTIVATED); >+ pageListeners.firePageActivated(page); >+ partService.pageActivated(page); >+ } finally { >+ UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >+ } >+ } >+ >+ /** >+ * Fires page closed >+ */ >+ private void firePageClosed(IWorkbenchPage page) { >+ String label = null; // debugging only >+ if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >+ label = "closed " + page.getLabel(); //$NON-NLS-1$ >+ } >+ try { >+ UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >+ UIListenerLogging.logPageEvent(this, page, >+ UIListenerLogging.WPE_PAGE_CLOSED); >+ pageListeners.firePageClosed(page); >+ partService.pageClosed(page); >+ } finally { >+ UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >+ } >+ >+ } >+ >+ /** >+ * Fires page opened >+ */ >+ private void firePageOpened(IWorkbenchPage page) { >+ String label = null; // debugging only >+ if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { >+ label = "opened " + page.getLabel(); //$NON-NLS-1$ >+ } >+ try { >+ UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); >+ UIListenerLogging.logPageEvent(this, page, >+ UIListenerLogging.WPE_PAGE_OPENED); >+ pageListeners.firePageOpened(page); >+ partService.pageOpened(page); >+ } finally { >+ UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); >+ } >+ } >+ >+ /** >+ * Fires perspective activated >+ */ >+ void firePerspectiveActivated(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective) { >+ UIListenerLogging.logPerspectiveEvent(this, page, perspective, >+ UIListenerLogging.PLE_PERSP_ACTIVATED); >+ perspectiveListeners.firePerspectiveActivated(page, perspective); >+ } >+ >+ /** >+ * Fires perspective deactivated. >+ */ >+ void firePerspectivePreDeactivate(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective) { >+ UIListenerLogging.logPerspectiveEvent(this, page, perspective, >+ UIListenerLogging.PLE_PERSP_PRE_DEACTIVATE); >+ perspectiveListeners.firePerspectivePreDeactivate(page, perspective); >+ } >+ >+ /** >+ * Fires perspective deactivated. >+ */ >+ void firePerspectiveDeactivated(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective) { >+ UIListenerLogging.logPerspectiveEvent(this, page, perspective, >+ UIListenerLogging.PLE_PERSP_DEACTIVATED); >+ perspectiveListeners.firePerspectiveDeactivated(page, perspective); >+ } >+ >+ /** >+ * Fires perspective changed >+ */ >+ public void firePerspectiveChanged(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective, String changeId) { >+ // Some callers call this even when there is no active perspective. >+ // Just ignore this case. >+ if (perspective != null) { >+ UIListenerLogging.logPerspectiveChangedEvent(this, page, >+ perspective, null, changeId); >+ perspectiveListeners.firePerspectiveChanged(page, perspective, >+ changeId); >+ } >+ } >+ >+ /** >+ * Fires perspective changed for an affected part >+ */ >+ public void firePerspectiveChanged(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective, >+ IWorkbenchPartReference partRef, String changeId) { >+ // Some callers call this even when there is no active perspective. >+ // Just ignore this case. >+ if (perspective != null) { >+ UIListenerLogging.logPerspectiveChangedEvent(this, page, >+ perspective, partRef, changeId); >+ perspectiveListeners.firePerspectiveChanged(page, perspective, >+ partRef, changeId); >+ } >+ } >+ >+ /** >+ * Fires perspective closed >+ */ >+ void firePerspectiveClosed(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective) { >+ UIListenerLogging.logPerspectiveEvent(this, page, perspective, >+ UIListenerLogging.PLE_PERSP_CLOSED); >+ perspectiveListeners.firePerspectiveClosed(page, perspective); >+ } >+ >+ /** >+ * Fires perspective opened >+ */ >+ void firePerspectiveOpened(IWorkbenchPage page, >+ IPerspectiveDescriptor perspective) { >+ UIListenerLogging.logPerspectiveEvent(this, page, perspective, >+ UIListenerLogging.PLE_PERSP_OPENED); >+ perspectiveListeners.firePerspectiveOpened(page, perspective); >+ } >+ >+ /** >+ * Fires perspective saved as. >+ */ >+ void firePerspectiveSavedAs(IWorkbenchPage page, >+ IPerspectiveDescriptor oldPerspective, >+ IPerspectiveDescriptor newPerspective) { >+ UIListenerLogging.logPerspectiveSavedAs(this, page, oldPerspective, >+ newPerspective); >+ perspectiveListeners.firePerspectiveSavedAs(page, oldPerspective, >+ newPerspective); >+ } >+ >+ /** >+ * Returns the action bars for this window. >+ */ >+ public WWinActionBars getActionBars() { >+ if (actionBars == null) { >+ actionBars = new WWinActionBars(this); >+ } >+ return actionBars; >+ } >+ >+ /** >+ * Returns the active page. >+ * >+ * @return the active page >+ */ >+ public IWorkbenchPage getActivePage() { >+ return pageList.getActive(); >+ } >+ >+ /** >+ * Returns the active workbench page. >+ * >+ * @return the active workbench page >+ */ >+ /* package */ >+ WorkbenchPage getActiveWorkbenchPage() { >+ return pageList.getActive(); >+ } >+ >+ /** >+ * Returns the page composite, under which the window's pages create their >+ * controls. >+ */ >+ protected Composite getPageComposite() { >+ return pageComposite; >+ } >+ >+ /** >+ * Answer the menu manager for this window. >+ */ >+ public MenuManager getMenuManager() { >+ return getMenuBarManager(); >+ } >+ >+ /** >+ * Returns the number. This corresponds to a page number in a window or a >+ * window number in the workbench. >+ */ >+ public int getNumber() { >+ return number; >+ } >+ >+ /** >+ * Returns an array of the pages in the workbench window. >+ * >+ * @return an array of pages >+ */ >+ public IWorkbenchPage[] getPages() { >+ return pageList.getPages(); >+ } >+ >+ /** >+ * @see IWorkbenchWindow >+ */ >+ public IPartService getPartService() { >+ return partService; >+ } >+ >+ /** >+ * Returns the layout for the shell. >+ * >+ * @return the layout for the shell >+ */ >+ protected Layout getLayout() { >+ return null; >+ } >+ >+ /** >+ * @see IWorkbenchWindow >+ */ >+ public ISelectionService getSelectionService() { >+ return partService.getSelectionService(); >+ } >+ >+ /** >+ * Returns <code>true</code> when the window's shell is activated, >+ * <code>false</code> when it's shell is deactivated >+ * >+ * @return boolean <code>true</code> when shell activated, >+ * <code>false</code> when shell deactivated >+ */ >+ public boolean getShellActivated() { >+ return shellActivated; >+ } >+ >+ /** >+ * Returns the status line manager for this window (if it has one). >+ * >+ * @return the status line manager, or <code>null</code> if this window >+ * does not have a status line >+ * @see ApplicationWindow#addStatusLine >+ */ >+ public StatusLineManager getStatusLineManager() { >+ return super.getStatusLineManager(); >+ } >+ >+ private IWindowTrim getStatusLineTrim() { >+ if (statusLineTrim == null) { >+ statusLineTrim = new WindowTrimProxy( >+ getStatusLineManager().getControl(), >+ "org.eclipse.jface.action.StatusLineManager", //$NON-NLS-1$ >+ WorkbenchMessages.get().TrimCommon_StatusLine_TrimName, SWT.NONE, >+ true); >+ } >+ return statusLineTrim; >+ } >+ >+ /** >+ * @see IWorkbenchWindow >+ */ >+ public IWorkbench getWorkbench() { >+ return PlatformUI.getWorkbench(); >+ } >+ >+ public String getToolbarLabel(String actionSetId) { >+ ActionSetRegistry registry = WorkbenchPlugin.getDefault() >+ .getActionSetRegistry(); >+ IActionSetDescriptor actionSet = registry.findActionSet(actionSetId); >+ if (actionSet != null) { >+ return actionSet.getLabel(); >+ } >+ >+ if (IWorkbenchActionConstants.TOOLBAR_FILE >+ .equalsIgnoreCase(actionSetId)) { >+ return WorkbenchMessages.get().WorkbenchWindow_FileToolbar; >+ } >+ >+ if (IWorkbenchActionConstants.TOOLBAR_NAVIGATE >+ .equalsIgnoreCase(actionSetId)) { >+ return WorkbenchMessages.get().WorkbenchWindow_NavigateToolbar; >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Unconditionally close this window. Assumes the proper flags have been set >+ * correctly (e.i. closing and updateDisabled) >+ */ >+ private boolean hardClose() { >+ boolean result; >+ try { >+ // Clear the action sets, fix for bug 27416. >+ getActionPresentation().clearActionSets(); >+ >+ // Remove the handler submissions. Bug 64024. >+ final IWorkbench workbench = getWorkbench(); >+ final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class); >+ handlerService.deactivateHandlers(handlerActivations); >+ final Iterator activationItr = handlerActivations.iterator(); >+ while (activationItr.hasNext()) { >+ final IHandlerActivation activation = (IHandlerActivation) activationItr >+ .next(); >+ activation.getHandler().dispose(); >+ } >+ handlerActivations.clear(); >+ globalActionHandlersByCommandId.clear(); >+ >+ // Remove the enabled submissions. Bug 64024. >+ final IContextService contextService = (IContextService) workbench.getService(IContextService.class); >+ contextService.unregisterShell(getShell()); >+ >+ closeAllPages(); >+ >+ fireWindowClosed(); >+ >+ // time to wipe our our populate >+ IMenuService menuService = (IMenuService) workbench >+ .getService(IMenuService.class); >+ menuService >+ .releaseContributions(((ContributionManager) getActionBars() >+ .getMenuManager())); >+ ICoolBarManager coolbar = getActionBars().getCoolBarManager(); >+ if (coolbar != null) { >+ menuService >+ .releaseContributions(((ContributionManager) coolbar)); >+ } >+ >+ getActionBarAdvisor().dispose(); >+ getWindowAdvisor().dispose(); >+ >+ // RAP [bm]: detached windows >+// detachedWindowShells.dispose(); >+ // RAPEND: [bm] >+ >+ // Bring down all of the services. >+ serviceLocator.dispose(); >+ >+ // Null out the progress region. Bug 64024. >+ progressRegion = null; >+ >+ // RAP [bm]: >+// // Remove drop targets >+// DragUtil.removeDragTarget(null, trimDropTarget); >+// DragUtil.removeDragTarget(getShell(), trimDropTarget); >+// trimDropTarget = null; >+ // RAPEND: [bm] >+ >+ if (trimMgr2 != null) { >+ trimMgr2.dispose(); >+ trimMgr2 = null; >+ } >+ >+ if (trimContributionMgr != null) { >+ trimContributionMgr.dispose(); >+ trimContributionMgr = null; >+ } >+ } finally { >+ result = super.close(); >+ } >+ return result; >+ } >+ >+ /** >+ * @see IWorkbenchWindow >+ */ >+ public boolean isApplicationMenu(String menuID) { >+ // delegate this question to the action bar advisor >+ return getActionBarAdvisor().isApplicationMenu(menuID); >+ } >+ >+ /** >+ * Return whether or not the given id matches the id of the coolitems that >+ * the application creates. >+ */ >+ /* package */ >+ boolean isWorkbenchCoolItemId(String id) { >+ return windowConfigurer.containsCoolItem(id); >+ } >+ >+ /** >+ * Locks/unlocks the CoolBar for the workbench. >+ * >+ * @param lock >+ * whether the CoolBar should be locked or unlocked >+ */ >+ /* package */ >+ void lockCoolBar(boolean lock) { >+ getCoolBarManager2().setLockLayout(lock); >+ } >+ >+ /** >+ * Makes the window visible and frontmost. >+ */ >+ void makeVisible() { >+ Shell shell = getShell(); >+ if (shell != null && !shell.isDisposed()) { >+ // see bug 96700 and bug 4414 for a discussion on the use of open() >+ // here >+ shell.open(); >+ } >+ } >+ >+ /** >+ * Called when this window is about to be closed. >+ * >+ * Subclasses may overide to add code that returns <code>false</code> to >+ * prevent closing under certain conditions. >+ */ >+ public boolean okToClose() { >+ // Save all of the editors. >+ if (!getWorkbenchImpl().isClosing()) { >+ if (!saveAllPages(true)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ /** >+ * Opens a new page. >+ * <p> >+ * <b>Note:</b> Since release 2.0, a window is limited to contain at most >+ * one page. If a page exist in the window when this method is used, then >+ * another window is created for the new page. Callers are strongly >+ * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >+ * programmatically show a perspective. >+ * </p> >+ */ >+ public IWorkbenchPage openPage(final String perspId, final IAdaptable input) >+ throws WorkbenchException { >+ Assert.isNotNull(perspId); >+ >+ // Run op in busy cursor. >+ final Object[] result = new Object[1]; >+ BusyIndicator.showWhile(null, new Runnable() { >+ public void run() { >+ try { >+ result[0] = busyOpenPage(perspId, input); >+ } catch (WorkbenchException e) { >+ result[0] = e; >+ } >+ } >+ }); >+ >+ if (result[0] instanceof IWorkbenchPage) { >+ return (IWorkbenchPage) result[0]; >+ } else if (result[0] instanceof WorkbenchException) { >+ throw (WorkbenchException) result[0]; >+ } else { >+ throw new WorkbenchException( >+ WorkbenchMessages.get().WorkbenchWindow_exceptionMessage); >+ } >+ } >+ >+ /** >+ * Opens a new page. >+ * <p> >+ * <b>Note:</b> Since release 2.0, a window is limited to contain at most >+ * one page. If a page exist in the window when this method is used, then >+ * another window is created for the new page. Callers are strongly >+ * recommended to use the <code>IWorkbench.openPerspective</code> APIs to >+ * programmatically show a perspective. >+ * </p> >+ */ >+ public IWorkbenchPage openPage(IAdaptable input) throws WorkbenchException { >+ String perspId = getWorkbenchImpl().getPerspectiveRegistry() >+ .getDefaultPerspective(); >+ return openPage(perspId, input); >+ } >+ >+ /* >+ * Removes an listener from the part service. >+ */ >+ public void removePageListener(IPageListener l) { >+ pageListeners.removePageListener(l); >+ } >+ >+ /** >+ * @see org.eclipse.ui.IPageService >+ */ >+ public void removePerspectiveListener(org.eclipse.ui.IPerspectiveListener l) { >+ perspectiveListeners.removePerspectiveListener(l); >+ } >+ >+ private IStatus unableToRestorePage(IMemento pageMem) { >+ String pageName = pageMem.getString(IWorkbenchConstants.TAG_LABEL); >+ if (pageName == null) { >+ pageName = ""; //$NON-NLS-1$ >+ } >+ return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind( >+ WorkbenchMessages.get().WorkbenchWindow_unableToRestorePerspective, >+ pageName), null); >+ } >+ >+ public IStatus restoreState(IMemento memento, >+ IPerspectiveDescriptor activeDescriptor) { >+ Assert.isNotNull(getShell()); >+ >+ final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, >+ WorkbenchMessages.get().WorkbenchWindow_problemsRestoringWindow, null); >+ >+ // Restore the window advisor state. >+ IMemento windowAdvisorState = memento >+ .getChild(IWorkbenchConstants.TAG_WORKBENCH_WINDOW_ADVISOR); >+ if (windowAdvisorState != null) { >+ result.add(getWindowAdvisor().restoreState(windowAdvisorState)); >+ } >+ >+ // Restore actionbar advisor state. >+ IMemento actionBarAdvisorState = memento >+ .getChild(IWorkbenchConstants.TAG_ACTION_BAR_ADVISOR); >+ if (actionBarAdvisorState != null) { >+ result.add(getActionBarAdvisor() >+ .restoreState(actionBarAdvisorState)); >+ } >+ >+ // Read window's bounds and state. >+ final Rectangle [] displayBounds = new Rectangle[1]; >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() { >+ displayBounds[0] = getShell().getDisplay().getBounds(); >+ >+ }}); >+ final Rectangle shellBounds = new Rectangle(0, 0, 0, 0); >+ >+ final IMemento fastViewMem = memento >+ .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >+ if (fastViewMem != null) { >+ if (fastViewBar != null) { >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() { >+ fastViewBar.restoreState(fastViewMem); >+ }}); >+ >+ } >+ } >+ Integer bigInt = memento.getInteger(IWorkbenchConstants.TAG_X); >+ shellBounds.x = bigInt == null ? 0 : bigInt.intValue(); >+ bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y); >+ shellBounds.y = bigInt == null ? 0 : bigInt.intValue(); >+ bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH); >+ shellBounds.width = bigInt == null ? 0 : bigInt.intValue(); >+ bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT); >+ shellBounds.height = bigInt == null ? 0 : bigInt.intValue(); >+ if (!shellBounds.isEmpty()) { >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() { >+ if (!shellBounds.intersects(displayBounds[0])) { >+ // RAP [bm]: Display#getClientArea >+// Rectangle clientArea = getShell().getDisplay().getClientArea(); >+ Rectangle clientArea = getShell().getDisplay().getBounds(); >+ // RAPEND: [bm] >+ >+ shellBounds.x = clientArea.x; >+ shellBounds.y = clientArea.y; >+ } >+ getShell().setBounds(shellBounds); >+ }}); >+ } >+ if ("true".equals(memento.getString(IWorkbenchConstants.TAG_MAXIMIZED))) { //$NON-NLS-1$ >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() { >+ getShell().setMaximized(true); >+ }}); >+ >+ } >+ if ("true".equals(memento.getString(IWorkbenchConstants.TAG_MINIMIZED))) { //$NON-NLS-1$ >+ // getShell().setMinimized(true); >+ } >+ >+ // restore the width of the perspective bar >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.restoreState(memento); >+ } >+ >+ // Restore the cool bar order by creating all the tool bar contribution >+ // items >+ // This needs to be done before pages are created to ensure proper >+ // canonical creation >+ // of cool items >+ final ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >+ if (coolBarMgr != null) { >+ IMemento coolBarMem = memento >+ .getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); >+ if (coolBarMem != null) { >+ // Check if the layout is locked >+ final Integer lockedInt = coolBarMem >+ .getInteger(IWorkbenchConstants.TAG_LOCKED); >+ StartupThreading.runWithoutExceptions(new StartupRunnable(){ >+ >+ public void runWithException() { >+ if ((lockedInt != null) && (lockedInt.intValue() == 1)) { >+ coolBarMgr.setLockLayout(true); >+ } else { >+ coolBarMgr.setLockLayout(false); >+ } >+ }}); >+ >+ // The new layout of the cool bar manager >+ ArrayList coolBarLayout = new ArrayList(); >+ // Traverse through all the cool item in the memento >+ IMemento contributionMems[] = coolBarMem >+ .getChildren(IWorkbenchConstants.TAG_COOLITEM); >+ for (int i = 0; i < contributionMems.length; i++) { >+ IMemento contributionMem = contributionMems[i]; >+ String type = contributionMem >+ .getString(IWorkbenchConstants.TAG_ITEM_TYPE); >+ if (type == null) { >+ // Do not recognize that type >+ continue; >+ } >+ String id = contributionMem >+ .getString(IWorkbenchConstants.TAG_ID); >+ >+ // Prevent duplicate items from being read back in. >+ IContributionItem existingItem = coolBarMgr.find(id); >+ if ((id != null) && (existingItem != null)) { >+ if (Policy.DEBUG_TOOLBAR_DISPOSAL) { >+ System.out >+ .println("Not loading duplicate cool bar item: " + id); //$NON-NLS-1$ >+ } >+ coolBarLayout.add(existingItem); >+ continue; >+ } >+ IContributionItem newItem = null; >+ if (type.equals(IWorkbenchConstants.TAG_TYPE_SEPARATOR)) { >+ if (id != null) { >+ newItem = new Separator(id); >+ } else { >+ newItem = new Separator(); >+ } >+ } else if (id != null) { >+ if (type >+ .equals(IWorkbenchConstants.TAG_TYPE_GROUPMARKER)) { >+ newItem = new GroupMarker(id); >+ >+ } else if (type >+ .equals(IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION) >+ || type >+ .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { >+ >+ // Get Width and height >+ Integer width = contributionMem >+ .getInteger(IWorkbenchConstants.TAG_ITEM_X); >+ Integer height = contributionMem >+ .getInteger(IWorkbenchConstants.TAG_ITEM_Y); >+ // Look for the object in the current cool bar >+ // manager >+ IContributionItem oldItem = coolBarMgr.find(id); >+ // If a tool bar contribution item already exists >+ // for this id then use the old object >+ if (oldItem != null) { >+ newItem = oldItem; >+ } else { >+ IActionBarPresentationFactory actionBarPresentation = getActionBarPresentationFactory(); >+ newItem = actionBarPresentation.createToolBarContributionItem( >+ actionBarPresentation.createToolBarManager(), id); >+ if (type >+ .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { >+ IToolBarContributionItem newToolBarItem = (IToolBarContributionItem) newItem; >+ if (height != null) { >+ newToolBarItem.setCurrentHeight(height >+ .intValue()); >+ } >+ if (width != null) { >+ newToolBarItem.setCurrentWidth(width >+ .intValue()); >+ } >+ newItem = new PlaceholderContributionItem( >+ newToolBarItem); >+ } >+ // make it invisible by default >+ newItem.setVisible(false); >+ // Need to add the item to the cool bar manager >+ // so that its canonical order can be preserved >+ IContributionItem refItem = findAlphabeticalOrder( >+ IWorkbenchActionConstants.MB_ADDITIONS, >+ id, coolBarMgr); >+ if (refItem != null) { >+ coolBarMgr.insertAfter(refItem.getId(), >+ newItem); >+ } else { >+ coolBarMgr.add(newItem); >+ } >+ } >+ // Set the current height and width >+ if ((width != null) >+ && (newItem instanceof IToolBarContributionItem)) { >+ ((IToolBarContributionItem) newItem) >+ .setCurrentWidth(width.intValue()); >+ } >+ if ((height != null) >+ && (newItem instanceof IToolBarContributionItem)) { >+ ((IToolBarContributionItem) newItem) >+ .setCurrentHeight(height.intValue()); >+ } >+ } >+ } >+ // Add new item into cool bar manager >+ if (newItem != null) { >+ coolBarLayout.add(newItem); >+ newItem.setParent(coolBarMgr); >+ coolBarMgr.markDirty(); >+ } >+ } >+ >+ // We need to check if we have everything we need in the layout. >+ final ArrayList finalLayout = new ArrayList(); >+ IContributionItem[] existingItems = coolBarMgr.getItems(); >+ for (int i = 0; i < existingItems.length; i++) { >+ IContributionItem existingItem = existingItems[i]; >+ >+ /* >+ * This line shouldn't be necessary, but is here for >+ * robustness. >+ */ >+ if (existingItem == null) { >+ continue; >+ } >+ >+ boolean found = false; >+ Iterator layoutItemItr = coolBarLayout.iterator(); >+ while (layoutItemItr.hasNext()) { >+ IContributionItem layoutItem = (IContributionItem) layoutItemItr >+ .next(); >+ if ((layoutItem != null) >+ && (layoutItem.equals(existingItem))) { >+ found = true; >+ break; >+ } >+ } >+ >+ if (!found) { >+ if (existingItem != null) { >+ finalLayout.add(existingItem); >+ } >+ } >+ } >+ >+ // Set the cool bar layout to the given layout. >+ finalLayout.addAll(coolBarLayout); >+ final IContributionItem[] itemsToSet = new IContributionItem[finalLayout >+ .size()]; >+ finalLayout.toArray(itemsToSet); >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() { >+ coolBarMgr.setItems(itemsToSet); >+ }}); >+ >+ } else { >+ // For older workbenchs >+ coolBarMem = memento >+ .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT); >+ if (coolBarMem != null) { >+ // Restore an older layout >+ restoreOldCoolBar(coolBarMem); >+ } >+ } >+ } >+ >+ // Recreate each page in the window. >+ IWorkbenchPage newActivePage = null; >+ IMemento[] pageArray = memento >+ .getChildren(IWorkbenchConstants.TAG_PAGE); >+ for (int i = 0; i < pageArray.length; i++) { >+ final IMemento pageMem = pageArray[i]; >+ String strFocus = pageMem.getString(IWorkbenchConstants.TAG_FOCUS); >+ if (strFocus == null || strFocus.length() == 0) { >+ continue; >+ } >+ >+ // Get the input factory. >+ final IAdaptable [] input = new IAdaptable[1]; >+ final IMemento inputMem = pageMem.getChild(IWorkbenchConstants.TAG_INPUT); >+ if (inputMem != null) { >+ final String factoryID = inputMem >+ .getString(IWorkbenchConstants.TAG_FACTORY_ID); >+ if (factoryID == null) { >+ WorkbenchPlugin >+ .log("Unable to restore page - no input factory ID."); //$NON-NLS-1$ >+ result.add(unableToRestorePage(pageMem)); >+ continue; >+ } >+ try { >+ UIStats.start(UIStats.RESTORE_WORKBENCH, >+ "WorkbenchPageFactory"); //$NON-NLS-1$ >+ StartupThreading >+ .runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ IElementFactory factory = PlatformUI >+ .getWorkbench().getElementFactory( >+ factoryID); >+ if (factory == null) { >+ WorkbenchPlugin >+ .log("Unable to restore page - cannot instantiate input factory: " + factoryID); //$NON-NLS-1$ >+ result >+ .add(unableToRestorePage(pageMem)); >+ return; >+ } >+ >+ // Get the input element. >+ input[0] = factory.createElement(inputMem); >+ } >+ }); >+ >+ if (input[0] == null) { >+ WorkbenchPlugin >+ .log("Unable to restore page - cannot instantiate input element: " + factoryID); //$NON-NLS-1$ >+ result.add(unableToRestorePage(pageMem)); >+ continue; >+ } >+ } finally { >+ UIStats.end(UIStats.RESTORE_WORKBENCH, factoryID, >+ "WorkbenchPageFactory"); //$NON-NLS-1$ >+ } >+ } >+ // Open the perspective. >+ final IAdaptable finalInput = input[0]; >+ final WorkbenchPage [] newPage = new WorkbenchPage[1]; >+ try { >+ StartupThreading.runWithWorkbenchExceptions(new StartupRunnable(){ >+ >+ public void runWithException() throws WorkbenchException { >+ newPage[0] = ((WorkbenchImplementation) Tweaklets >+ .get(WorkbenchImplementation.KEY)).createWorkbenchPage(WorkbenchWindow.this, finalInput); >+ }}); >+ >+ result.add(newPage[0].restoreState(pageMem, activeDescriptor)); >+ pageList.add(newPage[0]); >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ firePageOpened(newPage[0]); >+ }}); >+ >+ } catch (WorkbenchException e) { >+ WorkbenchPlugin >+ .log( >+ "Unable to restore perspective - constructor failed.", e); //$NON-NLS-1$ >+ result.add(e.getStatus()); >+ continue; >+ } >+ >+ if (strFocus != null && strFocus.length() > 0) { >+ newActivePage = newPage[0]; >+ } >+ } >+ >+ // If there are no pages create a default. >+ if (pageList.isEmpty()) { >+ try { >+ final String defPerspID = getWorkbenchImpl().getPerspectiveRegistry() >+ .getDefaultPerspective(); >+ if (defPerspID != null) { >+ final WorkbenchPage [] newPage = new WorkbenchPage[1]; >+ StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ newPage[0] = ((WorkbenchImplementation) Tweaklets >+ .get(WorkbenchImplementation.KEY)).createWorkbenchPage(WorkbenchWindow.this, defPerspID, >+ getDefaultPageInput()); >+ }}); >+ >+ pageList.add(newPage[0]); >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ firePageOpened(newPage[0]); >+ }}); >+ } >+ } catch (WorkbenchException e) { >+ WorkbenchPlugin >+ .log( >+ "Unable to create default perspective - constructor failed.", e); //$NON-NLS-1$ >+ result.add(e.getStatus()); >+ String productName = WorkbenchPlugin.getDefault() >+ .getProductName(); >+ if (productName == null) { >+ productName = ""; //$NON-NLS-1$ >+ } >+ getShell().setText(productName); >+ } >+ } >+ >+ // Set active page. >+ if (newActivePage == null) { >+ newActivePage = pageList.getNextActive(); >+ } >+ final IWorkbenchPage myPage = newActivePage; >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ setActivePage(myPage); >+ }}); >+ >+ >+// RAP [rh] Intro mechanism not supported >+// final IMemento introMem = memento.getChild(IWorkbenchConstants.TAG_INTRO); >+// if (introMem != null) { >+// StartupThreading.runWithoutExceptions(new StartupRunnable() { >+// >+// public void runWithException() throws Throwable { >+// getWorkbench() >+// .getIntroManager() >+// .showIntro( >+// WorkbenchWindow.this, >+// Boolean >+// .valueOf( >+// introMem >+// .getString(IWorkbenchConstants.TAG_STANDBY)) >+// .booleanValue()); >+// } >+// }); >+// >+// } >+ >+ // Only restore the trim state if we're using the default layout >+ if (defaultLayout != null) { >+ // Restore the trim state. We pass in the 'root' >+ // memento since we have to check for pre-3.2 >+ // state. >+ result.add(restoreTrimState(memento)); >+ } >+ >+ return result; >+ } >+ >+ /** >+ * Restores cool item order from an old workbench. >+ */ >+ private boolean restoreOldCoolBar(IMemento coolbarMem) { >+ // Make sure the tag exist >+ if (coolbarMem == null) { >+ return false; >+ } >+ ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >+ // Check to see if layout is locked >+ Integer locked = coolbarMem.getInteger(IWorkbenchConstants.TAG_LOCKED); >+ boolean state = (locked != null) && (locked.intValue() == 1); >+ coolBarMgr.setLockLayout(state); >+ >+ // Get the visual layout >+ IMemento visibleLayout = coolbarMem >+ .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT); >+ ArrayList visibleWrapIndicies = new ArrayList(); >+ ArrayList visibleItems = new ArrayList(); >+ if (visibleLayout != null) { >+ if (readLayout(visibleLayout, visibleItems, visibleWrapIndicies) == false) { >+ return false; >+ } >+ } >+ // Get the remembered layout >+ IMemento rememberedLayout = coolbarMem >+ .getChild(IWorkbenchConstants.TAG_LAYOUT); >+ ArrayList rememberedWrapIndicies = new ArrayList(); >+ ArrayList rememberedItems = new ArrayList(); >+ if (rememberedLayout != null) { >+ if (readLayout(rememberedLayout, rememberedItems, >+ rememberedWrapIndicies) == false) { >+ return false; >+ } >+ } >+ >+ // Create the objects >+ if (visibleItems != null) { >+ // Merge remembered layout into visible layout >+ if (rememberedItems != null) { >+ // Traverse through all the remembered items >+ int currentIndex = 0; >+ for (Iterator i = rememberedItems.iterator(); i.hasNext(); currentIndex++) { >+ String id = (String) i.next(); >+ int index = -1; >+ for (Iterator iter = visibleItems.iterator(); iter >+ .hasNext();) { >+ String visibleId = (String) iter.next(); >+ if (visibleId.equals(id)) { >+ index = visibleItems.indexOf(visibleId); >+ break; >+ } >+ } >+ // The item is not in the visible list >+ if (index == -1) { >+ int insertAt = Math.max(0, Math.min(currentIndex, >+ visibleItems.size())); >+ boolean separateLine = false; >+ // Check whether this item is on a separate line >+ for (Iterator iter = rememberedWrapIndicies.iterator(); iter >+ .hasNext();) { >+ Integer wrapIndex = (Integer) iter.next(); >+ if (wrapIndex.intValue() <= insertAt) { >+ insertAt = visibleItems.size(); >+ // Add new wrap index for this Item >+ visibleWrapIndicies.add(new Integer(insertAt)); >+ separateLine = true; >+ } >+ } >+ // Add item to array list >+ visibleItems.add(insertAt, id); >+ // If the item was not on a separate line then adjust >+ // the visible wrap indicies >+ if (!separateLine) { >+ // Adjust visible wrap indicies >+ for (int j = 0; j < visibleWrapIndicies.size(); j++) { >+ Integer index2 = (Integer) visibleWrapIndicies >+ .get(j); >+ if (index2.intValue() >= insertAt) { >+ visibleWrapIndicies.set(j, new Integer( >+ index2.intValue() + 1)); >+ } >+ } >+ } >+ } >+ } >+ } >+ // The new layout of the cool bar manager >+ ArrayList coolBarLayout = new ArrayList(visibleItems.size()); >+ // Add all visible items to the layout object >+ for (Iterator i = visibleItems.iterator(); i.hasNext();) { >+ String id = (String) i.next(); >+ // Look for the object in the current cool bar manager >+ IContributionItem oldItem = null; >+ IContributionItem newItem = null; >+ if (id != null) { >+ oldItem = coolBarMgr.find(id); >+ } >+ // If a tool bar contribution item already exists for this id >+ // then use the old object >+ if (oldItem instanceof IToolBarContributionItem) { >+ newItem = oldItem; >+ } else { >+ IActionBarPresentationFactory actionBarPresentaiton = getActionBarPresentationFactory(); >+ newItem = actionBarPresentaiton.createToolBarContributionItem( >+ actionBarPresentaiton.createToolBarManager(), id); >+ // make it invisible by default >+ newItem.setVisible(false); >+ // Need to add the item to the cool bar manager so that its >+ // canonical order can be preserved >+ IContributionItem refItem = findAlphabeticalOrder( >+ IWorkbenchActionConstants.MB_ADDITIONS, id, >+ coolBarMgr); >+ if (refItem != null) { >+ coolBarMgr.insertAfter(refItem.getId(), newItem); >+ } else { >+ coolBarMgr.add(newItem); >+ } >+ } >+ // Add new item into cool bar manager >+ if (newItem != null) { >+ coolBarLayout.add(newItem); >+ newItem.setParent(coolBarMgr); >+ coolBarMgr.markDirty(); >+ } >+ } >+ >+ // Add separators to the displayed Items data structure >+ int offset = 0; >+ for (int i = 1; i < visibleWrapIndicies.size(); i++) { >+ int insertAt = ((Integer) visibleWrapIndicies.get(i)) >+ .intValue() >+ + offset; >+ coolBarLayout.add(insertAt, new Separator( >+ CoolBarManager.USER_SEPARATOR)); >+ offset++; >+ } >+ >+ // Add any group markers in their appropriate places >+ IContributionItem[] items = coolBarMgr.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ IContributionItem item = items[i]; >+ if (item.isGroupMarker()) { >+ coolBarLayout.add(Math.max(Math >+ .min(i, coolBarLayout.size()), 0), item); >+ } >+ } >+ IContributionItem[] itemsToSet = new IContributionItem[coolBarLayout >+ .size()]; >+ coolBarLayout.toArray(itemsToSet); >+ coolBarMgr.setItems(itemsToSet); >+ } >+ return true; >+ } >+ >+ /** >+ * Helper method used for restoring an old cool bar layout. This method >+ * reads the memento and populatates the item id's and wrap indicies. >+ */ >+ private boolean readLayout(IMemento memento, ArrayList itemIds, >+ ArrayList wrapIndicies) { >+ // Get the Wrap indicies >+ IMemento[] wraps = memento >+ .getChildren(IWorkbenchConstants.TAG_ITEM_WRAP_INDEX); >+ if (wraps == null) { >+ return false; >+ } >+ for (int i = 0; i < wraps.length; i++) { >+ IMemento wrapMem = wraps[i]; >+ Integer index = wrapMem.getInteger(IWorkbenchConstants.TAG_INDEX); >+ if (index == null) { >+ return false; >+ } >+ wrapIndicies.add(index); >+ } >+ // Get the Item ids >+ IMemento[] savedItems = memento >+ .getChildren(IWorkbenchConstants.TAG_ITEM); >+ if (savedItems == null) { >+ return false; >+ } >+ for (int i = 0; i < savedItems.length; i++) { >+ IMemento savedMem = savedItems[i]; >+ String id = savedMem.getString(IWorkbenchConstants.TAG_ID); >+ if (id == null) { >+ return false; >+ } >+ itemIds.add(id); >+ } >+ return true; >+ } >+ >+ /** >+ * Returns the contribution item that the given contribution item should be >+ * inserted after. >+ * >+ * @param startId >+ * the location to start looking alphabetically. >+ * @param itemId >+ * the target item id. >+ * @param mgr >+ * the contribution manager. >+ * @return the contribution item that the given items should be returned >+ * after. >+ */ >+ private IContributionItem findAlphabeticalOrder(String startId, >+ String itemId, IContributionManager mgr) { >+ IContributionItem[] items = mgr.getItems(); >+ int insertIndex = 0; >+ >+ // look for starting point >+ while (insertIndex < items.length) { >+ IContributionItem item = items[insertIndex]; >+ if (item.getId() != null && item.getId().equals(startId)) { >+ break; >+ } >+ ++insertIndex; >+ } >+ >+ // Find the index that this item should be inserted in >+ for (int i = insertIndex + 1; i < items.length; i++) { >+ IContributionItem item = items[i]; >+ String testId = item.getId(); >+ >+ if (item.isGroupMarker()) { >+ break; >+ } >+ >+ if (itemId != null && testId != null) { >+ if (itemId.compareTo(testId) < 1) { >+ break; >+ } >+ } >+ insertIndex = i; >+ } >+ if (insertIndex >= items.length) { >+ return null; >+ } >+ return items[insertIndex]; >+ } >+ >+ /* >+ * (non-Javadoc) Method declared on IRunnableContext. >+ */ >+ public void run(boolean fork, boolean cancelable, >+ IRunnableWithProgress runnable) throws InvocationTargetException, >+ InterruptedException { >+ >+ // RAP [bm]: >+// IWorkbenchContextSupport contextSupport = getWorkbench() >+// .getContextSupport(); >+// final boolean keyFilterEnabled = contextSupport.isKeyFilterEnabled(); >+ >+ Control fastViewBarControl = getFastViewBar() == null ? null >+ : getFastViewBar().getControl(); >+ boolean fastViewBarWasEnabled = fastViewBarControl == null ? false >+ : fastViewBarControl.getEnabled(); >+ >+ Control perspectiveBarControl = getPerspectiveBar() == null ? null >+ : getPerspectiveBar().getControl(); >+ boolean perspectiveBarWasEnabled = perspectiveBarControl == null ? false >+ : perspectiveBarControl.getEnabled(); >+ >+ // Cache for any diabled trim controls >+ List disabledControls = null; >+ >+ try { >+ if (fastViewBarControl != null && !fastViewBarControl.isDisposed()) { >+ fastViewBarControl.setEnabled(false); >+ } >+ >+ if (perspectiveBarControl != null >+ && !perspectiveBarControl.isDisposed()) { >+ perspectiveBarControl.setEnabled(false); >+ } >+ >+ // RAP [bm]: >+// if (keyFilterEnabled) { >+// contextSupport.setKeyFilterEnabled(false); >+// } >+ // RAPEND: [bm] >+ >+ // Disable all trim -except- the StatusLine >+ if (defaultLayout != null) >+ disabledControls = defaultLayout.disableTrim(getStatusLineTrim()); >+ >+ super.run(fork, cancelable, runnable); >+ } finally { >+ if (fastViewBarControl != null && !fastViewBarControl.isDisposed()) { >+ fastViewBarControl.setEnabled(fastViewBarWasEnabled); >+ } >+ >+ if (perspectiveBarControl != null >+ && !perspectiveBarControl.isDisposed()) { >+ perspectiveBarControl.setEnabled(perspectiveBarWasEnabled); >+ } >+ >+ // RAP [bm]: >+// if (keyFilterEnabled) { >+// contextSupport.setKeyFilterEnabled(true); >+// } >+ // RAPEND: [bm] >+ >+ // Re-enable any disabled trim >+ if (defaultLayout != null && disabledControls != null) >+ defaultLayout.enableTrim(disabledControls); >+ } >+ } >+ >+ /** >+ * Save all of the pages. Returns true if the operation succeeded. >+ */ >+ private boolean saveAllPages(boolean bConfirm) { >+ boolean bRet = true; >+ Iterator itr = pageList.iterator(); >+ while (bRet && itr.hasNext()) { >+ WorkbenchPage page = (WorkbenchPage) itr.next(); >+ bRet = page.saveAllEditors(bConfirm); >+ } >+ return bRet; >+ } >+ >+ /** >+ * @see IPersistable >+ */ >+ public IStatus saveState(IMemento memento) { >+ >+ MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, >+ WorkbenchMessages.get().WorkbenchWindow_problemsSavingWindow, null); >+ >+ // Save the window's state and bounds. >+ if (getShell().getMaximized() || asMaximizedState) { >+ memento.putString(IWorkbenchConstants.TAG_MAXIMIZED, "true"); //$NON-NLS-1$ >+ } >+ if (getShell().getMinimized()) { >+ memento.putString(IWorkbenchConstants.TAG_MINIMIZED, "true"); //$NON-NLS-1$ >+ } >+ if (normalBounds == null) { >+ normalBounds = getShell().getBounds(); >+ } >+ IMemento fastViewBarMem = memento >+ .createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >+ if (fastViewBar != null) { >+ fastViewBar.saveState(fastViewBarMem); >+ } >+ >+ memento.putInteger(IWorkbenchConstants.TAG_X, normalBounds.x); >+ memento.putInteger(IWorkbenchConstants.TAG_Y, normalBounds.y); >+ memento.putInteger(IWorkbenchConstants.TAG_WIDTH, normalBounds.width); >+ memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, normalBounds.height); >+ >+// RAP [rh] Intro mechanism not supported >+// IWorkbenchPage activePage = getActivePage(); >+// if (activePage != null >+// && activePage.findView(IIntroConstants.INTRO_VIEW_ID) != null) { >+// IMemento introMem = memento >+// .createChild(IWorkbenchConstants.TAG_INTRO); >+// boolean isStandby = getWorkbench() >+// .getIntroManager() >+// .isIntroStandby(getWorkbench().getIntroManager().getIntro()); >+// introMem.putString(IWorkbenchConstants.TAG_STANDBY, String >+// .valueOf(isStandby)); >+// } >+ >+ // save the width of the perspective bar >+ IMemento persBarMem = memento >+ .createChild(IWorkbenchConstants.TAG_PERSPECTIVE_BAR); >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.saveState(persBarMem); >+ } >+ >+ // / Save the order of the cool bar contribution items >+ ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); >+ if (coolBarMgr != null) { >+ coolBarMgr.refresh(); >+ IMemento coolBarMem = memento >+ .createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); >+ if (coolBarMgr.getLockLayout() == true) { >+ coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1); >+ } else { >+ coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0); >+ } >+ IContributionItem[] items = coolBarMgr.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ IMemento coolItemMem = coolBarMem >+ .createChild(IWorkbenchConstants.TAG_COOLITEM); >+ IContributionItem item = items[i]; >+ // The id of the contribution item >+ if (item.getId() != null) { >+ coolItemMem.putString(IWorkbenchConstants.TAG_ID, item >+ .getId()); >+ } >+ // Write out type and size if applicable >+ if (item.isSeparator()) { >+ coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, >+ IWorkbenchConstants.TAG_TYPE_SEPARATOR); >+ } else if (item.isGroupMarker() && !item.isSeparator()) { >+ coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, >+ IWorkbenchConstants.TAG_TYPE_GROUPMARKER); >+ } else { >+ if (item instanceof PlaceholderContributionItem) { >+ coolItemMem.putString( >+ IWorkbenchConstants.TAG_ITEM_TYPE, >+ IWorkbenchConstants.TAG_TYPE_PLACEHOLDER); >+ } else { >+ // Store the identifier. >+ coolItemMem >+ .putString( >+ IWorkbenchConstants.TAG_ITEM_TYPE, >+ IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION); >+ } >+ >+ /* >+ * Retrieve a reasonable approximation of the height and >+ * width, if possible. >+ */ >+ final int height; >+ final int width; >+ if (item instanceof IToolBarContributionItem) { >+ IToolBarContributionItem toolBarItem = (IToolBarContributionItem) item; >+ toolBarItem.saveWidgetState(); >+ height = toolBarItem.getCurrentHeight(); >+ width = toolBarItem.getCurrentWidth(); >+ } else if (item instanceof PlaceholderContributionItem) { >+ PlaceholderContributionItem placeholder = (PlaceholderContributionItem) item; >+ height = placeholder.getHeight(); >+ width = placeholder.getWidth(); >+ } else { >+ height = -1; >+ width = -1; >+ } >+ >+ // Store the height and width. >+ coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_X, >+ width); >+ coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_Y, >+ height); >+ } >+ } >+ } >+ >+ // Save each page. >+ Iterator itr = pageList.iterator(); >+ while (itr.hasNext()) { >+ WorkbenchPage page = (WorkbenchPage) itr.next(); >+ >+ // Save perspective. >+ IMemento pageMem = memento >+ .createChild(IWorkbenchConstants.TAG_PAGE); >+ pageMem.putString(IWorkbenchConstants.TAG_LABEL, page.getLabel()); >+ result.add(page.saveState(pageMem)); >+ >+ if (page == getActiveWorkbenchPage()) { >+ pageMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$ >+ } >+ >+ // Get the input. >+ IAdaptable input = page.getInput(); >+ if (input != null) { >+ IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input, >+ IPersistableElement.class); >+ if (persistable == null) { >+ WorkbenchPlugin >+ .log("Unable to save page input: " //$NON-NLS-1$ >+ + input >+ + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$ >+ } else { >+ // Save input. >+ IMemento inputMem = pageMem >+ .createChild(IWorkbenchConstants.TAG_INPUT); >+ inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID, >+ persistable.getFactoryId()); >+ persistable.saveState(inputMem); >+ } >+ } >+ } >+ >+ // Save window advisor state. >+ IMemento windowAdvisorState = memento >+ .createChild(IWorkbenchConstants.TAG_WORKBENCH_WINDOW_ADVISOR); >+ result.add(getWindowAdvisor().saveState(windowAdvisorState)); >+ >+ // Save actionbar advisor state. >+ IMemento actionBarAdvisorState = memento >+ .createChild(IWorkbenchConstants.TAG_ACTION_BAR_ADVISOR); >+ result.add(getActionBarAdvisor().saveState(actionBarAdvisorState)); >+ >+ // Only save the trim state if we're using the default layout >+ if (defaultLayout != null) { >+ IMemento trimState = memento.createChild(IWorkbenchConstants.TAG_TRIM); >+ result.add(saveTrimState(trimState)); >+ } >+ >+ return result; >+ } >+ >+ /** >+ * Save the trim layout trim area and trim ordering. >+ * >+ * @param memento >+ * the memento to update >+ * @return the status, OK or not.. >+ */ >+ private IStatus saveTrimState(IMemento memento) { >+ int[] ids = defaultLayout.getAreaIds(); >+ for (int i = 0; i < ids.length; i++) { >+ int id = ids[i]; >+ List trim = defaultLayout.getAreaTrim(id); >+ if (!trim.isEmpty()) { >+ IMemento area = memento >+ .createChild(IWorkbenchConstants.TAG_TRIM_AREA, Integer >+ .toString(id)); >+ Iterator d = trim.iterator(); >+ while (d.hasNext()) { >+ IWindowTrim item = (IWindowTrim) d.next(); >+ area.createChild(IWorkbenchConstants.TAG_TRIM_ITEM, item >+ .getId()); >+ } >+ } >+ } >+ return Status.OK_STATUS; >+ } >+ >+ /** >+ * Restore the trim layout state from the memento. >+ * >+ * @param memento >+ * the 'root' Workbench memento to restore >+ * @return the status, OK or not >+ */ >+ private IStatus restoreTrimState(IMemento memento) { >+ // Determine if we have saved state. If we don't have any 3.2 >+ // type state we're not done because the FastViewBar maintained >+ // its own 'side' state in 3.1 so we'll honor its value >+ IMemento trimState = memento.getChild(IWorkbenchConstants.TAG_TRIM); >+ if (trimState != null) { >+ // first pass sets up ordering for all trim areas >+ IMemento[] areas = trimState >+ .getChildren(IWorkbenchConstants.TAG_TRIM_AREA); >+ >+ // We need to remember all the trim that was repositioned >+ // here so we can re-site -newly contributed- trim after >+ // we're done >+ final List knownIds = new ArrayList(); >+ >+ List[] trimOrder = new List[areas.length]; >+ for (int i = 0; i < areas.length; i++) { >+ trimOrder[i] = new ArrayList(); >+ List preferredLocations = new ArrayList(); >+ IMemento area = areas[i]; >+ IMemento[] items = area >+ .getChildren(IWorkbenchConstants.TAG_TRIM_ITEM); >+ for (int j = 0; j < items.length; j++) { >+ IMemento item = items[j]; >+ String id = item.getID(); >+ knownIds.add(id); >+ preferredLocations.add(id); >+ >+ IWindowTrim t = defaultLayout.getTrim(id); >+ if (t != null) { >+ trimOrder[i].add(t); >+ } >+ } >+ >+ // Inform the TrimLayout of the preferred location for this area >+ String areaIdString = areas[i].getID(); >+ int areaId = Integer.parseInt(areaIdString); >+ defaultLayout.setPreferredLocations(areaId, preferredLocations); >+ } >+ >+ // second pass applies all of the window trim >+ for (int i = 0; i < areas.length; i++) { >+ IMemento area = areas[i]; >+ final int id = Integer.parseInt(area.getID()); >+ final List myTrimOrderList = trimOrder[i]; >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ defaultLayout.updateAreaTrim(id, myTrimOrderList, false); >+ }}); >+ >+ } >+ >+ // get the trim manager to re-locate any -newly contributed- >+ // trim widgets >+ // Legacy (3.2) trim >+ if (trimMgr2 != null) { >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ trimMgr2.updateLocations(knownIds); >+ }}); >+ >+ } >+ >+ // 3.3 Trim Contributions >+ if (trimContributionMgr != null) { >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ public void runWithException() throws Throwable { >+ trimContributionMgr.updateLocations(knownIds); >+ >+ // Update the GUI with the new locations >+ WorkbenchPage page = getActiveWorkbenchPage(); >+ if (page != null) { >+ Perspective perspective = page.getActivePerspective(); >+ if (perspective != null) { >+ // Ensure that only the upper/right editor stack has >+ // min/max buttons >+ page.getEditorPresentation().updateStackButtons(); >+ >+ // The perspective's onActivate manipulates the trim under the >+ // new min/max story so cause it to refresh... >+ perspective.onActivate(); >+ } >+ } >+ }}); >+ } >+ } >+ else { >+ // No 3.2 state...check if the FVB has state >+ IMemento fastViewMem = memento >+ .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >+ if (fastViewMem != null) { >+ if (fastViewBar != null) { >+ final Integer bigInt = fastViewMem.getInteger(IWorkbenchConstants.TAG_FAST_VIEW_SIDE); >+ if (bigInt != null) { >+ StartupThreading.runWithoutExceptions(new StartupRunnable() { >+ >+ public void runWithException() throws Throwable { >+ fastViewBar.dock(bigInt.intValue()); >+ getTrimManager().addTrim(bigInt.intValue(), fastViewBar); >+ }}); >+ >+ } >+ } >+ } >+ } >+ >+ return Status.OK_STATUS; >+ } >+ >+ /** >+ * Sets the active page within the window. >+ * >+ * @param in >+ * identifies the new active page, or <code>null</code> for no >+ * active page >+ */ >+ public void setActivePage(final IWorkbenchPage in) { >+ if (getActiveWorkbenchPage() == in) { >+ return; >+ } >+ >+ // 1FVGTNR: ITPUI:WINNT - busy cursor for switching perspectives >+ BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { >+ public void run() { >+ // Deactivate old persp. >+ WorkbenchPage currentPage = getActiveWorkbenchPage(); >+ if (currentPage != null) { >+ currentPage.onDeactivate(); >+ } >+ >+ // Activate new persp. >+ if (in == null || pageList.contains(in)) { >+ pageList.setActive(in); >+ } >+ WorkbenchPage newPage = pageList.getActive(); >+ Composite parent = getPageComposite(); >+ StackLayout layout = (StackLayout) parent.getLayout(); >+ if (newPage != null) { >+ layout.topControl = newPage.getClientComposite(); >+ parent.layout(); >+ hideEmptyWindowContents(); >+ newPage.onActivate(); >+ firePageActivated(newPage); >+ if (newPage.getPerspective() != null) { >+ firePerspectiveActivated(newPage, newPage >+ .getPerspective()); >+ } >+ } else { >+ layout.topControl = null; >+ parent.layout(); >+ } >+ >+ updateFastViewBar(); >+ >+ if (isClosing()) { >+ return; >+ } >+ >+ updateDisabled = false; >+ >+ // Update action bars ( implicitly calls updateActionBars() ) >+ updateActionSets(); >+ submitGlobalActions(); >+ >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.update(false); >+ } >+ >+ getMenuManager().update(IAction.TEXT); >+ } >+ }); >+ } >+ >+ /** >+ * Returns whether or not children exist for the Window's toolbar control. >+ * Overridden for coolbar support. >+ * <p> >+ * >+ * @return boolean true if children exist, false otherwise >+ */ >+ protected boolean toolBarChildrenExist() { >+ CoolBar coolBarControl = (CoolBar) getCoolBarControl(); >+ return coolBarControl.getItemCount() > 0; >+ } >+ >+ /** >+ * Hooks a listener to track the activation and deactivation of the window's >+ * shell. Notifies the active part and editor of the change >+ */ >+ private void trackShellActivation(Shell shell) { >+ shell.addShellListener(new ShellAdapter() { >+ public void shellActivated(ShellEvent event) { >+ shellActivated = true; >+ serviceLocator.activate(); >+ getWorkbenchImpl().setActivatedWindow(WorkbenchWindow.this); >+ WorkbenchPage currentPage = getActiveWorkbenchPage(); >+ if (currentPage != null) { >+ IWorkbenchPart part = currentPage.getActivePart(); >+ if (part != null) { >+ PartSite site = (PartSite) part.getSite(); >+ site.getPane().shellActivated(); >+ } >+ IEditorPart editor = currentPage.getActiveEditor(); >+ if (editor != null) { >+ PartSite site = (PartSite) editor.getSite(); >+ site.getPane().shellActivated(); >+ } >+ getWorkbenchImpl() >+ .fireWindowActivated(WorkbenchWindow.this); >+ } >+ } >+ >+ public void shellDeactivated(ShellEvent event) { >+ shellActivated = false; >+ serviceLocator.deactivate(); >+ WorkbenchPage currentPage = getActiveWorkbenchPage(); >+ if (currentPage != null) { >+ IWorkbenchPart part = currentPage.getActivePart(); >+ if (part != null) { >+ PartSite site = (PartSite) part.getSite(); >+ site.getPane().shellDeactivated(); >+ } >+ IEditorPart editor = currentPage.getActiveEditor(); >+ if (editor != null) { >+ PartSite site = (PartSite) editor.getSite(); >+ site.getPane().shellDeactivated(); >+ } >+ getWorkbenchImpl().fireWindowDeactivated( >+ WorkbenchWindow.this); >+ } >+ } >+ }); >+ } >+ >+ /** >+ * Hooks a listener to track the resize of the window's shell. Stores the >+ * new bounds if in normal state - that is, not in minimized or maximized >+ * state) >+ */ >+ private void trackShellResize(Shell newShell) { >+ newShell.addControlListener(new ControlAdapter() { >+ public void controlMoved(ControlEvent e) { >+ saveBounds(); >+ } >+ >+ public void controlResized(ControlEvent e) { >+ saveBounds(); >+ } >+ >+ private void saveBounds() { >+ Shell shell = getShell(); >+ if (shell == null) { >+ return; >+ } >+ if (shell.isDisposed()) { >+ return; >+ } >+ if (shell.getMinimized()) { >+ return; >+ } >+ if (shell.getMaximized()) { >+ asMaximizedState = true; >+ return; >+ } >+ asMaximizedState = false; >+ normalBounds = shell.getBounds(); >+ } >+ }); >+ } >+ >+ /** >+ * update the action bars. >+ */ >+ public void updateActionBars() { >+ if (updateDisabled || updatesDeferred()) { >+ return; >+ } >+ // updateAll required in order to enable accelerators on pull-down menus >+ getMenuBarManager().update(false); >+ >+ // RAP [bm]: Composite#setLayoutDeferred >+// try { >+// getShell().setLayoutDeferred(true); >+// getCoolBarManager2().update(false); >+// } finally { >+// getShell().setLayoutDeferred(false); >+// } >+ getCoolBarManager2().update(false); >+ // RAPEND: [bm] >+ >+ getStatusLineManager().update(false); >+ } >+ >+ /** >+ * Returns true iff we are currently deferring UI processing due to a large >+ * update >+ * >+ * @return true iff we are deferring UI updates. >+ */ >+ private boolean updatesDeferred() { >+ return largeUpdates > 0; >+ } >+ >+ /** >+ * <p> >+ * Indicates the start of a large update within this window. This is used to >+ * disable CPU-intensive, change-sensitive services that were temporarily >+ * disabled in the midst of large changes. This method should always be >+ * called in tandem with <code>largeUpdateEnd</code>, and the event loop >+ * should not be allowed to spin before that method is called. >+ * </p> >+ * <p> >+ * Important: always use with <code>largeUpdateEnd</code>! >+ * </p> >+ */ >+ public final void largeUpdateStart() { >+ largeUpdates++; >+ } >+ >+ /** >+ * <p> >+ * Indicates the end of a large update within this window. This is used to >+ * re-enable services that were temporarily disabled in the midst of large >+ * changes. This method should always be called in tandem with >+ * <code>largeUpdateStart</code>, and the event loop should not be >+ * allowed to spin before this method is called. >+ * </p> >+ * <p> >+ * Important: always protect this call by using <code>finally</code>! >+ * </p> >+ */ >+ public final void largeUpdateEnd() { >+ if (--largeUpdates == 0) { >+ updateActionBars(); >+ } >+ } >+ >+ /** >+ * Update the visible action sets. This method is typically called from a >+ * page when the user changes the visible action sets within the >+ * prespective. >+ */ >+ public void updateActionSets() { >+ if (updateDisabled) { >+ return; >+ } >+ >+ WorkbenchPage currentPage = getActiveWorkbenchPage(); >+ if (currentPage == null) { >+ getActionPresentation().clearActionSets(); >+ } else { >+ ICoolBarManager2 coolBarManager = (ICoolBarManager2) getCoolBarManager2(); >+ if (coolBarManager != null) { >+ coolBarManager.refresh(); >+ } >+ getActionPresentation().setActionSets( >+ currentPage.getActionSets()); >+ } >+ fireActionSetsChanged(); >+ updateActionBars(); >+ >+ // hide the launch menu if it is empty >+ String path = IWorkbenchActionConstants.M_WINDOW >+ + IWorkbenchActionConstants.SEP >+ + IWorkbenchActionConstants.M_LAUNCH; >+ IMenuManager manager = getMenuBarManager().findMenuUsingPath(path); >+ IContributionItem item = getMenuBarManager().findUsingPath(path); >+ >+ if (manager == null || item == null) { >+ return; >+ } >+ item.setVisible(manager.getItems().length >= 2); >+ // there is a separator for the additions group thus >= 2 >+ } >+ >+ private ListenerList actionSetListeners = null; >+ >+ private ListenerList backgroundSaveListeners = new ListenerList(ListenerList.IDENTITY); >+ >+ private final void fireActionSetsChanged() { >+ if (actionSetListeners != null) { >+ final Object[] listeners = actionSetListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ final IActionSetsListener listener = (IActionSetsListener) listeners[i]; >+ final WorkbenchPage currentPage = getActiveWorkbenchPage(); >+ final IActionSetDescriptor[] newActionSets; >+ if (currentPage == null) { >+ newActionSets = null; >+ } else { >+ newActionSets = currentPage.getActionSets(); >+ } >+ final ActionSetsEvent event = new ActionSetsEvent(newActionSets); >+ listener.actionSetsChanged(event); >+ } >+ } >+ } >+ >+ final void addActionSetsListener(final IActionSetsListener listener) { >+ if (actionSetListeners == null) { >+ actionSetListeners = new ListenerList(); >+ } >+ >+ actionSetListeners.add(listener); >+ } >+ >+ final void removeActionSetsListener(final IActionSetsListener listener) { >+ if (actionSetListeners != null) { >+ actionSetListeners.remove(listener); >+ if (actionSetListeners.isEmpty()) { >+ actionSetListeners = null; >+ } >+ } >+ } >+ >+ /** >+ * Create the progress indicator for the receiver. >+ * >+ * @param shell >+ * the parent shell >+ */ >+ private void createProgressIndicator(Shell shell) { >+ if (getWindowConfigurer().getShowProgressIndicator()) { >+ progressRegion = new ProgressRegion(); >+ progressRegion.createContents(shell, this); >+ } >+ } >+ >+ class PageList { >+ // List of pages in the order they were created; >+ private List pagesInCreationOrder; >+ >+ // List of pages where the top is the last activated. >+ private List pageInActivationOrder; >+ >+ // The page explicitly activated >+ private Object active; >+ >+ public PageList() { >+ pagesInCreationOrder = new ArrayList(4); >+ pageInActivationOrder = new ArrayList(4); >+ } >+ >+ public boolean add(Object object) { >+ pagesInCreationOrder.add(object); >+ pageInActivationOrder.add(0, object); >+ // It will be moved to top only when activated. >+ return true; >+ } >+ >+ public Iterator iterator() { >+ return pagesInCreationOrder.iterator(); >+ } >+ >+ public boolean contains(Object object) { >+ return pagesInCreationOrder.contains(object); >+ } >+ >+ public boolean remove(Object object) { >+ if (active == object) { >+ active = null; >+ } >+ pageInActivationOrder.remove(object); >+ return pagesInCreationOrder.remove(object); >+ } >+ >+ public boolean isEmpty() { >+ return pagesInCreationOrder.isEmpty(); >+ } >+ >+ public IWorkbenchPage[] getPages() { >+ int nSize = pagesInCreationOrder.size(); >+ IWorkbenchPage[] retArray = new IWorkbenchPage[nSize]; >+ pagesInCreationOrder.toArray(retArray); >+ return retArray; >+ } >+ >+ public void setActive(Object page) { >+ if (active == page) { >+ return; >+ } >+ >+ active = page; >+ >+ if (page != null) { >+ pageInActivationOrder.remove(page); >+ pageInActivationOrder.add(page); >+ } >+ } >+ >+ public WorkbenchPage getActive() { >+ return (WorkbenchPage) active; >+ } >+ >+ public WorkbenchPage getNextActive() { >+ if (active == null) { >+ if (pageInActivationOrder.isEmpty()) { >+ return null; >+ } >+ >+ return (WorkbenchPage) pageInActivationOrder >+ .get(pageInActivationOrder.size() - 1); >+ } >+ >+ if (pageInActivationOrder.size() < 2) { >+ return null; >+ } >+ >+ return (WorkbenchPage) pageInActivationOrder >+ .get(pageInActivationOrder.size() - 2); >+ } >+ } >+ >+ /** >+ * Returns the unique object that applications use to configure this window. >+ * <p> >+ * IMPORTANT This method is declared package-private to prevent regular >+ * plug-ins from downcasting IWorkbenchWindow to WorkbenchWindow and getting >+ * hold of the workbench window configurer that would allow them to tamper >+ * with the workbench window. The workbench window configurer is available >+ * only to the application. >+ * </p> >+ */ >+ /* package - DO NOT CHANGE */ >+ WorkbenchWindowConfigurer getWindowConfigurer() { >+ if (windowConfigurer == null) { >+ // lazy initialize >+ windowConfigurer = new WorkbenchWindowConfigurer( this ); >+ } >+ return windowConfigurer; >+ } >+ >+ /** >+ * Returns the workbench advisor. Assumes the workbench has been created >+ * already. >+ * <p> >+ * IMPORTANT This method is declared private to prevent regular plug-ins >+ * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >+ * the workbench advisor that would allow them to tamper with the workbench. >+ * The workbench advisor is internal to the application. >+ * </p> >+ */ >+ private/* private - DO NOT CHANGE */ >+ WorkbenchAdvisor getAdvisor() { >+ return getWorkbenchImpl().getAdvisor(); >+ } >+ >+ /** >+ * Returns the window advisor, creating a new one for this window if needed. >+ * <p> >+ * IMPORTANT This method is declared private to prevent regular plug-ins >+ * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >+ * the window advisor that would allow them to tamper with the window. The >+ * window advisor is internal to the application. >+ * </p> >+ */ >+ private/* private - DO NOT CHANGE */ >+ WorkbenchWindowAdvisor getWindowAdvisor() { >+ if (windowAdvisor == null) { >+ windowAdvisor = getAdvisor().createWorkbenchWindowAdvisor( >+ getWindowConfigurer()); >+ Assert.isNotNull(windowAdvisor); >+ } >+ return windowAdvisor; >+ } >+ >+ /** >+ * Returns the action bar advisor, creating a new one for this window if >+ * needed. >+ * <p> >+ * IMPORTANT This method is declared private to prevent regular plug-ins >+ * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of >+ * the action bar advisor that would allow them to tamper with the window's >+ * action bars. The action bar advisor is internal to the application. >+ * </p> >+ */ >+ private/* private - DO NOT CHANGE */ >+ ActionBarAdvisor getActionBarAdvisor() { >+ if (actionBarAdvisor == null) { >+ actionBarAdvisor = getWindowAdvisor().createActionBarAdvisor( >+ getWindowConfigurer().getActionBarConfigurer()); >+ Assert.isNotNull(actionBarAdvisor); >+ } >+ return actionBarAdvisor; >+ } >+ >+ /* >+ * Returns the IWorkbench implementation. >+ */ >+ private Workbench getWorkbenchImpl() { >+ return Workbench.getInstance(); >+ } >+ >+ /** >+ * Fills the window's real action bars. >+ * >+ * @param flags >+ * indicate which bars to fill >+ */ >+ public void fillActionBars(int flags) { >+ Workbench workbench = getWorkbenchImpl(); >+ workbench.largeUpdateStart(); >+ try { >+ getActionBarAdvisor().fillActionBars(flags); >+ // >+ // 3.3 start >+ final IMenuService menuService = (IMenuService) serviceLocator >+ .getService(IMenuService.class); >+ menuService.populateContributionManager( >+ (ContributionManager) getActionBars().getMenuManager(), >+ MenuUtil.MAIN_MENU); >+ ICoolBarManager coolbar = getActionBars().getCoolBarManager(); >+ if (coolbar != null) { >+ menuService.populateContributionManager( >+ (ContributionManager) coolbar, >+ MenuUtil.MAIN_TOOLBAR); >+ } >+ // 3.3 end >+ } finally { >+ workbench.largeUpdateEnd(); >+ } >+ } >+ >+ /** >+ * Fills the window's proxy action bars. >+ * >+ * @param proxyBars >+ * the proxy configurer >+ * @param flags >+ * indicate which bars to fill >+ */ >+ public void fillActionBars(IActionBarConfigurer2 proxyBars, int flags) { >+ Assert.isNotNull(proxyBars); >+ WorkbenchWindowConfigurer.WindowActionBarConfigurer wab = (WorkbenchWindowConfigurer.WindowActionBarConfigurer) getWindowConfigurer() >+ .getActionBarConfigurer(); >+ wab.setProxy(proxyBars); >+ try { >+ getActionBarAdvisor().fillActionBars( >+ flags | ActionBarAdvisor.FILL_PROXY); >+ } finally { >+ wab.setProxy(null); >+ } >+ } >+ >+ /** >+ * The <code>WorkbenchWindow</code> implementation of this method has the >+ * same logic as <code>Window</code>'s implementation, but without the >+ * resize check. We don't want to skip setting the bounds if the shell has >+ * been resized since a free resize event occurs on Windows when the menubar >+ * is set in configureShell. >+ */ >+ protected void initializeBounds() { >+ Point size = getInitialSize(); >+ Point location = getInitialLocation(size); >+ getShell().setBounds( >+ getConstrainedShellBounds(new Rectangle(location.x, location.y, >+ size.x, size.y))); >+ } >+ >+ /* >+ * Unlike dialogs, the position of the workbench window is set by the user >+ * and persisted across sessions. If the user wants to put the window >+ * offscreen or spanning multiple monitors, let them (bug 74762) >+ */ >+ protected void constrainShellSize() { >+ // As long as the shell is visible on some monitor, don't change it. >+ Rectangle bounds = getShell().getBounds(); >+ if (!SwtUtil.intersectsAnyMonitor(Display.getCurrent(), bounds)) { >+ super.constrainShellSize(); >+ } >+ } >+ >+ /* >+ * Unlike dialogs, the position of the workbench window is set by the user >+ * and persisted across sessions. If the user wants to put the window >+ * offscreen or spanning multiple monitors, let them (bug 74762) >+ */ >+ protected Point getInitialLocation(Point size) { >+ Shell shell = getShell(); >+ if (shell != null) { >+ return shell.getLocation(); >+ } >+ >+ return super.getInitialLocation(size); >+ } >+ >+ /** >+ * The <code>WorkbenchWindow</code> implementation of this method >+ * delegates to the window configurer. >+ */ >+ protected Point getInitialSize() { >+ return getWindowConfigurer().getInitialSize(); >+ } >+ >+ /** >+ * @param visible >+ * whether the cool bar should be shown. This is only applicable >+ * if the window configurer also wishes either the cool bar to be >+ * visible. >+ */ >+ public void setCoolBarVisible(boolean visible) { >+ boolean oldValue = coolBarVisible; >+ coolBarVisible = visible; >+ if (oldValue != coolBarVisible) { >+ updateLayoutDataForContents(); >+ } >+ } >+ >+ /** >+ * @return whether the cool bar should be shown. This is only applicable if >+ * the window configurer also wishes either the cool bar to be >+ * visible. >+ */ >+ public boolean getCoolBarVisible() { >+ return coolBarVisible; >+ } >+ >+ /** >+ * @param visible >+ * whether the perspective bar should be shown. This is only >+ * applicable if the window configurer also wishes either the >+ * perspective bar to be visible. >+ */ >+ public void setPerspectiveBarVisible(boolean visible) { >+ boolean oldValue = perspectiveBarVisible; >+ perspectiveBarVisible = visible; >+ if (oldValue != perspectiveBarVisible) { >+ updateLayoutDataForContents(); >+ } >+ } >+ >+ /** >+ * @return whether the perspective bar should be shown. This is only >+ * applicable if the window configurer also wishes either the >+ * perspective bar to be visible. >+ */ >+ public boolean getPerspectiveBarVisible() { >+ return perspectiveBarVisible; >+ } >+ >+ /** >+ * Tell the workbench window a visible state for the fastview bar. This is >+ * only applicable if the window configurer also wishes the fast view bar to >+ * be visible. >+ * >+ * @param visible >+ * <code>true</code> or <code>false</code> >+ */ >+ public void setFastViewBarVisible(boolean visible) { >+ boolean oldValue = fastViewBarVisible; >+ fastViewBarVisible = visible; >+ if (oldValue != fastViewBarVisible) { >+ updateLayoutDataForContents(); >+ } >+ } >+ >+ /** >+ * The workbench window take on the fastview bar. This is only applicable if >+ * the window configurer also wishes the fast view bar to be visible. >+ * >+ * @return <code>true</code> if the workbench window thinks the fastview >+ * bar should be visible. >+ */ >+ public boolean getFastViewBarVisible() { >+ return fastViewBarVisible; >+ } >+ >+ /** >+ * @param visible >+ * whether the perspective bar should be shown. This is only >+ * applicable if the window configurer also wishes either the >+ * perspective bar to be visible. >+ */ >+ public void setStatusLineVisible(boolean visible) { >+ boolean oldValue = statusLineVisible; >+ statusLineVisible = visible; >+ if (oldValue != statusLineVisible) { >+ updateLayoutDataForContents(); >+ } >+ } >+ >+ /** >+ * @return whether the perspective bar should be shown. This is only >+ * applicable if the window configurer also wishes either the >+ * perspective bar to be visible. >+ */ >+ public boolean getStatusLineVisible() { >+ return statusLineVisible; >+ } >+ >+ /** >+ * Note that this will only have an effect if the default implementation of >+ * WorkbenchAdvisor.createWindowContents() has been invoked. >+ * >+ * called IWorkbench >+ */ >+ private void updateLayoutDataForContents() { >+ if (defaultLayout == null) { >+ return; >+ } >+ >+ // @issue this is not ideal; coolbar and perspective shortcuts should be >+ // separately configurable >+ if ((getCoolBarVisible() && getWindowConfigurer().getShowCoolBar()) >+ || (getPerspectiveBarVisible() && getWindowConfigurer() >+ .getShowPerspectiveBar())) { >+ if (defaultLayout.getTrim(topBarTrim.getId()) == null) { >+ defaultLayout.addTrim(SWT.TOP, topBarTrim); >+ } >+ topBar.setVisible(true); >+ } else { >+ defaultLayout.removeTrim(topBarTrim); >+ topBar.setVisible(false); >+ } >+ >+ if (fastViewBar != null) { >+ if (getFastViewBarVisible() >+ && getWindowConfigurer().getShowFastViewBars()) { >+ int side = fastViewBar.getSide(); >+ >+ if (defaultLayout.getTrim(fastViewBar.getId()) == null) { >+ defaultLayout.addTrim(side, fastViewBar); >+ } >+ fastViewBar.getControl().setVisible(true); >+ } else { >+ defaultLayout.removeTrim(fastViewBar); >+ fastViewBar.getControl().setVisible(false); >+ } >+ } >+ >+ if (getStatusLineVisible() && getWindowConfigurer().getShowStatusLine()) { >+ if (defaultLayout.getTrim(getStatusLineTrim().getId()) == null) { >+ defaultLayout.addTrim(SWT.BOTTOM, getStatusLineTrim()); >+ } >+ getStatusLineManager().getControl().setVisible(true); >+ } else { >+ defaultLayout.removeTrim(getStatusLineTrim()); >+ getStatusLineManager().getControl().setVisible(false); >+ } >+ >+// RAP [rh] HeapStatus not supported >+// if (heapStatus != null) { >+// if (getShowHeapStatus()) { >+// if (heapStatus.getLayoutData() == null) { >+// heapStatusTrim.setWidthHint(heapStatus.computeSize( >+// SWT.DEFAULT, SWT.DEFAULT).x); >+// heapStatusTrim >+// .setHeightHint(getStatusLineManager().getControl() >+// .computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >+// } >+// >+// if (defaultLayout.getTrim(heapStatusTrim.getId()) == null) { >+// defaultLayout.addTrim(SWT.BOTTOM, heapStatusTrim); >+// } >+// heapStatus.setVisible(true); >+// } else { >+// >+// defaultLayout.removeTrim(heapStatusTrim); >+// heapStatus.setVisible(false); >+// } >+// } >+ >+ if (progressRegion != null) { >+ if (getWindowConfigurer().getShowProgressIndicator()) { >+ if (defaultLayout.getTrim(progressRegion.getId()) == null) { >+ defaultLayout.addTrim(SWT.BOTTOM, progressRegion); >+ } >+ progressRegion.getControl().setVisible(true); >+ } else { >+ defaultLayout.removeTrim(progressRegion); >+ progressRegion.getControl().setVisible(false); >+ } >+ } >+ >+ defaultLayout.setCenterControl(getPageComposite()); >+ >+ // Re-populate the trim elements >+ if (trimMgr2 != null) >+ trimMgr2.update(true, false, !topBar.getVisible()); >+ if (trimContributionMgr != null) >+ trimContributionMgr.update(true, !topBar.getVisible()); >+ } >+ >+ public boolean getShowFastViewBars() { >+ return getWindowConfigurer().getShowFastViewBars(); >+ } >+ >+ /** >+ * Set the layout data for the contents of the window. >+ */ >+ private void setLayoutDataForContents() { >+ updateLayoutDataForContents(); >+ } >+ >+ /** >+ * Returns the fast view bar. >+ */ >+ public FastViewBar getFastViewBar() { >+ return fastViewBar; >+ } >+ >+ /** >+ * Returns the perspective bar. >+ * >+ * @return Returns the perspective bar, or <code>null</code> if it has not >+ * been initialized. >+ */ >+ public PerspectiveBarManager getPerspectiveBar() { >+ return perspectiveSwitcher == null ? null : perspectiveSwitcher >+ .getPerspectiveBar(); >+ } >+ >+ /** >+ * Returns the action presentation for dynamic UI >+ * @return action presentation >+ */ >+ public ActionPresentation getActionPresentation() { >+ if (actionPresentation == null) { >+ actionPresentation = new ActionPresentation(this); >+ } >+ return actionPresentation; >+ } >+ >+ /** >+ * Return the action bar presentation used for creating toolbars. This >+ * is for internal use only, used for consistency with the window. >+ * >+ * @return the presentation used. >+ */ >+ public IActionBarPresentationFactory getActionBarPresentationFactory() { >+ // allow replacement of the actionbar presentation >+ IActionBarPresentationFactory actionBarPresentation; >+ AbstractPresentationFactory presentationFactory = >+ getWindowConfigurer().getPresentationFactory(); >+ if (presentationFactory instanceof IActionBarPresentationFactory) { >+ actionBarPresentation = ((IActionBarPresentationFactory) presentationFactory); >+ } else { >+ actionBarPresentation = new DefaultActionBarPresentationFactory(); >+ } >+ >+ return actionBarPresentation; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.ApplicationWindow#showTopSeperator() >+ */ >+ protected boolean showTopSeperator() { >+ return false; >+ } >+ >+ /** >+ * Returns a new cool bar manager for the window. >+ * <p> >+ * Subclasses may override this method to customize the cool bar manager. >+ * </p> >+ * >+ * @return a cool bar manager >+ */ >+ protected ICoolBarManager createCoolBarManager2(int style) { >+ return getActionBarPresentationFactory().createCoolBarManager(); >+ } >+ >+ /** >+ * Returns a new tool bar manager for the window. >+ * <p> >+ * Subclasses may override this method to customize the tool bar manager. >+ * </p> >+ * @return a tool bar manager >+ */ >+ protected IToolBarManager createToolBarManager2(int style) { >+ return getActionBarPresentationFactory().createToolBarManager(); >+ } >+ >+ /** >+ * Delegate to the presentation factory. >+ * >+ * @see org.eclipse.jface.window.ApplicationWindow#createStatusLineManager >+ */ >+ protected StatusLineManager createStatusLineManager() { >+ // @issue ApplicationWindow and WorkbenchWindow should allow full >+ // IStatusLineManager >+ return (StatusLineManager) getWindowConfigurer() >+ .getPresentationFactory().createStatusLineManager(); >+ } >+ >+ /** >+ * Delegate to the presentation factory. >+ * >+ * @see org.eclipse.jface.window.ApplicationWindow#createStatusLine >+ */ >+ protected void createStatusLine(Shell shell) { >+ getWindowConfigurer().getPresentationFactory().createStatusLineControl( >+ getStatusLineManager(), shell); >+ } >+ >+ /** >+ * Updates the fast view bar, if present. TODO: The fast view bar should >+ * update itself as necessary. All calls to this should be cleaned up. >+ */ >+ public void updateFastViewBar() { >+ if (getFastViewBar() != null) { >+ getFastViewBar().update(true); >+ } >+ } >+ >+ /** >+ * @return Returns the progressRegion. >+ */ >+ public ProgressRegion getProgressRegion() { >+ return progressRegion; >+ } >+ >+ /** >+ * Adds the given control to the specified side of this window's trim. >+ * >+ * @param trim >+ * the bar's IWindowTrim >+ * @param side >+ * one of <code>SWT.LEFT</code>,<code>SWT.BOTTOM</code>, >+ * or <code>SWT.RIGHT</code> (only LEFT has been tested) >+ */ >+ public void addToTrim(IWindowTrim trim, int side) { >+ IWindowTrim reference = null; >+ defaultLayout.addTrim(side, trim, reference); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.IWorkbenchWindow#getExtensionTracker() >+ */ >+ public IExtensionTracker getExtensionTracker() { >+ if (tracker == null) { >+ tracker = new UIExtensionTracker(getWorkbench().getDisplay()); >+ } >+ return tracker; >+ } >+ >+ /** >+ * Creates the perspective customization dialog. >+ * >+ * @param persp >+ * perspective to customize >+ * >+ * @return a new perspective customization dialog >+ */ >+ public CustomizePerspectiveDialog createCustomizePerspectiveDialog( >+ Perspective persp) { >+ return new CustomizePerspectiveDialog(getWindowConfigurer(), persp); >+ } >+ >+ /** >+ * Returns the default page input for workbench pages opened in this window. >+ * >+ * @return the default page input or <code>null</code> if none >+ */ >+ IAdaptable getDefaultPageInput() { >+ return getWorkbenchImpl().getDefaultPageInput(); >+ } >+ >+ /** >+ * Add a listener for perspective reordering. >+ * >+ * @param listener >+ */ >+ public void addPerspectiveReorderListener(IReorderListener listener) { >+ if (perspectiveSwitcher != null) { >+ perspectiveSwitcher.addReorderListener(listener); >+ } >+ } >+ >+// RAP [rh] HeapStatus not supported >+// /** >+// * Show the heap status >+// * >+// * @param selection >+// */ >+// public void showHeapStatus(boolean selection) { >+// if (selection) { >+// if (heapStatus == null) { >+// createHeapStatus(getShell()); >+// updateLayoutDataForContents(); >+// getShell().layout(); >+// } >+// } else { >+// if (heapStatus != null) { >+// heapStatus.dispose(); >+// heapStatus = null; >+// } >+// } >+// >+// } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.IWorkbenchWindow#getTrimManager() >+ */ >+ public ITrimManager getTrimManager() { >+ return defaultLayout; >+ } >+ >+ /** >+ * Initializes all of the default command-based services for the workbench >+ * window. >+ */ >+ private final void initializeDefaultServices() { >+ serviceLocator.registerService(IWorkbenchWindow.class, this); >+ >+ final ActionCommandMappingService mappingService = new ActionCommandMappingService(); >+ serviceLocator.registerService(IActionCommandMappingService.class, >+ mappingService); >+ >+ final LegacyActionPersistence actionPersistence = new LegacyActionPersistence( >+ this); >+ serviceLocator.registerService(LegacyActionPersistence.class, >+ actionPersistence); >+ actionPersistence.read(); >+ >+ } >+ >+ public final Object getService(final Class key) { >+ return serviceLocator.getService(key); >+ } >+ >+ public final boolean hasService(final Class key) { >+ return serviceLocator.hasService(key); >+ } >+ >+ /** >+ * Toggle the visibility of the coolbar/perspective bar. This method >+ * respects the window configurer and will only toggle visibility if the >+ * item in question was originally declared visible by the window advisor. >+ */ >+ public void toggleToolbarVisibility() { >+ boolean coolbarVisible = getCoolBarVisible(); >+ boolean perspectivebarVisible = getPerspectiveBarVisible(); >+ // only toggle the visibility of the components that >+ // were on initially >+ if (getWindowConfigurer().getShowCoolBar()) { >+ setCoolBarVisible(!coolbarVisible); >+ firePropertyChanged(PROP_COOLBAR_VISIBLE, >+ coolbarVisible ? Boolean.TRUE : Boolean.FALSE, >+ !coolbarVisible ? Boolean.TRUE : Boolean.FALSE); >+ } >+ if (getWindowConfigurer().getShowPerspectiveBar()) { >+ setPerspectiveBarVisible(!perspectivebarVisible); >+ firePropertyChanged(PROP_PERSPECTIVEBAR_VISIBLE, >+ coolbarVisible ? Boolean.TRUE : Boolean.FALSE, >+ !coolbarVisible ? Boolean.TRUE : Boolean.FALSE); >+ } >+ getShell().layout(); >+ } >+ >+ /*package*/ void addBackgroundSaveListener(IBackgroundSaveListener listener) { >+ backgroundSaveListeners.add(listener); >+ } >+ >+ /*package*/ void fireBackgroundSaveStarted() { >+ Object[] listeners = backgroundSaveListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ IBackgroundSaveListener listener = (IBackgroundSaveListener) listeners[i]; >+ listener.handleBackgroundSaveStarted(); >+ } >+ } >+ >+ /*package*/ void removeBackgroundSaveListener(IBackgroundSaveListener listener) { >+ backgroundSaveListeners.remove(listener); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java,v >retrieving revision 1.14 >diff -u -r1.14 WorkbenchPlugin.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java 2 Jun 2008 08:48:50 -0000 1.14 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java 21 Jan 2009 09:57:25 -0000 >@@ -16,17 +16,30 @@ > import java.util.Collection; > import java.util.HashSet; > >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; > import org.eclipse.equinox.http.registry.HttpContextExtensionService; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.preference.PreferenceManager; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.ImageRegistry; > import org.eclipse.jface.window.Window; >+import org.eclipse.rap.ui.interactiondesign.layout.LayoutRegistry; > import org.eclipse.rwt.SessionSingletonBase; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.ui.*; >+import org.eclipse.ui.IEditorRegistry; >+import org.eclipse.ui.IElementFactory; >+import org.eclipse.ui.IPerspectiveRegistry; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkingSetManager; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.StartupThreading.StartupRunnable; > import org.eclipse.ui.internal.branding.BrandingExtension; > import org.eclipse.ui.internal.decorators.DecoratorManager; >@@ -35,19 +48,35 @@ > import org.eclipse.ui.internal.operations.WorkbenchOperationSupport; > import org.eclipse.ui.internal.progress.JobManagerAdapter; > import org.eclipse.ui.internal.progress.ProgressManager; >-import org.eclipse.ui.internal.registry.*; >+import org.eclipse.ui.internal.registry.ActionSetRegistry; >+import org.eclipse.ui.internal.registry.EditorRegistry; >+import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; >+import org.eclipse.ui.internal.registry.PerspectiveRegistry; >+import org.eclipse.ui.internal.registry.PreferencePageRegistryReader; >+import org.eclipse.ui.internal.registry.ViewRegistry; >+import org.eclipse.ui.internal.registry.WorkingSetRegistry; > import org.eclipse.ui.internal.servlet.EntryPointExtension; > import org.eclipse.ui.internal.servlet.HttpServiceTracker; >-import org.eclipse.ui.internal.themes.*; >+import org.eclipse.ui.internal.themes.IThemeRegistry; >+import org.eclipse.ui.internal.themes.ThemeRegistry; >+import org.eclipse.ui.internal.themes.ThemeRegistryReader; > import org.eclipse.ui.internal.util.BundleUtility; > import org.eclipse.ui.internal.util.SWTResourceUtil; >-import org.eclipse.ui.internal.wizards.*; >+import org.eclipse.ui.internal.wizards.ExportWizardRegistry; >+import org.eclipse.ui.internal.wizards.ImportWizardRegistry; >+import org.eclipse.ui.internal.wizards.NewWizardRegistry; > import org.eclipse.ui.operations.IWorkbenchOperationSupport; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.eclipse.ui.presentations.AbstractPresentationFactory; > import org.eclipse.ui.views.IViewRegistry; > import org.eclipse.ui.wizards.IWizardRegistry; >-import org.osgi.framework.*; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleContext; >+import org.osgi.framework.BundleEvent; >+import org.osgi.framework.BundleListener; >+import org.osgi.framework.InvalidSyntaxException; >+import org.osgi.framework.ServiceReference; >+import org.osgi.framework.SynchronousBundleListener; > import org.osgi.util.tracker.ServiceTracker; > > import com.ibm.icu.text.MessageFormat; >@@ -1043,7 +1072,11 @@ > } > }; > httpContextExtensionServiceTracker.open(); >- >+ >+ // Initialize Layout and layoutSets. >+ LayoutRegistry registry = LayoutRegistry.getInstance(); >+ registry.init(); >+ > > // RAP [fappel]: as workbench instances in RAP run in session scope the > // UI bundle should be initialized in time >Index: Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java,v >retrieving revision 1.1 >diff -u -r1.1 PresentablePart.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 17 Apr 2008 12:03:53 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 21 Jan 2009 09:57:27 -0000 >@@ -14,6 +14,7 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.ListenerList; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; >@@ -22,6 +23,7 @@ > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.ToolBar; > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.PlatformUI; >@@ -74,6 +76,9 @@ > private boolean isDirty = false; > private boolean isBusy = false; > private boolean hasViewMenu = false; >+ >+ // RAP [hs] IAdaptable for interactiondesign API >+ private IAdaptable adaptable; > > /** > * Constructor >@@ -283,10 +288,15 @@ > * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar() > */ > public Control getToolBar() { >- if (enableOutputs) { >- return getPane().getToolBar(); >- } >- return null; >+ Control result = null; >+ // RAP [hs] patched for interactiondesign API >+ if( adaptable != null ) { >+ result = ( Control ) adaptable.getAdapter( ToolBar.class ); >+ } else if (enableOutputs) { >+ result = getPane().getToolBar(); >+ >+ } >+ return result; > } > > /* >@@ -296,7 +306,7 @@ > */ > public IPartMenu getMenu() { > boolean hasMenu; >- >+ IPartMenu result = null; > if (enableOutputs) { > hasMenu = part.hasViewMenu(); > } else { >@@ -306,16 +316,19 @@ > if (!hasMenu) { > return null; > } >- >- if (viewMenu == null) { >- viewMenu = new IPartMenu() { >- public void showMenu(Point location) { >- part.showViewMenu(location); >- } >- }; >+ // RAP [hs] patched for interactiondesign API >+ if( adaptable != null ) { >+ viewMenu = ( IPartMenu ) adaptable.getAdapter( IPartMenu.class ); >+ >+ } else if (viewMenu == null) { >+ viewMenu = new IPartMenu() { >+ public void showMenu(Point location) { >+ part.showViewMenu(location); >+ } >+ }; > } >- >- return viewMenu; >+ result = viewMenu; >+ return result; > } > > /* (non-Javadoc) >@@ -415,5 +428,9 @@ > return getPane().getSizeFlags(width); > } > >+ public void setConfigurationAdaptable( IAdaptable adaptable ) { >+ this.adaptable = adaptable; >+ } >+ > > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/META-INF/MANIFEST.MF,v >retrieving revision 1.10 >diff -u -r1.10 MANIFEST.MF >--- META-INF/MANIFEST.MF 4 Nov 2008 17:14:34 -0000 1.10 >+++ META-INF/MANIFEST.MF 21 Jan 2009 09:57:27 -0000 >@@ -11,6 +11,9 @@ > Bundle-Vendor: %providerName > Bundle-Localization: plugin > Export-Package: org.eclipse.rap.ui.branding, >+ org.eclipse.rap.ui.interactiondesign, >+ org.eclipse.rap.ui.interactiondesign.layout, >+ org.eclipse.rap.ui.interactiondesign.layout.model, > org.eclipse.ui;ui.workbench=split;mandatory:="ui.workbench", > org.eclipse.ui.about, > org.eclipse.ui.actions;ui.workbench=split;mandatory:="ui.workbench", >@@ -96,11 +99,11 @@ > org.eclipse.equinox.http.registry, > org.eclipse.osgi.services > Import-Package: com.ibm.icu.text, >+ javax.servlet;version="[2.3.0,2.5.0]", >+ javax.servlet.http;version="[2.3.0,2.5.0]", > javax.xml.parsers, > org.w3c.dom, >- org.xml.sax, >- javax.servlet;version="[2.3.0,2.5.0]", >- javax.servlet.http;version="[2.3.0,2.5.0]" >+ org.xml.sax > Bundle-RequiredExecutionEnvironment: J2SE-1.4, > CDC-1.0/Foundation-1.0, > J2SE-1.3 >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStackProxy.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStackProxy.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStackProxy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStackProxy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,456 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.rwt.branding.AbstractBranding; >+import org.eclipse.rwt.internal.branding.BrandingUtil; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.internal.presentations.NativeStackPresentation; >+import org.eclipse.ui.internal.presentations.PresentablePart; >+import org.eclipse.ui.presentations.IPartMenu; >+import org.eclipse.ui.presentations.IPresentablePart; >+import org.eclipse.ui.presentations.IPresentationSerializer; >+import org.eclipse.ui.presentations.IStackPresentationSite; >+import org.eclipse.ui.presentations.StackPresentation; >+ >+ >+class ConfigurableStackProxy extends StackPresentation { >+ >+ public static final String STACK_PRESENTATION_ID = "stackPresentationId"; >+ >+ private StackPresentation currentStackPresentation; >+ >+ private NativeStackPresentation nativeStackPresentation; >+ >+ private Composite parent; >+ private IStackPresentationSite site; >+ private String type; >+ private String currentId; >+ private boolean showTitle = false; >+ >+ >+ private IConfigurationElement brandingElement; >+ >+ public ConfigurableStackProxy( >+ final Composite parent, >+ final IStackPresentationSite stackSite, >+ final String type ) >+ { >+ super( stackSite ); >+ this.parent = parent; >+ this.site = stackSite; >+ this.type = type; >+ currentId = ""; >+ nativeStackPresentation = new NativeStackPresentation( parent, stackSite ); >+ >+ currentStackPresentation >+ = loadStackPresentations( this.type, this.site, this.parent ); >+ if( currentStackPresentation == null ) { >+ currentStackPresentation = nativeStackPresentation; >+ } >+ } >+ >+ public void addPart( final IPresentablePart newPart, final Object cookie ) { >+ StackPresentation delegate = getDelegate(); >+ if( delegate instanceof ConfigurableStack ) { >+ IAdaptable adaptable = getConfigAdaptable(); >+ if( newPart instanceof PresentablePart ) { >+ PresentablePart part = ( PresentablePart ) newPart; >+ part.setConfigurationAdaptable( adaptable ); >+ } >+ } >+ delegate.addPart( newPart, cookie ); >+ } >+ >+ private boolean brandingPresentationFactoryExists() { >+ boolean result = false; >+ String id = getBrandingPresentationFactoryId(); >+ if( id != null ) { >+ result = true; >+ } >+ return result; >+ } >+ >+ public Point computeMinimumSize() { >+ return getDelegate().computeMinimumSize(); >+ } >+ >+ public int computePreferredSize( boolean width, >+ int availableParallel, >+ int availablePerpendicular, >+ int preferredResult ) >+ { >+ return getDelegate().computePreferredSize( width, >+ availableParallel, >+ availablePerpendicular, >+ preferredResult ); >+ } >+ >+ private ConfigurableStack createStackById( final String stackId ) { >+ ConfigurableStack result = null; >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String stackPresentationExtId = ConfigurableStack.STACK_PRESENTATION_EXT_ID; >+ IExtensionPoint point = registry.getExtensionPoint( stackPresentationExtId ); >+ if( point != null ) { >+ IConfigurationElement[] elements = point.getConfigurationElements(); >+ boolean found = false; >+ for( int i = 0; i < elements.length && !found; i++ ) { >+ String id = elements[ i ].getAttribute( "id" ); >+ //String presentationType = elements[ i ].getAttribute( "type" ); >+ if( id.equals( stackId ) ) { >+ found = true; >+ try { >+ Object obj = elements[ i ].createExecutableExtension( "class" ); >+ result = ( ConfigurableStack ) obj; >+ result.init( site, id, parent, this ); >+ } catch( CoreException e ) { >+ // nothing todo >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+ public void dispose() { >+ getDelegate().dispose(); >+ } >+ >+ // Delegate methods >+ >+ private IConfigurationElement getBrandingElement() { >+ if( brandingElement == null ) { >+ AbstractBranding branding = BrandingUtil.findBranding(); >+ if( branding != null ) { >+ String brandingId = branding.getId(); >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String id = "org.eclipse.rap.ui.branding"; >+ IExtensionPoint brandingPoint = registry.getExtensionPoint( id ); >+ if( brandingPoint != null ) { >+ IConfigurationElement[] elements >+ = brandingPoint.getConfigurationElements(); >+ >+ boolean found = false; >+ for( int i = 0; i < elements.length && !found; i++ ) { >+ String tempId = elements[ i ].getAttribute( "id" ); >+ if( tempId.equals( brandingId ) ) { >+ found = true; >+ brandingElement = elements[ i ]; >+ } >+ } >+ } >+ } >+ } >+ return brandingElement; >+ } >+ >+ private String getBrandingPresentationFactoryId() { >+ return loadBrandingPresentationFactoryId( getBrandingElement() ); >+ } >+ >+ private IAdaptable getConfigAdaptable() { >+ IAdaptable adaptable = new IAdaptable() { >+ >+ public Object getAdapter( Class adapter ) { >+ Object result = null; >+ if( currentStackPresentation instanceof ConfigurableStack ) { >+ ConfigurableStack stackPresentation >+ = ( ConfigurableStack ) currentStackPresentation; >+ if( adapter == ToolBar.class ) { >+ result = stackPresentation.createPartToolBar( ); >+ } else if( adapter == IPartMenu.class ) { >+ result = stackPresentation.createViewMenu(); >+ } >+ } >+ return result; >+ } >+ >+ }; >+ return adaptable; >+ } >+ >+ public Control getControl() { >+ return getDelegate().getControl(); >+ } >+ >+ public ConfigurableStack getCurrentStackPresentation() { >+ ConfigurableStack result = null; >+ if( currentStackPresentation instanceof ConfigurableStack ) { >+ result = ( ConfigurableStack ) currentStackPresentation; >+ } >+ return result; >+ } >+ >+ private StackPresentation getDelegate() { >+ StackPresentation result; >+ if( currentStackPresentation != null ) { >+ result = currentStackPresentation; >+ } else { >+ result = nativeStackPresentation; >+ } >+ return result; >+ } >+ >+ protected boolean getShowTitle() { >+ return showTitle; >+ } >+ >+ public int getSizeFlags( boolean width ) { >+ return getDelegate().getSizeFlags( width ); >+ } >+ >+ public Control[] getTabList( IPresentablePart part ) { >+ return getDelegate().getTabList( part ); >+ } >+ >+ private String loadBrandingPresentationFactoryId( >+ final IConfigurationElement element ) >+ { >+ String result = null; >+ if( element != null ) { >+ IConfigurationElement[] factory >+ = element.getChildren( "presentationFactory" ); >+ if( factory.length > 0 ) { >+ result = factory[ 0 ].getAttribute( "id" ); >+ } >+ } >+ return result; >+ } >+ >+ private ConfigurableStack loadDefaultPartStack() { >+ ConfigurableStack result = null; >+ IConfigurationElement element = getBrandingElement(); >+ IConfigurationElement[] factory >+ = element.getChildren( "presentationFactory" ); >+ if( factory.length > 0 ) { >+ IConfigurationElement[] stacks >+ = factory[ 0 ].getChildren( "defaultStackPresentation" ); >+ if( stacks.length > 0 ) { >+ String id = stacks[ 0 ].getAttribute( "id" ); >+ result = createStackById( id ); >+ } >+ } >+ return result; >+ } >+ >+ private ConfigurableStack loadLayoutPartStack() { >+ ConfigurableStack result = null; >+ IConfigurationElement element = getBrandingElement(); >+ IConfigurationElement[] factory >+ = element.getChildren( "presentationFactory" ); >+ if( factory.length > 0 ) { >+ IConfigurationElement[] stacks >+ = factory[ 0 ].getChildren( "stackPresentation" ); >+ if( stacks.length > 0 ) { >+ String layoutPartId = ConfigurableStack.getLayoutPartId( site ); >+ boolean found = false; >+ for( int i = 0; i < stacks.length && !found; i++ ) { >+ String partId = stacks[ i ].getAttribute( "partId" ); >+ if( partId.equals( layoutPartId ) ) { >+ String stackId = stacks[ i ].getAttribute( "id" ); >+ result = createStackById( stackId ); >+ found = true; >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+ private ConfigurableStack loadStackFromBranding() { >+ ConfigurableStack result = loadLayoutPartStack(); >+ if( result == null ) { >+ result = loadDefaultPartStack(); >+ } >+ return result; >+ } >+ >+ /* >+ * load the saved or default StackPresentation from extension registry >+ */ >+ private ConfigurableStack loadStackPresentations( >+ final String type, >+ final IStackPresentationSite site, >+ final Composite parent ) >+ { >+ this.parent = parent; >+ ConfigurableStack result = null; >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String stackPresentationExtId = ConfigurableStack.STACK_PRESENTATION_EXT_ID; >+ IExtensionPoint point = registry.getExtensionPoint( stackPresentationExtId ); >+ if( point != null ) { >+ IConfigurationElement[] elements = point.getConfigurationElements(); >+ >+ String savedStackId = ConfigurableStack.getSavedStackId( site ); >+ >+ boolean error = false; >+ boolean found = false; >+ for( int i = 0; !error && !found && i < elements.length; i++ ) { >+ >+ String id = elements[ i ].getAttribute( "id" ); >+ String presentationType = elements[ i ].getAttribute( "type" ); >+ >+ if( savedStackId.equals( IPreferenceStore.STRING_DEFAULT_DEFAULT ) ) { >+ // No id is saved, check branding Presentationfactory >+ if( brandingPresentationFactoryExists() ) { >+ ConfigurableStack tempStack = loadStackFromBranding(); >+ if( tempStack != null ) { >+ result = tempStack; >+ currentId = id; >+ } else { >+ result = null; >+ } >+ found = true; >+ } else { >+ result = null; >+ found = true; >+ } >+ >+ } else { >+ // their is a saved id, loading the stackPresentation if the id >+ // matches the saved id >+ if( id.equals( savedStackId ) && presentationType.equals( type ) ) { >+ result = createStackById( id ); >+ currentId = id; >+ found = true; >+ } >+ } >+ >+ } >+ } >+ return result; >+ } >+ >+ public void movePart( final IPresentablePart toMove, final Object cookie ) { >+ getDelegate().movePart( toMove, cookie ); >+ } >+ >+ public void refreshStack() { >+ if( !currentId.equals( "" ) ) { >+ setCurrentStackPresentation( currentId ); >+ } >+ >+ } >+ >+ public void removePart( final IPresentablePart oldPart ) { >+ getDelegate().removePart( oldPart ); >+ } >+ >+ public void restoreState( >+ final IPresentationSerializer context, final IMemento memento ) >+ { >+ getDelegate().restoreState( context, memento ); >+ } >+ >+ public void saveState( >+ final IPresentationSerializer context, final IMemento memento ) >+ { >+ getDelegate().saveState( context, memento ); >+ } >+ >+ public void selectPart( final IPresentablePart toSelect ) { >+ getDelegate().selectPart( toSelect ); >+ } >+ >+ public void setActive( final int newState ) { >+ getDelegate().setActive( newState ); >+ } >+ >+ public void setBounds( final Rectangle bounds ) { >+ getDelegate().setBounds( bounds ); >+ } >+ >+ public void setCurrentStackPresentation( final String id ) { >+ >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String stackPresentationExtId = ConfigurableStack.STACK_PRESENTATION_EXT_ID; >+ IExtensionPoint point >+ = registry.getExtensionPoint( stackPresentationExtId ); >+ >+ IConfigurationElement elements[] = point.getConfigurationElements(); >+ >+ Object stackObj = null; >+ for( int i = 0; stackObj == null && i < elements.length; i++ ) { >+ String attributeId = elements[ i ].getAttribute( "id" ); >+ if( attributeId.equals( id ) ) { >+ currentId = id; >+ try { >+ Rectangle bounds = currentStackPresentation.getControl().getBounds(); >+ >+ stackObj = elements[ i ].createExecutableExtension( "class" ); >+ if( stackObj instanceof ConfigurableStack ) { >+ >+ ConfigurableStack newStackPresentation >+ = ( ConfigurableStack ) stackObj; >+ newStackPresentation.init( site, id, parent, this ); >+ >+ >+ Control control = currentStackPresentation.getControl(); >+ control.dispose(); >+ >+ IPresentablePart[] parts = site.getPartList(); >+ for( int j = 0; j < parts.length; j++ ) { >+ newStackPresentation.addPart( parts[ j ], null ); >+ currentStackPresentation.removePart( parts[ j ] ); >+ } >+ newStackPresentation.selectPart( site.getSelectedPart() ); >+ >+ currentStackPresentation.getControl().dispose(); >+ currentStackPresentation.dispose(); >+ currentStackPresentation = newStackPresentation; >+ currentStackPresentation.setBounds( bounds ); >+ >+ } >+ } catch( CoreException e ) { >+ e.printStackTrace(); >+ } >+ >+ } >+ } >+ >+ } >+ >+ protected void setShowTitle( boolean showTitle ) { >+ this.showTitle = showTitle; >+ } >+ >+ public void setState( final int state ) { >+ getDelegate().setState( state ); >+ } >+ >+ public void setVisible( final boolean isVisible ) { >+ getDelegate().setVisible( isVisible ); >+ } >+ >+ public void showPaneMenu() { >+ getDelegate().showPaneMenu(); >+ } >+ >+ public void showPartList() { >+ getDelegate().showPartList(); >+ } >+ >+ public void showSystemMenu() { >+ getDelegate().showSystemMenu(); >+ } >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/LayoutSet.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/LayoutSet.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/LayoutSet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/LayoutSet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,157 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign.layout.model; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.rap.ui.interactiondesign.layout.ElementBuilder; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.layout.FormData; >+ >+/** >+ * A <code>LayoutSet</code> object can hold different components for a <code> >+ * {@link ElementBuilder}</code>. These can be <code>Image</code>, <code>Color >+ * </code>, <code>Font</code> and <code>FormData</code> objects. >+ * <p> >+ * Actually this class it's just a container for additional objects. >+ * </p> >+ * >+ * @since 1.2 >+ * >+ * @see ElementBuilder >+ */ >+public class LayoutSet { >+ >+ private String id; >+ private Map imageMap = new HashMap(); >+ private Map fontMap = new HashMap(); >+ private Map colorMap = new HashMap(); >+ private Map positionMap = new HashMap(); >+ >+ /** >+ * Instantiate an object of this class with a given id. This id is contributed >+ * in the attributes of the <code>org.eclipse.ui.presentations.Layouts >+ * </code> extension point. >+ * >+ * @param id the id of the <code>LayoutSet</code> >+ */ >+ public LayoutSet( final String id ) { >+ this.id = id; >+ } >+ >+ /** >+ * Adds a <code>Color</code> object. The object is couples to a key, which >+ * is defined by the <code>{@link ElementBuilder}</code> implementation. >+ * >+ * @param key the key for the <code>color</code> object. >+ * @param color the <code>Color</code> object to add. >+ * >+ * @see ElementBuilder >+ */ >+ public void addColor( final String key, final Color color ) { >+ colorMap.put( key, color ); >+ } >+ >+ /** >+ * Adds a <code>Font</code> object. The object is couples to a key, which >+ * is defined by the <code>{@link ElementBuilder}</code> implementation. >+ * >+ * @param key the key for the <code>Font</code> object. >+ * @param font the <code>Font</code> object to add. >+ * >+ * @see ElementBuilder >+ */ >+ public void addFont( final String key, final Font font ) { >+ fontMap.put( key, font ); >+ } >+ >+ /** >+ * Adds a path of a image. This path is coupled to a key, which is defined by >+ * the <code>{@link ElementBuilder}</code> implementation. The path of the >+ * image should be relative to the plug-in root, which the image belongs to. >+ * >+ * @param key the key for the image path. >+ * @param imagePath the relative image path. >+ * >+ * @see ElementBuilder >+ */ >+ public void addImagePath( final String key, final String imagePath ) { >+ imageMap.put( key, imagePath ); >+ } >+ >+ /** >+ * Adds a <code>FormData</code> object. The object is couples to a key, which >+ * is defined by the <code>{@link ElementBuilder}</code> implementation. >+ * >+ * @param key the key for the <code>FormData</code> object. >+ * @param position the <code>FormData</code> object to add. >+ * >+ * @see ElementBuilder >+ */ >+ public void addPosition( final String key, final FormData position ) { >+ positionMap.put( key, position ); >+ } >+ >+ /** >+ * Returns the <code>Color</code> object for the given key. >+ * >+ * @param key the key for the <code>Color</code> object. >+ * >+ * @return the <code>Color</code> object. >+ */ >+ public Color getColor( final String key ) { >+ return ( Color ) colorMap.get( key ); >+ } >+ >+ /** >+ * Returns the <code>Font</code> object for the given key. >+ * >+ * @param key the key for the <code>Font</code> object. >+ * >+ * @return the <code>Font</code> object. >+ */ >+ public Font getFont( final String key ) { >+ return ( Font ) fontMap.get( key ); >+ } >+ >+ /** >+ * Returns the id of a <code>LayoutSet</code> object. >+ * >+ * @return the id. >+ */ >+ public String getId() { >+ return id; >+ } >+ >+ /** >+ * Returns the image path for the given key. >+ * >+ * @param key the key for the image path. >+ * >+ * @return the recursive image path. >+ */ >+ public String getImagePath( final String key ) { >+ return ( String ) imageMap.get( key ); >+ } >+ >+ /** >+ * Returns the <code>FormData</code> object for the given key. >+ * >+ * @param key the key for the <code>FormData</code> object. >+ * >+ * @return the <code>FormData</code> object. >+ */ >+ public FormData getPosition( final String key ) { >+ return ( FormData ) positionMap.get( key ); >+ } >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStack.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStack.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStack.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurableStack.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,540 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IContributionItem; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.jface.internal.provisional.action.IToolBarManager2; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IViewSite; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.DefaultStackPresentationSite; >+import org.eclipse.ui.internal.LayoutPart; >+import org.eclipse.ui.internal.PartPane; >+import org.eclipse.ui.internal.WorkbenchPage; >+import org.eclipse.ui.internal.presentations.PresentablePart; >+import org.eclipse.ui.internal.util.PrefUtil; >+import org.eclipse.ui.part.ViewPart; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+import org.eclipse.ui.preferences.ScopedPreferenceStore; >+import org.eclipse.ui.presentations.IPartMenu; >+import org.eclipse.ui.presentations.IPresentablePart; >+import org.eclipse.ui.presentations.IStackPresentationSite; >+import org.eclipse.ui.presentations.StackPresentation; >+ >+/** >+ * This represents an object, which extends the original <code> >+ * {@link StackPresentation}</code>. >+ * <p> >+ * You can do everything with this as you can do with the original one. It >+ * just provides more methods for making a StackPresentation configurable. >+ * </p> >+ * >+ * @see StackPresentation >+ * @since 1.3 >+ */ >+public abstract class ConfigurableStack extends StackPresentation { >+ >+ /** >+ * Extension Point ID of the StackPresentation Extension point. >+ */ >+ public static final String STACK_PRESENTATION_EXT_ID >+ = "org.eclipse.rap.ui.stackPresentations"; >+ >+ private static final String CONFIG_ACTION_NAME = "actionClass"; >+ >+ private static IStackPresentationSite siteDummy >+ = new IStackPresentationSite() >+ { >+ >+ public void addSystemActions( IMenuManager menuManager ) { >+ >+ } >+ >+ public void close( IPresentablePart[] toClose ) { >+ >+ } >+ >+ public void dragStart( IPresentablePart beingDragged, >+ Point initialPosition, >+ boolean keyboard ) >+ { >+ >+ } >+ >+ public void dragStart( Point initialPosition, boolean keyboard ) { >+ >+ } >+ >+ public void flushLayout() { >+ >+ } >+ >+ public IPresentablePart[] getPartList() { >+ return null; >+ } >+ >+ public String getProperty( String id ) { >+ return null; >+ } >+ >+ public IPresentablePart getSelectedPart() { >+ return null; >+ } >+ >+ public int getState() { >+ return 0; >+ } >+ >+ public boolean isCloseable( IPresentablePart toClose ) { >+ return false; >+ } >+ >+ public boolean isPartMoveable( IPresentablePart toMove ) { >+ return false; >+ } >+ >+ public boolean isStackMoveable() { >+ return false; >+ } >+ >+ public void selectPart( IPresentablePart toSelect ) { >+ >+ } >+ >+ public void setState( int newState ) { >+ >+ } >+ >+ public boolean supportsState( int state ) { >+ return false; >+ } >+ >+ }; >+ /** >+ * This method is used for getting the <code>{@link LayoutPart}</code> ID for >+ * a specific <code>IStackPresentationSite</code>. Their is no other >+ * oppertunity to get this id. >+ * >+ * @param site an instance of <code>IStackPreentationSite</code>. >+ * >+ * @return the unique <code>LayoutPart</code> ID defined in a Perspective or >+ * <code>null</code> if their is no id. >+ * >+ * @see LayoutPart >+ * @see IStackPresentationSite >+ */ >+ public static final String getLayoutPartId( >+ final IStackPresentationSite site ) >+ { >+ String result = null; >+ if( site != null && site instanceof DefaultStackPresentationSite ) { >+ DefaultStackPresentationSite defaultSite >+ = ( DefaultStackPresentationSite) site; >+ result = defaultSite.getProperty( "id" ); >+ } >+ return result; >+ } >+ /** >+ * Loads the saved <code>ConfigurableStack</code> id from the preferences >+ * store using a specific <code>IStackPresentationSite</code>. This id is >+ * needed to instantiate the <code>ConfigurableStack</code> for a specific >+ * LayoutPart. >+ * >+ * @param site an instance of <code>IStackPreentationSite</code>. >+ * >+ * @return the saved <code>ConfigurableStack</code> id for the part >+ * represented by the <code>IStackPresentationSite</code> or <code>null</code> >+ * if no id is saved. >+ * >+ * @see LayoutPart >+ * @see IStackPresentationSite >+ */ >+ public static String getSavedStackId( final IStackPresentationSite site ) { >+ String layoutPartId = null; >+ String result = IPreferenceStore.STRING_DEFAULT_DEFAULT; >+ >+ layoutPartId = getLayoutPartId( site ); >+ >+ if( layoutPartId != null ) { >+ ScopedPreferenceStore prefStore >+ = ( ScopedPreferenceStore )PrefUtil.getAPIPreferenceStore(); >+ String stackPresentationId = ConfigurableStackProxy.STACK_PRESENTATION_ID; >+ String stackPresentationKey = stackPresentationId + "/" + layoutPartId; >+ result = prefStore.getString( stackPresentationKey ); >+ } >+ >+ return result; >+ } >+ private IStackPresentationSite site; >+ private String stackPresentationId; >+ >+ private Composite parent; >+ private ConfigurableStackProxy proxy; >+ >+ >+ private ConfigurationAction configAction; >+ >+ protected ImageDescriptor menuIcon; >+ >+ /** >+ * Instantiate an object of this class by calling the super constructor with >+ * a dummy <code>{@link IStackPresentationSite}</code>. >+ * >+ * @see IStackPresentationSite >+ */ >+ public ConfigurableStack() { >+ super( siteDummy ); >+ } >+ >+ Control createPartToolBar() { >+ Control result = null; >+ IToolBarManager manager = getPartToolBarManager(); >+ ConfigurationAction action = getConfigAction(); >+ IStackPresentationSite site = getSite(); >+ int actionCount = 0; >+ if( action != null && manager != null ) { >+ >+ IContributionItem[] items = manager.getItems(); >+ String paneId = getPaneId( site ); >+ >+ Composite toolBarParent = null; >+ IPresentablePart selectedPart = site.getSelectedPart(); >+ if( selectedPart instanceof PresentablePart ) { >+ PresentablePart part = ( PresentablePart ) selectedPart; >+ Control nativeToolBar = part.getPane().getToolBar(); >+ if( nativeToolBar != null ) { >+ nativeToolBar.setVisible( false ); >+ toolBarParent = nativeToolBar.getParent(); >+ } >+ >+ } >+ if( toolBarParent == null ) { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow(); >+ IWorkbenchPage activePage = activeWindow.getActivePage(); >+ if( activePage instanceof WorkbenchPage ) { >+ toolBarParent = ( ( WorkbenchPage ) activePage ).getClientComposite(); >+ } >+ } >+ >+ for( int i = 0; i < items.length; i++ ) { >+ items[ i ].setVisible( true ); >+ } >+ >+ if( toolBarParent != null ) { >+ IToolBarManager2 toolBarManager = null; >+ if( items.length > 0 && ( manager instanceof IToolBarManager2 ) ) { >+ toolBarManager = ( IToolBarManager2 ) manager; >+ result = toolBarManager.createControl2( toolBarParent ); >+ toolBarManager.update( false ); >+ } >+ >+ for( int i = 0; i < items.length; i++ ) { >+ if( items[ i ] instanceof ActionContributionItem ) { >+ ActionContributionItem actionItem >+ = ( ActionContributionItem ) items[ i ]; >+ String actionId = actionItem.getAction().getId(); >+ boolean isVisible >+ = action.loadViewActionVisibility( paneId, actionId ); >+ >+ if( isVisible ) { >+ actionItem.setVisible( true ); >+ actionCount++; >+ } else { >+ actionItem.setVisible( false ); >+ } >+ } >+ } >+ >+ if( toolBarManager != null && result != null ) { >+ toolBarManager.update( false ); >+ } >+ >+ } >+ if( actionCount <= 0 ) { >+ result = null; >+ } >+ if( result != null ) { >+ result.pack(); >+ result.setVisible( true ); >+ } >+ } >+ >+ return result; >+ } >+ >+ IPartMenu createViewMenu() { >+ >+ IPartMenu result = null; >+ if( isPartMenuVisisble() ) { >+ result = new IPartMenu() { >+ public void showMenu(Point location) { >+ IPresentablePart selectedPart = site.getSelectedPart(); >+ if( selectedPart instanceof PresentablePart ) { >+ PresentablePart part = ( PresentablePart ) selectedPart; >+ part.getPane().showViewMenu(location); >+ } >+ } >+ }; >+ } >+ return result; >+ } >+ >+ /** >+ * Returns an instance of <code>{@link ConfigurationAction}</code> for this >+ * <code>ConfigurableStack</code> object, which is declared over the same >+ * extension. >+ * >+ * @return the <code>ConfigurationAction</code> or <code>null</code> if no >+ * action is declared for the id holding by this object. >+ * >+ * @see ConfigurationAction >+ */ >+ public ConfigurationAction getConfigAction() { >+ ConfigurationAction result = null; >+ if( configAction == null ) { >+ if( stackPresentationId != null && !stackPresentationId.equals( "" ) ) { >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String stackId = STACK_PRESENTATION_EXT_ID; >+ IExtensionPoint point = registry.getExtensionPoint( stackId ); >+ >+ if( point != null ) { >+ IConfigurationElement[] elements = point.getConfigurationElements(); >+ String defaultValue = IPreferenceStore.STRING_DEFAULT_DEFAULT; >+ String actionClass = defaultValue; >+ >+ boolean breakValue = true; >+ IConfigurationElement element = null; >+ ImageDescriptor imageDesc = null; >+ for( int i = 0; breakValue && i < elements.length; i++ ) { >+ String id = elements[ i ].getAttribute( "id" ); >+ >+ >+ if( id.equals( stackPresentationId ) ) { >+ >+ actionClass = elements[ i ].getAttribute( CONFIG_ACTION_NAME ); >+ if( !actionClass.equals( defaultValue ) ) { >+ breakValue = false; >+ element = elements[ i ]; >+ String actionImage = element.getAttribute( "actionIcon" ); >+ String menuImage = element.getAttribute( "menuIcon" ); >+ String contributerId = element.getContributor().getName(); >+ imageDesc >+ = AbstractUIPlugin.imageDescriptorFromPlugin( contributerId, >+ actionImage ); >+ menuIcon >+ = AbstractUIPlugin.imageDescriptorFromPlugin( contributerId, >+ menuImage ); >+ } >+ } >+ } >+ >+ String defaultStore = IPreferenceStore.STRING_DEFAULT_DEFAULT; >+ if( actionClass != null && !actionClass.equals( defaultStore ) >+ && element != null ) >+ { >+ try { >+ Object obj >+ = element.createExecutableExtension( CONFIG_ACTION_NAME ); >+ if( obj instanceof ConfigurationAction ) { >+ configAction = ( ConfigurationAction ) obj; >+ configAction.init( getSite(), this ); >+ if( imageDesc != null ) { >+ configAction.setImageDescriptor( imageDesc ); >+ } >+ } >+ >+ } catch( CoreException e ) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ } >+ } >+ result = configAction; >+ >+ return result; >+ } >+ >+ /** >+ * This method returns the <code>{@link PartPane}</code> id defined in the >+ * selected <code>{@link PresentablePart}</code> of a >+ * <code>IStackPresentationSite</code> instance. >+ * >+ * @param site an instance of <code>IStackPresentationSite</code> >+ * >+ * @return the id of the <code>PartPane</code> from the selected >+ * <code>PresentablePart</code> or an empty String if no part is selected. >+ * >+ * @see PartPane >+ * @see PresentablePart >+ * @see IStackPresentationSite >+ */ >+ public final String getPaneId( final IStackPresentationSite site ) { >+ String result = ""; >+ IPresentablePart selectedPart = site.getSelectedPart(); >+ if( selectedPart instanceof PresentablePart ) { >+ PresentablePart part = ( PresentablePart ) selectedPart; >+ result = part.getPane().getID(); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns the parent composite for this kind of <code>StackPresentation >+ * </code>. >+ * @return the parent composite >+ */ >+ protected Composite getParent() { >+ return parent; >+ } >+ >+ /** >+ * This method returns the <code>{@link IToolBarManager}</code> for the >+ * selected <code>{@link ViewPart}</code>. >+ * >+ * @return the <code>IToolBarManager</code> or <code>null</code> if their is >+ * no <code>ViewPart</code> selected. >+ * >+ * @see IToolBarManager >+ * @see ViewPart >+ */ >+ public IToolBarManager getPartToolBarManager() { >+ IToolBarManager result = null; >+ IStackPresentationSite site = getSite(); >+ String paneId = getPaneId( site ); >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); >+ IWorkbenchPage activePage = window.getActivePage(); >+ if( activePage != null ) { >+ IViewPart viewPart = activePage.findView( paneId ); >+ >+ IActionBars bars = null; >+ if( viewPart != null ) { >+ IViewSite viewSite = ( IViewSite ) viewPart.getSite(); >+ bars = viewSite.getActionBars(); >+ result = bars.getToolBarManager(); >+ } >+ } >+ return result; >+ } >+ >+ >+ >+ /** >+ * If this Stack is from the type standaloneview, than it will have an >+ * attribute called showTitle. This is a parameter of the crate method in the >+ * original <code>AbstractPresentationFactory</code>. This is just a separate >+ * method, because the creation is now automated and using proxy objects. >+ * To match the old behaviour, thsi method was introduced. >+ * @return the showTitle flag for the standalone view. If the view is not >+ * standalone, it will return allways <code>false</code>. >+ */ >+ protected boolean getShowTitle() { >+ return proxy.getShowTitle(); >+ } >+ >+ /** >+ * Returns the <code>{@link IStackPresentationSite}</code> holding by this >+ * instance. >+ * >+ * @return the site used for communication between the presentation and >+ * the workbench. >+ * >+ * @see IStackPresentationSite >+ */ >+ protected IStackPresentationSite getSite() { >+ return site; >+ } >+ >+ /** >+ * This is called right after all necessary fields are initialized e.g. site, >+ * stackPresentationId, parent and proxy. Subclasses can implement any >+ * initializaion behaviour using this mehtod. >+ */ >+ public abstract void init(); >+ >+ >+ /** >+ * This method is called right after the constructor is called. It's >+ * necessary for creating a <code>ConfigurableStack</code> object over an >+ * extension because the standard <code>StackPresentation</code> has no >+ * parameterless constructor. >+ * <p> >+ * This method just set the mandatory fields. >+ * </p> >+ * >+ * @param site the site used for communication between the presentation and >+ * the workbench. >+ * @param stackId the StackPresentation ID, which is declared in the >+ * Extension. >+ * @param parent the parent composite to use for the presentation's controls. >+ * @param proxy the <code>{@link ConfigurableStackProxy}</code> that holds >+ * this instance. >+ * >+ * @see ConfigurableStackProxy >+ * @see StackPresentation >+ */ >+ public void init( >+ final IStackPresentationSite site, >+ final String stackId, >+ final Composite parent, >+ final ConfigurableStackProxy proxy ) >+ { >+ this.site = site; >+ this.stackPresentationId = stackId; >+ this.parent = parent; >+ this.proxy = proxy; >+ init(); >+ } >+ >+ private boolean isPartMenuVisisble() { >+ boolean result = false; >+ if( configAction != null ) { >+ result = configAction.isPartMenuVisible(); >+ } >+ >+ return result; >+ } >+ >+ /** >+ * Method to change the current StackPresentation of a part. This method just >+ * calls the >+ * <code>{@link ConfigurableStackProxy#setCurrentStackPresentation(String)} >+ * </code> method. >+ * >+ * @param newStackId the id of the stack to change. >+ * >+ * @see ConfigurableStackProxy >+ */ >+ protected void setCurrentStackPresentation( final String newStackId ) { >+ if( proxy != null ) { >+ proxy.setCurrentStackPresentation( newStackId ); >+ } >+ } >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/LayoutRegistry.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/LayoutRegistry.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/LayoutRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/LayoutRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,321 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign.layout; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.rap.ui.interactiondesign.layout.model.ILayoutSetInitializer; >+import org.eclipse.rap.ui.interactiondesign.layout.model.Layout; >+import org.eclipse.rap.ui.interactiondesign.layout.model.LayoutSet; >+import org.eclipse.ui.internal.util.PrefUtil; >+ >+/** >+ * This class represents a singleton object of a registry for >+ * <code>{@link Layout}</code> objects. This will contain all <code>Layout >+ * </code>s, which are contributed to the >+ * <code>org.eclipse.ui.presentations.Layouts</code> extension point. >+ * >+ * @since 1.2 >+ */ >+public class LayoutRegistry { >+ >+ private static LayoutRegistry registry; >+ private String layoutId; >+ private Map layoutMap; >+ private Layout activeLayout; >+ private List builders; >+ >+ /** >+ * This is the default <code>LayoutSet</code> id for the fallback mechanism. >+ */ >+ public static final String DEFAULT_LAYOUT_ID >+ = "org.eclipse.rap.ui.defaultlayout"; >+ >+ private static final String LAYOUT_EXT_ID >+ = "org.eclipse.rap.ui.layouts"; >+ >+ /** >+ * The key for saving key/value pairs of <code>LayoutSet</code>s. >+ */ >+ public static final String SAVED_LAYOUT_KEY = LAYOUT_EXT_ID + ".saved"; >+ >+ /** >+ * Returns the singleton instance of the <code>LayoutRegistry</code> object. >+ * >+ * @return the singleton instance. >+ */ >+ public static LayoutRegistry getInstance() { >+ if( registry == null ) { >+ registry = new LayoutRegistry(); >+ } >+ return registry; >+ } >+ >+ private LayoutRegistry() { >+ layoutId = DEFAULT_LAYOUT_ID; >+ layoutMap = new HashMap(); >+ builders = new ArrayList(); >+ } >+ >+ private void combineLayoutSets( >+ final Layout layout, final Layout defaultLayout, final Layout activeLayout ) >+ { >+ Map defaultLayoutSets = defaultLayout.getLayoutSets(); >+ Map activeLayoutSets = activeLayout.getLayoutSets(); >+ >+ createLayoutSetFromLayout( layout, defaultLayoutSets, defaultLayout ); >+ createLayoutSetFromLayout( layout, activeLayoutSets, activeLayout ); >+ } >+ >+ private Layout createHybridLayout() { >+ Layout result = new Layout( layoutId ); >+ >+ Layout defaultLayout = ( Layout ) layoutMap.get( DEFAULT_LAYOUT_ID ); >+ >+ >+ >+ combineLayoutSets( result, defaultLayout, activeLayout ); >+ >+ return result; >+ } >+ >+ private void createLayoutSetFromLayout( >+ final Layout layout, final Map layoutSets, final Layout oldLayout ) >+ { >+ Object[] keys = layoutSets.keySet().toArray(); >+ for( int i = 0; i < keys.length; i++ ) { >+ String key = ( String ) keys[ i ]; >+ LayoutSet set = ( LayoutSet ) layoutSets.get( key ); >+ layout.clearLayoutSet( key ); >+ layout.addLayoutSet( key, set ); >+ String pluginId = oldLayout.getPluginId( key ); >+ if( pluginId != null ) { >+ layout.setPluginIdForLayoutSet( key, pluginId ); >+ } >+ } >+ } >+ >+ private void createLayoutSets( >+ final IConfigurationElement[] layoutSets, final Layout layout ) >+ { >+ if( layoutSets != null && layoutSets.length > 0 ) { >+ for( int i = 0; i < layoutSets.length; i++ ) { >+ IConfigurationElement layoutSetElement = layoutSets[ i ]; >+ >+ String pluginId = layoutSetElement.getContributor().getName(); >+ String layoutSetId = layoutSetElement.getAttribute( "id" ); >+ >+ layout.clearLayoutSet( layoutSetId ); >+ layout.setPluginIdForLayoutSet( layoutSetId, pluginId ); >+ LayoutSet layoutSet = layout.getLayoutSet( layoutSetId ); >+ >+ try { >+ Object initializer >+ = layoutSetElement.createExecutableExtension( "class" ); >+ if( initializer instanceof ILayoutSetInitializer ) { >+ ILayoutSetInitializer layoutInitializer >+ = ( ILayoutSetInitializer ) initializer; >+ layoutInitializer.initializeLayoutSet( layoutSet ); >+ } >+ >+ } catch( CoreException e ) { >+ e.printStackTrace(); >+ } >+ >+ } >+ } >+ } >+ >+ /** >+ * This method will call the <code>{@link ElementBuilder#dispose()}</code> >+ * for all registered builders. >+ * >+ * @see ElementBuilder#dispose() >+ */ >+ public void disposeBuilders() { >+ for( int i = 0; i < builders.size(); i++ ) { >+ ElementBuilder builder = ( ElementBuilder ) builders.get( i ); >+ builder.dispose(); >+ } >+ } >+ >+ /** >+ * Returns the active <code>Layout</code>. If the active <code>Layout</code> >+ * is not the default <code>Layout</code> then a hybrid <code>Layout</code> >+ * is created. This contains the default <code>Layout</code> and the active >+ * <code>Layout</code>. >+ * <p> >+ * This is necessary because a active layout can override >+ * single <code>LayoutSet</code>s of a <code>Layout</code> but their can also >+ * be <code>LayoutSet</code>s, which the active <code>Layout</code> doesn't >+ * override. >+ * </p> >+ * >+ * @return the active layout containing default <code>LayoutSet</code>s if the >+ * active <code>Layout</code> doesn't override all default <code>LayoutSet >+ * </code>s. >+ * >+ * @see LayoutSet >+ * @see Layout >+ */ >+ public Layout getActiveLayout() { >+ Layout result = activeLayout; >+ if( layoutId.equals( DEFAULT_LAYOUT_ID ) ) { >+ if( result == null ) { >+ result = ( Layout ) layoutMap.get( layoutId ); >+ activeLayout = result; >+ } >+ } else { >+ result = createHybridLayout(); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns an <code>IExtension</code> array, which contains all Layouts >+ * contributed to the <code>org.eclipse.ui.presentations.Layouts</code> >+ * extension point. >+ * >+ * @return all <code>Layout</code>s as an <code>IExtension<code> array. >+ */ >+ public IConfigurationElement[] getLayoutExtensions() { >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IConfigurationElement[] result >+ = registry.getConfigurationElementsFor( LAYOUT_EXT_ID ); >+ return result; >+ } >+ >+ /** >+ * Reads the saved <code>Layout</code> id from a <code>ScopedPreferenceStore >+ * </code>. >+ * >+ * @return the saved <code>Layout</code> id or >+ * <code>{@link IPreferenceStore#STRING_DEFAULT_DEFAULT}</code> if no id is >+ * saved. >+ */ >+ public String getSavedLayoutId() { >+ String result = IPreferenceStore.STRING_DEFAULT_DEFAULT; >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ result = preferenceStore.getString( SAVED_LAYOUT_KEY ); >+ >+ return result; >+ } >+ >+ /** >+ * Initialize the <code>{@link LayoutSet}</code> contributed to the >+ * <code>org.eclipse.ui.presentations.Layouts</code> extension point. >+ * Additional it sets the active <code>Layout</code> to >+ * <code>{#DEFAULT_LAYOUT_ID}</code>. >+ */ >+ public void init() { >+ IConfigurationElement[] elements = getLayoutExtensions(); >+ for( int i = 0; i < elements.length; i++ ) { >+ >+ String id = elements[ i ].getAttribute( "id" ); >+ >+ Layout layout = ( Layout ) layoutMap.get( id ); >+ IConfigurationElement[] layoutSets >+ = elements[ i ].getChildren( "layoutSet" ); >+ >+ if( layout == null ) { >+ layout = initLayout( layoutSets, id ); >+ layoutMap.put( id, layout ); >+ } else { >+ createLayoutSets( layoutSets, layout ); >+ } >+ >+ } >+ } >+ >+ private Layout initLayout( >+ final IConfigurationElement[] configurationElements, final String id ) >+ { >+ Layout result = ( Layout ) layoutMap.get( id ); >+ if( result == null ) { >+ result = new Layout( id ); >+ >+ } >+ createLayoutSets( configurationElements, result ); >+ >+ return result; >+ } >+ >+ /** >+ * This method is called, if the active <code>Layout</code> has changed. It >+ * will call <code>{@link ElementBuilder#dispose()}</code> for all registered >+ * builders. >+ * >+ * @see ElementBuilder#dispose() >+ */ >+ public void notifyLayoutChanged() { >+ disposeBuilders(); >+ } >+ >+ /** >+ * Adds a <code>{@link ElementBuilder}</code> to a List of builders. >+ * >+ * @param builder a instance of a <code>ElementBuilder</code> >+ * >+ * @see ElementBuilder >+ */ >+ public void registerBuilder( final ElementBuilder builder ) { >+ builders.add( builder ); >+ } >+ >+ /** >+ * Saves the new <code>Layout</code> id in a >+ * <code>ScopedPreferenceStore</code>. >+ * >+ * @param id the new <code>Layout</code> id to save. >+ */ >+ public void saveLayoutId( final String id ) { >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ preferenceStore.putValue( SAVED_LAYOUT_KEY, id ); >+ preferenceStore.firePropertyChangeEvent( SAVED_LAYOUT_KEY, "", id ); >+ } >+ >+ /** >+ * Sets the active <code>Layout</code> to the one, which belongs to the >+ * id in the paramter and save the new id if necessary. >+ * >+ * @param id the new <code>Layout</code> id. >+ * @param save if <code>true</code> then the new <code>Layout</code> will be >+ * saved. >+ */ >+ public void setActiveLayout( final String id, final boolean save ) { >+ Layout newActive = ( Layout ) layoutMap.get( id ); >+ if( newActive != null ) { >+ layoutId = id; >+ activeLayout = newActive; >+ if( save ) { >+ saveLayoutId( layoutId ); >+ } >+ } >+ } >+ >+ /** >+ * Removes a <code>{@link ElementBuilder}</code> from a list of builders. >+ * >+ * @param builder the <code>Elementbuilder</code> to remove. >+ * >+ * @see ElementBuilder >+ */ >+ public void unregisterBuilder( final ElementBuilder builder ) { >+ builders.remove( builder ); >+ } >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,334 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.ui.internal.LayoutPart; >+import org.eclipse.ui.internal.WorkbenchWindow; >+import org.eclipse.ui.internal.presentations.PresentablePart; >+import org.eclipse.ui.internal.util.PrefUtil; >+import org.eclipse.ui.preferences.ScopedPreferenceStore; >+import org.eclipse.ui.presentations.IPresentablePart; >+import org.eclipse.ui.presentations.IStackPresentationSite; >+import org.eclipse.ui.presentations.StackPresentation; >+ >+/** >+ * This represents an object to configure different part properties e.g. >+ * toolitem visibility, viewmenu visibility or the >+ * <code>{@link ConfigurableStack}</code> for a selected part. >+ * <p> >+ * This is a ordinary <code>{@link Action}</code>. The >+ * <code>{@link #run()}</code> method can implement any configuration behaviour >+ * e.g. a PupupDialog. >+ * </p> >+ * <p> >+ * Additional this class provides methods for saving and laoding some >+ * presentation specific properties. >+ * </p> >+ * >+ * @since 1.2 >+ * @see Action >+ * @see ConfigurableStack >+ */ >+public abstract class ConfigurationAction extends Action { >+ >+ /** >+ * Extracts the id of an <code>{@link ActionContributionItem}</code> from a >+ * <code>{@link ToolItem}</code>. >+ * @param item the <code>ToolItem</code>, which holds a >+ * <code>ActionContributionItem</code>. >+ * >+ * @return the extracted id of an >+ */ >+ public static final String getActionIdFromToolItem( final ToolItem item ) { >+ String result = ""; >+ Object data = item.getData(); >+ ActionContributionItem toolBarAction = ( ActionContributionItem ) data; >+ result = toolBarAction.getId(); >+ return result; >+ } >+ private IStackPresentationSite site; >+ >+ private StackPresentation stackPresentation; >+ >+ private List configurationChangeListeners = new ArrayList(); >+ >+ /** >+ * Method to add a <code>{@link IConfigurationChangeListener}. >+ * @param listener an instance of a <code>IConfigurationChangedListener >+ * </code>. >+ * >+ * @see IConfigurationChangeListener >+ */ >+ public void addConfigurationChangeListener( >+ final IConfigurationChangeListener listener ) >+ { >+ configurationChangeListeners.add( listener ); >+ } >+ >+ /** >+ * This method is called if the <code>{@link ConfigurableStack}</code> of a >+ * part has changed. It just calls the >+ * <code>{@link IConfigurationChangeListener#presentationChanged(String)} >+ * </code> method for all listeners added by >+ * <code>{@link #addConfigurationChangeListener(IConfigurationChangeListener)} >+ * </code>. >+ * >+ * @param newId the new <code>ConfigurableStack</code> id to make active. >+ * >+ * @see ConfigurableStack >+ * @see IConfigurationChangeListener >+ */ >+ public void fireLayoutChange( final String newId ) { >+ for( int i = 0; i < configurationChangeListeners.size(); i++ ) { >+ IConfigurationChangeListener listener >+ = ( IConfigurationChangeListener ) configurationChangeListeners.get( i ); >+ listener.presentationChanged( newId ); >+ >+ } >+ } >+ >+ /** >+ * This method can be called if the configuration of the view's toolbar has >+ * been changed. It calls >+ * <code>{@link IConfigurationChangeListener#toolBarChanged()}</code> for all >+ * listeners registered by >+ * <code>{@link #addConfigurationChangeListener(IConfigurationChangeListener)} >+ * </code>. >+ * >+ * @see IConfigurationChangeListener >+ */ >+ public void fireToolBarChange() { >+ for( int i = 0; i < configurationChangeListeners.size(); i++ ) { >+ IConfigurationChangeListener listener >+ = ( IConfigurationChangeListener ) configurationChangeListeners.get( i ); >+ listener.toolBarChanged(); >+ >+ } >+ } >+ >+ private String getActionIdentifier( >+ final String viewId, final String actionId ) >+ { >+ return ConfigurableStackProxy.STACK_PRESENTATION_ID + "/" >+ + viewId + "/" + actionId; >+ } >+ >+ private String getPartMenuIdentifier( final String paneId ) { >+ return ConfigurableStackProxy.STACK_PRESENTATION_ID + "/" >+ + paneId + "/partMenu"; >+ } >+ >+ /** >+ * This method returns the <code>IStackPresentationSite</code> from the >+ * <code>StackPresentation</code>, which belongs to this >+ * <code>ConfigurationAction</code>. >+ * @return the <code>IStackPresentationSite</code> to communicate with the >+ * part. >+ */ >+ protected IStackPresentationSite getSite() { >+ return site; >+ } >+ >+ /** >+ * Return the <code>{@link StackPresentation}</code>, which this action >+ * belongs to. >+ * >+ * @return the <code>StackPresentation</code> object. >+ * >+ * @see ConfigurableStack >+ */ >+ public StackPresentation getStackPresentation() { >+ return stackPresentation; >+ } >+ >+ /** >+ * Checks if the selected part has a menu or not. >+ * >+ * @return <code>true</code> if the selected part has a menu. >+ */ >+ public boolean hasPartMenu() { >+ boolean result = false; >+ IPresentablePart selectedPart = site.getSelectedPart(); >+ if( selectedPart instanceof PresentablePart ) { >+ PresentablePart part = ( PresentablePart ) selectedPart; >+ result = part.getPane().hasViewMenu(); >+ } >+ return result; >+ } >+ >+ /** >+ * This method is called right after the object is instantiated to set >+ * different fields. These fields are necessary to get the needed >+ * information about the current <code>{@link WorkbenchWindow}</code> state >+ * e.g. the selected part or the current <code>{@link ConfigurableStack} >+ * </code>. >+ * >+ * @param site the site used for communication between the presentation and >+ * the workbench. >+ * @param stackPresentation the current <code>{@link StackPresentation}</code> >+ * or <code>ConfigurableStack</code> to get the part's toolbar and so on. >+ * >+ * @see ConfigurableStack >+ * @see IStackPresentationSite >+ * @see StackPresentation >+ */ >+ public void init( >+ final IStackPresentationSite site, >+ final StackPresentation stackPresentation ) >+ { >+ this.site = site; >+ this.stackPresentation = stackPresentation; >+ } >+ >+ /** >+ * Check if the part menu is set visible by the user. >+ * >+ * @return the visibility of the part menu. >+ */ >+ public boolean isPartMenuVisible() { >+ boolean result = false; >+ if( stackPresentation instanceof ConfigurableStack ) { >+ ConfigurableStack configStack = ( ConfigurableStack ) stackPresentation; >+ String paneId = configStack.getPaneId( site ); >+ String identifier = getPartMenuIdentifier( paneId ); >+ result = loadPartmenuVisibility( identifier ); >+ } >+ return result; >+ } >+ >+ private boolean loadPartmenuVisibility( final String identifier ) { >+ boolean result = false; >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ result = preferenceStore.getBoolean( identifier ); >+ return result; >+ } >+ >+ /** >+ * Returns the visibility for an <code>{@link ActionContributionItem}</code>, >+ * which is contributed to a view's toolbar. By default all <code> >+ * ActionContributionItem</code>s are not visible. The visibility is stored >+ * in a <code>ScopedPreferenceStore</code>. >+ * >+ * @param viewId the id of the view that holds the >+ * <code>ActionContributionItem</code>. >+ * @param actionId the unique id of the <code>{@link Action}</code> holding by >+ * an <code>ActionContributionItem</code>. >+ * >+ * @return the visibility of the <code>ActionContributionItem</code>. If no >+ * value is stored, the default value is <code>false</code>. >+ * >+ * @see ActionContributionItem >+ * @see Action >+ * @see ScopedPreferenceStore >+ */ >+ public boolean loadViewActionVisibility( >+ final String viewId, final String actionId ) >+ { >+ boolean result = false; >+ String identifier = getActionIdentifier( viewId, actionId ); >+ >+ ScopedPreferenceStore prefStore >+ = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore(); >+ result = prefStore.getBoolean( identifier ); >+ >+ return result; >+ } >+ >+ /** >+ * Removes a <code>{@link IConfigurationChangeListener}</code> from this >+ * action. >+ * >+ * @param listener the <code>IConfigurationChangeListener</code> to remove. >+ */ >+ public void removeLayoutChangeListener( >+ final IConfigurationChangeListener listener ) >+ { >+ boolean found = false; >+ for( int i = 0; !found && i < configurationChangeListeners.size(); i++ ) { >+ IConfigurationChangeListener current >+ = ( IConfigurationChangeListener ) configurationChangeListeners.get( i ); >+ if( current.equals( listener ) ) { >+ configurationChangeListeners.remove( i ); >+ found = true; >+ } >+ } >+ } >+ >+ /** >+ * Saves the visibility of a part's menu in a >+ * <code>{@link ScopedPreferenceStore}</code>. >+ * >+ * @param visible the new visibility to save. >+ * >+ * @see ScopedPreferenceStore >+ */ >+ public void savePartMenuVisibility( final boolean visible ) { >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ if( stackPresentation instanceof ConfigurableStack ) { >+ ConfigurableStack configStack = ( ConfigurableStack ) stackPresentation; >+ String paneId = configStack.getPaneId( site ); >+ String identifier = getPartMenuIdentifier( paneId ); >+ preferenceStore.setValue( identifier, visible ); >+ } >+ } >+ >+ /** >+ * Saves the <code>{@link ConfigurableStack}</code> id for the selected >+ * <code>{@link LayoutPart}</code>. >+ * >+ * @param id the unique id of the <code>ConfigurableStack</code> to save. >+ * >+ * @see LayoutPart >+ * @see ConfigurableStack >+ */ >+ public void saveStackPresentationId( final String id ) { >+ if( stackPresentation instanceof ConfigurableStack ) { >+ String layoutPartId = ConfigurableStack.getLayoutPartId( site ); >+ if( site != null && layoutPartId != null ) { >+ >+ ScopedPreferenceStore prefStore >+ = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore(); >+ prefStore.setValue( ConfigurableStackProxy.STACK_PRESENTATION_ID + "/" >+ + layoutPartId, >+ id ); >+ } >+ } >+ } >+ >+ /** >+ * Saves the visibility of a view action in a >+ * <code>{@link ScopedPreferenceStore}</code>. >+ * >+ * @param viewId the id of the view, which holds the view's >+ * <code>{@link ActionContributionItem}</code> >+ * @param actionId the id of the <code>ActionContributionItem</code>, which >+ * the new visibility belongs to. >+ * @param visibility the value of the visibility. >+ */ >+ public void saveViewActionVisibility( >+ final String viewId, final String actionId, boolean visibility ) >+ { >+ String identifier = getActionIdentifier( viewId, actionId ); >+ >+ ScopedPreferenceStore prefStore >+ = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore(); >+ >+ prefStore.setValue( identifier, visibility ); >+ >+ } >+ >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/PresentationFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/PresentationFactory.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/PresentationFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/PresentationFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,352 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.internal.provisional.action.ICoolBarManager2; >+import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem; >+import org.eclipse.jface.internal.provisional.action.IToolBarManager2; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.rap.ui.interactiondesign.layout.LayoutRegistry; >+import org.eclipse.rwt.branding.AbstractBranding; >+import org.eclipse.rwt.internal.branding.BrandingUtil; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IWindowListener; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.WorkbenchPage; >+import org.eclipse.ui.internal.WorkbenchWindow; >+import org.eclipse.ui.internal.provisional.presentations.IActionBarPresentationFactory; >+import org.eclipse.ui.internal.util.PrefUtil; >+import org.eclipse.ui.presentations.AbstractPresentationFactory; >+import org.eclipse.ui.presentations.IStackPresentationSite; >+import org.eclipse.ui.presentations.StackPresentation; >+ >+/** >+ * <p> >+ * The <code>PresentationFactory</code> is an enhancement of the original >+ * <code>{@link AbstractPresentationFactory}</code>. This factory provides >+ * many additional possibilities, which the original one doesn't provide. >+ * </p> >+ * <p> >+ * <code>{@link StackPresentation}</code> Objects shall not be created directly >+ * by this factory. Instead their is a new Extension Point for this called >+ * <code>org.eclipse.rap.presentation.stackPresentations</code>. You can >+ * contribute <code>ConfigurableStack</code>s to this now. >+ * </p> >+ * <p> >+ * This Factory controls the appereance of: >+ * <ul> >+ * <li>editors</li> >+ * <li>views</li> >+ * <li>standalone views</li> >+ * <li>view's toolbar</li> >+ * <li>coolbar</li> >+ * <li>menubar</li> >+ * <li>view's toolbar menu</li> >+ * <li>toolbar contribution items</li> >+ * </ul> >+ * It represents one central point for customizing the workbench's window. >+ * </p> >+ * @since 1.2 >+ * >+ * @see ConfigurableStack >+ * @see ConfigurationAction >+ * @see IWindowComposer >+ * @see AbstractPresentationFactory >+ */ >+public abstract class PresentationFactory extends AbstractPresentationFactory >+ implements IActionBarPresentationFactory >+{ >+ >+ private final class windowListener implements IWindowListener { >+ >+ public void windowActivated( IWorkbenchWindow window ) { >+ >+ } >+ >+ public void windowClosed( IWorkbenchWindow window ) { >+ >+ } >+ >+ public void windowDeactivated( IWorkbenchWindow window ) { >+ >+ } >+ >+ public void windowOpened( final IWorkbenchWindow window ) { >+ IPreferenceStore preferenceStore >+ = PrefUtil.getAPIPreferenceStore(); >+ preferenceStore.addPropertyChangeListener( new IPropertyChangeListener() { >+ >+ public void propertyChange( PropertyChangeEvent event ) { >+ String name = event.getProperty(); >+ String layoutKey = LayoutRegistry.SAVED_LAYOUT_KEY; >+ if( name.equals( layoutKey ) ) { >+ workbenchWindowLayoutChanged( window ); >+ } >+ >+ } >+ >+ }); >+ >+ } >+ } >+ >+ /** >+ * The key for an editor <code>ConfigurableStack</code>. >+ */ >+ public static final String KEY_EDITOR = "editor"; >+ >+ /** >+ * The key for a view <code>ConfigurableStack</code>. >+ */ >+ public static final String KEY_VIEW = "view"; >+ >+ /** >+ * The key for a standalone view <code>ConfigurableStack</code>. >+ */ >+ public static final String KEY_STANDALONE_VIEW = "standaloneview"; >+ >+ private List proxyList = new ArrayList(); >+ >+ /** >+ * Constructs a new instance of this class and adds a listener to the >+ * <code>{@link WorkbenchWindow}</code> for changing the window design on the >+ * fly. >+ */ >+ public PresentationFactory() { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ workbench.addWindowListener( new windowListener() ); >+ >+ // load Layout from branding because its too early in the LayoutRegistry >+ String layoutId = loadBrandingLayoutId(); >+ if( layoutId != null ) { >+ LayoutRegistry.getInstance().setActiveLayout( layoutId, false ); >+ } >+ } >+ >+ public abstract ICoolBarManager2 createCoolBarManager(); >+ >+ /** >+ * Creates an editor presentation proxy for presenting editors. >+ * <p> >+ * The presentation creates its controls on the given parent composite. >+ * </p> >+ * <p> >+ * The presentation itself can be contributed to the >+ * extension point >+ * <code>org.eclipse.ui.presentations.StackPresentations</code>. >+ * </p> >+ * >+ * @param parent >+ * the parent composite to use for the presentation's controls. >+ * @param site >+ * the site used for communication between the presentation and >+ * the workbench. >+ * @return a newly created part presentation proxy. >+ */ >+ public final StackPresentation createEditorPresentation( >+ final Composite parent, >+ final IStackPresentationSite site ) >+ { >+ ConfigurableStackProxy result >+ = new ConfigurableStackProxy( parent, site, KEY_EDITOR ); >+ proxyList.add( result ); >+ return result; >+ } >+ >+ /** >+ * Instantiate the <code>{@link MenuManager}</code> object for the window's >+ * menubar. >+ * >+ * @return the menubar manager >+ * >+ * @see MenuManager >+ */ >+ public abstract MenuManager createMenuBarManager(); >+ >+ /** >+ * Instantiate the <code>{@link MenuManager}</code> object for the part's >+ * menu. >+ * >+ * @return the partmenu manager >+ */ >+ public abstract MenuManager createPartMenuManager(); >+ >+ /** >+ * Creates a stack presentation proxy for presenting regular docked views. >+ * <p> >+ * The presentation creates its controls on the given parent composite. >+ * </p> >+ * <p> >+ * The presentation itself can be contributed to the >+ * extension point >+ * <code>org.eclipse.ui.presentations.StackPresentations</code>. >+ * </p> >+ * >+ * @param parent >+ * the parent composite to use for the presentation's controls. >+ * @param site >+ * the site used for communication between the presentation and >+ * the workbench. >+ * @param showTitle >+ * <code>true</code> to show the title for the view, >+ * <code>false</code> to hide it. >+ * @return a newly created part presentation proxy >+ */ >+ public final StackPresentation createStandaloneViewPresentation( >+ final Composite parent, >+ final IStackPresentationSite site, >+ final boolean showTitle ) >+ { >+ ConfigurableStackProxy result >+ = new ConfigurableStackProxy( parent, site, KEY_STANDALONE_VIEW ); >+ if( showTitle ) { >+ result.setShowTitle( showTitle ); >+ } >+ proxyList.add( result ); >+ return result; >+ } >+ >+ public abstract IToolBarContributionItem createToolBarContributionItem( >+ final IToolBarManager toolBarManager, final String id ); >+ >+ public abstract IToolBarManager2 createToolBarManager(); >+ >+ /** >+ * Creates a standalone stack presentation proxy for presenting a standalone >+ * view. A standalone view cannot be docked together with other views. >+ * The title of a standalone view may be hidden. >+ * <p> >+ * The presentation creates its controls on the given parent composite. >+ * </p> >+ * <p> >+ * The presentation itself can be contributed to the >+ * extension point >+ * <code>org.eclipse.ui.presentations.StackPresentations</code>. >+ * </p> >+ * >+ * @param parent >+ * the parent composite to use for the presentation's controls. >+ * @param site >+ * the site used for communication between the presentation and >+ * the workbench. >+ * @return a newly created part presentation proxy. >+ */ >+ public final StackPresentation createViewPresentation( >+ final Composite parent, final IStackPresentationSite site ) >+ { >+ ConfigurableStackProxy result >+ = new ConfigurableStackProxy( parent, site, KEY_VIEW ); >+ proxyList.add( result ); >+ return result; >+ } >+ >+ >+ public abstract IToolBarManager2 createViewToolBarManager(); >+ >+ /** >+ * This method is called within the <code>{@link WorkbenchWindow}</code> to >+ * couple the presentation factory and the design of the >+ * <code>WorkbenchWindow</code>. >+ * >+ * @return a newly created <code>{@link IWindowComposer}</code> object, which >+ * defines the design of a <code>WorkbenchWindow</code>. >+ * >+ * @see IWindowComposer >+ */ >+ public abstract IWindowComposer createWindowComposer( ); >+ >+ private String loadBrandingDefaultLayoutId( >+ final IConfigurationElement element ) >+ { >+ String result = null; >+ IConfigurationElement[] factory >+ = element.getChildren( "presentationFactory" ); >+ if( factory.length > 0 ) { >+ result = factory[ 0 ].getAttribute( "defaultLayoutId" ); >+ } >+ return result; >+ } >+ >+ private String loadBrandingLayoutId() { >+ String result = null; >+ AbstractBranding branding = BrandingUtil.findBranding(); >+ if( branding != null ) { >+ String brandingId = branding.getId(); >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ String id = "org.eclipse.rap.ui.branding"; >+ IExtensionPoint brandingPoint = registry.getExtensionPoint( id ); >+ if( brandingPoint != null ) { >+ IConfigurationElement[] elements >+ = brandingPoint.getConfigurationElements(); >+ boolean found = false; >+ for( int i = 0; i < elements.length && !found; i++ ) { >+ String tempId = elements[ i ].getAttribute( "id" ); >+ if( tempId.equals( brandingId ) ) { >+ found = true; >+ result = loadBrandingDefaultLayoutId( elements[ i ] ); >+ } >+ } >+ } >+ } >+ return result; >+ >+ } >+ >+ private void refreshStackPresentations( ) { >+ for( int i = 0; i < proxyList.size(); i++ ) { >+ ConfigurableStackProxy proxy >+ = ( ConfigurableStackProxy ) proxyList.get( i ); >+ proxy.refreshStack(); >+ } >+ } >+ >+ private void workbenchWindowLayoutChanged( final IWorkbenchWindow window ) { >+ >+ Composite newStackComposite = null; >+ if( window instanceof WorkbenchWindow ) { >+ WorkbenchWindow wbWindow = ( WorkbenchWindow ) window; >+ LayoutRegistry registry = LayoutRegistry.getInstance(); >+ registry.disposeBuilders(); >+ newStackComposite = wbWindow.changeWindowLayoutSet(); >+ >+ } >+ >+ refreshStackPresentations(); >+ >+ IWorkbenchPage activePage = window.getActivePage(); >+ if( activePage instanceof WorkbenchPage ) { >+ WorkbenchPage page = ( WorkbenchPage ) activePage; >+ Composite parent = page.getClientComposite().getParent(); >+ if( parent != null ) { >+ Composite stackComposite = parent.getParent(); >+ if( stackComposite != null && newStackComposite != null ) { >+ stackComposite.setLayoutData( newStackComposite.getLayoutData() ); >+ newStackComposite.getParent().layout( true, true ); >+ newStackComposite.dispose(); >+ } >+ } >+ } >+ } >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/IWindowComposer.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/IWindowComposer.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/IWindowComposer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/IWindowComposer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+ >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.application.IWorkbenchWindowConfigurer; >+import org.eclipse.ui.application.WorkbenchWindowAdvisor; >+ >+/** >+ * This interface is only used to bind some >+ * <code>{@link WorkbenchWindowAdvisor}</code> methods to a presentation. This >+ * is necessary to create components like a header or footer for a RAP >+ * application. But the methods can also be used to customize existing >+ * components like the perspective switcher or the toolbar and so on. >+ * <p> >+ * An instance of this interface is created in the >+ * <code>{@link PresentationFactory#createWindowComposer()}</code> method. >+ * </p> >+ * >+ * @since 1.2 >+ * >+ * @see WorkbenchWindowAdvisor >+ * @see PresentationFactory#createWindowComposer() >+ * >+ */ >+public interface IWindowComposer { >+ >+ /** >+ * Creates the contents of the window. >+ * <p> >+ * The default implementation of the <code>{@link WorkbenchWindowAdvisor} >+ * </code> adds a menu bar, a cool bar, a status line, >+ * a perspective bar, and a fast view bar. The visibility of these controls >+ * can be configured using the <code>setShow*</code> methods on >+ * <code>IWorkbenchWindowConfigurer</code>. >+ * </p> >+ * >+ * @param shell the window's shell >+ * @param configurer the <code>{@link IWorkbenchWindowConfigurer}<code> because >+ * the instance of the configurer is a field in the >+ * <code>WorkbenchWindowAdvisor</code> but not accessable in the >+ * <code>{@link PresentationFactory}</code>. >+ * >+ * @return the result is used to call >+ * <code>{@link IWorkbenchWindowConfigurer#createPageComposite}</code>. >+ * >+ * @see WorkbenchWindowAdvisor#createWindowContents(Shell) >+ * @see IWorkbenchWindowConfigurer#createMenuBar >+ * @see IWorkbenchWindowConfigurer#createCoolBarControl >+ * @see IWorkbenchWindowConfigurer#createStatusLineControl >+ * @see IWorkbenchWindowConfigurer#createPageComposite >+ * @see PresentationFactory#createWindowComposer() >+ */ >+ public Composite createWindowContents( >+ final Shell shell, final IWorkbenchWindowConfigurer configurer ); >+ >+ /** >+ * @see WorkbenchWindowAdvisor#postWindowCreate() >+ * @param configurer the <code>{@link IWorkbenchWindowConfigurer}<code> >+ * because the instance of the configurer is a field in the >+ * <code>WorkbenchWindowAdvisor</code> but not accessable in the >+ * <code>{@link PresentationFactory}</code>. >+ */ >+ public void postWindowCreate( final IWorkbenchWindowConfigurer configurer ); >+ >+ /** >+ * @see WorkbenchWindowAdvisor#preWindowOpen() >+ * >+ * @param configurer the <code>{@link IWorkbenchWindowConfigurer}<code> >+ * because the instance of the configurer is a field in the >+ * <code>WorkbenchWindowAdvisor</code> but not accessable in the >+ * <code>{@link PresentationFactory}</code>. >+ */ >+ public void preWindowOpen( final IWorkbenchWindowConfigurer configurer ); >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/ElementBuilder.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/ElementBuilder.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/ElementBuilder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/ElementBuilder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,292 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign.layout; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.rap.ui.interactiondesign.layout.model.Layout; >+import org.eclipse.rap.ui.interactiondesign.layout.model.LayoutSet; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+ >+/** >+ * A <code>ElementBuilder</code> represents the super class for all custom >+ * builders. With a custom builder you can construct complex objects e.g. a >+ * header, which needs nine or less images and additional information about >+ * placing logos or other images. >+ * <p> >+ * To fit as much as possible patterns of web components we introduce this >+ * <code>ElementBuilder</code>. This concept use the builder design pattern. >+ * So, an instantiation can look like: <code>ElementBuilder builder = new >+ * HeaderBuilder(param, param)</code>. The benefit of this technique is, that >+ * you can work against a defined api and you can change the implementation >+ * easily. >+ * </p> >+ * <p> >+ * Every builder needs a <code>{@link LayoutSet}</code>, which can be >+ * contributed to the <code>org.eclipse.ui.presentations.Layouts</code> >+ * extension point. >+ * </p> >+ * The point is, every builder should regard, that a <code>LayoutSet</code> >+ * can define more or less images depending on the contribution in the >+ * extension. E.g. a header can hold nine images, but i also can hold just >+ * three. So, the builder have to look that the component is build correctly. >+ * </p> >+ * >+ * @since 1.2 >+ * >+ * @see LayoutSet >+ */ >+public abstract class ElementBuilder { >+ >+ private Composite parent; >+ private Layout layout; >+ private LayoutSet layoutSet; >+ >+ /** >+ * This constructor stores the parent composite and instantiate a >+ * <code>{@link LayoutSet}</code> for this instance. The <code>LayoutSet >+ * </code> can be used to create images, fonts, colors or postion data. >+ * This depends on what is defined for a specific builder. >+ * <p> >+ * Subclasses have to call this constructor because it register the object >+ * in the <code>{@link LayoutRegistry}</code> >+ * </p> >+ * >+ * @param parent the parent <code>{@link Composite}</code> for the component >+ * to build. >+ * @param layoutSetId the id of the <code>LayoutSet</code>, which belongs to >+ * this instance. >+ * >+ * @see LayoutSet >+ * @see LayoutRegistry#registerBuilder(ElementBuilder) >+ * @see Composite >+ */ >+ public ElementBuilder( final Composite parent, final String layoutSetId ) >+ { >+ this.parent = parent; >+ LayoutRegistry registry = LayoutRegistry.getInstance(); >+ String savedLayoutId = registry.getSavedLayoutId(); >+ if( !savedLayoutId.equals( IPreferenceStore.STRING_DEFAULT_DEFAULT ) ) { >+ registry.setActiveLayout( savedLayoutId, false ); >+ } >+ layout = registry.getActiveLayout(); >+ if( layout != null ) { >+ layoutSet = layout.getLayoutSet( layoutSetId ); >+ registry.registerBuilder( this ); >+ } else { >+ throw new IllegalArgumentException( "no layout registered with default " + >+ "id (LayoutRegistry.DEFAULT_LAYOUT_ID) or no layout activated " + >+ "over branding extension." ); >+ } >+ } >+ >+ >+ /** >+ * Clients can call this method to add non standard components to the builder >+ * e.g. a logo placed on a label to show in a header. >+ * <p> >+ * So, subclasses can implement or ignore this method depending on their >+ * needs. >+ * </p> >+ * <p> >+ * Clients have to call this method before calling >+ * <code>{@link #build()}</code>. >+ * </p> >+ * >+ * @param control an instance of a <code>Cotrol</code> e.g. a <code>Composite >+ * </code> containing a image. >+ * @param layoutData can be any position information for the control. >+ * Usually it's a instance of <code>FormData</code>. >+ * >+ * @see FormData >+ * @see GridData >+ */ >+ public abstract void addControl( >+ final Control control, final Object layoutData ); >+ >+ /** >+ * This method do the same as <code>{@link #addControl(Control, Object)} >+ * </code>. The only difference is, that the position information can be >+ * loaded by the <code>{@link LayoutSet#getPosition(String)}</code> >+ * method. >+ * >+ * @param control an instance of a <code>Control</code> e.g. a <code>Composite >+ * </code> containing an image. >+ * @param positionId the unique id of a position data holding by the <code> >+ * LayoutSet</code> for this object. >+ * >+ * @see LayoutSet#getPosition(String) >+ * @see LayoutSet#addPosition(String, FormData) >+ */ >+ public abstract void addControl( >+ final Control control, final String positionId ); >+ >+ /** >+ * Subclasses can implement this method and process it. E.g. if a client >+ * want to add a logo for a header directly and not over the >+ * <code>{@link #addControl(Control, Object)}</code> method in a >+ * <code>Composite</code>. >+ * >+ * @param image an instance of a <code>Image</code> to add. >+ * @param layoutData can be any position information for the <code>Image</code>. >+ * Usually it's an instance of <code>FormData</code>. >+ * >+ * @see FormData >+ * @see GridData >+ */ >+ public abstract void addImage( final Image image, final Object layoutData ); >+ >+ /** >+ * This method do the same as <code>{@link #addImage(Image, Object)}</code>. >+ * The only difference is, that the position information can be >+ * loaded by the <code>{@link LayoutSet#getPosition(String)}</code> >+ * method. >+ * >+ * @param image an instance of an <code>Image</code> to add. >+ * @param positionId the unique id of a position data holding by the <code> >+ * LayoutSet</code> for this object. >+ * >+ * @see LayoutSet#getPosition(String) >+ * @see LayoutSet#addPosition(String, FormData) >+ */ >+ public abstract void addImage( final Image image, final String positionId ); >+ >+ /** >+ * This is the most important method in a builder. If a client call this, the >+ * builder have to build the needed component e.g. a header or footer >+ * regarding the defined <code>LayoutSet</code>. >+ */ >+ public abstract void build(); >+ >+ /** >+ * Subclasses can use this method to create an image by means of it's path in >+ * the <code>LayoutSet</code>. >+ * >+ * @param path the path for the image to create. >+ * >+ * @return the created image. >+ * >+ * @see LayoutSet#addImagePath(String, String) >+ * @see LayoutSet#getImagePath(String) >+ */ >+ protected Image createImage( final String path ) { >+ Image result = null; >+ if( path != null ) { >+ String id = layout.getPluginId( layoutSet.getId() ); >+ ImageDescriptor descriptor >+ = AbstractUIPlugin.imageDescriptorFromPlugin( id, path ); >+ result = descriptor.createImage(); >+ } >+ return result; >+ } >+ >+ /** >+ * Subclasses should dispose all created or rather added <code>Control</code>s >+ * and <code>Image</code>s in this method. >+ */ >+ public abstract void dispose(); >+ >+ /** >+ * Returns a <code>Color</code> object by it's id defined in the >+ * <code>LayoutSet</code> >+ * >+ * @param colorId the id of the color. >+ * >+ * @return the created <code>Color</code> object. >+ * >+ * @see LayoutSet#addColor(String, Color) >+ * @see LayoutSet#getColor(String) >+ */ >+ public Color getColor( final String colorId ) { >+ return layoutSet.getColor( colorId ); >+ } >+ >+ /** >+ * Subclasses should implement this method to return the component, >+ * which is created during the <code>{@link #build()}</code> call. >+ * >+ * @return the <code>{@link Control}</code> created in the >+ * <code>{@link #build()}</code> method. >+ */ >+ public abstract Control getControl(); >+ >+ /** >+ * Returns a <code>Font</code> object by it's id defined in the >+ * <code>LayoutSet</code> >+ * >+ * @param fontID the id of the font. >+ * >+ * @return the created font object. >+ * >+ * @see LayoutSet#addFont(String, Font) >+ * @see LayoutSet#getFont(String) >+ */ >+ public Font getFont( final String fontID ) { >+ return layoutSet.getFont( fontID ); >+ } >+ >+ /** >+ * Return the image by its id in the <code>LayoutSet</code>. This method >+ * just extract the image path and call <code>{@link #createImage(String)} >+ * </code>. >+ * >+ * @param imageId the id of the image defined in the <code>LayoutSet</code>. >+ * >+ * @return the created image. >+ * >+ * @see LayoutSet#getImagePath(String) >+ * @see LayoutSet#addImagePath(String, String) >+ */ >+ public Image getImage( final String imageId ) { >+ Image result = null; >+ String imagePath = layoutSet.getImagePath( imageId ); >+ if( imagePath != null ) { >+ result = createImage( imagePath ); >+ } >+ return result; >+ } >+ >+ /** >+ * This returns the <code>LayoutSet</code> for this builder. The layoutset >+ * contains all images, fonts, formdatas and colors, which are relevant for >+ * the whole builder layout. >+ * @return the <code>LayoutSet</code> object >+ */ >+ protected LayoutSet getLayoutSet() { >+ return layoutSet; >+ } >+ >+ /** >+ * Returns the parent, which was set in <code> >+ * {@link #ElementBuilder(Composite, String)}</code>. >+ * >+ * @return the parent <code>Composite</code>. >+ */ >+ protected Composite getParent() { >+ return parent; >+ } >+ >+ /** >+ * Should return the size from the representative component of the builder. >+ * >+ * @return the size as a Point. <code>Point.x</code> means the width and >+ * <code>Point.y</code> means the height of the component. >+ */ >+ public abstract Point getSize(); >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/IConfigurationChangeListener.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/IConfigurationChangeListener.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/IConfigurationChangeListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/IConfigurationChangeListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign; >+ >+/** >+ * This interface can be used to react on configuration changes e.g. the >+ * <code>{@link ConfigurableStack}</code> or the visibility of view toolbar >+ * items. >+ * <p> >+ * You can register an instance of this in the >+ * <code>{@link ConfigurationAction}</code> of a <code>ConfigurableStack</code> >+ * if it has one. >+ * </p> >+ * >+ * @since 1.2 >+ * >+ * @see ConfigurableStack >+ * @see ConfigurationAction >+ */ >+public interface IConfigurationChangeListener { >+ >+ /** >+ * This method is called if the <code>{@link ConfigurableStack}</code> of a >+ * part has changed. >+ * <p> >+ * An instance of this e.g. can call >+ * <code>{@link ConfigurableStackProxy#setCurrentStackPresentation(String)} >+ * <code> with the new id to change the <code>ConfigurableStack</code> on the >+ * fly. >+ * </p> >+ * >+ * @param newStackPresentationId the id of the new >+ * <code>ConfigurableStack</code> for the selected part. >+ * >+ * @see ConfigurableStack >+ * @see ConfigurableStackProxy#setCurrentStackPresentation(String) >+ */ >+ public void presentationChanged( final String newStackPresentationId ); >+ >+ /** >+ * This method is called if the visibility of the views's toolbar items or >+ * menu has changed. >+ * <p> >+ * <code>{@link ConfigurableStack}</code> objects can use this e.g. to refresh >+ * the part toolbar. >+ * </p> >+ * >+ * @see ConfigurableStack >+ */ >+ public void toolBarChanged(); >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/Layout.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/Layout.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/Layout.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/Layout.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,148 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign.layout.model; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+/** >+ * This class represents the <code>org.eclipse.ui.presentations.Layouts</code> >+ * extension point. This means, that it can be hold any number of <code> >+ * {@link LayoutSet}</code> objects. >+ * <p> >+ * This class is like a manager for <code>LayoutSet</code> objects. >+ * </p> >+ * >+ * @since 1.2 >+ * >+ */ >+public class Layout { >+ >+ private Map layoutSets = new HashMap(); >+ private Map pluginIdMap = new HashMap(); >+ private String id; >+ >+ /** >+ * Instantiate a object of this class and sets the unique id, which is >+ * contributed to the <code>org.eclipse.ui.presentations.Layouts >+ * </code> extension point. >+ * >+ * @param id the unique <code>Layout</code> id. >+ */ >+ public Layout( final String id ) { >+ this.id = id; >+ } >+ >+ /** >+ * Adds a existing <code>LayoutSet</code> object to this <code>Layout</code>. >+ * >+ * @param id the id of the <code>LayoutSet</code> to add. >+ * @param set the <code>LayoutSet</code> object to add. >+ */ >+ public void addLayoutSet( final String id, final LayoutSet set ) { >+ layoutSets.put( id, set ); >+ } >+ >+ /** >+ * This method removes a <code>LayoutSet</code> object completely from this >+ * instance. >+ * >+ * @param layoutSetId the id of the <code>LayoutSet</code> object to remove. >+ */ >+ public void clearLayoutSet( final String layoutSetId ) { >+ LayoutSet set = ( LayoutSet ) layoutSets.get( layoutSetId ); >+ if( set != null ) { >+ layoutSets.remove( layoutSetId ); >+ pluginIdMap.remove( layoutSetId ); >+ } >+ } >+ >+ /** >+ * Returns the <code>Layout</code> id, which was set by calling <code> >+ * {@link #Layout(String)}</code>. >+ * >+ * @return the id. >+ */ >+ public String getId() { >+ return id; >+ } >+ >+ /** >+ * Returns an instance of a <code>LayoutSet</code> object for the given id. If >+ * the instance does not yet exists it will be created. >+ * >+ * @param layoutSetId the id of the wanted <code>LayoutSet</code> object. >+ * >+ * @return a instance of a <code>LayoutSet</code> object with the given id. >+ */ >+ public LayoutSet getLayoutSet( final String layoutSetId ) { >+ LayoutSet result = ( LayoutSet ) layoutSets.get( layoutSetId ); >+ if( result == null ) { >+ result = new LayoutSet( layoutSetId ); >+ layoutSets.put( layoutSetId, result ); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns a <code>Map</code> object that contains all <code>LayoutSet</code> >+ * objects for this <code>Layout</code>. >+ * >+ * @return all <code>LayoutSet</code> object for this <code>Layout</code>. >+ */ >+ public Map getLayoutSets() { >+ return layoutSets; >+ } >+ >+ /** >+ * Returns the plug-in id for the <code>LayoutSet</code> object with the given >+ * id. >+ * >+ * @param layoutSetId the id of the <code>LayoutSet</code> object. >+ * >+ * @return the id of the plug-in, which declares the </code>LayoutSet</code>. >+ */ >+ public String getPluginId( final String layoutSetId ) { >+ String result = ""; >+ result = ( String ) pluginIdMap.get( layoutSetId ); >+ return result; >+ } >+ >+ /** >+ * Checks if the object holds a <code>LayoutSet</code> object with the given >+ * <code>LayoutSet</code> id. >+ * >+ * @param layoutSetId the <code>LayoutSet</code> id to check. >+ * >+ * @return <code>true</code> if this object holds a instance of the <code> >+ * LayoutSet</code> with the given id. >+ * >+ * @see LayoutSet#getId() >+ */ >+ public boolean layoutSetExist( final String layoutSetId ) { >+ return layoutSets.containsKey( layoutSetId ); >+ } >+ >+ /** >+ * Different <code>LayoutSet</code> objects can have different bundles. >+ * Therefore it's necessary to know the plug-in id e.g. to create images and >+ * so on. >+ * >+ * @param layoutSetId the id of the <code>LayoutSet</code> object, which the >+ * plug-in id belongs to. >+ * @param pluginId the id of the plug-in, which contribute to the <code> >+ * org.eclipse.ui.presentations.Layouts</code> extension point. >+ */ >+ public void setPluginIdForLayoutSet( >+ final String layoutSetId, final String pluginId ) { >+ pluginIdMap.put( layoutSetId, pluginId ); >+ } >+ >+} >Index: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/ILayoutSetInitializer.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/ILayoutSetInitializer.java >diff -N Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/ILayoutSetInitializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/rap/ui/interactiondesign/layout/model/ILayoutSetInitializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+* Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+* program and the accompanying materials are made available under the terms of >+* the Eclipse Public License v1.0 which accompanies this distribution, and is >+* available at http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* EclipseSource - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.rap.ui.interactiondesign.layout.model; >+ >+/** >+ * This interface is implemented by the class defined in the attributes of the >+ * <code>org.eclipse.ui.presentations.Layouts</code> extension point. >+ * <p> >+ * Classes implementing this interface to add components to a >+ * <code>{@link LayoutSet}</code> object. >+ * >+ * @since 1.2 >+ */ >+public interface ILayoutSetInitializer { >+ >+ /** >+ * This method is automatically called by the <code>LayoutRegistry</code> >+ * instance during the initialization process. This happens on the plug-in >+ * activation. >+ * <p> >+ * Clients should add <code>Image</code>, <code>Font</code>, <code>Color >+ * </code> and <code>FormData</code> objects to the given >+ * <code>LayoutSet</code>. >+ * </p> >+ * >+ * @param layoutSet the <code>LayoutSet</code> instance you should add >+ * components. >+ * >+ * @see LayoutSet#addColor(String, org.eclipse.swt.graphics.Color) >+ * @see LayoutSet#addFont(String, org.eclipse.swt.graphics.Font) >+ * @see LayoutSet#addImagePath(String, String) >+ * @see LayoutSet#addPosition(String, org.eclipse.swt.layout.FormData) >+ */ >+ public void initializeLayoutSet( final LayoutSet layoutSet ); >+ >+ >+} >#P org.eclipse.rap.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui/plugin.xml,v >retrieving revision 1.17 >diff -u -r1.17 plugin.xml >--- plugin.xml 5 May 2008 17:48:13 -0000 1.17 >+++ plugin.xml 21 Jan 2009 09:57:36 -0000 >@@ -73,6 +73,8 @@ > <extension-point id="org.eclipse.ui.workingSets" name="%ExtPoint.workingSets" schema="schema/workingSets.exsd"/> > <extension-point id="org.eclipse.ui.browserSupport" name="%ExtPoint.browserSupport" schema="schema/browserSupport.exsd"/> > <extension-point id="org.eclipse.ui.internalTweaklets" name="%ExtPoint.tweaklets" schema="schema/internalTweaklets.exsd"/> >+ <extension-point id="layouts" name="%ExtPoint.layouts" schema="schema/rap/layouts.exsd"/> >+ <extension-point id="stackPresentations" name="%ExtPoint.configurableStackPresentation" schema="schema/rap/stackPresentations.exsd"/> > > <extension > point="org.eclipse.ui.contexts"> >Index: build.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui/build.properties,v >retrieving revision 1.1 >diff -u -r1.1 build.properties >--- build.properties 17 Apr 2008 12:32:47 -0000 1.1 >+++ build.properties 21 Jan 2009 09:57:34 -0000 >@@ -14,7 +14,9 @@ > plugin.xml,\ > about.html,\ > .,\ >- META-INF/ >+ META-INF/,\ >+ patch.jar > src.includes = about.html,\ > schema/ > source.. = src/ >+source.patch.jar = src/ >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui/plugin.properties,v >retrieving revision 1.2 >diff -u -r1.2 plugin.properties >--- plugin.properties 18 Apr 2008 10:46:45 -0000 1.2 >+++ plugin.properties 21 Jan 2009 09:57:35 -0000 >@@ -66,6 +66,8 @@ > ExtPoint.browserSupport = Browser Support > ExtPoint.statusHandlers = Status Handlers > ExtPoint.tweaklets = Tweaklets (internal/experimental) >+ExtPoint.layouts = Layouts >+ExtPoint.configurableStackPresentation = Configurable Stacks > > Views.Category.Basic = General > Views.IntroAdapter = Welcome >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.4 >diff -u -r1.4 MANIFEST.MF >--- META-INF/MANIFEST.MF 4 Nov 2008 17:14:42 -0000 1.4 >+++ META-INF/MANIFEST.MF 21 Jan 2009 09:57:36 -0000 >@@ -1,9 +1,11 @@ > Manifest-Version: 1.0 >+Eclipse-ExtensibleAPI: true > Bundle-ManifestVersion: 2 > Bundle-Name: %Plugin.name > Bundle-SymbolicName: org.eclipse.rap.ui; singleton:=true > Bundle-Version: 1.2.0.qualifier >-Bundle-ClassPath: . >+Bundle-ClassPath: patch.jar, >+ . > Bundle-Activator: org.eclipse.ui.internal.UIPlugin > Bundle-ActivationPolicy: lazy > Bundle-Vendor: %Plugin.providerName >Index: schema/rap/branding.exsd >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui/schema/rap/branding.exsd,v >retrieving revision 1.3 >diff -u -r1.3 branding.exsd >--- schema/rap/branding.exsd 3 Dec 2008 15:33:33 -0000 1.3 >+++ schema/rap/branding.exsd 21 Jan 2009 09:57:36 -0000 >@@ -2,9 +2,9 @@ > <!-- Schema file written by PDE --> > <schema targetNamespace="org.eclipse.rap.ui" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> >- <appInfo> >+ <appinfo> > <meta.schema plugin="org.eclipse.rap.ui" id="branding" name="Branding"/> >- </appInfo> >+ </appinfo> > <documentation> > The branding extension points allows you to have a RCP-like branding functionality but with additional aspects regarding web applications. You can specify values for the used servlet name or the favicon. Additionally you're able to group entrypoints together to one branding which helps you to brand external entrypoints. > </documentation> >@@ -12,9 +12,9 @@ > > <element name="extension"> > <annotation> >- <appInfo> >+ <appinfo> > <meta.element /> >- </appInfo> >+ </appinfo> > </annotation> > <complexType> > <sequence minOccurs="1" maxOccurs="unbounded"> >@@ -39,9 +39,9 @@ > <documentation> > > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute translatable="true"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > </complexType> >@@ -49,14 +49,15 @@ > > <element name="branding"> > <annotation> >- <appInfo> >+ <appinfo> > <meta.element labelAttribute="title"/> >- </appInfo> >+ </appinfo> > </annotation> > <complexType> > <sequence> > <element ref="additionalHeaders" minOccurs="0" maxOccurs="1"/> > <element ref="associatedEntrypoints" minOccurs="0" maxOccurs="1"/> >+ <element ref="presentationFactory" minOccurs="0" maxOccurs="1"/> > </sequence> > <attribute name="id" type="string" use="required"> > <annotation> >@@ -91,9 +92,9 @@ > <documentation> > The title attribute is responsible for the title of the RAP application. This will show up in the browser window or as title of the tab in the browser. > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute translatable="true"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > <attribute name="favicon" type="string"> >@@ -101,9 +102,9 @@ > <documentation> > If you have a logo or something for your web application you put its path here so it can be displayed as icon in the browser near the adressbar or in the favourites. Be sure you specify a file in the .ico format as most browsers don't accept other image types as favicons. > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute kind="resource"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > <attribute name="body" type="string"> >@@ -111,9 +112,9 @@ > <documentation> > You can define any valid html file to be used as body of the RAP startup page. You can put whatever you want in it as long as it does not break the page. > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute kind="resource"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > <attribute name="exitConfirmationClass" type="string"> >@@ -129,9 +130,9 @@ > This will only work in browsers of the Mozilla family and Internet Explorer. > </p> > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute kind="java" basedOn=":org.eclipse.rap.ui.branding.IExitConfirmation"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > </complexType> >@@ -239,9 +240,9 @@ > > <element name="entrypoint"> > <annotation> >- <appInfo> >+ <appinfo> > <meta.element labelAttribute="id"/> >- </appInfo> >+ </appinfo> > <documentation> > An element which references to an existing entrypoint defined by <code>org.eclipse.rap.ui.entrypoint</code>. > </documentation> >@@ -257,19 +258,94 @@ > </complexType> > </element> > >+ <element name="presentationFactory"> >+ <complexType> >+ <sequence> >+ <element ref="stackPresentation" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="defaultStackPresentation" minOccurs="0" maxOccurs="1"/> >+ </sequence> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The id of the PresentationFactory to load. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="defaultLayoutId" type="string"> >+ <annotation> >+ <documentation> >+ The id of the default Layout to load. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="stackPresentation"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The id of the StackPresentation >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="partId" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The id of the part to couple with the id of the StackPresentation. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="defaultStackPresentation"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The id of the StackPresentation, which is loaded if no mapping for parts and stackPresentations exists. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="since"/> >- </appInfo> >+ </appinfo> > <documentation> > RAP 1.0 > </documentation> > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="examples"/> >- </appInfo> >+ </appinfo> > <documentation> > <pre> > <extension >@@ -290,9 +366,9 @@ > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="apiInfo"/> >- </appInfo> >+ </appinfo> > <documentation> > There is no API available for branding. > </documentation> >@@ -300,9 +376,9 @@ > > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="copyright"/> >- </appInfo> >+ </appinfo> > <documentation> > Copyright (c) 2007 Innoopract Informationssysteme GmbH and others.<br> > All rights reserved. This program and the accompanying materials are made >Index: schema/rap/stackPresentations.exsd >=================================================================== >RCS file: schema/rap/stackPresentations.exsd >diff -N schema/rap/stackPresentations.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/rap/stackPresentations.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,191 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.rap.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.rap.ui" id="stackPresentations" name="StackPresentations"/> >+ </appinfo> >+ <documentation> >+ This extension point is used to register <code>ConfigurableStack</code>s. This object extending a ordinary <code>StackPresentation</code> so it can be used to style a <code>LayoutPart</code>. To register such a <code>ConfigurableStack</code> only makes sence if the PresentationFactory is a <code>org.eclipse.rap.presentation.PresentationFactory</code>. Because only this PresentationFactory can handle a <code>ConfigurableStack</code>.<br> >+This extension point is also used to couple a <code>ConfigurationAction</code> to such a <code>ConfigurableStack</code>. With this you can implement different configuration behaviours for different <code>ConfigurableStack</code> implementations.<br> >+You can define default StackPresentations for a part using the <code>org.eclipse.rap.ui.branding</code> extension point. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="stackPresentation" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="stackPresentation"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The identifier for the ConfigurableStack. This is for load and save such a part presentation. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ An implementation of <code>ConfigurableStack</code> >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.rap.ui.interactiondesign.ConfigurableStack:"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The name of ConfigurableStack, this is just to give it a readable name. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="type" use="required"> >+ <annotation> >+ <documentation> >+ This defines the type where the ConfigurableStack can be used. there are three possible types: Editor, View and StandaloneView. >+ </documentation> >+ </annotation> >+ <simpleType> >+ <restriction base="string"> >+ <enumeration value="editor"> >+ </enumeration> >+ <enumeration value="view"> >+ </enumeration> >+ <enumeration value="standaloneview"> >+ </enumeration> >+ </restriction> >+ </simpleType> >+ </attribute> >+ <attribute name="actionClass" type="string"> >+ <annotation> >+ <documentation> >+ An implementation of <code>ConfigurationAction</code>. >+With this action you can implement configuration bahaviour e.g. this action can create a popup dialog that shows configuration elements. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.rap.ui.interactiondesign.RAPConfigurationAction:"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="actionIcon" type="string"> >+ <annotation> >+ <documentation> >+ The icon for the ConfigurationAction. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="resource"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="menuIcon" type="string"> >+ <annotation> >+ <documentation> >+ The icon for a view's menu if it has one. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="resource"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ RAP 1.2 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ <pre> >+<extension >+ point="org.eclipse.ui.presentations.StackPresentations"> >+ <stackPresentation >+ actionClass="org.eclipse.rap.ui.interactiondesign.example.configaction.ExampleConfigAction" >+ actionIcon="icons/configure.png" >+ class="org.eclipse.rap.ui.interactiondesign.example.stacks.NavigationPaneStackPresentation" >+ id="org.eclipse.rap.ui.interactiondesign.navigationPaneStackPresentation" >+ menuIcon="icons/menuIcon.gif" >+ name="Navigation Pane" >+ type="view"> >+ </stackPresentation> >+</extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ Each stackPresentation has to extend <code>org.eclipse.rap.ui.interactiondesign.ConfigurableStack</code> to handle different mechanisms, e.g. stackPresentation changing on the fly and so on. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ A detailed implementation example can be found in the <code>org.eclipse.rap.presentation.example</code> project. This project defines two different <code>ConfigurableStack</code> implementations. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+program and the accompanying materials are made available under the terms of >+the Eclipse Public License v1.0 which accompanies this distribution, and is >+available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: schema/rap/layouts.exsd >=================================================================== >RCS file: schema/rap/layouts.exsd >diff -N schema/rap/layouts.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/rap/layouts.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.rap.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.rap.ui" id="layouts" name="Layouts"/> >+ </appinfo> >+ <documentation> >+ This extension point is used to register a custom Layout. This means a grafical Layout not a Layout from the programmers point of view.<br> >+Every Layout can hold attributes called LayoutSets. A LayoutSet is a simple container for images, fonts, colors and position data. These sets are usually coupled to a <code>ElementBuilder</code>.<br> >+A Layout can override LayoutSets of other Layouts. These overriden LayoutSets are used if the user switch the Layout during runtime.<br> >+The default Layout can be defined by contributing to the <code>org.eclipse.rap.ui.branding</code> extension point. If there is no default Layout defined a fallback mechanism will be used to show the standard Layout. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="layout" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="layoutSet"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The unique identifier for a LayoutSet. This id can be used to override a LayoutSet in a different Layout. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ This optional attribute is just to give the LayoutSet a readable name. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The definition of a LayoutSet. This is a class that has to implement the ILayoutSetInitializer interface. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.rap.ui.interactiondesign.elements.model.ILayoutSetInitializer"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="layout"> >+ <complexType> >+ <sequence> >+ <element ref="layoutSet" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ RAP 1.2 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ The following is an example of a Layout with three LayoutSets: >+<p> >+<pre> >+<extension >+ id="org.eclipse.presentation.example.layout" >+ name="Example Layout" >+ point="org.eclipse.ui.presentations.Layouts"> >+ <LayoutSet >+ class="org.eclipse.rap.ui.interactiondesign.example.layoutset.HeaderLayoutSet2" >+ id="header.layoutset" >+ name="Header2"> >+ </LayoutSet> >+ <LayoutSet >+ class="org.eclipse.rap.ui.interactiondesign.example.layoutset.MacBarLayoutSet2" >+ id="macBar.layoutset" >+ name="MacBar 2"> >+ </LayoutSet> >+ <LayoutSet >+ class="org.eclipse.rap.ui.interactiondesign.example.layoutset.FooterLayoutSet2" >+ id="footer.layoutset" >+ name="Footer"> >+ </LayoutSet> >+ <LayoutSet >+ class="org.eclipse.rap.ui.interactiondesign.example.layoutset.NavigationPaneLayoutSet2" >+ id="navigationpane.layoutset" >+ name="NavigationPane"> >+ </LayoutSet> >+ </extension> >+ </pre> >+ </p> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ Each LayoutSet in a Layout has to implement the <code>ILayoutSetInitializer</code> interface. The method within is called during the plugin activation to initialize components like images or fonts for this LayoutSet. This implementation can look like this: >+ >+<pre> >+public class HeaderLayoutSet implements ILayoutSetInitializer { >+ public void initializeLayoutSet( LayoutSet layoutSet ) { >+ layoutSet.addImagePath( HeaderBuilderData.LEFT, "icons/headerLeft.png" ); >+ layoutSet.addImagePath( HeaderBuilderData.CENTER, "icons/headerCenter.png" ); >+ layoutSet.addImagePath( HeaderBuilderData.RIGHT, "icons/headerRight.png" ); >+ layoutSet.addImagePath( HeaderBuilderData.LOGO, "icons/headerLogo.png" ); >+ addHeaderPositions( layoutSet ); >+ } >+} >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ A detailed implementation example can be found in the <code>org.eclipse.rap.presentation.example</code> project. This project defines two Layouts and a bunch of LayoutSets. They look not pretty but they do their job. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2008 EclipseSource and others. All rights reserved. This >+program and the accompanying materials are made available under the terms of >+the Eclipse Public License v1.0 which accompanies this distribution, and is >+available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 261795
: 123209