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