Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java48
1 files changed, 30 insertions, 18 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
index f68a8a97a..b9fe5a8fc 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
@@ -93,6 +93,16 @@ public abstract class AbstractAttributeEditor {
}
};
+ private final DisposeListener disposeDecorationListener = new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (decoration != null) {
+ decoration.dispose();
+ decoration = null;
+ }
+ }
+ };
+
private ControlDecoration decoration;
/**
@@ -249,11 +259,15 @@ public abstract class AbstractAttributeEditor {
}
private void updateRequiredDecoration() {
- if (getLabelControl() != null && isRequired()) {
- decorateRequired();
- } else if (decoration != null) {
- decoration.hide();
- decoration.dispose();
+ if (getLabelControl() != null) {
+ if (needsValue()) {
+ decorateRequired();
+ } else if (decoration != null) {
+ decoration.hide();
+ decoration.dispose();
+ decoration = null;
+ getLabelControl().removeDisposeListener(disposeDecorationListener);
+ }
}
}
@@ -261,24 +275,22 @@ public abstract class AbstractAttributeEditor {
* @since 3.11
*/
protected void decorateRequired() {
- decoration = new ControlDecoration(getLabelControl(), SWT.TOP | SWT.RIGHT);
- decoration.setDescriptionText(Messages.AbstractAttributeEditor_AttributeIsRequired);
- decoration.setMarginWidth(0);
- Image image = FieldDecorationRegistry.getDefault()
- .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
- .getImage();
- decoration.setImage(image);
- getLabelControl().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- decoration.dispose();
- }
- });
+ if (decoration == null) {
+ decoration = new ControlDecoration(getLabelControl(), SWT.TOP | SWT.RIGHT);
+ decoration.setDescriptionText(Messages.AbstractAttributeEditor_AttributeIsRequired);
+ decoration.setMarginWidth(0);
+ Image image = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
+ .getImage();
+ decoration.setImage(image);
+ getLabelControl().addDisposeListener(disposeDecorationListener);
+ }
}
/**
* @since 3.11
*/
- protected boolean isRequired() {
+ protected boolean needsValue() {
boolean isRequired = getTaskAttribute().getMetaData().isRequired();
boolean hasValue = !StringUtils.isEmpty(getTaskAttribute().getValue());
return isRequired && !hasValue;

Back to the top