001: /*
002: * Lucane - a collaborative platform
003: * Copyright (C) 2002 Vincent Fiack <vfiack@mail15.com>
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019: package org.lucane.applications.pluginsinfos;
020:
021: import org.lucane.client.*;
022: import org.lucane.client.widgets.ManagedWindow;
023: import org.lucane.common.*;
024:
025: import java.awt.*;
026: import java.awt.event.*;
027: import java.net.*;
028: import java.util.Iterator;
029:
030: import javax.swing.*;
031:
032: public class PluginsInfos extends StandalonePlugin implements
033: ActionListener {
034:
035: private ManagedWindow window;
036: JTextField name; // + version
037: JTextField author; // + email
038: JTextField tooltip;
039: JTextField category;
040: JTextField title;
041: JPanel infos;
042: JLabel lblIcon;
043: JComboBox plugins;
044: PluginManager ploader;
045:
046: public PluginsInfos() {
047: }
048:
049: public Plugin newInstance(ConnectInfo[] friends) {
050: return new PluginsInfos();
051: }
052:
053: public void start() {
054: ploader = PluginManager.getInstance();
055:
056: JPanel jpmain = new JPanel();
057: jpmain.setLayout(new BorderLayout());
058: window = new ManagedWindow(this , getTitle());
059: window.setExitPluginOnClose(true);
060: window.getContentPane().setLayout(new BorderLayout());
061: window.getContentPane().add(jpmain, BorderLayout.CENTER);
062: plugins = new JComboBox();
063: plugins.addActionListener(this );
064: jpmain.add(plugins, BorderLayout.NORTH);
065: name = new JTextField();
066: name.setEditable(false);
067: author = new JTextField();
068: author.setEditable(false);
069: tooltip = new JTextField();
070: tooltip.setEditable(false);
071: category = new JTextField();
072: category.setEditable(false);
073: title = new JTextField();
074: title.setEditable(false);
075: infos = new JPanel();
076:
077: JPanel labels = new JPanel();
078: JPanel texts = new JPanel();
079: infos.setLayout(new BorderLayout());
080: labels.setLayout(new GridLayout(0, 1));
081: texts.setLayout(new GridLayout(0, 1));
082: infos.add(labels, BorderLayout.WEST);
083: infos.add(texts, BorderLayout.CENTER);
084: labels.add(new JLabel(tr("fname")));
085: texts.add(name);
086: labels.add(new JLabel(tr("fauthor")));
087: texts.add(author);
088: labels.add(new JLabel(tr("fcategory")));
089: texts.add(category);
090: labels.add(new JLabel(tr("ftitle")));
091: texts.add(title);
092: labels.add(new JLabel(tr("ftooltip")));
093: texts.add(tooltip);
094: lblIcon = new JLabel(tr("noicon"));
095: infos.add(lblIcon, BorderLayout.EAST);
096: jpmain.add(infos, BorderLayout.CENTER);
097:
098: Iterator i = PluginManager.getInstance().getAvailablePlugins();
099: while (i.hasNext()) {
100: Plugin p = (Plugin) i.next();
101: plugins.addItem(p.getName());
102: }
103:
104: window.setPreferredSize(new Dimension(340, 150));
105: window.show();
106: }
107:
108: public void actionPerformed(ActionEvent ae) {
109: int idx = plugins.getSelectedIndex();
110:
111: if (idx >= 0) {
112: Plugin p = ploader.getPlugin((String) plugins
113: .getSelectedItem());
114: name.setText(p.getName() + " - " + p.getVersion());
115: author.setText(p.getAuthor() + " <" + p.getEmail() + ">");
116: category.setText(p.getCategory());
117: title.setText(p.getTitle());
118: tooltip.setText(p.getToolTip());
119:
120: ImageIcon iic = null;
121:
122: try {
123: iic = p.getImageIcon(p.getIcon());
124: iic = new ImageIcon(iic.getImage().getScaledInstance(
125: 32, 32, Image.SCALE_SMOOTH));
126: lblIcon.setText("");
127: lblIcon.setIcon(iic);
128: } catch (Exception e) {
129: lblIcon.setText(tr("noicon"));
130: }
131: }
132: }
133: }
|