01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.userobjects;
16:
17: import javax.swing.JComboBox;
18:
19: import com.metaboss.applications.designstudio.Application;
20: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
21: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
22:
23: /* Message combobox item class */
24:
25: public class MessageItem {
26: // load Messages combobox
27: public static void loadBoxWithMessages(JComboBox pBox,
28: Servicemodule pServiceModule, boolean pAddNull) {
29: pBox.removeAllItems();
30:
31: if (pAddNull)
32: pBox.addItem(new MessageItem(null));
33:
34: if (pServiceModule != null) {
35: try {
36: Object[] pList = pServiceModule.getMessages().toArray();
37: for (int i = 0; i < pList.length; i++)
38: pBox.addItem(new MessageItem((Message) pList[i]));
39: } catch (Exception e) {
40: e.printStackTrace();
41: }
42: }
43: }
44:
45: // find message index
46: public static int findMessageItemIndex(JComboBox pBox,
47: Message pMessage) throws Exception {
48: for (int i = 0; i < pBox.getItemCount(); i++) {
49: MessageItem lItem = (MessageItem) pBox.getItemAt(i);
50: if (pMessage == null && lItem.mMessage == null)
51: return i;
52: else if (pMessage != null && lItem.mMessage != null
53: && lItem.toString().equals(pMessage.getName()))
54: return i;
55: }
56: return -1;
57: }
58:
59: public Message mMessage = null;
60:
61: public MessageItem(Message pMessage) {
62: mMessage = pMessage;
63: }
64:
65: public String toString() {
66: String lRedult = "";
67: try {
68: if (mMessage != null)
69: lRedult = mMessage.getName();
70: else
71: lRedult = Application.getString("unspecified");
72: } catch (Exception e) {
73: e.printStackTrace();
74: }
75: return lRedult;
76: }
77: }
|