001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.cleverphl.gui;
025:
026: import jacareto.cleverphl.CleverPHL;
027: import jacareto.system.Language;
028: import jacareto.system.Module;
029: import jacareto.system.Modules;
030:
031: import java.awt.BorderLayout;
032: import java.awt.Component;
033: import java.awt.Point;
034: import java.awt.event.ActionEvent;
035: import java.awt.event.ActionListener;
036:
037: import java.util.Iterator;
038:
039: import javax.swing.JButton;
040: import javax.swing.JDialog;
041: import javax.swing.JPanel;
042: import javax.swing.JScrollPane;
043: import javax.swing.JTable;
044: import javax.swing.border.EmptyBorder;
045: import javax.swing.table.DefaultTableModel;
046:
047: /**
048: * Shows all loaded modules.
049: *
050: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
051: * @version 1.00
052: */
053: public class ModulesDialog extends JDialog {
054: /**
055: * Creates a new modules dialog.
056: *
057: * @param cleverPHL the CleverPHL instance
058: */
059: public ModulesDialog(CleverPHL cleverPHL) {
060: super (cleverPHL.getMainFrame(), true);
061: setName(cleverPHL.getCustomization().getString(
062: "Components.JacaretoComponent", "JACARETO_COMPONENT"));
063:
064: Language language = cleverPHL.getLanguage();
065:
066: setTitle(language.getString("CleverPHL.ModulesDialog.Title"));
067:
068: Modules modules = cleverPHL.getEnvironment().getModules();
069:
070: String[] columnNames = new String[3];
071: columnNames[0] = language
072: .getString("CleverPHL.ModulesDialog.Name");
073: columnNames[1] = language
074: .getString("CleverPHL.ModulesDialog.Author");
075: columnNames[2] = language
076: .getString("CleverPHL.ModulesDialog.Version");
077:
078: DefaultTableModel model = new DefaultTableModel(columnNames, 0);
079: Iterator it = modules.iterator();
080:
081: while (it.hasNext()) {
082: Object[] data = new Object[3];
083: Module module = (Module) it.next();
084: data[0] = module.getName();
085: data[1] = module.getAuthor();
086: data[2] = module.getVersion();
087: model.addRow(data);
088: }
089:
090: Component mainPanel = new JScrollPane(new JTable(model),
091: JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
092: JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
093:
094: // The panel with the two buttons
095: JPanel buttonPanel = new JPanel();
096: JButton okButton = new JButton(language.getString("General.Ok"));
097: okButton.addActionListener(new ActionListener() {
098: public void actionPerformed(ActionEvent e) {
099: dispose();
100: }
101: });
102:
103: buttonPanel.add(okButton);
104: buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
105:
106: // Add all to the content pane
107: getContentPane().setLayout(new BorderLayout());
108: getContentPane().add(mainPanel, BorderLayout.NORTH);
109: getContentPane().add(buttonPanel, BorderLayout.CENTER);
110:
111: setSize(400, 500);
112: setResizable(true);
113:
114: Point ownerLoc = cleverPHL.getMainFrame().getLocation();
115: setLocation(((int) ownerLoc.getX()) + 30, ((int) ownerLoc
116: .getY()) + 30);
117: setVisible(true);
118: }
119: }
|