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 / SelectAttributesPanelView.java @ 44497
History | View | Annotate | Download (7.15 KB)
1 | 43925 | jjdelcerro | package org.gvsig.export.swing.impl.panels; |
---|---|---|---|
2 | 44408 | jjdelcerro | |
3 | 44395 | omartinez | import com.jeta.open.i18n.I18NUtils; |
4 | 43925 | jjdelcerro | 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 | 44408 | jjdelcerro | import javax.swing.JButton; |
13 | 43925 | jjdelcerro | import javax.swing.JFrame; |
14 | import javax.swing.JLabel; |
||
15 | import javax.swing.JPanel; |
||
16 | import javax.swing.JScrollPane; |
||
17 | 44270 | omartinez | import javax.swing.JTable; |
18 | 44408 | jjdelcerro | import javax.swing.JTextField; |
19 | import javax.swing.border.EmptyBorder; |
||
20 | 43925 | jjdelcerro | |
21 | |||
22 | 44395 | omartinez | public class SelectAttributesPanelView extends JPanel |
23 | { |
||
24 | JLabel lblHeader = new JLabel(); |
||
25 | JPanel jplAttributes = new JPanel(); |
||
26 | JTable tblAttributes = new JTable(); |
||
27 | 44408 | jjdelcerro | JButton btnFilter = new JButton(); |
28 | JTextField txtFilter = new JTextField(); |
||
29 | JButton btnCheckAll = new JButton(); |
||
30 | JButton btnUncheckAll = new JButton(); |
||
31 | 43925 | jjdelcerro | |
32 | 44395 | omartinez | /**
|
33 | * Default constructor
|
||
34 | */
|
||
35 | public SelectAttributesPanelView()
|
||
36 | { |
||
37 | initializePanel(); |
||
38 | } |
||
39 | 43925 | jjdelcerro | |
40 | 44395 | omartinez | /**
|
41 | * Adds fill components to empty cells in the first row and first column of the grid.
|
||
42 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
43 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
44 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
45 | */
|
||
46 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
47 | { |
||
48 | Dimension filler = new Dimension(10,10); |
||
49 | 43925 | jjdelcerro | |
50 | 44395 | omartinez | boolean filled_cell_11 = false; |
51 | CellConstraints cc = new CellConstraints();
|
||
52 | if ( cols.length > 0 && rows.length > 0 ) |
||
53 | { |
||
54 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
55 | { |
||
56 | /** add a rigid area */
|
||
57 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
58 | filled_cell_11 = true;
|
||
59 | } |
||
60 | } |
||
61 | 43925 | jjdelcerro | |
62 | 44395 | omartinez | for( int index = 0; index < cols.length; index++ ) |
63 | { |
||
64 | if ( cols[index] == 1 && filled_cell_11 ) |
||
65 | { |
||
66 | continue;
|
||
67 | } |
||
68 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
69 | } |
||
70 | 43925 | jjdelcerro | |
71 | 44395 | omartinez | for( int index = 0; index < rows.length; index++ ) |
72 | { |
||
73 | if ( rows[index] == 1 && filled_cell_11 ) |
||
74 | { |
||
75 | continue;
|
||
76 | } |
||
77 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
78 | } |
||
79 | 43925 | jjdelcerro | |
80 | 44395 | omartinez | } |
81 | 43925 | jjdelcerro | |
82 | 44395 | omartinez | /**
|
83 | * Helper method to load an image file from the CLASSPATH
|
||
84 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
85 | * @return an ImageIcon instance with the specified image file
|
||
86 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
87 | */
|
||
88 | public ImageIcon loadImage( String imageName ) |
||
89 | { |
||
90 | try
|
||
91 | { |
||
92 | ClassLoader classloader = getClass().getClassLoader();
|
||
93 | java.net.URL url = classloader.getResource( imageName ); |
||
94 | if ( url != null ) |
||
95 | { |
||
96 | ImageIcon icon = new ImageIcon( url ); |
||
97 | return icon;
|
||
98 | } |
||
99 | } |
||
100 | catch( Exception e ) |
||
101 | { |
||
102 | e.printStackTrace(); |
||
103 | } |
||
104 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
105 | } |
||
106 | 43925 | jjdelcerro | |
107 | 44395 | omartinez | /**
|
108 | * Method for recalculating the component orientation for
|
||
109 | * right-to-left Locales.
|
||
110 | * @param orientation the component orientation to be applied
|
||
111 | */
|
||
112 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
113 | { |
||
114 | // Not yet implemented...
|
||
115 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
116 | super.applyComponentOrientation(orientation);
|
||
117 | } |
||
118 | 43925 | jjdelcerro | |
119 | 44395 | omartinez | public JPanel createPanel() |
120 | { |
||
121 | JPanel jpanel1 = new JPanel(); |
||
122 | 44408 | jjdelcerro | FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,FILL:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:53DLU:NONE,CENTER:2DLU:NONE"); |
123 | 44395 | omartinez | CellConstraints cc = new CellConstraints();
|
124 | jpanel1.setLayout(formlayout1); |
||
125 | 43925 | jjdelcerro | |
126 | 44395 | omartinez | lblHeader.setName("lblHeader");
|
127 | lblHeader.setText("_Select_name_type_size_and_attributes_to_export");
|
||
128 | 44408 | jjdelcerro | jpanel1.add(lblHeader,cc.xywh(2,2,2,1)); |
129 | 43925 | jjdelcerro | |
130 | 44395 | omartinez | jplAttributes.setAutoscrolls(true);
|
131 | jplAttributes.setName("jplAttributes");
|
||
132 | 44408 | jjdelcerro | jpanel1.add(jplAttributes,cc.xy(3,9)); |
133 | 43925 | jjdelcerro | |
134 | 44395 | omartinez | tblAttributes.setName("tblAttributes");
|
135 | 44408 | jjdelcerro | tblAttributes.setShowVerticalLines(false);
|
136 | 44395 | omartinez | JScrollPane jscrollpane1 = new JScrollPane(); |
137 | jscrollpane1.setViewportView(tblAttributes); |
||
138 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
139 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
140 | 44408 | jjdelcerro | jpanel1.add(jscrollpane1,cc.xy(3,6)); |
141 | 43925 | jjdelcerro | |
142 | 44408 | jjdelcerro | jpanel1.add(createPanel1(),cc.xy(3,4)); |
143 | jpanel1.add(createPanel2(),cc.xy(3,8)); |
||
144 | addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10 }); |
||
145 | 44395 | omartinez | return jpanel1;
|
146 | } |
||
147 | 43925 | jjdelcerro | |
148 | 44408 | jjdelcerro | public JPanel createPanel1() |
149 | { |
||
150 | JPanel jpanel1 = new JPanel(); |
||
151 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
||
152 | CellConstraints cc = new CellConstraints();
|
||
153 | jpanel1.setLayout(formlayout1); |
||
154 | |||
155 | btnFilter.setActionCommand("JButton");
|
||
156 | btnFilter.setIcon(loadImage("org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/resources/images/export-to/common-filter.png"));
|
||
157 | btnFilter.setName("btnFilter");
|
||
158 | EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
||
159 | btnFilter.setBorder(emptyborder1); |
||
160 | jpanel1.add(btnFilter,cc.xy(3,1)); |
||
161 | |||
162 | txtFilter.setName("txtFilter");
|
||
163 | jpanel1.add(txtFilter,cc.xy(1,1)); |
||
164 | |||
165 | addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
||
166 | return jpanel1;
|
||
167 | } |
||
168 | |||
169 | public JPanel createPanel2() |
||
170 | { |
||
171 | JPanel jpanel1 = new JPanel(); |
||
172 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE"); |
||
173 | CellConstraints cc = new CellConstraints();
|
||
174 | jpanel1.setLayout(formlayout1); |
||
175 | |||
176 | btnCheckAll.setActionCommand("JButton");
|
||
177 | btnCheckAll.setIcon(loadImage("org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/resources/images/export-to/common-check-on.png"));
|
||
178 | btnCheckAll.setName("btnCheckAll");
|
||
179 | EmptyBorder emptyborder1 = new EmptyBorder(0,0,0,0); |
||
180 | btnCheckAll.setBorder(emptyborder1); |
||
181 | jpanel1.add(btnCheckAll,cc.xy(1,1)); |
||
182 | |||
183 | btnUncheckAll.setActionCommand("JButton");
|
||
184 | btnUncheckAll.setIcon(loadImage("org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/resources/images/export-to/common-check-off.png"));
|
||
185 | btnUncheckAll.setName("btnUncheckAll");
|
||
186 | EmptyBorder emptyborder2 = new EmptyBorder(0,0,0,0); |
||
187 | btnUncheckAll.setBorder(emptyborder2); |
||
188 | jpanel1.add(btnUncheckAll,cc.xy(2,1)); |
||
189 | |||
190 | addFillComponents(jpanel1,new int[]{ 3 },new int[0]); |
||
191 | return jpanel1;
|
||
192 | } |
||
193 | |||
194 | 44395 | omartinez | /**
|
195 | * Initializer
|
||
196 | */
|
||
197 | protected void initializePanel() |
||
198 | { |
||
199 | setLayout(new BorderLayout()); |
||
200 | add(createPanel(), BorderLayout.CENTER);
|
||
201 | } |
||
202 | 43925 | jjdelcerro | |
203 | |||
204 | } |