svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerWizardPanelView.java @ 43534
History | View | Annotate | Download (6.66 KB)
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing; |
---|---|
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.JFrame; |
14 |
import javax.swing.JPanel; |
15 |
import javax.swing.JScrollPane; |
16 |
import javax.swing.JTable; |
17 |
|
18 |
|
19 |
public class FilesystemExplorerWizardPanelView extends JPanel |
20 |
{ |
21 |
JTable tableFiles = new JTable(); |
22 |
JButton btnAdd = new JButton(); |
23 |
JButton btnProperties = new JButton(); |
24 |
JButton btnRemove = new JButton(); |
25 |
JButton btnUp = new JButton(); |
26 |
JButton btnDown = new JButton(); |
27 |
JButton btnChangeViewProjection = new JButton(); |
28 |
|
29 |
/**
|
30 |
* Default constructor
|
31 |
*/
|
32 |
public FilesystemExplorerWizardPanelView()
|
33 |
{ |
34 |
initializePanel(); |
35 |
} |
36 |
|
37 |
/**
|
38 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
39 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
40 |
* @param cols an array of column indices in the first row where fill components should be added.
|
41 |
* @param rows an array of row indices in the first column where fill components should be added.
|
42 |
*/
|
43 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
44 |
{ |
45 |
Dimension filler = new Dimension(10,10); |
46 |
|
47 |
boolean filled_cell_11 = false; |
48 |
CellConstraints cc = new CellConstraints();
|
49 |
if ( cols.length > 0 && rows.length > 0 ) |
50 |
{ |
51 |
if ( cols[0] == 1 && rows[0] == 1 ) |
52 |
{ |
53 |
/** add a rigid area */
|
54 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
55 |
filled_cell_11 = true;
|
56 |
} |
57 |
} |
58 |
|
59 |
for( int index = 0; index < cols.length; index++ ) |
60 |
{ |
61 |
if ( cols[index] == 1 && filled_cell_11 ) |
62 |
{ |
63 |
continue;
|
64 |
} |
65 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
66 |
} |
67 |
|
68 |
for( int index = 0; index < rows.length; index++ ) |
69 |
{ |
70 |
if ( rows[index] == 1 && filled_cell_11 ) |
71 |
{ |
72 |
continue;
|
73 |
} |
74 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
75 |
} |
76 |
|
77 |
} |
78 |
|
79 |
/**
|
80 |
* Helper method to load an image file from the CLASSPATH
|
81 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
82 |
* @return an ImageIcon instance with the specified image file
|
83 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
84 |
*/
|
85 |
public ImageIcon loadImage( String imageName ) |
86 |
{ |
87 |
try
|
88 |
{ |
89 |
ClassLoader classloader = getClass().getClassLoader();
|
90 |
java.net.URL url = classloader.getResource( imageName ); |
91 |
if ( url != null ) |
92 |
{ |
93 |
ImageIcon icon = new ImageIcon( url ); |
94 |
return icon;
|
95 |
} |
96 |
} |
97 |
catch( Exception e ) |
98 |
{ |
99 |
e.printStackTrace(); |
100 |
} |
101 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* Method for recalculating the component orientation for
|
106 |
* right-to-left Locales.
|
107 |
* @param orientation the component orientation to be applied
|
108 |
*/
|
109 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
110 |
{ |
111 |
// Not yet implemented...
|
112 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
113 |
super.applyComponentOrientation(orientation);
|
114 |
} |
115 |
|
116 |
public JPanel createPanel() |
117 |
{ |
118 |
JPanel jpanel1 = new JPanel(); |
119 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
120 |
CellConstraints cc = new CellConstraints();
|
121 |
jpanel1.setLayout(formlayout1); |
122 |
|
123 |
tableFiles.setName("tableFiles");
|
124 |
JScrollPane jscrollpane1 = new JScrollPane(); |
125 |
jscrollpane1.setViewportView(tableFiles); |
126 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
127 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
128 |
jpanel1.add(jscrollpane1,new CellConstraints(2,2,1,1,CellConstraints.DEFAULT,CellConstraints.FILL)); |
129 |
|
130 |
jpanel1.add(createPanel1(),new CellConstraints(4,2,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
131 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3 }); |
132 |
return jpanel1;
|
133 |
} |
134 |
|
135 |
public JPanel createPanel1() |
136 |
{ |
137 |
JPanel jpanel1 = new JPanel(); |
138 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT: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:DEFAULT:GROW(1.0)"); |
139 |
CellConstraints cc = new CellConstraints();
|
140 |
jpanel1.setLayout(formlayout1); |
141 |
|
142 |
btnAdd.setActionCommand("JButton");
|
143 |
btnAdd.setName("btnAdd");
|
144 |
btnAdd.setText("_add");
|
145 |
btnAdd.setToolTipText("_select_a_file_to_add_to_the_list");
|
146 |
jpanel1.add(btnAdd,cc.xy(1,1)); |
147 |
|
148 |
btnProperties.setActionCommand("JButton");
|
149 |
btnProperties.setName("btnProperties");
|
150 |
btnProperties.setText("_properties");
|
151 |
btnProperties.setToolTipText("_change_default_properties_to_load_the_selected_item");
|
152 |
jpanel1.add(btnProperties,cc.xy(1,3)); |
153 |
|
154 |
btnRemove.setActionCommand("JButton");
|
155 |
btnRemove.setName("btnRemove");
|
156 |
btnRemove.setText("_remove");
|
157 |
btnRemove.setToolTipText("_remove_the_selected_item_from_the_list");
|
158 |
jpanel1.add(btnRemove,cc.xy(1,5)); |
159 |
|
160 |
btnUp.setActionCommand("JButton");
|
161 |
btnUp.setName("btnUp");
|
162 |
btnUp.setText("_up");
|
163 |
btnUp.setToolTipText("_move_up_the_selected_item_in_the_list");
|
164 |
jpanel1.add(btnUp,cc.xy(1,7)); |
165 |
|
166 |
btnDown.setActionCommand("JButton");
|
167 |
btnDown.setName("btnDown");
|
168 |
btnDown.setText("_down");
|
169 |
btnDown.setToolTipText("_move_down_the_selected_item_in_the_list");
|
170 |
jpanel1.add(btnDown,cc.xy(1,9)); |
171 |
|
172 |
btnChangeViewProjection.setActionCommand("_Change_view_projection");
|
173 |
btnChangeViewProjection.setName("btnChangeViewProjection");
|
174 |
btnChangeViewProjection.setText("_Change_view_projection");
|
175 |
btnChangeViewProjection.setToolTipText("_Change_view_projection_to_projection_of_the_selected_item_in_the_list\n");
|
176 |
jpanel1.add(btnChangeViewProjection,cc.xy(1,11)); |
177 |
|
178 |
addFillComponents(jpanel1,new int[0],new int[]{ 2,4,6,8,10,12 }); |
179 |
return jpanel1;
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* Initializer
|
184 |
*/
|
185 |
protected void initializePanel() |
186 |
{ |
187 |
setLayout(new BorderLayout()); |
188 |
add(createPanel(), BorderLayout.CENTER);
|
189 |
} |
190 |
|
191 |
|
192 |
} |