01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package org.lucane.applications.jmailadmin.gui;
20:
21: import java.awt.*;
22: import java.awt.event.*;
23: import javax.swing.*;
24: import javax.swing.event.*;
25:
26: import org.lucane.applications.jmailadmin.*;
27: import org.lucane.client.widgets.ManagedWindow;
28: import org.lucane.common.concepts.UserConcept;
29:
30: public class MainFrame extends ManagedWindow implements ActionListener,
31: ListSelectionListener {
32: private JMailAdminPlugin plugin;
33: private AccountPanel account;
34:
35: private Account template;
36:
37: public MainFrame(JMailAdminPlugin plugin) {
38: super (plugin, plugin.getTitle());
39:
40: this .plugin = plugin;
41: this .account = new AccountPanel(plugin);
42:
43: getContentPane().setLayout(new BorderLayout());
44: getContentPane().add(new UserListPanel(plugin, this ),
45: BorderLayout.WEST);
46: getContentPane().add(this .account, BorderLayout.CENTER);
47: getContentPane().add(new ButtonPanel(plugin, this ),
48: BorderLayout.SOUTH);
49: setPreferredSize(new Dimension(500, 250));
50: }
51:
52: public void actionPerformed(ActionEvent ae) {
53: JButton src = (JButton) ae.getSource();
54:
55: //save & close
56: if (src.getText().equals(plugin.tr("btn.save")))
57: plugin.storeAccount(this .account.getAccount());
58: else if (src.getText().equals(plugin.tr("btn.close"))) {
59: plugin.exit();
60: this .dispose();
61: }
62:
63: //copy paste
64: else if (src.getText().equals(plugin.tr("btn.copy")))
65: template = account.getAccount();
66: else if (src.getText().equals(plugin.tr("btn.paste")))
67: account.applyTemplate(template);
68: }
69:
70: public void valueChanged(ListSelectionEvent lse) {
71: JList src = (JList) lse.getSource();
72: UserConcept user = (UserConcept) src.getSelectedValue();
73: if (user != null)
74: this.account.setAccount(plugin.getAccount(user.getName()));
75: }
76: }
|