author | Eugene Ostroukhov <eugeneo@symbian.org> |
Thu, 02 Sep 2010 15:18:58 -0700 | |
changeset 484 | f5df819c1852 |
parent 470 | d4809db37847 |
permissions | -rw-r--r-- |
17
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
1 |
/** |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
3 |
* All rights reserved. |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
8 |
* |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
11 |
* Contributors: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
12 |
* Description: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
13 |
* Overview: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
14 |
* Details: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
17 |
* Failures and causes: |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
18 |
*/ |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
19 |
package org.symbian.tools.wrttools.util; |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
20 |
|
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
21 |
import org.eclipse.core.databinding.validation.IValidator; |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
22 |
import org.eclipse.core.runtime.IStatus; |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
23 |
import org.eclipse.core.runtime.Status; |
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
24 |
|
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
25 |
public class CompoundValidator implements IValidator { |
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
26 |
private final IValidator[] validators; |
17
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
27 |
|
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
28 |
public CompoundValidator(IValidator... validators) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
29 |
this.validators = validators; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
30 |
} |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
31 |
|
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
32 |
public CompoundValidator(IValidator validator, IValidator[] validators) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
33 |
this.validators = new IValidator[validators.length + 1]; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
34 |
this.validators[0] = validator; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
35 |
System.arraycopy(validators, 0, this.validators, 1, validators.length); |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
36 |
} |
17
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
37 |
|
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
38 |
public IStatus validate(Object value) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
39 |
IStatus status = Status.OK_STATUS; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
40 |
|
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
41 |
for (IValidator validator : validators) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
42 |
IStatus s = validator.validate(value); |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
43 |
switch (s.getSeverity()) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
44 |
case IStatus.ERROR: |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
45 |
return s; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
46 |
case IStatus.WARNING: |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
47 |
status = s; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
48 |
} |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
49 |
} |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
50 |
return status; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
51 |
} |
17
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
52 |
|
f1b0259bb410
Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents:
diff
changeset
|
53 |
} |