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.scrollbars;
20:
21: import java.awt.event.ActionEvent;
22: import java.awt.event.ActionListener;
23:
24: import com.jeta.forms.store.properties.BorderProperty;
25: import com.jeta.forms.store.properties.CompoundBorderProperty;
26: import com.jeta.forms.store.properties.ScrollBarsProperty;
27: import com.jeta.open.gui.framework.JETAController;
28: import com.jeta.open.gui.framework.JETADialog;
29: import com.jeta.open.gui.utils.JETAToolbox;
30: import com.jeta.open.i18n.I18N;
31: import com.jeta.swingbuilder.gui.border.CompoundBorderView;
32:
33: public class ScrollPolicyController extends JETAController {
34: private ScrollPolicyView m_view;
35:
36: public ScrollPolicyController(ScrollPolicyView view) {
37: super (view);
38: m_view = view;
39: assignAction(ScrollPolicyNames.ID_BORDER_BTN,
40: new BorderAction());
41: }
42:
43: public class BorderAction implements ActionListener {
44: public void actionPerformed(ActionEvent evt) {
45: ScrollBarsProperty sprop = m_view.getScrollBarsProperty();
46: BorderProperty border_prop = sprop.getBorderProperty();
47: if (!(border_prop instanceof CompoundBorderProperty)) {
48: if (border_prop == null)
49: border_prop = new CompoundBorderProperty();
50: else {
51: CompoundBorderProperty cprop = new CompoundBorderProperty();
52: cprop.setValue(border_prop);
53: border_prop = cprop;
54: }
55: }
56:
57: CompoundBorderView view = new CompoundBorderView(
58: (CompoundBorderProperty) border_prop);
59: JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
60: JETADialog.class, m_view, true);
61: dlg.setPrimaryPanel(view);
62: dlg.setSize(dlg.getPreferredSize());
63: dlg.setTitle(I18N.getLocalizedMessage("Edit Border"));
64: dlg.showCenter();
65: if (dlg.isOk()) {
66: CompoundBorderProperty cborder = (CompoundBorderProperty) view
67: .createBorderProperty();
68: sprop.setBorderProperty(cborder);
69: m_view.setText(ScrollPolicyNames.ID_BORDER_LABEL,
70: cborder.toString());
71: }
72: }
73: }
74: }
|