Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/altara/mars/swingui/ConfigPanel.java


1   /* MARS Network Monitor Swing User Interface
2      Copyright (C) 1999 Brian H. Trammell
3      Copyright (C) 2002 Leapfrog Research & Development, LLC
4   
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License
7     as published by the Free Software Foundation; either version 2
8     of the License, or (at your option) any later version.
9   
10    This program 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
13    GNU General Public License for more details.
14    
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, it is available at 
17    http:///www.gnu.org/copyleft/gpl.html, or by writing to the
18    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA  02111-1307, USA.
20  */
21  
22  package org.altara.mars.swingui;
23  
24  import org.altara.util.*;
25  import org.altara.mars.*;
26  import org.altara.mars.engine.*;
27  import org.altara.mars.plugin.*;
28  import java.util.*;
29  import java.awt.*;
30  import java.awt.event.*;
31  import javax.swing.*;
32  import javax.swing.tree.*;
33  import javax.swing.event.*;
34  import javax.swing.border.*;
35  
36  /** Provides user access to plugin and (future) global config options.
37  */
38  
39  public class ConfigPanel extends JPanel {
40  
41    public ConfigPanel(final MarsView parent) {
42      // create a list of plugins
43      final JList pluglist = new JList(Main.getMain()
44        .getPluginRegistry().getRegisteredPlugins());
45      pluglist.setCellRenderer(new MarsAbstractRenderer() {
46        protected Icon getIconForValue(Object value) {
47          return null;
48        }
49        protected String getStringForValue(Object value) {
50          return ((Plugin)value).getDisplayName();
51        }
52      });
53      pluglist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
54      JScrollPane pluglistSP = new JScrollPane(pluglist);
55      pluglistSP.setBorder(new TitledBorder("Loaded Plugins"));
56  
57      // create a button to configure the selected pluglist
58      JButton plugcfgBtn = new JButton("Configure...");
59      plugcfgBtn.addActionListener(new ActionListener() {
60        public void actionPerformed(ActionEvent ae) {
61          Plugin ptc = (Plugin)pluglist.getSelectedValue();
62          if (ptc == null) return;
63          Editor ed = ptc.getEditor();
64          if (ed == null) return;
65          new EditorDialog(parent,ed);
66          parent.markUnsavedChanges(true);
67        }
68      });
69  
70      // set up the layout manager
71      setLayout(new GridBagLayout());
72      GridBagConstraints c = new GridBagConstraints();
73      c.anchor = c.NORTHWEST; c.fill = c.BOTH;
74      c.weightx = 1.0; c.weighty = 0.0;
75      c.insets = new Insets(4,4,6,4);
76       c.gridwidth = 1; c.gridheight = 1;
77  
78      // lay out the panel
79      c.gridx = 0; c.gridy = 0; c.weighty = 1.0;
80      add(pluglistSP,c);
81      c.gridx = 0; c.gridy = 1; c.weighty = 0.0;
82      c.fill = c.VERTICAL; c.anchor = c.SOUTHEAST;
83      add(plugcfgBtn,c);
84    }
85  }