svn-gvsig-desktop / tags / PilotoRedes_Build_4 / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / gui / MultiInputDlg.java @ 12191
History | View | Annotate | Download (3.93 KB)
1 |
package com.iver.cit.gvsig.graph.gui; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.TextArea; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ActionListener; |
8 |
import java.util.ArrayList; |
9 |
|
10 |
import javax.swing.JDialog; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JScrollPane; |
13 |
import javax.swing.JTable; |
14 |
import javax.swing.JTextArea; |
15 |
import javax.swing.table.DefaultTableModel; |
16 |
|
17 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
18 |
import java.awt.SystemColor; |
19 |
|
20 |
public class MultiInputDlg extends JDialog { |
21 |
private boolean canceled = false; |
22 |
private class MyListener implements ActionListener { |
23 |
|
24 |
private MultiInputDlg dlg;
|
25 |
public MyListener(MultiInputDlg dlg)
|
26 |
{ |
27 |
this.dlg = dlg;
|
28 |
} |
29 |
public void actionPerformed(ActionEvent e) { |
30 |
if (e.getActionCommand().equalsIgnoreCase("OK")) |
31 |
{ |
32 |
dlg.dispose(); |
33 |
} |
34 |
if (e.getActionCommand().equalsIgnoreCase("CANCEL")) |
35 |
{ |
36 |
dlg.canceled = true;
|
37 |
dlg.dispose(); |
38 |
|
39 |
} |
40 |
} |
41 |
|
42 |
} |
43 |
|
44 |
private class MyModel extends DefaultTableModel { |
45 |
|
46 |
private ArrayList l; |
47 |
private ArrayList r; |
48 |
|
49 |
MyModel(ArrayList leftList, ArrayList rightList) { |
50 |
l = leftList; |
51 |
r = rightList; |
52 |
} |
53 |
|
54 |
public ArrayList getRigthValues() |
55 |
{ |
56 |
return r;
|
57 |
} |
58 |
public int getColumnCount() { |
59 |
return 2; |
60 |
} |
61 |
|
62 |
public int getRowCount() { |
63 |
if (l == null) return 0; |
64 |
return l.size();
|
65 |
} |
66 |
|
67 |
public Object getValueAt(int row, int column) { |
68 |
if (column == 0) |
69 |
return l.get(row);
|
70 |
return r.get(row);
|
71 |
} |
72 |
|
73 |
public boolean isCellEditable(int row, int column) { |
74 |
if (column == 1) |
75 |
return true; |
76 |
else
|
77 |
return false; |
78 |
} |
79 |
|
80 |
public void setValueAt(Object aValue, int row, int column) { |
81 |
r.set(row, aValue); |
82 |
} |
83 |
|
84 |
} |
85 |
private ArrayList firstList; |
86 |
private ArrayList secondList; |
87 |
|
88 |
private String msg; |
89 |
/**
|
90 |
*
|
91 |
*/
|
92 |
private static final long serialVersionUID = 1914037292995440998L; |
93 |
private JTextArea jLblMsg = null; // @jve:decl-index=0:visual-constraint="220,10" |
94 |
private JScrollPane jScrollPane = null; // @jve:decl-index=0:visual-constraint="183,139" |
95 |
private JTable jTable = null; |
96 |
private String colName1; |
97 |
private String colName2; |
98 |
|
99 |
public MultiInputDlg(String msg, ArrayList leftValues) { |
100 |
firstList = leftValues; |
101 |
secondList = new ArrayList(); |
102 |
for (int i=0; i < firstList.size(); i++) |
103 |
secondList.add("60");
|
104 |
this.msg = msg;
|
105 |
initialize(); |
106 |
} |
107 |
/**
|
108 |
* This method initializes this
|
109 |
*
|
110 |
*/
|
111 |
private void initialize() { |
112 |
jLblMsg = new JTextArea(); |
113 |
jLblMsg.setText(msg); |
114 |
jLblMsg.setBackground(SystemColor.control);
|
115 |
jLblMsg.setLineWrap(true);
|
116 |
jLblMsg.setPreferredSize(new Dimension(173, 49)); |
117 |
|
118 |
this.getContentPane().setLayout(new BorderLayout()); |
119 |
this.getContentPane().add(jLblMsg, BorderLayout.NORTH); |
120 |
this.setSize(new Dimension(200, 300)); |
121 |
this.getContentPane().add(getJScrollPane(), BorderLayout.CENTER); |
122 |
MyListener myListener = new MyListener(this); |
123 |
AcceptCancelPanel okCancelPanel = new AcceptCancelPanel(myListener, myListener);
|
124 |
this.getContentPane().add(okCancelPanel, BorderLayout.SOUTH); |
125 |
|
126 |
} |
127 |
|
128 |
public ArrayList getRightValues() { |
129 |
return secondList;
|
130 |
} |
131 |
/**
|
132 |
* This method initializes jScrollPane
|
133 |
*
|
134 |
* @return javax.swing.JScrollPane
|
135 |
*/
|
136 |
private JScrollPane getJScrollPane() { |
137 |
if (jScrollPane == null) { |
138 |
jScrollPane = new JScrollPane(); |
139 |
jScrollPane.setViewportView(getJTable()); |
140 |
} |
141 |
return jScrollPane;
|
142 |
} |
143 |
/**
|
144 |
* This method initializes jTable
|
145 |
*
|
146 |
* @return javax.swing.JTable
|
147 |
*/
|
148 |
private JTable getJTable() { |
149 |
if (jTable == null) { |
150 |
jTable = new JTable(); |
151 |
MyModel myModel = new MyModel(firstList, secondList);
|
152 |
jTable.setModel(myModel); |
153 |
} |
154 |
return jTable;
|
155 |
} |
156 |
public void actionPerformed(ActionEvent e) { |
157 |
|
158 |
|
159 |
} |
160 |
public boolean isCanceled() { |
161 |
return canceled;
|
162 |
} |
163 |
public void setColumnNames(String col1, String col2) { |
164 |
this.colName1 = col1;
|
165 |
this.colName2 = col2;
|
166 |
jTable.getColumnModel().getColumn(0).setHeaderValue(col1);
|
167 |
jTable.getColumnModel().getColumn(1).setHeaderValue(col2);
|
168 |
} |
169 |
|
170 |
} // @jve:decl-index=0:visual-constraint="10,10"
|