Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2014-01-15 00:07:28 +0000
committerGerrit Code Review @ Eclipse.org2014-01-16 14:51:37 +0000
commitf6291e4a1d8816da3f33e9241294dd0102b74e28 (patch)
tree6e16efcb04d42b02a79d20fe66f2051f9aed2d5e /org.eclipse.mylyn.tasks.ui
parent9cf9041d9f8f453ace9d724dc17d3730eaf72ad8 (diff)
downloadorg.eclipse.mylyn.tasks-f6291e4a1d8816da3f33e9241294dd0102b74e28.tar.gz
org.eclipse.mylyn.tasks-f6291e4a1d8816da3f33e9241294dd0102b74e28.tar.xz
org.eclipse.mylyn.tasks-f6291e4a1d8816da3f33e9241294dd0102b74e28.zip
425658: long and integer attributes show message referring to double
* fix editor for attributes of type integer * add editor for attributes of type long Change-Id: I2d874fafa5bb09b1b5706a34a3bef87cf5ce88d8 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=425658
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/.settings/org.moreunit.prefs4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DoubleAttributeEditor.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/IntegerAttributeEditor.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/LongAttributeEditor.java53
-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/AttributeEditorFactory.java6
7 files changed, 68 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/.settings/org.moreunit.prefs b/org.eclipse.mylyn.tasks.ui/.settings/org.moreunit.prefs
new file mode 100644
index 000000000..0b568b7db
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/.settings/org.moreunit.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.moreunit.preferences.version=2
+org.moreunit.unitsourcefolder=org.eclipse.mylyn.tasks.ui\:src\:org.eclipse.mylyn.tasks.ui.tests\:src
+org.moreunit.useprojectsettings=true
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
index f332d6df5..b3dbc2bc6 100644
--- 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
@@ -34,12 +34,12 @@ public class DoubleAttributeEditor extends TextAttributeEditor {
AttributeEditorToolkit.createValidator(this, getText(), getAttributeTypeValidator());
}
- private IInputValidator getAttributeTypeValidator() {
+ IInputValidator getAttributeTypeValidator() {
return new IInputValidator() {
public String isValid(String newText) {
if (StringUtils.isNotBlank(newText)) {
try {
- Double.parseDouble(getText().getText());
+ Double.parseDouble(newText);
} catch (NumberFormatException e) {
return Messages.DoubleAttributeEditor_this_field_requires_double_value;
}
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
index 4d96da126..cd82e9d49 100644
--- 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
@@ -34,12 +34,12 @@ public class IntegerAttributeEditor extends TextAttributeEditor {
AttributeEditorToolkit.createValidator(this, getText(), getAttributeTypeValidator());
}
- private IInputValidator getAttributeTypeValidator() {
+ IInputValidator getAttributeTypeValidator() {
return new IInputValidator() {
public String isValid(String newText) {
if (StringUtils.isNotBlank(newText)) {
try {
- Integer.parseInt(getText().getText());
+ Integer.parseInt(newText);
} catch (NumberFormatException e) {
return Messages.IntegerAttributeEditor_this_field_requires_integer_value;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/LongAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/LongAttributeEditor.java
new file mode 100644
index 000000000..099b6444d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/LongAttributeEditor.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * @author Steffen Pingel
+ */
+public class LongAttributeEditor extends TextAttributeEditor {
+
+ public LongAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
+ super(manager, taskAttribute);
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ super.createControl(parent, toolkit);
+ AttributeEditorToolkit.createValidator(this, getText(), getAttributeTypeValidator());
+ }
+
+ IInputValidator getAttributeTypeValidator() {
+ return new IInputValidator() {
+ public String isValid(String newText) {
+ if (StringUtils.isNotBlank(newText)) {
+ try {
+ Long.parseLong(newText);
+ } catch (NumberFormatException e) {
+ return Messages.LongAttributeEditor_This_field_requires_a_long_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 5cf42dbf3..125997eae 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
@@ -59,6 +59,8 @@ public class Messages extends NLS {
public static String LastCommentedAttributeEditor_dateLastCommented;
+ public static String LongAttributeEditor_This_field_requires_a_long_value;
+
public static String CommentGroupStrategy_Current;
public static String CommentGroupStrategy_Older;
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 0586ac69e..fcacc8b3e 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
@@ -29,6 +29,7 @@ BrowserPreviewViewer_The_repository_does_not_support_HTML_preview=The repository
CheckboxMultiSelectAttributeEditor_Select_X=Select {0}
LastCommentedAttributeEditor_dateLastCommented=Last commented:
+LongAttributeEditor_This_field_requires_a_long_value=This field requires a long value.
CommentGroupStrategy_Current=Current
CommentGroupStrategy_Older=Older
CommentGroupStrategy_Recent=Recent
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 e756cd57a..369aae159 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
@@ -15,7 +15,9 @@ 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.IntegerAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.LastCommentedAttributeEditor;
+import org.eclipse.mylyn.internal.tasks.ui.editors.LongAttributeEditor;
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;
@@ -147,9 +149,9 @@ public class AttributeEditorFactory {
} else if (TaskAttribute.TYPE_DOUBLE.equals(type)) {
return new DoubleAttributeEditor(model, taskAttribute);
} else if (TaskAttribute.TYPE_INTEGER.equals(type)) {
- return new DoubleAttributeEditor(model, taskAttribute);
+ return new IntegerAttributeEditor(model, taskAttribute);
} else if (TaskAttribute.TYPE_LONG.equals(type)) {
- return new DoubleAttributeEditor(model, taskAttribute);
+ return new LongAttributeEditor(model, taskAttribute);
}
throw new IllegalArgumentException("Unsupported editor type: \"" + type + "\""); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top