svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / symboltables / functionPanels / firstlayerfeature / FirstLayerFeatureAditionalPanelView.java @ 44129
History | View | Annotate | Download (7.47 KB)
1 |
package org.gvsig.app.project.symboltables.functionPanels.firstlayerfeature; |
---|---|
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.Color; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import java.awt.Font; |
12 |
import javax.swing.Box; |
13 |
import javax.swing.ImageIcon; |
14 |
import javax.swing.JButton; |
15 |
import javax.swing.JComboBox; |
16 |
import javax.swing.JFrame; |
17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JTextField; |
20 |
import javax.swing.border.EmptyBorder; |
21 |
|
22 |
|
23 |
public class FirstLayerFeatureAditionalPanelView extends JPanel |
24 |
{ |
25 |
JComboBox cboViews = new JComboBox(); |
26 |
JComboBox cboLayers = new JComboBox(); |
27 |
JComboBox cboFields = new JComboBox(); |
28 |
JTextField txtPreview = new JTextField(); |
29 |
JButton btnInsertFunction = new JButton(); |
30 |
JTextField txtFilter = new JTextField(); |
31 |
JButton btnFilter = new JButton(); |
32 |
JPanel btnOrder = new JPanel(); |
33 |
JTextField txtOrder = new JTextField(); |
34 |
JButton jbutton1 = new JButton(); |
35 |
|
36 |
/**
|
37 |
* Default constructor
|
38 |
*/
|
39 |
public FirstLayerFeatureAditionalPanelView()
|
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 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
127 |
CellConstraints cc = new CellConstraints();
|
128 |
jpanel1.setLayout(formlayout1); |
129 |
|
130 |
JLabel jlabel1 = new JLabel(); |
131 |
jlabel1.setFont(new Font("Tahoma",Font.BOLD,11)); |
132 |
jlabel1.setText("FistLayerFeature");
|
133 |
jpanel1.add(jlabel1,cc.xywh(2,2,3,1)); |
134 |
|
135 |
cboViews.setName("cboViews");
|
136 |
jpanel1.add(cboViews,cc.xy(4,4)); |
137 |
|
138 |
JLabel jlabel2 = new JLabel(); |
139 |
jlabel2.setText("_View");
|
140 |
jpanel1.add(jlabel2,cc.xy(2,4)); |
141 |
|
142 |
JLabel jlabel3 = new JLabel(); |
143 |
jlabel3.setText("_Layer");
|
144 |
jpanel1.add(jlabel3,cc.xy(2,6)); |
145 |
|
146 |
cboLayers.setName("cboLayers");
|
147 |
jpanel1.add(cboLayers,cc.xy(4,6)); |
148 |
|
149 |
JLabel jlabel4 = new JLabel(); |
150 |
jlabel4.setText("_Field");
|
151 |
jpanel1.add(jlabel4,cc.xy(2,8)); |
152 |
|
153 |
cboFields.setName("cboFields");
|
154 |
jpanel1.add(cboFields,cc.xy(4,8)); |
155 |
|
156 |
JLabel jlabel5 = new JLabel(); |
157 |
jlabel5.setText("_Filter");
|
158 |
jpanel1.add(jlabel5,cc.xy(2,10)); |
159 |
|
160 |
JLabel jlabel6 = new JLabel(); |
161 |
jlabel6.setText("_Order");
|
162 |
jpanel1.add(jlabel6,cc.xy(2,12)); |
163 |
|
164 |
txtPreview.setBackground(new Color(236,233,216)); |
165 |
txtPreview.setEditable(false);
|
166 |
txtPreview.setName("txtPreview");
|
167 |
jpanel1.add(txtPreview,cc.xy(4,14)); |
168 |
|
169 |
btnInsertFunction.setActionCommand("_Insert_function");
|
170 |
btnInsertFunction.setName("btnInsertFunction");
|
171 |
btnInsertFunction.setText("_Insert_function");
|
172 |
jpanel1.add(btnInsertFunction,new CellConstraints(4,16,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
173 |
|
174 |
jpanel1.add(createPanel1(),cc.xy(4,10)); |
175 |
jpanel1.add(createbtnOrder(),cc.xy(4,12)); |
176 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }); |
177 |
return jpanel1;
|
178 |
} |
179 |
|
180 |
public JPanel createPanel1() |
181 |
{ |
182 |
JPanel jpanel1 = new JPanel(); |
183 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
184 |
CellConstraints cc = new CellConstraints();
|
185 |
jpanel1.setLayout(formlayout1); |
186 |
|
187 |
txtFilter.setName("txtFilter");
|
188 |
jpanel1.add(txtFilter,cc.xy(1,1)); |
189 |
|
190 |
btnFilter.setName("btnFilter");
|
191 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
192 |
btnFilter.setBorder(emptyborder1); |
193 |
jpanel1.add(btnFilter,cc.xy(3,1)); |
194 |
|
195 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
196 |
return jpanel1;
|
197 |
} |
198 |
|
199 |
public JPanel createbtnOrder() |
200 |
{ |
201 |
btnOrder.setName("btnOrder");
|
202 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
203 |
CellConstraints cc = new CellConstraints();
|
204 |
btnOrder.setLayout(formlayout1); |
205 |
|
206 |
txtOrder.setEnabled(false);
|
207 |
txtOrder.setName("txtOrder");
|
208 |
btnOrder.add(txtOrder,cc.xy(1,1)); |
209 |
|
210 |
jbutton1.setActionCommand("...");
|
211 |
jbutton1.setEnabled(false);
|
212 |
jbutton1.setText("...");
|
213 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
214 |
jbutton1.setBorder(emptyborder1); |
215 |
btnOrder.add(jbutton1,cc.xy(3,1)); |
216 |
|
217 |
addFillComponents(btnOrder,new int[]{ 2 },new int[0]); |
218 |
return btnOrder;
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* Initializer
|
223 |
*/
|
224 |
protected void initializePanel() |
225 |
{ |
226 |
setLayout(new BorderLayout()); |
227 |
add(createPanel(), BorderLayout.CENTER);
|
228 |
} |
229 |
|
230 |
|
231 |
} |