001: /*
002: /*
003: * The contents of this file are subject to the
004: * Mozilla Public License Version 1.1 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
007: *
008: * Software distributed under the License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
010: * See the License for the specific language governing rights and
011: * limitations under the License.
012: *
013: * The Initial Developer of the Original Code is Simulacra Media Ltd.
014: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
015: *
016: * All Rights Reserved.
017: *
018: * Contributor(s):
019: */
020: package org.openharmonise.him.metadata.range.swing;
021:
022: import org.openharmonise.commons.xml.namespace.*;
023: import org.openharmonise.him.harmonise.*;
024: import org.openharmonise.him.metadata.range.swing.booleanhandling.*;
025: import org.openharmonise.him.metadata.range.swing.datehandling.*;
026: import org.openharmonise.him.metadata.range.swing.datetimehandling.*;
027: import org.openharmonise.him.metadata.range.swing.domain.*;
028: import org.openharmonise.him.metadata.range.swing.floathandling.*;
029: import org.openharmonise.him.metadata.range.swing.integerhandling.*;
030: import org.openharmonise.him.metadata.range.swing.propertyhandling.*;
031: import org.openharmonise.him.metadata.range.swing.range.*;
032: import org.openharmonise.him.metadata.range.swing.relatedevents.*;
033: import org.openharmonise.him.metadata.range.swing.resourcehandling.*;
034: import org.openharmonise.him.metadata.range.swing.rolehandling.*;
035: import org.openharmonise.him.metadata.range.swing.stringhandling.*;
036: import org.openharmonise.him.metadata.range.swing.stringreadonlyhandling.*;
037: import org.openharmonise.him.metadata.range.swing.valuehandling.*;
038: import org.openharmonise.him.metadata.range.swing.workflow.*;
039: import org.openharmonise.him.metadata.range.swing.workflowstagepermissions.*;
040: import org.openharmonise.vfs.metadata.*;
041: import org.openharmonise.vfs.metadata.range.*;
042:
043: /**
044: * Factory for creating a range display specific to the range of a
045: * given property instance.
046: *
047: * @author Matthew Large
048: * @version $Revision: 1.2 $
049: *
050: */
051: public class RangeDisplayFactory {
052:
053: private RangeDisplayFactory() {
054: super ();
055: }
056:
057: /**
058: * Factory method to return a range display specific to the range of a
059: * given property instance.
060: *
061: * @param propInstance Property instance to get a range display component for
062: * @return Range display component for the give property instance
063: */
064: public static RangeDisplay getRangeDisplay(
065: PropertyInstance propInstance) {
066: RangeDisplay retn = null;
067:
068: Range range = propInstance.getDefinition().getRange();
069: if (propInstance.getName().equals("related_events")
070: || propInstance.getName().equals("Related Events")) {
071: retn = new RelatedEventRangeDisplay(propInstance);
072: } else if (propInstance.getDefinition().getNamespace()
073: .equalsIgnoreCase(NamespaceType.OHRM_RBS.getURI())
074: && propInstance.getDefinition().getName()
075: .equalsIgnoreCase("ROLE")) {
076: retn = new RoleRangeDisplay(propInstance);
077: } else if (propInstance.getDefinition().getHREF().startsWith(
078: HarmonisePaths.PATH_WORKFLOW_PROPS)) {
079: retn = new WorkflowRangeDisplay(propInstance);
080: } else if (propInstance.getDefinition().getNamespace()
081: .equalsIgnoreCase(NamespaceType.OHRM.getURI())
082: && (propInstance.getDefinition().getName()
083: .equalsIgnoreCase("WORKFLOW_ROLES") || propInstance
084: .getDefinition().getName().equalsIgnoreCase(
085: "REPORT_EXE_ROLES"))) {
086: retn = new WorkflowStagePermissionsRangeDisplay(
087: propInstance);
088: } else if (propInstance.getDefinition().getNamespace()
089: .equalsIgnoreCase(NamespaceType.OHRM.getURI())
090: && propInstance.getDefinition().getName()
091: .equalsIgnoreCase("harmonise-id")) {
092: retn = new StringReadOnlyRangeDisplay(propInstance);
093: } else if (propInstance.getDefinition().getNamespace()
094: .equalsIgnoreCase(NamespaceType.OHRM.getURI())
095: && propInstance.getDefinition().getName()
096: .equalsIgnoreCase("harmonise-path")) {
097: retn = new StringReadOnlyRangeDisplay(propInstance);
098: } else if (range instanceof BooleanRange) {
099: retn = new BooleanRangeDisplay(propInstance);
100: } else if (range instanceof CollectionRange) {
101: retn = new ResourceRangeDisplay(propInstance);
102: } else if (range instanceof DateRange) {
103: retn = new DateRangeDisplay(propInstance);
104: } else if (range instanceof DateTimeRange) {
105: retn = new DateTimeRangeDisplay(propInstance);
106: } else if (range instanceof FloatRange) {
107: retn = new FloatRangeDisplay(propInstance);
108: } else if (range instanceof IntegerRange) {
109: retn = new IntegerRangeDisplay(propInstance);
110: } else if (range instanceof PropertyRange) {
111: retn = new PropertyRangeDisplay(propInstance);
112: } else if (range instanceof ResourceRange) {
113: retn = new ResourceRangeDisplay(propInstance);
114: } else if (range instanceof StringRange) {
115: retn = new StringRangeDisplay(propInstance);
116: } else if (range instanceof URIRange) {
117:
118: } else if (range instanceof DomainRange) {
119: retn = new DomainRangeDisplay(propInstance);
120: } else if (range instanceof RangeRange) {
121: retn = new RangeRangeDisplay(propInstance);
122: } else if (range instanceof ValueRange) {
123: retn = new ValueRangeDisplay(propInstance);
124: } else {
125: retn = new StringRangeDisplay(propInstance);
126: }
127:
128: return retn;
129: }
130:
131: }
|