2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SearchDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:41 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
/* |
2 |
26 Feb 07 |
jari |
* GeneSearchDialog.java |
2 |
26 Feb 07 |
jari |
15 |
* |
2 |
26 Feb 07 |
jari |
* Created on September 8, 2004, 9:53 AM |
2 |
26 Feb 07 |
jari |
17 |
*/ |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
27 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
28 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
29 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
30 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
31 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JList; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.ListCellRenderer; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.ParameterPanel; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
/** |
2 |
26 Feb 07 |
jari |
52 |
* |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
54 |
*/ |
2 |
26 Feb 07 |
jari |
55 |
public class SearchDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
private int result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
private JPanel controlPanel; |
2 |
26 Feb 07 |
jari |
60 |
private JTextField termField; |
2 |
26 Feb 07 |
jari |
61 |
private JCheckBox caseSensBox; |
2 |
26 Feb 07 |
jari |
62 |
private JCheckBox entireWordBox; |
2 |
26 Feb 07 |
jari |
63 |
private JRadioButton geneSearchButton; |
2 |
26 Feb 07 |
jari |
64 |
private JRadioButton expSearchButton; |
2 |
26 Feb 07 |
jari |
65 |
private FieldsPanel fieldsPanel; |
2 |
26 Feb 07 |
jari |
66 |
private FieldsPanel sampleFieldsPanel; |
2 |
26 Feb 07 |
jari |
67 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of GeneSearchDialog */ |
2 |
26 Feb 07 |
jari |
69 |
public SearchDialog(Frame parent, String [] fieldNames, String [] sampleNames) { |
2 |
26 Feb 07 |
jari |
70 |
super(parent, "Global Search", true); |
2 |
26 Feb 07 |
jari |
71 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
//Main panel |
2 |
26 Feb 07 |
jari |
74 |
controlPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
75 |
controlPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
//search gene or experiment selection panel |
2 |
26 Feb 07 |
jari |
78 |
ParameterPanel modePanel = new ParameterPanel("Search Mode"); |
2 |
26 Feb 07 |
jari |
79 |
modePanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
80 |
ButtonGroup bg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
geneSearchButton = new JRadioButton("Gene Search", true); |
2 |
26 Feb 07 |
jari |
83 |
geneSearchButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
84 |
geneSearchButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
85 |
geneSearchButton.setActionCommand("search-mode-change"); |
2 |
26 Feb 07 |
jari |
86 |
geneSearchButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
87 |
bg.add(geneSearchButton); |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
expSearchButton = new JRadioButton("Sample Search", true); |
2 |
26 Feb 07 |
jari |
90 |
expSearchButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
91 |
expSearchButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
92 |
expSearchButton.setActionCommand("search-mode-change"); |
2 |
26 Feb 07 |
jari |
93 |
expSearchButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
94 |
bg.add(expSearchButton); |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
modePanel.add(geneSearchButton, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,15,0,25),0,0)); |
2 |
26 Feb 07 |
jari |
97 |
modePanel.add(expSearchButton, new GridBagConstraints(1,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,40,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
//search term panel |
2 |
26 Feb 07 |
jari |
100 |
ParameterPanel searchTermPanel = new ParameterPanel("Search Term"); |
2 |
26 Feb 07 |
jari |
101 |
searchTermPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
JLabel termLabel = new JLabel("Search Term:"); |
2 |
26 Feb 07 |
jari |
104 |
termLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
termField = new JTextField(25); |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
caseSensBox = new JCheckBox("Case Sensitive", false); |
2 |
26 Feb 07 |
jari |
109 |
caseSensBox.setOpaque(false); |
2 |
26 Feb 07 |
jari |
110 |
caseSensBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
entireWordBox = new JCheckBox("Exact Match", false); |
2 |
26 Feb 07 |
jari |
113 |
entireWordBox.setOpaque(false); |
2 |
26 Feb 07 |
jari |
114 |
entireWordBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
//add components |
2 |
26 Feb 07 |
jari |
117 |
searchTermPanel.add(termLabel, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(5,20,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
118 |
searchTermPanel.add(termField, new GridBagConstraints(1,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,10,0,20), 0, 0)); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
121 |
panel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
122 |
panel.add(caseSensBox, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,35), 0, 0)); |
2 |
26 Feb 07 |
jari |
123 |
panel.add(entireWordBox, new GridBagConstraints(1,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,15,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
124 |
searchTermPanel.add(panel, new GridBagConstraints(0,1,2,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
//Now the search fields |
2 |
26 Feb 07 |
jari |
//Use an nxm layout option with rows over columns |
2 |
26 Feb 07 |
jari |
128 |
fieldsPanel = new FieldsPanel(fieldNames); |
2 |
26 Feb 07 |
jari |
//fieldsPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
sampleFieldsPanel = new FieldsPanel(sampleNames); |
2 |
26 Feb 07 |
jari |
132 |
|
2 |
26 Feb 07 |
jari |
133 |
controlPanel.add(modePanel, new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0)); |
2 |
26 Feb 07 |
jari |
134 |
controlPanel.add(searchTermPanel, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0)); |
2 |
26 Feb 07 |
jari |
135 |
controlPanel.add(fieldsPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0)); |
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
addContent(controlPanel); |
2 |
26 Feb 07 |
jari |
138 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
139 |
pack(); |
2 |
26 Feb 07 |
jari |
140 |
} |
2 |
26 Feb 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
142 |
/** |
2 |
26 Feb 07 |
jari |
* Shows the dialog. |
2 |
26 Feb 07 |
jari |
144 |
*/ |
2 |
26 Feb 07 |
jari |
145 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
146 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
147 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
148 |
show(); |
2 |
26 Feb 07 |
jari |
149 |
return result; |
2 |
26 Feb 07 |
jari |
150 |
} |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
public Vector getSelectedFields() { |
2 |
26 Feb 07 |
jari |
154 |
FieldsPanel fPanel; |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
if(isGeneSearch()) |
2 |
26 Feb 07 |
jari |
157 |
fPanel = fieldsPanel; |
2 |
26 Feb 07 |
jari |
158 |
else |
2 |
26 Feb 07 |
jari |
159 |
fPanel = sampleFieldsPanel; |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
Vector v = new Vector(); |
2 |
26 Feb 07 |
jari |
162 |
Vector boxes = fPanel.fieldBoxVector; |
2 |
26 Feb 07 |
jari |
163 |
JCheckBox box; |
2 |
26 Feb 07 |
jari |
164 |
for(int i = 0; i < boxes.size(); i++) { |
2 |
26 Feb 07 |
jari |
165 |
box = (JCheckBox)(boxes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
166 |
if(box.isSelected()) |
2 |
26 Feb 07 |
jari |
167 |
v.add(box.getText()); |
2 |
26 Feb 07 |
jari |
168 |
} |
2 |
26 Feb 07 |
jari |
169 |
return v; |
2 |
26 Feb 07 |
jari |
170 |
} |
2 |
26 Feb 07 |
jari |
171 |
|
2 |
26 Feb 07 |
jari |
172 |
public boolean isGeneSearch() { |
2 |
26 Feb 07 |
jari |
173 |
return geneSearchButton.isSelected(); |
2 |
26 Feb 07 |
jari |
174 |
} |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
public String getSearchTerm() { |
2 |
26 Feb 07 |
jari |
177 |
return termField.getText(); |
2 |
26 Feb 07 |
jari |
178 |
} |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
public boolean isCaseSensitive() { |
2 |
26 Feb 07 |
jari |
181 |
return caseSensBox.isSelected(); |
2 |
26 Feb 07 |
jari |
182 |
} |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
public boolean isWholeTermRequired() { |
2 |
26 Feb 07 |
jari |
//swiched label and polarity |
2 |
26 Feb 07 |
jari |
186 |
return entireWordBox.isSelected(); |
2 |
26 Feb 07 |
jari |
187 |
} |
2 |
26 Feb 07 |
jari |
188 |
|
2 |
26 Feb 07 |
jari |
189 |
public AlgorithmData getSearchCriteria() { |
2 |
26 Feb 07 |
jari |
190 |
AlgorithmData params = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
191 |
params.addParam("search-term", getSearchTerm()); |
2 |
26 Feb 07 |
jari |
192 |
params.addParam("case-sensitive", String.valueOf(isCaseSensitive())); |
2 |
26 Feb 07 |
jari |
193 |
params.addParam("full-term", String.valueOf(isWholeTermRequired())); |
2 |
26 Feb 07 |
jari |
194 |
params.addParam("gene-search", String.valueOf(isGeneSearch())); |
2 |
26 Feb 07 |
jari |
195 |
Vector v = getSelectedFields(); |
2 |
26 Feb 07 |
jari |
196 |
String [] fieldNames = new String[v.size()]; |
2 |
26 Feb 07 |
jari |
197 |
for(int i = 0; i < fieldNames.length; i++) { |
2 |
26 Feb 07 |
jari |
198 |
fieldNames[i] = (String)(v.elementAt(i)); |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
params.addStringArray("field-names", fieldNames); |
2 |
26 Feb 07 |
jari |
201 |
return params; |
2 |
26 Feb 07 |
jari |
202 |
} |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
private void resetControls() { |
2 |
26 Feb 07 |
jari |
205 |
geneSearchButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
206 |
caseSensBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
207 |
entireWordBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
208 |
|
2 |
26 Feb 07 |
jari |
209 |
for(int i = 0; i < fieldsPanel.fieldBoxVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
210 |
((JCheckBox)(fieldsPanel.fieldBoxVector.elementAt(i))).setSelected(i == 0); |
2 |
26 Feb 07 |
jari |
211 |
} |
2 |
26 Feb 07 |
jari |
212 |
|
2 |
26 Feb 07 |
jari |
213 |
termField.setText(""); |
2 |
26 Feb 07 |
jari |
214 |
termField.grabFocus(); |
2 |
26 Feb 07 |
jari |
215 |
termField.selectAll(); |
2 |
26 Feb 07 |
jari |
216 |
} |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
private class FieldsPanel extends ParameterPanel { |
2 |
26 Feb 07 |
jari |
219 |
JScrollPane scrollPane; |
2 |
26 Feb 07 |
jari |
220 |
JList fieldList; |
2 |
26 Feb 07 |
jari |
221 |
Vector fieldBoxVector; |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
223 |
JButton allButton; |
2 |
26 Feb 07 |
jari |
224 |
JButton resetSelButton; |
2 |
26 Feb 07 |
jari |
225 |
|
2 |
26 Feb 07 |
jari |
226 |
public FieldsPanel(String [] fields) { |
2 |
26 Feb 07 |
jari |
227 |
super("Searchable Fields"); |
2 |
26 Feb 07 |
jari |
228 |
super.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
229 |
setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
230 |
|
2 |
26 Feb 07 |
jari |
231 |
allButton = new JButton("Select All Fields"); |
2 |
26 Feb 07 |
jari |
232 |
allButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
233 |
allButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
234 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
235 |
for(int i = 0; i < fieldBoxVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
236 |
((JCheckBox)(fieldBoxVector.elementAt(i))).setSelected(true); |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
} |
2 |
26 Feb 07 |
jari |
239 |
}); |
2 |
26 Feb 07 |
jari |
240 |
|
2 |
26 Feb 07 |
jari |
241 |
resetSelButton = new JButton("Reset Selection"); |
2 |
26 Feb 07 |
jari |
242 |
resetSelButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
243 |
resetSelButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
244 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
245 |
for(int i = 0; i < fieldBoxVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
246 |
((JCheckBox)(fieldBoxVector.elementAt(i))).setSelected(i == 0); |
2 |
26 Feb 07 |
jari |
247 |
} |
2 |
26 Feb 07 |
jari |
248 |
} |
2 |
26 Feb 07 |
jari |
249 |
}); |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
fieldBoxVector = new Vector(); |
2 |
26 Feb 07 |
jari |
252 |
JPanel fieldPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
253 |
fieldPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
254 |
fieldPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//fieldPanel.setPreferredSize(new Dimension(200,200)); |
2 |
26 Feb 07 |
jari |
//scrollPane.setSize(200,200); |
2 |
26 Feb 07 |
jari |
257 |
|
2 |
26 Feb 07 |
jari |
258 |
for(int i = 0; i < fields.length; i++) { |
2 |
26 Feb 07 |
jari |
259 |
addBox(fieldPanel, fieldBoxVector, fields[i], i); |
2 |
26 Feb 07 |
jari |
260 |
} |
2 |
26 Feb 07 |
jari |
261 |
|
2 |
26 Feb 07 |
jari |
262 |
fieldList = new JList(fieldBoxVector); |
2 |
26 Feb 07 |
jari |
263 |
fieldList.setSelectionMode(javax.swing.DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
2 |
26 Feb 07 |
jari |
264 |
fieldList.setVisibleRowCount(5); |
2 |
26 Feb 07 |
jari |
265 |
fieldList.setCellRenderer(new MyCellRenderer()); |
2 |
26 Feb 07 |
jari |
266 |
scrollPane = new JScrollPane(fieldPanel); |
2 |
26 Feb 07 |
jari |
267 |
scrollPane.setPreferredSize(new Dimension(350,Math.min(200, fieldBoxVector.size()*30))); |
2 |
26 Feb 07 |
jari |
268 |
scrollPane.setSize(350, Math.min(200, fieldBoxVector.size()*30)); |
2 |
26 Feb 07 |
jari |
269 |
|
2 |
26 Feb 07 |
jari |
270 |
super.add(allButton, new GridBagConstraints(0,0,1,1,0,0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,0,10,5), 0,0)); |
2 |
26 Feb 07 |
jari |
271 |
super.add(resetSelButton, new GridBagConstraints(1,0,1,1,0,0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,10,0), 0,0)); |
2 |
26 Feb 07 |
jari |
272 |
JPanel p = new JPanel(); |
2 |
26 Feb 07 |
jari |
273 |
p.setBackground(Color.red); |
2 |
26 Feb 07 |
jari |
274 |
super.add(scrollPane, new GridBagConstraints(0,1,2,1,0,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
275 |
} |
2 |
26 Feb 07 |
jari |
276 |
} |
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
278 |
private class MyCellRenderer implements ListCellRenderer { |
2 |
26 Feb 07 |
jari |
279 |
private JCheckBox box; |
2 |
26 Feb 07 |
jari |
280 |
|
2 |
26 Feb 07 |
jari |
281 |
public MyCellRenderer() { |
2 |
26 Feb 07 |
jari |
282 |
box = new JCheckBox(); |
2 |
26 Feb 07 |
jari |
283 |
box.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
284 |
box.setOpaque(false); |
2 |
26 Feb 07 |
jari |
285 |
} |
2 |
26 Feb 07 |
jari |
286 |
|
2 |
26 Feb 07 |
jari |
287 |
public java.awt.Component getListCellRendererComponent(JList jList, Object obj, int param, boolean sel, boolean param4) { |
2 |
26 Feb 07 |
jari |
288 |
box.setText((String)obj); |
2 |
26 Feb 07 |
jari |
289 |
box.setSelected(sel); |
2 |
26 Feb 07 |
jari |
290 |
return box; |
2 |
26 Feb 07 |
jari |
291 |
} |
2 |
26 Feb 07 |
jari |
292 |
|
2 |
26 Feb 07 |
jari |
293 |
} |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
private void addBox(JPanel p, Vector v, String s, int yPos) { |
2 |
26 Feb 07 |
jari |
296 |
JCheckBox box = new JCheckBox(s); |
2 |
26 Feb 07 |
jari |
297 |
box.setOpaque(false); |
2 |
26 Feb 07 |
jari |
298 |
box.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
299 |
box.setSelected(yPos == 0); |
2 |
26 Feb 07 |
jari |
300 |
p.add(box, new GridBagConstraints(0,yPos,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
301 |
v.addElement(box); |
2 |
26 Feb 07 |
jari |
302 |
} |
2 |
26 Feb 07 |
jari |
303 |
|
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
private void setFieldsPanel() { |
2 |
26 Feb 07 |
jari |
306 |
if(!this.isGeneSearch()) { |
2 |
26 Feb 07 |
jari |
307 |
controlPanel.remove(fieldsPanel); |
2 |
26 Feb 07 |
jari |
308 |
controlPanel.add(sampleFieldsPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0)); |
2 |
26 Feb 07 |
jari |
309 |
controlPanel.validate(); |
2 |
26 Feb 07 |
jari |
310 |
repaint(); |
2 |
26 Feb 07 |
jari |
// pack(); |
2 |
26 Feb 07 |
jari |
312 |
} else { |
2 |
26 Feb 07 |
jari |
313 |
controlPanel.remove(sampleFieldsPanel); |
2 |
26 Feb 07 |
jari |
314 |
controlPanel.add(fieldsPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0)); |
2 |
26 Feb 07 |
jari |
315 |
controlPanel.validate(); |
2 |
26 Feb 07 |
jari |
316 |
repaint(); |
2 |
26 Feb 07 |
jari |
// pack(); |
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
322 |
String [] s = new String[8]; |
2 |
26 Feb 07 |
jari |
323 |
s[0] = "UID"; |
2 |
26 Feb 07 |
jari |
324 |
s[1] = "TC#"; |
2 |
26 Feb 07 |
jari |
325 |
s[2]= "GenBank"; |
2 |
26 Feb 07 |
jari |
326 |
s[3] = "Locus Link Human gene Identifier this is a long field name"; |
2 |
26 Feb 07 |
jari |
327 |
s[4] = "Unigene"; |
2 |
26 Feb 07 |
jari |
328 |
|
2 |
26 Feb 07 |
jari |
329 |
s[5] = "UID"; |
2 |
26 Feb 07 |
jari |
330 |
s[6] = "TC#"; |
2 |
26 Feb 07 |
jari |
331 |
s[7]= "GenBank"; |
2 |
26 Feb 07 |
jari |
332 |
String [] expFields = new String[2]; |
2 |
26 Feb 07 |
jari |
333 |
expFields[0] = "Default Sample Name"; |
2 |
26 Feb 07 |
jari |
334 |
expFields[1] = "Strain"; |
2 |
26 Feb 07 |
jari |
335 |
SearchDialog dialog = new SearchDialog(new Frame(), s, expFields); |
2 |
26 Feb 07 |
jari |
336 |
dialog.showModal(); |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
|
2 |
26 Feb 07 |
jari |
339 |
|
2 |
26 Feb 07 |
jari |
340 |
|
2 |
26 Feb 07 |
jari |
341 |
private class Listener extends DialogListener { |
2 |
26 Feb 07 |
jari |
342 |
|
2 |
26 Feb 07 |
jari |
343 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
344 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
345 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
346 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
347 |
dispose(); |
2 |
26 Feb 07 |
jari |
348 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
349 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
350 |
dispose(); |
2 |
26 Feb 07 |
jari |
351 |
} |
2 |
26 Feb 07 |
jari |
352 |
else if (command.equals("reset-command")){ |
2 |
26 Feb 07 |
jari |
353 |
resetControls(); |
2 |
26 Feb 07 |
jari |
354 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
355 |
return; |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
358 |
HelpWindow hw = new HelpWindow(SearchDialog.this, "Search Dialog"); |
2 |
26 Feb 07 |
jari |
359 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
360 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
361 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
362 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
363 |
hw.show(); |
2 |
26 Feb 07 |
jari |
364 |
return; |
2 |
26 Feb 07 |
jari |
365 |
} |
2 |
26 Feb 07 |
jari |
366 |
else { |
2 |
26 Feb 07 |
jari |
367 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
368 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
369 |
return; |
2 |
26 Feb 07 |
jari |
370 |
} |
2 |
26 Feb 07 |
jari |
371 |
} else if (command.equals("search-mode-change")) { |
2 |
26 Feb 07 |
jari |
372 |
setFieldsPanel(); |
2 |
26 Feb 07 |
jari |
373 |
return; |
2 |
26 Feb 07 |
jari |
374 |
} |
2 |
26 Feb 07 |
jari |
375 |
dispose(); |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
|
2 |
26 Feb 07 |
jari |
378 |
|
2 |
26 Feb 07 |
jari |
379 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
380 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
381 |
dispose(); |
2 |
26 Feb 07 |
jari |
382 |
} |
2 |
26 Feb 07 |
jari |
383 |
} |
2 |
26 Feb 07 |
jari |
384 |
|
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
} |