svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / extension / reportfromlayout / ConfigureReportFromLayoutPanelView.java @ 1608
History | View | Annotate | Download (10.2 KB)
1 |
package org.gvsig.app.extension.reportfromlayout; |
---|---|
2 |
|
3 |
import com.jeta.forms.components.separator.TitledSeparator; |
4 |
import com.jeta.open.i18n.I18NUtils; |
5 |
import com.jgoodies.forms.layout.CellConstraints; |
6 |
import com.jgoodies.forms.layout.FormLayout; |
7 |
import java.awt.BorderLayout; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import javax.swing.Box; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JCheckBox; |
15 |
import javax.swing.JComboBox; |
16 |
import javax.swing.JFrame; |
17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JScrollPane; |
20 |
import javax.swing.JTextField; |
21 |
import javax.swing.JTree; |
22 |
|
23 |
|
24 |
public class ConfigureReportFromLayoutPanelView extends JPanel |
25 |
{ |
26 |
JLabel lblLayout = new JLabel(); |
27 |
JLabel lblSource = new JLabel(); |
28 |
JLabel lblReport = new JLabel(); |
29 |
JLabel lblIdentifier = new JLabel(); |
30 |
JLabel lblLabel = new JLabel(); |
31 |
JCheckBox chkUseInternalPdfViewer = new JCheckBox(); |
32 |
JComboBox cboLayout = new JComboBox(); |
33 |
JTree treeSource = new JTree(); |
34 |
JComboBox cboReport = new JComboBox(); |
35 |
JTextField txtIdentifier = new JTextField(); |
36 |
JTextField txtLabel = new JTextField(); |
37 |
TitledSeparator lblViewSeparator = new TitledSeparator();
|
38 |
JLabel lblView = new JLabel(); |
39 |
JComboBox cboView = new JComboBox(); |
40 |
JCheckBox chkHighlightRecord = new JCheckBox(); |
41 |
JCheckBox chkZoomToCurrentRow = new JCheckBox(); |
42 |
JLabel lblBufferSize = new JLabel(); |
43 |
JTextField txtBufferSize = new JTextField(); |
44 |
JCheckBox chkCenterToCurrentRow = new JCheckBox(); |
45 |
JLabel lblAppySymbolTo = new JLabel(); |
46 |
JComboBox cboApplySymbolTo = new JComboBox(); |
47 |
JButton btnSelectSymbol = new JButton(); |
48 |
|
49 |
/**
|
50 |
* Default constructor
|
51 |
*/
|
52 |
public ConfigureReportFromLayoutPanelView()
|
53 |
{ |
54 |
initializePanel(); |
55 |
} |
56 |
|
57 |
/**
|
58 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
59 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
60 |
* @param cols an array of column indices in the first row where fill components should be added.
|
61 |
* @param rows an array of row indices in the first column where fill components should be added.
|
62 |
*/
|
63 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
64 |
{ |
65 |
Dimension filler = new Dimension(10,10); |
66 |
|
67 |
boolean filled_cell_11 = false; |
68 |
CellConstraints cc = new CellConstraints();
|
69 |
if ( cols.length > 0 && rows.length > 0 ) |
70 |
{ |
71 |
if ( cols[0] == 1 && rows[0] == 1 ) |
72 |
{ |
73 |
/** add a rigid area */
|
74 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
75 |
filled_cell_11 = true;
|
76 |
} |
77 |
} |
78 |
|
79 |
for( int index = 0; index < cols.length; index++ ) |
80 |
{ |
81 |
if ( cols[index] == 1 && filled_cell_11 ) |
82 |
{ |
83 |
continue;
|
84 |
} |
85 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
86 |
} |
87 |
|
88 |
for( int index = 0; index < rows.length; index++ ) |
89 |
{ |
90 |
if ( rows[index] == 1 && filled_cell_11 ) |
91 |
{ |
92 |
continue;
|
93 |
} |
94 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
95 |
} |
96 |
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Helper method to load an image file from the CLASSPATH
|
101 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
102 |
* @return an ImageIcon instance with the specified image file
|
103 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
104 |
*/
|
105 |
public ImageIcon loadImage( String imageName ) |
106 |
{ |
107 |
try
|
108 |
{ |
109 |
ClassLoader classloader = getClass().getClassLoader();
|
110 |
java.net.URL url = classloader.getResource( imageName ); |
111 |
if ( url != null ) |
112 |
{ |
113 |
ImageIcon icon = new ImageIcon( url ); |
114 |
return icon;
|
115 |
} |
116 |
} |
117 |
catch( Exception e ) |
118 |
{ |
119 |
e.printStackTrace(); |
120 |
} |
121 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Method for recalculating the component orientation for
|
126 |
* right-to-left Locales.
|
127 |
* @param orientation the component orientation to be applied
|
128 |
*/
|
129 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
130 |
{ |
131 |
// Not yet implemented...
|
132 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
133 |
super.applyComponentOrientation(orientation);
|
134 |
} |
135 |
|
136 |
public JPanel createPanel() |
137 |
{ |
138 |
JPanel jpanel1 = new JPanel(); |
139 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:22DLU:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
140 |
CellConstraints cc = new CellConstraints();
|
141 |
jpanel1.setLayout(formlayout1); |
142 |
|
143 |
lblLayout.setName("lblLayout");
|
144 |
lblLayout.setText("_Layout_template");
|
145 |
jpanel1.add(lblLayout,cc.xy(2,2)); |
146 |
|
147 |
lblSource.setName("lblSource");
|
148 |
lblSource.setText("_Source");
|
149 |
lblSource.setVerticalAlignment(JLabel.TOP);
|
150 |
jpanel1.add(lblSource,new CellConstraints(2,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
151 |
|
152 |
lblReport.setName("lblReport");
|
153 |
lblReport.setText("_Report");
|
154 |
jpanel1.add(lblReport,cc.xy(2,6)); |
155 |
|
156 |
lblIdentifier.setName("lblIdentifier");
|
157 |
lblIdentifier.setText("_Identifier");
|
158 |
jpanel1.add(lblIdentifier,cc.xy(2,8)); |
159 |
|
160 |
lblLabel.setName("lblLabel");
|
161 |
lblLabel.setText("_Label");
|
162 |
jpanel1.add(lblLabel,cc.xy(2,10)); |
163 |
|
164 |
chkUseInternalPdfViewer.setActionCommand("_Center_to_current_row");
|
165 |
chkUseInternalPdfViewer.setName("chkUseInternalPdfViewer");
|
166 |
chkUseInternalPdfViewer.setText("_Use_internal_pdf_viewer");
|
167 |
chkUseInternalPdfViewer.setToolTipText("_Use_internal_pdf_viewer_description");
|
168 |
jpanel1.add(chkUseInternalPdfViewer,cc.xywh(2,22,3,1)); |
169 |
|
170 |
cboLayout.setName("cboLayout");
|
171 |
jpanel1.add(cboLayout,cc.xy(4,2)); |
172 |
|
173 |
treeSource.setName("treeSource");
|
174 |
treeSource.setRootVisible(false);
|
175 |
JScrollPane jscrollpane1 = new JScrollPane(); |
176 |
jscrollpane1.setViewportView(treeSource); |
177 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
178 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
179 |
jpanel1.add(jscrollpane1,new CellConstraints(4,4,1,1,CellConstraints.DEFAULT,CellConstraints.FILL)); |
180 |
|
181 |
cboReport.setName("cboReport");
|
182 |
jpanel1.add(cboReport,cc.xy(4,6)); |
183 |
|
184 |
txtIdentifier.setName("txtIdentifier");
|
185 |
jpanel1.add(txtIdentifier,cc.xy(4,8)); |
186 |
|
187 |
txtLabel.setName("txtLabel");
|
188 |
jpanel1.add(txtLabel,cc.xy(4,10)); |
189 |
|
190 |
lblViewSeparator.setName("lblViewSeparator");
|
191 |
lblViewSeparator.setText("_View");
|
192 |
jpanel1.add(lblViewSeparator,cc.xywh(2,12,3,1)); |
193 |
|
194 |
lblView.setName("lblView");
|
195 |
lblView.setText("_View");
|
196 |
jpanel1.add(lblView,cc.xy(2,14)); |
197 |
|
198 |
cboView.setName("cboView");
|
199 |
jpanel1.add(cboView,cc.xy(4,14)); |
200 |
|
201 |
chkHighlightRecord.setActionCommand("_Center_to_current_row");
|
202 |
chkHighlightRecord.setName("chkHighlightRecord");
|
203 |
chkHighlightRecord.setText("_Highlight_record");
|
204 |
chkHighlightRecord.setToolTipText("_Highlight_record_in_report");
|
205 |
jpanel1.add(chkHighlightRecord,cc.xy(2,16)); |
206 |
|
207 |
jpanel1.add(createPanel1(),cc.xywh(2,20,3,1)); |
208 |
chkCenterToCurrentRow.setActionCommand("_Center_to_current_row");
|
209 |
chkCenterToCurrentRow.setName("chkCenterToCurrentRow");
|
210 |
chkCenterToCurrentRow.setText("_Center_to_current_row");
|
211 |
chkCenterToCurrentRow.setToolTipText("_Center_to_current_row_description");
|
212 |
jpanel1.add(chkCenterToCurrentRow,cc.xywh(2,18,3,1)); |
213 |
|
214 |
jpanel1.add(createPanel2(),cc.xy(4,16)); |
215 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 }); |
216 |
return jpanel1;
|
217 |
} |
218 |
|
219 |
public JPanel createPanel1() |
220 |
{ |
221 |
JPanel jpanel1 = new JPanel(); |
222 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE"); |
223 |
CellConstraints cc = new CellConstraints();
|
224 |
jpanel1.setLayout(formlayout1); |
225 |
|
226 |
chkZoomToCurrentRow.setActionCommand("_Center_to_current_row");
|
227 |
chkZoomToCurrentRow.setName("chkZoomToCurrentRow");
|
228 |
chkZoomToCurrentRow.setText("_Zoom_to_current_row");
|
229 |
chkZoomToCurrentRow.setToolTipText("_Zoom_to_current_row_description");
|
230 |
jpanel1.add(chkZoomToCurrentRow,cc.xy(1,1)); |
231 |
|
232 |
lblBufferSize.setName("lblBufferSize");
|
233 |
lblBufferSize.setText("_Buffer_size");
|
234 |
lblBufferSize.setToolTipText("_Buffer_size_description");
|
235 |
jpanel1.add(lblBufferSize,cc.xy(3,1)); |
236 |
|
237 |
txtBufferSize.setName("txtBufferSize");
|
238 |
txtBufferSize.setToolTipText("_Buffer_size_description");
|
239 |
jpanel1.add(txtBufferSize,cc.xy(5,1)); |
240 |
|
241 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]); |
242 |
return jpanel1;
|
243 |
} |
244 |
|
245 |
public JPanel createPanel2() |
246 |
{ |
247 |
JPanel jpanel1 = new JPanel(); |
248 |
FormLayout formlayout1 = new FormLayout("FILL:22DLU:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:8DLU:GROW(1.0)","CENTER:DEFAULT:NONE"); |
249 |
CellConstraints cc = new CellConstraints();
|
250 |
jpanel1.setLayout(formlayout1); |
251 |
|
252 |
lblAppySymbolTo.setName("lblAppySymbolTo");
|
253 |
lblAppySymbolTo.setText("_Apply_symbol");
|
254 |
jpanel1.add(lblAppySymbolTo,cc.xy(3,1)); |
255 |
|
256 |
cboApplySymbolTo.setName("cboApplySymbolTo");
|
257 |
jpanel1.add(cboApplySymbolTo,cc.xy(5,1)); |
258 |
|
259 |
btnSelectSymbol.setActionCommand("...");
|
260 |
btnSelectSymbol.setName("btnSelectSymbol");
|
261 |
btnSelectSymbol.setText("...");
|
262 |
btnSelectSymbol.setToolTipText("_Select_symbol");
|
263 |
jpanel1.add(btnSelectSymbol,new CellConstraints(1,1,1,1,CellConstraints.FILL,CellConstraints.FILL)); |
264 |
|
265 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]); |
266 |
return jpanel1;
|
267 |
} |
268 |
|
269 |
/**
|
270 |
* Initializer
|
271 |
*/
|
272 |
protected void initializePanel() |
273 |
{ |
274 |
setLayout(new BorderLayout()); |
275 |
add(createPanel(), BorderLayout.CENTER);
|
276 |
} |
277 |
|
278 |
|
279 |
} |