svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / workspace / WorkspaceConfigurationPanelView.java @ 44297
History | View | Annotate | Download (8.58 KB)
1 |
package org.gvsig.geodb.workspace; |
---|---|
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.JButton; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
|
18 |
|
19 |
public class WorkspaceConfigurationPanelView extends JPanel |
20 |
{ |
21 |
JButton btnCreateResourceTable = new JButton(); |
22 |
JButton btnDropResourceTable = new JButton(); |
23 |
JButton btnSearchResourceTable = new JButton(); |
24 |
JButton btnShowResourceTable = new JButton(); |
25 |
JButton jbutton1 = new JButton(); |
26 |
JButton jbutton2 = new JButton(); |
27 |
JButton jbutton3 = new JButton(); |
28 |
JButton jbutton4 = new JButton(); |
29 |
JComboBox cboConnections = new JComboBox(); |
30 |
JButton btnAddConnection = new JButton(); |
31 |
|
32 |
/**
|
33 |
* Default constructor
|
34 |
*/
|
35 |
public WorkspaceConfigurationPanelView()
|
36 |
{ |
37 |
initializePanel(); |
38 |
} |
39 |
|
40 |
/**
|
41 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
42 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
43 |
* @param cols an array of column indices in the first row where fill components should be added.
|
44 |
* @param rows an array of row indices in the first column where fill components should be added.
|
45 |
*/
|
46 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
47 |
{ |
48 |
Dimension filler = new Dimension(10,10); |
49 |
|
50 |
boolean filled_cell_11 = false; |
51 |
CellConstraints cc = new CellConstraints();
|
52 |
if ( cols.length > 0 && rows.length > 0 ) |
53 |
{ |
54 |
if ( cols[0] == 1 && rows[0] == 1 ) |
55 |
{ |
56 |
/** add a rigid area */
|
57 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
58 |
filled_cell_11 = true;
|
59 |
} |
60 |
} |
61 |
|
62 |
for( int index = 0; index < cols.length; index++ ) |
63 |
{ |
64 |
if ( cols[index] == 1 && filled_cell_11 ) |
65 |
{ |
66 |
continue;
|
67 |
} |
68 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
69 |
} |
70 |
|
71 |
for( int index = 0; index < rows.length; index++ ) |
72 |
{ |
73 |
if ( rows[index] == 1 && filled_cell_11 ) |
74 |
{ |
75 |
continue;
|
76 |
} |
77 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
78 |
} |
79 |
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Helper method to load an image file from the CLASSPATH
|
84 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
85 |
* @return an ImageIcon instance with the specified image file
|
86 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
87 |
*/
|
88 |
public ImageIcon loadImage( String imageName ) |
89 |
{ |
90 |
try
|
91 |
{ |
92 |
ClassLoader classloader = getClass().getClassLoader();
|
93 |
java.net.URL url = classloader.getResource( imageName ); |
94 |
if ( url != null ) |
95 |
{ |
96 |
ImageIcon icon = new ImageIcon( url ); |
97 |
return icon;
|
98 |
} |
99 |
} |
100 |
catch( Exception e ) |
101 |
{ |
102 |
e.printStackTrace(); |
103 |
} |
104 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Method for recalculating the component orientation for
|
109 |
* right-to-left Locales.
|
110 |
* @param orientation the component orientation to be applied
|
111 |
*/
|
112 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
113 |
{ |
114 |
// Not yet implemented...
|
115 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
116 |
super.applyComponentOrientation(orientation);
|
117 |
} |
118 |
|
119 |
public JPanel createPanel() |
120 |
{ |
121 |
JPanel jpanel1 = new JPanel(); |
122 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU: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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
123 |
CellConstraints cc = new CellConstraints();
|
124 |
jpanel1.setLayout(formlayout1); |
125 |
|
126 |
JLabel jlabel1 = new JLabel(); |
127 |
jlabel1.setText("Manage the gvSIG desktop resource table.");
|
128 |
jpanel1.add(jlabel1,cc.xy(2,5)); |
129 |
|
130 |
jpanel1.add(createPanel1(),cc.xy(2,7)); |
131 |
JLabel jlabel2 = new JLabel(); |
132 |
jlabel2.setText("Manage the gvSIG desktop table repository table.");
|
133 |
jpanel1.add(jlabel2,cc.xy(2,9)); |
134 |
|
135 |
jpanel1.add(createPanel2(),cc.xy(2,11)); |
136 |
JLabel jlabel3 = new JLabel(); |
137 |
jlabel3.setText("Manage the gvSIG desktop configuration table.");
|
138 |
jpanel1.add(jlabel3,cc.xy(2,13)); |
139 |
|
140 |
jpanel1.add(createPanel3(),cc.xy(2,15)); |
141 |
JLabel jlabel4 = new JLabel(); |
142 |
jlabel4.setText("Connection");
|
143 |
jpanel1.add(jlabel4,cc.xy(2,1)); |
144 |
|
145 |
jpanel1.add(createPanel4(),cc.xy(2,3)); |
146 |
addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }); |
147 |
return jpanel1;
|
148 |
} |
149 |
|
150 |
public JPanel createPanel1() |
151 |
{ |
152 |
JPanel jpanel1 = new JPanel(); |
153 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
154 |
CellConstraints cc = new CellConstraints();
|
155 |
jpanel1.setLayout(formlayout1); |
156 |
|
157 |
btnCreateResourceTable.setActionCommand("Create");
|
158 |
btnCreateResourceTable.setName("btnCreateResourceTable");
|
159 |
btnCreateResourceTable.setText("Create");
|
160 |
jpanel1.add(btnCreateResourceTable,cc.xy(4,1)); |
161 |
|
162 |
btnDropResourceTable.setActionCommand("Create");
|
163 |
btnDropResourceTable.setName("btnDropResourceTable");
|
164 |
btnDropResourceTable.setText("Drop");
|
165 |
jpanel1.add(btnDropResourceTable,cc.xy(2,1)); |
166 |
|
167 |
btnSearchResourceTable.setActionCommand("Edit");
|
168 |
btnSearchResourceTable.setName("btnSearchResourceTable");
|
169 |
btnSearchResourceTable.setText("Search");
|
170 |
jpanel1.add(btnSearchResourceTable,cc.xy(6,1)); |
171 |
|
172 |
btnShowResourceTable.setActionCommand("Edit");
|
173 |
btnShowResourceTable.setName("btnShowResourceTable");
|
174 |
btnShowResourceTable.setText("Show form");
|
175 |
jpanel1.add(btnShowResourceTable,cc.xy(8,1)); |
176 |
|
177 |
addFillComponents(jpanel1,new int[]{ 1,3,5,7 },new int[]{ 1 }); |
178 |
return jpanel1;
|
179 |
} |
180 |
|
181 |
public JPanel createPanel2() |
182 |
{ |
183 |
JPanel jpanel1 = new JPanel(); |
184 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
185 |
CellConstraints cc = new CellConstraints();
|
186 |
jpanel1.setLayout(formlayout1); |
187 |
|
188 |
jbutton1.setActionCommand("Edit");
|
189 |
jbutton1.setEnabled(false);
|
190 |
jbutton1.setText("Edit");
|
191 |
jpanel1.add(jbutton1,cc.xy(4,1)); |
192 |
|
193 |
jbutton2.setActionCommand("Create");
|
194 |
jbutton2.setEnabled(false);
|
195 |
jbutton2.setText("Create");
|
196 |
jpanel1.add(jbutton2,cc.xy(6,1)); |
197 |
|
198 |
addFillComponents(jpanel1,new int[]{ 1,2,3,5 },new int[]{ 1 }); |
199 |
return jpanel1;
|
200 |
} |
201 |
|
202 |
public JPanel createPanel3() |
203 |
{ |
204 |
JPanel jpanel1 = new JPanel(); |
205 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
206 |
CellConstraints cc = new CellConstraints();
|
207 |
jpanel1.setLayout(formlayout1); |
208 |
|
209 |
jbutton3.setActionCommand("Edit");
|
210 |
jbutton3.setEnabled(false);
|
211 |
jbutton3.setText("Edit");
|
212 |
jpanel1.add(jbutton3,cc.xy(4,1)); |
213 |
|
214 |
jbutton4.setActionCommand("Create");
|
215 |
jbutton4.setEnabled(false);
|
216 |
jbutton4.setText("Create");
|
217 |
jpanel1.add(jbutton4,cc.xy(6,1)); |
218 |
|
219 |
addFillComponents(jpanel1,new int[]{ 1,2,3,5 },new int[]{ 1 }); |
220 |
return jpanel1;
|
221 |
} |
222 |
|
223 |
public JPanel createPanel4() |
224 |
{ |
225 |
JPanel jpanel1 = new JPanel(); |
226 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
227 |
CellConstraints cc = new CellConstraints();
|
228 |
jpanel1.setLayout(formlayout1); |
229 |
|
230 |
cboConnections.setName("cboConnections");
|
231 |
jpanel1.add(cboConnections,cc.xy(1,1)); |
232 |
|
233 |
btnAddConnection.setActionCommand("...");
|
234 |
btnAddConnection.setName("btnAddConnection");
|
235 |
btnAddConnection.setText("...");
|
236 |
jpanel1.add(btnAddConnection,cc.xy(3,1)); |
237 |
|
238 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
239 |
return jpanel1;
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* Initializer
|
244 |
*/
|
245 |
protected void initializePanel() |
246 |
{ |
247 |
setLayout(new BorderLayout()); |
248 |
add(createPanel(), BorderLayout.CENTER);
|
249 |
} |
250 |
|
251 |
|
252 |
} |