24 import org.eclipse.core.runtime.IStatus; |
24 import org.eclipse.core.runtime.IStatus; |
25 import org.eclipse.core.runtime.Status; |
25 import org.eclipse.core.runtime.Status; |
26 import org.symbian.tools.tmw.ui.TMWCoreUI; |
26 import org.symbian.tools.tmw.ui.TMWCoreUI; |
27 |
27 |
28 public class NonEmptyStringValidator implements IValidator { |
28 public class NonEmptyStringValidator implements IValidator { |
29 private final String propertyName; |
29 private final String propertyName; |
30 private final AbstractDataBindingPage page; |
|
31 |
30 |
32 public NonEmptyStringValidator(String propertyName, AbstractDataBindingPage page) { |
31 public NonEmptyStringValidator(String propertyName) { |
33 this.propertyName = propertyName; |
32 this.propertyName = propertyName; |
34 this.page = page; |
33 } |
35 } |
|
36 |
34 |
37 public IStatus validate(Object value) { |
35 public IStatus validate(Object value) { |
38 if (page != null && page.isActive()) { |
36 if (value == null || value.toString().trim().length() == 0) { |
39 if (value == null || value.toString().trim().length() == 0) { |
37 return new Status(IStatus.ERROR, TMWCoreUI.PLUGIN_ID, MessageFormat.format("Field {0} is empty", |
40 return new Status(IStatus.ERROR, TMWCoreUI.PLUGIN_ID, |
38 propertyName)); |
41 MessageFormat.format("Field {0} is empty", |
39 } |
42 propertyName)); |
40 return Status.OK_STATUS; |
43 } |
41 } |
44 } |
|
45 return Status.OK_STATUS; |
|
46 } |
|
47 } |
42 } |