KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > pluginsinfos > PluginsInfos


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2002 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.pluginsinfos;
20
21 import org.lucane.client.*;
22 import org.lucane.client.widgets.ManagedWindow;
23 import org.lucane.common.*;
24
25 import java.awt.*;
26 import java.awt.event.*;
27 import java.net.*;
28 import java.util.Iterator JavaDoc;
29
30 import javax.swing.*;
31
32
33 public class PluginsInfos
34   extends StandalonePlugin
35   implements ActionListener
36 {
37
38   private ManagedWindow window;
39   JTextField name; // + version
40
JTextField author; // + email
41
JTextField tooltip;
42   JTextField category;
43   JTextField title;
44   JPanel infos;
45   JLabel lblIcon;
46   JComboBox plugins;
47   PluginManager ploader;
48
49   public PluginsInfos()
50   {
51   }
52
53   public Plugin newInstance(ConnectInfo[] friends)
54   {
55     return new PluginsInfos();
56   }
57
58   public void start()
59   {
60     ploader = PluginManager.getInstance();
61
62     JPanel jpmain = new JPanel();
63     jpmain.setLayout(new BorderLayout());
64     window = new ManagedWindow(this, getTitle());
65     window.setExitPluginOnClose(true);
66     window.getContentPane().setLayout(new BorderLayout());
67     window.getContentPane().add(jpmain, BorderLayout.CENTER);
68     plugins = new JComboBox();
69     plugins.addActionListener(this);
70     jpmain.add(plugins, BorderLayout.NORTH);
71     name = new JTextField();
72     name.setEditable(false);
73     author = new JTextField();
74     author.setEditable(false);
75     tooltip = new JTextField();
76     tooltip.setEditable(false);
77     category = new JTextField();
78     category.setEditable(false);
79     title = new JTextField();
80     title.setEditable(false);
81     infos = new JPanel();
82
83     JPanel labels = new JPanel();
84     JPanel texts = new JPanel();
85     infos.setLayout(new BorderLayout());
86     labels.setLayout(new GridLayout(0, 1));
87     texts.setLayout(new GridLayout(0, 1));
88     infos.add(labels, BorderLayout.WEST);
89     infos.add(texts, BorderLayout.CENTER);
90     labels.add(new JLabel(tr("fname")));
91     texts.add(name);
92     labels.add(new JLabel(tr("fauthor")));
93     texts.add(author);
94     labels.add(new JLabel(tr("fcategory")));
95     texts.add(category);
96     labels.add(new JLabel(tr("ftitle")));
97     texts.add(title);
98     labels.add(new JLabel(tr("ftooltip")));
99     texts.add(tooltip);
100     lblIcon = new JLabel(tr("noicon"));
101     infos.add(lblIcon, BorderLayout.EAST);
102     jpmain.add(infos, BorderLayout.CENTER);
103
104     Iterator JavaDoc i = PluginManager.getInstance().getAvailablePlugins();
105     while(i.hasNext())
106     {
107         Plugin p = (Plugin)i.next();
108         plugins.addItem(p.getName());
109     }
110
111     window.setPreferredSize(new Dimension(340, 150));
112     window.show();
113   }
114
115   public void actionPerformed(ActionEvent ae)
116   {
117     int idx = plugins.getSelectedIndex();
118
119     if(idx >= 0)
120     {
121         Plugin p = ploader.getPlugin((String JavaDoc)plugins.getSelectedItem());
122       name.setText(p.getName() + " - " + p.getVersion());
123       author.setText(p.getAuthor() + " <" + p.getEmail() + ">");
124       category.setText(p.getCategory());
125       title.setText(p.getTitle());
126       tooltip.setText(p.getToolTip());
127
128       ImageIcon iic = null;
129
130       try
131       {
132         iic = p.getImageIcon(p.getIcon());
133         iic = new ImageIcon(iic.getImage().getScaledInstance(32, 32, Image.SCALE_SMOOTH));
134         lblIcon.setText("");
135         lblIcon.setIcon(iic);
136       }
137       catch(Exception JavaDoc e)
138       {
139         lblIcon.setText(tr("noicon"));
140       }
141     }
142   }
143 }
Popular Tags