1 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 ; 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; JTextField author; 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 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 )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 e) 138 { 139 lblIcon.setText(tr("noicon")); 140 } 141 } 142 } 143 } | Popular Tags |