gvsig-projects-pool / org.gvsig.topology / trunk / org.gvsig.topology / org.gvsig.topology.swing / org.gvsig.topology.swing.impl / src / main / java / org / gvsig / topology / swing / impl / CreateRuleDialogView.java @ 2067
History | View | Annotate | Download (7.99 KB)
1 | 688 | jjdelcerro | package org.gvsig.topology.swing.impl; |
---|---|---|---|
2 | |||
3 | import com.jeta.open.i18n.I18NUtils; |
||
4 | import com.jgoodies.forms.layout.CellConstraints; |
||
5 | import com.jgoodies.forms.layout.FormLayout; |
||
6 | import java.awt.BorderLayout; |
||
7 | import java.awt.ComponentOrientation; |
||
8 | import java.awt.Container; |
||
9 | import java.awt.Dimension; |
||
10 | import javax.swing.Box; |
||
11 | import javax.swing.ImageIcon; |
||
12 | import javax.swing.JComboBox; |
||
13 | import javax.swing.JEditorPane; |
||
14 | import javax.swing.JFrame; |
||
15 | import javax.swing.JLabel; |
||
16 | import javax.swing.JPanel; |
||
17 | import javax.swing.JScrollPane; |
||
18 | 2067 | jolivas | import javax.swing.JTabbedPane; |
19 | 688 | jjdelcerro | import javax.swing.JTextField; |
20 | |||
21 | |||
22 | public class CreateRuleDialogView extends JPanel |
||
23 | { |
||
24 | 2067 | jolivas | JTabbedPane tabCreateRulePanel = new JTabbedPane(); |
25 | JComboBox cboDataSet2 = new JComboBox(); |
||
26 | JLabel lblDataSet2 = new JLabel(); |
||
27 | 688 | jjdelcerro | JTextField txtTolerance = new JTextField(); |
28 | 2067 | jolivas | JLabel lblTolerance = new JLabel(); |
29 | JComboBox cboRule = new JComboBox(); |
||
30 | JLabel lblRule = new JLabel(); |
||
31 | 688 | jjdelcerro | JComboBox cboDataSet1 = new JComboBox(); |
32 | JLabel lblDataSet1 = new JLabel(); |
||
33 | JEditorPane txtDescription = new JEditorPane(); |
||
34 | 2067 | jolivas | JPanel pnlParametros = new JPanel(); |
35 | 688 | jjdelcerro | |
36 | /**
|
||
37 | * Default constructor
|
||
38 | */
|
||
39 | public CreateRuleDialogView()
|
||
40 | { |
||
41 | initializePanel(); |
||
42 | } |
||
43 | |||
44 | /**
|
||
45 | * Adds fill components to empty cells in the first row and first column of the grid.
|
||
46 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
47 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
48 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
49 | */
|
||
50 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
51 | { |
||
52 | Dimension filler = new Dimension(10,10); |
||
53 | |||
54 | boolean filled_cell_11 = false; |
||
55 | CellConstraints cc = new CellConstraints();
|
||
56 | if ( cols.length > 0 && rows.length > 0 ) |
||
57 | { |
||
58 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
59 | { |
||
60 | /** add a rigid area */
|
||
61 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
62 | filled_cell_11 = true;
|
||
63 | } |
||
64 | } |
||
65 | |||
66 | for( int index = 0; index < cols.length; index++ ) |
||
67 | { |
||
68 | if ( cols[index] == 1 && filled_cell_11 ) |
||
69 | { |
||
70 | continue;
|
||
71 | } |
||
72 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
73 | } |
||
74 | |||
75 | for( int index = 0; index < rows.length; index++ ) |
||
76 | { |
||
77 | if ( rows[index] == 1 && filled_cell_11 ) |
||
78 | { |
||
79 | continue;
|
||
80 | } |
||
81 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
82 | } |
||
83 | |||
84 | } |
||
85 | |||
86 | /**
|
||
87 | * Helper method to load an image file from the CLASSPATH
|
||
88 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
89 | * @return an ImageIcon instance with the specified image file
|
||
90 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
91 | */
|
||
92 | public ImageIcon loadImage( String imageName ) |
||
93 | { |
||
94 | try
|
||
95 | { |
||
96 | ClassLoader classloader = getClass().getClassLoader();
|
||
97 | java.net.URL url = classloader.getResource( imageName ); |
||
98 | if ( url != null ) |
||
99 | { |
||
100 | ImageIcon icon = new ImageIcon( url ); |
||
101 | return icon;
|
||
102 | } |
||
103 | } |
||
104 | catch( Exception e ) |
||
105 | { |
||
106 | e.printStackTrace(); |
||
107 | } |
||
108 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * Method for recalculating the component orientation for
|
||
113 | * right-to-left Locales.
|
||
114 | * @param orientation the component orientation to be applied
|
||
115 | */
|
||
116 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
117 | { |
||
118 | // Not yet implemented...
|
||
119 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
120 | super.applyComponentOrientation(orientation);
|
||
121 | } |
||
122 | |||
123 | public JPanel createPanel() |
||
124 | { |
||
125 | JPanel jpanel1 = new JPanel(); |
||
126 | 2067 | jolivas | FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0)"); |
127 | 688 | jjdelcerro | CellConstraints cc = new CellConstraints();
|
128 | jpanel1.setLayout(formlayout1); |
||
129 | |||
130 | 2067 | jolivas | tabCreateRulePanel.setName("tabCreateRulePanel");
|
131 | tabCreateRulePanel.addTab("General",null,createPanel1()); |
||
132 | tabCreateRulePanel.addTab("Parametros",null,createPanel4()); |
||
133 | jpanel1.add(tabCreateRulePanel,cc.xy(2,2)); |
||
134 | |||
135 | addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2 }); |
||
136 | 688 | jjdelcerro | return jpanel1;
|
137 | } |
||
138 | |||
139 | public JPanel createPanel1() |
||
140 | { |
||
141 | JPanel jpanel1 = new JPanel(); |
||
142 | 2067 | jolivas | FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
143 | 688 | jjdelcerro | CellConstraints cc = new CellConstraints();
|
144 | jpanel1.setLayout(formlayout1); |
||
145 | |||
146 | 2067 | jolivas | jpanel1.add(createPanel2(),cc.xy(2,2)); |
147 | jpanel1.add(createPanel3(),cc.xy(4,2)); |
||
148 | addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3 }); |
||
149 | return jpanel1;
|
||
150 | } |
||
151 | |||
152 | public JPanel createPanel2() |
||
153 | { |
||
154 | JPanel jpanel1 = new JPanel(); |
||
155 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
||
156 | CellConstraints cc = new CellConstraints();
|
||
157 | jpanel1.setLayout(formlayout1); |
||
158 | |||
159 | cboDataSet2.setEnabled(false);
|
||
160 | cboDataSet2.setName("cboDataSet2");
|
||
161 | jpanel1.add(cboDataSet2,cc.xy(1,11)); |
||
162 | |||
163 | lblDataSet2.setName("lblDataSet2");
|
||
164 | lblDataSet2.setText("_Secondary_dataset");
|
||
165 | jpanel1.add(lblDataSet2,cc.xy(1,9)); |
||
166 | |||
167 | 688 | jjdelcerro | txtTolerance.setName("txtTolerance");
|
168 | txtTolerance.setHorizontalAlignment(JTextField.RIGHT);
|
||
169 | jpanel1.add(txtTolerance,cc.xy(1,15)); |
||
170 | |||
171 | 2067 | jolivas | lblTolerance.setName("lblTolerance");
|
172 | lblTolerance.setText("_Tolerance");
|
||
173 | jpanel1.add(lblTolerance,cc.xy(1,13)); |
||
174 | 688 | jjdelcerro | |
175 | 2067 | jolivas | cboRule.setEnabled(false);
|
176 | cboRule.setName("cboRule");
|
||
177 | jpanel1.add(cboRule,cc.xy(1,7)); |
||
178 | 688 | jjdelcerro | |
179 | lblRule.setName("lblRule");
|
||
180 | lblRule.setText("_Rule");
|
||
181 | jpanel1.add(lblRule,cc.xy(1,5)); |
||
182 | |||
183 | 2067 | jolivas | cboDataSet1.setName("cboDataSet1");
|
184 | jpanel1.add(cboDataSet1,cc.xy(1,3)); |
||
185 | 688 | jjdelcerro | |
186 | 2067 | jolivas | lblDataSet1.setName("lblDataSet1");
|
187 | lblDataSet1.setText("_Primary_dataset");
|
||
188 | jpanel1.add(lblDataSet1,cc.xy(1,1)); |
||
189 | 688 | jjdelcerro | |
190 | 2067 | jolivas | addFillComponents(jpanel1,new int[0],new int[]{ 2,4,6,8,10,12,14,16,17,18,19 }); |
191 | 688 | jjdelcerro | return jpanel1;
|
192 | } |
||
193 | |||
194 | 2067 | jolivas | public JPanel createPanel3() |
195 | 688 | jjdelcerro | { |
196 | JPanel jpanel1 = new JPanel(); |
||
197 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.7)","FILL:DEFAULT:GROW(1.0)"); |
||
198 | CellConstraints cc = new CellConstraints();
|
||
199 | jpanel1.setLayout(formlayout1); |
||
200 | |||
201 | txtDescription.setName("txtDescription");
|
||
202 | JScrollPane jscrollpane1 = new JScrollPane(); |
||
203 | jscrollpane1.setViewportView(txtDescription); |
||
204 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
205 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
206 | 2067 | jolivas | jpanel1.add(jscrollpane1,new CellConstraints(1,1,1,1,CellConstraints.DEFAULT,CellConstraints.FILL)); |
207 | 688 | jjdelcerro | |
208 | addFillComponents(jpanel1,new int[0],new int[0]); |
||
209 | return jpanel1;
|
||
210 | } |
||
211 | |||
212 | 2067 | jolivas | public JPanel createPanel4() |
213 | { |
||
214 | JPanel jpanel1 = new JPanel(); |
||
215 | FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
||
216 | CellConstraints cc = new CellConstraints();
|
||
217 | jpanel1.setLayout(formlayout1); |
||
218 | |||
219 | pnlParametros.setName("pnlParametros");
|
||
220 | jpanel1.add(pnlParametros,cc.xy(2,2)); |
||
221 | |||
222 | addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
||
223 | return jpanel1;
|
||
224 | } |
||
225 | |||
226 | 688 | jjdelcerro | /**
|
227 | * Initializer
|
||
228 | */
|
||
229 | protected void initializePanel() |
||
230 | { |
||
231 | setLayout(new BorderLayout()); |
||
232 | add(createPanel(), BorderLayout.CENTER);
|
||
233 | } |
||
234 | |||
235 | |||
236 | } |