root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / modeler / parameters / TablePanel.java @ 83
History | View | Annotate | Download (2.9 KB)
1 |
package es.unex.sextante.gui.modeler.parameters; |
---|---|
2 |
|
3 |
import javax.swing.JCheckBox; |
4 |
import javax.swing.JDialog; |
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import es.unex.sextante.additionalInfo.AdditionalInfoTable; |
8 |
import es.unex.sextante.core.Sextante; |
9 |
import es.unex.sextante.exceptions.NullParameterAdditionalInfoException; |
10 |
import es.unex.sextante.gui.modeler.ModelerPanel; |
11 |
import es.unex.sextante.parameters.Parameter; |
12 |
import es.unex.sextante.parameters.ParameterTable; |
13 |
|
14 |
public class TablePanel |
15 |
extends
|
16 |
ParameterPanel { |
17 |
|
18 |
private JCheckBox jCheckBoxMandatory; |
19 |
|
20 |
|
21 |
public TablePanel(final JDialog parent, |
22 |
final ModelerPanel panel) {
|
23 |
|
24 |
super(parent, panel);
|
25 |
|
26 |
} |
27 |
|
28 |
|
29 |
public TablePanel(final ModelerPanel panel) { |
30 |
|
31 |
super(panel);
|
32 |
|
33 |
} |
34 |
|
35 |
|
36 |
@Override
|
37 |
protected void initGUI() { |
38 |
|
39 |
super.initGUI();
|
40 |
|
41 |
super.setTitle(Sextante.getText("modeler_add_par_table")); |
42 |
|
43 |
super.setPreferredSize(new java.awt.Dimension(400, 200)); |
44 |
|
45 |
try {
|
46 |
jCheckBoxMandatory = new JCheckBox(); |
47 |
jCheckBoxMandatory.setSelected(true);
|
48 |
jPanelMiddle.add(jCheckBoxMandatory); |
49 |
jCheckBoxMandatory.setText(Sextante.getText("Mandatory"));
|
50 |
} |
51 |
catch (final Exception e) { |
52 |
Sextante.addErrorToLog(e); |
53 |
} |
54 |
|
55 |
} |
56 |
|
57 |
|
58 |
@Override
|
59 |
protected boolean prepareParameter() { |
60 |
|
61 |
|
62 |
final String sDescription = jTextFieldDescription.getText(); |
63 |
|
64 |
if (sDescription.length() != 0) { |
65 |
final AdditionalInfoTable addInfo = new AdditionalInfoTable(jCheckBoxMandatory.isSelected()); |
66 |
m_Parameter = new ParameterTable();
|
67 |
m_Parameter.setParameterAdditionalInfo(addInfo); |
68 |
m_Parameter.setParameterDescription(jTextFieldDescription.getText()); |
69 |
|
70 |
m_Parameter.setColorR(m_Color.getRed()); |
71 |
m_Parameter.setColorG(m_Color.getGreen()); |
72 |
m_Parameter.setColorB(m_Color.getBlue()); |
73 |
m_Parameter.setColorAlpha(m_Color.getAlpha()); |
74 |
|
75 |
return true; |
76 |
} |
77 |
else {
|
78 |
JOptionPane.showMessageDialog(null, Sextante.getText("Invalid_description"), Sextante.getText("Warning"), |
79 |
JOptionPane.WARNING_MESSAGE);
|
80 |
return false; |
81 |
} |
82 |
|
83 |
|
84 |
} |
85 |
|
86 |
|
87 |
@Override
|
88 |
public void setParameter(final Parameter param) { |
89 |
|
90 |
super.setParameter(param);
|
91 |
|
92 |
try {
|
93 |
final AdditionalInfoTable ai = (AdditionalInfoTable) param.getParameterAdditionalInfo();
|
94 |
jCheckBoxMandatory.setSelected(ai.getIsMandatory()); |
95 |
} |
96 |
catch (final NullParameterAdditionalInfoException e) { |
97 |
e.printStackTrace(); |
98 |
} |
99 |
|
100 |
} |
101 |
|
102 |
|
103 |
@Override
|
104 |
public String getParameterDescription() { |
105 |
|
106 |
return Sextante.getText("Table"); |
107 |
|
108 |
} |
109 |
|
110 |
|
111 |
@Override
|
112 |
public boolean parameterCanBeAdded() { |
113 |
|
114 |
return true; |
115 |
|
116 |
} |
117 |
|
118 |
} |