001: /**
002: * <copyright>
003: *
004: * Copyright 2002-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */package org.cougaar.tools.csmart.recipe;
026:
027: import org.cougaar.core.component.ComponentDescription;
028: import org.cougaar.tools.csmart.core.property.ConfigurableComponent;
029: import org.cougaar.tools.csmart.core.property.ConfigurableComponentProperty;
030: import org.cougaar.tools.csmart.core.property.range.StringRange;
031: import org.cougaar.tools.csmart.ui.viewer.CSMART;
032: import org.cougaar.util.log.Logger;
033:
034: import java.util.Collections;
035: import java.util.HashSet;
036: import java.util.Set;
037:
038: /**
039: * PriorityProperty: Legitimate ComponentPrioritys come from <code>ComponentDescription</code>
040: *
041: *
042: * Created: Wed May 15 14:17:33 2002
043: *
044: */
045: public class PriorityProperty extends ConfigurableComponentProperty {
046: public PriorityProperty(ConfigurableComponent c, String name,
047: Object value) {
048: super (c, name, value);
049: setPropertyClass(StringRange.class);
050: }
051:
052: public Set getAllowedValues() {
053: return getAvailableProperties();
054: }
055:
056: private static Set availableProperties = null;
057:
058: private static Set getAvailableProperties() {
059: Logger log = CSMART
060: .createLogger("org.cougaar.tools.csmart.recipe.PriorityProperty");
061: if (availableProperties == null) {
062: StringRange value = null;
063: availableProperties = new HashSet();
064: try {
065: value = new StringRange(
066: ComponentDescription
067: .priorityToString(ComponentDescription.PRIORITY_HIGH));
068: availableProperties.add(value);
069:
070: value = new StringRange(
071: ComponentDescription
072: .priorityToString(ComponentDescription.PRIORITY_INTERNAL));
073: availableProperties.add(value);
074:
075: value = new StringRange(
076: ComponentDescription
077: .priorityToString(ComponentDescription.PRIORITY_BINDER));
078: availableProperties.add(value);
079:
080: value = new StringRange(
081: ComponentDescription
082: .priorityToString(ComponentDescription.PRIORITY_COMPONENT));
083: availableProperties.add(value);
084:
085: value = new StringRange(
086: ComponentDescription
087: .priorityToString(ComponentDescription.PRIORITY_LOW));
088: availableProperties.add(value);
089:
090: } catch (IllegalArgumentException e) {
091: if (log.isErrorEnabled()) {
092: log.error("Unknown Priority Level: ", e);
093: }
094: availableProperties = Collections.EMPTY_SET;
095: }
096: }
097: return availableProperties;
098: }
099:
100: }// PriorityProperty
|