annotate SMART/Java/Sav/ProgramOption.java @ 22:1e3f2c2657a3

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:26:07 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 /**
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 * Copyright INRA-URGI 2009-2010
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 * This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 * abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 * modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 * license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 * "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 * As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 * modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 * with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 * economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 * liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 * In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 * with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 * software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 * that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 * therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 * professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 * encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 * requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 * data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 * same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 * The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 * knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 */
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 import java.util.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 import java.awt.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 import java.awt.event.ActionEvent;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 import java.awt.event.ActionListener;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 import java.io.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 import javax.swing.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 import javax.swing.filechooser.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 import javax.swing.border.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 import javax.swing.SwingUtilities;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 public class ProgramOption {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 boolean input;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 String identifier;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 String type;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 String comment;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 boolean compulsory;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 String[] format;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 String formatIdentifier;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 ProgramOption associatedOption;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 String defaultValue;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 String[] choices;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 JComponent component;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 JPanel panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 public ProgramOption() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 this.input = true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 this.identifier = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 this.type = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 this.comment = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 this.compulsory = false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 this.format = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 this.formatIdentifier = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 this.associatedOption = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 this.defaultValue = "";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 this.choices = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 this.component = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 this.panel = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 public void setInput(boolean input) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 this.input = input;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 public void setIdentifier(String identifier) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 this.identifier = identifier;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 public void setType(String type) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 this.type = type;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 public void setComment(String comment) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 this.comment = comment;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 public void setCompulsory(boolean compulsory) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 this.compulsory = compulsory;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 public void setFormat(String[] format) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 this.format = format;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 public void setFormat(String format) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 this.format = new String[1];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 this.format[0] = format;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 public void setFormatIdentifier(String formatIdentifier) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 this.formatIdentifier = formatIdentifier;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 public void setAssociatedOption(ProgramOption option) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 this.associatedOption = option;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 public void setChoices(String[] choices) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 this.choices = choices;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 public void setDefault(String defaultValue) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 this.defaultValue = defaultValue;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 public boolean isInput() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 return this.input;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 public JPanel getPanel() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 if (this.panel != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 return this.panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 String comment = this.comment;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 if (this.compulsory) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 comment += " [*]";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 GridLayout horizontalLayout = new GridLayout(1, 0);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 this.panel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 this.panel.setLayout(horizontalLayout);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 JLabel label = new JLabel(comment);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 if (this.type == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 System.out.println("Error! Option '" + this.identifier + "' is not set!");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 if (("int".compareToIgnoreCase(this.type) == 0) || ("float".compareToIgnoreCase(this.type) == 0) || ("string".compareToIgnoreCase(this.type) == 0) || (("file".compareToIgnoreCase(this.type) == 0) && (!this.input))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 this.component = new JTextField();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 if (this.defaultValue != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 ((JTextField) this.component).setText(this.defaultValue);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 this.panel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 else if ("file".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 this.component = new JList(Global.fileNames);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 ((JList) this.component).setVisibleRowCount(1);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 JScrollPane scroll = new JScrollPane(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 Box box = Box.createHorizontalBox();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 box.add(Box.createRigidArea(new Dimension(0, 100)));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 box.add(scroll);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 this.panel.add(box);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 else if ("boolean".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 this.component = new JCheckBox();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 if ((this.defaultValue != null) && (this.defaultValue.compareToIgnoreCase("true") == 0)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 ((JCheckBox) this.component).setSelected(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 this.panel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 else if ("format".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 Vector < String > formats = new Vector < String > ();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 for (String format: this.format) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 formats.addAll(Global.formats.getFormats(format).getFormats());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 this.component = new JComboBox(formats);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 this.panel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 else if ("files".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 JButton button = new JButton("file...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 this.component = new JTextField();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 this.panel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 this.panel.add(button);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 Global.otherFileConcatenationChooser.put(button, (JTextField) this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 else if ("directory".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 JButton button = new JButton("directory...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 this.component = new JTextField();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 JPanel rightPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.LINE_AXIS));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 rightPanel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 rightPanel.add(button);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 this.panel.add(rightPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 Global.otherDirectoriesChooser.put(button, (JTextField) this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 else if ("choice".compareToIgnoreCase(this.type) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 this.component = new JComboBox(this.choices);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 label.setLabelFor(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 this.panel.add(label);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 this.panel.add(this.component);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 System.out.println("Do not know how to read type " + this.type);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 return this.panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 public JComponent getComponent() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 if (component == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 this.getPanel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 return this.component;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 private String getValue() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 if (("int".equals(this.type)) || ("float".equals(this.type)) || ("string".equals(this.type)) || (("file".equals(this.type)) && (! this.input)) || ("directory".equals(this.type)) || ("files".equals(this.type))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 String s = ((JTextField) this.component).getText();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 if ("None".equals(s)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 return "";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 return s;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 if ("file".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 return (String) ((JList) this.component).getSelectedValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 if ("boolean".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 return ((JCheckBox) this.component).isSelected()? "true": "false";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 if ("format".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 return (String) ((JComboBox) this.component).getSelectedItem();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258 public String checkValue() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259 String value = this.getValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 if ((this.compulsory) && ((value == null) || ("".equals(value)))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 return "Option '" + this.comment + "' has no value... Please specify it.\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 if ("int".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 if ((value != null) && (! "".equals(value)) && (! "None".equals(value))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 int i = Integer.parseInt(value);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268 catch (NumberFormatException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 return "Option '" + this.comment + "' should be an integer... Please correct it.\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 else if ("float".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 if ((value != null) && (! "".equals(value))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 float i = Float.parseFloat(value);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 catch (NumberFormatException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 return "Option '" + this.comment + "' should be a float... Please correct it.\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287 public LinkedList <String> getCommand() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288 LinkedList <String> list = new LinkedList <String> ();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 if (("int".equals(this.type)) || ("float".equals(this.type)) || ("string".equals(this.type)) || (("file".equals(this.type)) && (! this.input)) || ("format".equals(this.type)) || ("directory".equals(this.type)) || ("files".equals(this.type))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 String value = this.getValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 if (value.length() == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 return list;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 list.add(this.identifier);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296 list.add(value);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 return list;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 if ("file".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 String fileName = (String) ((JList) this.component).getSelectedValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 if (fileName == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302 return list;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 list.add(this.identifier);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305 list.add(this.getValue());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 return list;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 if ("boolean".equals(this.type)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 if ("true".equals(this.getValue())) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 list.add(this.identifier);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 return list;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318 public File getOutputFile() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319 if (this.input) return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 String format = "";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321 if (this.format != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 format = this.format[0];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 if (this.associatedOption != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 format = this.associatedOption.getValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 return new File(this.getValue() + "." + format, Global.formats.getFormatType(format), format);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329 }