blob: 099b6444db1d730587fb34d23f7a163adaedb74e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
}
};
}
}
|