001: package com.calipso.reportgenerator.userinterface;
002:
003: import com.calipso.reportgenerator.common.LanguageTraslator;
004: import com.calipso.reportgenerator.client.ReportManagerService;
005:
006: import javax.swing.*;
007: import java.awt.event.ActionListener;
008: import java.awt.event.ActionEvent;
009: import java.awt.*;
010: import java.io.File;
011:
012: /**
013: * Calipso Software
014: * User: Breto
015: * Date: 18/04/2006
016: * Time: 17:56:15
017: */
018: public class LicenceFrame extends JDialog implements ActionListener {
019: private JButton btAccept;
020: private JButton btCancel;
021: private boolean hasCanceled;
022: private JTextField tfName;
023:
024: public LicenceFrame(Frame owner, String title, boolean modal)
025: throws HeadlessException {
026: super (owner, title, modal);
027: Image icon = ReportManagerService.getConfiguration().getImage(
028: "icon");
029: if (icon != null && owner != null) {
030: owner.setIconImage(icon);
031: }
032: hasCanceled = false;
033: createComponents();
034: }
035:
036: public static boolean accept() {
037: LicenceFrame licenceFrame = new LicenceFrame(new JFrame(),
038: LanguageTraslator.traslate("582"), true);
039: if (!licenceFrame.getHasCanceled()) {
040: return true;
041: }
042: return false;
043:
044: }
045:
046: private boolean getHasCanceled() {
047: return hasCanceled;
048: }
049:
050: protected void createComponents() {
051: getContentPane().setLayout(new BorderLayout());
052: getContentPane().add(createNorthPanel(), BorderLayout.CENTER);
053: getContentPane().add(createSouthPanel(), BorderLayout.SOUTH);
054: java.awt.Dimension screenSize = java.awt.Toolkit
055: .getDefaultToolkit().getScreenSize();
056: setLocation(100, 100);
057: setSize(new Dimension(620, 550));
058: setVisible(true);
059: }
060:
061: /**
062: * Crea el panel del sur
063: * @return
064: */
065: protected JComponent createSouthPanel() {
066: FlowLayout layout = new FlowLayout(FlowLayout.RIGHT);
067: JPanel pnlSouth = new JPanel(layout);
068: btAccept = new JButton(LanguageTraslator.traslate("112"));
069: btAccept.addActionListener(this );
070: btCancel = new JButton(LanguageTraslator.traslate("113"));
071: btCancel.addActionListener(this );
072: pnlSouth.add(btAccept);
073: pnlSouth.add(btCancel);
074: return pnlSouth;
075: }
076:
077: /**
078: * Crea el panel del norte
079: * @return
080: */
081: protected JComponent createNorthPanel() {
082: JPanel pnlNorth = new JPanel(new GridLayout(1, 1));
083: JTextArea jTextArea = new JTextArea();
084: jTextArea.setEditable(false);
085: jTextArea.append(getBSDText());
086: pnlNorth.add(jTextArea);
087: return pnlNorth;
088: }
089:
090: private String getBSDText() {
091: return new String(
092: "BSD License\n"
093: + "============\n"
094: + "\n"
095: + "Redistribution and use in source and binary forms, with or without modification, \n"
096: + "are permitted provided that the following conditions are met:\n"
097: + " 1. Redistributions of source code must retain the above copyright notice, \n"
098: + " this list of conditions and the following disclaimer. \n"
099: + " 2. Redistributions in binary form must reproduce the above copyright notice, \n"
100: + " this list of conditions and the following disclaimer in the documentation \n"
101: + " and/or other materials provided with the distribution. \n"
102: + " 3. All advertising materials mentioning features or use of this software must \n"
103: + " display the following acknowledgement:\n"
104: + " This product includes software developed by the NetBSD Foundation, Inc. \n"
105: + " and its contributors. \n"
106: + " \n"
107: + " 4. Neither the name of Calipso nor the names of its contributors \n"
108: + " may be used to endorse or promote products derived from this software without \n"
109: + " specific prior written permission. \n"
110: + "\n"
111: + "THIS SOFTWARE IS PROVIDED THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \n"
112: + "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \n"
113: + "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \n"
114: + "IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \n"
115: + "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \n"
116: + "PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n"
117: + "INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, \n"
118: + "STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n"
119: + "OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
120: + "");
121: }
122:
123: public void actionPerformed(ActionEvent e) {
124: if (e.getSource() == btAccept) {
125: dispose();
126: } else {
127: hasCanceled = true;
128: dispose();
129: }
130: }
131:
132: }
|