Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Dos Santos2013-12-13 19:26:37 +0000
committerGerrit Code Review @ Eclipse.org2013-12-18 01:13:01 +0000
commitb7eef8e0c8da174009283d5a2c7e2c518c21e9fd (patch)
tree37dced3a9d767f1784914896e6d5968d8033ecc8 /org.eclipse.mylyn.tasks.ui
parent461cb61c85d4f7872c0faf5b9174d999bfcc98f5 (diff)
downloadorg.eclipse.mylyn.tasks-b7eef8e0c8da174009283d5a2c7e2c518c21e9fd.tar.gz
org.eclipse.mylyn.tasks-b7eef8e0c8da174009283d5a2c7e2c518c21e9fd.tar.xz
org.eclipse.mylyn.tasks-b7eef8e0c8da174009283d5a2c7e2c518c21e9fd.zip
378032: [api] provide editor support for required attributes
Change-Id: I711b84be94880ab04fe0bfb15464bb4c5aa6cf33 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378032 Signed-off-by: Leo Dos Santos <leo.dos.santos@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/icons/ovr16/overlay-required.gifbin48 -> 0 bytes
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java48
2 files changed, 30 insertions, 18 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/icons/ovr16/overlay-required.gif b/org.eclipse.mylyn.tasks.ui/icons/ovr16/overlay-required.gif
deleted file mode 100644
index 1b17af928..000000000
--- a/org.eclipse.mylyn.tasks.ui/icons/ovr16/overlay-required.gif
+++ /dev/null
Binary files differ
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