svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / export / swing / impl / panels / SelectGeometryFieldPanelView.java @ 43925
History | View | Annotate | Download (5.85 KB)
1 |
package org.gvsig.export.swing.impl.panels; |
---|---|
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.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JRadioButton; |
18 |
|
19 |
|
20 |
public class SelectGeometryFieldPanelView extends JPanel |
21 |
{ |
22 |
JLabel lblSelectOfTheGeometryField = new JLabel(); |
23 |
JRadioButton rdoUseTheGeometryFieldByDefault = new JRadioButton(); |
24 |
ButtonGroup buttongroup1 = new ButtonGroup(); |
25 |
JRadioButton rdoUseNullAsTheValueOfTheGeometry = new JRadioButton(); |
26 |
JRadioButton rdoSelectTheFieldToBeUsedAsGeometry = new JRadioButton(); |
27 |
JComboBox cboGeometryField = new JComboBox(); |
28 |
|
29 |
/**
|
30 |
* Default constructor
|
31 |
*/
|
32 |
public SelectGeometryFieldPanelView()
|
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:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
120 |
CellConstraints cc = new CellConstraints();
|
121 |
jpanel1.setLayout(formlayout1); |
122 |
|
123 |
lblSelectOfTheGeometryField.setName("lblSelectOfTheGeometryField");
|
124 |
lblSelectOfTheGeometryField.setText("_Selection_of_the_geometry_field");
|
125 |
jpanel1.add(lblSelectOfTheGeometryField,cc.xywh(2,2,2,1)); |
126 |
|
127 |
rdoUseTheGeometryFieldByDefault.setActionCommand("_Use_the_geometry_field_by_default");
|
128 |
rdoUseTheGeometryFieldByDefault.setName("rdoUseTheGeometryFieldByDefault");
|
129 |
rdoUseTheGeometryFieldByDefault.setText("_Use_the_geometry_field_by_default");
|
130 |
buttongroup1.add(rdoUseTheGeometryFieldByDefault); |
131 |
jpanel1.add(rdoUseTheGeometryFieldByDefault,cc.xywh(2,4,2,1)); |
132 |
|
133 |
rdoUseNullAsTheValueOfTheGeometry.setActionCommand("_Use_null_as_the_value_of_the_geometry");
|
134 |
rdoUseNullAsTheValueOfTheGeometry.setName("rdoUseNullAsTheValueOfTheGeometry");
|
135 |
rdoUseNullAsTheValueOfTheGeometry.setText("_Use_null_as_the_value_of_the_geometry");
|
136 |
buttongroup1.add(rdoUseNullAsTheValueOfTheGeometry); |
137 |
jpanel1.add(rdoUseNullAsTheValueOfTheGeometry,cc.xywh(2,6,2,1)); |
138 |
|
139 |
rdoSelectTheFieldToBeUsedAsGeometry.setActionCommand("_Select_the_field_to_be_used_as_geometry");
|
140 |
rdoSelectTheFieldToBeUsedAsGeometry.setName("rdoSelectTheFieldToBeUsedAsGeometry");
|
141 |
rdoSelectTheFieldToBeUsedAsGeometry.setText("_Select_the_field_to_be_used_as_geometry");
|
142 |
buttongroup1.add(rdoSelectTheFieldToBeUsedAsGeometry); |
143 |
jpanel1.add(rdoSelectTheFieldToBeUsedAsGeometry,cc.xywh(2,8,2,1)); |
144 |
|
145 |
cboGeometryField.setName("cboGeometryField");
|
146 |
jpanel1.add(cboGeometryField,cc.xy(3,10)); |
147 |
|
148 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 }); |
149 |
return jpanel1;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* Initializer
|
154 |
*/
|
155 |
protected void initializePanel() |
156 |
{ |
157 |
setLayout(new BorderLayout()); |
158 |
add(createPanel(), BorderLayout.CENTER);
|
159 |
} |
160 |
|
161 |
|
162 |
} |