# HG changeset patch # User dadubrow # Date 1279137633 18000 # Node ID 1828ccdd6878b5ad111201a5a7b1c4337439685c # Parent d5f384bf1e88c9fab0c813a210c9af112120f321 add ranking to portal page extension diff -r d5f384bf1e88 -r 1828ccdd6878 core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF --- a/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF Wed Jul 14 12:01:27 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF Wed Jul 14 15:00:33 2010 -0500 @@ -17,15 +17,10 @@ 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.core;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 + org.eclipse.ui.forms;bundle-version="3.5.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: Nokia diff -r d5f384bf1e88 -r 1828ccdd6878 core/com.nokia.carbide.discovery.ui/plugin.xml --- a/core/com.nokia.carbide.discovery.ui/plugin.xml Wed Jul 14 12:01:27 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/plugin.xml Wed Jul 14 15:00:33 2010 -0500 @@ -48,19 +48,22 @@ + class="com.nokia.carbide.internal.discovery.ui.view.InstallExtensionsPage" + rank="50"> + class="com.nokia.carbide.internal.discovery.ui.view.HomePage" + rank="1"> + class="com.nokia.carbide.internal.discovery.ui.view.SupportPage" + rank="100"> diff -r d5f384bf1e88 -r 1828ccdd6878 core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd --- a/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd Wed Jul 14 12:01:27 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/schema/portalPage.exsd Wed Jul 14 15:00:33 2010 -0500 @@ -59,6 +59,13 @@ + + + + relative ordering of pages in the navigation bar (1-100) + + + diff -r d5f384bf1e88 -r 1828ccdd6878 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 Wed Jul 14 12:01:27 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Wed Jul 14 15:00:33 2010 -0500 @@ -16,7 +16,10 @@ */ package com.nokia.carbide.internal.discovery.ui.editor; +import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,6 +53,7 @@ import com.nokia.carbide.discovery.ui.Messages; 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.core.Pair; import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; public class PortalEditor extends EditorPart { @@ -68,22 +72,44 @@ public PortalEditor() { resources = new ArrayList(); - getPortalPages(); + loadPortalPages(); pageToControlMap = new HashMap(); } - private void getPortalPages() { - uninitializedPages = new ArrayList(); + private void loadPortalPages() { + List> pageExtensions = new ArrayList>(); IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID + ".portalPage"); //$NON-NLS-1$ for (IConfigurationElement element : elements) { try { - uninitializedPages.add((IPortalPage) element.createExecutableExtension("class")); //$NON-NLS-1$ + IPortalPage portalPage = (IPortalPage) element.createExecutableExtension("class"); //$NON-NLS-1$ + String rankString = element.getAttribute("rank"); //$NON-NLS-1$ + int rank = Integer.MAX_VALUE; + if (rankString != null) { + try { + rank = Integer.parseInt(rankString); + } + catch (NumberFormatException e) { + Activator.logError(MessageFormat.format("Could not get rank for portal page {0}", + portalPage.getClass().getName()), e); + } + } + pageExtensions.add(new Pair(portalPage, rank)); } catch (CoreException e) { Activator.logError(Messages.PortalEditor_PageLoadError, e); } } + Collections.sort(pageExtensions, new Comparator>() { + @Override + public int compare(Pair o1, Pair o2) { + return o1.second.compareTo(o2.second); + } + }); + uninitializedPages = new ArrayList(); + for (Pair pair : pageExtensions) { + uninitializedPages.add(pair.first); + } } @Override