org.eclipse.e4.ui.css.workbench: "icon" and "wm-tooltip" properties
need to remove IPresentationEngine.OVERRIDE_* keys when present.
This remove only happens when the icon/wm-tooltip values have
actually changed so that subsequent IPE.OVERRIDEs work properly.
diff --git a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchRendererPropertyHandler.java b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchRendererPropertyHandler.java
index 4f96fc9..f8e2580 100644
--- a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchRendererPropertyHandler.java
+++ b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchRendererPropertyHandler.java
@@ -24,7 +24,7 @@
public boolean applyCSSProperty(Object element, String property,
CSSValue value, String pseudo, CSSEngine engine) throws Exception {
WMElement wbElement = (WMElement) engine.getElement(element);
- if (element == null) {
+ if (wbElement == null) {
return false;
}
MUIElement uiElement = wbElement.getUIElement();
@@ -40,7 +40,7 @@
public String retrieveCSSProperty(Object element, String property,
String pseudo, CSSEngine engine) throws Exception {
WMElement wbElement = (WMElement) engine.getElement(element);
- if (element == null) {
+ if (wbElement == null) {
return null;
}
MUIElement uiElement = wbElement.getUIElement();
diff --git a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchUILabelProperties.java b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchUILabelProperties.java
index fb7a79b..381597f 100644
--- a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchUILabelProperties.java
+++ b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchUILabelProperties.java
@@ -10,10 +10,15 @@
*******************************************************************************/
package org.eclipse.e4.ui.css.model.workbench.internal.properties;
+import java.util.Map;
+
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.model.workbench.internal.elements.WMUIElement;
+import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.ui.MUILabel;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
+import org.eclipse.e4.ui.workbench.IPresentationEngine;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;
@@ -30,23 +35,48 @@
public boolean applyCSSProperty(Object element, String property,
CSSValue value, String pseudo, CSSEngine engine) throws Exception {
Element wbElement = engine.getElement(element);
- if (!(element instanceof WMUIElement && ((WMUIElement) wbElement).getUIElement() instanceof MUILabel)) {
+ if (!(wbElement instanceof WMUIElement && ((WMUIElement) wbElement)
+ .getUIElement() instanceof MUILabel)) {
return false;
}
MUILabel uiElement = (MUILabel) ((WMUIElement) wbElement)
.getUIElement();
- if (PROPERTY_ICON.equals(property)) {
+ if (PROPERTY_LABEL.equals(property)) {
+ String label = value.getCssText();
+ uiElement.setLabel(label);
+ return true;
+ } else if (PROPERTY_ICON.equals(property)) {
+ // Must check and remove an override (e.g., on MParts)
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE
&& ((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
- uiElement.setIconURI(((CSSPrimitiveValue) value)
- .getStringValue());
+ String iconURI = ((CSSPrimitiveValue) value).getStringValue();
+ if (uiElement instanceof MApplicationElement) {
+ Map<String, Object> td = ((MApplicationElement) uiElement)
+ .getTransientData();
+ if (!iconURI.equals(td.get(PROPERTY_ICON))) {
+ td.put(PROPERTY_ICON, iconURI);
+ td.remove(IPresentationEngine.OVERRIDE_ICON_IMAGE_KEY);
+ uiElement.setIconURI(iconURI);
+ }
+ } else {
+ uiElement.setIconURI(iconURI);
+ }
return true;
}
- } else if (PROPERTY_LABEL.equals(property)) {
- uiElement.setLabel(value.getCssText());
- return true;
} else if (PROPERTY_TOOLTIP.equals(property)) {
- uiElement.setTooltip(value.getCssText());
+ // Must check and remove an override (e.g., on MParts)
+ String tooltip = value.getCssText();
+ if (uiElement instanceof MApplicationElement) {
+ Map<String, Object> td = ((MApplicationElement) uiElement)
+ .getTransientData();
+ if (!tooltip.equals(td.get(PROPERTY_TOOLTIP))) {
+ td.put(PROPERTY_TOOLTIP, tooltip);
+ td.remove(IPresentationEngine.OVERRIDE_TITLE_TOOL_TIP_KEY);
+ uiElement.setTooltip(tooltip);
+ }
+ } else {
+ uiElement.setTooltip(tooltip);
+ }
return true;
}
return false;
@@ -55,12 +85,21 @@
public String retrieveCSSProperty(Object element, String property,
String pseudo, CSSEngine engine) throws Exception {
Element wbElement = engine.getElement(element);
- if (!(element instanceof WMUIElement && ((WMUIElement) wbElement)
- .getUIElement() instanceof MUILabel)) {
+ if (!(wbElement instanceof WMUIElement)) {
return null;
}
- MUILabel uiElement = (MUILabel) ((WMUIElement) wbElement)
- .getUIElement();
+ MUILabel uiElement = null;
+ if (((WMUIElement) wbElement).getUIElement() instanceof MUILabel) {
+ uiElement = (MUILabel) ((WMUIElement) wbElement).getUIElement();
+ } else if (((WMUIElement) wbElement).getUIElement() instanceof MPlaceholder
+ && ((MPlaceholder) ((WMUIElement) wbElement).getUIElement())
+ .getRef() instanceof MUILabel) {
+ uiElement = (MUILabel) ((MPlaceholder) ((WMUIElement) wbElement)
+ .getUIElement()).getRef();
+ }
+ if (uiElement == null) {
+ return null;
+ }
if (PROPERTY_ICON.equals(property)) {
return uiElement.getIconURI();
} else if (PROPERTY_LABEL.equals(property)) {
diff --git a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchVisibilityHandler.java b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchVisibilityHandler.java
index 2745d3d..bd51de9 100644
--- a/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchVisibilityHandler.java
+++ b/bundles/org.eclipse.e4.ui.css.workbench/src/org/eclipse/e4/ui/css/model/workbench/internal/properties/CSSWorkbenchVisibilityHandler.java
@@ -22,7 +22,7 @@
public boolean applyCSSProperty(Object element, String property,
CSSValue value, String pseudo, CSSEngine engine) throws Exception {
Element wbElement = engine.getElement(element);
- if (!(element instanceof WMUIElement)) {
+ if (!(wbElement instanceof WMUIElement)) {
return false;
}
MUIElement uiElement = ((WMUIElement) wbElement).getUIElement();
@@ -41,7 +41,7 @@
public String retrieveCSSProperty(Object element, String property,
String pseudo, CSSEngine engine) throws Exception {
Element wbElement = engine.getElement(element);
- if (!(element instanceof WMUIElement)) {
+ if (!(wbElement instanceof WMUIElement)) {
return null;
}
MUIElement uiElement = ((WMUIElement) wbElement).getUIElement();