Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java54
3 files changed, 54 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
index 49597de80..5cf42dbf3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
@@ -25,6 +25,8 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
+ public static String AbstractAttributeEditor_AttributeIsRequired;
+
public static String AbstractReplyToCommentAction_Reply;
public static String AttachmentSizeFormatter_0_bytes;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
index cb12598c9..0586ac69e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
@@ -8,6 +8,7 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
+AbstractAttributeEditor_AttributeIsRequired=This attribute is required
AbstractReplyToCommentAction_Reply=Reply
AttachmentSizeFormatter_0_bytes=0 bytes
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 38291ebdd..f68a8a97a 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
@@ -11,16 +11,22 @@
package org.eclipse.mylyn.tasks.ui.editors;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.mylyn.internal.tasks.ui.editors.Messages;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -66,10 +72,13 @@ public abstract class AbstractAttributeEditor {
private final TaskDataModelListener modelListener = new TaskDataModelListener() {
@Override
public void attributeChanged(TaskDataModelEvent event) {
- if (shouldAutoRefresh() && getTaskAttribute().equals(event.getTaskAttribute())) {
+ if (getTaskAttribute().equals(event.getTaskAttribute())) {
try {
- refreshInProgress = true;
- refresh();
+ if (shouldAutoRefresh()) {
+ refreshInProgress = true;
+ refresh();
+ }
+ updateRequiredDecoration();
} catch (UnsupportedOperationException e) {
} finally {
refreshInProgress = false;
@@ -84,6 +93,8 @@ public abstract class AbstractAttributeEditor {
}
};
+ private ControlDecoration decoration;
+
/**
* @since 3.0
*/
@@ -233,10 +244,47 @@ public abstract class AbstractAttributeEditor {
if (manager.hasOutgoingChanges(getTaskAttribute())) {
decorateOutgoing(color);
}
+ updateRequiredDecoration();
+ }
+ }
+
+ private void updateRequiredDecoration() {
+ if (getLabelControl() != null && isRequired()) {
+ decorateRequired();
+ } else if (decoration != null) {
+ decoration.hide();
+ decoration.dispose();
}
}
/**
+ * @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();
+ }
+ });
+ }
+
+ /**
+ * @since 3.11
+ */
+ protected boolean isRequired() {
+ boolean isRequired = getTaskAttribute().getMetaData().isRequired();
+ boolean hasValue = !StringUtils.isEmpty(getTaskAttribute().getValue());
+ return isRequired && !hasValue;
+ }
+
+ /**
* @since 3.0
*/
protected void decorateOutgoing(Color color) {

Back to the top