Portal initial commit
authordadubrow
Tue, 13 Jul 2010 15:27:30 -0500
changeset 1609 085da1889c59
parent 1608 231c47d08fe4
child 1611 6bd46a890989
Portal initial commit
core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF
core/com.nokia.carbide.discovery.ui/icons/Carbide_c_icon_16x16.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/discovery/ui/view/DiscoveryView.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/command/LaunchHandler.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/ActionUIUpdater.java
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/RoundedCornerComposite.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SharedBackgroundComposite.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/StackComposite.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IPortalPage.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/DiscoveryView.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/HomePage.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPage.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java
--- a/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF	Mon Jul 12 10:32:59 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF	Tue Jul 13 15:27:30 2010 -0500
@@ -16,7 +16,16 @@
  org.eclipse.equinox.p2.metadata;bundle-version="2.0.0",
  org.eclipse.equinox.p2.repository;bundle-version="2.0.0",
  org.eclipse.equinox.p2.engine;bundle-version="2.0.0",
- com.nokia.cpp.utils.ui;bundle-version="1.0.0"
+ com.nokia.cpp.utils.ui;bundle-version="1.0.0",
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.forms;bundle-version="3.5.0",
+ org.eclipse.core.databinding,
+ org.eclipse.core.databinding.beans,
+ org.eclipse.core.databinding.observable,
+ org.eclipse.core.databinding.property,
+ org.eclipse.jface.databinding,
+ com.ibm.icu
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Vendor: Nokia
Binary file core/com.nokia.carbide.discovery.ui/icons/Carbide_c_icon_16x16.png has changed
--- a/core/com.nokia.carbide.discovery.ui/plugin.properties	Mon Jul 12 10:32:59 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/plugin.properties	Tue Jul 13 15:27:30 2010 -0500
@@ -1,1 +1,2 @@
 view.name=Install Extensions
+menu.title=Carbide Portal
\ No newline at end of file
--- a/core/com.nokia.carbide.discovery.ui/plugin.xml	Mon Jul 12 10:32:59 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/plugin.xml	Tue Jul 13 15:27:30 2010 -0500
@@ -1,33 +1,66 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
-
-   <extension
-         point="org.eclipse.ui.views">
-      <view
-            name="%view.name"
-            icon="icons/icon-discovery.png"
-            category="com.nokia.carbide.cpp"
-            class="com.nokia.carbide.discovery.ui.view.DiscoveryView"
-            id="com.nokia.carbide.discovery.view">
-      </view>
-   </extension>
-   <extension
-         point="org.eclipse.ui.perspectiveExtensions">
-      <perspectiveExtension
-            targetID="com.nokia.carbide.cpp.CarbideCppPerspective">
-         <view
-               id="com.nokia.carbide.discovery.view"
-               relationship="stack"
-               relative="org.eclipse.ui.internal.introview">
-         </view>
-      </perspectiveExtension>
-   </extension>
+   <extension-point id="portalPage" name="Portal Page" schema="schema/portalPage.exsd"/>
    <extension
          point="org.eclipse.help.contexts">
       <contexts
             file="contexts.xml">
       </contexts>
    </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="com.nokia.carbide.internal.discovery.ui.editor.PortalEditor"
+            default="false"
+            icon="icons/Carbide_c_icon_16x16.png"
+            id="com.nokia.carbide.discovery.ui.portalEditor"
+            name="Carbide.c++ Portal">
+      </editor>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            id="com.nokia.carbide.discovery.commands.launch"
+            name="%menu.title">
+      </command>
+   </extension>
+	<extension point="org.eclipse.ui.handlers">
+    	<handler
+			class="com.nokia.carbide.internal.discovery.ui.command.LaunchHandler"
+			commandId="com.nokia.carbide.discovery.commands.launch">
+		</handler>
+	</extension>
+
+	<extension point="org.eclipse.ui.menus">
+		<!-- Defines a new menu contribution to the Eclipse help menu -->
+		<menuContribution
+			locationURI="menu:help?after=helpEnd">
+            <command
+				commandId="com.nokia.carbide.discovery.commands.launch"
+				icon="icons/Carbide_c_icon_16x16.png"
+				label="%menu.title"
+				id="portalCommand">
+			</command>
+		</menuContribution>
+	</extension>
+ <extension
+       point="com.nokia.carbide.discovery.ui.portalPage">
+    <portalPage
+          class="com.nokia.carbide.internal.discovery.ui.view.HomePage">
+    </portalPage>
+ </extension>
+ <extension
+       point="com.nokia.carbide.discovery.ui.portalPage">
+    <portalPage
+          class="com.nokia.carbide.internal.discovery.ui.view.InstallExtensionsPage">
+    </portalPage>
+ </extension>
+ <extension
+       point="com.nokia.carbide.discovery.ui.portalPage">
+    <portalPage
+          class="com.nokia.carbide.internal.discovery.ui.view.SupportPage">
+    </portalPage>
+ </extension>
 
 </plugin>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.nokia.carbide.discovery.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="com.nokia.carbide.discovery.ui" id="portalPage" name="Portal Page"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="portalPage"/>
