annotate java-genomics-toolkit/gui/edu/unc/genomics/JobConfigPanel.java @ 0:1daf3026d231

Upload alpha version
author timpalpant
date Mon, 13 Feb 2012 21:55:55 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
1 package edu.unc.genomics;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
2
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
3 import java.awt.Color;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
4 import java.awt.Component;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
5 import java.awt.Dimension;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
6 import java.awt.FileDialog;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
7 import java.awt.event.ActionEvent;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
8 import java.awt.event.ActionListener;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
9 import java.lang.reflect.Field;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
10 import java.nio.file.Path;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
11 import java.util.HashMap;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
12 import java.util.List;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
13 import java.util.Map;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
14
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
15 import javax.swing.BorderFactory;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
16 import javax.swing.BoxLayout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
17 import javax.swing.ImageIcon;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
18 import javax.swing.JButton;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
19 import javax.swing.JComboBox;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
20 import javax.swing.JComponent;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
21 import javax.swing.JFileChooser;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
22 import javax.swing.JFrame;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
23 import javax.swing.JLabel;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
24 import javax.swing.JPanel;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
25 import javax.swing.JTextField;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
26 import javax.swing.SpringLayout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
27 import javax.swing.SwingUtilities;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
28 import javax.swing.event.DocumentEvent;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
29 import javax.swing.event.DocumentListener;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
30 import javax.swing.layout.SpringUtilities;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
31 import javax.swing.text.BadLocationException;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
32 import javax.swing.text.Document;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
33
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
34 import org.apache.commons.lang3.StringUtils;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
35 import org.apache.log4j.Logger;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
36
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
37 import com.beust.jcommander.ParameterDescription;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
38
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
39 import edu.unc.genomics.io.IntervalFile;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
40 import edu.unc.genomics.io.WigFile;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
41
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
42 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
43 * View for configuring the parameters of a Job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
44 * Implements databinding between a Job object and the various Swing components
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
45 * for configuring each parameter
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
46 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
47 * @author timpalpant
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
48 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
49 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
50 public class JobConfigPanel extends JPanel {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
51
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
52 private static final long serialVersionUID = 3336295203155728629L;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
53 private static final Logger log = Logger.getLogger(JobConfigPanel.class);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
54
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
55 private static final ImageIcon fileIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("folder_page.png").toString());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
56
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
57 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
58 * Maps parameters in the Job to GUI components (forward data-binding)
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
59 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
60 private Map<ParameterDescription, JComponent> guiMap = new HashMap<>();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
61
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
62 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
63 * Maps GUI components to parameters in the Job (reverse data-binding)
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
64 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
65 private Map<Component, ParameterDescription> jobMap = new HashMap<>();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
66
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
67 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
68 * The model for the Job that this panel allows you to configure
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
69 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
70 private Job job;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
71
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
72 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
73 * Initialize a new ConfigurationPanel with no Job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
74 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
75 public JobConfigPanel() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
76 this(null);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
77 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
78
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
79 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
80 * Initialize a new ConfigurationPanel for the given Job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
81 * @param job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
82 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
83 public JobConfigPanel(final Job job) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
84 setJob(job);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
85 setLayout(new SpringLayout());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
86 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
87
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
88 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
89 * Return the Job that this ConfigurationPanel is editing
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
90 * @return
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
91 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
92 public Job getJob() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
93 return job;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
94 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
95
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
96 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
97 * Set the job for this Configuration panel and re-render
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
98 * @param job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
99 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
100 public void setJob(final Job job) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
101 this.job = job;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
102 renderJob();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
103 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
104
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
105 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
106 * Highlights fields on the Panel that are not set correctly
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
107 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
108 public void highlightInvalidArguments() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
109 for (ParameterDescription param : job) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
110 JComponent guiComponent = guiMap.get(param);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
111 if (param.getParameter().required() && !job.isSet(param)) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
112 guiComponent.setBorder(BorderFactory.createLineBorder(Color.RED));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
113 } else {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
114 guiComponent.setBorder(BorderFactory.createEmptyBorder());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
115 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
116 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
117 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
118
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
119 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
120 * Render the parameters from the Job into GUI components
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
121 * and set up one-way data binding to map changes to the GUI fields
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
122 * back into the Job object's parameters
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
123 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
124 private void renderJob() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
125 removeAll();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
126 guiMap.clear();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
127 jobMap.clear();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
128 if (job == null) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
129 validate();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
130 repaint();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
131 return;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
132 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
133
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
134 // Iterate through the parameters in the Job
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
135 // and render them appropriately based on their type
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
136 for (ParameterDescription paramDescription : job) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
137 // Add the parameter name to the configuration panel
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
138 String name = paramDescription.getLongestName();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
139 while (name.startsWith("-")) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
140 name = name.substring(1);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
141 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
142 name = StringUtils.capitalize(name);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
143 JLabel label = new JLabel(name);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
144 label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
145 add(label);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
146
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
147 // Add a panel for configuring the parameter
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
148 JPanel fieldPanel = new JPanel();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
149 fieldPanel.setLayout(new BoxLayout(fieldPanel, BoxLayout.LINE_AXIS));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
150 add(fieldPanel);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
151 Field field = paramDescription.getField();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
152 Class<?> type = field.getType();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
153 if (type.equals(Assembly.class)) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
154 List<Assembly> availableAssemblies = AssemblyManager.getAvailableAssemblies();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
155 Assembly[] assemblies = new Assembly[availableAssemblies.size()];
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
156 assemblies = availableAssemblies.toArray(assemblies);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
157 final JComboBox<Assembly> cbAssemblyChooser = new JComboBox<Assembly>(assemblies);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
158 cbAssemblyChooser.setPreferredSize(new Dimension(0, 25));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
159 cbAssemblyChooser.setMaximumSize(new Dimension(Integer.MAX_VALUE, cbAssemblyChooser.getPreferredSize().height));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
160 cbAssemblyChooser.setSelectedItem(AssemblyManager.getLastUsed());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
161 cbAssemblyChooser.addActionListener(new ActionListener() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
162 public void actionPerformed(ActionEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
163 log.debug("Auto-databinding changed assembly into Job argument");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
164 Assembly selectedAssembly = (Assembly) cbAssemblyChooser.getSelectedItem();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
165 AssemblyManager.setLastUsed(selectedAssembly);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
166 ParameterDescription param = jobMap.get(cbAssemblyChooser);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
167 job.setArgument(param, selectedAssembly.toString());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
168 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
169 });
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
170 fieldPanel.add(cbAssemblyChooser);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
171 guiMap.put(paramDescription, cbAssemblyChooser);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
172 jobMap.put(cbAssemblyChooser, paramDescription);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
173 } else {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
174 final JTextField textField = new JTextField();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
175 // Set to default parameter, if it exists
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
176 if (job.isSet(paramDescription)) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
177 textField.setText(job.getArgument(paramDescription));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
178 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
179 textField.setPreferredSize(new Dimension(0, 20));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
180 textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, textField.getPreferredSize().height));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
181 textField.getDocument().addDocumentListener(new DocumentListener() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
182 public void changedUpdate(DocumentEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
183 pushTextToModel(e);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
184 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
185
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
186 public void removeUpdate(DocumentEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
187 pushTextToModel(e);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
188 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
189
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
190 public void insertUpdate(DocumentEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
191 pushTextToModel(e);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
192 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
193
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
194 private void pushTextToModel(DocumentEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
195 log.debug("Auto-databinding changed text into Job argument");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
196 Document doc = (Document) e.getDocument();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
197 ParameterDescription param = jobMap.get(textField);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
198 try {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
199 String text = doc.getText(0, doc.getLength());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
200 job.setArgument(param, text);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
201 } catch (BadLocationException e1) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
202 log.error("Error pushing changed text into Job model");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
203 e1.printStackTrace();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
204 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
205 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
206 });
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
207 fieldPanel.add(textField);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
208 guiMap.put(paramDescription, textField);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
209 jobMap.put(textField, paramDescription);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
210
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
211 // For input/output files, add a file chooser button
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
212 if (type.equals(Path.class) || type.equals(WigFile.class) || type.equals(IntervalFile.class)) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
213 // TODO Replace with file icon
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
214 JButton btnChooseFile = new JButton(fileIcon);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
215 btnChooseFile.addActionListener(new ActionListener() {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
216 public void actionPerformed(ActionEvent e) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
217 // AWT FileDialog uses native components, but seems to hang
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
218 //Component c = (Component) e.getSource();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
219 //JFrame frame = (JFrame) SwingUtilities.getRoot(c);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
220 //FileDialog fd = new FileDialog(frame, "Choose File");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
221 //fd.setVisible(true);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
222 //if (fd.getFile() != null) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
223 // textField.setText(fd.getDirectory()+fd.getFile());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
224 //}
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
225
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
226 // Swing JFileChooser
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
227 JFileChooser fc = new JFileChooser();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
228 int retValue = fc.showDialog(getParent(), "OK");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
229 if (retValue == JFileChooser.APPROVE_OPTION) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
230 textField.setText(fc.getSelectedFile().toString());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
231 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
232 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
233 });
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
234 fieldPanel.add(btnChooseFile);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
235 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
236 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
237 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
238
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
239 // Lay out the panel
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
240 SpringUtilities.makeCompactGrid(this, job.numParameters(), 2, 5, 5, 5, 5);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
241
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
242 validate();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
243 repaint();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
244 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
245
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
246 }