1 /*
2 * LicenseDialog.java
3 *
4 * Copyright (c) 2001 Raben Systems, Inc. All Rights Reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of Raben Systems, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Created on December 31, 2001, 5:00 PM
32 */
33
34 package com.raben.tools.xslteditor;
35 import java.io.*;
36
37 /***
38 *
39 * @author Vern Raben
40 */
41 public class LicenseDialog extends javax.swing.JDialog {
42
43 /*** Creates new form LicenseDialog */
44 public LicenseDialog(java.awt.Frame parent, boolean modal) {
45 super(parent, modal);
46 initComponents();
47 }
48
49 /*** This method is called from within the constructor to
50 * initialize the form.
51 * WARNING: Do NOT modify this code. The content of this method is
52 * always regenerated by the Form Editor.
53 */
54 private void initComponents() {//GEN-BEGIN:initComponents
55 jScrollPane1 = new javax.swing.JScrollPane();
56 licenseTextArea = new javax.swing.JTextArea();
57 jPanel2 = new javax.swing.JPanel();
58 acceptButton = new javax.swing.JButton();
59 declineButton = new javax.swing.JButton();
60
61 getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
62
63 setTitle("Binary License Agreement");
64 addWindowListener(new java.awt.event.WindowAdapter() {
65 public void windowClosing(java.awt.event.WindowEvent evt) {
66 closeDialog(evt);
67 }
68 });
69
70 licenseTextArea.setColumns(55);
71 licenseTextArea.setRows(15);
72 licenseTextArea.setText(getLicenseStr());
73 jScrollPane1.setViewportView(licenseTextArea);
74
75 getContentPane().add(jScrollPane1);
76
77 jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
78
79 acceptButton.setMnemonic('A');
80 acceptButton.setText("Accept");
81 acceptButton.addActionListener(new java.awt.event.ActionListener() {
82 public void actionPerformed(java.awt.event.ActionEvent evt) {
83 acceptButtonActionPerformed(evt);
84 }
85 });
86
87 jPanel2.add(acceptButton);
88
89 declineButton.setMnemonic('D');
90 declineButton.setText("Decline");
91 declineButton.addActionListener(new java.awt.event.ActionListener() {
92 public void actionPerformed(java.awt.event.ActionEvent evt) {
93 declineButtonActionPerformed(evt);
94 }
95 });
96
97 jPanel2.add(declineButton);
98
99 getContentPane().add(jPanel2);
100
101 pack();
102 }//GEN-END:initComponents
103
104 private void declineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_declineButtonActionPerformed
105 accept=false;
106 closeDialog(null);
107 }//GEN-LAST:event_declineButtonActionPerformed
108
109 private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed
110 accept=true;
111 closeDialog(null);
112 }//GEN-LAST:event_acceptButtonActionPerformed
113
114 /*** Closes the dialog */
115 private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
116 firePropertyChange(LICENSE_RESPONSE,null,String.valueOf(accept));
117 setVisible(false);
118 dispose();
119 }//GEN-LAST:event_closeDialog
120
121 /***
122 * @param args the command line arguments
123 */
124 public static void main(String args[]) {
125 new LicenseDialog(new javax.swing.JFrame(), true).show();
126 }
127
128 public String getLicenseStr() {
129
130 StringBuffer buf=new StringBuffer();
131 BufferedReader br=null;
132 InputStream is=null;
133
134 try {
135 is=getClass().getResourceAsStream("/LICENSE.txt");
136 if (is!=null) {
137 br=new BufferedReader(new InputStreamReader(is));
138
139 while (br.ready()) {
140 buf.append(br.readLine());
141 buf.append("\n");
142 }
143
144 }
145 }
146 catch (IOException e){
147 System.out.println("error reading license "+e);
148 }
149 finally {
150 try {
151 if (br!=null) {
152 br.close();
153 br=null;
154 }
155 if (is!=null) {
156 is.close();
157 }
158 }
159 catch (IOException e){}
160 }
161
162 return buf.toString();
163 }
164 public static final String LICENSE_RESPONSE="LICENSE_RESPONSE";
165 // Variables declaration - do not modify//GEN-BEGIN:variables
166 private javax.swing.JButton declineButton;
167 private javax.swing.JScrollPane jScrollPane1;
168 private javax.swing.JPanel jPanel2;
169 private javax.swing.JTextArea licenseTextArea;
170 private javax.swing.JButton acceptButton;
171 // End of variables declaration//GEN-END:variables
172
173 private boolean accept = false;
174
175 }
This page was automatically generated by Maven