01: /*
02: * Copyright 2004 JETA Software, Inc. All rights reserved.
03: * JETA SOFTWARE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
04: */
05:
06: package com.jeta.swingbuilder.gui.components.list;
07:
08: import java.awt.event.ActionEvent;
09: import java.awt.event.ActionListener;
10:
11: import javax.swing.JComponent;
12: import javax.swing.JTable;
13:
14: import com.jeta.forms.store.properties.ListItemProperty;
15: import com.jeta.open.gui.framework.JETADialog;
16: import com.jeta.open.gui.utils.JETAToolbox;
17: import com.jeta.open.i18n.I18N;
18: import com.jeta.swingbuilder.gui.utils.TableSupportHandler;
19:
20: public class ItemsController extends TableSupportHandler {
21: private ItemsView m_view;
22:
23: /** @link dependency */
24:
25: /* # ItemsViewNames lnkItemsViewNames; */
26:
27: public ItemsController(ItemsView view) {
28: super (view, ItemsViewNames.ID_ITEMS_TABLE,
29: ItemsViewNames.ID_DELETE_ITEM,
30: ItemsViewNames.ID_MOVE_UP, ItemsViewNames.ID_MOVE_DOWN);
31: m_view = view;
32: assignAction(ItemsViewNames.ID_ADD_ITEM, new AddItemAction());
33: assignAction(ItemsViewNames.ID_EDIT_ITEM, new EditItemAction());
34: }
35:
36: public class AddItemAction implements ActionListener {
37: public void actionPerformed(ActionEvent evt) {
38: JTable table = m_view
39: .getTable(ItemsViewNames.ID_ITEMS_TABLE);
40: ItemsModel tmodel = (ItemsModel) table.getModel();
41: ListItemView view = new ListItemView();
42: JETADialog dlg = JETAToolbox
43: .invokeDialog(
44: view,
45: m_view,
46: I18N.getLocalizedMessage("Item Properties"),
47: (JComponent) view
48: .getComponentByName(ListItemNames.ID_ITEM_LABEL));
49: if (dlg.isOk()) {
50: ListItemProperty lip = new ListItemProperty(view
51: .getLabel(), view.getIconProperty());
52: tmodel.addRow(lip);
53: }
54: }
55: }
56:
57: public class EditItemAction implements ActionListener {
58: public void actionPerformed(ActionEvent evt) {
59: ListItemProperty oldprop = m_view.getSelectedProperty();
60: if (oldprop != null) {
61: JTable table = m_view
62: .getTable(ItemsViewNames.ID_ITEMS_TABLE);
63: ItemsModel items_model = (ItemsModel) table.getModel();
64: ListItemView view = new ListItemView(
65: oldprop.getLabel(), oldprop.getIconProperty());
66: JETADialog dlg = JETAToolbox
67: .invokeDialog(
68: view,
69: m_view,
70: I18N
71: .getLocalizedMessage("Item Properties"),
72: (JComponent) view
73: .getComponentByName(ListItemNames.ID_ITEM_LABEL));
74: if (dlg.isOk()) {
75: ListItemProperty lip = new ListItemProperty(view
76: .getLabel(), view.getIconProperty());
77: items_model.set(items_model.indexOf(oldprop), lip);
78: }
79: }
80: }
81: }
82: }
|