23 |
23 |
*/
|
24 |
24 |
package org.gvsig.tools.dynform.services.dynformset.subform;
|
25 |
25 |
|
26 |
|
import com.sun.java.swing.plaf.motif.MotifBorders;
|
27 |
|
|
28 |
|
import java.awt.Color;
|
29 |
26 |
import java.awt.Cursor;
|
30 |
27 |
import java.awt.Dimension;
|
31 |
28 |
import java.awt.FlowLayout;
|
32 |
29 |
import java.awt.event.MouseAdapter;
|
33 |
30 |
import java.awt.event.MouseEvent;
|
34 |
31 |
import java.net.URL;
|
|
32 |
import java.util.ArrayList;
|
35 |
33 |
import java.util.HashSet;
|
36 |
34 |
import java.util.Iterator;
|
|
35 |
import java.util.List;
|
37 |
36 |
import java.util.Set;
|
|
37 |
import javax.swing.Action;
|
|
38 |
import javax.swing.BorderFactory;
|
38 |
39 |
|
39 |
|
import javax.swing.BorderFactory;
|
40 |
40 |
import javax.swing.Icon;
|
41 |
41 |
import javax.swing.ImageIcon;
|
|
42 |
import javax.swing.JButton;
|
42 |
43 |
import javax.swing.JComponent;
|
43 |
44 |
import javax.swing.JLabel;
|
44 |
45 |
import javax.swing.JPanel;
|
45 |
46 |
import javax.swing.SwingConstants;
|
46 |
|
import javax.swing.border.BevelBorder;
|
47 |
47 |
|
48 |
48 |
import org.gvsig.tools.ToolsLocator;
|
49 |
49 |
import org.gvsig.tools.i18n.I18nManager;
|
... | ... | |
90 |
90 |
private Set listeners = null;
|
91 |
91 |
private int current = 0;
|
92 |
92 |
private int numrecords = 0;
|
93 |
|
|
|
93 |
|
|
94 |
private JPanel othersButtons;
|
|
95 |
private List<Action> otherActions;
|
|
96 |
|
94 |
97 |
private boolean readOnly = false;
|
95 |
98 |
|
96 |
99 |
|
... | ... | |
104 |
107 |
this.activatedActions[i]=true;
|
105 |
108 |
}
|
106 |
109 |
this.listeners = new HashSet();
|
|
110 |
this.otherActions = new ArrayList<>();
|
107 |
111 |
}
|
108 |
112 |
|
109 |
113 |
public JComponent asJComponent() {
|
... | ... | |
231 |
235 |
}
|
232 |
236 |
|
233 |
237 |
private void initComponents() {
|
234 |
|
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
235 |
238 |
this.contents = new JPanel();
|
236 |
|
//this.contents.setBorder(BorderFactory.createLineBorder(Color.GRAY));
|
237 |
239 |
this.contents.setLayout( new FlowLayout(FlowLayout.LEADING, 4,4));
|
238 |
|
// this.contents.setBorder( BorderFactory.createLineBorder(Color.GRAY, 1));
|
|
240 |
|
|
241 |
this.contents.add(getStandardButtonBar());
|
|
242 |
|
|
243 |
this.othersButtons = new JPanel();
|
|
244 |
this.othersButtons.setLayout( new FlowLayout(FlowLayout.LEADING, 4,4));
|
|
245 |
this.contents.add(this.othersButtons);
|
239 |
246 |
|
|
247 |
for( Action action : this.otherActions ) {
|
|
248 |
this.othersButtons.add(new JButton(action));
|
|
249 |
}
|
|
250 |
|
|
251 |
this.contents.add(createButton("Close", "close.png", ActionClose));
|
|
252 |
this.initButtons();
|
|
253 |
this.updateRecords();
|
|
254 |
}
|
|
255 |
|
|
256 |
private JPanel getStandardButtonBar() {
|
|
257 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
258 |
JPanel contents = new JPanel();
|
|
259 |
contents.setLayout( new FlowLayout(FlowLayout.LEADING, 4,4));
|
|
260 |
|
240 |
261 |
JComponent firstButton = createButton(i18nManager.getTranslation("_first"), "first.png", ActionFirst);
|
241 |
|
this.contents.add(firstButton);
|
242 |
|
this.contents.add(createButton(i18nManager.getTranslation("_back"), "previous.png", ActionPrevious));
|
|
262 |
contents.add(firstButton);
|
|
263 |
contents.add(createButton(i18nManager.getTranslation("_back"), "previous.png", ActionPrevious));
|
243 |
264 |
|
244 |
265 |
this.records = new JLabel();
|
245 |
266 |
int height = this.records.getFont().getSize();
|
... | ... | |
248 |
269 |
}
|
249 |
270 |
this.records.setPreferredSize(new Dimension(COUNTER_WIDTH, height));
|
250 |
271 |
this.records.setHorizontalAlignment( SwingConstants.CENTER );
|
251 |
|
//this.records.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
252 |
|
this.contents.add(this.records);
|
|
272 |
contents.add(this.records);
|
253 |
273 |
|
254 |
|
this.contents.add(createButton(i18nManager.getTranslation("_next"), "next.png", ActionNext));
|
255 |
|
this.contents.add(createButton(i18nManager.getTranslation("_last"), "last.png", ActionLast));
|
|
274 |
contents.add(createButton(i18nManager.getTranslation("_next"), "next.png", ActionNext));
|
|
275 |
contents.add(createButton(i18nManager.getTranslation("_last"), "last.png", ActionLast));
|
256 |
276 |
|
257 |
|
this.contents.add(createButton(i18nManager.getTranslation("guardar"), "save.png", ActionSave));
|
258 |
|
this.contents.add(createButton(i18nManager.getTranslation("nuevo"), "new.png", ActionNew));
|
259 |
|
this.contents.add(createButton(i18nManager.getTranslation("borrar"), "delete.png", ActionDelete));
|
260 |
|
this.contents.add(createButton(i18nManager.getTranslation("search"), "search.png", ActionSearch));
|
|
277 |
contents.add(createButton(i18nManager.getTranslation("guardar"), "save.png", ActionSave));
|
|
278 |
contents.add(createButton(i18nManager.getTranslation("nuevo"), "new.png", ActionNew));
|
|
279 |
contents.add(createButton(i18nManager.getTranslation("borrar"), "delete.png", ActionDelete));
|
|
280 |
contents.add(createButton(i18nManager.getTranslation("search"), "search.png", ActionSearch));
|
|
281 |
|
|
282 |
return contents;
|
|
283 |
}
|
261 |
284 |
|
262 |
|
this.contents.add(createButton("Close", "close.png", ActionClose));
|
263 |
|
this.initButtons();
|
264 |
|
this.updateRecords();
|
265 |
|
}
|
266 |
|
|
267 |
285 |
private void initButtons() {
|
268 |
286 |
setActionActive(ActionSave, isActionActive(ActionSave));
|
269 |
287 |
setActionActive(ActionNew, isActionActive(ActionNew));
|
... | ... | |
339 |
357 |
}
|
340 |
358 |
}
|
341 |
359 |
}
|
|
360 |
|
|
361 |
public void addAction(Action action) {
|
|
362 |
this.otherActions.add(action);
|
|
363 |
if( this.contents == null ) {
|
|
364 |
return;
|
|
365 |
}
|
|
366 |
JButton button = new JButton(action);
|
|
367 |
button.setBorder(BorderFactory.createEmptyBorder());
|
|
368 |
this.othersButtons.add(button);
|
|
369 |
}
|
342 |
370 |
|
343 |
371 |
}
|