More portal tweaks - icons, nav l&f + tooltips
authordadubrow
Mon, 20 Sep 2010 14:29:54 -0500
changeset 2062 4d032dc346bf
parent 2061 6e114e9bc527
child 2063 b130afa02241
More portal tweaks - icons, nav l&f + tooltips
core/com.nokia.carbide.discovery.ui/icons/debug.png
core/com.nokia.carbide.discovery.ui/icons/icon_customize.png
core/com.nokia.carbide.discovery.ui/icons/icon_home.png
core/com.nokia.carbide.discovery.ui/icons/icon_kits.png
core/com.nokia.carbide.discovery.ui/icons/icon_support.png
core/com.nokia.carbide.discovery.ui/plugin.properties
core/com.nokia.carbide.discovery.ui/plugin.xml
core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java
Binary file core/com.nokia.carbide.discovery.ui/icons/debug.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/icon_customize.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/icon_home.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/icon_kits.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/icon_support.png has changed
--- a/core/com.nokia.carbide.discovery.ui/plugin.properties	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/plugin.properties	Mon Sep 20 14:29:54 2010 -0500
@@ -2,8 +2,13 @@
 menu.title = Carbide.c++ Portal
 portal.desc = Install extensions, get support, install SDKs, find latest news
 customize.title = Customize
-home.title = Home
+customize.tooltip = Add-ons and settings
+home.title = Welcome
+home.tooltip = Information, blogs, etc.
 support.title = Support
+support.tooltip = Support links
+kits.title = Kits
+kits.tooltip = Installed SDKs
 install.layer.title = Install Extensions
 wrenchscience.title = Wrench Science
 creatingcarbide.title = Creating Carbide
--- a/core/com.nokia.carbide.discovery.ui/plugin.xml	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/plugin.xml	Mon Sep 20 14:29:54 2010 -0500
@@ -51,27 +51,31 @@
     <portalPage
           class="com.nokia.carbide.internal.discovery.ui.view.SettingsBarCreator"
           id="com.nokia.carbide.discovery.ui.customizePage"
-          image="icons/icon-discovery.png"
+          image="icons/icon_customize.png"
           order="50"
-          title="%customize.title">
+          title="%customize.title"
+          tooltip="%customize.tooltip">
     </portalPage>
     <portalPage
           id="com.nokia.carbide.discovery.ui.homePage"
           image="icons/icon_home.png"
           order="1"
-          title="%home.title">
+          title="%home.title"
+          tooltip="%home.tooltip">
     </portalPage>
     <portalPage
           id="com.nokia.carbide.discovery.ui.supportPage"
-          image="icons/debug.png"
+          image="icons/icon_support.png"
           order="100"
-          title="%support.title">
+          title="%support.title"
+          tooltip="%support.tooltip">
     </portalPage>
     <portalPage
           id="com.nokia.carbide.discovery.ui.kitsPage"
-          image="icons/Carbide_c_icon_16x16.png"
+          image="icons/icon_kits.png"
           order="75"
-          title="Kits">
+          title="%kits.title"
+          tooltip="%kits.tooltip">
     </portalPage>
  </extension>
  <extension
--- a/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd	Mon Sep 20 14:29:54 2010 -0500
@@ -76,6 +76,13 @@
                </appinfo>
             </annotation>
          </attribute>
+         <attribute name="tooltip" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
          <attribute name="order" type="string">
             <annotation>
                <documentation>
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java	Mon Sep 20 14:29:54 2010 -0500
@@ -22,16 +22,104 @@
 import org.eclipse.jface.resource.FontDescriptor;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.MouseTrackListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+
+import com.nokia.cpp.internal.api.utils.core.ListenerList;
 
 class NavigationBar extends RoundedCornerComposite {
+	private class Button extends CLabel {
+		private ListenerList<SelectionListener> listeners;
+		private boolean selection;
+		private MouseTrackListener mouseTrackListener;
+		private MouseListener mouseListener;
+		
+		public Button(Composite parent) {
+			super(parent, SWT.CENTER);
+			listeners = new ListenerList<SelectionListener>();
+			setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
+			addMouseTrackListener(mouseTrackListener = new MouseTrackAdapter() {
+				@Override
+				public void mouseExit(MouseEvent e) {
+					if (!selection)
+						setBackgroundColor();
+					
+				}
+				
+				@Override
+				public void mouseEnter(MouseEvent e) {
+					if (!selection)
+						setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+				}
+			});
+			
+			addMouseListener(mouseListener = new MouseAdapter() {
+				@Override
+				public void mouseUp(MouseEvent e) {
+					setSelection(true);
+				}
+			});
+		}
+		
+		@Override
+		protected void checkSubclass() {
+		}
+
+		public void addSelectionListener(SelectionListener listener) {
+			listeners.add(listener);
+		}
+
+		public void setSelection(boolean selection) {
+			if (this.selection != selection) {
+				this.selection = selection;
+				setBackgroundColor();
+				if (selection) {
+					for (Control control : getParent().getChildren()) {
+						if (control instanceof Button) {
+							if (!control.equals(this)) {
+								((Button) control).setSelection(false);
+							}
+						}
+					}
+					fireSelection();
+				}
+			}
+		}
+
+		private void fireSelection() {
+			Event e = new Event();
+			e.widget = this;
+			e.display = getDisplay();
+			for (SelectionListener listener : listeners) {
+				listener.widgetSelected(new SelectionEvent(e));
+			}
+			
+		}
+
+		private void setBackgroundColor() {
+			setBackground(getDisplay().getSystemColor(selection ? SWT.COLOR_WIDGET_NORMAL_SHADOW : SWT.COLOR_WHITE));
+		}
+		
+		@Override
+		public void dispose() {
+			removeMouseTrackListener(mouseTrackListener);
+			removeMouseListener(mouseListener);
+			super.dispose();
+		}
+	}
 
 	private final class ButtonListener extends SelectionAdapter {
 		@Override
@@ -41,7 +129,7 @@
 		}
 	}
 
