01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.components.tabpane;
20:
21: import java.awt.event.ActionEvent;
22: import java.awt.event.ActionListener;
23:
24: import com.jeta.forms.store.properties.TabProperty;
25: import com.jeta.open.gui.framework.JETADialog;
26: import com.jeta.open.gui.utils.JETAToolbox;
27: import com.jeta.open.i18n.I18N;
28: import com.jeta.swingbuilder.gui.components.list.ListItemView;
29: import com.jeta.swingbuilder.gui.utils.TableSupportHandler;
30:
31: public class TabDesignerController extends TableSupportHandler {
32: private TabDesignerView m_view;
33:
34: /** @link dependency */
35:
36: /* # TabDesignerNames lnkTabDesignerNames; */
37:
38: public TabDesignerController(TabDesignerView view) {
39: super (view, TabDesignerNames.ID_TABS_TABLE,
40: TabDesignerNames.ID_DELETE_TAB,
41: TabDesignerNames.ID_MOVE_UP,
42: TabDesignerNames.ID_MOVE_DOWN);
43: m_view = view;
44: assignAction(TabDesignerNames.ID_ADD_TAB, new AddTabAction());
45: assignAction(TabDesignerNames.ID_EDIT_TAB, new EditTabAction());
46: }
47:
48: public class AddTabAction implements ActionListener {
49: public void actionPerformed(ActionEvent evt) {
50: ListItemView view = new ListItemView();
51: JETADialog dlg = JETAToolbox.invokeDialog(view, m_view,
52: I18N.getLocalizedMessage("Tab Properties"));
53: if (dlg.isOk()) {
54: TabProperty tp = new TabProperty();
55: tp.setTitle(view.getLabel());
56: tp.setIconProperty(view.getIconProperty());
57: m_view.addTabProperty(tp);
58: }
59: }
60: }
61:
62: public class EditTabAction implements ActionListener {
63: public void actionPerformed(ActionEvent evt) {
64: TabProperty tp = m_view.getSelectedTabProperty();
65: if (tp != null) {
66: ListItemView view = new ListItemView(tp.getTitle(), tp
67: .getIconProperty());
68: JETADialog dlg = JETAToolbox.invokeDialog(view, m_view,
69: I18N.getLocalizedMessage("Tab Properties"));
70: if (dlg.isOk()) {
71: TabProperty newtp = new TabProperty();
72: newtp.setValue(tp);
73: newtp.setTitle(view.getLabel());
74: newtp.setIconProperty(view.getIconProperty());
75: m_view.setTabProperty(newtp, tp);
76: }
77: }
78: }
79: }
80: }
|