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.cleverphl.session.Session;
028: import jacareto.system.Language;
029: import jacareto.toolkit.PriorityList;
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 registered replayers.
049: *
050: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
051: * @version 1.00
052: */
053: public class ReplayersDialog extends JDialog {
054: /**
055: * Creates a new replayers dialog.
056: *
057: * @param cleverPHL the CleverPHL instance
058: */
059: public ReplayersDialog(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.ReplayersDialog.Title"));
067:
068: Session actualSession = cleverPHL.getSessionList().getActual();
069:
070: PriorityList replayers = actualSession.getReplay()
071: .getReplayers();
072:
073: String[] columnNames = new String[2];
074: columnNames[0] = language
075: .getString("CleverPHL.ReplayersDialog.Priority");
076: columnNames[1] = language
077: .getString("CleverPHL.ReplayersDialog.Replayer");
078:
079: DefaultTableModel model = new DefaultTableModel(columnNames, 0);
080: Iterator it = replayers.iterator();
081:
082: while (it.hasNext()) {
083: Object[] data = new Object[2];
084: Object element = it.next();
085: data[0] = new Integer(replayers.getPriority(element));
086: data[1] = element.getClass().getName();
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: }
|