KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > jmailadmin > gui > MainFrame


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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
31 implements ActionListener, ListSelectionListener
32 {
33     private JMailAdminPlugin plugin;
34     private AccountPanel account;
35     
36     private Account template;
37     
38     public MainFrame(JMailAdminPlugin plugin)
39     {
40         super(plugin, plugin.getTitle());
41     
42         this.plugin = plugin;
43         this.account = new AccountPanel(plugin);
44         
45         getContentPane().setLayout(new BorderLayout());
46         getContentPane().add(new UserListPanel(plugin, this), BorderLayout.WEST);
47         getContentPane().add(this.account, BorderLayout.CENTER);
48         getContentPane().add(new ButtonPanel(plugin, this), BorderLayout.SOUTH);
49         setPreferredSize(new Dimension(500, 250));
50     }
51
52     public void actionPerformed(ActionEvent ae)
53     {
54         JButton src = (JButton)ae.getSource();
55         
56         //save & close
57
if(src.getText().equals(plugin.tr("btn.save")))
58             plugin.storeAccount(this.account.getAccount());
59         else if(src.getText().equals(plugin.tr("btn.close")))
60         {
61             plugin.exit();
62             this.dispose();
63         }
64         
65         //copy paste
66
else if(src.getText().equals(plugin.tr("btn.copy")))
67             template = account.getAccount();
68         else if(src.getText().equals(plugin.tr("btn.paste")))
69             account.applyTemplate(template);
70     }
71
72     public void valueChanged(ListSelectionEvent lse)
73     {
74         JList src = (JList)lse.getSource();
75         UserConcept user = (UserConcept)src.getSelectedValue();
76         if(user != null)
77             this.account.setAccount(plugin.getAccount(user.getName()));
78     }
79 }
Popular Tags