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