KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > metadata > range > swing > RangeDisplayFactory


1 /*
2 /*
3  * The contents of this file are subject to the
4  * Mozilla Public License Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
10  * See the License for the specific language governing rights and
11  * limitations under the License.
12  *
13  * The Initial Developer of the Original Code is Simulacra Media Ltd.
14  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
15  *
16  * All Rights Reserved.
17  *
18  * Contributor(s):
19  */

20 package org.openharmonise.him.metadata.range.swing;
21
22
23 import org.openharmonise.commons.xml.namespace.*;
24 import org.openharmonise.him.harmonise.*;
25 import org.openharmonise.him.metadata.range.swing.booleanhandling.*;
26 import org.openharmonise.him.metadata.range.swing.datehandling.*;
27 import org.openharmonise.him.metadata.range.swing.datetimehandling.*;
28 import org.openharmonise.him.metadata.range.swing.domain.*;
29 import org.openharmonise.him.metadata.range.swing.floathandling.*;
30 import org.openharmonise.him.metadata.range.swing.integerhandling.*;
31 import org.openharmonise.him.metadata.range.swing.propertyhandling.*;
32 import org.openharmonise.him.metadata.range.swing.range.*;
33 import org.openharmonise.him.metadata.range.swing.relatedevents.*;
34 import org.openharmonise.him.metadata.range.swing.resourcehandling.*;
35 import org.openharmonise.him.metadata.range.swing.rolehandling.*;
36 import org.openharmonise.him.metadata.range.swing.stringhandling.*;
37 import org.openharmonise.him.metadata.range.swing.stringreadonlyhandling.*;
38 import org.openharmonise.him.metadata.range.swing.valuehandling.*;
39 import org.openharmonise.him.metadata.range.swing.workflow.*;
40 import org.openharmonise.him.metadata.range.swing.workflowstagepermissions.*;
41 import org.openharmonise.vfs.metadata.*;
42 import org.openharmonise.vfs.metadata.range.*;
43
44
45 /**
46  * Factory for creating a range display specific to the range of a
47  * given property instance.
48  *
49  * @author Matthew Large
50  * @version $Revision: 1.2 $
51  *
52  */

53 public class RangeDisplayFactory {
54
55     private RangeDisplayFactory() {
56         super();
57     }
58
59     /**
60      * Factory method to return a range display specific to the range of a
61      * given property instance.
62      *
63      * @param propInstance Property instance to get a range display component for
64      * @return Range display component for the give property instance
65      */

66     public static RangeDisplay getRangeDisplay(PropertyInstance propInstance) {
67         RangeDisplay retn = null;
68         
69         Range range = propInstance.getDefinition().getRange();
70         if(propInstance.getName().equals("related_events") ||
71             propInstance.getName().equals("Related Events")) {
72             retn = new RelatedEventRangeDisplay(propInstance);
73         } else if(propInstance.getDefinition().getNamespace().equalsIgnoreCase(NamespaceType.OHRM_RBS.getURI())
74                     && propInstance.getDefinition().getName().equalsIgnoreCase("ROLE")) {
75             retn = new RoleRangeDisplay(propInstance);
76         } else if(propInstance.getDefinition().getHREF().startsWith( HarmonisePaths.PATH_WORKFLOW_PROPS)) {
77             retn = new WorkflowRangeDisplay(propInstance);
78         } else if(propInstance.getDefinition().getNamespace().equalsIgnoreCase(NamespaceType.OHRM.getURI())
79                 && (propInstance.getDefinition().getName().equalsIgnoreCase("WORKFLOW_ROLES")
80                         || propInstance.getDefinition().getName().equalsIgnoreCase("REPORT_EXE_ROLES")) ) {
81             retn = new WorkflowStagePermissionsRangeDisplay(propInstance);
82         } else if(propInstance.getDefinition().getNamespace().equalsIgnoreCase(NamespaceType.OHRM.getURI())
83                 && propInstance.getDefinition().getName().equalsIgnoreCase("harmonise-id")) {
84             retn = new StringReadOnlyRangeDisplay(propInstance);
85         } else if(propInstance.getDefinition().getNamespace().equalsIgnoreCase(NamespaceType.OHRM.getURI())
86                 && propInstance.getDefinition().getName().equalsIgnoreCase("harmonise-path")) {
87             retn = new StringReadOnlyRangeDisplay(propInstance);
88         } else if( range instanceof BooleanRange) {
89             retn = new BooleanRangeDisplay(propInstance);
90         } else if( range instanceof CollectionRange) {
91             retn = new ResourceRangeDisplay(propInstance);
92         } else if( range instanceof DateRange) {
93             retn = new DateRangeDisplay(propInstance);
94         } else if( range instanceof DateTimeRange) {
95             retn = new DateTimeRangeDisplay(propInstance);
96         } else if( range instanceof FloatRange) {
97             retn = new FloatRangeDisplay(propInstance);
98         } else if( range instanceof IntegerRange) {
99             retn = new IntegerRangeDisplay(propInstance);
100         } else if( range instanceof PropertyRange) {
101             retn = new PropertyRangeDisplay(propInstance);
102         } else if( range instanceof ResourceRange) {
103             retn = new ResourceRangeDisplay(propInstance);
104         } else if( range instanceof StringRange) {
105             retn = new StringRangeDisplay(propInstance);
106         } else if( range instanceof URIRange) {
107             
108         } else if( range instanceof DomainRange) {
109             retn = new DomainRangeDisplay(propInstance);
110         } else if( range instanceof RangeRange) {
111             retn = new RangeRangeDisplay(propInstance);
112         } else if( range instanceof ValueRange) {
113             retn = new ValueRangeDisplay(propInstance);
114         } else {
115             retn = new StringRangeDisplay(propInstance);
116         }
117         
118         return retn;
119     }
120
121 }
122
Popular Tags