Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2015-12-22 20:31:34 +0000
committerBrian de Alwis2016-01-22 20:14:57 +0000
commitde5846610979bdc09d2cc46a2e0eb352707a3322 (patch)
tree18e2ca860fd3d9f9bd294ac354f1f93357a6d7e3
parent78e971706b608798380b3a7c950801c41cdb1ddc (diff)
downloadeclipse.platform.ua-de5846610979bdc09d2cc46a2e0eb352707a3322.tar.gz
eclipse.platform.ua-de5846610979bdc09d2cc46a2e0eb352707a3322.tar.xz
eclipse.platform.ua-de5846610979bdc09d2cc46a2e0eb352707a3322.zip
Bug 431704 - [Intro] 'Workbench' button on Welcome page does not minimize the Welcome page but closes it
Rework the IntroLaunchBar to install itself as an E4 MToolControl. Required adding new IntroConfigurer#bind() method to associate the IntroModelRoot. Change-Id: Id96620ef2fd6ed8e92995af2741995ceb18be8af
-rw-r--r--org.eclipse.ui.intro/.classpath2
-rw-r--r--org.eclipse.ui.intro/.settings/org.eclipse.jdt.core.prefs24
-rw-r--r--org.eclipse.ui.intro/META-INF/MANIFEST.MF9
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java9
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java18
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java233
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroConfigurer.java23
7 files changed, 210 insertions, 108 deletions
diff --git a/org.eclipse.ui.intro/.classpath b/org.eclipse.ui.intro/.classpath
index ce7393340..22f30643c 100644
--- a/org.eclipse.ui.intro/.classpath
+++ b/org.eclipse.ui.intro/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.ui.intro/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ui.intro/.settings/org.eclipse.jdt.core.prefs
index e129e40f6..db6270e27 100644
--- a/org.eclipse.ui.intro/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.ui.intro/.settings/org.eclipse.jdt.core.prefs
@@ -1,16 +1,21 @@
-#Mon May 01 15:56:06 EDT 2006
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
@@ -54,7 +59,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,NORMAL,NORMAL
org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,INTRO,DONOW
@@ -124,7 +129,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
diff --git a/org.eclipse.ui.intro/META-INF/MANIFEST.MF b/org.eclipse.ui.intro/META-INF/MANIFEST.MF
index 29539bc73..4b3ad0cbf 100644
--- a/org.eclipse.ui.intro/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.intro/META-INF/MANIFEST.MF
@@ -24,13 +24,18 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
org.eclipse.help.base;bundle-version="[4.0.0,5.0.0)";resolution:=optional,
org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.core.expressions;bundle-version="3.4.200"
+ org.eclipse.core.expressions;bundle-version="3.4.200",
+ org.eclipse.e4.ui.workbench,
+ org.eclipse.e4.ui.model.workbench
Eclipse-LazyStart: true
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.xml.parsers,
javax.xml.transform,
javax.xml.transform.dom,
javax.xml.transform.stream,
+ org.eclipse.e4.core.di.annotations,
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore,
org.w3c.dom,
org.xml.sax
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
index c0a5b58ad..04123c61b 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
@@ -218,6 +218,12 @@ public class IntroModelRoot extends AbstractIntroContainer {
// Attributes of root page decide if we have a static or dynamic case.
setModelState(true, true);
+
+ if (configurer != null) {
+ // The configurer may vary its returned results based on the theme
+ // properties
+ configurer.bind(this);
+ }
}
/**
@@ -260,8 +266,9 @@ public class IntroModelRoot extends AbstractIntroContainer {
if (cname!=null) {
try {
Object obj = getCfgElement().createExecutableExtension(ATT_CONFIGURER);
- if (obj instanceof IntroConfigurer)
+ if (obj instanceof IntroConfigurer) {
configurer = (IntroConfigurer)obj;
+ }
}
catch (CoreException e) {
Log.error("Error loading intro configurer", e); //$NON-NLS-1$
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
index 0feb28018..526c02344 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
@@ -40,7 +40,6 @@ import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage;
import org.eclipse.ui.internal.intro.impl.model.IntroLaunchBarElement;
import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.internal.intro.impl.model.IntroPartPresentation;
-import org.eclipse.ui.internal.intro.impl.model.IntroTheme;
import org.eclipse.ui.internal.intro.impl.model.IntroURLAction;
import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager;
import org.eclipse.ui.internal.intro.impl.model.loader.ModelLoaderUtil;
@@ -653,22 +652,15 @@ public class IntroURL implements IIntroURL {
CustomizableIntroPart cpart = (CustomizableIntroPart) intro;
IntroModelRoot modelRoot = IntroPlugin.getDefault().getIntroModelRoot();
- String pageId = modelRoot.getCurrentPageId();
- IntroTheme theme = modelRoot.getTheme();
Rectangle bounds = cpart.getControl().getBounds();
Rectangle startBounds = Geometry.toDisplay(cpart.getControl()
.getParent(), bounds);
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- IntroLaunchBarElement launchBarElement = modelRoot.getPresentation()
- .getLaunchBarElement();
- if (launchBarElement==null)
- return true;
- IntroLaunchBar launchBar = new IntroLaunchBar(launchBarElement
- .getOrientation(), pageId, launchBarElement, theme);
-
- launchBar.createInActiveWindow();
+ IntroLaunchBarElement launchBarElement = modelRoot.getPresentation().getLaunchBarElement();
+ if (launchBarElement == null)
+ return true;
+ IWorkbenchWindow window = intro.getIntroSite().getWorkbenchWindow();
+ IntroLaunchBar launchBar = IntroLaunchBar.create(window, modelRoot, launchBarElement);
PlatformUI.getWorkbench().getIntroManager().setIntroStandby(intro, true);
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java
index dae737cce..49b798e3e 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java
@@ -11,6 +11,18 @@ package org.eclipse.ui.internal.intro.impl.presentations;
import java.util.Map;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.SideValue;
+import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
+import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
+import org.eclipse.e4.ui.workbench.IPresentationEngine;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -37,17 +49,14 @@ import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.AnimationEngine;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.dnd.DragUtil;
import org.eclipse.ui.internal.intro.impl.IntroPlugin;
import org.eclipse.ui.internal.intro.impl.Messages;
import org.eclipse.ui.internal.intro.impl.model.IntroLaunchBarElement;
import org.eclipse.ui.internal.intro.impl.model.IntroLaunchBarShortcut;
+import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.internal.intro.impl.model.IntroTheme;
import org.eclipse.ui.internal.intro.impl.swt.SharedStyleManager;
import org.eclipse.ui.internal.intro.impl.util.ImageUtil;
-import org.eclipse.ui.internal.layout.ITrimManager;
-import org.eclipse.ui.internal.layout.IWindowTrim;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.intro.config.CustomizableIntroPart;
import org.eclipse.ui.intro.config.IIntroURL;
@@ -58,26 +67,37 @@ import org.eclipse.ui.intro.config.IntroURLFactory;
* 'restore' and 'close' actions, as well as actions for each shortcut element contributed in the
* extension point.
*
+ * Reimplemented as an E4 MToolControl for 4.x. Ideally the intro configuration information would be
+ * available from the application IEclipseContext.
+ *
* @since 3.1
*/
-public class IntroLaunchBar implements IWindowTrim {
+public class IntroLaunchBar {
- private Composite container;
+ private static final String LAUNCHBAR_ID = "org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar"; //$NON-NLS-1$
+ private static final String BUNDLECLASS_URI = "bundleclass://org.eclipse.ui.intro/" //$NON-NLS-1$
+ + IntroLaunchBar.class.getName();
- protected ToolBarManager toolBarManager;
+ /* Information to persist so as to be able to reload the intro state */
+ private static final String LAST_PAGE_ID = "lastPageId"; //$NON-NLS-1$
+ private static final String INTRO_CONFIG_ID = "introConfigId"; //$NON-NLS-1$
- protected int orientation;
+ private Composite container;
- protected int location;
+ protected ToolBarManager toolBarManager;
protected String lastPageId;
protected Action closeAction = null;
+ @Inject
+ @Optional
private IntroLaunchBarElement element;
protected boolean simple;
+ @Inject
+ @Optional
private IntroTheme theme;
static final int[] TOP_LEFT_CORNER = new int[] { 0, 6, 1, 5, 1, 4, 4, 1, 5, 1, 6, 0 };
@@ -104,10 +124,12 @@ public class IntroLaunchBar implements IWindowTrim {
private Color bg;
+ private MToolControl trimControl;
+
class BarLayout extends Layout {
protected Point computeSize(Composite composite, int wHint, int hHint, boolean changed) {
- boolean vertical = (orientation & SWT.VERTICAL) != 0;
+ boolean vertical = (getOrientation() & SWT.VERTICAL) != 0;
int marginWidth = vertical | isPlain() ? 1 : simple ? 3 : 7;
int marginHeight = !vertical | isPlain() ? 1 : simple ? 3 : 7;
int width = 0;
@@ -133,13 +155,13 @@ public class IntroLaunchBar implements IWindowTrim {
}
protected void layout(Composite composite, boolean changed) {
- boolean vertical = (orientation & SWT.VERTICAL) != 0;
+ boolean vertical = (getOrientation() & SWT.VERTICAL) != 0;
int marginWidth = vertical | isPlain() ? 1 : simple ? 4 : 7;
int marginHeight = !vertical | isPlain() ? 1 : simple ? 4 : 7;
Point tsize = toolBarManager.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
Rectangle carea = composite.getClientArea();
- int x = carea.x + (location == SWT.LEFT ? 0 : marginWidth);
+ int x = carea.x + (getLocation() == SideValue.LEFT ? 0 : marginWidth);
int y = carea.y + marginHeight;
if (vertical) {
@@ -150,62 +172,104 @@ public class IntroLaunchBar implements IWindowTrim {
}
}
- public IntroLaunchBar(int orientation, String lastPageId, IntroLaunchBarElement element, IntroTheme theme) {
- this.orientation = orientation;
- this.location = element.getLocation();
- this.lastPageId = lastPageId;
- this.element = element;
- this.theme = theme;
+ /**
+ * Install the Intro Launch Bar into the provided window.
+ *
+ * @param window
+ * the window to host the launch bar
+ * @param modelRoot
+ * the current intro configuration, with pages
+ * @param element
+ * the launch bar configuration
+ * @return the launch bar instance
+ */
+ public static IntroLaunchBar create(IWorkbenchWindow window, IntroModelRoot modelRoot,
+ IntroLaunchBarElement element) {
+ EModelService modelService = (EModelService) window.getService(EModelService.class);
+ MTrimmedWindow trimmedWindow = (MTrimmedWindow) window.getService(MTrimmedWindow.class);
- simple = true;
- loadStoredLocation();
+ MToolControl trimControl = modelService.createModelElement(MToolControl.class);
+ trimControl.setElementId(LAUNCHBAR_ID);
+ trimControl.setContributionURI(BUNDLECLASS_URI);
+ // Must record sufficient information so as to be able to obtain the
+ // launch configuration on workspace restart
+ trimControl.getPersistedState().put(INTRO_CONFIG_ID, modelRoot.getId());
+ trimControl.getPersistedState().put(LAST_PAGE_ID, modelRoot.getCurrentPageId());
+ trimControl.getTags().add(IPresentationEngine.DRAGGABLE);
+
+ MTrimBar bar = modelService.getTrim(trimmedWindow, determineLocation(element));
+ bar.getChildren().add(trimControl);
+
+ // should now be rendered
+ return (IntroLaunchBar) trimControl.getObject();
}
- private void loadStoredLocation() {
+ private static SideValue determineLocation(IntroLaunchBarElement element) {
+ // Try restoring to the same location if moved previously
IDialogSettings settings = IntroPlugin.getDefault().getDialogSettings();
try {
int storedLocation = settings.getInt(S_STORED_LOCATION);
if (storedLocation > 0)
- setLocation(storedLocation);
+ return toSideValue(storedLocation);
} catch (NumberFormatException e) {
// The stored value either does not exist or
// is corrupted - just pick the default silently.
}
+ return toSideValue(element.getLocation());
+ }
+
+ private static SideValue toSideValue(int location) {
+ switch (location) {
+ case SWT.LEFT:
+ return SideValue.LEFT;
+ case SWT.RIGHT:
+ return SideValue.RIGHT;
+ case SWT.TOP:
+ return SideValue.TOP;
+ case SWT.BOTTOM:
+ return SideValue.BOTTOM;
+ }
+ return SideValue.BOTTOM;
+ }
+
+ private static int toSWT(SideValue sv) {
+ switch (sv) {
+ case LEFT:
+ return SWT.LEFT;
+ case RIGHT:
+ return SWT.RIGHT;
+ case TOP:
+ return SWT.TOP;
+ case BOTTOM:
+ return SWT.BOTTOM;
+ }
+ return SWT.BOTTOM;
}
- private void storeLocation() {
- IDialogSettings settings = IntroPlugin.getDefault().getDialogSettings();
- settings.put(S_STORED_LOCATION, this.location);
- }
-
- /**
- * This method now calls dock(location) and then adds itself to the window trim. This is to
- * support the re-ordering of IWindowTrim lifecycle related to dock().
- */
- public void createInActiveWindow() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- dock(location);
+ @PostConstruct
+ void init(Composite parent, MToolControl trimControl) {
+ simple = true;
+ this.trimControl = trimControl;
+ this.lastPageId = (String) trimControl.getPersistedState().get(LAST_PAGE_ID);
+
+ // Handle situation where intro information is not available from the
+ // the application's IEclipseContext
+ if (element == null || theme == null) {
+ String configId = (String) trimControl.getPersistedState().get(INTRO_CONFIG_ID);
+ IntroModelRoot modelRoot = IntroPlugin.getDefault().getExtensionPointManager().getModel(configId);
+ element = modelRoot.getPresentation().getLaunchBarElement();
+ theme = modelRoot.getTheme();
+ }
- ITrimManager trimManager = getTrimManager();
- trimManager.addTrim(location, this);
- window.getShell().layout();
+ createControl(parent);
+ storeLocation(); // since we may have been dragged elsewhere
}
- /**
- * Get the trim manager from the default workbench window. If the current
- * workbench window is -not- the <code>WorkbenchWindow</code> then return null.
- *
- * @return The trim manager for the current workbench window
- */
- private ITrimManager getTrimManager() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window instanceof WorkbenchWindow)
- return ((WorkbenchWindow)window).getTrimManager();
-
- return null; // not using the default workbench window
+ private void storeLocation() {
+ IDialogSettings settings = IntroPlugin.getDefault().getDialogSettings();
+ settings.put(S_STORED_LOCATION, toSWT(getLocation()));
}
-
+
/**
* Not supported anymore as of the removal of the presentation API
* TODO remove usage, see Bug 446171
@@ -221,7 +285,7 @@ public class IntroLaunchBar implements IWindowTrim {
computeColors(parent.getDisplay());
container.setLayout(new BarLayout());
// boolean vertical = (orientation & SWT.VERTICAL) != 0;
- toolBarManager = new ToolBarManager(SWT.FLAT | orientation);
+ toolBarManager = new ToolBarManager(SWT.FLAT | getOrientation());
fillToolBar();
@@ -263,15 +327,17 @@ public class IntroLaunchBar implements IWindowTrim {
IntroPlugin.getDefault().setLaunchBar(this);
}
- protected void startDragging(Point position, boolean usingKeyboard) {
- Rectangle dragRect = DragUtil.getDisplayBounds(getControl());
- startDrag(this, dragRect, position, usingKeyboard);
+ private SideValue getLocation() {
+ MElementContainer<?> parent = trimControl.getParent();
+ while (parent != null) {
+ if (parent instanceof MTrimBar) {
+ return ((MTrimBar) parent).getSide();
+ }
+ parent = parent.getParent();
+ }
+ return SideValue.BOTTOM;
}
- private void startDrag(Object toDrag, Rectangle dragRect, Point position, boolean usingKeyboard) {
-
- DragUtil.performDrag(toDrag, dragRect, position, !usingKeyboard);
- }
protected void onPaint(PaintEvent e) {
GC gc = e.gc;
@@ -287,14 +353,14 @@ public class IntroLaunchBar implements IWindowTrim {
gc.fillRectangle(0, 0, size.x, size.y);
gc.drawRectangle(0, 0, size.x - 1, size.y - 1);
} else {
- switch (location) {
- case SWT.LEFT:
+ switch (getLocation()) {
+ case LEFT:
paintLeft(gc);
break;
- case SWT.RIGHT:
+ case RIGHT:
paintRight(gc);
break;
- case SWT.BOTTOM:
+ case BOTTOM:
paintBottom(gc);
break;
}
@@ -413,6 +479,7 @@ public class IntroLaunchBar implements IWindowTrim {
return container;
}
+ @PreDestroy
public void dispose() {
if (container != null) {
container.dispose();
@@ -486,13 +553,15 @@ public class IntroLaunchBar implements IWindowTrim {
protected IIntroPart closeLaunchBar(boolean restore) {
IntroPlugin.getDefault().setLaunchBar(null);
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// if we've already been removed, this won't hurt us
- getTrimManager().removeTrim(this);
+ if (trimControl.getParent() != null) {
+ trimControl.getParent().getChildren().remove(trimControl);
+ }
IIntroPart intro = null;
if (restore) {
+ IWorkbenchWindow window = getWorkbenchWindow();
intro = PlatformUI.getWorkbench().getIntroManager().showIntro(window, false);
CustomizableIntroPart cpart = (CustomizableIntroPart) intro;
Rectangle startBounds = Geometry.toDisplay(getControl().getParent(), getControl().getBounds());
@@ -502,10 +571,13 @@ public class IntroLaunchBar implements IWindowTrim {
AnimationEngine.createTweakedAnimation(window.getShell(), 400, startBounds, endBounds);
}
dispose();
- window.getShell().layout();
return intro;
}
+ private IWorkbenchWindow getWorkbenchWindow() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ }
+
protected void executeShortcut(String url) {
IIntroURL introURL = IntroURLFactory.createIntroURL(url);
if (introURL != null) {
@@ -533,20 +605,19 @@ public class IntroLaunchBar implements IWindowTrim {
}
public void dock(int side) {
- dispose();
- setLocation(side);
- storeLocation();
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- createControl(window.getShell());
- }
-
- private void setLocation(int location) {
- this.orientation = (location == SWT.LEFT || location == SWT.RIGHT) ? SWT.VERTICAL : SWT.HORIZONTAL;
- this.location = location;
- }
-
- public int getValidSides() {
- return SWT.LEFT | SWT.RIGHT | SWT.BOTTOM;
+ // dispose();
+ // setLocation(side);
+ // storeLocation();
+ }
+
+ private int getOrientation() {
+ switch (getLocation()) {
+ case LEFT:
+ case RIGHT:
+ return SWT.VERTICAL;
+ default:
+ return SWT.HORIZONTAL;
+ }
}
/*
@@ -555,7 +626,7 @@ public class IntroLaunchBar implements IWindowTrim {
* @see org.eclipse.ui.internal.IWindowTrim#getId()
*/
public String getId() {
- return "org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar"; //$NON-NLS-1$
+ return LAUNCHBAR_ID;
}
/*
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroConfigurer.java b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroConfigurer.java
index a90def6f7..0663141e2 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroConfigurer.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroConfigurer.java
@@ -11,7 +11,7 @@ package org.eclipse.ui.intro.config;
import java.util.Map;
-import org.eclipse.ui.internal.intro.impl.IntroPlugin;
+import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.intro.IIntroSite;
@@ -36,6 +36,8 @@ public abstract class IntroConfigurer {
protected Map themeProperties;
protected IIntroSite site;
+ protected IntroModelRoot model;
+
/**
* Provides the opportunity for the configurer to contribute to the action bars and to fetch
* presentation theme properties.
@@ -53,6 +55,21 @@ public abstract class IntroConfigurer {
}
/**
+ * Internal method to associate the corresponding intro configuration model. May be called
+ * independently of {@link #init(IIntroSite, Map)}.
+ *
+ * @noreference
+ */
+ final public void bind(IntroModelRoot model) {
+ // The configurer may vary its returned results based on the theme
+ // properties
+ this.model = model;
+ if (model != null && model.getTheme() != null) {
+ themeProperties = model.getTheme().getProperties();
+ }
+ }
+
+ /**
* Returns the value of the theme property with a given name.
*
* @param name
@@ -65,8 +82,8 @@ public abstract class IntroConfigurer {
if (themeProperties == null)
return null;
String value = (String)themeProperties.get(name);
- if (value!=null)
- value = IntroPlugin.getDefault().getIntroModelRoot().resolveVariables(value);
+ if (value != null && model != null)
+ value = model.resolveVariables(value);
return value;
}

Back to the top