Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DoubleAttributeEditor.java51
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/IntegerAttributeEditor.java51
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java7
5 files changed, 114 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DoubleAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DoubleAttributeEditor.java
new file mode 100644
index 000000000..4f6e83277
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DoubleAttributeEditor.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.editors;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorToolkit;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Thomas Ehrnhoefer
+ */
+public class DoubleAttributeEditor extends TextAttributeEditor {
+
+ public DoubleAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
+ super(manager, taskAttribute);
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ super.createControl(parent, toolkit);
+ AttributeEditorToolkit.createValidator(this, getText(), getAttributeTypeValidator());
+ }
+
+ private IInputValidator getAttributeTypeValidator() {
+ return new IInputValidator() {
+ public String isValid(String newText) {
+ if (StringUtils.isNotBlank(newText)) {
+ try {
+ Double.parseDouble(getText().getText());
+ } catch (NumberFormatException e) {
+ return Messages.DoubleAttributeEditor_this_field_requires_double_value;
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/IntegerAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/IntegerAttributeEditor.java
new file mode 100644
index 000000000..ea96c62d6
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/IntegerAttributeEditor.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.editors;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorToolkit;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Thomas Ehrnhoefer
+ */
+public class IntegerAttributeEditor extends TextAttributeEditor {
+
+ public IntegerAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
+ super(manager, taskAttribute);
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ super.createControl(parent, toolkit);
+ AttributeEditorToolkit.createValidator(this, getText(), getAttributeTypeValidator());
+ }
+
+ private IInputValidator getAttributeTypeValidator() {
+ return new IInputValidator() {
+ public String isValid(String newText) {
+ if (StringUtils.isNotBlank(newText)) {
+ try {
+ Integer.parseInt(getText().getText());
+ } catch (NumberFormatException e) {
+ return Messages.IntegerAttributeEditor_this_field_requires_integer_value;
+ }
+ }
+ return null;
+ }
+ };
+ }
+}
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 34a5a30e1..2e79e079b 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
@@ -257,6 +257,10 @@ public class Messages extends NLS {
public static String AttributePart_Category_;
+ public static String DoubleAttributeEditor_this_field_requires_double_value;
+
+ public static String IntegerAttributeEditor_this_field_requires_integer_value;
+
public static String SummaryPart_Section_Title;
public static String TaskEditor_Edit_Task_Repository_ToolTip;
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 69b5782e5..a949ec42d 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
@@ -143,6 +143,8 @@ AbstractTaskEditorPage_Unable_to_submit_at_this_time=Unable to submit at this ti
AttributeEditorToolkit_Content_Assist_Available__X_=Content Assist Available ({0})
AttributePart_Category_=Category:
+DoubleAttributeEditor_this_field_requires_double_value=This field requires a double value.
+IntegerAttributeEditor_this_field_requires_integer_value=This field requires an integer value.
SummaryPart_Section_Title=Summary
TaskEditor_Edit_Task_Repository_ToolTip=Edit Task Repository
TaskEditor_Task=Task
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java
index ad5dd28b1..759e83ee5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java
@@ -14,14 +14,15 @@ package org.eclipse.mylyn.tasks.ui.editors;
import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.internal.tasks.ui.editors.BooleanAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.DateAttributeEditor;
+import org.eclipse.mylyn.internal.tasks.ui.editors.DoubleAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.LongTextAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.MultiSelectionAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.PersonAttributeEditor;
+import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode;
import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.SingleSelectionAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions;
import org.eclipse.mylyn.internal.tasks.ui.editors.TextAttributeEditor;
-import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
@@ -137,6 +138,10 @@ public class AttributeEditorFactory {
SWT.SINGLE);
editor.setMode(Mode.URL);
return editor;
+ } else if (TaskAttribute.TYPE_DOUBLE.equals(type)) {
+ return new DoubleAttributeEditor(model, taskAttribute);
+ } else if (TaskAttribute.TYPE_INTEGER.equals(type)) {
+ return new DoubleAttributeEditor(model, taskAttribute);
}
throw new IllegalArgumentException("Unsupported editor type: \"" + type + "\""); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top