001: /*
002: * InformationDialog.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.executequery.gui;
023:
024: import java.awt.Dimension;
025: import java.awt.Font;
026: import java.awt.GridBagConstraints;
027: import java.awt.GridBagLayout;
028: import java.io.IOException;
029: import javax.swing.JButton;
030: import javax.swing.JPanel;
031: import javax.swing.JScrollPane;
032: import javax.swing.JTextArea;
033: import org.executequery.Constants;
034: import org.underworldlabs.swing.actions.ActionUtilities;
035: import org.underworldlabs.util.FileUtils;
036:
037: /* ----------------------------------------------------------
038: * CVS NOTE: Changes to the CVS repository prior to the
039: * release of version 3.0.0beta1 has meant a
040: * resetting of CVS revision numbers.
041: * ----------------------------------------------------------
042: */
043:
044: /**
045: *
046: * @author Takis Diakoumis
047: * @version $Revision: 1.6 $
048: * @date $Date: 2006/06/05 15:35:35 $
049: */
050: public class InformationDialog extends ActionDialog {
051:
052: public static final int RESOURCE_PATH_VALUE = 0;
053: public static final int TEXT_CONTENT_VALUE = 1;
054:
055: /** Creates a new instance of InformationDialog */
056: public InformationDialog(String name, String value, int valueType) {
057: super (name, true);
058: try {
059: String text = null;
060: if (valueType == RESOURCE_PATH_VALUE) {
061: text = FileUtils.loadResource(value);
062: } else {
063: text = value;
064: }
065:
066: JTextArea textArea = new JTextArea(text);
067: textArea.setFont(new Font("monospaced", Font.PLAIN, 11));
068: textArea.setEditable(false);
069:
070: JPanel panel = new JPanel(new GridBagLayout());
071: JButton closeButton = ActionUtilities.createButton(this ,
072: "Close", "dispose");
073: closeButton.setPreferredSize(Constants.BUTTON_SIZE);
074:
075: GridBagConstraints gbc = new GridBagConstraints();
076: gbc.insets.top = 5;
077: gbc.insets.bottom = 5;
078: gbc.insets.left = 5;
079: gbc.insets.right = 5;
080: gbc.gridy = 0;
081: gbc.gridx = 0;
082: gbc.weightx = 1.0;
083: gbc.weighty = 1.0;
084: gbc.fill = GridBagConstraints.BOTH;
085: gbc.anchor = GridBagConstraints.NORTHWEST;
086: panel.add(new JScrollPane(textArea), gbc);
087: gbc.gridy++;
088: gbc.weightx = 0;
089: gbc.weighty = 0;
090: gbc.insets.top = 0;
091: gbc.fill = GridBagConstraints.NONE;
092: gbc.anchor = GridBagConstraints.CENTER;
093: panel.add(closeButton, gbc);
094:
095: panel.setPreferredSize(new Dimension(650, 500));
096:
097: addDisplayComponent(panel);
098: display();
099: } catch (IOException e) {
100: e.printStackTrace();
101: }
102: }
103:
104: }
|