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 @ 2726
History | View | Annotate | Download (7.47 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 |
|
41 |
/**
|
42 |
* Default constructor
|
43 |
*/
|
44 |
public VCSGisJCheckoutView()
|
45 |
{ |
46 |
initializePanel(); |
47 |
} |
48 |
|
49 |
/**
|
50 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
51 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
52 |
* @param cols an array of column indices in the first row where fill components should be added.
|
53 |
* @param rows an array of row indices in the first column where fill components should be added.
|
54 |
*/
|
55 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
56 |
{ |
57 |
Dimension filler = new Dimension(10,10); |
58 |
|
59 |
boolean filled_cell_11 = false; |
60 |
CellConstraints cc = new CellConstraints();
|
61 |
if ( cols.length > 0 && rows.length > 0 ) |
62 |
{ |
63 |
if ( cols[0] == 1 && rows[0] == 1 ) |
64 |
{ |
65 |
/** add a rigid area */
|
66 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
67 |
filled_cell_11 = true;
|
68 |
} |
69 |
} |
70 |
|
71 |
for( int index = 0; index < cols.length; index++ ) |
72 |
{ |
73 |
if ( cols[index] == 1 && filled_cell_11 ) |
74 |
{ |
75 |
continue;
|
76 |
} |
77 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
78 |
} |
79 |
|
80 |
for( int index = 0; index < rows.length; index++ ) |
81 |
{ |
82 |
if ( rows[index] == 1 && filled_cell_11 ) |
83 |
{ |
84 |
continue;
|
85 |
} |
86 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
87 |
} |
88 |
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* Helper method to load an image file from the CLASSPATH
|
93 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
94 |
* @return an ImageIcon instance with the specified image file
|
95 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
96 |
*/
|
97 |
public ImageIcon loadImage( String imageName ) |
98 |
{ |
99 |
try
|
100 |
{ |
101 |
ClassLoader classloader = getClass().getClassLoader();
|
102 |
java.net.URL url = classloader.getResource( imageName ); |
103 |
if ( url != null ) |
104 |
{ |
105 |
ImageIcon icon = new ImageIcon( url ); |
106 |
return icon;
|
107 |
} |
108 |
} |
109 |
catch( Exception e ) |
110 |
{ |
111 |
e.printStackTrace(); |
112 |
} |
113 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* Method for recalculating the component orientation for
|
118 |
* right-to-left Locales.
|
119 |
* @param orientation the component orientation to be applied
|
120 |
*/
|
121 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
122 |
{ |
123 |
// Not yet implemented...
|
124 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
125 |
super.applyComponentOrientation(orientation);
|
126 |
} |
127 |
|
128 |
public JPanel createPanel() |
129 |
{ |
130 |
JPanel jpanel1 = new JPanel(); |
131 |
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"); |
132 |
CellConstraints cc = new CellConstraints();
|
133 |
jpanel1.setLayout(formlayout1); |
134 |
|
135 |
lblWorkspace.setName("lblWorkspace");
|
136 |
lblWorkspace.setText("_workspace");
|
137 |
jpanel1.add(lblWorkspace,cc.xy(2,2)); |
138 |
|
139 |
cboWorkspaces.setName("cboWorkspaces");
|
140 |
jpanel1.add(cboWorkspaces,cc.xy(4,2)); |
141 |
|
142 |
btnInitWorkspace.setActionCommand("...");
|
143 |
btnInitWorkspace.setName("btnInitWorkspace");
|
144 |
btnInitWorkspace.setText("...");
|
145 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
146 |
btnInitWorkspace.setBorder(emptyborder1); |
147 |
jpanel1.add(btnInitWorkspace,cc.xy(6,2)); |
148 |
|
149 |
lblTable.setName("lblTable");
|
150 |
lblTable.setText("_table");
|
151 |
jpanel1.add(lblTable,cc.xy(2,4)); |
152 |
|
153 |
txtFilter.setName("txtFilter");
|
154 |
jpanel1.add(txtFilter,cc.xywh(2,6,3,1)); |
155 |
|
156 |
lstTables.setName("lstTables");
|
157 |
JScrollPane jscrollpane1 = new JScrollPane(); |
158 |
jscrollpane1.setViewportView(lstTables); |
159 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
160 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
161 |
jpanel1.add(jscrollpane1,cc.xywh(2,8,5,1)); |
162 |
|
163 |
rdbEffectiveDate.setActionCommand("_branch");
|
164 |
rdbEffectiveDate.setEnabled(false);
|
165 |
rdbEffectiveDate.setName("rdbEffectiveDate");
|
166 |
rdbEffectiveDate.setText("_Effective_date");
|
167 |
buttongroup1.add(rdbEffectiveDate); |
168 |
jpanel1.add(rdbEffectiveDate,cc.xywh(2,10,5,1)); |
169 |
|
170 |
rdbRevision.setActionCommand("_revision");
|
171 |
rdbRevision.setName("rdbRevision");
|
172 |
rdbRevision.setText("_revision");
|
173 |
buttongroup1.add(rdbRevision); |
174 |
jpanel1.add(rdbRevision,cc.xywh(2,14,5,1)); |
175 |
|
176 |
lstRevisions.setName("lstRevisions");
|
177 |
JScrollPane jscrollpane2 = new JScrollPane(); |
178 |
jscrollpane2.setViewportView(lstRevisions); |
179 |
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
180 |
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
181 |
jpanel1.add(jscrollpane2,cc.xy(4,16)); |
182 |
|
183 |
btnTable.setActionCommand("...");
|
184 |
btnTable.setName("btnTable");
|
185 |
btnTable.setText("...");
|
186 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
187 |
btnTable.setBorder(emptyborder2); |
188 |
jpanel1.add(btnTable,cc.xy(6,6)); |
189 |
|
190 |
txtEffectiveDate.setEnabled(false);
|
191 |
txtEffectiveDate.setName("txtEffectiveDate");
|
192 |
jpanel1.add(txtEffectiveDate,cc.xy(4,12)); |
193 |
|
194 |
btnEffectiveDate.setActionCommand("...");
|
195 |
btnEffectiveDate.setEnabled(false);
|
196 |
btnEffectiveDate.setName("btnEffectiveDate");
|
197 |
btnEffectiveDate.setText("...");
|
198 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
199 |
btnEffectiveDate.setBorder(emptyborder3); |
200 |
jpanel1.add(btnEffectiveDate,cc.xy(6,12)); |
201 |
|
202 |
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 }); |
203 |
return jpanel1;
|
204 |
} |
205 |
|
206 |
/**
|
207 |
* Initializer
|
208 |
*/
|
209 |
protected void initializePanel() |
210 |
{ |
211 |
setLayout(new BorderLayout()); |
212 |
add(createPanel(), BorderLayout.CENTER);
|
213 |
} |
214 |
|
215 |
|
216 |
} |