svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / comboboxconfigurablelookup / usertests / JPanelUserTestOfJComboBoxConfigurableLookUp.java @ 40561
History | View | Annotate | Download (112 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.comboboxconfigurablelookup.usertests; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.FlowLayout; |
29 |
import java.awt.Font; |
30 |
import java.awt.GridLayout; |
31 |
import java.awt.event.MouseAdapter; |
32 |
import java.awt.event.MouseEvent; |
33 |
import java.awt.event.WindowAdapter; |
34 |
import java.awt.event.WindowEvent; |
35 |
import java.io.BufferedReader; |
36 |
import java.io.File; |
37 |
import java.io.FileReader; |
38 |
import java.io.IOException; |
39 |
import java.io.OutputStream; |
40 |
import java.io.PrintStream; |
41 |
import java.io.Serializable; |
42 |
import java.lang.reflect.InvocationTargetException; |
43 |
import java.lang.reflect.Method; |
44 |
import java.util.HashMap; |
45 |
import java.util.Map; |
46 |
import java.util.StringTokenizer; |
47 |
import java.util.Vector; |
48 |
|
49 |
import javax.swing.BorderFactory; |
50 |
import javax.swing.JButton; |
51 |
import javax.swing.JCheckBox; |
52 |
import javax.swing.JComboBox; |
53 |
import javax.swing.JFrame; |
54 |
import javax.swing.JLabel; |
55 |
import javax.swing.JOptionPane; |
56 |
import javax.swing.JPanel; |
57 |
import javax.swing.JScrollPane; |
58 |
import javax.swing.JTabbedPane; |
59 |
import javax.swing.JTextArea; |
60 |
import javax.swing.JTextField; |
61 |
import javax.swing.border.TitledBorder; |
62 |
import javax.swing.event.ListDataEvent; |
63 |
import javax.swing.event.ListDataListener; |
64 |
import javax.swing.event.PopupMenuEvent; |
65 |
import javax.swing.event.PopupMenuListener; |
66 |
|
67 |
import org.gvsig.gui.beans.Messages; |
68 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.DefaultComboBoxConfigurableLookUpModel; |
69 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
70 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.programmertests.SampleBasicComboBoxRenderer; |
71 |
|
72 |
|
73 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
74 |
*
|
75 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
76 |
*
|
77 |
* This program is free software; you can redistribute it and/or
|
78 |
* modify it under the terms of the GNU General Public License
|
79 |
* as published by the Free Software Foundation; either version 2
|
80 |
* of the License, or (at your option) any later version.
|
81 |
*
|
82 |
* This program is distributed in the hope that it will be useful,
|
83 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
84 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
85 |
* GNU General Public License for more details.
|
86 |
*
|
87 |
* You should have received a copy of the GNU General Public License
|
88 |
* along with this program; if not, write to the Free Software
|
89 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
90 |
*
|
91 |
* For more information, contact:
|
92 |
*
|
93 |
* Generalitat Valenciana
|
94 |
* Conselleria d'Infraestructures i Transport
|
95 |
* Av. Blasco Ib??ez, 50
|
96 |
* 46010 VALENCIA
|
97 |
* SPAIN
|
98 |
*
|
99 |
* +34 963862235
|
100 |
* gvsig@gva.es
|
101 |
* www.gvsig.gva.es
|
102 |
*
|
103 |
* or
|
104 |
*
|
105 |
* IVER T.I. S.A
|
106 |
* Salamanca 50
|
107 |
* 46005 Valencia
|
108 |
* Spain
|
109 |
*
|
110 |
* +34 963163400
|
111 |
* dac@iver.es
|
112 |
*/
|
113 |
|
114 |
/**
|
115 |
* <p>Application for testing <code>JComboBoxLookUpConfigurable</code> objects.</p>
|
116 |
*
|
117 |
* <p>This class is a JPanel and has other classes nested.</p>
|
118 |
*
|
119 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
120 |
* @version 07/02/2008
|
121 |
*/
|
122 |
public class JPanelUserTestOfJComboBoxConfigurableLookUp extends JPanel implements Serializable { |
123 |
private static final long serialVersionUID = -8900802197326194647L; |
124 |
|
125 |
private final int panelWidth = 735; |
126 |
private final int panelHeight = 580; |
127 |
private final int testWidth = 260; |
128 |
private ConfigurationJPanel configurationPanel = null; |
129 |
private OtherTestsJPanel otherTestsPanel = null; |
130 |
private JavaFileMethodsLoader javaFileMethodsLoader;
|
131 |
private int testNumber; |
132 |
private String path; |
133 |
private boolean isConfiguring; |
134 |
|
135 |
private static final short DEFAULT_CELL_RENDERER = 0; |
136 |
private static final short SAMPLE_BG_COLOR_CELL_RENDERER = 1; |
137 |
|
138 |
/**
|
139 |
* <p>Default constructor.</p>
|
140 |
*/
|
141 |
public JPanelUserTestOfJComboBoxConfigurableLookUp() {
|
142 |
super();
|
143 |
this.initialize();
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* <p>Initializes the application pane.</p>
|
148 |
*/
|
149 |
private void initialize() { |
150 |
path = "src/org/gvsig/gui/beans/comboboxconfigurablelookup/JComboBoxConfigurableLookUp.java";
|
151 |
isConfiguring = false;
|
152 |
this.setPreferredSize(new Dimension(panelWidth, panelHeight)); |
153 |
this.setSize(new Dimension(panelWidth, panelHeight)); |
154 |
FlowLayout flowLayout = new FlowLayout(); |
155 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
156 |
this.setLayout(flowLayout);
|
157 |
this.add(this.getConfigurationPanel()); |
158 |
this.add(this.getOtherTestsPanel()); |
159 |
this.loadPublicMethods();
|
160 |
this.redirectDebugAndErrorMessages();
|
161 |
testNumber = 1;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* <p>Loads public methods of the <code>JComboBoxConfigurableLookUp</code> from its file class and adds the constructors to the
|
166 |
* inner <code>ConfigurationPanel</code> and the other methods to the <code>OtherTestsPanel</code>.</p>
|
167 |
*/
|
168 |
private void loadPublicMethods() { |
169 |
String methodHead;
|
170 |
String reservedWord = new String("public "); |
171 |
int reservedWordLength = reservedWord.length();
|
172 |
|
173 |
for (int i = 0; i < javaFileMethodsLoader.size(); i++) |
174 |
{ |
175 |
methodHead = javaFileMethodsLoader.getMethodHead(i); |
176 |
if (methodHead.startsWith(reservedWord))
|
177 |
{ |
178 |
if (methodHead.startsWith(reservedWord + javaFileMethodsLoader.getClassName()))
|
179 |
getConfigurationPanel().addConstructorItem(methodHead.substring(reservedWordLength, methodHead.length())); |
180 |
else
|
181 |
getOtherTestsPanel().addMethodItem(methodHead.substring(reservedWordLength, methodHead.length())); |
182 |
} |
183 |
} |
184 |
} |
185 |
|
186 |
/**
|
187 |
* <p>Redirects the default output and error stream to the inner log <code>JTextArea</code>.</p>
|
188 |
*/
|
189 |
private void redirectDebugAndErrorMessages() { |
190 |
// Now create a new TextAreaOutputStream to write to our JTextArea control and wrap a
|
191 |
// PrintStream around it to support the println/printf methods.
|
192 |
PrintStream out = new PrintStream( new TextAreaOutputStream( getOtherTestsPanel().getJTextAreaLog() ) ); |
193 |
|
194 |
// Redirect standard output stream to the TextAreaOutputStream
|
195 |
System.setOut( out );
|
196 |
|
197 |
// Redirect standard error stream to the TextAreaOutputStream
|
198 |
System.setErr( out );
|
199 |
} |
200 |
|
201 |
/**
|
202 |
* <p>This method initializes <code>configurationPanel</code>.</p>
|
203 |
*
|
204 |
* @return javax.swing.JComboBoxItemsSeekerConfigurableTestingByTheUserConfigurationPanel
|
205 |
*/
|
206 |
private ConfigurationJPanel getConfigurationPanel() {
|
207 |
if (configurationPanel == null) { |
208 |
configurationPanel = new ConfigurationJPanel();
|
209 |
configurationPanel.getJButtonNew().addMouseListener(new MouseAdapter() { |
210 |
/*
|
211 |
* (non-Javadoc)
|
212 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
213 |
*/
|
214 |
public void mouseClicked(MouseEvent arg0) { |
215 |
addNewTestObject(); |
216 |
} |
217 |
}); |
218 |
} |
219 |
|
220 |
return configurationPanel;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* <p>This method initializes <code>otherTestsPanel</code>.<p>
|
225 |
*
|
226 |
* @return javax.swing.JComboBoxItemsSeekerConfigurableTestingByTheUserOtherTestsPanel
|
227 |
*/
|
228 |
private OtherTestsJPanel getOtherTestsPanel() {
|
229 |
if (this.otherTestsPanel == null) |
230 |
this.otherTestsPanel = new OtherTestsJPanel(path); |
231 |
|
232 |
return this.otherTestsPanel; |
233 |
} |
234 |
|
235 |
/**
|
236 |
* <p>This method creates a JFrame with a new object for testing.</p>
|
237 |
* <p>This method also defines the closing methods and the name of the <code>JFrame</code>, and add the <code>JFrame</code> to the <code>OtherTestPanel</code>; that panel.
|
238 |
* will use it for do methods.</p>
|
239 |
*/
|
240 |
private void addNewTestObject() { |
241 |
JComboBoxConfigurableLookUp object = this.createComponent();
|
242 |
object.setPreferredSize(new Dimension(testWidth, object.getPreferredSize().height)); |
243 |
String keyAndTitle = Messages.getText("test") + " " + String.valueOf(testNumber++); |
244 |
|
245 |
JFrame jFrame = new JFrame(keyAndTitle); |
246 |
jFrame.getContentPane().add(object); |
247 |
jFrame.pack(); |
248 |
jFrame.setVisible(true);
|
249 |
|
250 |
// Centers the JFrame in the middle of the screen
|
251 |
jFrame.setLocationRelativeTo(null);
|
252 |
|
253 |
// Defines the methods that will have to do the JFrame when it would have to be closed
|
254 |
jFrame.addWindowListener(new WindowAdapter(){ |
255 |
|
256 |
/*
|
257 |
* (non-Javadoc)
|
258 |
* @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
|
259 |
*/
|
260 |
public void windowClosed(WindowEvent e) { |
261 |
// It's executen when the application closes the JFrame
|
262 |
getOtherTestsPanel().removeTestObject(((JFrame)e.getSource()).getTitle());
|
263 |
getOtherTestsPanel().getJTextAreaLog().append('(' + ((JFrame)e.getSource()).getTitle() + ", " + Messages.getText("elimination") + ")\n"); |
264 |
} |
265 |
|
266 |
/*
|
267 |
* (non-Javadoc)
|
268 |
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
|
269 |
*/
|
270 |
public void windowClosing(WindowEvent e) { |
271 |
// It's executen when the user closes the JFrame
|
272 |
getOtherTestsPanel().removeTestObject(((JFrame)e.getSource()).getTitle());
|
273 |
getOtherTestsPanel().getJTextAreaLog().append('(' + ((JFrame)e.getSource()).getTitle() + ", " + Messages.getText("elimination") + ")\n"); |
274 |
} |
275 |
}); |
276 |
|
277 |
this.getOtherTestsPanel().addTestObject(keyAndTitle, jFrame);
|
278 |
} |
279 |
|
280 |
|
281 |
/**
|
282 |
* <p>Obtains the configuration value for create the new object and creates it.</p>
|
283 |
*
|
284 |
* @return JComboBoxConfigurableLookUp The new object created
|
285 |
*/
|
286 |
private JComboBoxConfigurableLookUp createComponent() {
|
287 |
JComboBoxConfigurableLookUp comboBox = null;
|
288 |
String argument = ""; |
289 |
|
290 |
// ESTA PARTE CREA EL OBJETO, AVISA DE QUE EN CASO NECESARIO PONDR? UN PAR?METRO PREESTABLECIDO, Y ALMACENA EL TEXTO ACERCA
|
291 |
// DEL PAR?METRO QUE PONDR? LUEGO EN EL LOG
|
292 |
switch(getConfigurationPanel().getSelectedComboBoxConstructor()) {
|
293 |
case 0: |
294 |
comboBox = new JComboBoxConfigurableLookUp();
|
295 |
break;
|
296 |
case 1: |
297 |
JOptionPane.showMessageDialog(null, Messages.getText("will_use_a_default_model"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
298 |
DefaultComboBoxConfigurableLookUpModel model = new DefaultComboBoxConfigurableLookUpModel(new Object[] {"Item1", "Item2", "Item3", "Item4", "Item5"}); |
299 |
comboBox = new JComboBoxConfigurableLookUp(model);
|
300 |
argument = "model; ";
|
301 |
break;
|
302 |
case 2: |
303 |
JOptionPane.showMessageDialog(null, Messages.getText("will_use_a_default_array_of_items"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
304 |
comboBox = new JComboBoxConfigurableLookUp(new Object[] {"Item1", "Item2", "Item3", "Item4", "Item5"}); |
305 |
argument = "array; ";
|
306 |
break;
|
307 |
case 3: |
308 |
JOptionPane.showMessageDialog(null, Messages.getText("will_use_a_default_vector_of_items"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
309 |
Vector<Object> vector = new Vector<Object>(); |
310 |
vector.add("Item1");
|
311 |
vector.add("Item2");
|
312 |
vector.add("Item3");
|
313 |
vector.add("Item4");
|
314 |
vector.add("Item5");
|
315 |
comboBox = new JComboBoxConfigurableLookUp(vector);
|
316 |
argument = "vector; ";
|
317 |
break;
|
318 |
default:
|
319 |
comboBox = new JComboBoxConfigurableLookUp();
|
320 |
} |
321 |
|
322 |
DefaultComboBoxConfigurableLookUpModel model = (DefaultComboBoxConfigurableLookUpModel)comboBox.getModel(); |
323 |
String itemsOrderText = null; |
324 |
String languageRule = null; |
325 |
String cellRenderer = getConfigurationPanel().getSelectedComboBoxCellRenderer();
|
326 |
|
327 |
|
328 |
if (isConfiguring) {
|
329 |
comboBox.setOnlyOneColorOnText(getConfigurationPanel().isSelectedJCheckBoxOnlyOneColor()); |
330 |
comboBox.setBeepEnabled(getConfigurationPanel().isSelectedJCheckBoxBeepEnabled()); |
331 |
comboBox.setHidePopupIfThereAreNoItems(getConfigurationPanel().isSelectedJCheckBoxHidePopupIfThereAreNoItems()); |
332 |
comboBox.setToForceSelectAnItem(getConfigurationPanel().isSelectedJCheckBoxToForceSelectAnItem()); |
333 |
comboBox.setCompleteArrowKeySelection(getConfigurationPanel().isSelectedJCheckBoxCompleteArrowKeySelection()); |
334 |
comboBox.setDisplayAllItemsWithArrowButton(getConfigurationPanel().isSelectedJCheckBoxDisplayAllItemsWithArrowButton()); |
335 |
|
336 |
if (getConfigurationPanel().getSelectedComboBoxCellRendererIndex() == SAMPLE_BG_COLOR_CELL_RENDERER)
|
337 |
comboBox.setRenderer(new SampleBasicComboBoxRenderer());
|
338 |
|
339 |
// Configuration of the model
|
340 |
model.setItemsOrder(getConfigurationPanel().getSelectedComboBoxItemsOrder()); |
341 |
model.setShowAllItemsInListBox(getConfigurationPanel().isSelectedJCheckBoxShowAllItemsInListBox()); |
342 |
model.setLocaleRules(getConfigurationPanel().getSelectedComboBoxLanguageRuleText()); |
343 |
model.setCaseSensitive(getConfigurationPanel().isSelectedJCheckBoxCaseSensitive()); |
344 |
|
345 |
itemsOrderText = getConfigurationPanel().getSelectedComboBoxItemsOrderText(); |
346 |
languageRule = getConfigurationPanel().getSelectedComboBoxLanguageRuleText(); |
347 |
|
348 |
// Write the log
|
349 |
getOtherTestsPanel().getJTextAreaLog().append('(' + Messages.getText("test") + " " + String.valueOf(testNumber) + ", " + |
350 |
Messages.getText("creaction") + ": " + argument + Messages.getText("configuration") + ": " + getConfigurationPanel().isSelectedJCheckBoxOnlyOneColor() + ", " + |
351 |
getConfigurationPanel().isSelectedJCheckBoxBeepEnabled() + ", " + getConfigurationPanel().isSelectedJCheckBoxHidePopupIfThereAreNoItems() + ", " + |
352 |
getConfigurationPanel().isSelectedJCheckBoxToForceSelectAnItem() + ", " +
|
353 |
getConfigurationPanel().isSelectedJCheckBoxCompleteArrowKeySelection() + ", " +
|
354 |
getConfigurationPanel().isSelectedJCheckBoxDisplayAllItemsWithArrowButton() + ", " +
|
355 |
cellRenderer + ", " +
|
356 |
itemsOrderText + ", " +
|
357 |
getConfigurationPanel().isSelectedJCheckBoxShowAllItemsInListBox() + ", " + languageRule + ", " + |
358 |
getConfigurationPanel().isSelectedJCheckBoxCaseSensitive() + ")\n");
|
359 |
} |
360 |
else {
|
361 |
switch(model.getItemsOrder()) {
|
362 |
case DefaultComboBoxConfigurableLookUpModel.MAINTAIN_POSITION:
|
363 |
itemsOrderText = Messages.getText("maintain_position");
|
364 |
break;
|
365 |
case DefaultComboBoxConfigurableLookUpModel.ALPHABETICAL_ORDERED:
|
366 |
itemsOrderText = Messages.getText("alphabetical_ordered");
|
367 |
break;
|
368 |
case DefaultComboBoxConfigurableLookUpModel.MAINTAIN_AGENT_POSITIONS:
|
369 |
itemsOrderText = Messages.getText("agent_positions");
|
370 |
break;
|
371 |
} |
372 |
|
373 |
// Write the log
|
374 |
getOtherTestsPanel().getJTextAreaLog().append('(' + Messages.getText("test") + " " + String.valueOf(testNumber) + ", " + |
375 |
Messages.getText("creaction") + ": " + argument + Messages.getText("configuration") + ": " + comboBox.isOnlyOneColorOnText() + ", " + |
376 |
comboBox.isBeepEnabled() + ", " + comboBox.isHidePopupIfThereAreNoItems() + ", " + comboBox.isToForceSelectAnItem() + ", " + |
377 |
comboBox.isCompleteArrowKeySelection() + ", " + comboBox.isDisplayAllItemsWithArrowButton() + ", " + cellRenderer + ", " + |
378 |
itemsOrderText + ", " + model.isShowAllItemsInListBox() + ", " + model.getLocaleRules() + ", " + model.isCaseSensitive() + ")\n"); |
379 |
} |
380 |
|
381 |
return comboBox;
|
382 |
} |
383 |
|
384 |
/**
|
385 |
* <p>A JPanel for the configuration and create a new JComboBoxConfigurableLookUp for testing.</p>
|
386 |
*
|
387 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
388 |
*/
|
389 |
private class ConfigurationJPanel extends JPanel implements Serializable { |
390 |
private static final long serialVersionUID = 6327342028864667372L; |
391 |
|
392 |
private final int configurationPanelWidth = 310; |
393 |
private final int configurationPanelHeight = 570; |
394 |
private final int subPanelWidth = 280; |
395 |
private final int subPanelHeight = 28; |
396 |
private final int buttonWidth = 90; |
397 |
private final int buttonHeight = 20; |
398 |
private final int jComboBoxWidth = 160; |
399 |
private final int jComboBoxHeight = 20; |
400 |
private final int jPaneConfigurationParametersWidth = 296; |
401 |
private final int jPaneConfigurationParametersHeight = 440; |
402 |
private final int jPaneConstructorsWidth = jPaneConfigurationParametersWidth; |
403 |
private final int jPaneConstructorsHeight = 55; |
404 |
private final int jComboBoxConstructorsWidth = jPaneConfigurationParametersWidth - 10; |
405 |
private final int jComboBoxConstructorsHeight = jComboBoxHeight; |
406 |
private JCheckBox jCheckBoxOnlyOneColorOnText = null; |
407 |
private JCheckBox jCheckBoxBeepEnabled = null; |
408 |
private JCheckBox jCheckBoxHidePopupIfThereAreNoItems = null; |
409 |
private JCheckBox jCheckBoxToForceSelectAnItem = null; |
410 |
private JCheckBox jCheckBoxShowAllItemsInListBox = null; |
411 |
private JCheckBox jCheckBoxCaseSensitive = null; |
412 |
private JCheckBox jCheckBoxCompleteArrowKeySelection = null; |
413 |
private JCheckBox jCheckBoxDisplayAllItemsWithArrowButton = null; |
414 |
private JLabel jLabelOnlyOneColorOnText = null; |
415 |
private JLabel jLabelBeepEnabled = null; |
416 |
private JLabel jLabelHidePopupIfThereAreNoItems = null; |
417 |
private JLabel jLabelToForceSelectAnItem = null; |
418 |
private JLabel jLabelItemsOrder = null; |
419 |
private JLabel jLabelShowAllItemsInListBox = null; |
420 |
private JLabel jLabelLanguageRules = null; |
421 |
private JLabel jLabelCaseSensitive = null; |
422 |
private JLabel jLabelCompleteArrowKeySelection = null; |
423 |
private JLabel jLabelDisplayAllItemsWithArrowButton = null; |
424 |
private JLabel jLabelCellRenderer = null; |
425 |
private JButton jButtonReset = null; |
426 |
private JPanel jPaneConstructor = null; |
427 |
private JPanel jPaneConfigurationParameters = null; |
428 |
private JPanel jPaneOnlyOneColorOnText = null; |
429 |
private JPanel jPaneBeepEnabled = null; |
430 |
private JPanel jPaneHidePopupIfThereAreNoItems = null; |
431 |
private JPanel jPaneToForceSelectAnItem = null; |
432 |
private JPanel jPaneItemsOrder = null; |
433 |
private JPanel jPaneShowAllItemsInListBox = null; |
434 |
private JPanel jPaneLanguageRules = null; |
435 |
private JPanel jPaneCaseSensitive = null; |
436 |
private JPanel jPaneCompleteArrowKeySelection = null; |
437 |
private JPanel jPaneDisplayAllItemsWithArrowButton = null; |
438 |
private JPanel jPaneCellRenderer = null; |
439 |
private JPanel jPaneButtons = null; |
440 |
private JComboBox jComboBoxConstructors = null; |
441 |
private JComboBox jComboBoxItemsOrder = null; |
442 |
private JComboBox jComboBoxLanguageRules = null; |
443 |
private JComboBox jComboBoxCellRenderer = null; |
444 |
private JButton jButtonNew = null; |
445 |
private JButton jButtonEnableParametersConfiguration = null; |
446 |
private Object lastSelectedConstructor = null; |
447 |
|
448 |
/**
|
449 |
* <p>Default constructor.</p>
|
450 |
*/
|
451 |
public ConfigurationJPanel() {
|
452 |
super();
|
453 |
this.initialize();
|
454 |
} |
455 |
|
456 |
/**
|
457 |
* <p>Initializes this pane.</p>
|
458 |
*/
|
459 |
private void initialize() { |
460 |
this.setPreferredSize(new Dimension(configurationPanelWidth, configurationPanelHeight)); |
461 |
this.setSize(new Dimension(configurationPanelWidth, configurationPanelHeight)); |
462 |
this.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("objectsCreation"), TitledBorder.LEFT, TitledBorder.TOP, new Font("Dialog", Font.BOLD, 12), Color.black)); |
463 |
this.add(getJPaneConstructors(), null); |
464 |
this.add(getJPaneConfigurationParameters(), null); |
465 |
this.add(getJPaneButtons(), null); |
466 |
this.resetConfigurationPanel();
|
467 |
} |
468 |
|
469 |
/**
|
470 |
* <p>This method initializes <code>jCheckBoxOnlyOneColor</code>.</p>
|
471 |
*
|
472 |
* @return javax.swing.JCheckBox
|
473 |
*/
|
474 |
private JCheckBox getJCheckBoxOnlyOneColorOnText() { |
475 |
if (jCheckBoxOnlyOneColorOnText == null) { |
476 |
jCheckBoxOnlyOneColorOnText = new JCheckBox(); |
477 |
} |
478 |
return jCheckBoxOnlyOneColorOnText;
|
479 |
} |
480 |
|
481 |
/**
|
482 |
* <p>This method initializes <code>jCheckBoxBeepEnabled</code>.</p>
|
483 |
*
|
484 |
* @return javax.swing.JCheckBox
|
485 |
*/
|
486 |
private JCheckBox getJCheckBoxBeepEnabled() { |
487 |
if (jCheckBoxBeepEnabled == null) { |
488 |
jCheckBoxBeepEnabled = new JCheckBox(); |
489 |
} |
490 |
return jCheckBoxBeepEnabled;
|
491 |
} |
492 |
|
493 |
/**
|
494 |
* <p>This method initializes <code>jCheckBoxHidePopupIfThereAreNoItems</code>.</p>
|
495 |
*
|
496 |
* @return javax.swing.JCheckBox
|
497 |
*/
|
498 |
private JCheckBox getJCheckBoxHidePopupIfThereAreNoItems() { |
499 |
if (jCheckBoxHidePopupIfThereAreNoItems == null) { |
500 |
jCheckBoxHidePopupIfThereAreNoItems = new JCheckBox(); |
501 |
} |
502 |
return jCheckBoxHidePopupIfThereAreNoItems;
|
503 |
} |
504 |
|
505 |
/**
|
506 |
* <p>This method initializes <code>jCheckBoxToForceSelectAnItem</code>.</p>
|
507 |
*
|
508 |
* @return javax.swing.JCheckBox
|
509 |
*/
|
510 |
private JCheckBox getJCheckBoxToForceSelectAnItem() { |
511 |
if (jCheckBoxToForceSelectAnItem == null) { |
512 |
jCheckBoxToForceSelectAnItem = new JCheckBox(); |
513 |
} |
514 |
return jCheckBoxToForceSelectAnItem;
|
515 |
} |
516 |
|
517 |
/**
|
518 |
* <p>This method initializes <code>jCheckBoxShowAllItemsInListBox</code>.</p>
|
519 |
*
|
520 |
* @return javax.swing.JCheckBox
|
521 |
*/
|
522 |
private JCheckBox getJCheckBoxShowAllItemsInListBox() { |
523 |
if (jCheckBoxShowAllItemsInListBox == null) { |
524 |
jCheckBoxShowAllItemsInListBox = new JCheckBox(); |
525 |
} |
526 |
return jCheckBoxShowAllItemsInListBox;
|
527 |
} |
528 |
|
529 |
/**
|
530 |
* <p>This method initializes <code>jCheckBoxCaseSensitive</code>.</p>
|
531 |
*
|
532 |
* @return javax.swing.JCheckBox
|
533 |
*/
|
534 |
private JCheckBox getJCheckBoxCaseSensitive() { |
535 |
if (jCheckBoxCaseSensitive == null) { |
536 |
jCheckBoxCaseSensitive = new JCheckBox(); |
537 |
} |
538 |
return jCheckBoxCaseSensitive;
|
539 |
} |
540 |
|
541 |
/**
|
542 |
* <p>This method initializes <code>jCheckBoxCompleteArrowKeySelection</code>.</p>
|
543 |
*
|
544 |
* @return javax.swing.JCheckBox
|
545 |
*/
|
546 |
private JCheckBox getJCheckBoxCompleteArrowKeySelection() { |
547 |
if (jCheckBoxCompleteArrowKeySelection == null) { |
548 |
jCheckBoxCompleteArrowKeySelection = new JCheckBox(); |
549 |
} |
550 |
return jCheckBoxCompleteArrowKeySelection;
|
551 |
} |
552 |
|
553 |
/**
|
554 |
* <p>This method initializes <code>jCheckBoxDisplayAllItemsWithArrowButton</code>.</p>
|
555 |
*
|
556 |
* @return javax.swing.JCheckBox
|
557 |
*/
|
558 |
private JCheckBox getJCheckBoxDisplayAllItemsWithArrowButton() { |
559 |
if (jCheckBoxDisplayAllItemsWithArrowButton == null) { |
560 |
jCheckBoxDisplayAllItemsWithArrowButton = new JCheckBox(); |
561 |
} |
562 |
return jCheckBoxDisplayAllItemsWithArrowButton;
|
563 |
} |
564 |
|
565 |
/**
|
566 |
* @see JCheckBox#setSelected(boolean)
|
567 |
*/
|
568 |
public void setSelectedJCheckBoxOnlyOneColor(boolean b) { |
569 |
getJCheckBoxOnlyOneColorOnText().setSelected(b); |
570 |
} |
571 |
|
572 |
/**
|
573 |
* @see JCheckBox#setSelected(boolean)
|
574 |
*/
|
575 |
public void setSelectedJCheckBoxBeepEnabled(boolean b) { |
576 |
getJCheckBoxBeepEnabled().setSelected(b); |
577 |
} |
578 |
|
579 |
/**
|
580 |
* @see JCheckBox#setSelected(boolean)
|
581 |
*/
|
582 |
public void setSelectedJCheckBoxHidePopupIfThereAreNoItems(boolean b) { |
583 |
getJCheckBoxHidePopupIfThereAreNoItems().setSelected(b); |
584 |
} |
585 |
|
586 |
/**
|
587 |
* @see JCheckBox#setSelected(boolean)
|
588 |
*/
|
589 |
public void setSelectedJCheckBoxToForceSelectAnItem(boolean b) { |
590 |
getJCheckBoxToForceSelectAnItem().setSelected(b); |
591 |
} |
592 |
|
593 |
/**
|
594 |
* @see JCheckBox#setSelected(boolean)
|
595 |
*/
|
596 |
public void setSelectedJCheckShowAllItemsInListBox(boolean b) { |
597 |
getJCheckBoxShowAllItemsInListBox().setSelected(b); |
598 |
} |
599 |
|
600 |
/**
|
601 |
* @see JCheckBox#setSelected(boolean)
|
602 |
*/
|
603 |
public void setSelectedJCheckBoxCaseSensitive(boolean b) { |
604 |
jCheckBoxCaseSensitive.setSelected(b); |
605 |
} |
606 |
|
607 |
/**
|
608 |
* @see JCheckBox#setSelected(boolean)
|
609 |
*/
|
610 |
public void setSelectedJCheckBoxCompleteArrowKeySelection(boolean b) { |
611 |
jCheckBoxCompleteArrowKeySelection.setSelected(b); |
612 |
} |
613 |
|
614 |
/**
|
615 |
* @see JCheckBox#setSelected(boolean)
|
616 |
*/
|
617 |
public void setSelectedJCheckBoxDisplayAllItemsWithArrowButton(boolean b) { |
618 |
jCheckBoxDisplayAllItemsWithArrowButton.setSelected(b); |
619 |
} |
620 |
|
621 |
/**
|
622 |
* @see JCheckBox#isSelected()
|
623 |
*/
|
624 |
public boolean isSelectedJCheckBoxOnlyOneColor() { |
625 |
return getJCheckBoxOnlyOneColorOnText().isSelected();
|
626 |
} |
627 |
|
628 |
/**
|
629 |
* @see JCheckBox#isSelected()
|
630 |
*/
|
631 |
public boolean isSelectedJCheckBoxBeepEnabled() { |
632 |
return getJCheckBoxBeepEnabled().isSelected();
|
633 |
} |
634 |
|
635 |
/**
|
636 |
* @see JCheckBox#isSelected()
|
637 |
*/
|
638 |
public boolean isSelectedJCheckBoxHidePopupIfThereAreNoItems() { |
639 |
return getJCheckBoxHidePopupIfThereAreNoItems().isSelected();
|
640 |
} |
641 |
|
642 |
/**
|
643 |
* @see JCheckBox#isSelected()
|
644 |
*/
|
645 |
public boolean isSelectedJCheckBoxToForceSelectAnItem() { |
646 |
return getJCheckBoxToForceSelectAnItem().isSelected();
|
647 |
} |
648 |
|
649 |
/**
|
650 |
* @see JCheckBox#isSelected()
|
651 |
*/
|
652 |
public boolean isSelectedJCheckBoxShowAllItemsInListBox() { |
653 |
return getJCheckBoxShowAllItemsInListBox().isSelected();
|
654 |
} |
655 |
|
656 |
/**
|
657 |
* @see JCheckBox#isSelected()
|
658 |
*/
|
659 |
public boolean isSelectedJCheckBoxCaseSensitive() { |
660 |
return getJCheckBoxCaseSensitive().isSelected();
|
661 |
} |
662 |
|
663 |
/**
|
664 |
* @see JCheckBox#isSelected()
|
665 |
*/
|
666 |
public boolean isSelectedJCheckBoxCompleteArrowKeySelection() { |
667 |
return getJCheckBoxCompleteArrowKeySelection().isSelected();
|
668 |
} |
669 |
|
670 |
/**
|
671 |
* @see JCheckBox#isSelected()
|
672 |
*/
|
673 |
public boolean isSelectedJCheckBoxDisplayAllItemsWithArrowButton() { |
674 |
return getJCheckBoxDisplayAllItemsWithArrowButton().isSelected();
|
675 |
} |
676 |
|
677 |
/**
|
678 |
* <p>This method initializes <code>jButtonReset</code>.<p>
|
679 |
*
|
680 |
* @return javax.swing.JButton
|
681 |
*/
|
682 |
private JButton getJButtonReset() { |
683 |
if (jButtonReset == null) { |
684 |
jButtonReset = new JButton(); |
685 |
jButtonReset.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
686 |
jButtonReset.setText(Messages.getText("reset"));
|
687 |
jButtonReset.addMouseListener(new MouseAdapter() { |
688 |
/*
|
689 |
* (non-Javadoc)
|
690 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
691 |
*/
|
692 |
public void mouseClicked(MouseEvent arg0) { |
693 |
resetConfigurationPanel(); |
694 |
} |
695 |
}); |
696 |
} |
697 |
return jButtonReset;
|
698 |
} |
699 |
|
700 |
/**
|
701 |
* <p>This method initializes <code>jPaneConfigurationParameters</code>.</p>
|
702 |
*
|
703 |
* @return javax.swing.JPanel
|
704 |
*/
|
705 |
private JPanel getJPaneConfigurationParameters() { |
706 |
if (jPaneConfigurationParameters == null) { |
707 |
jPaneConfigurationParameters = new JPanel(); |
708 |
jPaneConfigurationParameters.setPreferredSize(new Dimension(jPaneConfigurationParametersWidth, jPaneConfigurationParametersHeight)); |
709 |
jPaneConfigurationParameters.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("configurationParameters"), TitledBorder.LEFT, TitledBorder.TOP, new Font("Dialog", Font.BOLD, 12), Color.black)); |
710 |
|
711 |
// Enable or disable the configuration of the parameters
|
712 |
jPaneConfigurationParameters.add(getJButtonEnableParametersConfiguration()); |
713 |
|
714 |
// Parameters of the JComboBoxLookUpConfigurable View and Control
|
715 |
jPaneConfigurationParameters.add(getJPaneOnlyOneColorOnText(), null);
|
716 |
jPaneConfigurationParameters.add(getJPaneBeepEnabled(), null);
|
717 |
jPaneConfigurationParameters.add(getJPaneHidePopupIfThereAreNoItems(), null);
|
718 |
jPaneConfigurationParameters.add(getJPaneToForceSelectAnItem(), null);
|
719 |
jPaneConfigurationParameters.add(getJPaneCompleteArrowKeySelection(), null);
|
720 |
jPaneConfigurationParameters.add(getJPaneDisplayAllItemsWithArrowButton(), null);
|
721 |
jPaneConfigurationParameters.add(getJPaneCellRenderer(), null);
|
722 |
|
723 |
// Parameters of the JComboBoxLookUpConfigurable Model
|
724 |
jPaneConfigurationParameters.add(getJPaneItemsOrder(), null);
|
725 |
jPaneConfigurationParameters.add(getJPaneShowAllItemsInListBox(), null);
|
726 |
jPaneConfigurationParameters.add(getJPaneLanguageRules(), null);
|
727 |
jPaneConfigurationParameters.add(getJPaneCaseSensitive(), null);
|
728 |
|
729 |
// By default don't change the default configuration
|
730 |
enableAllConfigurationComponents(false);
|
731 |
} |
732 |
return jPaneConfigurationParameters;
|
733 |
} |
734 |
|
735 |
/**
|
736 |
* <p>This method initializes <code>jLabelOnlyOneColorOnText</code>.</p>
|
737 |
*
|
738 |
* @return javax.swing.JLabel
|
739 |
*/
|
740 |
private JLabel getJLabelOnlyOneColorOnText() { |
741 |
if (jLabelOnlyOneColorOnText == null) { |
742 |
jLabelOnlyOneColorOnText = new JLabel(); |
743 |
jLabelOnlyOneColorOnText.setText(Messages.getText("onlyOneColorOnTextConfigurationLabel"));
|
744 |
jLabelOnlyOneColorOnText.addMouseListener(new MouseAdapter(){ |
745 |
/*
|
746 |
* (non-Javadoc)
|
747 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
748 |
*/
|
749 |
public void mouseClicked(MouseEvent arg0) { |
750 |
getJCheckBoxOnlyOneColorOnText().setSelected(!getJCheckBoxOnlyOneColorOnText().isSelected()); |
751 |
} |
752 |
}); |
753 |
} |
754 |
return jLabelOnlyOneColorOnText;
|
755 |
} |
756 |
|
757 |
/**
|
758 |
* <p>This method initializes <code>jLabelBeepEnabled</code>.</p>
|
759 |
*
|
760 |
* @return javax.swing.JLabel
|
761 |
*/
|
762 |
private JLabel getJLabelBeepEnabled() { |
763 |
if (jLabelBeepEnabled == null) { |
764 |
jLabelBeepEnabled = new JLabel(); |
765 |
jLabelBeepEnabled.setText(Messages.getText("beepConfigurationLabel"));
|
766 |
jLabelBeepEnabled.addMouseListener(new MouseAdapter(){ |
767 |
/*
|
768 |
* (non-Javadoc)
|
769 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
770 |
*/
|
771 |
public void mouseClicked(MouseEvent arg0) { |
772 |
getJCheckBoxBeepEnabled().setSelected(!getJCheckBoxBeepEnabled().isSelected()); |
773 |
} |
774 |
}); |
775 |
} |
776 |
return jLabelBeepEnabled;
|
777 |
} |
778 |
|
779 |
/**
|
780 |
* <p>This method initializes <code>jLabelHidePopupIfThereAreNoItems</code>.</p>
|
781 |
*
|
782 |
* @return javax.swing.JLabel
|
783 |
*/
|
784 |
private JLabel getJLabelHidePopupIfThereAreNoItems() { |
785 |
if (jLabelHidePopupIfThereAreNoItems == null) { |
786 |
jLabelHidePopupIfThereAreNoItems = new JLabel(); |
787 |
jLabelHidePopupIfThereAreNoItems.setText(Messages.getText("hidePopupIfThereAreNoItemsConfigurationLabel"));
|
788 |
jLabelHidePopupIfThereAreNoItems.addMouseListener(new MouseAdapter(){ |
789 |
/*
|
790 |
* (non-Javadoc)
|
791 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
792 |
*/
|
793 |
public void mouseClicked(MouseEvent arg0) { |
794 |
getJCheckBoxHidePopupIfThereAreNoItems().setSelected(!getJCheckBoxHidePopupIfThereAreNoItems().isSelected()); |
795 |
} |
796 |
}); |
797 |
} |
798 |
return jLabelHidePopupIfThereAreNoItems;
|
799 |
} |
800 |
|
801 |
/**
|
802 |
* <p>This method initializes <code>jLabelToForceSelectAnItem</code>.</p>
|
803 |
*
|
804 |
* @return javax.swing.JLabel
|
805 |
*/
|
806 |
private JLabel getJLabelToForceSelectAnItem() { |
807 |
if (jLabelToForceSelectAnItem == null) { |
808 |
jLabelToForceSelectAnItem = new JLabel(); |
809 |
jLabelToForceSelectAnItem.setText(Messages.getText("toForceSelectAnItemConfigurationLabel"));
|
810 |
jLabelToForceSelectAnItem.addMouseListener(new MouseAdapter(){ |
811 |
/*
|
812 |
* (non-Javadoc)
|
813 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
814 |
*/
|
815 |
public void mouseClicked(MouseEvent arg0) { |
816 |
getJCheckBoxToForceSelectAnItem().setSelected(!getJCheckBoxToForceSelectAnItem().isSelected()); |
817 |
} |
818 |
}); |
819 |
} |
820 |
return jLabelToForceSelectAnItem;
|
821 |
} |
822 |
|
823 |
/**
|
824 |
* <p>This method initializes <code>jLabelItemsOrder</code>.<p>
|
825 |
*
|
826 |
* @return javax.swing.JLabel
|
827 |
*/
|
828 |
private JLabel getJLabelItemsOrder() { |
829 |
if (jLabelItemsOrder == null) { |
830 |
jLabelItemsOrder = new JLabel(); |
831 |
jLabelItemsOrder.setText(Messages.getText("itemsOrderConfigurationLabel"));
|
832 |
} |
833 |
return jLabelItemsOrder;
|
834 |
} |
835 |
|
836 |
/**
|
837 |
* <p>This method initializes <code>jLabelShowAllItemsInListBox</code>.</p>
|
838 |
*
|
839 |
* @return javax.swing.JLabel
|
840 |
*/
|
841 |
private JLabel getJLabelShowAllItemsInListBox() { |
842 |
if (jLabelShowAllItemsInListBox == null) { |
843 |
jLabelShowAllItemsInListBox = new JLabel(); |
844 |
jLabelShowAllItemsInListBox.setText(Messages.getText("showAllItemsInListBoxConfigurationLabel"));
|
845 |
jLabelShowAllItemsInListBox.addMouseListener(new MouseAdapter(){ |
846 |
/*
|
847 |
* (non-Javadoc)
|
848 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
849 |
*/
|
850 |
public void mouseClicked(MouseEvent arg0) { |
851 |
getJCheckBoxShowAllItemsInListBox().setSelected(!getJCheckBoxShowAllItemsInListBox().isSelected()); |
852 |
} |
853 |
}); |
854 |
} |
855 |
return jLabelShowAllItemsInListBox;
|
856 |
} |
857 |
|
858 |
/**
|
859 |
* <p>This method initializes <code>jLabelLanguageRules</code>.</p>
|
860 |
*
|
861 |
* @return javax.swing.JLabel
|
862 |
*/
|
863 |
private JLabel getJLabelLanguageRules() { |
864 |
if (jLabelLanguageRules == null) { |
865 |
jLabelLanguageRules = new JLabel(); |
866 |
jLabelLanguageRules.setText(Messages.getText("languageRulesConfigurationLabel"));
|
867 |
} |
868 |
return jLabelLanguageRules;
|
869 |
} |
870 |
|
871 |
/**
|
872 |
* <p>This method initializes <code>jLabelCaseSensitive1</code>.</p>
|
873 |
*
|
874 |
* @return javax.swing.JLabel
|
875 |
*/
|
876 |
private JLabel getJLabelCaseSensitive() { |
877 |
if (jLabelCaseSensitive == null) { |
878 |
jLabelCaseSensitive = new JLabel(); |
879 |
jLabelCaseSensitive.setText(Messages.getText("caseSensitiveConfigurationLabel"));
|
880 |
jLabelCaseSensitive.addMouseListener(new MouseAdapter(){ |
881 |
/*
|
882 |
* (non-Javadoc)
|
883 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
884 |
*/
|
885 |
public void mouseClicked(MouseEvent arg0) { |
886 |
getJCheckBoxCaseSensitive().setSelected(!getJCheckBoxCaseSensitive().isSelected()); |
887 |
} |
888 |
}); |
889 |
} |
890 |
return jLabelCaseSensitive;
|
891 |
} |
892 |
|
893 |
|
894 |
/**
|
895 |
* <p>This method initializes <code>jLabelCompleteArrowKeySelection</code>.</p>
|
896 |
*
|
897 |
* @return javax.swing.JLabel
|
898 |
*/
|
899 |
private JLabel getJLabelCompleteArrowKeySelection() { |
900 |
if (jLabelCompleteArrowKeySelection == null) { |
901 |
jLabelCompleteArrowKeySelection = new JLabel(); |
902 |
jLabelCompleteArrowKeySelection.setText(Messages.getText("completeArrowKeySelectionConfigurationLabel"));
|
903 |
jLabelCompleteArrowKeySelection.addMouseListener(new MouseAdapter(){ |
904 |
/*
|
905 |
* (non-Javadoc)
|
906 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
907 |
*/
|
908 |
public void mouseClicked(MouseEvent arg0) { |
909 |
getJCheckBoxCompleteArrowKeySelection().setSelected(!getJCheckBoxCompleteArrowKeySelection().isSelected()); |
910 |
} |
911 |
}); |
912 |
} |
913 |
return jLabelCompleteArrowKeySelection;
|
914 |
} |
915 |
|
916 |
/**
|
917 |
* <p>This method initializes <code>jLabelDisplayAllItemsWithArrowButton</code>.</p>
|
918 |
*
|
919 |
* @return javax.swing.JLabel
|
920 |
*/
|
921 |
private JLabel getJLabelDisplayAllItemsWithArrowButton() { |
922 |
if (jLabelDisplayAllItemsWithArrowButton == null) { |
923 |
jLabelDisplayAllItemsWithArrowButton = new JLabel(); |
924 |
jLabelDisplayAllItemsWithArrowButton.setText(Messages.getText("displayAllItemsWithArrowButtonConfigurationLabel"));
|
925 |
jLabelDisplayAllItemsWithArrowButton.addMouseListener(new MouseAdapter(){ |
926 |
/*
|
927 |
* (non-Javadoc)
|
928 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
929 |
*/
|
930 |
public void mouseClicked(MouseEvent arg0) { |
931 |
getJCheckBoxDisplayAllItemsWithArrowButton().setSelected(!getJCheckBoxDisplayAllItemsWithArrowButton().isSelected()); |
932 |
} |
933 |
}); |
934 |
} |
935 |
return jLabelDisplayAllItemsWithArrowButton;
|
936 |
} |
937 |
|
938 |
/**
|
939 |
* <p>This method initializes <code>jLabelCellRenderer</code>.</p>
|
940 |
*
|
941 |
* @return javax.swing.JLabel
|
942 |
*/
|
943 |
private JLabel getJLabelCellRenderer() { |
944 |
if (jLabelCellRenderer == null) { |
945 |
jLabelCellRenderer = new JLabel(); |
946 |
jLabelCellRenderer.setText(Messages.getText("cellRendererConfigurationLabel"));
|
947 |
} |
948 |
return jLabelCellRenderer;
|
949 |
} |
950 |
|
951 |
/**
|
952 |
* <p>This method initializes <code>jPaneConstructor</code>.</p>
|
953 |
*
|
954 |
* @return javax.swing.JPanel
|
955 |
*/
|
956 |
private JPanel getJPaneConstructors() { |
957 |
if (jPaneConstructor == null) { |
958 |
jPaneConstructor = new JPanel(); |
959 |
jPaneConstructor.setPreferredSize(new Dimension(jPaneConstructorsWidth, jPaneConstructorsHeight)); |
960 |
jPaneConstructor.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("constructors"), TitledBorder.LEFT, TitledBorder.TOP, new Font("Dialog", Font.BOLD, 12), Color.black)); |
961 |
jPaneConstructor.add(getJComboBoxConstructors(), null);
|
962 |
} |
963 |
return jPaneConstructor;
|
964 |
} |
965 |
|
966 |
/**
|
967 |
* <p>This method initializes <code>jPaneOnlyOneColor</code>.</p>
|
968 |
*
|
969 |
* @return javax.swing.JPanel
|
970 |
*/
|
971 |
private JPanel getJPaneOnlyOneColorOnText() { |
972 |
if (jPaneOnlyOneColorOnText == null) { |
973 |
FlowLayout flowLayout = new FlowLayout(); |
974 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
975 |
jPaneOnlyOneColorOnText = new JPanel(); |
976 |
jPaneOnlyOneColorOnText.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
977 |
jPaneOnlyOneColorOnText.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
978 |
jPaneOnlyOneColorOnText.setLayout(flowLayout); |
979 |
jPaneOnlyOneColorOnText.add(getJCheckBoxOnlyOneColorOnText(), null);
|
980 |
jPaneOnlyOneColorOnText.add(getJLabelOnlyOneColorOnText(), null);
|
981 |
} |
982 |
return jPaneOnlyOneColorOnText;
|
983 |
} |
984 |
|
985 |
/**
|
986 |
* <p>This method initializes <code>jPaneBeepEnabled</code>.</p>
|
987 |
*
|
988 |
* @return javax.swing.JPanel
|
989 |
*/
|
990 |
private JPanel getJPaneBeepEnabled() { |
991 |
if (jPaneBeepEnabled == null) { |
992 |
FlowLayout flowLayout = new FlowLayout(); |
993 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
994 |
jPaneBeepEnabled = new JPanel(); |
995 |
jPaneBeepEnabled.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
996 |
jPaneBeepEnabled.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
997 |
jPaneBeepEnabled.setLayout(flowLayout); |
998 |
jPaneBeepEnabled.add(getJCheckBoxBeepEnabled(), null);
|
999 |
jPaneBeepEnabled.add(getJLabelBeepEnabled(), null);
|
1000 |
} |
1001 |
return jPaneBeepEnabled;
|
1002 |
} |
1003 |
|
1004 |
/**
|
1005 |
* <p>This method initializes <code>jPaneHidePopupIfThereAreNoItems</code>.</p>
|
1006 |
*
|
1007 |
* @return javax.swing.JPanel
|
1008 |
*/
|
1009 |
private JPanel getJPaneHidePopupIfThereAreNoItems() { |
1010 |
if (jPaneHidePopupIfThereAreNoItems == null) { |
1011 |
FlowLayout flowLayout = new FlowLayout(); |
1012 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1013 |
jPaneHidePopupIfThereAreNoItems = new JPanel(); |
1014 |
jPaneHidePopupIfThereAreNoItems.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1015 |
jPaneHidePopupIfThereAreNoItems.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1016 |
jPaneHidePopupIfThereAreNoItems.setLayout(flowLayout); |
1017 |
jPaneHidePopupIfThereAreNoItems.add(getJCheckBoxHidePopupIfThereAreNoItems(), null);
|
1018 |
jPaneHidePopupIfThereAreNoItems.add(getJLabelHidePopupIfThereAreNoItems(), null);
|
1019 |
} |
1020 |
return jPaneHidePopupIfThereAreNoItems;
|
1021 |
} |
1022 |
|
1023 |
/**
|
1024 |
* <p>This method initializes <code>jPaneToForceSelectAnItem</code>.</p>
|
1025 |
*
|
1026 |
* @return javax.swing.JPanel
|
1027 |
*/
|
1028 |
private JPanel getJPaneToForceSelectAnItem() { |
1029 |
if (jPaneToForceSelectAnItem == null) { |
1030 |
FlowLayout flowLayout = new FlowLayout(); |
1031 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1032 |
jPaneToForceSelectAnItem = new JPanel(); |
1033 |
jPaneToForceSelectAnItem.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1034 |
jPaneToForceSelectAnItem.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1035 |
jPaneToForceSelectAnItem.setLayout(flowLayout); |
1036 |
jPaneToForceSelectAnItem.add(getJCheckBoxToForceSelectAnItem(), null);
|
1037 |
jPaneToForceSelectAnItem.add(getJLabelToForceSelectAnItem(), null);
|
1038 |
} |
1039 |
return jPaneToForceSelectAnItem;
|
1040 |
} |
1041 |
|
1042 |
/**
|
1043 |
* <p>This method initializes <code>jPaneItemsOrder</code>.</p>
|
1044 |
*
|
1045 |
* @return javax.swing.JPanel
|
1046 |
*/
|
1047 |
private JPanel getJPaneItemsOrder() { |
1048 |
if (jPaneItemsOrder == null) { |
1049 |
FlowLayout flowLayout = new FlowLayout(); |
1050 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1051 |
jPaneItemsOrder = new JPanel(); |
1052 |
jPaneItemsOrder.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1053 |
jPaneItemsOrder.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1054 |
jPaneItemsOrder.setLayout(flowLayout); |
1055 |
jPaneItemsOrder.add(getJComboBoxItemsOrder(), null);
|
1056 |
jPaneItemsOrder.add(getJLabelItemsOrder(), null);
|
1057 |
} |
1058 |
return jPaneItemsOrder;
|
1059 |
} |
1060 |
|
1061 |
/**
|
1062 |
* <p>This method initializes <code>jPaneShowAllItemsInListBox</code>.</p>
|
1063 |
*
|
1064 |
* @return javax.swing.JPanel
|
1065 |
*/
|
1066 |
private JPanel getJPaneShowAllItemsInListBox() { |
1067 |
if (jPaneShowAllItemsInListBox == null) { |
1068 |
FlowLayout flowLayout = new FlowLayout(); |
1069 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1070 |
jPaneShowAllItemsInListBox = new JPanel(); |
1071 |
jPaneShowAllItemsInListBox.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1072 |
jPaneShowAllItemsInListBox.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1073 |
jPaneShowAllItemsInListBox.setLayout(flowLayout); |
1074 |
jPaneShowAllItemsInListBox.add(getJCheckBoxShowAllItemsInListBox(), null);
|
1075 |
jPaneShowAllItemsInListBox.add(getJLabelShowAllItemsInListBox(), null);
|
1076 |
} |
1077 |
return jPaneShowAllItemsInListBox;
|
1078 |
} |
1079 |
|
1080 |
/**
|
1081 |
* <p>This method initializes <code>jPaneLanguageRules</code>.</p>
|
1082 |
*
|
1083 |
* @return javax.swing.JPanel
|
1084 |
*/
|
1085 |
private JPanel getJPaneLanguageRules() { |
1086 |
if (jPaneLanguageRules == null) { |
1087 |
FlowLayout flowLayout = new FlowLayout(); |
1088 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1089 |
jPaneLanguageRules = new JPanel(); |
1090 |
jPaneLanguageRules.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1091 |
jPaneLanguageRules.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1092 |
jPaneLanguageRules.setLayout(flowLayout); |
1093 |
jPaneLanguageRules.add(getJComboBoxLanguageRules(), null);
|
1094 |
jPaneLanguageRules.add(getJLabelLanguageRules(), null);
|
1095 |
} |
1096 |
return jPaneLanguageRules;
|
1097 |
} |
1098 |
|
1099 |
/**
|
1100 |
* <p>This method initializes <code>jPaneCaseSensitive</code>.</p>
|
1101 |
*
|
1102 |
* @return javax.swing.JPanel
|
1103 |
*/
|
1104 |
private JPanel getJPaneCaseSensitive() { |
1105 |
if (jPaneCaseSensitive == null) { |
1106 |
FlowLayout flowLayout = new FlowLayout(); |
1107 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1108 |
jPaneCaseSensitive = new JPanel(); |
1109 |
jPaneCaseSensitive.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1110 |
jPaneCaseSensitive.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1111 |
jPaneCaseSensitive.setLayout(flowLayout); |
1112 |
jPaneCaseSensitive.add(getJCheckBoxCaseSensitive(), null);
|
1113 |
jPaneCaseSensitive.add(getJLabelCaseSensitive(), null);
|
1114 |
} |
1115 |
return jPaneCaseSensitive;
|
1116 |
} |
1117 |
|
1118 |
/**
|
1119 |
* <p>This method initializes <code>jPaneCompleteArrowKeySelection</code>.</p>
|
1120 |
*
|
1121 |
* @return javax.swing.JPanel
|
1122 |
*/
|
1123 |
private JPanel getJPaneCompleteArrowKeySelection() { |
1124 |
if (jPaneCompleteArrowKeySelection == null) { |
1125 |
FlowLayout flowLayout = new FlowLayout(); |
1126 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1127 |
jPaneCompleteArrowKeySelection = new JPanel(); |
1128 |
jPaneCompleteArrowKeySelection.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1129 |
jPaneCompleteArrowKeySelection.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1130 |
jPaneCompleteArrowKeySelection.setLayout(flowLayout); |
1131 |
jPaneCompleteArrowKeySelection.add(getJCheckBoxCompleteArrowKeySelection(), null);
|
1132 |
jPaneCompleteArrowKeySelection.add(getJLabelCompleteArrowKeySelection(), null);
|
1133 |
} |
1134 |
return jPaneCompleteArrowKeySelection;
|
1135 |
} |
1136 |
|
1137 |
/**
|
1138 |
* <p>This method initializes <code>jPaneDisplayAllItemsWithArrowButton</code>.</p>
|
1139 |
*
|
1140 |
* @return javax.swing.JPanel
|
1141 |
*/
|
1142 |
private JPanel getJPaneDisplayAllItemsWithArrowButton() { |
1143 |
if (jPaneDisplayAllItemsWithArrowButton == null) { |
1144 |
FlowLayout flowLayout = new FlowLayout(); |
1145 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1146 |
jPaneDisplayAllItemsWithArrowButton = new JPanel(); |
1147 |
jPaneDisplayAllItemsWithArrowButton.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1148 |
jPaneDisplayAllItemsWithArrowButton.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1149 |
jPaneDisplayAllItemsWithArrowButton.setLayout(flowLayout); |
1150 |
jPaneDisplayAllItemsWithArrowButton.add(getJCheckBoxDisplayAllItemsWithArrowButton(), null);
|
1151 |
jPaneDisplayAllItemsWithArrowButton.add(getJLabelDisplayAllItemsWithArrowButton(), null);
|
1152 |
} |
1153 |
return jPaneDisplayAllItemsWithArrowButton;
|
1154 |
} |
1155 |
|
1156 |
/**
|
1157 |
* <p>This method initializes <code>jPaneCellRenderer</code>.</p>
|
1158 |
*
|
1159 |
* @return javax.swing.JPanel
|
1160 |
*/
|
1161 |
private JPanel getJPaneCellRenderer() { |
1162 |
if (jPaneCellRenderer == null) { |
1163 |
FlowLayout flowLayout = new FlowLayout(); |
1164 |
flowLayout.setAlignment(FlowLayout.LEFT);
|
1165 |
jPaneCellRenderer = new JPanel(); |
1166 |
jPaneCellRenderer.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1167 |
jPaneCellRenderer.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1168 |
jPaneCellRenderer.setLayout(flowLayout); |
1169 |
jPaneCellRenderer.add(getJComboBoxCellRenderer(), null);
|
1170 |
jPaneCellRenderer.add(getJLabelCellRenderer(), null);
|
1171 |
} |
1172 |
return jPaneCellRenderer;
|
1173 |
} |
1174 |
|
1175 |
/**
|
1176 |
* <p>This method initializes <code>jPaneButtons</code>.</p>
|
1177 |
*
|
1178 |
* @return javax.swing.JPanel
|
1179 |
*/
|
1180 |
private JPanel getJPaneButtons() { |
1181 |
if (jPaneButtons == null) { |
1182 |
FlowLayout flowLayout = new FlowLayout(); |
1183 |
flowLayout.setAlignment(FlowLayout.RIGHT);
|
1184 |
jPaneButtons = new JPanel(); |
1185 |
jPaneButtons.setPreferredSize(new Dimension(subPanelWidth, subPanelHeight)); |
1186 |
jPaneButtons.setLayout(flowLayout); |
1187 |
jPaneButtons.add(getJButtonReset(), null);
|
1188 |
jPaneButtons.add(getJButtonNew(), null);
|
1189 |
} |
1190 |
return jPaneButtons;
|
1191 |
} |
1192 |
|
1193 |
/**
|
1194 |
* <p>This method initializes <code>jComboBoxConstructors</code>.</p>
|
1195 |
*
|
1196 |
* @return javax.swing.JComboBox
|
1197 |
*/
|
1198 |
private JComboBox getJComboBoxConstructors() { |
1199 |
if (jComboBoxConstructors == null) { |
1200 |
jComboBoxConstructors = new JComboBox(); |
1201 |
jComboBoxConstructors.setEditable(false);
|
1202 |
jComboBoxConstructors.setPreferredSize(new Dimension(jComboBoxConstructorsWidth, jComboBoxConstructorsHeight)); |
1203 |
|
1204 |
jComboBoxConstructors.getModel().addListDataListener(new ListDataListener() { |
1205 |
/*
|
1206 |
* (non-Javadoc)
|
1207 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
1208 |
*/
|
1209 |
public void contentsChanged(ListDataEvent e) { |
1210 |
Object item = jComboBoxConstructors.getSelectedItem();
|
1211 |
|
1212 |
if (item != null) |
1213 |
jComboBoxConstructors.setToolTipText(item.toString()); |
1214 |
} |
1215 |
|
1216 |
/*
|
1217 |
* (non-Javadoc)
|
1218 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
1219 |
*/
|
1220 |
public void intervalAdded(ListDataEvent e) { |
1221 |
} |
1222 |
|
1223 |
/*
|
1224 |
* (non-Javadoc)
|
1225 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
1226 |
*/
|
1227 |
public void intervalRemoved(ListDataEvent e) { |
1228 |
} |
1229 |
}); |
1230 |
|
1231 |
jComboBoxConstructors.addPopupMenuListener(new PopupMenuListener() { |
1232 |
/*
|
1233 |
* (non-Javadoc)
|
1234 |
* @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent)
|
1235 |
*/
|
1236 |
public void popupMenuCanceled(PopupMenuEvent e) { |
1237 |
} |
1238 |
|
1239 |
/*
|
1240 |
* (non-Javadoc)
|
1241 |
* @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent)
|
1242 |
*/
|
1243 |
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
1244 |
} |
1245 |
|
1246 |
/*
|
1247 |
* (non-Javadoc)
|
1248 |
* @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
|
1249 |
*/
|
1250 |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
1251 |
lastSelectedConstructor = jComboBoxConstructors.getSelectedItem(); |
1252 |
} |
1253 |
}); |
1254 |
} |
1255 |
return jComboBoxConstructors;
|
1256 |
} |
1257 |
|
1258 |
/**
|
1259 |
* <p>This method initializes <code>jComboBoxItemsOrder</code>.</p>
|
1260 |
*
|
1261 |
* @return javax.swing.JComboBox
|
1262 |
*/
|
1263 |
private JComboBox getJComboBoxItemsOrder() { |
1264 |
if (jComboBoxItemsOrder == null) { |
1265 |
jComboBoxItemsOrder = new JComboBox(); |
1266 |
jComboBoxItemsOrder.setEditable(false);
|
1267 |
jComboBoxItemsOrder.setPreferredSize(new Dimension(jComboBoxWidth, jComboBoxHeight)); |
1268 |
|
1269 |
jComboBoxItemsOrder.getModel().addListDataListener(new ListDataListener() { |
1270 |
/*
|
1271 |
* (non-Javadoc)
|
1272 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
1273 |
*/
|
1274 |
public void contentsChanged(ListDataEvent e) { |
1275 |
Object item = jComboBoxItemsOrder.getSelectedItem();
|
1276 |
|
1277 |
if (item != null) |
1278 |
jComboBoxItemsOrder.setToolTipText(item.toString()); |
1279 |
} |
1280 |
|
1281 |
/*
|
1282 |
* (non-Javadoc)
|
1283 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
1284 |
*/
|
1285 |
public void intervalAdded(ListDataEvent e) { |
1286 |
} |
1287 |
|
1288 |
/*
|
1289 |
* (non-Javadoc)
|
1290 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
1291 |
*/
|
1292 |
public void intervalRemoved(ListDataEvent e) { |
1293 |
} |
1294 |
}); |
1295 |
|
1296 |
jComboBoxItemsOrder.addItem(Messages.getText("maintain_position"));
|
1297 |
jComboBoxItemsOrder.addItem(Messages.getText("alphabetical_ordered"));
|
1298 |
jComboBoxItemsOrder.addItem(Messages.getText("disordered"));
|
1299 |
} |
1300 |
|
1301 |
return jComboBoxItemsOrder;
|
1302 |
} |
1303 |
|
1304 |
/**
|
1305 |
* <p>This method initializes <code>jComboBoxLanguageRules</code>.</p>
|
1306 |
*
|
1307 |
* @return javax.swing.JComboBox
|
1308 |
*/
|
1309 |
private JComboBox getJComboBoxLanguageRules() { |
1310 |
if (jComboBoxLanguageRules == null) { |
1311 |
jComboBoxLanguageRules = new JComboBox(); |
1312 |
jComboBoxLanguageRules.setEditable(false);
|
1313 |
jComboBoxLanguageRules.setPreferredSize(new Dimension(jComboBoxWidth, jComboBoxHeight)); |
1314 |
|
1315 |
jComboBoxLanguageRules.getModel().addListDataListener(new ListDataListener() { |
1316 |
/*
|
1317 |
* (non-Javadoc)
|
1318 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
1319 |
*/
|
1320 |
public void contentsChanged(ListDataEvent e) { |
1321 |
Object item = jComboBoxLanguageRules.getSelectedItem();
|
1322 |
|
1323 |
if (item != null) |
1324 |
jComboBoxLanguageRules.setToolTipText(item.toString()); |
1325 |
} |
1326 |
|
1327 |
/*
|
1328 |
* (non-Javadoc)
|
1329 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
1330 |
*/
|
1331 |
public void intervalAdded(ListDataEvent e) { |
1332 |
} |
1333 |
|
1334 |
/*
|
1335 |
* (non-Javadoc)
|
1336 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
1337 |
*/
|
1338 |
public void intervalRemoved(ListDataEvent e) { |
1339 |
} |
1340 |
}); |
1341 |
|
1342 |
jComboBoxLanguageRules.addItem("es_ES");
|
1343 |
jComboBoxLanguageRules.addItem("en_US");
|
1344 |
jComboBoxLanguageRules.addItem("fr_FR");
|
1345 |
} |
1346 |
|
1347 |
return jComboBoxLanguageRules;
|
1348 |
} |
1349 |
|
1350 |
|
1351 |
/**
|
1352 |
* <p>This method initializes <code>jComboBoxCellRenderer</code>.</p>
|
1353 |
*
|
1354 |
* @return javax.swing.JCheckBox
|
1355 |
*/
|
1356 |
private JComboBox getJComboBoxCellRenderer() { |
1357 |
if (jComboBoxCellRenderer == null) { |
1358 |
jComboBoxCellRenderer = new JComboBox(); |
1359 |
jComboBoxCellRenderer.setEditable(false);
|
1360 |
jComboBoxCellRenderer.setPreferredSize(new Dimension(jComboBoxWidth, jComboBoxHeight)); |
1361 |
|
1362 |
jComboBoxCellRenderer.getModel().addListDataListener(new ListDataListener() { |
1363 |
/*
|
1364 |
* (non-Javadoc)
|
1365 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
1366 |
*/
|
1367 |
public void contentsChanged(ListDataEvent e) { |
1368 |
Object item = jComboBoxCellRenderer.getSelectedItem();
|
1369 |
|
1370 |
if (item != null) |
1371 |
jComboBoxCellRenderer.setToolTipText(item.toString()); |
1372 |
} |
1373 |
|
1374 |
/*
|
1375 |
* (non-Javadoc)
|
1376 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
1377 |
*/
|
1378 |
public void intervalAdded(ListDataEvent e) { |
1379 |
} |
1380 |
|
1381 |
/*
|
1382 |
* (non-Javadoc)
|
1383 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
1384 |
*/
|
1385 |
public void intervalRemoved(ListDataEvent e) { |
1386 |
} |
1387 |
}); |
1388 |
|
1389 |
jComboBoxCellRenderer.addItem("Default");
|
1390 |
jComboBoxCellRenderer.addItem("Sample_BG_Color");
|
1391 |
} |
1392 |
|
1393 |
return jComboBoxCellRenderer;
|
1394 |
} |
1395 |
|
1396 |
/**
|
1397 |
* <p>Adds a constructor item to <code>jComboBoxConstructors</code>, and if it`s needed configures the configuration options of this JPanel.</p>
|
1398 |
*
|
1399 |
* @param name Constructor name
|
1400 |
*/
|
1401 |
public void addConstructorItem(String name) { |
1402 |
this.jComboBoxConstructors.addItem(name);
|
1403 |
|
1404 |
// Displays description of the first item added by default
|
1405 |
if (this.lastSelectedConstructor == null) |
1406 |
{ |
1407 |
this.lastSelectedConstructor = getJComboBoxConstructors().getSelectedItem();
|
1408 |
} |
1409 |
} |
1410 |
|
1411 |
/**
|
1412 |
* @see JComboBox#getSelectedIndex()
|
1413 |
*/
|
1414 |
public int getSelectedComboBoxItemsOrder() { |
1415 |
return jComboBoxItemsOrder.getSelectedIndex();
|
1416 |
} |
1417 |
|
1418 |
/**
|
1419 |
* @see JComboBox#setSelectedIndex(int)
|
1420 |
*/
|
1421 |
public void setSelectedComboBoxItemsOrder(int index) { |
1422 |
jComboBoxItemsOrder.setSelectedIndex(index); |
1423 |
} |
1424 |
|
1425 |
/**
|
1426 |
* @see JComboBox#getSelectedIndex()
|
1427 |
*/
|
1428 |
public int getSelectedComboBoxLanguageRules() { |
1429 |
return jComboBoxLanguageRules.getSelectedIndex();
|
1430 |
} |
1431 |
|
1432 |
/**
|
1433 |
* @see JComboBox#setSelectedIndex(int)
|
1434 |
*/
|
1435 |
public void setSelectedComboBoxLanguageRules(int index) { |
1436 |
jComboBoxLanguageRules.setSelectedIndex(index); |
1437 |
} |
1438 |
|
1439 |
/**
|
1440 |
* <p>Gets the selected cell renderer.</p>
|
1441 |
*
|
1442 |
* @return the selected cell renderer index
|
1443 |
*/
|
1444 |
public int getSelectedComboBoxCellRendererIndex() { |
1445 |
return jComboBoxCellRenderer.getSelectedIndex();
|
1446 |
} |
1447 |
|
1448 |
/**
|
1449 |
* @see JComboBox#getSelectedIndex()
|
1450 |
*/
|
1451 |
public int getSelectedComboBoxConstructor() { |
1452 |
return jComboBoxConstructors.getSelectedIndex();
|
1453 |
} |
1454 |
|
1455 |
/**
|
1456 |
* <p>Gets an string that identifies the selected items order.</p>
|
1457 |
*
|
1458 |
* @return text that identifies the selected items order
|
1459 |
*/
|
1460 |
public String getSelectedComboBoxItemsOrderText() { |
1461 |
return jComboBoxItemsOrder.getSelectedItem().toString();
|
1462 |
} |
1463 |
|
1464 |
/**
|
1465 |
* <p>Gets an string that identifies the selected language rule.</p>
|
1466 |
*
|
1467 |
* @return text that identifies the selected language rule
|
1468 |
*/
|
1469 |
public String getSelectedComboBoxLanguageRuleText() { |
1470 |
return jComboBoxLanguageRules.getSelectedItem().toString();
|
1471 |
} |
1472 |
|
1473 |
/**
|
1474 |
* <p>Gets an string that identifies the selected cell renderer.</p>
|
1475 |
*
|
1476 |
* @return text that identifies the selected cell renderer
|
1477 |
*/
|
1478 |
public String getSelectedComboBoxCellRenderer() { |
1479 |
return jComboBoxCellRenderer.getSelectedItem().toString();
|
1480 |
} |
1481 |
|
1482 |
/**
|
1483 |
* <p>This method initializes <code>jButtonNew</code>.</p>
|
1484 |
*
|
1485 |
* @return javax.swing.JButton
|
1486 |
*/
|
1487 |
private JButton getJButtonNew() { |
1488 |
if (jButtonNew == null) { |
1489 |
jButtonNew = new JButton(); |
1490 |
jButtonNew.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
1491 |
jButtonNew.setText(Messages.getText("new"));
|
1492 |
} |
1493 |
return jButtonNew;
|
1494 |
} |
1495 |
|
1496 |
/**
|
1497 |
* <p>This method initializes <code>jButtonEnableParametersConfiguration</code>.</p>
|
1498 |
*
|
1499 |
* @return javax.swing.JButton
|
1500 |
*/
|
1501 |
private JButton getJButtonEnableParametersConfiguration() { |
1502 |
if (jButtonEnableParametersConfiguration == null) { |
1503 |
jButtonEnableParametersConfiguration = new JButton(); |
1504 |
jButtonEnableParametersConfiguration.setPreferredSize(new Dimension(subPanelWidth, buttonHeight)); |
1505 |
jButtonEnableParametersConfiguration.setText(Messages.getText("configure"));
|
1506 |
|
1507 |
jButtonEnableParametersConfiguration.addMouseListener(new MouseAdapter() { |
1508 |
/*
|
1509 |
* (non-Javadoc)
|
1510 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
1511 |
*/
|
1512 |
public void mouseClicked(MouseEvent e) { |
1513 |
if (getJComboBoxConstructors().getItemCount() == 0) { |
1514 |
JOptionPane.showMessageDialog(null, Messages.getText("cant_configure_parameters"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
1515 |
return;
|
1516 |
} |
1517 |
|
1518 |
isConfiguring = !isConfiguring; |
1519 |
|
1520 |
enableAllConfigurationComponents(isConfiguring); |
1521 |
} |
1522 |
}); |
1523 |
} |
1524 |
return jButtonEnableParametersConfiguration;
|
1525 |
} |
1526 |
|
1527 |
/**
|
1528 |
* <p>Sets all configuration components enabled or disabled according the value of the parameter.</p>
|
1529 |
*
|
1530 |
* @param b a boolean value
|
1531 |
*/
|
1532 |
private void enableAllConfigurationComponents(boolean b) { |
1533 |
getJLabelOnlyOneColorOnText().setEnabled(b); |
1534 |
getJCheckBoxOnlyOneColorOnText().setEnabled(b); |
1535 |
|
1536 |
getJLabelBeepEnabled().setEnabled(b); |
1537 |
getJCheckBoxBeepEnabled().setEnabled(b); |
1538 |
|
1539 |
getJLabelHidePopupIfThereAreNoItems().setEnabled(b); |
1540 |
getJCheckBoxHidePopupIfThereAreNoItems().setEnabled(b); |
1541 |
|
1542 |
getJLabelToForceSelectAnItem().setEnabled(b); |
1543 |
getJCheckBoxToForceSelectAnItem().setEnabled(b); |
1544 |
|
1545 |
getJLabelCompleteArrowKeySelection().setEnabled(b); |
1546 |
getJCheckBoxCompleteArrowKeySelection().setEnabled(b); |
1547 |
|
1548 |
getJLabelDisplayAllItemsWithArrowButton().setEnabled(b); |
1549 |
getJCheckBoxDisplayAllItemsWithArrowButton().setEnabled(b); |
1550 |
|
1551 |
getJLabelCellRenderer().setEnabled(b); |
1552 |
getJComboBoxCellRenderer().setEnabled(b); |
1553 |
|
1554 |
getJLabelItemsOrder().setEnabled(b); |
1555 |
getJComboBoxItemsOrder().setEnabled(b); |
1556 |
|
1557 |
getJLabelShowAllItemsInListBox().setEnabled(b); |
1558 |
getJCheckBoxShowAllItemsInListBox().setEnabled(b); |
1559 |
|
1560 |
getJLabelLanguageRules().setEnabled(b); |
1561 |
getJComboBoxLanguageRules().setEnabled(b); |
1562 |
|
1563 |
getJLabelCaseSensitive().setEnabled(b); |
1564 |
getJCheckBoxCaseSensitive().setEnabled(b); |
1565 |
} |
1566 |
|
1567 |
/**
|
1568 |
* <p>Reset the configuration options of this pane to their default value.</p>
|
1569 |
*/
|
1570 |
private void resetConfigurationPanel() { |
1571 |
isConfiguring = false;
|
1572 |
|
1573 |
// JComboBoxConstructors (The constructor selected)
|
1574 |
if (getJComboBoxConstructors().getItemCount() > 0) |
1575 |
getJComboBoxConstructors().setSelectedIndex(0);
|
1576 |
else
|
1577 |
getJComboBoxConstructors().setSelectedIndex(-1);
|
1578 |
|
1579 |
|
1580 |
// Disable all options
|
1581 |
enableAllConfigurationComponents(false);
|
1582 |
|
1583 |
// Only One Color
|
1584 |
getJCheckBoxOnlyOneColorOnText().setSelected(JComboBoxConfigurableLookUp.DEFAULT_ONLY_ONE_COLOR_ON_TEXT_CONFIGURATION); |
1585 |
|
1586 |
// Beep Enabled
|
1587 |
getJCheckBoxBeepEnabled().setSelected(JComboBoxConfigurableLookUp.DEFAULT_BEEP_ENABLED_CONFIGURATION); |
1588 |
|
1589 |
// Hide Popup If There Are No Items
|
1590 |
getJCheckBoxHidePopupIfThereAreNoItems().setSelected(JComboBoxConfigurableLookUp.DEFAULT_HIDE_POPUP_IF_THERE_ARE_NO_ITEMS_CONFIGURATION); |
1591 |
|
1592 |
// To Force Select An Item
|
1593 |
getJCheckBoxToForceSelectAnItem().setSelected(JComboBoxConfigurableLookUp.DEFAULT_TO_FORCE_SELECT_AN_ITEM_CONFIGURATION); |
1594 |
|
1595 |
// Complete Arrow Key Selection
|
1596 |
getJCheckBoxCompleteArrowKeySelection().setSelected(JComboBoxConfigurableLookUp.DEFAULT_COMPLETE_ARROW_KEY_SELECTION_CONFIGURATION); |
1597 |
|
1598 |
// Display All Items With Arrow Button
|
1599 |
getJCheckBoxDisplayAllItemsWithArrowButton().setSelected(JComboBoxConfigurableLookUp.DEFAULT_DISPLAY_ALL_ITEMS_WITH_ARROW_BUTTON_CONFIGURATION); |
1600 |
|
1601 |
// Cell Renderer -> the default (that's a the position 0)
|
1602 |
getJComboBoxCellRenderer().setSelectedIndex(DEFAULT_CELL_RENDERER); |
1603 |
|
1604 |
// Items order
|
1605 |
getJComboBoxItemsOrder().setSelectedIndex(DefaultComboBoxConfigurableLookUpModel.DEFAULT_ITEMS_ORDER_CONFIGURATION); |
1606 |
|
1607 |
// Show all items in list box
|
1608 |
getJCheckBoxShowAllItemsInListBox().setSelected(DefaultComboBoxConfigurableLookUpModel.DEFAULT_SHOW_ALL_ITEMS_IN_LIST_BOX_CONFIGURATION); |
1609 |
|
1610 |
// Language rules
|
1611 |
getJComboBoxLanguageRules().setSelectedIndex(0); // es_ES |
1612 |
|
1613 |
// Case Sensitive
|
1614 |
getJCheckBoxCaseSensitive().setSelected(DefaultComboBoxConfigurableLookUpModel.DEFAULT_CASE_SENSITIVE_CONFIGURATION); |
1615 |
} |
1616 |
} |
1617 |
|
1618 |
|
1619 |
/**
|
1620 |
* <p>A <code>JPanel</code> for the configuration and create a new JComboBoxLookUpConfigurable for testing.</p>
|
1621 |
*
|
1622 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
1623 |
*/
|
1624 |
private class OtherTestsJPanel extends JPanel implements Serializable { |
1625 |
private static final long serialVersionUID = 402109040183526786L; |
1626 |
|
1627 |
private final int panelWidth = 410; |
1628 |
private final int panelHeight = 570; |
1629 |
private final int buttonWidth = 90; |
1630 |
private final int buttonHeight = 20; |
1631 |
private final int methodsPanelWidth = 390; |
1632 |
private final int methodsPanelHeight = 60; |
1633 |
private final int otherUtilitiesJTabbedPaneWidth = methodsPanelWidth; |
1634 |
private final int otherUtilitiesJTabbedPaneHeight = 435; |
1635 |
private final int columnsOfJTextAreaDescriptionInstructions = 34; |
1636 |
private final int rowsOfJTextAreaDescriptionInstructions = 22; |
1637 |
private final int jScrollPaneIncrementConstant = 10; |
1638 |
private final int jLabelWidth = 70; |
1639 |
private final int jLabelHeight = buttonHeight; |
1640 |
private final int parametersTextFieldWidth = methodsPanelWidth - jLabelWidth - 25; // -25 for the margins |
1641 |
private final int parametersTextFieldHeight = 20; |
1642 |
private final int buttonsPanelHeight = 30; |
1643 |
private final int buttonsPanelWidth = methodsPanelWidth; |
1644 |
private final int jComboBoxWidth = 180; |
1645 |
private final int jComboBoxHeigth = 20; |
1646 |
private JComboBox jComboBoxMethods = null; |
1647 |
private JTextField jTextField = null; |
1648 |
private JButton jButtonTest = null; |
1649 |
private JLabel jLabelMethod = null; |
1650 |
private JPanel jPanelMethods = null; |
1651 |
private JLabel jLabelComponents = null; |
1652 |
private JLabel jLabelParameters = null; |
1653 |
private JComboBox jComboBoxTestObjects = null; |
1654 |
private JTextArea jTextAreaDescriptionInstructions = null; |
1655 |
private JButton jButtonReset = null; |
1656 |
private JPanel jPanelButtons = null; |
1657 |
private Vector<Object> methods = null; |
1658 |
private Object lastSelectedMethod = null; |
1659 |
private Vector<Object> currentMethodTypes = null; |
1660 |
private JScrollPane jScrollPaneDescriptionInstructions = null; |
1661 |
String textHelp;
|
1662 |
private String globalHelp; |
1663 |
private Map<Object, Object> testObjects; |
1664 |
private JButton jButtonFill = null; |
1665 |
private JButton jButtonOtherTestsHelp = null; |
1666 |
private JTabbedPane jTabbedPaneOtherUtilities = null; |
1667 |
private JScrollPane jScrollPaneLog = null; |
1668 |
private JTextArea jTextAreaLog = null; |
1669 |
|
1670 |
/**
|
1671 |
* <p>Default constructor without parameters.</p>
|
1672 |
*/
|
1673 |
public OtherTestsJPanel() {
|
1674 |
super();
|
1675 |
} |
1676 |
|
1677 |
/**
|
1678 |
* <p>Default constructor with 1 parameter.</p>
|
1679 |
*/
|
1680 |
public OtherTestsJPanel(String path) { |
1681 |
super();
|
1682 |
javaFileMethodsLoader = new JavaFileMethodsLoader(path);
|
1683 |
this.initialize();
|
1684 |
} |
1685 |
|
1686 |
/**
|
1687 |
* <p>Initializes this pane.</p>
|
1688 |
*/
|
1689 |
private void initialize() { |
1690 |
this.setPreferredSize(new Dimension(panelWidth, panelHeight)); |
1691 |
this.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("proofs"), TitledBorder.LEFT, TitledBorder.TOP, new Font("Dialog", Font.BOLD, 12), Color.black)); |
1692 |
this.setSize(new Dimension(panelWidth, panelHeight)); |
1693 |
this.testObjects = new HashMap<Object, Object>(); |
1694 |
|
1695 |
this.add(getJPanelMethods(), null); |
1696 |
this.add(getJTabbedPaneOtherUtilities(), null); |
1697 |
this.add(getJPaneButtons(), null); |
1698 |
textHelp = new String("AYUDA CON LOS PAR?METROS:\n\n" + |
1699 |
"Se permiten 5 tipos de par?metros:\n" +
|
1700 |
" - Entero (int) (Ejemplo: 24)\n" +
|
1701 |
" - Real corto (float) (Ejemplo: 2.5)\n" +
|
1702 |
" - Real largo (double) (Ejemplo: 2.56869479346)\n" +
|
1703 |
" - Booleano (boolean) (Ejemplo valor true: T) (Ejemplo valor false: F)\n" +
|
1704 |
" - Cadena de caracteres (String) (Se deben usar comillas dobles) (Ejemplo: \"La casa.\")\n" +
|
1705 |
" - Car?cter (char) (Se deben usar comillas simples) (Ejemplo: 'a')\n\n" +
|
1706 |
"Los par?metros se deben escribir separados por coma:\n" +
|
1707 |
" Ejemplo: 2, 3.5, true, \"El coche\", 'c'\n");
|
1708 |
|
1709 |
globalHelp = new String(" AYUDA CON LOS PAR?METROS:\n" + |
1710 |
" ==========================\n" +
|
1711 |
" Se permiten 5 tipos de par?metros:\n" +
|
1712 |
" - Entero (int) (Ejemplo: 24)\n" +
|
1713 |
" - Real corto (float) (Ejemplo: 2.5)\n" +
|
1714 |
" - Real largo (double) (Ejemplo: 2.56869479346)\n" +
|
1715 |
" - Booleano/Bandera (boolean) (Ejemplo valor cierto: true) (Ejemplo valor falso: false)\n" +
|
1716 |
" - Cadena de caracteres (String) (Se deben usar comillas dobles) (Ejemplo: \"La casa.\")\n" +
|
1717 |
" - Car?cter (char) (Se deben usar comillas simples) (Ejemplo: 'a')\n" +
|
1718 |
" - Objeto (Object) (Se considerar? como un item a a?adir o quitar a un JComboBox; se\n" +
|
1719 |
" escribir? como si fuese una cadena de caracteres (String)) (Ejemplo: \"El reloj\"\n\n" +
|
1720 |
" Los par?metros se deben escribir separados por coma:\n" +
|
1721 |
" Ejemplo: 2, 3.5, true, \"El coche\", 'c', \"El reloj\"\n\n\n" +
|
1722 |
" AYUDA PANEL \"OTRAS PRUEBAS\" :\n" +
|
1723 |
" =============================\n" +
|
1724 |
" + JComboBox \"Operaci?n\" :\n" +
|
1725 |
" Puede seleccionar la operaci?n que desee realizar.\n\n" +
|
1726 |
" + JComboBox \"Objeto\" :\n" +
|
1727 |
" Puede seleccionar el objeto sobre el que realizar\n" +
|
1728 |
" la operaci?n seleccionada.\n\n" +
|
1729 |
" + Pesta?a \"Descripci?n\" :\n" +
|
1730 |
" - ?rea de texto \"Descripci?n\" :\n" +
|
1731 |
" Muestra informaci?n de la operaci?n seleccionada y\n" +
|
1732 |
" puede mostrar esta informaci?n de ayuda acerca del\n" +
|
1733 |
" manejo de esta aplicaci?n\n\n" +
|
1734 |
" - Campo de texto \"Par?metros\" :\n" +
|
1735 |
" Permite introducir par?metros para probar la operaci?n\n" +
|
1736 |
" seleccionada sobre el objeto seleccionado. Se debe introducir\n" +
|
1737 |
" par?metros del mismo tipo que los necesarios por la operaci?n,\n" +
|
1738 |
" y el mismo n?mero. En caso de que la operaci?n no necesite\n" +
|
1739 |
" par?metros de entrada, este campo estar? deshabilitado. Y en\n" +
|
1740 |
" en caso que no el usuario no pueda introducir un tipo de\n" +
|
1741 |
" par?metro (tipo distinto a los soportados), en caso de poderse\n" +
|
1742 |
" realizar la operaci?n, se usar?n valores por defecto desde la\n" +
|
1743 |
" aplicaci?n (y no escribir el par?metro).\n\n" +
|
1744 |
" - Bot?n \"Rellenar\" :\n" +
|
1745 |
" A?ade un conjunto de items por defecto al objeto actual,\n" +
|
1746 |
" permite as? al usuario probar el objeto sin tener que introducir\n" +
|
1747 |
" datos manualmente.\n\n" +
|
1748 |
" - Bot?n \"Reset\" :\n" +
|
1749 |
" Puls?ndolo deja el panel \"Otras Pruebas\" tal y como\n" +
|
1750 |
" estaba inicialmente.\n\n" +
|
1751 |
" - Bot?n \"Test\" :\n" +
|
1752 |
" Puls?ndolo se intenta ejecutar un test de la operaci?n\n" +
|
1753 |
" seleccionada sobre el objeto seleccionado, y usando los\n" +
|
1754 |
" par?metros introducidos en caso necesario.\n" +
|
1755 |
" El test puede no ejecutarse si algo de lo anterior no es\n" +
|
1756 |
" correcto.\n\n" +
|
1757 |
" + Pesta?a \"Log\" :\n" +
|
1758 |
" Se va mostrando el resultado de las operaciones, as? como\n" +
|
1759 |
" texto de depuraci?n que puedan ir generando los objetos\n" +
|
1760 |
" objetos seg?n se usen.");
|
1761 |
|
1762 |
this.inializeMethods();
|
1763 |
} |
1764 |
|
1765 |
/**
|
1766 |
* <p>Pass a JavaFileMethodsLoader object that has been used for load a the <code>JComboBoxLookUpConfigurable</code> class file.</p>
|
1767 |
*
|
1768 |
* @param methodsLoader A JavaFileMethodsLoader object
|
1769 |
*/
|
1770 |
public void setJavaFileMethodsLoader(JavaFileMethodsLoader methodsLoader) { |
1771 |
javaFileMethodsLoader = methodsLoader; |
1772 |
this.initialize();
|
1773 |
} |
1774 |
|
1775 |
/**
|
1776 |
* <p>Add a method to a private Vector with all the methods that this pane will use.</p>
|
1777 |
*/
|
1778 |
private void inializeMethods() { |
1779 |
methods = new Vector<Object>(0, 1); |
1780 |
|
1781 |
/* Create object without parameters */
|
1782 |
MethodsDescription description = new MethodsDescription();
|
1783 |
methods.add(description); |
1784 |
} |
1785 |
|
1786 |
/**
|
1787 |
* <p>This method initializes <code>jComboBoxMethods</code>.</p>
|
1788 |
*
|
1789 |
* @return javax.swing.JComboBox
|
1790 |
*/
|
1791 |
private JComboBox getJComboBoxMethods() { |
1792 |
if (jComboBoxMethods == null) { |
1793 |
jComboBoxMethods = new JComboBox(); |
1794 |
jComboBoxMethods.setPreferredSize(new Dimension(jComboBoxWidth, jComboBoxHeigth)); |
1795 |
|
1796 |
jComboBoxMethods.getModel().addListDataListener(new ListDataListener() { |
1797 |
/*
|
1798 |
* (non-Javadoc)
|
1799 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
1800 |
*/
|
1801 |
public void contentsChanged(ListDataEvent e) { |
1802 |
Object item = jComboBoxMethods.getSelectedItem();
|
1803 |
|
1804 |
if (item != null) |
1805 |
jComboBoxMethods.setToolTipText(item.toString()); |
1806 |
} |
1807 |
|
1808 |
/*
|
1809 |
* (non-Javadoc)
|
1810 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
1811 |
*/
|
1812 |
public void intervalAdded(ListDataEvent e) { |
1813 |
} |
1814 |
|
1815 |
/*
|
1816 |
* (non-Javadoc)
|
1817 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
1818 |
*/
|
1819 |
public void intervalRemoved(ListDataEvent e) { |
1820 |
} |
1821 |
}); |
1822 |
|
1823 |
jComboBoxMethods.addPopupMenuListener(new PopupMenuListener() { |
1824 |
|
1825 |
/*
|
1826 |
* (non-Javadoc)
|
1827 |
* @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent)
|
1828 |
*/
|
1829 |
public void popupMenuCanceled(PopupMenuEvent e) { |
1830 |
} |
1831 |
|
1832 |
/*
|
1833 |
* (non-Javadoc)
|
1834 |
* @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent)
|
1835 |
*/
|
1836 |
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
1837 |
// If the user has selected another method -> show its description
|
1838 |
Object item = jComboBoxMethods.getSelectedItem();
|
1839 |
if (item != null) |
1840 |
{ |
1841 |
if ((lastSelectedMethod == null) || (!lastSelectedMethod.equals(item))) |
1842 |
{ |
1843 |
displayMethodDescription(item); |
1844 |
|
1845 |
currentMethodTypes = javaFileMethodsLoader.getMethodParametersType(item.toString()); |
1846 |
|
1847 |
// Clears the previous parameters
|
1848 |
getJTextField().setText("");
|
1849 |
|
1850 |
// Updates the editable status of the field with parameters
|
1851 |
if (currentMethodTypes.size() == 0) |
1852 |
getJTextField().setEditable(false);
|
1853 |
else
|
1854 |
getJTextField().setEditable(true);
|
1855 |
} |
1856 |
} |
1857 |
} |
1858 |
|
1859 |
/*
|
1860 |
* (non-Javadoc)
|
1861 |
* @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
|
1862 |
*/
|
1863 |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
1864 |
lastSelectedMethod = jComboBoxMethods.getSelectedItem(); |
1865 |
} |
1866 |
}); |
1867 |
} |
1868 |
|
1869 |
return jComboBoxMethods;
|
1870 |
} |
1871 |
|
1872 |
/**
|
1873 |
* <p>Displays in the <code>JTextAreaDescriptionInstructions</code> information about a method.</p>
|
1874 |
*
|
1875 |
* @param method A method
|
1876 |
*/
|
1877 |
private void displayMethodDescription(Object method) { |
1878 |
// Adds the description text
|
1879 |
String methodHead = new String("public " + method); |
1880 |
this.getJTextAreaDescriptionInstructions().setText(javaFileMethodsLoader.getMethodDocumentation(methodHead) + "\n" + method); |
1881 |
|
1882 |
// Adjusts the view (jTextAreaDescriptionInstructions) to the jtreeRoot-left corner
|
1883 |
this.getJTextAreaDescriptionInstructions().getCaret().setDot(0); |
1884 |
} |
1885 |
|
1886 |
/**
|
1887 |
* <p>Adds an method item to the <code>jComboBoxMethods</code>.</p>
|
1888 |
*
|
1889 |
* @param name Name of the new method
|
1890 |
*/
|
1891 |
public void addMethodItem(String name) { |
1892 |
this.jComboBoxMethods.addItem(name);
|
1893 |
|
1894 |
// Displays description of the first item added by default
|
1895 |
if (this.lastSelectedMethod == null) |
1896 |
{ |
1897 |
this.lastSelectedMethod = getJComboBoxMethods().getSelectedItem();
|
1898 |
currentMethodTypes = javaFileMethodsLoader.getMethodParametersType((String)lastSelectedMethod);
|
1899 |
|
1900 |
if (currentMethodTypes.size() == 0) |
1901 |
getJTextField().setEditable(false);
|
1902 |
else
|
1903 |
getJTextField().setEditable(true);
|
1904 |
|
1905 |
displayMethodDescription(name); |
1906 |
} |
1907 |
} |
1908 |
|
1909 |
/**
|
1910 |
* <p>Removes a method item from the <code>jComboBoxMethods</code>.</p>
|
1911 |
*
|
1912 |
* @param name Name of a method to remove
|
1913 |
*/
|
1914 |
public void removeMethodItem(String name) { |
1915 |
this.jComboBoxMethods.removeItem(name);
|
1916 |
} |
1917 |
|
1918 |
/**
|
1919 |
* <p>Removes all method items from the <code>jComboBoxMethods</code>.</p>
|
1920 |
*/
|
1921 |
public void removeAllMethodItems() { |
1922 |
this.jComboBoxMethods.removeAll();
|
1923 |
} |
1924 |
|
1925 |
/**
|
1926 |
* <p>This method initializes <code>jTextField</code>.</p>
|
1927 |
*
|
1928 |
* @return javax.swing.JTextField
|
1929 |
*/
|
1930 |
private JTextField getJTextField() { |
1931 |
if (jTextField == null) { |
1932 |
jTextField = new JTextField(); |
1933 |
jTextField.setPreferredSize(new Dimension(parametersTextFieldWidth, parametersTextFieldHeight)); |
1934 |
} |
1935 |
return jTextField;
|
1936 |
} |
1937 |
|
1938 |
/**
|
1939 |
* <p>This method initializes <code>jLabelMethod</code>.</p>
|
1940 |
*
|
1941 |
* @return javax.swing.JLabel
|
1942 |
*/
|
1943 |
private JLabel getJLabelMethod() { |
1944 |
if (jLabelMethod == null) { |
1945 |
jLabelMethod = new JLabel(); |
1946 |
jLabelMethod.setText(Messages.getText("method"));
|
1947 |
} |
1948 |
return jLabelMethod;
|
1949 |
} |
1950 |
|
1951 |
/**
|
1952 |
* <p>This method initializes <code>jLabelParameters</code>.</p>
|
1953 |
*
|
1954 |
* @return javax.swing.JLabel
|
1955 |
*/
|
1956 |
private JLabel getJLabelParameters() { |
1957 |
if (jLabelParameters == null) { |
1958 |
jLabelParameters = new JLabel(); |
1959 |
jLabelParameters.setPreferredSize(new Dimension(this.jLabelWidth, this.jLabelHeight)); |
1960 |
jLabelParameters.setText(Messages.getText("parameters"));
|
1961 |
} |
1962 |
return jLabelParameters;
|
1963 |
} |
1964 |
|
1965 |
/**
|
1966 |
* <p>This method initializes <code>jPanelMethods</code>.</p>
|
1967 |
*
|
1968 |
* @return javax.swing.JPanel
|
1969 |
*/
|
1970 |
private JPanel getJPanelMethods() { |
1971 |
if (jPanelMethods == null) { |
1972 |
jPanelMethods = new JPanel(); |
1973 |
jPanelMethods.setPreferredSize(new Dimension(methodsPanelWidth, methodsPanelHeight)); |
1974 |
jPanelMethods.setSize(new Dimension(methodsPanelWidth, methodsPanelHeight)); |
1975 |
jPanelMethods.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
1976 |
|
1977 |
GridLayout gridLayout = new GridLayout(2, 2); |
1978 |
gridLayout.setHgap(4);
|
1979 |
gridLayout.setVgap(4);
|
1980 |
jPanelMethods.setLayout(gridLayout); |
1981 |
|
1982 |
jPanelMethods.add(getJLabelMethod()); |
1983 |
jPanelMethods.add(getJLabelComponents()); |
1984 |
jPanelMethods.add(getJComboBoxMethods()); |
1985 |
jPanelMethods.add(getJComboBoxTestObjects()); |
1986 |
} |
1987 |
return jPanelMethods;
|
1988 |
} |
1989 |
|
1990 |
/**
|
1991 |
* <p>This method initializes <code>jLabelComponents</code>.</p>
|
1992 |
*
|
1993 |
* @return javax.swing.JLabel
|
1994 |
*/
|
1995 |
private JLabel getJLabelComponents() { |
1996 |
if (jLabelComponents == null) { |
1997 |
jLabelComponents = new JLabel(); |
1998 |
jLabelComponents.setText(Messages.getText("object"));
|
1999 |
} |
2000 |
return jLabelComponents;
|
2001 |
} |
2002 |
|
2003 |
/**
|
2004 |
* <p>This method initializes <code>jComboBoxTestObjects</code>.</p>
|
2005 |
*
|
2006 |
* @return javax.swing.JComboBox
|
2007 |
*/
|
2008 |
private JComboBox getJComboBoxTestObjects() { |
2009 |
if (jComboBoxTestObjects == null) { |
2010 |
jComboBoxTestObjects = new JComboBox(); |
2011 |
jComboBoxTestObjects.setPreferredSize(new Dimension(jComboBoxWidth, jComboBoxHeigth)); |
2012 |
jComboBoxTestObjects.setSize(new Dimension(jComboBoxWidth, jComboBoxHeigth)); |
2013 |
jComboBoxTestObjects.setMaximumSize(new Dimension(jComboBoxWidth, jComboBoxHeigth)); |
2014 |
|
2015 |
jComboBoxTestObjects.getModel().addListDataListener(new ListDataListener() { |
2016 |
/*
|
2017 |
* (non-Javadoc)
|
2018 |
* @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
|
2019 |
*/
|
2020 |
public void contentsChanged(ListDataEvent e) { |
2021 |
Object item = jComboBoxTestObjects.getSelectedItem();
|
2022 |
|
2023 |
if (item != null) |
2024 |
jComboBoxTestObjects.setToolTipText(item.toString()); |
2025 |
} |
2026 |
|
2027 |
/*
|
2028 |
* (non-Javadoc)
|
2029 |
* @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
|
2030 |
*/
|
2031 |
public void intervalAdded(ListDataEvent e) { |
2032 |
} |
2033 |
|
2034 |
/*
|
2035 |
* (non-Javadoc)
|
2036 |
* @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
|
2037 |
*/
|
2038 |
public void intervalRemoved(ListDataEvent e) { |
2039 |
} |
2040 |
}); |
2041 |
} |
2042 |
return jComboBoxTestObjects;
|
2043 |
} |
2044 |
|
2045 |
/**
|
2046 |
* <p>Adds an object for testing.</p>
|
2047 |
*
|
2048 |
* @param key A reference/name of the object
|
2049 |
* @param object The object
|
2050 |
*/
|
2051 |
public void addTestObject(Object key, Object object) { |
2052 |
this.testObjects.put(key, object);
|
2053 |
this.jComboBoxTestObjects.addItem(key);
|
2054 |
} |
2055 |
|
2056 |
/**
|
2057 |
* <p>Removes a testing object.</p>
|
2058 |
*
|
2059 |
* @param key A reference/name of the object
|
2060 |
*/
|
2061 |
public void removeTestObject(Object key) { |
2062 |
this.testObjects.remove(key);
|
2063 |
this.jComboBoxTestObjects.removeItem(key);
|
2064 |
} |
2065 |
|
2066 |
/**
|
2067 |
* <p>Removes all testing objects.</p>
|
2068 |
*/
|
2069 |
public void removeAllTestObjects() { |
2070 |
this.testObjects.clear();
|
2071 |
this.jComboBoxTestObjects.removeAllItems();
|
2072 |
} |
2073 |
|
2074 |
/**
|
2075 |
* <p>This method initializes <code>jScrollPaneDescriptionInstructions</code>.</p>
|
2076 |
*
|
2077 |
* @return javax.swing.JScrollPane
|
2078 |
*/
|
2079 |
private JScrollPane getJScrollPaneDescriptionInstructions() { |
2080 |
if (jScrollPaneDescriptionInstructions == null) { |
2081 |
jScrollPaneDescriptionInstructions = new JScrollPane(getJTextAreaDescriptionInstructions()); |
2082 |
Dimension dimension = getJTextAreaDescriptionInstructions().getPreferredSize();
|
2083 |
dimension.height += jScrollPaneIncrementConstant; |
2084 |
dimension.width += jScrollPaneIncrementConstant; |
2085 |
jScrollPaneDescriptionInstructions.setPreferredSize(dimension); |
2086 |
} |
2087 |
return jScrollPaneDescriptionInstructions;
|
2088 |
} |
2089 |
|
2090 |
/**
|
2091 |
* <p>This method initializes <code>jTextAreaDescriptionInstructions</code>.</p>
|
2092 |
*
|
2093 |
* @return javax.swing.JTextArea
|
2094 |
*/
|
2095 |
private JTextArea getJTextAreaDescriptionInstructions() { |
2096 |
if (jTextAreaDescriptionInstructions == null) { |
2097 |
jTextAreaDescriptionInstructions = new JTextArea(rowsOfJTextAreaDescriptionInstructions, columnsOfJTextAreaDescriptionInstructions); |
2098 |
jTextAreaDescriptionInstructions.setEditable(false);
|
2099 |
} |
2100 |
return jTextAreaDescriptionInstructions;
|
2101 |
} |
2102 |
|
2103 |
/**
|
2104 |
* <p>This method initializes <code>jButtonTest</code>.</p>
|
2105 |
*
|
2106 |
* @return javax.swing.JButton
|
2107 |
*/
|
2108 |
private JButton getJButtonTest() { |
2109 |
if (jButtonTest == null) { |
2110 |
jButtonTest = new JButton(); |
2111 |
jButtonTest.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
2112 |
jButtonTest.setText(Messages.getText("test"));
|
2113 |
jButtonTest.addMouseListener(new MouseAdapter() { |
2114 |
/*
|
2115 |
* (non-Javadoc)
|
2116 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
2117 |
*/
|
2118 |
public void mouseClicked(MouseEvent arg0) { |
2119 |
try {
|
2120 |
String methodHead = (String)getJComboBoxMethods().getSelectedItem(); |
2121 |
if (methodHead == null) |
2122 |
{ |
2123 |
JOptionPane.showMessageDialog(null, Messages.getText("selectAMethod"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2124 |
return;
|
2125 |
} |
2126 |
|
2127 |
int selectedTestObjectIndex = getJComboBoxTestObjects().getSelectedIndex();
|
2128 |
if (selectedTestObjectIndex == -1) |
2129 |
{ |
2130 |
JOptionPane.showMessageDialog(null, Messages.getText("selectAComponent"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2131 |
return;
|
2132 |
} |
2133 |
|
2134 |
// If the method selected needs an special treatment
|
2135 |
if (javaFileMethodsLoader.hasTheMethodAnStrangeParameterType(methodHead) || javaFileMethodsLoader.hasTheMethodAnStrangeReturnParameterType(methodHead))
|
2136 |
{ |
2137 |
JOptionPane.showMessageDialog(null, Messages.getText("cantTestThisMethod"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2138 |
return;
|
2139 |
} |
2140 |
|
2141 |
Vector<Object> parametersWritten = getParametersWritten(); |
2142 |
if (parametersWritten.size() != currentMethodTypes.size())
|
2143 |
{ |
2144 |
JOptionPane.showMessageDialog(null, Messages.getText("incorrectNumberOfParametersWritten"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2145 |
return;
|
2146 |
} |
2147 |
|
2148 |
// Defines the type of parameters for the current selected method
|
2149 |
Class parameterTypes[] = new Class[currentMethodTypes.size()]; |
2150 |
|
2151 |
// Create the 'parameters' array
|
2152 |
Object parameters[] = new Object[currentMethodTypes.size()]; |
2153 |
|
2154 |
for (int i = 0; i < currentMethodTypes.size(); i++) |
2155 |
{ |
2156 |
MethodParameter parameter = parametersTypeIsCorrect((String)parametersWritten.get(i), (Integer)currentMethodTypes.get(i)); |
2157 |
|
2158 |
if (parameter == null) |
2159 |
{ |
2160 |
JOptionPane.showMessageDialog(null, Messages.getText("incorrectParameter") + ": " + (String)parametersWritten.get(i), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2161 |
return;
|
2162 |
} |
2163 |
|
2164 |
parameters[i] = parameter.getParameter(); |
2165 |
parameterTypes[i] = parameter.getType(); |
2166 |
} |
2167 |
|
2168 |
// Select the "log" tab of the jTabbedPane
|
2169 |
getJTabbedPaneOtherUtilities().setSelectedIndex(1);
|
2170 |
|
2171 |
// Gets the frame of the object selected
|
2172 |
String objectName = getJComboBoxTestObjects().getSelectedItem().toString();
|
2173 |
JFrame jTestObjectFrame = ((JFrame)testObjects.get(objectName)); |
2174 |
|
2175 |
// Sets the focus to the frame of the selected object
|
2176 |
((JFrame)jTestObjectFrame).getRootPane().requestDefaultFocus();
|
2177 |
|
2178 |
// Gets the selected object for test
|
2179 |
Object object = jTestObjectFrame.getContentPane().getComponent(0); |
2180 |
|
2181 |
// Gets the class of the current selected object
|
2182 |
Class testObjectClass = object.getClass();
|
2183 |
|
2184 |
// Gets the method that corresponds with the selected method
|
2185 |
String methodName = javaFileMethodsLoader.getMethodName(methodHead);
|
2186 |
Method method = testObjectClass.getMethod(methodName, parameterTypes);
|
2187 |
|
2188 |
// Show information about the next method to do
|
2189 |
getJTextAreaLog().append(Messages.getText("invoke") +"(" + objectName + ", " + methodName + "):\n"); |
2190 |
|
2191 |
// Invoke the selected method for the selected object
|
2192 |
Object objectReturned = method.invoke(object, parameters);
|
2193 |
|
2194 |
// Show the results of the method
|
2195 |
if (objectReturned != null) |
2196 |
getJTextAreaLog().append(Messages.getText("resultOf") +"(" + objectName + ", " + methodName + "): " + objectReturned.toString() + "\n"); |
2197 |
} |
2198 |
catch(Exception e) { |
2199 |
e.printStackTrace(); |
2200 |
} |
2201 |
} |
2202 |
}); |
2203 |
} |
2204 |
return jButtonTest;
|
2205 |
} |
2206 |
|
2207 |
/**
|
2208 |
* <p>This method initializes <code>jTabbedPaneOtherUtilities</code>.</p>
|
2209 |
*
|
2210 |
* @return javax.swing.JTabbedPane
|
2211 |
*/
|
2212 |
private JTabbedPane getJTabbedPaneOtherUtilities() { |
2213 |
if (jTabbedPaneOtherUtilities == null) { |
2214 |
jTabbedPaneOtherUtilities = new JTabbedPane(); |
2215 |
jTabbedPaneOtherUtilities.setPreferredSize(new Dimension(otherUtilitiesJTabbedPaneWidth, otherUtilitiesJTabbedPaneHeight)); |
2216 |
|
2217 |
JPanel panel1 = new JPanel(); |
2218 |
panel1.setPreferredSize(new Dimension(otherUtilitiesJTabbedPaneWidth - 10, 30)); |
2219 |
panel1.add(getJLabelParameters()); |
2220 |
panel1.add(getJTextField()); |
2221 |
|
2222 |
JPanel tab1Pane = new JPanel(); |
2223 |
tab1Pane.add(getJScrollPaneDescriptionInstructions()); |
2224 |
tab1Pane.add(panel1); |
2225 |
jTabbedPaneOtherUtilities.addTab(Messages.getText("description"), tab1Pane);
|
2226 |
|
2227 |
jTabbedPaneOtherUtilities.addTab(Messages.getText("log"), getJScrollPaneLog());
|
2228 |
} |
2229 |
return jTabbedPaneOtherUtilities;
|
2230 |
} |
2231 |
|
2232 |
/**
|
2233 |
* <p>Verifies if a parameter is of one particular type: if <code>true</code> -> returns a <code>MethodParameter</code> object with
|
2234 |
* the type codification and the parameter as an object of its type; if <code>false</code> -> returns <code>null</code>.</p>
|
2235 |
*
|
2236 |
* @param parameter A parameter as a name
|
2237 |
* @param type An Integer object with the codification of the type
|
2238 |
* @return <code>Null<code> or a <code>MethodParameter<code> object with an object of the same type as the parameter type, and
|
2239 |
* the codification of the type.
|
2240 |
*/
|
2241 |
private MethodParameter parametersTypeIsCorrect(String parameter, Integer type) { |
2242 |
MethodParameter methodParameter = new MethodParameter();
|
2243 |
|
2244 |
switch (type.intValue()) {
|
2245 |
case JavaFileMethodsLoader.BOOLEAN_TYPE:
|
2246 |
if (parameter.compareTo("true") == 0) |
2247 |
{ |
2248 |
methodParameter.setParameter(new Boolean(true)); |
2249 |
methodParameter.setType(Boolean.TYPE);
|
2250 |
} |
2251 |
else
|
2252 |
{ |
2253 |
if (parameter.compareTo("false") == 0) |
2254 |
{ |
2255 |
methodParameter.setParameter(new Boolean(false)); |
2256 |
methodParameter.setType(Boolean.TYPE);
|
2257 |
} |
2258 |
else
|
2259 |
return null; |
2260 |
} |
2261 |
return methodParameter;
|
2262 |
case JavaFileMethodsLoader.CHAR_TYPE:
|
2263 |
if ((parameter.length() == 3) && (parameter.charAt(0) == '\'') && (parameter.charAt(2) == '\'')) |
2264 |
{ |
2265 |
methodParameter.setParameter(new Character(parameter.charAt(1))); |
2266 |
methodParameter.setType(Character.TYPE);
|
2267 |
} |
2268 |
else
|
2269 |
return null; |
2270 |
case JavaFileMethodsLoader.FLOAT_TYPE:
|
2271 |
try {
|
2272 |
methodParameter.setParameter(new Float(parameter)); |
2273 |
methodParameter.setType(Float.TYPE);
|
2274 |
return methodParameter;
|
2275 |
} |
2276 |
catch(Exception e) { |
2277 |
return null; |
2278 |
} |
2279 |
case JavaFileMethodsLoader.DOUBLE_TYPE:
|
2280 |
try {
|
2281 |
methodParameter.setParameter(new Double(parameter)); |
2282 |
methodParameter.setType(Double.TYPE);
|
2283 |
return methodParameter;
|
2284 |
} |
2285 |
catch(Exception e) { |
2286 |
return null; |
2287 |
} |
2288 |
case JavaFileMethodsLoader.INT_TYPE:
|
2289 |
try {
|
2290 |
methodParameter.setParameter(new Integer(parameter)); |
2291 |
methodParameter.setType(Integer.TYPE);
|
2292 |
return methodParameter;
|
2293 |
} |
2294 |
catch(Exception e) { |
2295 |
return null; |
2296 |
} |
2297 |
case JavaFileMethodsLoader.STRING_TYPE:
|
2298 |
// If the string is between "" simbols:
|
2299 |
if ((parameter.charAt(0) == '\"') && (parameter.charAt(parameter.length() - 1) == '\"')) |
2300 |
{ |
2301 |
methodParameter.setParameter(new String(parameter.substring(1, parameter.length() -1))); |
2302 |
methodParameter.setType(String.class);
|
2303 |
return methodParameter;
|
2304 |
} |
2305 |
else
|
2306 |
return null; |
2307 |
case JavaFileMethodsLoader.OBJECT_TYPE:
|
2308 |
// If the string written is between "" simbols:
|
2309 |
if ((parameter.charAt(0) == '\"') && (parameter.charAt(parameter.length() - 1) == '\"')) |
2310 |
{ |
2311 |
methodParameter.setParameter(parameter.substring(1, parameter.length() -1)); |
2312 |
methodParameter.setType(Object.class);
|
2313 |
return methodParameter;
|
2314 |
} |
2315 |
else
|
2316 |
return null; |
2317 |
default: // JavaFileMethodsLoader.OTHER_TYPE |
2318 |
return null; |
2319 |
} |
2320 |
} |
2321 |
|
2322 |
/**
|
2323 |
* <p>Return a Vector with the parameters written as <code>String</code>.</p>
|
2324 |
*
|
2325 |
* @return A Vector with the parameters written
|
2326 |
*/
|
2327 |
private Vector<Object> getParametersWritten() { |
2328 |
Vector<Object> parameters = new Vector<Object>(0, 1); |
2329 |
|
2330 |
String parametersWritten = getJTextField().getText().trim();
|
2331 |
|
2332 |
// If there is only one parameter
|
2333 |
if (parametersWritten.indexOf(',') == -1) |
2334 |
{ |
2335 |
if (parametersWritten.length() > 0) |
2336 |
parameters.add(parametersWritten); |
2337 |
else
|
2338 |
return parameters;
|
2339 |
} |
2340 |
else
|
2341 |
{ |
2342 |
StringTokenizer tokens = new StringTokenizer(parametersWritten, ","); |
2343 |
|
2344 |
while(tokens.hasMoreTokens())
|
2345 |
parameters.add(tokens.nextToken().trim()); |
2346 |
} |
2347 |
|
2348 |
return parameters;
|
2349 |
} |
2350 |
|
2351 |
/**
|
2352 |
* <p>This method initializes <code>jButtonReset</code>.</p>
|
2353 |
*
|
2354 |
* @return javax.swing.JButton
|
2355 |
*/
|
2356 |
private JButton getJButtonReset() { |
2357 |
if (jButtonReset == null) { |
2358 |
jButtonReset = new JButton(); |
2359 |
jButtonReset.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
2360 |
jButtonReset.setText(Messages.getText("reset"));
|
2361 |
jButtonReset.addMouseListener(new MouseAdapter() { |
2362 |
/*
|
2363 |
* (non-Javadoc)
|
2364 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
2365 |
*/
|
2366 |
public void mouseClicked(MouseEvent arg0) { |
2367 |
resetOtherTestsPanel(); |
2368 |
} |
2369 |
}); |
2370 |
} |
2371 |
return jButtonReset;
|
2372 |
} |
2373 |
|
2374 |
/**
|
2375 |
* <p>Resets this <code>JPanel</code>: all will be similar as at beginning except the log, that won't be reset.</p>
|
2376 |
*/
|
2377 |
private void resetOtherTestsPanel() { |
2378 |
getJTextAreaDescriptionInstructions().setText("");
|
2379 |
|
2380 |
getJTextField().setText("");
|
2381 |
|
2382 |
if (getJComboBoxMethods().getItemCount() == 0) |
2383 |
{ |
2384 |
getJComboBoxMethods().setSelectedIndex(-1);
|
2385 |
this.lastSelectedMethod = this.currentMethodTypes = null; |
2386 |
getJTextField().setEditable(false);
|
2387 |
} |
2388 |
else
|
2389 |
{ |
2390 |
this.getJComboBoxMethods().setSelectedIndex(0); |
2391 |
this.lastSelectedMethod = getJComboBoxMethods().getSelectedItem();
|
2392 |
currentMethodTypes = javaFileMethodsLoader.getMethodParametersType((String)lastSelectedMethod);
|
2393 |
|
2394 |
if (currentMethodTypes.size() == 0) |
2395 |
getJTextField().setEditable(false);
|
2396 |
else
|
2397 |
getJTextField().setEditable(true);
|
2398 |
|
2399 |
displayMethodDescription(this.lastSelectedMethod);
|
2400 |
} |
2401 |
|
2402 |
// Removes all test objects (closing the JFrames that cointain them)
|
2403 |
Object[] objects = testObjects.keySet().toArray(); |
2404 |
for (int i = 0; i < objects.length; i++) |
2405 |
{ |
2406 |
((JFrame)testObjects.get(objects[i])).dispose();
|
2407 |
((JFrame)testObjects.get(objects[i])).setVisible(false); // For complete de JFrame close method (it's necessary) |
2408 |
} |
2409 |
|
2410 |
// Set selected the firt tab
|
2411 |
getJTabbedPaneOtherUtilities().setSelectedIndex(0);
|
2412 |
} |
2413 |
|
2414 |
/**
|
2415 |
* <p>This method initializes <code>jPaneButtons</code>.</p>
|
2416 |
*
|
2417 |
* @return javax.swing.JPanel
|
2418 |
*/
|
2419 |
private JPanel getJPaneButtons() { |
2420 |
if (jPanelButtons == null) { |
2421 |
FlowLayout flowLayout = new FlowLayout(); |
2422 |
flowLayout.setAlignment(FlowLayout.RIGHT);
|
2423 |
jPanelButtons = new JPanel(); |
2424 |
jPanelButtons.setPreferredSize(new Dimension(buttonsPanelWidth, buttonsPanelHeight)); |
2425 |
jPanelButtons.setLayout(flowLayout); |
2426 |
jPanelButtons.add(getJButtonOtherTestsHelp(), null);
|
2427 |
jPanelButtons.add(getJButtonFill(), null);
|
2428 |
jPanelButtons.add(getJButtonReset(), null);
|
2429 |
jPanelButtons.add(getJButtonTest(), null);
|
2430 |
} |
2431 |
return jPanelButtons;
|
2432 |
} |
2433 |
|
2434 |
/**
|
2435 |
* <p>Returns the number of testing objects that this panel has in this moments.</p>
|
2436 |
*
|
2437 |
* @return Number of testing objects that this panel has in this moments
|
2438 |
*/
|
2439 |
public int getTestObjectsCount() { |
2440 |
return this.getJComboBoxTestObjects().getItemCount(); |
2441 |
} |
2442 |
|
2443 |
/**
|
2444 |
* <p>This method initializes <code>jButtonLog</code>.</p>
|
2445 |
*
|
2446 |
* @return javax.swing.JButton
|
2447 |
*/
|
2448 |
private JButton getJButtonFill() { |
2449 |
if (jButtonFill == null) { |
2450 |
jButtonFill = new JButton(); |
2451 |
jButtonFill.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
2452 |
jButtonFill.setText(Messages.getText("fill"));
|
2453 |
jButtonFill.addMouseListener(new MouseAdapter() { |
2454 |
/*
|
2455 |
* (non-Javadoc)
|
2456 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
2457 |
*/
|
2458 |
public void mouseClicked(MouseEvent arg0) { |
2459 |
try
|
2460 |
{ |
2461 |
// It must be selected a component -> else: show a message dialog and don't fill with data the object
|
2462 |
int selectedTestObjectIndex = getJComboBoxTestObjects().getSelectedIndex();
|
2463 |
if (selectedTestObjectIndex == -1) |
2464 |
{ |
2465 |
JOptionPane.showMessageDialog(null, Messages.getText("selectAComponent"), Messages.getText("warning"), JOptionPane.WARNING_MESSAGE); |
2466 |
return;
|
2467 |
} |
2468 |
|
2469 |
JFrame jTestObjectFrame = ((JFrame)testObjects.get(getJComboBoxTestObjects().getSelectedItem().toString())); |
2470 |
|
2471 |
// Sets the focus to the frame of the selected object
|
2472 |
((JFrame)jTestObjectFrame).getRootPane().requestDefaultFocus();
|
2473 |
|
2474 |
// Gets the selected object for test
|
2475 |
Object object = jTestObjectFrame.getContentPane().getComponent(0); |
2476 |
|
2477 |
// Gets the class of the current selected object
|
2478 |
Class testObjectClass = object.getClass();
|
2479 |
|
2480 |
// Defines the type of parameter for the 'addItem' method
|
2481 |
Class addItemParameterTypes[] = new Class[1]; |
2482 |
addItemParameterTypes[0] = Object.class; |
2483 |
|
2484 |
// Gets the 'addItem' method of the current selected object
|
2485 |
Method addItemMethod = testObjectClass.getMethod("addItem", addItemParameterTypes); |
2486 |
|
2487 |
// ADDS SAMPLE DATA:
|
2488 |
addSampleData(object, addItemMethod); |
2489 |
} |
2490 |
catch(Exception e) { |
2491 |
e.printStackTrace(); |
2492 |
} |
2493 |
} |
2494 |
}); |
2495 |
} |
2496 |
|
2497 |
return jButtonFill;
|
2498 |
} |
2499 |
|
2500 |
/**
|
2501 |
* <p>This method add sample data (items) to the current selected object invoking the "addItem" method for the object.</p>
|
2502 |
*
|
2503 |
* @param object Object where the items will be added
|
2504 |
* @param addItemMethod Method "addItem" to invoke
|
2505 |
*/
|
2506 |
private void addSampleData(Object object, Method addItemMethod) { |
2507 |
try {
|
2508 |
// Create the 'parameters' array
|
2509 |
Object parameters[] = new Object[1]; |
2510 |
|
2511 |
// Invokes the 'addItem' method of the object for adding sample items
|
2512 |
parameters[0] = "_fwAndami"; |
2513 |
addItemMethod.invoke(object, parameters); |
2514 |
|
2515 |
parameters[0] = "appgvSIG"; |
2516 |
addItemMethod.invoke(object, parameters); |
2517 |
|
2518 |
parameters[0] = "extAddEventTheme"; |
2519 |
addItemMethod.invoke(object, parameters); |
2520 |
|
2521 |
parameters[0] = "extAddIDEELayers"; |
2522 |
addItemMethod.invoke(object, parameters); |
2523 |
|
2524 |
parameters[0] = "extCAD"; |
2525 |
addItemMethod.invoke(object, parameters); |
2526 |
|
2527 |
parameters[0] = "extCenterViewToPoint"; |
2528 |
addItemMethod.invoke(object, parameters); |
2529 |
|
2530 |
parameters[0] = "extJDBC"; |
2531 |
addItemMethod.invoke(object, parameters); |
2532 |
|
2533 |
parameters[0] = "extNomenclatorIGN"; |
2534 |
addItemMethod.invoke(object, parameters); |
2535 |
|
2536 |
parameters[0] = "extScripting"; |
2537 |
addItemMethod.invoke(object, parameters); |
2538 |
|
2539 |
parameters[0] = "extWCS"; |
2540 |
addItemMethod.invoke(object, parameters); |
2541 |
|
2542 |
parameters[0] = "extWMS"; |
2543 |
addItemMethod.invoke(object, parameters); |
2544 |
|
2545 |
parameters[0] = "libCorePlugin"; |
2546 |
addItemMethod.invoke(object, parameters); |
2547 |
|
2548 |
parameters[0] = "libCq CMS for java"; |
2549 |
addItemMethod.invoke(object, parameters); |
2550 |
|
2551 |
parameters[0] = "libDriverManager"; |
2552 |
addItemMethod.invoke(object, parameters); |
2553 |
|
2554 |
parameters[0] = "libFMap"; |
2555 |
addItemMethod.invoke(object, parameters); |
2556 |
|
2557 |
parameters[0] = "libGDBMS"; |
2558 |
addItemMethod.invoke(object, parameters); |
2559 |
|
2560 |
parameters[0] = "libIverUtiles"; |
2561 |
addItemMethod.invoke(object, parameters); |
2562 |
|
2563 |
parameters[0] = "libNomeclatorIGN"; |
2564 |
addItemMethod.invoke(object, parameters); |
2565 |
|
2566 |
parameters[0] = "libNomenclatorIGN_GUI"; |
2567 |
addItemMethod.invoke(object, parameters); |
2568 |
|
2569 |
parameters[0] = "libRemoteServices"; |
2570 |
addItemMethod.invoke(object, parameters); |
2571 |
|
2572 |
parameters[0] = "libUI"; |
2573 |
addItemMethod.invoke(object, parameters); |
2574 |
|
2575 |
parameters[0] = "May?scula1"; |
2576 |
addItemMethod.invoke(object, parameters); |
2577 |
|
2578 |
parameters[0] = "MAY?SCULA2"; |
2579 |
addItemMethod.invoke(object, parameters); |
2580 |
|
2581 |
parameters[0] = "Mayuscula3"; |
2582 |
addItemMethod.invoke(object, parameters); |
2583 |
|
2584 |
parameters[0] = "mayuscula4?"; |
2585 |
addItemMethod.invoke(object, parameters); |
2586 |
|
2587 |
parameters[0] = "min?scula1"; |
2588 |
addItemMethod.invoke(object, parameters); |
2589 |
|
2590 |
parameters[0] = "minuscula2"; |
2591 |
addItemMethod.invoke(object, parameters); |
2592 |
|
2593 |
parameters[0] = "?and?"; |
2594 |
addItemMethod.invoke(object, parameters); |
2595 |
|
2596 |
parameters[0] = "?AND?"; |
2597 |
addItemMethod.invoke(object, parameters); |
2598 |
|
2599 |
parameters[0] = "a"; |
2600 |
addItemMethod.invoke(object, parameters); |
2601 |
|
2602 |
parameters[0] = "aa"; |
2603 |
addItemMethod.invoke(object, parameters); |
2604 |
|
2605 |
parameters[0] = "aaa"; |
2606 |
addItemMethod.invoke(object, parameters); |
2607 |
|
2608 |
parameters[0] = "aaaa"; |
2609 |
addItemMethod.invoke(object, parameters); |
2610 |
|
2611 |
parameters[0] = "aaaaa"; |
2612 |
addItemMethod.invoke(object, parameters); |
2613 |
|
2614 |
parameters[0] = "af??=)(/?/"; |
2615 |
addItemMethod.invoke(object, parameters); |
2616 |
|
2617 |
parameters[0] = "."; |
2618 |
addItemMethod.invoke(object, parameters); |
2619 |
|
2620 |
parameters[0] = "-a,malj'=)/"; |
2621 |
addItemMethod.invoke(object, parameters); |
2622 |
|
2623 |
parameters[0] = "ZZZZZ"; |
2624 |
addItemMethod.invoke(object, parameters); |
2625 |
|
2626 |
parameters[0] = "BLIUE? "; |
2627 |
addItemMethod.invoke(object, parameters); |
2628 |
|
2629 |
parameters[0] = "etye7yyy-er"; |
2630 |
addItemMethod.invoke(object, parameters); |
2631 |
|
2632 |
parameters[0] = "_abcdefghijklmn?opqrstuvwxyz"; |
2633 |
addItemMethod.invoke(object, parameters); |
2634 |
|
2635 |
parameters[0] = "_0123456789"; |
2636 |
addItemMethod.invoke(object, parameters); |
2637 |
|
2638 |
parameters[0] = "..."; |
2639 |
addItemMethod.invoke(object, parameters); |
2640 |
|
2641 |
parameters[0] = "gvSIG"; |
2642 |
addItemMethod.invoke(object, parameters); |
2643 |
|
2644 |
parameters[0] = "?LTIMO ITEM EN A?ADIRSE POR DEFECTO"; |
2645 |
addItemMethod.invoke(object, parameters); |
2646 |
|
2647 |
} catch (IllegalArgumentException e) { |
2648 |
e.printStackTrace(); |
2649 |
} catch (IllegalAccessException e) { |
2650 |
e.printStackTrace(); |
2651 |
} catch (InvocationTargetException e) { |
2652 |
e.printStackTrace(); |
2653 |
} |
2654 |
} |
2655 |
|
2656 |
/**
|
2657 |
* <p>This method initializes <code>jButtonOtherTestsHelp</code>.</p>
|
2658 |
*
|
2659 |
* @return javax.swing.JButton
|
2660 |
*/
|
2661 |
private JButton getJButtonOtherTestsHelp() { |
2662 |
if (jButtonOtherTestsHelp == null) { |
2663 |
jButtonOtherTestsHelp = new JButton(); |
2664 |
jButtonOtherTestsHelp.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
2665 |
jButtonOtherTestsHelp.setText(Messages.getText("help"));
|
2666 |
jButtonOtherTestsHelp.addMouseListener(new MouseAdapter() { |
2667 |
/*
|
2668 |
* (non-Javadoc)
|
2669 |
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
2670 |
*/
|
2671 |
public void mouseClicked(MouseEvent arg0) { |
2672 |
// Selects the 'description' tab pane
|
2673 |
getJTabbedPaneOtherUtilities().setSelectedIndex(0);
|
2674 |
|
2675 |
// Sets the help text
|
2676 |
getJTextAreaDescriptionInstructions().setText(globalHelp); |
2677 |
|
2678 |
// Adjusts the view (jTextAreaDescriptionInstructions) to the jtreeRoot-left corner
|
2679 |
getJTextAreaDescriptionInstructions().getCaret().setDot(0);
|
2680 |
|
2681 |
// Reset the current method selected
|
2682 |
lastSelectedMethod = null;
|
2683 |
getJTextField().setEditable(false);
|
2684 |
currentMethodTypes = null;
|
2685 |
getJComboBoxMethods().setSelectedIndex(-1);
|
2686 |
} |
2687 |
}); |
2688 |
|
2689 |
} |
2690 |
return jButtonOtherTestsHelp;
|
2691 |
} |
2692 |
|
2693 |
/**
|
2694 |
* <p>This method initializes <code>jScrollPaneLog</code>.</p>
|
2695 |
*
|
2696 |
* @return javax.swing.JScrollPane
|
2697 |
*/
|
2698 |
private JScrollPane getJScrollPaneLog() { |
2699 |
if (jScrollPaneLog == null) { |
2700 |
jScrollPaneLog = new JScrollPane(getJTextAreaLog()); |
2701 |
} |
2702 |
return jScrollPaneLog;
|
2703 |
} |
2704 |
|
2705 |
/**
|
2706 |
* <p>This method initializes <code>jTextAreaLog</code>.</p>
|
2707 |
*
|
2708 |
* @return javax.swing.JTextArea
|
2709 |
*/
|
2710 |
private JTextArea getJTextAreaLog() { |
2711 |
if (jTextAreaLog == null) { |
2712 |
jTextAreaLog = new JTextArea(); |
2713 |
jTextAreaLog.setEditable(false);
|
2714 |
} |
2715 |
return jTextAreaLog;
|
2716 |
} |
2717 |
|
2718 |
/**
|
2719 |
* <p>This class has information about a parameter of a method of a class.</p>
|
2720 |
*
|
2721 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
2722 |
*/
|
2723 |
private class MethodParameter implements Serializable { |
2724 |
private static final long serialVersionUID = -6492607912912912179L; |
2725 |
|
2726 |
private Object parameter; |
2727 |
private Class type; |
2728 |
|
2729 |
/**
|
2730 |
* <p>Default constructor without parameters.</p>
|
2731 |
*/
|
2732 |
public MethodParameter() {
|
2733 |
super();
|
2734 |
} |
2735 |
|
2736 |
/**
|
2737 |
* <p>Default constructor with 2 parameters.</p>
|
2738 |
*
|
2739 |
* @param parameter The parameter object
|
2740 |
* @param type The type of the parameter
|
2741 |
*/
|
2742 |
public MethodParameter(Object parameter, Class type) { |
2743 |
super();
|
2744 |
this.parameter = parameter;
|
2745 |
this.type = type;
|
2746 |
} |
2747 |
|
2748 |
/**
|
2749 |
* <p>Returns the parameter object.</p>
|
2750 |
*
|
2751 |
* @return Parameter object
|
2752 |
*/
|
2753 |
public Object getParameter() { |
2754 |
return parameter;
|
2755 |
} |
2756 |
|
2757 |
/**
|
2758 |
* <p>Sets the parameter object.</p>
|
2759 |
*
|
2760 |
* @param parameter Parameter object
|
2761 |
*/
|
2762 |
public void setParameter(Object parameter) { |
2763 |
this.parameter = parameter;
|
2764 |
} |
2765 |
|
2766 |
/**
|
2767 |
* <p>Returns the type of the parameter.</p>
|
2768 |
*
|
2769 |
* @return Type of the parameter
|
2770 |
*/
|
2771 |
public Class getType() { |
2772 |
return type;
|
2773 |
} |
2774 |
|
2775 |
/**
|
2776 |
* <p>Sets the type of the parameter.</p>
|
2777 |
*
|
2778 |
* @param type Type of the parameter
|
2779 |
*/
|
2780 |
public void setType(Class type) { |
2781 |
this.type = type;
|
2782 |
} |
2783 |
} |
2784 |
} |
2785 |
|
2786 |
|
2787 |
/**
|
2788 |
* <p>This class loads from a java file the methods of the class defined, and has some methods for get or manipulate them
|
2789 |
* (It's supposed that the file to load has a determinated structure).</p>
|
2790 |
*
|
2791 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
2792 |
*/
|
2793 |
private class JavaFileMethodsLoader implements Serializable { |
2794 |
private static final long serialVersionUID = 4934916590524133748L; |
2795 |
|
2796 |
private String className; |
2797 |
private Map<String, String> methods; |
2798 |
private Vector<Object> methodHeads; |
2799 |
private String filePath; |
2800 |
private File file; |
2801 |
|
2802 |
public static final int BOOLEAN_TYPE = 0; |
2803 |
public static final int STRING_TYPE = 1; |
2804 |
public static final int INT_TYPE = 2; |
2805 |
public static final int FLOAT_TYPE = 3; |
2806 |
public static final int DOUBLE_TYPE = 4; |
2807 |
public static final int CHAR_TYPE = 5; |
2808 |
public static final int VOID_TYPE = 6; |
2809 |
public static final int OBJECT_TYPE = 7; |
2810 |
public static final int OTHER_TYPE = 8; |
2811 |
|
2812 |
/**
|
2813 |
* <p>Default constructor without parameters.</p>
|
2814 |
*/
|
2815 |
public JavaFileMethodsLoader() {
|
2816 |
methods = new HashMap<String, String>(); |
2817 |
methodHeads = new Vector<Object>(0, 1); // Initial capacity = 0; Increment capacity = 1 |
2818 |
} |
2819 |
|
2820 |
/**
|
2821 |
* <p>Default constructor with a parameter: the path of the file to load.</p>
|
2822 |
*
|
2823 |
* <p>Loads that file.</p>
|
2824 |
*
|
2825 |
* @param path The path for the file to load
|
2826 |
*/
|
2827 |
public JavaFileMethodsLoader(String path) { |
2828 |
methods = new HashMap<String, String>(); |
2829 |
methodHeads = new Vector<Object>(0, 1); // Initial capacity = 0; Increment capacity = 1 |
2830 |
|
2831 |
this.filePath = path;
|
2832 |
this.file = new File(this.filePath); |
2833 |
this.className = this.obteinClassName(); |
2834 |
this.processFile();
|
2835 |
} |
2836 |
|
2837 |
/**
|
2838 |
* <p>Obtains the name of the class.</p>
|
2839 |
*
|
2840 |
* @return Name of the main class of the file loaded
|
2841 |
*/
|
2842 |
private String obteinClassName() { |
2843 |
return file.getName().substring(0, file.getName().lastIndexOf('.')); |
2844 |
} |
2845 |
|
2846 |
/**
|
2847 |
* <p>Returns the name of the main class of the file loaded.</p>
|
2848 |
*
|
2849 |
* @return Name of the main class of the file loaded
|
2850 |
*/
|
2851 |
public String getClassName() { |
2852 |
return this.className; |
2853 |
} |
2854 |
|
2855 |
/**
|
2856 |
* <p>Returns the name of the file loaded.</p>
|
2857 |
*
|
2858 |
* @return Name of the file loaded
|
2859 |
*/
|
2860 |
public String getClassFileName() { |
2861 |
return this.file.getName(); |
2862 |
} |
2863 |
|
2864 |
/**
|
2865 |
* <p>Returns a method head in order as it was declared/defined in the file loaded.</p>
|
2866 |
*
|
2867 |
* @param position Order of the method in the file, for return its head
|
2868 |
* @return A method head
|
2869 |
*/
|
2870 |
public String getMethodHead(int position) { |
2871 |
return (String)methodHeads.get(position); |
2872 |
} |
2873 |
|
2874 |
/**
|
2875 |
* <p>Returns the documentation of a method.</p>
|
2876 |
*
|
2877 |
* @param methodHead A method head
|
2878 |
* @return Documentation of a method
|
2879 |
*/
|
2880 |
public String getMethodDocumentation(String methodHead) { |
2881 |
return (String)methods.get(methodHead); |
2882 |
} |
2883 |
|
2884 |
/**
|
2885 |
* <p>Returns only the name from a method head.</p>
|
2886 |
*
|
2887 |
* @param methodHead A method head
|
2888 |
* @return A name of a method
|
2889 |
*/
|
2890 |
public String getMethodName(String methodHead) { |
2891 |
int endPosition = methodHead.indexOf('('); |
2892 |
|
2893 |
StringTokenizer tokens = new StringTokenizer(methodHead.substring(0, endPosition), " "); |
2894 |
|
2895 |
int numberOfTokens = tokens.countTokens();
|
2896 |
|
2897 |
if (numberOfTokens == 0) |
2898 |
return null; |
2899 |
else
|
2900 |
{ |
2901 |
// Get the last token -> which is the name of the method
|
2902 |
for (int i = 0; i < (numberOfTokens - 1); i++) |
2903 |
tokens.nextToken(); |
2904 |
|
2905 |
return tokens.nextToken();
|
2906 |
} |
2907 |
} |
2908 |
|
2909 |
/**
|
2910 |
* <p>Returns a vector with the codes of the parameter types of a method from its method head.</p>
|
2911 |
*
|
2912 |
* @param methodHead A method head
|
2913 |
* @return A vector with the parameter types of a method. Each element in the vector is an Integer object
|
2914 |
*/
|
2915 |
public Vector<Object> getMethodParametersType(String methodHead) { |
2916 |
Vector<Object> types = new Vector<Object>(0, 1); |
2917 |
|
2918 |
int startPosition = methodHead.indexOf('(') + 1; |
2919 |
int endPosition = methodHead.lastIndexOf(')'); |
2920 |
|
2921 |
StringTokenizer tokens = new StringTokenizer(methodHead.substring(startPosition, endPosition).trim(), ","); |
2922 |
|
2923 |
a: while(tokens.hasMoreTokens()) {
|
2924 |
String token = tokens.nextToken().trim();
|
2925 |
|
2926 |
if (token.startsWith("boolean ")) |
2927 |
{ |
2928 |
types.add(new Integer(JavaFileMethodsLoader.BOOLEAN_TYPE)); |
2929 |
continue a;
|
2930 |
} |
2931 |
|
2932 |
if (token.startsWith("int ")) |
2933 |
{ |
2934 |
types.add(new Integer(JavaFileMethodsLoader.INT_TYPE)); |
2935 |
continue a;
|
2936 |
} |
2937 |
|
2938 |
if (token.startsWith("double ")) |
2939 |
{ |
2940 |
types.add(new Integer(JavaFileMethodsLoader.DOUBLE_TYPE)); |
2941 |
continue a;
|
2942 |
} |
2943 |
|
2944 |
if (token.startsWith("String ")) |
2945 |
{ |
2946 |
types.add(new Integer(JavaFileMethodsLoader.STRING_TYPE)); |
2947 |
continue a;
|
2948 |
} |
2949 |
|
2950 |
if (token.startsWith("char ")) |
2951 |
{ |
2952 |
types.add(new Integer(JavaFileMethodsLoader.CHAR_TYPE)); |
2953 |
continue a;
|
2954 |
} |
2955 |
|
2956 |
if (token.startsWith("float ")) |
2957 |
{ |
2958 |
types.add(new Integer(JavaFileMethodsLoader.FLOAT_TYPE)); |
2959 |
continue a;
|
2960 |
} |
2961 |
|
2962 |
if (token.startsWith("Object ")) |
2963 |
{ |
2964 |
types.add(new Integer(JavaFileMethodsLoader.OBJECT_TYPE)); |
2965 |
continue a;
|
2966 |
} |
2967 |
|
2968 |
// Other type of parameters
|
2969 |
types.add(new Integer(JavaFileMethodsLoader.OTHER_TYPE)); |
2970 |
} |
2971 |
|
2972 |
return types;
|
2973 |
} |
2974 |
|
2975 |
/**
|
2976 |
* <p>Returns the return type name of a method.</p>
|
2977 |
*
|
2978 |
* @param methodHead A method head
|
2979 |
* @return A return type name
|
2980 |
*/
|
2981 |
public String getMethodReturnTypeName(String methodHead) { |
2982 |
int endPosition = methodHead.indexOf('('); |
2983 |
String aux = methodHead.substring(0, endPosition); |
2984 |
endPosition = aux.lastIndexOf(' ');
|
2985 |
return methodHead.substring(0, endPosition); |
2986 |
} |
2987 |
|
2988 |
/**
|
2989 |
* <p>Returns the code of the return type of a method from its method head.</p>
|
2990 |
*
|
2991 |
* @param methodHead A method head
|
2992 |
* @return An Integer object with the code
|
2993 |
*/
|
2994 |
public Integer getMethodReturnType(String methodHead) { |
2995 |
String returnType = getMethodReturnTypeName(methodHead);
|
2996 |
|
2997 |
if (returnType.compareTo("boolean") == 0) |
2998 |
return new Integer(JavaFileMethodsLoader.BOOLEAN_TYPE); |
2999 |
|
3000 |
if (returnType.compareTo("int") == 0) |
3001 |
return new Integer(JavaFileMethodsLoader.INT_TYPE); |
3002 |
|
3003 |
if (returnType.compareTo("double") == 0) |
3004 |
return new Integer(JavaFileMethodsLoader.DOUBLE_TYPE); |
3005 |
|
3006 |
if (returnType.compareTo("String") == 0) |
3007 |
return new Integer(JavaFileMethodsLoader.STRING_TYPE); |
3008 |
|
3009 |
if (returnType.compareTo("char") == 0) |
3010 |
return new Integer(JavaFileMethodsLoader.CHAR_TYPE); |
3011 |
|
3012 |
if (returnType.compareTo("float") == 0) |
3013 |
return new Integer(JavaFileMethodsLoader.FLOAT_TYPE); |
3014 |
|
3015 |
if (returnType.compareTo("void") == 0) |
3016 |
return new Integer(JavaFileMethodsLoader.VOID_TYPE); |
3017 |
|
3018 |
if (returnType.compareTo("Object") == 0) |
3019 |
return new Integer(JavaFileMethodsLoader.OBJECT_TYPE); |
3020 |
|
3021 |
// Other type of parameters
|
3022 |
return new Integer(JavaFileMethodsLoader.OTHER_TYPE); |
3023 |
|
3024 |
} |
3025 |
|
3026 |
/**
|
3027 |
* <p>Returns true if the method has almost one parameter that its type is unkwown <code>(JavaFileMethodsLoader.OTHER_TYPE)</code>.</p>
|
3028 |
*
|
3029 |
* @param methodHead A method head
|
3030 |
* @return true or false
|
3031 |
*/
|
3032 |
public boolean hasTheMethodAnStrangeParameterType(String methodHead) { |
3033 |
Vector<Object> types = this.getMethodParametersType(methodHead); |
3034 |
Integer otherType = new Integer(JavaFileMethodsLoader.OTHER_TYPE); |
3035 |
|
3036 |
for (int i = 0; i < types.size(); i++) { |
3037 |
if (((Integer)types.get(i)).intValue() == otherType.intValue()) |
3038 |
return true; |
3039 |
} |
3040 |
|
3041 |
return false; |
3042 |
} |
3043 |
|
3044 |
/**
|
3045 |
* <p>Returns true if the method has a return parameter that its type is unkwown <code>(JavaFileMethodsLoader.OTHER_TYPE)</code>.</p>
|
3046 |
*
|
3047 |
* @param methodHead A method head
|
3048 |
* @return true or false
|
3049 |
*/
|
3050 |
public boolean hasTheMethodAnStrangeReturnParameterType(String methodHead) { |
3051 |
Integer otherType = new Integer(JavaFileMethodsLoader.OTHER_TYPE); |
3052 |
|
3053 |
if (((Integer)getMethodReturnType(methodHead)).intValue() == otherType.intValue()) |
3054 |
return true; |
3055 |
|
3056 |
return false; |
3057 |
} |
3058 |
|
3059 |
/**
|
3060 |
* <p>Returns the number of methods loaded.</p>
|
3061 |
*
|
3062 |
* @return Number of methods loaded
|
3063 |
*/
|
3064 |
public int size() { |
3065 |
return methodHeads.size();
|
3066 |
} |
3067 |
|
3068 |
/**
|
3069 |
* <p>Returns the path of the file loaded.</p>
|
3070 |
*
|
3071 |
* @return The path of the file loaded
|
3072 |
*/
|
3073 |
public String getPath() { |
3074 |
return filePath;
|
3075 |
} |
3076 |
|
3077 |
/**
|
3078 |
* <p>Sets a path for a file to load, and loads it.</p>
|
3079 |
*
|
3080 |
* @param aPath A path for a file to load
|
3081 |
*/
|
3082 |
public void setPath(String aPath) { |
3083 |
this.filePath = aPath;
|
3084 |
file = new File(this.filePath); |
3085 |
this.className = this.obteinClassName(); |
3086 |
this.processFile();
|
3087 |
} |
3088 |
|
3089 |
/**
|
3090 |
* <p>Verifies if can read the file and invokes a method for analyze it.</p>
|
3091 |
*/
|
3092 |
private void processFile() { |
3093 |
try
|
3094 |
{ |
3095 |
// Verify if exists the file
|
3096 |
if (!file.exists())
|
3097 |
{ |
3098 |
// File doesn't exists
|
3099 |
JOptionPane.showMessageDialog(null, Messages.getText("jOPMessageFileDoesntExists"), Messages.getText("error"), JOptionPane.ERROR_MESSAGE); |
3100 |
return;
|
3101 |
} |
3102 |
|
3103 |
// Verify if it's a file
|
3104 |
if (!file.isFile())
|
3105 |
{ |
3106 |
JOptionPane.showMessageDialog(null, Messages.getText("jOPMessageIncorrectFile"), Messages.getText("error"), JOptionPane.ERROR_MESSAGE); |
3107 |
return;
|
3108 |
} |
3109 |
|
3110 |
// Verify if it can be read
|
3111 |
if (!file.canRead())
|
3112 |
{ |
3113 |
JOptionPane.showMessageDialog(null, Messages.getText("jOPMessageFileWithoutReadPermissions"), Messages.getText("error"), JOptionPane.ERROR_MESSAGE); |
3114 |
return;
|
3115 |
} |
3116 |
|
3117 |
analyzeFile(); |
3118 |
} |
3119 |
catch(Exception e) |
3120 |
{ |
3121 |
e.printStackTrace(); |
3122 |
} |
3123 |
} |
3124 |
|
3125 |
/**
|
3126 |
* <p>Analyes/loads a file, obtaining its methods and other information.</p>
|
3127 |
*
|
3128 |
* @throws IOException
|
3129 |
*/
|
3130 |
private void analyzeFile() throws IOException { |
3131 |
String line, commentary, methodHead;
|
3132 |
int pos;
|
3133 |
|
3134 |
// Process:
|
3135 |
// Associates a buffered-reader to the file-reader of the file
|
3136 |
BufferedReader input = new BufferedReader(new FileReader(file)); |
3137 |
|
3138 |
while(input.ready())
|
3139 |
{ |
3140 |
// Tries to read a commentary
|
3141 |
line = input.readLine(); |
3142 |
|
3143 |
if (line.startsWith("\t/*")) // This include the "\t/**" and "\t/*" commentary starts |
3144 |
{ |
3145 |
commentary = new String(line.trim()); |
3146 |
|
3147 |
while((pos = (line = input.readLine()).indexOf("*/")) == -1) |
3148 |
commentary += "\n " + line.trim();
|
3149 |
|
3150 |
commentary += "\n " + line.substring(0, pos+2).trim(); |
3151 |
|
3152 |
// Tries to read the head of a method
|
3153 |
line = input.readLine(); |
3154 |
|
3155 |
if (line.startsWith("\tpublic ") || line.startsWith("\tprivate ") || line.startsWith("\tprotected ")) |
3156 |
{ |
3157 |
// Ignore inner/nested classes
|
3158 |
if (line.indexOf(" class ") == -1) |
3159 |
{ |
3160 |
// Removes the '{' character if exists and does a trim:
|
3161 |
if ((pos = line.indexOf("{")) != -1) |
3162 |
line = line.substring(0, pos);
|
3163 |
|
3164 |
methodHead = new String(line.trim()); |
3165 |
commentary = commentary.trim(); |
3166 |
|
3167 |
// Adds needed information of the new method
|
3168 |
this.methodHeads.add(methodHead);
|
3169 |
this.methods.put(methodHead, commentary);
|
3170 |
} |
3171 |
} |
3172 |
} |
3173 |
} |
3174 |
|
3175 |
// Closes the buffered-reader
|
3176 |
input.close(); |
3177 |
} |
3178 |
} |
3179 |
|
3180 |
/**
|
3181 |
* <p>This class stores for a method, its previous commentary description.</p>
|
3182 |
*
|
3183 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
3184 |
*/
|
3185 |
private class MethodsDescription implements Serializable { |
3186 |
private static final long serialVersionUID = 5425689217735155592L; |
3187 |
|
3188 |
private String methodName; |
3189 |
private String description; |
3190 |
|
3191 |
/**
|
3192 |
* <p>Default Constructor without parameters.</p>
|
3193 |
*/
|
3194 |
public MethodsDescription() {
|
3195 |
super();
|
3196 |
} |
3197 |
|
3198 |
/**
|
3199 |
* <p>Default Constructor with 2 parameters.</p>
|
3200 |
*
|
3201 |
* @param methodName Name of a method
|
3202 |
* @param description Description (commentary) of the method
|
3203 |
*/
|
3204 |
public MethodsDescription(String methodName, String description) { |
3205 |
super();
|
3206 |
this.methodName = methodName;
|
3207 |
this.description = description;
|
3208 |
} |
3209 |
|
3210 |
/**
|
3211 |
* <p>Returns the description of this method.</p>
|
3212 |
*
|
3213 |
* @return Description of this method
|
3214 |
*/
|
3215 |
public String getDescription() { |
3216 |
return description;
|
3217 |
} |
3218 |
|
3219 |
/**
|
3220 |
* <p>Sets a description for this method.</p>
|
3221 |
*
|
3222 |
* @param description A description for this method
|
3223 |
*/
|
3224 |
public void setDescription(String description) { |
3225 |
this.description = description;
|
3226 |
} |
3227 |
|
3228 |
/**
|
3229 |
* <p>Returns the name of this method.</p>
|
3230 |
*
|
3231 |
* @return The name of this method
|
3232 |
*/
|
3233 |
public String getMethodName() { |
3234 |
return methodName;
|
3235 |
} |
3236 |
|
3237 |
/**
|
3238 |
* <p>Sets a name of this method.</p>
|
3239 |
*
|
3240 |
* @param methodName A name for this method
|
3241 |
*/
|
3242 |
public void setMethodName(String methodName) { |
3243 |
this.methodName = methodName;
|
3244 |
} |
3245 |
} |
3246 |
|
3247 |
/**
|
3248 |
* <p>An output stream that writes its output to a <code>javax.swing.JTextArea</code> control.</p>
|
3249 |
*
|
3250 |
* @see javax.swing.JTextArea
|
3251 |
*
|
3252 |
* @author Ranganath Kini
|
3253 |
*/
|
3254 |
public class TextAreaOutputStream extends OutputStream { |
3255 |
private JTextArea textControl; |
3256 |
|
3257 |
/**
|
3258 |
* <p>Creates a new instance of TextAreaOutputStream which writes
|
3259 |
* to the specified instance of <code>javax.swing.JTextArea</code> control.</p>
|
3260 |
*
|
3261 |
* @param control A reference to the javax.swing.JTextArea
|
3262 |
* control to which the output must be redirected
|
3263 |
* to.
|
3264 |
*/
|
3265 |
public TextAreaOutputStream( JTextArea control ) { |
3266 |
textControl = control; |
3267 |
} |
3268 |
|
3269 |
/*
|
3270 |
* Writes the specified byte as a character to the
|
3271 |
* javax.swing.JTextArea.
|
3272 |
*
|
3273 |
* @see java.io.OutputStream#write(int)
|
3274 |
*
|
3275 |
* @param b The byte to be written as character to the
|
3276 |
* JTextArea.
|
3277 |
*/
|
3278 |
public void write(int arg0) throws IOException { |
3279 |
// append the data as characters to the JTextArea control
|
3280 |
textControl.append( String.valueOf( ( char )arg0 ) ); |
3281 |
} |
3282 |
} |
3283 |
} |