001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.userobjects;
016:
017: import java.util.ArrayList;
018:
019: import javax.swing.JComboBox;
020:
021: import com.metaboss.applications.designstudio.Application;
022: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.RelationalStorageTechnology;
023: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.StorageTechnology;
024: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.TechnologyLibrary;
025:
026: /* StorageTechnology combobox item class */
027:
028: public class StorageTechnologyItem {
029: public static Object[] preloadStorageTechnologies(
030: TechnologyLibrary pTechLibrary, boolean pAddNull) {
031: int lCount = pTechLibrary.getStorageTechnologies().size();
032: ArrayList lArray = new ArrayList();
033:
034: if (pAddNull)
035: lArray.add(new StorageTechnologyItem(null));
036:
037: if (lCount > 0) {
038: Object[] lTechnologies = pTechLibrary
039: .getStorageTechnologies().toArray();
040: if (lTechnologies.length > 0) {
041: for (int i = 0; i < lTechnologies.length; i++)
042: lArray
043: .add(new StorageTechnologyItem(
044: (RelationalStorageTechnology) lTechnologies[i]));
045: }
046: }
047: Object[] lResult = lArray.toArray();
048: return lResult;
049: }
050:
051: // load combobox with StorageTechnolgies
052: public static void loadBoxWithStorageTechnolgies(
053: JComboBox pComboBox, Object[] pStorageTechnolgies) {
054: if (pComboBox != null) {
055: pComboBox.removeAllItems();
056: if (pStorageTechnolgies != null)
057: for (int i = 0; i < pStorageTechnolgies.length; i++)
058: pComboBox.addItem(pStorageTechnolgies[i]);
059: }
060: }
061:
062: // find datatype index
063: public static int findStorageTechnologyItemIndex(
064: StorageTechnology pStorageTechnology, JComboBox pBox)
065: throws Exception {
066: for (int i = 0; i < pBox.getItemCount(); i++) {
067: StorageTechnologyItem lItem = (StorageTechnologyItem) pBox
068: .getItemAt(i);
069: if (pStorageTechnology == null
070: && lItem.mStorageTechnology == null)
071: return i;
072: else if (pStorageTechnology != null
073: && lItem.mStorageTechnology != null
074: && lItem.toString().equals(
075: pStorageTechnology.getName()))
076: return i;
077: }
078: return -1;
079: }
080:
081: public RelationalStorageTechnology mStorageTechnology = null;
082:
083: //constructor
084: public StorageTechnologyItem(
085: RelationalStorageTechnology pStorageTechnology) {
086: mStorageTechnology = pStorageTechnology;
087: }
088:
089: public String toString() {
090: String lResult = "";
091: try {
092: if (mStorageTechnology != null)
093: lResult = mStorageTechnology.getName();
094: else
095: lResult = Application.getString("unspecified");
096: } catch (Exception e) {
097: e.printStackTrace();
098: }
099: return lResult;
100: }
101:
102: public int compareTo(Object o) {
103: int lResult = 0;
104: try {
105: if (mStorageTechnology == null || o == null)
106: lResult = -1;
107: else if (mStorageTechnology != null && o != null
108: && o instanceof DatatypeItem)
109: lResult = mStorageTechnology.getName().compareTo(
110: ((StorageTechnologyItem) o).mStorageTechnology
111: .getName());
112: } catch (Exception e) {
113: e.printStackTrace();
114: }
115: return lResult;
116: }
117: }
|