-	private static final int BUTTON_SPACING = -2;
+	private static final int BUTTON_SPACING = 0;
 	private PortalEditor portalEditor;
 	private Map<Button, PortalPage> buttonToPageMap;
 	private SelectionListener listener;
@@ -70,13 +158,14 @@
 	public void initUI() {
 		if (buttonToPageMap.isEmpty())
 			return;
-		selectNavButton(buttonToPageMap.keySet().iterator().next());
+		buttonToPageMap.keySet().iterator().next().setSelection(true);
 	}
 
 	public void addNavButton(NavigationBar bar, PortalPage page) {
-		Button b = new Button(bar, SWT.TOGGLE);
+		Button b = new Button(bar);
 		b.setFont(buttonFont);
 		b.setText(page.getTitle());
+		b.setToolTipText(page.getTooltip());
 		b.setImage(portalEditor.createImage(page.getImageDescriptor(), 32, 32));
 		b.addSelectionListener(listener);
 		buttonToPageMap.put(b, page);
@@ -84,11 +173,6 @@
 
 
 	public void selectNavButton(Button button) {
-		for (Button other : buttonToPageMap.keySet()) {
-			other.setSelection(false);
-			other.setFont(buttonFont);
-		}
-		button.setSelection(true);
 		portalEditor.showPage(buttonToPageMap.get(button));
 		button.setFont(selectedButtonFont);
 		layout();
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java	Mon Sep 20 14:29:54 2010 -0500
@@ -163,6 +163,7 @@
 			String id = element.getAttribute("id"); //$NON-NLS-1$
 			int order = getOrderStringFromElement(element, id);
 			String title = element.getAttribute("title"); //$NON-NLS-1$
+			String tooltip = element.getAttribute("tooltip"); //$NON-NLS-1$
 			String imageFilePath = element.getAttribute("image"); //$NON-NLS-1$
 			String pluginId = element.getContributor().getName();
 			ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, imageFilePath);
@@ -178,7 +179,7 @@
 					Activator.logError(MessageFormat.format(Messages.PortalEditor_BadCommandBarFactoryError, id), e);
 				}
 			}
-			PortalPage portalPage = new PortalPage(title, imageDesc, id, portalLayers, commandBarFactory);
+			PortalPage portalPage = new PortalPage(title, tooltip, imageDesc, id, portalLayers, commandBarFactory);
 			pageList.add(new Pair<PortalPage, Integer>(portalPage, order));
 		}
 		Collections.sort(pageList, new Comparator<Pair<PortalPage, Integer>>() {
@@ -193,7 +194,7 @@
 		}
 	}
 
-	private int getOrderStringFromElement(IConfigurationElement element, String id) {
+	private int getOrderStringFromElement(IConfigurationElement element, String name) {
 		int order = Integer.MAX_VALUE;
 		String orderString = element.getAttribute("order"); //$NON-NLS-1$
 		if (orderString != null) {
@@ -201,7 +202,7 @@
 				order = Integer.parseInt(orderString);
 			}
 			catch (NumberFormatException e) {
-				Activator.logError(MessageFormat.format(Messages.PortalEditor_PageRankError, id), e);
+				Activator.logError(MessageFormat.format(Messages.PortalEditor_PageRankError, name), e);
 			}
 		}
 		return order;
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java	Mon Sep 20 14:29:54 2010 -0500
@@ -94,6 +94,7 @@
 	}
 
 	private String title;
+	private String tooltip;
 	private ImageDescriptor imageDescriptor;
 	private String id;
 	private final ICommandBarFactory commandBarFactory;
@@ -104,9 +105,10 @@
 	private IAction[] actions;
 	private List<TaskBar> pageTaskBars;
 	
-	public PortalPage(String title, ImageDescriptor imageDescriptor, String id, 
+	public PortalPage(String title, String tooltip, ImageDescriptor imageDescriptor, String id, 
 			List<LayerExtension> layerExtensions, ICommandBarFactory commandBarFactory) {
 		this.title = title;
+		this.tooltip = tooltip;
 		this.imageDescriptor = imageDescriptor;
 		this.id = id;
 		this.commandBarFactory = commandBarFactory;
@@ -131,6 +133,10 @@
 		return title;
 	}
 	
+	public String getTooltip() {
+		return tooltip;
+	}
+	
 	public ImageDescriptor getImageDescriptor() {
 		return imageDescriptor;
 	}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java	Mon Sep 20 13:13:27 2010 -0600
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java	Mon Sep 20 14:29:54 2010 -0500
@@ -313,7 +313,7 @@
 				try {
 					new URL(value);
 				} catch (MalformedURLException e) {
-					value = "http://" + value;
+					value = "http://" + value; //$NON-NLS-1$
 				}
 				return value;
 			};