001: /* Copyright (C) 2003 Finalist IT Group
002: *
003: * This file is part of JAG - the Java J2EE Application Generator
004: *
005: * JAG is free software; you can redistribute it and/or modify
006: * it under the terms of the GNU General Public License as published by
007: * the Free Software Foundation; either version 2 of the License, or
008: * (at your option) any later version.
009: * JAG is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: * You should have received a copy of the GNU General Public License
014: * along with JAG; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
016: */
017:
018: package com.finalist.jaggenerator;
019:
020: import com.finalist.jaggenerator.modules.*;
021:
022: import java.util.*;
023: import javax.swing.*;
024:
025: /**
026: *
027: * @author hillie
028: */
029: public class SelectRefs extends javax.swing.JDialog {
030: private DefaultListModel listModel = new DefaultListModel();
031: private ArrayList refList;
032:
033: /** Creates new form SelectRefs for Sesson EJBs to design a Session Facade to Entity EJBs. */
034: public SelectRefs(JFrame parent, Session session, ArrayList refList) {
035: super (parent, true);
036: this .setTitle("Select entity bean(s)");
037: this .refList = refList;
038: initComponents();
039: setBounds(50, 10, 200, 700);
040: Root root = (Root) session.getRoot();
041: ArrayList refs = root.getRefs();
042: for (int i = 0; i < refs.size(); i++) {
043: listModel.addElement((String) refs.get(i));
044: }
045: list.setModel(listModel);
046: refList = refs;
047: }
048:
049: /** Creates new form SelectRefs for CMR in Entity EJBs */
050: public SelectRefs(JFrame parent, Entity entity, ArrayList refList) {
051: super (parent, true);
052: this .refList = refList;
053: initComponents();
054: setBounds(50, 10, 200, 700);
055: Root root = (Root) entity.getRoot();
056: ArrayList refs = root.getRefs();
057: for (int i = 0; i < refs.size(); i++) {
058: listModel.addElement((String) refs.get(i));
059: }
060: list.setModel(listModel);
061: refList = refs;
062: }
063:
064: /** This method is called from within the constructor to
065: * initialize the form.
066: * WARNING: Do NOT modify this code. The content of this method is
067: * always regenerated by the Form Editor.
068: */
069: private void initComponents() {//GEN-BEGIN:initComponents
070: java.awt.GridBagConstraints gridBagConstraints;
071:
072: selectButton = new javax.swing.JButton();
073: jScrollPane1 = new javax.swing.JScrollPane();
074: list = new javax.swing.JList();
075:
076: getContentPane().setLayout(new java.awt.GridBagLayout());
077:
078: addWindowListener(new java.awt.event.WindowAdapter() {
079: public void windowClosing(java.awt.event.WindowEvent evt) {
080: closeDialog(evt);
081: }
082: });
083:
084: selectButton.setText("Select");
085: selectButton
086: .addActionListener(new java.awt.event.ActionListener() {
087: public void actionPerformed(
088: java.awt.event.ActionEvent evt) {
089: selectButtonActionPerformed(evt);
090: }
091: });
092:
093: gridBagConstraints = new java.awt.GridBagConstraints();
094: gridBagConstraints.gridx = 0;
095: gridBagConstraints.gridy = 1;
096: gridBagConstraints.ipadx = 2;
097: gridBagConstraints.ipady = 2;
098: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
099: gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0);
100: getContentPane().add(selectButton, gridBagConstraints);
101:
102: jScrollPane1.setViewportView(list);
103:
104: gridBagConstraints = new java.awt.GridBagConstraints();
105: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
106: gridBagConstraints.weightx = 1.0;
107: gridBagConstraints.weighty = 1.0;
108: getContentPane().add(jScrollPane1, gridBagConstraints);
109:
110: pack();
111: }//GEN-END:initComponents
112:
113: private void selectButtonActionPerformed(
114: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
115: Object[] refs = list.getSelectedValues();
116: for (int i = 0; i < refs.length; i++) {
117: listModel.addElement((String) refs[i]);
118: this .refList.add((String) refs[i]);
119: }
120: list.setModel(listModel);
121: dispose();
122: }//GEN-LAST:event_selectButtonActionPerformed
123:
124: /** Closes the dialog */
125: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
126:
127: }//GEN-LAST:event_closeDialog
128:
129: // Variables declaration - do not modify//GEN-BEGIN:variables
130: private javax.swing.JList list;
131: private javax.swing.JScrollPane jScrollPane1;
132: private javax.swing.JButton selectButton;
133: // End of variables declaration//GEN-END:variables
134:
135: }
|