blob: 865c39ffe0a7fefe7438d38d29965408efed6bd1 (
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) 2007 Oracle Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Oracle Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.pagedesigner.editors.properties.internal;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage;
/**
* Adapts IValidValues to ICellEditorValidator
*
*/
public class EditorValidatorAdapter implements ICellEditorValidator, IInputValidator {
private IValidValues _vvs;
/**
* Constructor
* @param vvs
*/
public EditorValidatorAdapter(IValidValues vvs) {
_vvs = vvs;
}
public String isValid(Object value) {
//for now, if value is not a string, return true
if (value instanceof String)
return isValid((String)value);
return null;
}
public String isValid(String value) {
_vvs.getValidationMessages().clear();
if (_vvs.isValidValue(value))
return null;//is valid
return ((IValidationMessage)_vvs.getValidationMessages().get(0)).getMessage();
}
}
|