From c751aa7f4cbb644019fa2367b63bf661a9aa2080 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Mon, 17 Feb 2014 13:29:52 +0100 Subject: 417396: [CSS] The CSS Engine shall support label visibility & mask https://bugs.eclipse.org/bugs/show_bug.cgi?id=417396 - Load theme contributions in an ordered (deterministic) way to avoid a random default theme--- .../infra/gmfdiag/css/theme/ThemeManager.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java index 0447500b859..d7ca686c397 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2012 CEA LIST. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,9 +14,10 @@ package org.eclipse.papyrus.infra.gmfdiag.css.theme; import java.io.IOException; import java.net.URL; import java.text.Collator; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -32,9 +33,9 @@ import org.eclipse.swt.graphics.Image; /** * A Singleton to manage CSS Themes. Reads Themes from an extension point, * and provides an access to them. - * + * * @author Camille Letavernier - * + * */ public class ThemeManager { @@ -46,7 +47,7 @@ public class ThemeManager { /** * Returns all the Themes, sorted alphabetically - * + * * @return */ public List getThemes() { @@ -57,7 +58,7 @@ public class ThemeManager { /** * Returns the list of the workspace stylesheet's URLs. - * + * * @return */ public List getWorkspaceStyleSheets() { @@ -71,7 +72,7 @@ public class ThemeManager { /** * Returns the theme associated to the given id, or null if it doesn't * exist - * + * * @param themeId * @return */ @@ -81,7 +82,7 @@ public class ThemeManager { private Map getAllThemes() { if(allThemes == null) { - allThemes = new HashMap(); + allThemes = new LinkedHashMap(); //Keep the themes ordered, to avoid nondeterministic behavior allThemes.put(EmptyTheme.instance.getId(), EmptyTheme.instance); IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID); @@ -158,7 +159,7 @@ public class ThemeManager { } //The theme has not been defined: return the first one, and store it - List sortedThemes = getThemes(); + List sortedThemes = new ArrayList(getAllThemes().values()); if(sortedThemes.size() < 2) { return EmptyTheme.instance; } @@ -189,7 +190,7 @@ public class ThemeManager { /** * Sorts the Themes alphabetically (Based on their label). The Empty theme * is always the first element. - * + * * @author Camille Letavernier */ private static class ThemeComparator implements Comparator { @@ -197,6 +198,7 @@ public class ThemeManager { private ThemeComparator() { } + @Override public int compare(Theme o1, Theme o2) { if(o1 == EmptyTheme.instance) { return -1; -- cgit v1.2.3