Bug 546140 - Remove ability to set MRU via CSS
This commit removes the CSS handlers for swt-mru-visible as we control
this behavior via the preferences.
Change-Id: I964da52ce8719c466fd2f72d82fab13ca25aad69
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
index a8668d5..67adfef 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
+++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
@@ -305,14 +305,6 @@
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.CTabFolderElement"
composite="false"
- handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyMruVisibleSWTHandler">
- <property-name
- name="swt-mru-visible">
- </property-name>
- </handler>
- <handler
- adapter="org.eclipse.e4.ui.css.swt.dom.CTabFolderElement"
- composite="false"
handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyMaximizedSWTHandler">
<property-name
name="swt-maximized">
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMruVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMruVisibleSWTHandler.java
deleted file mode 100644
index dd90ff7..0000000
--- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMruVisibleSWTHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Andrey Loskutov <loskutov@gmx.de> - Bug 388476
- *******************************************************************************/
-package org.eclipse.e4.ui.css.swt.properties.custom;
-
-import org.eclipse.e4.ui.css.core.engine.CSSEngine;
-import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.widgets.Control;
-import org.w3c.dom.css.CSSValue;
-
-public class CSSPropertyMruVisibleSWTHandler extends AbstractCSSPropertySWTHandler{
-
- private static boolean mruControlledByCSS = true;
-
- @Override
- public void applyCSSProperty(Control control, String property,
- CSSValue value, String pseudo, CSSEngine engine) throws Exception {
- if (!isMRUControlledByCSS()) {
- return;
- }
- boolean isMruVisible = (Boolean)engine.convert(value, Boolean.class, null);
- if (control instanceof CTabFolder) {
- CTabFolder folder = (CTabFolder) control;
- folder.setMRUVisible(isMruVisible);
- }
- }
-
- @Override
- public String retrieveCSSProperty(Control control, String property,
- String pseudo, CSSEngine engine) throws Exception {
- if (control instanceof CTabFolder){
- CTabFolder folder = (CTabFolder)control;
- return Boolean.toString( folder.getMRUVisible() );
- }
- return null;
- }
-
- public static boolean isMRUControlledByCSS() {
- return mruControlledByCSS;
- }
-
- public static void setMRUControlledByCSS(boolean controlledByCSS) {
- mruControlledByCSS = controlledByCSS;
- }
-}
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
index 0e8074f..1cbe738 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
@@ -38,7 +38,6 @@
import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
-import org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyMruVisibleSWTHandler;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.internal.workbench.OpaqueElementUtil;
@@ -46,7 +45,6 @@
import org.eclipse.e4.ui.internal.workbench.renderers.swt.SWTRenderersMessages;
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
import org.eclipse.e4.ui.internal.workbench.swt.CSSConstants;
-import org.eclipse.e4.ui.internal.workbench.swt.CSSRenderingUtils;
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
@@ -104,7 +102,6 @@
import org.eclipse.swt.widgets.Widget;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
-import org.w3c.dom.css.CSSValue;
/**
* SWT default renderer for a MPartStack model elements
@@ -132,27 +129,11 @@
public static final String MRU_KEY = "enableMRU"; //$NON-NLS-1$
/**
- * Key to switch if the "most recently used" behavior controlled via CSS or
- * preferences
- */
- public static final String MRU_CONTROLLED_BY_CSS_KEY = "MRUControlledByCSS"; //$NON-NLS-1$
-
- /**
* Default default value for MRU behavior.
*/
public static final boolean MRU_DEFAULT = true;
/*
- * org.eclipse.ui.internal.dialogs.ViewsPreferencePage controls currently the
- * MRU behavior via IEclipsePreferences, so that CSS values from the themes
- * aren't used.
- *
- * TODO once we can use preferences from CSS (and update the value on the fly)
- * we can switch this default to true, see discussion on bug 388476.
- */
- private static final boolean MRU_CONTROLLED_BY_CSS_DEFAULT = false;
-
- /*
* JFace key for default workbench tab font
*/
private static final String TAB_FONT_KEY = "org.eclipse.ui.workbench.TAB_TEXT_FONT"; //$NON-NLS-1$
@@ -667,27 +648,7 @@
return tabFolder;
}
- private boolean getInitialMRUValue(Control control) {
- CSSRenderingUtils util = context.get(CSSRenderingUtils.class);
- if (util == null) {
- return getMRUValueFromPreferences();
- }
-
- CSSValue value = util.getCSSValue(control, "MPartStack", "swt-mru-visible"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (value == null) {
- value = util.getCSSValue(control, "MPartStack", "mru-visible"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (value == null) {
- return getMRUValueFromPreferences();
- }
- return Boolean.parseBoolean(value.getCssText());
- }
-
private boolean getMRUValue(Control control) {
- if (CSSPropertyMruVisibleSWTHandler.isMRUControlledByCSS()) {
- return getInitialMRUValue(control);
- }
return getMRUValueFromPreferences();
}
@@ -703,8 +664,6 @@
@Override
public void preferenceChange(PreferenceChangeEvent event) {
- boolean mruControlledByCSS = preferences.getBoolean(MRU_CONTROLLED_BY_CSS_KEY, MRU_CONTROLLED_BY_CSS_DEFAULT);
- CSSPropertyMruVisibleSWTHandler.setMRUControlledByCSS(mruControlledByCSS);
}
/**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
index f4a716c..f6d2268 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
@@ -237,12 +237,6 @@
createLabel(composite, ""); //$NON-NLS-1$
createLabel(composite, WorkbenchMessages.ViewsPreference_visibleTabs_description);
IEclipsePreferences prefs = getSwtRendererPreferences();
- if (engine != null) {
- boolean mruControlledByCSS = prefs.getBoolean(StackRenderer.MRU_CONTROLLED_BY_CSS_KEY, false);
- if (mruControlledByCSS) {
- return;
- }
- }
boolean defaultValue = getDefaultMRUValue();
boolean actualValue = prefs.getBoolean(StackRenderer.MRU_KEY, defaultValue);
enableMru = createCheckButton(composite, WorkbenchMessages.ViewsPreference_enableMRU, actualValue);
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java
index 0dfd829..b155589 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java
@@ -19,7 +19,6 @@
import static org.junit.Assert.assertNotSame;
import org.eclipse.e4.ui.css.swt.dom.CTabFolderElement;
-import org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyMruVisibleSWTHandler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
@@ -220,40 +219,6 @@
}
@Test
- public void testMRUVisible() {
- final boolean mruControlledByCSSDefault = CSSPropertyMruVisibleSWTHandler.isMRUControlledByCSS();
- try {
- CSSPropertyMruVisibleSWTHandler.setMRUControlledByCSS(true);
- CTabFolder folderToTest = createTestCTabFolder("CTabFolder { swt-mru-visible: true}");
- assertEquals(true, folderToTest.getMRUVisible());
- assertEquals("true", engine.retrieveCSSProperty(folderToTest, "swt-mru-visible", null));
- folderToTest.getShell().close();
- folderToTest = createTestCTabFolder("CTabFolder { swt-mru-visible: false}");
- assertEquals("false", engine.retrieveCSSProperty(folderToTest, "swt-mru-visible", null));
- assertEquals(false, folderToTest.getMRUVisible());
- } finally {
- CSSPropertyMruVisibleSWTHandler.setMRUControlledByCSS(mruControlledByCSSDefault);
- }
- }
-
- @Test
- public void testMRUVisibleCSSControlOff() {
- final boolean mruControlledByCSSDefault = CSSPropertyMruVisibleSWTHandler.isMRUControlledByCSS();
- try {
- CSSPropertyMruVisibleSWTHandler.setMRUControlledByCSS(false);
- CTabFolder folderToTest = createTestCTabFolder("CTabFolder { swt-mru-visible: true}");
- assertEquals(false, folderToTest.getMRUVisible());
- assertEquals("false", engine.retrieveCSSProperty(folderToTest, "swt-mru-visible", null));
- folderToTest.getShell().close();
- folderToTest = createTestCTabFolder("CTabFolder { swt-mru-visible: false}");
- assertEquals("false", engine.retrieveCSSProperty(folderToTest, "swt-mru-visible", null));
- assertEquals(false, folderToTest.getMRUVisible());
- } finally {
- CSSPropertyMruVisibleSWTHandler.setMRUControlledByCSS(mruControlledByCSSDefault);
- }
- }
-
- @Test
public void testMaximized() {
CTabFolder folderToTest = createTestCTabFolder("CTabFolder { swt-maximized: true}");
assertEquals(true, folderToTest.getMaximized());
@@ -328,7 +293,6 @@
assertEquals(null, engine.retrieveCSSProperty(shell, "swt-maximized", null));
assertEquals(null, engine.retrieveCSSProperty(shell, "swt-maximize-visible", null));
assertEquals(null, engine.retrieveCSSProperty(shell, "swt-minimize-visible", null));
- assertEquals(null, engine.retrieveCSSProperty(shell, "swt-mru-visible", null));
assertEquals(null, engine.retrieveCSSProperty(shell, "show-close", null));
assertEquals(null, engine.retrieveCSSProperty(shell, "swt-simple", null));
assertEquals(null, engine.retrieveCSSProperty(shell, "swt-single", null));