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