01: package org.enhydra.jawe.base.panel.panels;
02:
03: import java.util.List;
04:
05: import javax.swing.ListSelectionModel;
06: import javax.swing.event.ListSelectionEvent;
07: import javax.swing.event.ListSelectionListener;
08:
09: import org.enhydra.jawe.JaWEManager;
10: import org.enhydra.jawe.base.panel.PanelContainer;
11: import org.enhydra.shark.xpdl.XMLCollection;
12: import org.enhydra.shark.xpdl.XMLElement;
13:
14: /**
15: * Creates a table panel.
16: *
17: * @author Sasa Bojanic
18: * @author Zoran Milakovic
19: * @author Miroslav Popov
20: */
21: public class XMLSimpleTableSelPanel extends XMLSimpleTablePanel {
22:
23: public XMLSimpleTableSelPanel(PanelContainer pc,
24: XMLCollection myOwner, List columnsToShow,
25: List elementsToShow, String title, boolean hasBorder,
26: boolean hasEmptyBorder, boolean automaticWidth) {
27: super (pc, myOwner, columnsToShow, elementsToShow, title,
28: hasBorder, hasEmptyBorder, automaticWidth);
29:
30: }
31:
32: protected void setupTable(boolean automaticWidth) {
33: super .setupTable(automaticWidth);
34:
35: // selection listener for sending selection event
36: ListSelectionModel lsm = allItems.getSelectionModel();
37: lsm.addListSelectionListener(new ListSelectionListener() {
38: public void valueChanged(ListSelectionEvent e) {
39: // Ignore extra messages.
40: if (e.getValueIsAdjusting())
41: return;
42:
43: ListSelectionModel ls = (ListSelectionModel) e
44: .getSource();
45: if (ls.isSelectionEmpty()) {
46:
47: } else {
48: try {
49: XMLElement el = getSelectedElement();
50: if (el != null) {
51: JaWEManager.getInstance()
52: .getJaWEController()
53: .getSelectionManager()
54: .setSelection(el, true);
55: }
56: } catch (Exception ex) {
57: }
58: }
59: }
60: });
61:
62: }
63:
64: }
|