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