+         </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="portalPage">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":com.nokia.carbide.internal.discovery.ui.extension.IPortalPage"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/view/DiscoveryView.java	Mon Jul 12 10:32:59 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,307 +0,0 @@
-package com.nokia.carbide.discovery.ui.view;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.equinox.internal.p2.discovery.Catalog;
-import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
-import org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi;
-import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
-import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.operations.ProvisioningSession;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-import org.eclipse.ui.part.ViewPart;
-
-import com.nokia.carbide.discovery.ui.Activator;
-import com.nokia.carbide.discovery.ui.Messages;
-import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
-
-@SuppressWarnings("restriction")
-public class DiscoveryView extends ViewPart {
-	
-	private final class RunnableContextDialog extends ProgressMonitorDialog {
-		private final String title;
-
-		private RunnableContextDialog(Shell parent, String title) {
-			super(parent);
-			this.title = title;
-		}
-
-		@Override
-		protected void configureShell(Shell shell) {
-			super.configureShell(shell);
-			shell.setText(title);
-		}
-		
-	}
-
-	private static final String DIRECTORY_KEY = "com.nokia.carbide.discovery.directory"; //$NON-NLS-1$
-
-	private CatalogViewer viewer;
-	private Action refreshAction;
-	private BaseSelectionListenerAction checkAllAction;
-	private BaseSelectionListenerAction checkNoneAction;
-	private BaseSelectionListenerAction installAction;
-	private Action showInstallWizardAction;
-	private ISelectionChangedListener selectionListener;
-
-	/**
-	 * This is a callback that will allow us
-	 * to create the viewer and initialize it.
-	 */
-	public void createPartControl(Composite parent) {
-		Composite c = new Composite(parent, SWT.NONE);
-		GridLayoutFactory.fillDefaults().applyTo(c);
-		viewer = new CatalogViewer(getCatalog(), getSite(), 
-				new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
-						Messages.DiscoveryView_GatherExtensionsTitle), 
-				getConfiguration());
-		viewer.createControl(c);
-		GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
-		
-		// Create the help context id for the viewer's control
-		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), 
-				"com.nokia.carbide.discovery.ui.view.DiscoveryView.catalogviewer"); //$NON-NLS-1$
-		makeActions();
-		contributeToActionBars();
-		if (!WorkbenchUtils.isJUnitRunning()) { // do not initialize the catalog if JUnit is running
-			getSite().getShell().getDisplay().asyncExec(new Runnable() {
-				@Override
-				public void run() {
-					viewer.updateCatalog();
-				}
-			});
-		}
-	}
-	
-	private CatalogConfiguration getConfiguration() {
-		CatalogConfiguration configuration = new CatalogConfiguration();
-		configuration.setShowTagFilter(false);
-		return configuration;
-	}
-
-	private Catalog getCatalog() {
-		Catalog catalog = new Catalog();
-		catalog.setEnvironment(DiscoveryCore.createEnvironment());
-		catalog.setVerifyUpdateSiteAvailability(false);
-		
-		// look for remote descriptor
-		RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
-		String url = getFromServerProperties(DIRECTORY_KEY);
-		if (url != null) {
-			remoteDiscoveryStrategy.setDirectoryUrl(url);
-			catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
-		}
-		else // look for descriptors from installed bundles
-			catalog.getDiscoveryStrategies().add(new BundleDiscoveryStrategy());
-
-		return catalog;
-	}
-
-	public static String getFromServerProperties(String key) {
-		Location installLocation = Platform.getInstallLocation();
-		URL url = installLocation.getURL();
-		IPath path = new Path(url.getPath());
-		path = path.append("configuration/server.properties"); //$NON-NLS-1$
-		File file = path.toFile();
-		Properties properties = new Properties();
-		try {
-			InputStream is = new FileInputStream(file);
-			properties.load(is);
-			is.close();
-		} catch (IOException e) {
-			String message = 
-				MessageFormat.format(Messages.DiscoveryView_MissingDirectoryURLError, key);
-			Activator.logError(message, e);
-		}
-		return (String) properties.get(key);
-	}
-
-	private void contributeToActionBars() {
-		IActionBars bars = getViewSite().getActionBars();
-		fillLocalPullDown(bars.getMenuManager());
-		fillLocalToolBar(bars.getToolBarManager());
-	}
-
-	private void fillLocalPullDown(IMenuManager manager) {
-		manager.add(checkAllAction);
-		manager.add(checkNoneAction);
-		manager.add(new Separator());
-		manager.add(installAction);
-		manager.add(showInstallWizardAction);
-	}
-
-	private void fillLocalToolBar(IToolBarManager manager) {
-		manager.add(refreshAction);
-		manager.add(installAction);
-	}
-
-	private void makeActions() {
-		refreshAction = new Action() {
-			public void run() {
-				viewer.setSelection(StructuredSelection.EMPTY);
-				viewer.updateCatalog();
-				viewer.refresh();
-			}
-		};
-		refreshAction.setText(Messages.DiscoveryView_RefreshLabel);
-		refreshAction.setImageDescriptor(Activator.getImageDescriptor("icons/refresh.gif")); //$NON-NLS-1$
-		checkAllAction = new BaseSelectionListenerAction(Messages.DiscoveryView_CheckAllLabel) {
-			public void run() {
-				viewer.setSelection(StructuredSelection.EMPTY);
-				viewer.setSelection(getAllItemsSelection());
-				viewer.refresh();
-			}
-
-			private IStructuredSelection getAllItemsSelection() {
-				List<CatalogItem> catalogItems = new ArrayList<CatalogItem>();
-				for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
-					if (!catalogItem.isInstalled())
-						catalogItems.add(catalogItem);
-				}	
-				return new StructuredSelection(catalogItems);
-			}
-
-			protected boolean updateSelection(IStructuredSelection selection) {
-				return !getAllItemsSelection().equals(selection);
-			};
-		};
-		checkNoneAction = new BaseSelectionListenerAction(Messages.DiscoveryView_UncheckAllLabel) {
-			public void run() {
-				viewer.setSelection(StructuredSelection.EMPTY);
-				viewer.refresh();
-			};
-			
-			protected boolean updateSelection(IStructuredSelection selection) {
-				return !selection.isEmpty();
-			};
-		};
-		installAction = new BaseSelectionListenerAction(Messages.DiscoveryView_InstallLabel) {
-			public void run() {
-				DiscoveryUi.install(viewer.getCheckedItems(), 
-						new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
-								Messages.DiscoveryView_GatheringInstallInfoTitle));
-			};
-			
-			protected boolean updateSelection(IStructuredSelection selection) {
-				return !selection.isEmpty();
-			};
-		};
-		installAction.setImageDescriptor(Activator.getImageDescriptor("icons/icon-discovery.png")); //$NON-NLS-1$
-		showInstallWizardAction = new Action(Messages.DiscoveryView_AdvancedInstallLabel) {
-			public void run() {
-				showInstallWizard();
-			}
-		};
-		viewer.addSelectionChangedListener(checkAllAction);
-		viewer.addSelectionChangedListener(checkNoneAction);
-		viewer.addSelectionChangedListener(installAction);
-		selectionListener = new ISelectionChangedListener() {
-			@Override
-			public void selectionChanged(SelectionChangedEvent event) {
-				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
-				IActionBars bars = getViewSite().getActionBars();
-				bars.getStatusLineManager().setMessage(
-						selection.isEmpty() ? null : MessageFormat.format(
-								Messages.DiscoveryView_StatusLineFmt, selection.size()));
-			}
-		};
-		viewer.addSelectionChangedListener(selectionListener);
-	}
-	
-	@Override
-	public void dispose() {
-		viewer.removeSelectionChangedListener(checkAllAction);
-		viewer.removeSelectionChangedListener(checkNoneAction);
-		viewer.removeSelectionChangedListener(installAction);
-		viewer.removeSelectionChangedListener(selectionListener);
-		
-		super.dispose();
-	}
-
-	/**
-	 * Passing the focus request to the viewer's control.
-	 */
-	public void setFocus() {
-	}
-
-	private void showInstallWizard() {
-		ProvisioningUI defaultUI = ProvisioningUI.getDefaultUI();
-		ProvisioningSession session = defaultUI.getSession();
-		IProvisioningAgent agent = session.getProvisioningAgent();
-		IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
-		IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
-		for (URI uri : getCatalogURIs()) {
-			metadataManager.addRepository(uri);
-			artifactManager.addRepository(uri);
-		}
-		defaultUI.openInstallWizard(null, null, null);
-		
-//		String profileId = defaultUI.getProfileId();
-//		IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
-//		IProfile profile = profileRegistry.getProfile(profileId);
-//		IQueryResult<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUGroupQuery(), null);
-//		List<String> list = new ArrayList<String>();
-//		for (Iterator<IInstallableUnit> iter = queryResult.iterator(); iter.hasNext();) {
-//			IInstallableUnit iu = iter.next();
-//			list.add(iu.getId() + "|" + iu.getVersion());
-//		}
-//		Collections.sort(list);
-//		for (String s : list) {
-//			System.out.println(s);
-//		}
-	}
-
-	private Collection<URI> getCatalogURIs() {
-		Set<URI> uris = new HashSet<URI>();
-		for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
-			try {
-				uris.add(new URI(catalogItem.getSiteUrl()));
-			} catch (URISyntaxException e) {
-				// ignore bad URIs
-			}
-		}
-		return uris;
-	};
-
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/command/LaunchHandler.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.command;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.nokia.carbide.internal.discovery.ui.editor.PortalEditor;
+
+public class LaunchHandler extends AbstractHandler {
+
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		PortalEditor.openPortal();
+		return null;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/ActionUIUpdater.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage.IActionUIUpdater;
+
+class ActionUIUpdater implements IActionUIUpdater {
+	
+	private TaskBar taskBar;
+
+	void setTaskBar(TaskBar taskBar) {
+		this.taskBar = taskBar;
+	}
+	
+	@Override
+	public void update(String actionId) {
+		if (taskBar != null)
+			taskBar.updateActionUI(actionId);
+	}
+
+	@Override
+	public void updateAll() {
+		if (taskBar != null)
+			taskBar.updateAllActionsUI();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.RowDataFactory;
+import org.eclipse.jface.layout.RowLayoutFactory;
+import org.eclipse.swt.SWT;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+
+class NavigationBar extends RoundedCornerComposite {
+
+	private PortalEditor portalEditor;
+
+
+	private final class ButtonListener extends SelectionAdapter {
+		@Override
+		public void widgetSelected(SelectionEvent e) {
+			Button button = (Button) e.getSource();
+			selectNavButton(button);
+		}
+	}
+
+	private Map<Button, IPortalPage> buttonToPageMap;
+	private SelectionListener listener;
+	private Font buttonFont;
+	private Font selectedButtonFont;
+	
+	NavigationBar(PortalEditor portalEditor, Composite parent) {
+		super(parent, portalEditor.getBackgroundParent(), 
+				parent.getDisplay().getSystemColor(SWT.COLOR_BLACK),
+				parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+		this.portalEditor = portalEditor;
+		buttonToPageMap = new LinkedHashMap<Button, IPortalPage>();
+		setLayoutData(GridDataFactory.swtDefaults().grab(true, false)
+				.align(SWT.CENTER, SWT.TOP).indent(10, 10).create());
+		setLayout(RowLayoutFactory.swtDefaults().margins(3, 3).pack(false).wrap(false).create());
+		listener = new ButtonListener();
+		buttonFont = this.portalEditor.createFont("Arial", 12, SWT.NORMAL);
+		selectedButtonFont = this.portalEditor.createFont("Arial", 12, SWT.BOLD);
+	}
+
+	public void initUI() {
+		if (buttonToPageMap.isEmpty())
+			return;
+		selectNavButton(buttonToPageMap.keySet().iterator().next());
+	}
+
+	public void addNavButton(NavigationBar bar, IPortalPage page) {
+		Button b = new Button(bar, SWT.TOGGLE | SWT.FLAT);
+		b.setFont(buttonFont);
+		b.setText(page.getText());
+		b.setImage(this.portalEditor.createImage(page.getImageDescriptor()));
+		b.addSelectionListener(listener);
+		b.setLayoutData(RowDataFactory.swtDefaults().hint(200, SWT.DEFAULT).create());
+		buttonToPageMap.put(b, page);
+	}
+
+
+	public void selectNavButton(Button button) {
+		for (Button other : buttonToPageMap.keySet()) {
+			other.setSelection(false);
+			other.setFont(buttonFont);
+		}
+		button.setSelection(true);
+		this.portalEditor.showPage(buttonToPageMap.get(button));
+		button.setFont(selectedButtonFont);
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,287 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+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.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Resource;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.EditorPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage.IActionBar;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+
+public class PortalEditor extends EditorPart {
+
+	private static final String ID = "com.nokia.carbide.discovery.ui.portalEditor"; //$NON-NLS-1$
+	private static final String CONTEXT_ID = ID + ".context"; //$NON-NLS-1$
+	private static IEditorInput input;
+	private List<IPortalPage> uninitializedPages;
+	private Composite backgroundParent;
+	private Image oldBGImg;
+	private List<Resource> resources;
+	private StackComposite stackComposite;
+	
+	private Map<IPortalPage, Control> pageToControlMap;
+	private NavigationBar navigationBar;
+
+	public PortalEditor() {
+		resources = new ArrayList<Resource>();
+		getPortalPages();
+		pageToControlMap = new HashMap<IPortalPage, Control>();
+	}
+	
+	private void getPortalPages() {
+		uninitializedPages = new ArrayList<IPortalPage>();
+		IConfigurationElement[] elements = 
+			Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID + ".portalPage");
+		for (IConfigurationElement element : elements) {
+			try {
+				uninitializedPages.add((IPortalPage) element.createExecutableExtension("class")); //$NON-NLS-1$
+			} 
+			catch (CoreException e) {
+				Activator.logError("Could not load portal page", e);
+			}
+		}
+	}
+
+	@Override
+	public void doSave(IProgressMonitor monitor) {
+	}
+
+	@Override
+	public void doSaveAs() {
+	}
+
+	@Override
+	public boolean isDirty() {
+		return false;
+	}
+
+	@Override
+	public boolean isSaveAsAllowed() {
+		return false;
+	}
+
+	@Override
+	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+		setSite(site);
+		setInput(input);
+	}
+
+	@Override
+	public void createPartControl(final Composite parent) {
+		Composite body = createBody(parent);
+		navigationBar.initUI();
+
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(body, CONTEXT_ID);
+	}
+
+	private Composite createBody(final Composite parent) {
+		// create background
+		backgroundParent = new Composite(parent, SWT.NONE);
+		applyBG(backgroundParent);
+		backgroundParent.setLayout(GridLayoutFactory.fillDefaults().create());
+		// create top naviation bar
+		navigationBar = createNavigationBar(backgroundParent);
+		// create stack composite
+		createStackComposite(backgroundParent, navigationBar);
+		return backgroundParent;
+	}
+
+	private void createStackComposite(Composite parent, NavigationBar bar) {
+		stackComposite = new StackComposite(parent, backgroundParent);
+		for (IPortalPage page : uninitializedPages) {
+			Control control = createPage(page);
+			pageToControlMap.put(page, control);
+		}
+		stackComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
+	}
+
+	private Control createPage(IPortalPage page) {
+		Composite pageComposite = new SharedBackgroundComposite(stackComposite, backgroundParent);
+		pageComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).spacing(20, 0)
+				.extendedMargins(20, 20, 20, 0).create());
+		ActionUIUpdater updater = new ActionUIUpdater();
+		IActionBar[] commandBars = page.createCommandBars(this, updater);
+		if (commandBars.length > 0) {
+			Composite taskComposite = new SharedBackgroundComposite(pageComposite, backgroundParent);
+			taskComposite.setLayout(GridLayoutFactory.fillDefaults().create());
+			taskComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
+			for (IActionBar actionBar : commandBars) {
+				Control control = createTaskBarControl(taskComposite, actionBar, updater);
+				control.setLayoutData(GridDataFactory.fillDefaults().indent(0, 0).create());
+			}
+		}
+		Composite pageControl = new RoundedCornerComposite(pageComposite, backgroundParent, 
+				null, pageComposite.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+		pageControl.setLayout(GridLayoutFactory.fillDefaults().margins(2, 2).create());
+		pageControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
+		Control control = page.createControl(pageControl, this);
+		control.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
+		return pageComposite;
+	}
+
+	private Control createTaskBarControl(Composite clientArea, IActionBar actionBar, ActionUIUpdater updater) {
+		TaskBar taskBar = new TaskBar(clientArea, this, actionBar);
+		updater.setTaskBar(taskBar);
+		return taskBar;
+	}
+
+	private NavigationBar createNavigationBar(Composite parent) {
+		NavigationBar bar = new NavigationBar(this, parent);
+		for (IPortalPage page : uninitializedPages) {
+			bar.addNavButton(bar, page);
+		}
+		
+		return bar;
+	}
+	
+	void showPage(IPortalPage page) {
+		if (uninitializedPages.contains(page)) {
+			uninitializedPages.remove(page);
+			page.init();
+		}
+		stackComposite.showControl(pageToControlMap.get(page));
+	}
+
+	private void applyBG(final Composite composite) {
+		composite.addListener(SWT.Resize, new Listener() {
+			@Override
+			public void handleEvent(Event event) {
+				Rectangle rect = composite.getClientArea();
+				Image newImage = new Image(composite.getDisplay(), rect.width, rect.height);
+				GC gc = new GC(newImage);
+				gc.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+				gc.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+				gc.fillGradientRectangle(0, 0, rect.width, rect.height, true);
+				gc.dispose();
+				composite.setBackgroundImage(newImage);
+
+				if (oldBGImg != null)
+					oldBGImg.dispose();
+				oldBGImg = newImage;
+			}
+		});
+	}
+
+	@Override
+	public void setFocus() {
+	}
+	
+	public static void openPortal() {
+		try {
+			WorkbenchUtils.openEditor(getInput(), ID);
+		} catch (PartInitException e) {
+			Activator.logError("Could not open portal", e);
+		}
+	}
+
+	private static IEditorInput getInput() {
+		if (input == null) {
+			input = new IEditorInput() {
+				@SuppressWarnings("rawtypes")
+				@Override
+				public Object getAdapter(Class adapter) {
+					return null;
+				}
+				
+				@Override
+				public String getToolTipText() {
+					return getName();
+				}
+				
+				@Override
+				public IPersistableElement getPersistable() {
+					return null;
+				}
+				
+				@Override
+				public String getName() {
+					return "Carbide.c++ Portal";
+				}
+				
+				@Override
+				public ImageDescriptor getImageDescriptor() {
+					return null;
+				}
+				
+				@Override
+				public boolean exists() {
+					return false;
+				}
+			};
+		}
+			
+		return input;
+	}
+	
+	Image createImage(ImageDescriptor desc) {
+//		Image image = new Image(Display.getCurrent(), desc.getImageData().scaledTo(16, 16));
+		Image image = desc.createImage();
+		resources.add(image);
+		return image;
+	}
+	
+	Font createFont(String name, int height, int style) {
+		Font font = new Font(Display.getCurrent(), name, height, style);
+		
+		resources.add(font);
+		return font;
+	}
+	
+	@Override
+	public void dispose() {
+		super.dispose();
+		for (Resource resource : resources) {
+			resource.dispose();
+		}
+		if (oldBGImg != null)
+			oldBGImg.dispose();
+	}
+
+	public Composite getBackgroundParent() {
+		return backgroundParent;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/RoundedCornerComposite.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Composite;
+
+class RoundedCornerComposite extends SharedBackgroundComposite {
+
+	private final Color background;
+	private final Color outline;
+
+	public RoundedCornerComposite(Composite parent, Composite backgroundParent, Color outline, Color background) {
+		super(parent, backgroundParent);
+		this.background = background;
+		this.outline = outline;
+	}
+
+	@Override
+	public void drawBackground(GC gc, int x, int y, int width, int height) {
+		super.drawBackground(gc, x, y, width, height);
+		if (background != null) {
+			gc.setBackground(background);
+			gc.fillRoundRectangle(0, 0, width, height, 5, 5);
+		}
+		if (outline != null) {
+			gc.setForeground(outline);
+			gc.drawRoundRectangle(2, 2, width - 4, height - 4, 5, 5);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SharedBackgroundComposite.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+
+class SharedBackgroundComposite extends Canvas {
+
+	private final Composite backgroundParent;
+
+	public SharedBackgroundComposite(Composite parent, Composite backgroundParent) {
+		super(parent, SWT.NO_BACKGROUND);
+		this.backgroundParent = backgroundParent;
+		addPaintListener(new PaintListener() {
+			@Override
+			public void paintControl(PaintEvent e) {
+				Rectangle b = getBounds();
+				drawBackground(e.gc, b.x, b.y, b.width, b.height);
+			}
+		});
+	}
+	
+	@Override
+	public void drawBackground(GC gc, int x, int y, int width, int height) {
+		Composite relParent = getParent();
+		while (relParent != backgroundParent) {
+			Rectangle relB = relParent.getBounds();
+			x += relB.x;
+			y += relB.y;
+			relParent = relParent.getParent();
+		}
+
+		Image image = backgroundParent.getBackgroundImage();
+		Rectangle imageBounds = image.getBounds();
+		width = Math.min(width, imageBounds.width - x);
+		height = Math.min(height, imageBounds.height - y);
+		if (width > 0 && height > 0)
+			gc.drawImage(image, x, y, width, height, 0, 0, width, height);
+//		gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
+//		gc.drawRectangle(1, 1, width - 2, height - 2);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/StackComposite.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,26 @@
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class StackComposite extends SharedBackgroundComposite {
+
+	private StackLayout stackLayout;
+	private Control currentControl;
+
+	public StackComposite(Composite parent, Composite backgroundParent) {
+		super(parent, backgroundParent);
+		stackLayout = new StackLayout();
+		setLayout(stackLayout);
+	}
+
+	public void showControl(Control control) {
+		if (control == currentControl)
+			return;
+
+		stackLayout.topControl = control;
+		layout();
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.editor;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.RowDataFactory;
+import org.eclipse.jface.layout.RowLayoutFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage.IActionBar;
+
+class TaskBar extends RoundedCornerComposite {
+
+	private final class ActionListener implements IHyperlinkListener {
+		@Override
+		public void linkActivated(HyperlinkEvent e) {
+			Hyperlink link = (Hyperlink) e.getSource();
+			runAction(link);
+		}
+		
+		@Override
+		public void linkEntered(HyperlinkEvent e) {
+			Hyperlink link = (Hyperlink) e.getSource();
+			link.setUnderlined(true);
+		}
+		
+		@Override
+		public void linkExited(HyperlinkEvent e) {
+			Hyperlink link = (Hyperlink) e.getSource();
+			link.setUnderlined(false);
+		}
+	}
+
+	private PortalEditor portalEditor;
+	private Map<Hyperlink, IAction> linkToActionMap;
+	private ActionListener listener;
+
+	public TaskBar(Composite parent, PortalEditor portalEditor, IActionBar actionBar) {
+		super(parent, portalEditor.getBackgroundParent(), 
+				parent.getDisplay().getSystemColor(SWT.COLOR_BLACK),
+				parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+		this.portalEditor = portalEditor;
+		createTitle(actionBar);
+		createActions(actionBar);
+		setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).create());
+		setLayout(RowLayoutFactory.swtDefaults().type(SWT.VERTICAL).margins(10, 10).extendedMargins(5, 5, 5, 10).fill(true).wrap(false).create());
+	}
+
+	private void createTitle(IActionBar actionBar) {
+		String title = actionBar.getTitle();
+		if (title != null) {
+			Label l = new Label(this, SWT.LEFT);
+			l.setFont(portalEditor.createFont("Arial", 10, SWT.BOLD));
+			l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+			l.setText(title);
+			l.setLayoutData(RowDataFactory.swtDefaults().create());
+			l = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR);
+			l.setLayoutData(RowDataFactory.swtDefaults().create());
+		}
+	}
+
+	private void createActions(IActionBar actionBar) {
+		listener = new ActionListener();
+		linkToActionMap = new HashMap<Hyperlink, IAction>();
+		for (IAction action : actionBar.getActions()) {
+			Hyperlink link = new Hyperlink(this, SWT.NONE);
+			link.setText(action.getText());
+			String toolTipText = action.getToolTipText();
+			if (toolTipText != null)
+				link.setToolTipText(toolTipText);
+			link.setBackground(link.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+			linkToActionMap.put(link, action);
+			link.addHyperlinkListener(listener);
+		}
+//		updateAllActionsUI();
+	}
+	
+	public void runAction(Hyperlink link) {
+		IAction action = linkToActionMap.get(link);
+		action.run();
+	}
+
+	public void updateActionUI(String actionId) {
+		for (Entry<Hyperlink, IAction> entry : linkToActionMap.entrySet()) {
+			IAction action = entry.getValue();
+			if (actionId.equals(action.getId())) {
+				entry.getKey().setEnabled(action.isEnabled());
+			}
+		}
+	}
+
+	public void updateAllActionsUI() {
+		for (Entry<Hyperlink, IAction> entry : linkToActionMap.entrySet()) {
+			entry.getKey().setEnabled(entry.getValue().isEnabled());
+		}
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IPortalPage.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.extension;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Interface to a portal page extension
+ */
+public interface IPortalPage {
+
+	/**
+	 * Interface to an action/navigation bar for the portal page
+	 */
+	public interface IActionBar {
+		
+		/**
+		 * Optional title for the action bar
+		 * @return String
+		 */
+		String getTitle();
+		
+		/**
+		 * Actions shown in the action bar:
+		 * Required: text and run() methods
+		 * Optional: tool tip text
+		 * Unused: image
+		 * @return IAction
+		 */
+		IAction[] getActions();
+
+	}
+	
+	/**
+	 * Interface allowing the UI for provided actions of an IActionBar to be updated (e.g., enabled state)
+	 */
+	public interface IActionUIUpdater {
+		
+		/**
+		 * Update the UI for a specific action by id
+		 * @param actionId
+		 */
+		void update(String actionId);
+		
+		/**
+		 * Update the UI for all actions in the IActionBar
+		 */
+		void updateAll();
+		
+	}
+
+	/**
+	 * Required title text used by main navigation bar
+	 * @return String
+	 */
+	String getText();
+	
+	/**
+	 * Required image descriptor used by main navigation bar
+	 * @return ImageDescriptor
+	 */
+	ImageDescriptor getImageDescriptor();
+	
+	/**
+	 * Called to create the control for the page
+	 * @param parent Composite
+	 * @param part IEditorPart
+	 * @return Control
+	 */
+	Control createControl(Composite parent, IEditorPart part);
+	
+	/**
+	 * Called to initialize the page when shown for the first time
+	 */
+	void init();
+	
+	/**
+	 * Return action bars for the page (can't be null)
+	 * @param part IEditorPart
+	 * @param updater IActionUIUpdater
+	 * @return IActionBar[]
+	 */
+	IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater);
+	
+	/**
+	 * Called to dispose internal resources of the page
+	 */
+	void dispose();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/DiscoveryView.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,323 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.internal.discovery.ui.view;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.p2.discovery.Catalog;
+import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.eclipse.ui.part.ViewPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+
+@SuppressWarnings("restriction")
+public class DiscoveryView extends ViewPart {
+	
+	private final class RunnableContextDialog extends ProgressMonitorDialog {
+		private final String title;
+
+		private RunnableContextDialog(Shell parent, String title) {
+			super(parent);
+			this.title = title;
+		}
+
+		@Override
+		protected void configureShell(Shell shell) {
+			super.configureShell(shell);
+			shell.setText(title);
+		}
+		
+	}
+
+	private static final String DIRECTORY_KEY = "com.nokia.carbide.discovery.directory"; //$NON-NLS-1$
+
+	private CatalogViewer viewer;
+	private Action refreshAction;
+	private BaseSelectionListenerAction checkAllAction;
+	private BaseSelectionListenerAction checkNoneAction;
+	private BaseSelectionListenerAction installAction;
+	private Action showInstallWizardAction;
+	private ISelectionChangedListener selectionListener;
+
+	/**
+	 * This is a callback that will allow us
+	 * to create the viewer and initialize it.
+	 */
+	public void createPartControl(Composite parent) {
+		Composite c = new Composite(parent, SWT.NONE);
+		GridLayoutFactory.fillDefaults().applyTo(c);
+		viewer = new CatalogViewer(getCatalog(), getSite(), 
+				new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
+						Messages.DiscoveryView_GatherExtensionsTitle), 
+				getConfiguration());
+		viewer.createControl(c);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
+		
+		// Create the help context id for the viewer's control
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), 
+				"com.nokia.carbide.discovery.ui.view.DiscoveryView.catalogviewer"); //$NON-NLS-1$
+		makeActions();
+		contributeToActionBars();
+		if (!WorkbenchUtils.isJUnitRunning()) { // do not initialize the catalog if JUnit is running
+			getSite().getShell().getDisplay().asyncExec(new Runnable() {
+				@Override
+				public void run() {
+					viewer.updateCatalog();
+				}
+			});
+		}
+	}
+	
+	private CatalogConfiguration getConfiguration() {
+		CatalogConfiguration configuration = new CatalogConfiguration();
+		configuration.setShowTagFilter(false);
+		return configuration;
+	}
+
+	private Catalog getCatalog() {
+		Catalog catalog = new Catalog();
+		catalog.setEnvironment(DiscoveryCore.createEnvironment());
+		catalog.setVerifyUpdateSiteAvailability(false);
+		
+		// look for remote descriptor
+		RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
+		String url = getFromServerProperties(DIRECTORY_KEY);
+		if (url != null) {
+			remoteDiscoveryStrategy.setDirectoryUrl(url);
+			catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+		}
+		else // look for descriptors from installed bundles
+			catalog.getDiscoveryStrategies().add(new BundleDiscoveryStrategy());
+
+		return catalog;
+	}
+
+	public static String getFromServerProperties(String key) {
+		Location installLocation = Platform.getInstallLocation();
+		URL url = installLocation.getURL();
+		IPath path = new Path(url.getPath());
+		path = path.append("configuration/server.properties"); //$NON-NLS-1$
+		File file = path.toFile();
+		Properties properties = new Properties();
+		try {
+			InputStream is = new FileInputStream(file);
+			properties.load(is);
+			is.close();
+		} catch (IOException e) {
+			String message = 
+				MessageFormat.format(Messages.DiscoveryView_MissingDirectoryURLError, key);
+			Activator.logError(message, e);
+		}
+		return (String) properties.get(key);
+	}
+
+	private void contributeToActionBars() {
+		IActionBars bars = getViewSite().getActionBars();
+		fillLocalPullDown(bars.getMenuManager());
+		fillLocalToolBar(bars.getToolBarManager());
+	}
+
+	private void fillLocalPullDown(IMenuManager manager) {
+		manager.add(checkAllAction);
+		manager.add(checkNoneAction);
+		manager.add(new Separator());
+		manager.add(installAction);
+		manager.add(showInstallWizardAction);
+	}
+
+	private void fillLocalToolBar(IToolBarManager manager) {
+		manager.add(refreshAction);
+		manager.add(installAction);
+	}
+
+	private void makeActions() {
+		refreshAction = new Action() {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.updateCatalog();
+				viewer.refresh();
+			}
+		};
+		refreshAction.setText(Messages.DiscoveryView_RefreshLabel);
+		refreshAction.setImageDescriptor(Activator.getImageDescriptor("icons/refresh.gif")); //$NON-NLS-1$
+		checkAllAction = new BaseSelectionListenerAction(Messages.DiscoveryView_CheckAllLabel) {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.setSelection(getAllItemsSelection());
+				viewer.refresh();
+			}
+
+			private IStructuredSelection getAllItemsSelection() {
+				List<CatalogItem> catalogItems = new ArrayList<CatalogItem>();
+				for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
+					if (!catalogItem.isInstalled())
+						catalogItems.add(catalogItem);
+				}	
+				return new StructuredSelection(catalogItems);
+			}
+
+			protected boolean updateSelection(IStructuredSelection selection) {
+				return !getAllItemsSelection().equals(selection);
+			};
+		};
+		checkNoneAction = new BaseSelectionListenerAction(Messages.DiscoveryView_UncheckAllLabel) {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.refresh();
+			};
+			
+			protected boolean updateSelection(IStructuredSelection selection) {
+				return !selection.isEmpty();
+			};
+		};
+		installAction = new BaseSelectionListenerAction(Messages.DiscoveryView_InstallLabel) {
+			public void run() {
+				DiscoveryUi.install(viewer.getCheckedItems(), 
+						new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
+								Messages.DiscoveryView_GatheringInstallInfoTitle));
+			};
+			
+			protected boolean updateSelection(IStructuredSelection selection) {
+				return !selection.isEmpty();
+			};
+		};
+		installAction.setImageDescriptor(Activator.getImageDescriptor("icons/icon-discovery.png")); //$NON-NLS-1$
+		showInstallWizardAction = new Action(Messages.DiscoveryView_AdvancedInstallLabel) {
+			public void run() {
+				showInstallWizard();
+			}
+		};
+		viewer.addSelectionChangedListener(checkAllAction);
+		viewer.addSelectionChangedListener(checkNoneAction);
+		viewer.addSelectionChangedListener(installAction);
+		selectionListener = new ISelectionChangedListener() {
+			@Override
+			public void selectionChanged(SelectionChangedEvent event) {
+				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+				IActionBars bars = getViewSite().getActionBars();
+				bars.getStatusLineManager().setMessage(
+						selection.isEmpty() ? null : MessageFormat.format(
+								Messages.DiscoveryView_StatusLineFmt, selection.size()));
+			}
+		};
+		viewer.addSelectionChangedListener(selectionListener);
+	}
+	
+	@Override
+	public void dispose() {
+		viewer.removeSelectionChangedListener(checkAllAction);
+		viewer.removeSelectionChangedListener(checkNoneAction);
+		viewer.removeSelectionChangedListener(installAction);
+		viewer.removeSelectionChangedListener(selectionListener);
+		
+		super.dispose();
+	}
+
+	/**
+	 * Passing the focus request to the viewer's control.
+	 */
+	public void setFocus() {
+	}
+
+	private void showInstallWizard() {
+		ProvisioningUI defaultUI = ProvisioningUI.getDefaultUI();
+		ProvisioningSession session = defaultUI.getSession();
+		IProvisioningAgent agent = session.getProvisioningAgent();
+		IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+		IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+		for (URI uri : getCatalogURIs()) {
+			metadataManager.addRepository(uri);
+			artifactManager.addRepository(uri);
+		}
+		defaultUI.openInstallWizard(null, null, null);
+		
+//		String profileId = defaultUI.getProfileId();
+//		IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+//		IProfile profile = profileRegistry.getProfile(profileId);
+//		IQueryResult<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUGroupQuery(), null);
+//		List<String> list = new ArrayList<String>();
+//		for (Iterator<IInstallableUnit> iter = queryResult.iterator(); iter.hasNext();) {
+//			IInstallableUnit iu = iter.next();
+//			list.add(iu.getId() + "|" + iu.getVersion());
+//		}
+//		Collections.sort(list);
+//		for (String s : list) {
+//			System.out.println(s);
+//		}
+	}
+
+	private Collection<URI> getCatalogURIs() {
+		Set<URI> uris = new HashSet<URI>();
+		for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
+			try {
+				uris.add(new URI(catalogItem.getSiteUrl()));
+			} catch (URISyntaxException e) {
+				// ignore bad URIs
+			}
+		}
+		return uris;
+	};
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/HomePage.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,47 @@
+package com.nokia.carbide.internal.discovery.ui.view;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+
+public class HomePage implements IPortalPage {
+
+	public HomePage() {
+	}
+
+	@Override
+	public String getText() {
+		return "Home";
+	}
+
+	@Override
+	public ImageDescriptor getImageDescriptor() {
+		return Activator.getImageDescriptor("icons/Carbide_c_icon_16x16.png");
+	}
+
+	@Override
+	public Control createControl(Composite parent, IEditorPart part) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+		return composite;
+	}
+
+	@Override
+	public void init() {
+	}
+	
+	@Override
+	public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) {
+		return new IActionBar[0];
+	}
+
+	@Override
+	public void dispose() {
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPage.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,329 @@
+package com.nokia.carbide.internal.discovery.ui.view;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.p2.discovery.Catalog;
+import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+
+@SuppressWarnings("restriction")
+public class InstallExtensionsPage implements IPortalPage {
+
+	private final class RunnableContextDialog extends ProgressMonitorDialog {
+		private final String title;
+
+		private RunnableContextDialog(Shell parent, String title) {
+			super(parent);
+			this.title = title;
+		}
+
+		@Override
+		protected void configureShell(Shell shell) {
+			super.configureShell(shell);
+			shell.setText(title);
+		}
+		
+	}
+
+	private final class ActionBar implements IActionBar {
+		private IAction[] actions;
+
+		public ActionBar(IEditorPart part) {
+			actions = makeActions(part);
+		}
+		
+		@Override
+		public String getTitle() {
+			return "Install Extensions";
+		}
+
+		@Override
+		public IAction[] getActions() {
+			return actions;
+		}
+	}
+
+	private static final String DIRECTORY_KEY = "com.nokia.carbide.discovery.directory"; //$NON-NLS-1$
+
+	private CatalogViewer viewer;
+	private List<ISelectionChangedListener> selectionListeners;
+	private IActionBar actionBar;
+	private IActionUIUpdater updater;
+
+	public InstallExtensionsPage() {
+	}
+
+	@Override
+	public String getText() {
+		return "Install Extensions";
+	}
+
+	@Override
+	public ImageDescriptor getImageDescriptor() {
+		return Activator.getImageDescriptor("icons/icon-discovery.png"); //$NON-NLS-1$
+	}
+
+	@Override
+	public Control createControl(Composite parent, IEditorPart part) {
+		Composite c = new Composite(parent, SWT.NONE);
+		GridLayoutFactory.swtDefaults().applyTo(c);
+		viewer = new CatalogViewer(getCatalog(), part.getEditorSite(), 
+				new RunnableContextDialog(part.getEditorSite().getShell(), 
+						Messages.DiscoveryView_GatherExtensionsTitle), 
+				getConfiguration());
+		viewer.createControl(c);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
+		
+		// Create the help context id for the viewer's control
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), 
+				"com.nokia.carbide.discovery.ui.view.DiscoveryView.catalogviewer"); //$NON-NLS-1$
+		return c;
+	}
+
+	@Override
+	public void init() {
+		if (!WorkbenchUtils.isJUnitRunning()) { // do not initialize the catalog if JUnit is running
+			Display.getDefault().asyncExec(new Runnable() {
+				@Override
+				public void run() {
+					for (ISelectionChangedListener listener : selectionListeners) {
+						viewer.addSelectionChangedListener(listener);
+					}
+					viewer.updateCatalog();
+				}
+			});
+		}
+	}
+	
+	@Override
+	public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) {
+		this.updater = updater;
+		actionBar = new ActionBar(part);
+		return new IActionBar[] { actionBar };
+	}
+
+	private CatalogConfiguration getConfiguration() {
+		CatalogConfiguration configuration = new CatalogConfiguration();
+		configuration.setShowTagFilter(false);
+		return configuration;
+	}
+
+	private Catalog getCatalog() {
+		Catalog catalog = new Catalog();
+		catalog.setEnvironment(DiscoveryCore.createEnvironment());
+		catalog.setVerifyUpdateSiteAvailability(false);
+		
+		// look for remote descriptor
+		RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
+		String url = getFromServerProperties(DIRECTORY_KEY);
+		if (url != null) {
+			remoteDiscoveryStrategy.setDirectoryUrl(url);
+			catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+		}
+		else // look for descriptors from installed bundles
+			catalog.getDiscoveryStrategies().add(new BundleDiscoveryStrategy());
+
+		return catalog;
+	}
+
+	public static String getFromServerProperties(String key) {
+		Location installLocation = Platform.getInstallLocation();
+		URL url = installLocation.getURL();
+		IPath path = new Path(url.getPath());
+		path = path.append("configuration/server.properties"); //$NON-NLS-1$
+		File file = path.toFile();
+		Properties properties = new Properties();
+		try {
+			InputStream is = new FileInputStream(file);
+			properties.load(is);
+			is.close();
+		} catch (IOException e) {
+			String message = 
+				MessageFormat.format(Messages.DiscoveryView_MissingDirectoryURLError, key);
+			Activator.logError(message, e);
+		}
+		return (String) properties.get(key);
+	}
+
+	private IAction[] makeActions(final IEditorPart part) {
+		selectionListeners = new ArrayList<ISelectionChangedListener>();
+		List<IAction> actions = new ArrayList<IAction>();
+		IAction action = new Action(Messages.DiscoveryView_RefreshLabel) {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.updateCatalog();
+				viewer.refresh();
+			}
+		};
+		actions.add(action);
+		
+		action = new BaseSelectionListenerAction(Messages.DiscoveryView_CheckAllLabel) {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.setSelection(getAllItemsSelection());
+				viewer.refresh();
+			}
+
+			private IStructuredSelection getAllItemsSelection() {
+				List<CatalogItem> catalogItems = new ArrayList<CatalogItem>();
+				for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
+					if (!catalogItem.isInstalled())
+						catalogItems.add(catalogItem);
+				}	
+				return new StructuredSelection(catalogItems);
+			}
+
+			protected boolean updateSelection(IStructuredSelection selection) {
+				scheduleUpdateAllActionUIs();
+				return !getAllItemsSelection().equals(selection);
+			}
+		};
+		action.setId(getClass().getName() + ".checkAll");
+		selectionListeners.add((ISelectionChangedListener) action);
+		actions.add(action);
+		
+		action = new BaseSelectionListenerAction(Messages.DiscoveryView_UncheckAllLabel) {
+			public void run() {
+				viewer.setSelection(StructuredSelection.EMPTY);
+				viewer.refresh();
+			};
+			
+			protected boolean updateSelection(IStructuredSelection selection) {
+				scheduleUpdateAllActionUIs();
+				return !selection.isEmpty();
+			};
+		};
+		action.setId(getClass().getName() + ".uncheckAll");
+		selectionListeners.add((ISelectionChangedListener) action);
+		actions.add(action);
+
+		action = new BaseSelectionListenerAction(Messages.DiscoveryView_InstallLabel) {
+			public void run() {
+				DiscoveryUi.install(viewer.getCheckedItems(), 
+						new RunnableContextDialog(part.getEditorSite().getShell(), 
+								Messages.DiscoveryView_GatheringInstallInfoTitle));
+			};
+			
+			protected boolean updateSelection(IStructuredSelection selection) {
+				scheduleUpdateAllActionUIs();
+				return !selection.isEmpty();
+			};
+		};
+		action.setId(getClass().getName() + ".install");
+		selectionListeners.add((ISelectionChangedListener) action);
+		actions.add(action);
+
+		action = new Action(Messages.DiscoveryView_AdvancedInstallLabel) {
+			public void run() {
+				showInstallWizard();
+			}
+		};
+		actions.add(action);
+		
+		ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
+			@Override
+			public void selectionChanged(SelectionChangedEvent event) {
+				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+				IActionBars bars = part.getEditorSite().getActionBars();
+				bars.getStatusLineManager().setMessage(
+						selection.isEmpty() ? null : MessageFormat.format(
+								Messages.DiscoveryView_StatusLineFmt, selection.size()));
+			}
+		};
+		selectionListeners.add(selectionListener);
+		
+		return (IAction[]) actions.toArray(new IAction[actions.size()]);
+	}
+	
+	@Override
+	public void dispose() {
+		for (ISelectionChangedListener listener : selectionListeners) {
+			viewer.removeSelectionChangedListener(listener);
+		}
+	}
+
+	private void showInstallWizard() {
+		ProvisioningUI defaultUI = ProvisioningUI.getDefaultUI();
+		ProvisioningSession session = defaultUI.getSession();
+		IProvisioningAgent agent = session.getProvisioningAgent();
+		IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+		IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+		for (URI uri : getCatalogURIs()) {
+			metadataManager.addRepository(uri);
+			artifactManager.addRepository(uri);
+		}
+		defaultUI.openInstallWizard(null, null, null);
+	}
+
+	private Collection<URI> getCatalogURIs() {
+		Set<URI> uris = new HashSet<URI>();
+		for (CatalogItem catalogItem : viewer.getCatalog().getItems()) {
+			try {
+				uris.add(new URI(catalogItem.getSiteUrl()));
+			} catch (URISyntaxException e) {
+				// ignore bad URIs
+			}
+		}
+		return uris;
+	};
+
+	private void scheduleUpdateAllActionUIs() {
+		Display.getDefault().asyncExec(new Runnable() {
+			@Override
+			public void run() {
+				updater.updateAll();
+			}
+		});
+	};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java	Tue Jul 13 15:27:30 2010 -0500
@@ -0,0 +1,47 @@
+package com.nokia.carbide.internal.discovery.ui.view;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage;
+
+public class SupportPage implements IPortalPage {
+
+	public SupportPage() {
+	}
+
+	@Override
+	public String getText() {
+		return "Carbide Support";
+	}
+
+	@Override
+	public ImageDescriptor getImageDescriptor() {
+		return Activator.getImageDescriptor("icons/Carbide_c_icon_16x16.png");
+	}
+
+	@Override
+	public Control createControl(Composite parent, IEditorPart part) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+		return composite;
+	}
+
+	@Override
+	public void init() {
+	}
+	
+	@Override
+	public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) {
+		return new IActionBar[0];
+	}
+
+	@Override
+	public void dispose() {
+	}
+
+}