# HG changeset patch # User dadubrow # Date 1280756685 18000 # Node ID bf670d38123af67ea89cbede69576954f0ccf602 # Parent f77f2721ad5a0181d173813d88854942b7751736 More portal framework changes: support for page command bars in page extension ordering across layers on page abstract discovery UI pages improvements to open editor asap and defer updates if needed diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.cpp.sdk.ui/plugin.xml --- a/core/com.nokia.carbide.cpp.sdk.ui/plugin.xml Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/plugin.xml Mon Aug 02 08:44:45 2010 -0500 @@ -57,6 +57,7 @@ point="com.nokia.carbide.discovery.ui.portalPageLayer"> diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/SDKPreferencePage.java Mon Aug 02 08:44:45 2010 -0500 @@ -82,6 +82,7 @@ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { + sdkList = sdkMgr.getSDKList(); } /* (non-Javadoc) @@ -96,7 +97,6 @@ } shell = parent.getShell(); - sdkList = sdkMgr.getSDKList(); RED = shell.getDisplay().getSystemColor(SWT.COLOR_RED); BLACK = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); GRAY = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKPreferencesPortalPageLayer.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKPreferencesPortalPageLayer.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/SDKPreferencesPortalPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -19,8 +19,11 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; import com.nokia.carbide.cpp.internal.sdk.ui.SDKPreferencePage; +import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; +import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; @SuppressWarnings("restriction") @@ -35,6 +38,7 @@ } public void init() { + preferencePage.init(PlatformUI.getWorkbench()); } public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) { diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/plugin.xml --- a/core/com.nokia.carbide.discovery.ui/plugin.xml Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/plugin.xml Mon Aug 02 08:44:45 2010 -0500 @@ -49,6 +49,7 @@ @@ -87,24 +89,34 @@ + + diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd --- a/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd Mon Aug 02 08:44:45 2010 -0500 @@ -83,6 +83,16 @@ + + + + optionally provide command bars visible in all layers + + + + + + diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/schema/portalPageLayer.exsd --- a/core/com.nokia.carbide.discovery.ui/schema/portalPageLayer.exsd Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/schema/portalPageLayer.exsd Mon Aug 02 08:44:45 2010 -0500 @@ -76,6 +76,13 @@ + + + + relative ordering of layers on a page (integer used to sort layers) + + + diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Mon Aug 02 08:44:45 2010 -0500 @@ -21,18 +21,24 @@ 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.Properties; import org.eclipse.core.net.proxy.IProxyData; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -50,6 +56,8 @@ private static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ private static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ + + private boolean proxyDataAvailable; /** * The constructor @@ -64,13 +72,66 @@ public void start(BundleContext context) throws Exception { plugin = this; super.start(context); - IProxyData proxyData = ProxyUtils.getProxyData(new URI("http://www.yahoo.com")); //$NON-NLS-1$ - if (proxyData != null) { - System.setProperty(PROPERTY_PROXYHOST, proxyData.getHost()); - System.setProperty(PROPERTY_PROXYPORT, String.valueOf(proxyData.getPort())); - } + Job j = new Job("Getting proxy info") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + IProxyData proxyData = ProxyUtils.getProxyData(new URI("http://www.yahoo.com")); + if (proxyData != null) { + System.setProperty(PROPERTY_PROXYHOST, proxyData.getHost()); + System.setProperty(PROPERTY_PROXYPORT, String.valueOf(proxyData.getPort())); + } + } catch (URISyntaxException e) { + } //$NON-NLS-1$ + setProxyDataAvailable(); + return Status.OK_STATUS; + } + }; + j.setSystem(true); + j.setUser(false); + j.schedule(); + } + + private synchronized void setProxyDataAvailable() { + proxyDataAvailable = true; + } + + public synchronized boolean isProxyDataAvailable() { + return proxyDataAvailable; } + public static void runInUIThreadWhenProxyDataSet(final Control control, final Runnable r) { + Job j = new Job("") { + @Override + protected IStatus run(IProgressMonitor monitor) { + setBusyCursor(control, true); + Activator activator = getDefault(); + while (!activator.isProxyDataAvailable()) { + try { + Thread.sleep(200); + } catch (InterruptedException e) { + } + } + setBusyCursor(control, false); + Display.getDefault().asyncExec(r); + return Status.OK_STATUS; + } + }; + j.setSystem(true); + j.setUser(false); + j.schedule(); + } + + public static void setBusyCursor(final Control control, final boolean isBusy) { + final Display display = control.getDisplay(); + display.syncExec(new Runnable() { + @Override + public void run() { + control.setCursor(isBusy ? display.getSystemCursor(SWT.CURSOR_WAIT) : null); + } + }); + } + /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java Mon Aug 02 08:44:45 2010 -0500 @@ -1,3 +1,19 @@ +/* +* 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.discovery.ui; import org.eclipse.osgi.util.NLS; @@ -15,24 +31,30 @@ public static String AbstractBrowserPortalPageLayer_OpenLocationTitle; public static String AbstractBrowserPortalPageLayer_ShowInBrowserLabel; public static String AbstractBrowserPortalPageLayer_URLLabel; + public static String AbstractDiscoveryPortalPageLayer_AdvancedInstallActionLabel; + public static String AbstractDiscoveryPortalPageLayer_CheckAllActionLabel; + public static String AbstractDiscoveryPortalPageLayer_CheckedItemsStatusMessage; + public static String AbstractDiscoveryPortalPageLayer_GatheringExtensionsDesc; + public static String AbstractDiscoveryPortalPageLayer_GatheringInstallInfoDesc; + public static String AbstractDiscoveryPortalPageLayer_InstallActionLabel; + public static String AbstractDiscoveryPortalPageLayer_InstallActionTooltip; + public static String AbstractDiscoveryPortalPageLayer_RefreshActionLabel; + public static String AbstractDiscoveryPortalPageLayer_Title; + public static String AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel; public static String AbstractRSSPortalPageLayer_ReturnToFeedLabel; public static String AbstractRSSPortalPageLayer_RSSReadError; public static String Activator_MissingConfigURLError; - public static String InstallExtensionsPage_AdvancedInstallLabel; - public static String InstallExtensionsPage_CheckAllLabel; - public static String InstallExtensionsPage_GatherExtensionsTitle; - public static String InstallExtensionsPage_GatheringInstallInfoTitle; - public static String InstallExtensionsPage_InstallLabel; - public static String InstallExtensionsPage_InstallTip; - public static String InstallExtensionsPage_RefreshLabel; - public static String InstallExtensionsPage_StatusLineFmt; - public static String InstallExtensionsPage_UncheckAllLabel; - public static String InstallExtensionsPortalExtension_InstallExtensionsTitle; + public static String PortalEditor_BadCommandBarFactoryError; public static String PortalEditor_Name; public static String PortalEditor_NoLayersError; public static String PortalEditor_PageLoadError; public static String PortalEditor_PageOpenError; public static String PortalEditor_PageRankError; + public static String SettingsBarCreator_CapabilitiesActionLabel; + public static String SettingsBarCreator_CodeStyleActionLabel; + public static String SettingsBarCreator_KeyBindingsActionLabel; + public static String SettingsBarCreator_ProxiesActionLabel; + public static String SettingsBarCreator_Title; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Mon Aug 02 08:44:45 2010 -0500 @@ -9,21 +9,27 @@ AbstractBrowserPortalPageLayer_OpenLocationTitle=Open Location AbstractBrowserPortalPageLayer_ShowInBrowserLabel=Show in browser AbstractBrowserPortalPageLayer_URLLabel=URL: +AbstractDiscoveryPortalPageLayer_AdvancedInstallActionLabel=Advanced install... +AbstractDiscoveryPortalPageLayer_CheckAllActionLabel=Check all +AbstractDiscoveryPortalPageLayer_CheckedItemsStatusMessage={0} item(s) checked +AbstractDiscoveryPortalPageLayer_GatheringExtensionsDesc=Gathering Extensions +AbstractDiscoveryPortalPageLayer_GatheringInstallInfoDesc=Gathering Install Information +AbstractDiscoveryPortalPageLayer_InstallActionLabel=Install... +AbstractDiscoveryPortalPageLayer_InstallActionTooltip=Install checked items +AbstractDiscoveryPortalPageLayer_RefreshActionLabel=Refresh +AbstractDiscoveryPortalPageLayer_Title=Install Extensions +AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel=Check none AbstractRSSPortalPageLayer_ReturnToFeedLabel=Return to RSS AbstractRSSPortalPageLayer_RSSReadError=Could not read RSS from: {0} Activator_MissingConfigURLError=Could not find URL in configuration/server.properties file for key={0} -InstallExtensionsPage_AdvancedInstallLabel=Advanced install... -InstallExtensionsPage_CheckAllLabel=Check all -InstallExtensionsPage_GatherExtensionsTitle=Gathering Extensions -InstallExtensionsPage_GatheringInstallInfoTitle=Gathering Install Information -InstallExtensionsPage_InstallLabel=Install... -InstallExtensionsPage_InstallTip=Install checked items -InstallExtensionsPage_RefreshLabel=Refresh -InstallExtensionsPage_StatusLineFmt={0} item(s) checked -InstallExtensionsPage_UncheckAllLabel=Check none -InstallExtensionsPortalExtension_InstallExtensionsTitle=Install Extensions +PortalEditor_BadCommandBarFactoryError=Command bar factory class could not be created for id: {0 PortalEditor_Name=Carbide Portal PortalEditor_NoLayersError=Could not load portal page because no layers were found for id: {0} PortalEditor_PageLoadError=Could not load portal page PortalEditor_PageOpenError=Could not open portal -PortalEditor_PageRankError=Could not get rank for portal page {0} +PortalEditor_PageRankError=Could not get order value for portal page or layer: {0} +SettingsBarCreator_CapabilitiesActionLabel=Capabilities +SettingsBarCreator_CodeStyleActionLabel=Code Style +SettingsBarCreator_KeyBindingsActionLabel=Key bindings +SettingsBarCreator_ProxiesActionLabel=Proxies +SettingsBarCreator_Title=Settings diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/ActionUIUpdater.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/ActionUIUpdater.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/ActionUIUpdater.java Mon Aug 02 08:44:45 2010 -0500 @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; -import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer.IActionUIUpdater; +import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; class ActionUIUpdater implements IActionUIUpdater { diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Mon Aug 02 08:44:45 2010 -0500 @@ -54,12 +54,24 @@ import com.nokia.carbide.discovery.ui.Activator; import com.nokia.carbide.discovery.ui.Messages; +import com.nokia.carbide.internal.discovery.ui.extension.ICommandBarFactory; import com.nokia.carbide.internal.discovery.ui.extension.IPortalEditor; import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; import com.nokia.cpp.internal.api.utils.core.Pair; import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; public class PortalEditor extends EditorPart implements IPortalEditor { + + class LayerExtension { + public LayerExtension(IPortalPageLayer layer, String title, int order) { + this.layer = layer; + this.title = title; + this.order = order; + } + public IPortalPageLayer layer; + public String title; + public int order; + } 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$ @@ -76,19 +88,20 @@ loadPortalPages(); } - private Map>> loadPortalLayers() { - Map>> pageIdToExtensionsMap = - new HashMap>>(); + private Map> loadPortalLayers() { + Map> pageIdToExtensionsMap = + new HashMap>(); IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID + ".portalPageLayer"); //$NON-NLS-1$ for (IConfigurationElement element : elements) { String pageId = element.getAttribute("pageId"); //$NON-NLS-1$ String title = element.getAttribute("title"); //$NON-NLS-1$ + int order = getOrderStringFromElement(element, title); try { IPortalPageLayer extension = (IPortalPageLayer) element.createExecutableExtension("class"); //$NON-NLS-1$ if (!pageIdToExtensionsMap.containsKey(pageId)) - pageIdToExtensionsMap.put(pageId, new ArrayList>()); - pageIdToExtensionsMap.get(pageId).add(new Pair(extension, title)); + pageIdToExtensionsMap.put(pageId, new ArrayList()); + pageIdToExtensionsMap.get(pageId).add(new LayerExtension(extension, title, order)); } catch (CoreException e) { Activator.logError(MessageFormat.format(Messages.PortalEditor_PageLoadError, pageId), e); } @@ -97,31 +110,30 @@ } private void loadPortalPages() { - Map>> portalLayersMap = loadPortalLayers(); + Map> portalLayersMap = loadPortalLayers(); List> pageList = new ArrayList>(); IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID + ".portalPage"); //$NON-NLS-1$ for (IConfigurationElement element : elements) { String id = element.getAttribute("id"); //$NON-NLS-1$ - int order = Integer.MAX_VALUE; - String orderString = element.getAttribute("order"); //$NON-NLS-1$ - if (orderString != null) { - try { - order = Integer.parseInt(orderString); - } - catch (NumberFormatException e) { - Activator.logError(MessageFormat.format(Messages.PortalEditor_PageRankError, id), e); - } - } + int order = getOrderStringFromElement(element, id); String title = element.getAttribute("title"); //$NON-NLS-1$ String imageFilePath = element.getAttribute("image"); //$NON-NLS-1$ String pluginId = element.getContributor().getName(); ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, imageFilePath); - List> portalLayers = portalLayersMap.get(id); + List portalLayers = portalLayersMap.get(id); if (portalLayers == null || portalLayers.isEmpty()) { Activator.logError(MessageFormat.format(Messages.PortalEditor_NoLayersError, id), null); } - PortalPage portalPage = new PortalPage(title, imageDesc, id, portalLayers); + ICommandBarFactory commandBarFactory = null; + if (element.getAttribute("class") != null) { //$NON-NLS-1$ + try { + commandBarFactory = (ICommandBarFactory) element.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + Activator.logError(MessageFormat.format(Messages.PortalEditor_BadCommandBarFactoryError, id), e); + } + } + PortalPage portalPage = new PortalPage(title, imageDesc, id, portalLayers, commandBarFactory); pageList.add(new Pair(portalPage, order)); } Collections.sort(pageList, new Comparator>() { @@ -136,6 +148,20 @@ } } + private int getOrderStringFromElement(IConfigurationElement element, String id) { + int order = Integer.MAX_VALUE; + String orderString = element.getAttribute("order"); //$NON-NLS-1$ + if (orderString != null) { + try { + order = Integer.parseInt(orderString); + } + catch (NumberFormatException e) { + Activator.logError(MessageFormat.format(Messages.PortalEditor_PageRankError, id), e); + } + } + return order; + } + @Override public void doSave(IProgressMonitor monitor) { } diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalPage.java Mon Aug 02 08:44:45 2010 -0500 @@ -17,6 +17,8 @@ package com.nokia.carbide.internal.discovery.ui.editor; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import org.eclipse.jface.action.Action; @@ -29,9 +31,10 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import com.nokia.carbide.internal.discovery.ui.editor.PortalEditor.LayerExtension; +import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; +import com.nokia.carbide.internal.discovery.ui.extension.ICommandBarFactory; import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; -import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer.IActionBar; -import com.nokia.cpp.internal.api.utils.core.Pair; public class PortalPage implements IActionBar { @@ -90,26 +93,34 @@ } } - private String id; private String title; private ImageDescriptor imageDescriptor; + private String id; + private final ICommandBarFactory commandBarFactory; private StackComposite pageComposite; private boolean initialized; private List layers; private Layer currentLayer; private IAction[] actions; - private List navigationTaskBars; + private List pageTaskBars; public PortalPage(String title, ImageDescriptor imageDescriptor, String id, - List> layerExtensionPairs) { + List layerExtensions, ICommandBarFactory commandBarFactory) { this.title = title; this.imageDescriptor = imageDescriptor; this.id = id; - layers = new ArrayList(layerExtensionPairs.size()); - for (Pair layerExtensionTitlePair : layerExtensionPairs) { - layers.add(new Layer(layerExtensionTitlePair.first, layerExtensionTitlePair.second)); + this.commandBarFactory = commandBarFactory; + layers = new ArrayList(layerExtensions.size()); + Collections.sort(layerExtensions, new Comparator() { + @Override + public int compare(LayerExtension o1, LayerExtension o2) { + return o1.order - o2.order; + } + }); + for (LayerExtension layerExtension : layerExtensions) { + layers.add(new Layer(layerExtension.layer, layerExtension.title)); } - navigationTaskBars = new ArrayList(layerExtensionPairs.size()); + pageTaskBars = new ArrayList(layerExtensions.size()); } public String getId() { @@ -157,12 +168,22 @@ GridDataFactory.fillDefaults().grab(false, true).applyTo(taskComposite); TaskBar taskBar = new TaskBar(taskComposite, backgroundParent, this); GridDataFactory.fillDefaults().minSize(150, SWT.DEFAULT).grab(true, false).indent(0, 0).applyTo(taskBar); - navigationTaskBars.add(taskBar); + pageTaskBars.add(taskBar); ActionUIUpdater updater = new ActionUIUpdater(); - IActionBar[] commandBars = layerExtension.createCommandBars(portalEditor, updater); + createCommandBars(backgroundParent, taskComposite, updater, + layerExtension.createCommandBars(portalEditor, updater)); + if (commandBarFactory != null) { + createCommandBars(backgroundParent, taskComposite, updater, + commandBarFactory.createCommandBars(portalEditor, updater)); + + } + } + + private void createCommandBars(Composite backgroundParent, Composite taskComposite, + ActionUIUpdater updater, IActionBar[] commandBars) { if (commandBars != null) { for (IActionBar actionBar : commandBars) { - taskBar = new TaskBar(taskComposite, backgroundParent, actionBar); + TaskBar taskBar = new TaskBar(taskComposite, backgroundParent, actionBar); updater.addTaskBar(taskBar); GridDataFactory.fillDefaults().minSize(150, SWT.DEFAULT).grab(true, false).indent(0, 0).applyTo(taskBar); } @@ -201,7 +222,7 @@ pageComposite.showControl(currentLayer.getControl()); if (!currentLayer.isInitialized()) currentLayer.initialize(); - for (TaskBar taskBar : navigationTaskBars) { + for (TaskBar taskBar : pageTaskBars) { taskBar.updateAllActionsUI(); } } diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/StackComposite.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/StackComposite.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/StackComposite.java Mon Aug 02 08:44:45 2010 -0500 @@ -1,3 +1,19 @@ +/* +* 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.custom.StackLayout; diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Mon Aug 02 08:44:45 2010 -0500 @@ -31,7 +31,7 @@ import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.Hyperlink; -import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer.IActionBar; +import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; class TaskBar extends RoundedCornerComposite { @@ -112,14 +112,18 @@ for (Entry entry : linkToActionMap.entrySet()) { IAction action = entry.getValue(); if (actionId.equals(action.getId())) { - entry.getKey().setEnabled(action.isEnabled()); + Hyperlink link = entry.getKey(); + if (link != null && !link.isDisposed()) + link.setEnabled(entry.getValue().isEnabled()); } } } public void updateAllActionsUI() { for (Entry entry : linkToActionMap.entrySet()) { - entry.getKey().setEnabled(entry.getValue().isEnabled()); + Hyperlink link = entry.getKey(); + if (link != null && !link.isDisposed()) + link.setEnabled(entry.getValue().isEnabled()); } } diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -111,8 +111,8 @@ updater.updateAll(); } - private void setLoading(boolean loading) { - browser.setCursor(loading ? browser.getDisplay().getSystemCursor(SWT.CURSOR_WAIT) : null); + public void setLoading(boolean loading) { + Activator.setBusyCursor(browser, loading); this.loading = loading; } @@ -156,13 +156,19 @@ @Override public void init() { if (browser != null) { - URL url = getURL(); - if (url != null) { - browser.setUrl(url.toString()); - } - actionBar.hookBrowser(); + Activator.runInUIThreadWhenProxyDataSet(browser, new Runnable() { + @Override + public void run() { + URL url = getURL(); + if (url != null) { + browser.setUrl(url.toString()); + actionBar.setLoading(true); + } + actionBar.hookBrowser(); + actionBar.update(); + } + }); } - actionBar.update(); } @Override diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractDiscoveryPortalPageLayer.java --- /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/AbstractDiscoveryPortalPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,324 @@ +/* +* 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 java.net.URI; +import java.net.URISyntaxException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +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.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +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.actions.BaseSelectionListenerAction; + +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 abstract class AbstractDiscoveryPortalPageLayer implements IPortalPageLayer { + + private 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); + } + + } + + protected class ActionBar implements IActionBar { + private IAction[] actions; + + public ActionBar(IEditorPart part) { + actions = makeActions(part); + } + + @Override + public String getTitle() { + return Messages.AbstractDiscoveryPortalPageLayer_Title; + } + + @Override + public IAction[] getActions() { + return actions; + } + + @Override + public String[] getHighlightedActionIds() { + return new String[] {INSTALL_ACTION_ID}; + } + } + + protected static final String INSTALL_ACTION_ID = + AbstractDiscoveryPortalPageLayer.class.getName() + ".install"; //$NON-NLS-1$ + protected static final String UNCHECK_ALL_ACTION_ID = + AbstractDiscoveryPortalPageLayer.class.getName() + ".uncheckAll"; //$NON-NLS-1$ + protected static final String CHECK_ALL_ACTION_ID = + AbstractDiscoveryPortalPageLayer.class.getName() + ".checkAll"; //$NON-NLS-1$ + protected static final String ADV_INSTALL_ACTION_ID = + AbstractDiscoveryPortalPageLayer.class.getName() + ".advancedInstall"; //$NON-NLS-1$ + protected static final String REFRESH_ACTION_ID = + AbstractDiscoveryPortalPageLayer.class.getName() + ".refresh"; //$NON-NLS-1$ + + private CatalogViewer viewer; + private List selectionListeners; + private IActionUIUpdater updater; + + @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.AbstractDiscoveryPortalPageLayer_GatheringExtensionsDesc), + getConfiguration()); + viewer.createControl(c); + GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); + + 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; + return new IActionBar[] { new ActionBar(part) }; + } + + protected CatalogConfiguration getConfiguration() { + CatalogConfiguration configuration = new CatalogConfiguration(); + configuration.setShowTagFilter(false); + return configuration; + } + + protected Catalog getCatalog() { + Catalog catalog = new Catalog(); + catalog.setEnvironment(DiscoveryCore.createEnvironment()); + catalog.setVerifyUpdateSiteAvailability(false); + + // look for remote descriptor + RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy(); + String url = getDirectoryURL(); + if (url != null) { + remoteDiscoveryStrategy.setDirectoryUrl(url); + catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy); + } + else // look for descriptors from installed bundles + catalog.getDiscoveryStrategies().add(new BundleDiscoveryStrategy()); + + return catalog; + } + + protected String getDirectoryURL() { + return Activator.getFromServerProperties(getClass().getName()); + } + + protected IAction[] makeActions(final IEditorPart part) { + selectionListeners = new ArrayList(); + List actions = new ArrayList(); + IAction action; + + // install + action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_InstallActionLabel) { + public void run() { + DiscoveryUi.install(viewer.getCheckedItems(), + new RunnableContextDialog(part.getEditorSite().getShell(), + Messages.AbstractDiscoveryPortalPageLayer_GatheringInstallInfoDesc)); + }; + + protected boolean updateSelection(IStructuredSelection selection) { + scheduleUpdateAllActionUIs(); + return !selection.isEmpty(); + }; + }; + action.setToolTipText(Messages.AbstractDiscoveryPortalPageLayer_InstallActionTooltip); + action.setId(INSTALL_ACTION_ID); + selectionListeners.add((ISelectionChangedListener) action); + actions.add(action); + + // refresh + action = new Action(Messages.AbstractDiscoveryPortalPageLayer_RefreshActionLabel) { + public void run() { + viewer.setSelection(StructuredSelection.EMPTY); + viewer.updateCatalog(); + viewer.refresh(); + } + }; + action.setId(REFRESH_ACTION_ID); + actions.add(action); + + // check all + action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_CheckAllActionLabel) { + public void run() { + viewer.setSelection(StructuredSelection.EMPTY); + viewer.setSelection(getAllItemsSelection()); + viewer.refresh(); + } + + private IStructuredSelection getAllItemsSelection() { + List catalogItems = new ArrayList(); + 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(CHECK_ALL_ACTION_ID); + selectionListeners.add((ISelectionChangedListener) action); + actions.add(action); + + // uncheck all + action = new BaseSelectionListenerAction(Messages.AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel) { + public void run() { + viewer.setSelection(StructuredSelection.EMPTY); + viewer.refresh(); + }; + + protected boolean updateSelection(IStructuredSelection selection) { + scheduleUpdateAllActionUIs(); + return !selection.isEmpty(); + }; + }; + action.setId(UNCHECK_ALL_ACTION_ID); + selectionListeners.add((ISelectionChangedListener) action); + actions.add(action); + + // advanced install + action = new Action(Messages.AbstractDiscoveryPortalPageLayer_AdvancedInstallActionLabel) { + public void run() { + showInstallWizard(); + } + }; + action.setId(ADV_INSTALL_ACTION_ID); + 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.AbstractDiscoveryPortalPageLayer_CheckedItemsStatusMessage, selection.size())); + } + }; + selectionListeners.add(selectionListener); + + return (IAction[]) actions.toArray(new IAction[actions.size()]); + } + + @Override + public void dispose() { + for (ISelectionChangedListener listener : selectionListeners) { + viewer.removeSelectionChangedListener(listener); + } + } + + protected 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); + } + + protected Collection getCatalogURIs() { + Set uris = new HashSet(); + for (CatalogItem catalogItem : viewer.getCatalog().getItems()) { + try { + uris.add(new URI(catalogItem.getSiteUrl())); + } catch (URISyntaxException e) { + // ignore bad URIs + } + } + return uris; + } + + protected void scheduleUpdateAllActionUIs() { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + updater.updateAll(); + } + }); + } + +} \ No newline at end of file diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -1,3 +1,19 @@ +/* +* 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 java.net.URL; @@ -60,17 +76,22 @@ @Override public void init() { - URL url = getURL(); - if (url != null) { - try { - rss = SimpleRSSReader.readRSS(url); - displayRSS(); - actionBar.hookBrowser(); - } catch (Exception e) { - Activator.logError(MessageFormat.format(Messages.AbstractRSSPortalPageLayer_RSSReadError, url), e); + Activator.runInUIThreadWhenProxyDataSet(browser, new Runnable() { + @Override + public void run() { + URL url = getURL(); + if (url != null) { + try { + rss = SimpleRSSReader.readRSS(url); + displayRSS(); + actionBar.hookBrowser(); + } catch (Exception e) { + Activator.logError(MessageFormat.format(Messages.AbstractRSSPortalPageLayer_RSSReadError, url), e); + } + actionBar.update(); + } } - actionBar.update(); - } + }); } private void displayRSS() { diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IActionBar.java --- /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/IActionBar.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,47 @@ +/* +* 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; + +/** + * Interface to an action/navigation bar for the portal portal page layer + */ +public interface IActionBar { + + /** + * Required 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/check + * @return IAction + */ + IAction[] getActions(); + + /** + * Action ids for actions that should be emphasized in the action bar (e.g., bold font) + * @return String[] or null + */ + String[] getHighlightedActionIds(); + +} \ No newline at end of file diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IActionUIUpdater.java --- /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/IActionUIUpdater.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,35 @@ +/* +* 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; + +/** + * 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(); + +} \ No newline at end of file diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/ICommandBarFactory.java --- /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/ICommandBarFactory.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,34 @@ +/* +* 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.ui.IEditorPart; + +/** + * Interface to a factory for command bars for a portal page/layer + */ +public interface ICommandBarFactory { + + /** + * Return action bars for the portal page layer + * @param part IEditorPart + * @param updater IActionUIUpdater + * @return IActionBar[] + */ + IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater); + +} diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IPortalPageLayer.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IPortalPageLayer.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/IPortalPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -16,7 +16,6 @@ */ package com.nokia.carbide.internal.discovery.ui.extension; -import org.eclipse.jface.action.IAction; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IEditorPart; @@ -24,53 +23,7 @@ /** * Interface to a portal page layer extension */ -public interface IPortalPageLayer { - - /** - * Interface to an action/navigation bar for the portal portal page layer - */ - public interface IActionBar { - - /** - * Required 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/check - * @return IAction - */ - IAction[] getActions(); - - /** - * Action ids for actions that should be emphasized in the action bar (e.g., bold font) - * @return String[] or null - */ - String[] getHighlightedActionIds(); - - } - - /** - * 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(); - - } +public interface IPortalPageLayer extends ICommandBarFactory { /** * Called to create the control for the portal page layer @@ -86,14 +39,6 @@ void init(); /** - * Return action bars for the portal page layer - * @param part IEditorPart - * @param updater IActionUIUpdater - * @return IActionBar[] - */ - IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater); - - /** * Called to dispose internal resources of the portal page layer */ void dispose(); diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPortalExtension.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPortalExtension.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPortalExtension.java Mon Aug 02 08:44:45 2010 -0500 @@ -16,338 +16,24 @@ */ package com.nokia.carbide.internal.discovery.ui.view; -import java.net.MalformedURLException; -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.Set; -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.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -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.PartInitException; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.BaseSelectionListenerAction; -import org.eclipse.ui.browser.IWorkbenchBrowserSupport; - -import com.nokia.carbide.discovery.ui.Activator; -import com.nokia.carbide.discovery.ui.Messages; -import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; -import com.nokia.carbide.internal.discovery.ui.extension.OpenPreferencePageAction; -import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; - -@SuppressWarnings("restriction") -public class InstallExtensionsPortalExtension implements IPortalPageLayer { - - private static final String INSTALL_ACTION_ID = InstallExtensionsPortalExtension.class.getName() + ".install"; //$NON-NLS-1$ - - 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 Messages.InstallExtensionsPortalExtension_InstallExtensionsTitle; - } - @Override - public IAction[] getActions() { - return actions; - } - - @Override - public String[] getHighlightedActionIds() { - return new String[] {INSTALL_ACTION_ID}; - } - } - - private class SettingsBar implements IActionBar { - @Override - public String getTitle() { - return "Settings"; - } +import com.nokia.carbide.internal.discovery.ui.extension.AbstractDiscoveryPortalPageLayer; - @Override - public IAction[] getActions() { - List actions = new ArrayList(); - actions.add(new OpenPreferencePageAction( - "Capabilities", - "org.eclipse.sdk.capabilities")); - actions.add(new OpenPreferencePageAction( - "Code Style", - "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage")); - actions.add(new OpenPreferencePageAction( - "Key bindings", - "org.eclipse.ui.preferencePages.Keys")); - actions.add(new OpenPreferencePageAction( - "Proxies", - "org.eclipse.ui.net.NetPreferences")); - return (IAction[]) actions.toArray(new IAction[actions.size()]); - } - - @Override - public String[] getHighlightedActionIds() { - return null; - } - } - - private static final String DIRECTORY_KEY = "com.nokia.carbide.discovery.directory"; //$NON-NLS-1$ - - private CatalogViewer viewer; - private List selectionListeners; - private IActionUIUpdater updater; - - public InstallExtensionsPortalExtension() { - } +public class InstallExtensionsPortalExtension extends AbstractDiscoveryPortalPageLayer { @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.InstallExtensionsPage_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; - return new IActionBar[] { new ActionBar(part), new SettingsBar() }; - } - - 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 = Activator.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; - } + Control control = super.createControl(parent, part); - private IAction[] makeActions(final IEditorPart part) { - selectionListeners = new ArrayList(); - List actions = new ArrayList(); - IAction action; - - // install - action = new BaseSelectionListenerAction(Messages.InstallExtensionsPage_InstallLabel) { - public void run() { - DiscoveryUi.install(viewer.getCheckedItems(), - new RunnableContextDialog(part.getEditorSite().getShell(), - Messages.InstallExtensionsPage_GatheringInstallInfoTitle)); - }; - - protected boolean updateSelection(IStructuredSelection selection) { - scheduleUpdateAllActionUIs(); - return !selection.isEmpty(); - }; - }; - action.setToolTipText(Messages.InstallExtensionsPage_InstallTip); - action.setId(INSTALL_ACTION_ID); - selectionListeners.add((ISelectionChangedListener) action); - actions.add(action); - - // refresh - action = new Action(Messages.InstallExtensionsPage_RefreshLabel) { - public void run() { - viewer.setSelection(StructuredSelection.EMPTY); - viewer.updateCatalog(); - viewer.refresh(); - } - }; - actions.add(action); - - // check all - action = new BaseSelectionListenerAction(Messages.InstallExtensionsPage_CheckAllLabel) { - public void run() { - viewer.setSelection(StructuredSelection.EMPTY); - viewer.setSelection(getAllItemsSelection()); - viewer.refresh(); - } - - private IStructuredSelection getAllItemsSelection() { - List catalogItems = new ArrayList(); - for (CatalogItem catalogItem : viewer.getCatalog().getItems()) { - if (!catalogItem.isInstalled()) - catalogItems.add(catalogItem); - } - return new StructuredSelection(catalogItems); - } + // Create the help context id for the viewer's control + PlatformUI.getWorkbench().getHelpSystem().setHelp(control, + "com.nokia.carbide.discovery.ui.view.DiscoveryView.catalogviewer"); //$NON-NLS-1$ - protected boolean updateSelection(IStructuredSelection selection) { - scheduleUpdateAllActionUIs(); - return !getAllItemsSelection().equals(selection); - } - }; - action.setId(InstallExtensionsPortalExtension.class.getName() + ".checkAll"); //$NON-NLS-1$ - selectionListeners.add((ISelectionChangedListener) action); - actions.add(action); - - // uncheck all - action = new BaseSelectionListenerAction(Messages.InstallExtensionsPage_UncheckAllLabel) { - public void run() { - viewer.setSelection(StructuredSelection.EMPTY); - viewer.refresh(); - }; - - protected boolean updateSelection(IStructuredSelection selection) { - scheduleUpdateAllActionUIs(); - return !selection.isEmpty(); - }; - }; - action.setId(InstallExtensionsPortalExtension.class.getName() + ".uncheckAll"); //$NON-NLS-1$ - selectionListeners.add((ISelectionChangedListener) action); - actions.add(action); - - // advanced install - action = new Action(Messages.InstallExtensionsPage_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.InstallExtensionsPage_StatusLineFmt, selection.size())); - } - }; - selectionListeners.add(selectionListener); - - return (IAction[]) actions.toArray(new IAction[actions.size()]); + return control; } - - @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 getCatalogURIs() { - Set uris = new HashSet(); - 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(); - } - }); - }; } diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/PulsarPageLayer.java --- /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/PulsarPageLayer.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,29 @@ +/* +* 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 com.nokia.carbide.internal.discovery.ui.extension.AbstractDiscoveryPortalPageLayer; + + +public class PulsarPageLayer extends AbstractDiscoveryPortalPageLayer { + + @Override + protected String getDirectoryURL() { + return "http://tools.ext.nokia.com/pulsar/directory.xml"; //$NON-NLS-1$ + } + +} diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SettingsBarCreator.java --- /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/SettingsBarCreator.java Mon Aug 02 08:44:45 2010 -0500 @@ -0,0 +1,68 @@ +/* +* 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.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IEditorPart; + +import com.nokia.carbide.discovery.ui.Messages; +import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; +import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; +import com.nokia.carbide.internal.discovery.ui.extension.ICommandBarFactory; +import com.nokia.carbide.internal.discovery.ui.extension.OpenPreferencePageAction; + +public class SettingsBarCreator implements ICommandBarFactory { + + private class SettingsBar implements IActionBar { + @Override + public String getTitle() { + return Messages.SettingsBarCreator_Title; + } + + @Override + public IAction[] getActions() { + List actions = new ArrayList(); + actions.add(new OpenPreferencePageAction( + Messages.SettingsBarCreator_CapabilitiesActionLabel, + "org.eclipse.sdk.capabilities")); //$NON-NLS-1$ + actions.add(new OpenPreferencePageAction( + Messages.SettingsBarCreator_CodeStyleActionLabel, + "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage")); //$NON-NLS-1$ + actions.add(new OpenPreferencePageAction( + Messages.SettingsBarCreator_KeyBindingsActionLabel, + "org.eclipse.ui.preferencePages.Keys")); //$NON-NLS-1$ + actions.add(new OpenPreferencePageAction( + Messages.SettingsBarCreator_ProxiesActionLabel, + "org.eclipse.ui.net.NetPreferences")); //$NON-NLS-1$ + return (IAction[]) actions.toArray(new IAction[actions.size()]); + } + + @Override + public String[] getHighlightedActionIds() { + return null; + } + } + + @Override + public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) { + return new IActionBar[] { new SettingsBar() }; + } + +} \ No newline at end of file diff -r f77f2721ad5a -r bf670d38123a core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Thu Jul 29 15:31:29 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Mon Aug 02 08:44:45 2010 -0500 @@ -22,6 +22,8 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IEditorPart; +import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; +import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; public class SupportPage implements IPortalPageLayer {