Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDejan Gloszic2005-02-10 18:44:43 +0000
committerDejan Gloszic2005-02-10 18:44:43 +0000
commitb276a398ca3b34d1bb9c1c751a66d83e5aab9b52 (patch)
tree74d5a81fa21ac30e76cbcf245be83934a01f2a49
parent6e60d609d2ee0d4e8a9cee2ecb1f481284a0e357 (diff)
downloadeclipse.platform.ua-b276a398ca3b34d1bb9c1c751a66d83e5aab9b52.tar.gz
eclipse.platform.ua-b276a398ca3b34d1bb9c1c751a66d83e5aab9b52.tar.xz
eclipse.platform.ua-b276a398ca3b34d1bb9c1c751a66d83e5aab9b52.zip
*** empty log message ***v20050210_launchBar
-rw-r--r--org.eclipse.ui.intro/icons/full/dtool16/restore_welcome.gifbin0 -> 329 bytes
-rw-r--r--org.eclipse.ui.intro/icons/full/etool16/restore_welcome.gifbin0 -> 339 bytes
-rw-r--r--org.eclipse.ui.intro/schema/config.exsd14
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/IntroPlugin.java16
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java10
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java24
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURL.java50
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarElement.java122
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarShortcutElement.java70
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java224
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/SharedStyleManager.java12
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/ImageUtil.java3
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java2
13 files changed, 535 insertions, 12 deletions
diff --git a/org.eclipse.ui.intro/icons/full/dtool16/restore_welcome.gif b/org.eclipse.ui.intro/icons/full/dtool16/restore_welcome.gif
new file mode 100644
index 000000000..4997b20ce
--- /dev/null
+++ b/org.eclipse.ui.intro/icons/full/dtool16/restore_welcome.gif
Binary files differ
diff --git a/org.eclipse.ui.intro/icons/full/etool16/restore_welcome.gif b/org.eclipse.ui.intro/icons/full/etool16/restore_welcome.gif
new file mode 100644
index 000000000..7736bcec6
--- /dev/null
+++ b/org.eclipse.ui.intro/icons/full/etool16/restore_welcome.gif
Binary files differ
diff --git a/org.eclipse.ui.intro/schema/config.exsd b/org.eclipse.ui.intro/schema/config.exsd
index 593e8b137..48cfb49e1 100644
--- a/org.eclipse.ui.intro/schema/config.exsd
+++ b/org.eclipse.ui.intro/schema/config.exsd
@@ -187,6 +187,20 @@ The content file is parsed at run time by the intro framework. Based on the sett
</restriction>
</simpleType>
</attribute>
+ <attribute name="bg" type="string">
+ <annotation>
+ <documentation>
+ background color that will be applied to the launch bar if specified. Expected format is hex, as in: #rrggbb (for example, #80a4a1).
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="fg" type="string">
+ <annotation>
+ <documentation>
+ foreground color that will be used to paint the border of the launch bar if specified. Expected format is hex, as in: #rrggbb (for example, #80a4a1).
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/IntroPlugin.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/IntroPlugin.java
index db9ee8bea..233379597 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/IntroPlugin.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/IntroPlugin.java
@@ -16,6 +16,7 @@ import java.util.*;
import org.eclipse.ui.*;
import org.eclipse.ui.internal.intro.impl.model.*;
import org.eclipse.ui.internal.intro.impl.model.loader.*;
+import org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar;
import org.eclipse.ui.internal.intro.impl.util.*;
import org.eclipse.ui.intro.*;
import org.eclipse.ui.plugin.*;
@@ -31,6 +32,10 @@ public class IntroPlugin extends AbstractUIPlugin {
// There should always be a single instance of all these classes.
private ResourceBundle resourceBundle;
+
+ // We must keep track of the launch bar so that we can
+ // close it if intro is opened from the menu.
+ private IntroLaunchBar launchBar;
// The intro resource bundle.
private static String INTRO_RESOURCE_BUNDLE = "org.eclipse.ui.internal.intro.impl.IntroPluginResources"; //$NON-NLS-1$
@@ -64,6 +69,17 @@ public class IntroPlugin extends AbstractUIPlugin {
return key;
}
}
+
+ public void closeLaunchBar() {
+ if (launchBar!=null) {
+ launchBar.close();
+ launchBar = null;
+ }
+ }
+
+ public void setLaunchBar(IntroLaunchBar launchBar) {
+ this.launchBar = launchBar;
+ }
/**
* Utility method to get a resource from the given key, then format it with
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java
index befe866ef..c599b5699 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java
@@ -122,6 +122,16 @@ public abstract class AbstractIntroElement implements Cloneable {
* Type constant which identifies the IntroContentProvider element.
*/
public static final int CONTENT_PROVIDER = 1 << 14;
+
+ /**
+ * Type constant which identifies the LaunchBarElement.
+ */
+ public static final int LAUNCH_BAR = 1 << 15;
+
+ /**
+ * Type constant which identifies the launch bar shortcut.
+ */
+ public static final int LAUNCH_BAR_SHORTCUT = 1 << 16;
/**
* Type constant which identifies the AbstractText element.
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
index 40f39b15d..3c4212f74 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java
@@ -46,6 +46,8 @@ public class IntroPartPresentation extends AbstractIntroElement {
protected static final String TAG_PRESENTATION = "presentation"; //$NON-NLS-1$
private static final String TAG_IMPLEMENTATION = "implementation"; //$NON-NLS-1$
+ private static final String TAG_LAUNCH_BAR = "launchBar"; //$NON-NLS-1$
+
/*
* type attribute can only be org.eclipse.platform.intro.FormsPresentation
@@ -57,7 +59,7 @@ public class IntroPartPresentation extends AbstractIntroElement {
private static final String ATT_WS = "ws"; //$NON-NLS-1$
protected static final String ATT_HOME_PAGE_ID = "home-page-id"; //$NON-NLS-1$
protected static final String ATT_STANDBY_PAGE_ID = "standby-page-id"; //$NON-NLS-1$
-
+
private static final String BROWSER_IMPL_KIND = "html"; //$NON-NLS-1$
private static final String FORMS_IMPL_KIND = "swt"; //$NON-NLS-1$
// this implementation kind if not public api. Only used internally for
@@ -76,6 +78,8 @@ public class IntroPartPresentation extends AbstractIntroElement {
private IntroHead head;
private AbstractIntroPartImplementation implementation;
+
+ private LaunchBarElement launchBar;
// CustomizableIntroPart and memento instances. Passed to the Implementation
// classes.
@@ -151,6 +155,24 @@ public class IntroPartPresentation extends AbstractIntroElement {
return null;
}
}
+
+/**
+ * Returns the launch bar element if defined in this presentation,
+ * or <code>null</code> otherwise.
+ *
+ * @since 3.1
+ * @return
+ */
+
+ public LaunchBarElement getLaunchBar() {
+ if (launchBar!=null)
+ return launchBar;
+ IConfigurationElement [] children = getCfgElement().getChildren(TAG_LAUNCH_BAR);
+ if (children.length>0) {
+ launchBar = new LaunchBarElement(children[0]);
+ }
+ return launchBar;
+ }
/**
* @param introPart
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURL.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURL.java
index 52a3b6004..d91c765e4 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURL.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURL.java
@@ -11,18 +11,21 @@
package org.eclipse.ui.internal.intro.impl.model;
-import java.io.*;
-import java.net.*;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.util.*;
import org.eclipse.jface.action.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.jface.util.Geometry;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.*;
-import org.eclipse.ui.help.*;
+import org.eclipse.ui.internal.*;
import org.eclipse.ui.internal.intro.impl.*;
import org.eclipse.ui.internal.intro.impl.model.loader.*;
-import org.eclipse.ui.internal.intro.impl.parts.*;
+import org.eclipse.ui.internal.intro.impl.parts.StandbyPart;
+import org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar;
import org.eclipse.ui.internal.intro.impl.util.*;
import org.eclipse.ui.intro.*;
import org.eclipse.ui.intro.config.*;
@@ -54,6 +57,7 @@ public class IntroURL implements IIntroURL {
public static final String SHOW_PAGE = "showPage"; //$NON-NLS-1$
public static final String SHOW_MESSAGE = "showMessage"; //$NON-NLS-1$
public static final String NAVIGATE = "navigate"; //$NON-NLS-1$
+ public static final String SWITCH_TO_LAUNCH_BAR = "switchToLaunchBar"; //$NON-NLS-1$
/**
* Constants that represent valid action keys.
@@ -148,6 +152,8 @@ public class IntroURL implements IIntroURL {
else if (action.equals(NAVIGATE))
return navigate(getParameter(KEY_DIRECTION));
+ else if (action.equals(SWITCH_TO_LAUNCH_BAR))
+ return switchToLaunchBar();
else
return handleCustomAction();
}
@@ -255,7 +261,7 @@ public class IntroURL implements IIntroURL {
*/
private boolean showHelpTopic(String href) {
// WorkbenchHelp takes care of error handling.
- WorkbenchHelp.displayHelpResource(href);
+ PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(href);
return true;
}
@@ -263,7 +269,7 @@ public class IntroURL implements IIntroURL {
* Open the help system.
*/
private boolean showHelp() {
- WorkbenchHelp.displayHelp();
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp();
return true;
}
@@ -490,5 +496,29 @@ public class IntroURL implements IIntroURL {
return query.toString();
}
-}
-
+ private boolean switchToLaunchBar() {
+ IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
+ if (intro==null) return false;
+
+ CustomizableIntroPart cpart = (CustomizableIntroPart)intro;
+ IntroModelRoot modelRoot = IntroPlugin.getDefault().getIntroModelRoot();
+ String pageId = modelRoot.getCurrentPageId();
+ Rectangle bounds = cpart.getControl().getBounds();
+ Rectangle startBounds = Geometry.toDisplay(cpart.getControl().getParent(), bounds);
+ closeIntro();
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ WorkbenchWindow wwindow = (WorkbenchWindow)window;
+ LaunchBarElement launchBarElement = modelRoot.getPresentation().getLaunchBar();
+ IntroLaunchBar launchBar = new IntroLaunchBar(launchBarElement.getOrientation(), pageId, launchBarElement);
+ launchBar.createControl(window.getShell());
+ wwindow.addToTrim(launchBar.getControl(), launchBarElement.getLocation());
+ window.getShell().layout();
+ Rectangle endBounds = Geometry.toDisplay(launchBar.getControl().getParent(),
+ launchBar.getControl().getBounds());
+
+ RectangleAnimation animation = new RectangleAnimation(window.getShell(), startBounds, endBounds);
+ animation.schedule();
+ return true;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarElement.java
new file mode 100644
index 000000000..f53def9ac
--- /dev/null
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarElement.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.intro.impl.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.swt.SWT;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Element;
+
+/**
+ * An Intro Config component that has captures launch bar information.
+ *
+ * @since 3.1
+ */
+public class LaunchBarElement extends AbstractIntroElement {
+ private static final String LOC_LEFT = "left";
+
+ private static final String LOC_BOTTOM = "bottom";
+
+ private static final String LOC_RIGHT = "right";
+
+ private static final String ATT_LOCATION = "location"; //$NON-NLS-1$
+ private static final String ATT_BG = "bg"; //$NON-NLS-1$
+ private static final String ATT_FG = "fg"; //$NON-NLS-1$
+
+ private static final String TAG_SHORTCUT = "shortcut"; //$NON-NLS-1$
+
+ private ArrayList shortcuts;
+
+ public LaunchBarElement(IConfigurationElement element) {
+ super(element);
+ }
+
+ public LaunchBarElement(Element element, Bundle bundle) {
+ super(element, bundle);
+ }
+
+ /**
+ * Returns LAUNCH_BAR.
+ */
+ public int getType() {
+ return LAUNCH_BAR;
+ }
+
+/**
+ * Returns the desired launch bar orientation that results
+ * from the desired location. Valid values are <code>SWT.VERTICAL</code> and
+ * <code>SWT.HORIZONTAL</code>.
+ * @return
+ */
+ public int getOrientation() {
+ int location = getLocation();
+ return (location == SWT.RIGHT || location == SWT.LEFT) ? SWT.VERTICAL
+ : SWT.HORIZONTAL;
+ }
+
+ /**
+ * Returns the location of the launch bar in the workbench window.
+ * Valid values are <code>SWT.RIGHT</code>, <code>SWT.LEFT</code>
+ * and <code>SWT.BOTTOM</code>.
+ *
+ * @return
+ */
+ public int getLocation() {
+ String location = getCfgElement().getAttribute(ATT_LOCATION);
+ int loc = SWT.RIGHT;
+ if (location != null) {
+ if (location.equals(LOC_LEFT))
+ return SWT.LEFT;
+ if (location.equals(LOC_BOTTOM))
+ return SWT.BOTTOM;
+ }
+ return loc;
+ }
+
+ public String getBackground() {
+ return getCfgElement().getAttribute(ATT_BG);
+ }
+
+ public String getForeground() {
+ return getCfgElement().getAttribute(ATT_FG);
+ }
+
+ /**
+ * Returns an array of shorcut elements.
+ *
+ * @return
+ */
+ public LaunchBarShortcutElement[] getShortcuts() {
+ if (shortcuts == null) {
+ createShortcuts();
+ }
+ return (LaunchBarShortcutElement[]) shortcuts
+ .toArray(new LaunchBarShortcutElement[shortcuts.size()]);
+ }
+
+ /**
+ * Creates an array of shortcut elements
+ *
+ */
+ private void createShortcuts() {
+ shortcuts = new ArrayList();
+ IConfigurationElement[] children = getCfgElement().getChildren(
+ TAG_SHORTCUT);
+ for (int i = 0; i < children.length; i++) {
+ IConfigurationElement child = children[i];
+ LaunchBarShortcutElement shortcut = new LaunchBarShortcutElement(
+ child);
+ shortcuts.add(shortcut);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarShortcutElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarShortcutElement.java
new file mode 100644
index 000000000..11b25575a
--- /dev/null
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/LaunchBarShortcutElement.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.intro.impl.model;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.internal.intro.impl.util.ImageUtil;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Element;
+
+/**
+ * An Intro Config component that captures launch bar shortcut
+ * information.
+ *
+ * @since 3.1
+ */
+public class LaunchBarShortcutElement extends AbstractIntroElement {
+ private static final String ATT_TOOLTIP = "tooltip"; //$NON-NLS-1$
+ private static final String ATT_ICON = "icon"; //$NON-NLS-1$
+ private static final String ATT_URL = "url"; //$NON-NLS-1$
+
+ public LaunchBarShortcutElement(IConfigurationElement element) {
+ super(element);
+ }
+
+ public LaunchBarShortcutElement(Element element, Bundle bundle) {
+ super(element, bundle);
+ }
+
+ public int getType() {
+ return LAUNCH_BAR_SHORTCUT;
+ }
+ /**
+ * Returns the URL of this shortcut.
+ * @return
+ */
+ public String getURL() {
+ return getCfgElement().getAttribute(ATT_URL);
+ }
+ /**
+ * Returns the tooltip of this shortcut.
+ * @return
+ */
+ public String getToolTip() {
+ return getCfgElement().getAttribute(ATT_TOOLTIP);
+ }
+ /**
+ * Returns the relative icon path of this shortcut.
+ * @return
+ */
+ private String getIcon() {
+ return getCfgElement().getAttribute(ATT_ICON);
+ }
+ /**
+ * Returns the icon image of this shortcut, or <code>null</code>
+ * if not found.
+ * @return
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return ImageUtil.createImageDescriptor(getBundle(), getIcon());
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..a0677c54d
--- /dev/null
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/IntroLaunchBar.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.intro.impl.presentations;
+
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.util.Geometry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.internal.RectangleAnimation;
+import org.eclipse.ui.internal.intro.impl.IntroPlugin;
+import org.eclipse.ui.internal.intro.impl.model.*;
+import org.eclipse.ui.internal.intro.impl.swt.SharedStyleManager;
+import org.eclipse.ui.internal.intro.impl.util.ImageUtil;
+import org.eclipse.ui.intro.IIntroPart;
+import org.eclipse.ui.intro.config.*;
+
+
+/**
+ * This class is responsible for creating the intro launch bar
+ * in the provided parent. It creates 'restore' and 'close'
+ * actions, as well as actions for each shortcut element
+ * contributed in the extension point.
+ * @author dejan
+ *
+ */
+public class IntroLaunchBar {
+ private Composite container;
+ private ToolBarManager toolBarManager;
+
+ private int orientation;
+
+ private String lastPageId;
+
+ private Action closeAction;
+
+ private LaunchBarElement element;
+ private Color fg;
+ private Color bg;
+
+ public IntroLaunchBar(int orientation, String lastPageId,
+ LaunchBarElement element) {
+ this.orientation = orientation;
+ this.lastPageId = lastPageId;
+ this.element = element;
+ }
+
+ public void createControl(Composite parent) {
+ container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.marginWidth = 1;
+ layout.marginHeight = 1;
+ toolBarManager = new ToolBarManager(SWT.FLAT | orientation);
+ fillToolBar();
+ toolBarManager.createControl(container);
+ ToolBar toolBar = toolBarManager.getControl();
+ computeColors(parent.getDisplay());
+ //new ToolItem(toolBar, SWT.SEPARATOR);
+ if (bg!=null)
+ toolBar.setBackground(bg);
+ toolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
+ container.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ Color color = fg;
+ if (color==null)
+ color = e.display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ gc.setForeground(color);
+ Point size = container.getSize();
+ gc.drawRectangle(0, 0, size.x-1, size.y-1);
+ }
+ });
+ MenuManager manager = new MenuManager();
+ IMenuListener listener = new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ contextMenuAboutToShow(manager);
+ }
+ };
+ manager.setRemoveAllWhenShown(true);
+ manager.addMenuListener(listener);
+ Menu contextMenu = manager.createContextMenu(toolBarManager
+ .getControl());
+ toolBarManager.getControl().setMenu(contextMenu);
+ IntroPlugin.getDefault().setLaunchBar(this);
+ }
+
+ private void computeColors(Display display) {
+ if (element.getBackground()!=null) {
+ RGB r = SharedStyleManager.parseRGB(element.getBackground());
+ if (r!=null)
+ bg = new Color(display, r);
+ }
+ if (element.getForeground()!=null) {
+ RGB r = SharedStyleManager.parseRGB(element.getForeground());
+ if (r!=null)
+ fg = new Color(display, r);
+ }
+ }
+
+ public Control getControl() {
+ return container;
+ }
+
+ public void dispose() {
+ container.dispose();
+ toolBarManager.dispose();
+ toolBarManager.removeAll();
+ toolBarManager = null;
+ container = null;
+ if (bg!=null)
+ bg.dispose();
+ if (fg!=null)
+ fg.dispose();
+ }
+
+ private void fillToolBar() {
+ Action action;
+
+ closeAction = new Action("close") {
+ public void run() {
+ closeLaunchBar(false);
+ }
+ };
+ closeAction.setText("Close");
+ closeAction.setToolTipText("Close this bar");
+
+ action = new Action("restore") {
+ public void run() {
+ openPage(lastPageId);
+ }
+ };
+ action.setToolTipText("Return to Welcome");
+ action.setImageDescriptor(ImageUtil
+ .createImageDescriptor("full/etool16/restore_welcome.gif"));
+ toolBarManager.add(action);
+ toolBarManager.add(new Separator());
+ if (element == null)
+ return;
+ LaunchBarShortcutElement[] shortcuts = element.getShortcuts();
+ for (int i = 0; i < shortcuts.length; i++) {
+ LaunchBarShortcutElement shortcut = shortcuts[i];
+ addShortcut(shortcut, toolBarManager);
+ }
+ }
+
+ private void addShortcut(final LaunchBarShortcutElement shortcut,
+ IToolBarManager toolBarManager) {
+ Action action = new Action(shortcut.getToolTip()) {
+ public void run() {
+ executeShortcut(shortcut.getURL());
+ }
+ };
+ action.setImageDescriptor(shortcut.getImageDescriptor());
+ action.setToolTipText(shortcut.getToolTip());
+ toolBarManager.add(action);
+ }
+
+ public void close() {
+ closeLaunchBar(false);
+ }
+
+ private IIntroPart closeLaunchBar(boolean restore) {
+ IntroPlugin.getDefault().setLaunchBar(null);
+ IWorkbenchWindow window = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ IIntroPart intro = null;
+ if (restore) {
+ intro = PlatformUI.getWorkbench().getIntroManager().showIntro(
+ window, false);
+ }
+ if (restore) {
+ CustomizableIntroPart cpart = (CustomizableIntroPart) intro;
+ Rectangle startBounds = Geometry.toDisplay(
+ getControl().getParent(), getControl().getBounds());
+ Rectangle endBounds = Geometry.toDisplay(cpart.getControl()
+ .getParent(), cpart.getControl().getBounds());
+
+ RectangleAnimation animation = new RectangleAnimation(window
+ .getShell(), startBounds, endBounds);
+ animation.schedule();
+ }
+ dispose();
+ window.getShell().layout();
+ return intro;
+ }
+
+ private void executeShortcut(String url) {
+ IIntroURL introURL = IntroURLFactory.createIntroURL(url);
+ if (introURL != null) {
+ IIntroPart intro = closeLaunchBar(true);
+ if (intro == null)
+ return;
+ introURL.execute();
+ }
+ }
+
+ private void openPage(String id) {
+ IIntroPart intro = closeLaunchBar(true);
+ if (intro == null)
+ return;
+ StringBuffer url = new StringBuffer();
+ url.append("http://org.eclipse.ui.intro/showPage?id=");
+ url.append(id);
+ IIntroURL introURL = IntroURLFactory.createIntroURL(url.toString());
+ if (introURL != null)
+ introURL.execute();
+ }
+
+ private void contextMenuAboutToShow(IMenuManager manager) {
+ manager.add(closeAction);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/SharedStyleManager.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/SharedStyleManager.java
index c29c8bd7c..e39e9badd 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/SharedStyleManager.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/SharedStyleManager.java
@@ -82,6 +82,18 @@ public class SharedStyleManager {
String value = getProperty(key);
if (value == null)
return null;
+ return parseRGB(value);
+ }
+
+ /**
+ * A utility method that creates RGB object from a value
+ * encoded in the following format: #rrggbb, where r, g and b
+ * are hex color values in the range from 00 to ff.
+ * @param value
+ * @return
+ */
+
+ public static RGB parseRGB(String value) {
if (value.charAt(0) == '#') {
// HEX
try {
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/ImageUtil.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/ImageUtil.java
index bc5db98b7..25ba642a5 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/ImageUtil.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/ImageUtil.java
@@ -35,6 +35,9 @@ public final class ImageUtil {
// Standby images
public static final String BACK = "back"; //$NON-NLS-1$
public static final String HELP_TOPIC = "helpTopic"; //$NON-NLS-1$
+
+ // Launch bar image
+ public static final String RESTORE_WELCOME = "restoreWelcome";
// Viewer images
public static final String INTRO_MODEL_LEAF = "leaf"; //$NON-NLS-1$
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
index fa5f39682..138e87792 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/CustomizableIntroPart.java
@@ -111,7 +111,7 @@ public final class CustomizableIntroPart extends IntroPart implements
public void init(IIntroSite site, IMemento memento)
throws PartInitException {
super.init(site, memento);
-
+ IntroPlugin.getDefault().closeLaunchBar();
// load the correct model based in the current Intro Part id. Set the
// IntroPartId in the manager class.
String introId = getConfigurationElement().getAttribute("id"); //$NON-NLS-1$

Back to the top