summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Geiger2018-02-05 07:04:07 -0500
committerStefan Geiger2018-02-05 07:04:07 -0500
commit60c0d563f7fa4b0761d0ee681a4858e3f4fbbd52 (patch)
tree17b902e64b557677912ffdd4fedc31d97183fd01
parent9486a384766f0c350a0100f58f32ec57cd7e4dc1 (diff)
parentea3a8f23e77a41b5835f53b830006b73b10e5b59 (diff)
downloadorg.eclipse.riena-60c0d563f7fa4b0761d0ee681a4858e3f4fbbd52.zip
org.eclipse.riena-60c0d563f7fa4b0761d0ee681a4858e3f4fbbd52.tar.gz
org.eclipse.riena-60c0d563f7fa4b0761d0ee681a4858e3f4fbbd52.tar.xz
Merge remote-tracking branch
'origin/feature/LabelRidgetSupportsIconAndText' into develop
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/.settings/.api_filters11
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidget.java5
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java50
3 files changed, 59 insertions, 7 deletions
diff --git a/org.eclipse.riena.ui.ridgets.swt/.settings/.api_filters b/org.eclipse.riena.ui.ridgets.swt/.settings/.api_filters
new file mode 100644
index 0000000..0cbc3c4
--- /dev/null
+++ b/org.eclipse.riena.ui.ridgets.swt/.settings/.api_filters
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.riena.ui.ridgets.swt" version="2">
+ <resource path="src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java" type="org.eclipse.riena.ui.ridgets.swt.AbstractLabelRidget">
+ <filter comment="new abstract Method for getting the Image from Label Widget" id="336695337">
+ <message_arguments>
+ <message_argument value="org.eclipse.riena.ui.ridgets.swt.AbstractLabelRidget"/>
+ <message_argument value="getUIControlImage()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidget.java
index 86573b7..67fe118 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidget.java
@@ -44,6 +44,11 @@ public class LabelRidget extends AbstractLabelRidget {
}
@Override
+ protected Image getUIControlImage() {
+ return getUIControl().getImage();
+ }
+
+ @Override
protected void setUIControlText(final String text) {
getUIControl().setText(text);
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java
index 2c27858..2924125 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractLabelRidget.java
@@ -42,10 +42,13 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
private IconSize iconSize;
private URL iconLocation;
private boolean textAlreadyInitialized;
+ private boolean iconAlreadyInitalized;
+ private Image imageFromUiControl;
private boolean useRidgetIcon;
public AbstractLabelRidget() {
textAlreadyInitialized = false;
+ iconAlreadyInitalized = false;
useRidgetIcon = false;
}
@@ -62,6 +65,7 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
@Override
protected void bindUIControl() {
initText();
+ initIcon();
updateUIText();
updateUIIcon();
}
@@ -82,6 +86,23 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
}
}
+ private void initIcon() {
+ if (iconIDIsEmpty() && !iconAlreadyInitalized) {
+ final Control control = getUIControl();
+ if (control != null && !control.isDisposed()) {
+ final Image uiControlImage = getUIControlImage();
+ if (uiControlImage != null) {
+ imageFromUiControl = uiControlImage;
+ iconAlreadyInitalized = true;
+ }
+ }
+ }
+ }
+
+ private boolean iconIDIsEmpty() {
+ return iconID == null || iconID == EMPTY_STRING;
+ }
+
/**
* {@inheritDoc}
* <p>
@@ -158,6 +179,7 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
public void setText(final String text) {
final String oldValue = this.text;
this.text = text;
+ useRidgetIcon = false;
updateUIText();
firePropertyChange(PROPERTY_TEXT_INTERNAL, oldValue, this.text);
firePropertyChange(ILabelRidget.PROPERTY_TEXT, oldValue, this.text);
@@ -180,8 +202,16 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
*/
protected abstract String getUIControlText();
+ /**
+ * @since 6.2
+ */
+ protected abstract Image getUIControlImage();
+
private void updateUIText() {
if (getUIControl() != null) {
+ if (getUIControlText().equals(text)) {
+ setUIControlText(EMPTY_STRING);
+ }
setUIControlText(text);
}
}
@@ -193,19 +223,25 @@ public abstract class AbstractLabelRidget extends AbstractValueRidget implements
private void updateUIIcon() {
if (getUIControl() != null) {
- Image image = null;
- if (getIcon() != null) {
- image = getManagedImage(getIcon(), iconSize);
- } else if (iconLocation != null) {
- final String key = iconLocation.toExternalForm();
- image = getManagedImage(key);
- }
+ final Image image = getManagedImage();
if ((image != null) || useRidgetIcon) {
setUIControlImage(image);
+ } else if (iconAlreadyInitalized) {
+ setUIControlImage(imageFromUiControl);
}
}
}
+ private Image getManagedImage() {
+ if (getIcon() != null) {
+ return getManagedImage(getIcon(), iconSize);
+ } else if (iconLocation != null) {
+ final String key = iconLocation.toExternalForm();
+ return getManagedImage(key);
+ }
+ return null;
+ }
+
/**
* Sets the controls image.
*/