001: /*
002: * argun 1.0
003: * Web 2.0 delivery framework
004: * Copyright (C) 2007 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) 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 GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.biz
021: * e-Mail: support@hammurapi.biz
022: */
023: package biz.hammurapi.web.webdiagram;
024:
025: import java.awt.Frame;
026: import java.awt.GridBagConstraints;
027: import java.awt.GridBagLayout;
028: import java.awt.Insets;
029: import java.awt.event.ActionEvent;
030: import java.awt.event.ActionListener;
031:
032: import javax.swing.JButton;
033: import javax.swing.JCheckBox;
034: import javax.swing.JEditorPane;
035: import javax.swing.JFrame;
036: import javax.swing.JScrollPane;
037: import javax.swing.JTabbedPane;
038: import javax.swing.JTextPane;
039:
040: /**
041: * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
042: * Builder, which is free for non-commercial use. If Jigloo is being used
043: * commercially (ie, by a corporation, company or business for any purpose
044: * whatever) then you should purchase a license for each developer using Jigloo.
045: * Please visit www.cloudgarden.com for details. Use of Jigloo implies
046: * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
047: * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
048: * ANY CORPORATE OR COMMERCIAL PURPOSE.
049: */
050: public class OperationPermissionPropertiesDialog extends
051: javax.swing.JDialog {
052: private JButton okButton;
053:
054: private JButton cancelButton;
055:
056: private JEditorPane descriptionEditorPane;
057:
058: private JScrollPane descriptionScrollPane;
059:
060: private JTabbedPane tabbedPanel;
061: private JCheckBox denyCheckBox;
062:
063: private OperationPermission data;
064:
065: /**
066: * Auto-generated main method to display this JDialog
067: */
068: public static void main(String[] args) {
069: JFrame frame = new JFrame();
070: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
071: OperationPermissionPropertiesDialog inst = new OperationPermissionPropertiesDialog(
072: frame, null);
073: inst.setVisible(true);
074: frame.dispose();
075: //System.exit(0);
076: }
077:
078: public OperationPermissionPropertiesDialog(Frame frame,
079: OperationPermission data) {
080: super (frame);
081: this .data = data;
082: initGUI();
083: denyCheckBox
084: .setSelected("yes".equals(data.getProperty("deny")));
085: descriptionEditorPane.setText(data.getDescription());
086: }
087:
088: private void initGUI() {
089: try {
090: GridBagLayout this Layout = new GridBagLayout();
091: this Layout.rowWeights = new double[] { 0.0, 0.1, 0.0 };
092: this Layout.rowHeights = new int[] { 32, 303, 7 };
093: this Layout.columnWeights = new double[] { 0.0, 0.1, 0.0 };
094: this Layout.columnWidths = new int[] { 45, 354, 7 };
095: getContentPane().setLayout(this Layout);
096: this .setName("Properties");
097: this .setModal(true);
098: this .setTitle("Properties");
099: {
100: okButton = new JButton();
101: getContentPane().add(
102: okButton,
103: new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
104: GridBagConstraints.EAST,
105: GridBagConstraints.NONE, new Insets(3,
106: 0, 3, 3), 0, 0));
107: okButton.setText("OK");
108: okButton.addActionListener(new ActionListener() {
109: public void actionPerformed(ActionEvent evt) {
110: okButtonActionPerformed(evt);
111: }
112: });
113: }
114: {
115: cancelButton = new JButton();
116: getContentPane().add(
117: cancelButton,
118: new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
119: GridBagConstraints.WEST,
120: GridBagConstraints.NONE, new Insets(3,
121: 0, 3, 3), 0, 0));
122: cancelButton.setText("Cancel");
123: cancelButton.addActionListener(new ActionListener() {
124: public void actionPerformed(ActionEvent evt) {
125: cancelButtonActionPerformed(evt);
126: }
127: });
128: }
129: {
130: tabbedPanel = new JTabbedPane();
131: getContentPane().add(
132: tabbedPanel,
133: new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0,
134: GridBagConstraints.NORTHWEST,
135: GridBagConstraints.BOTH, new Insets(0,
136: 0, 0, 0), 0, 0));
137: {
138: descriptionScrollPane = new JScrollPane();
139: tabbedPanel.addTab("Description", null,
140: descriptionScrollPane, null);
141: descriptionScrollPane
142: .setPreferredSize(new java.awt.Dimension(
143: 360, 159));
144: descriptionScrollPane.setAutoscrolls(true);
145: {
146: descriptionEditorPane = new JTextPane();
147: descriptionScrollPane
148: .setViewportView(descriptionEditorPane);
149: descriptionEditorPane.setText("Description");
150: descriptionEditorPane
151: .setPreferredSize(new java.awt.Dimension(
152: 185, 74));
153: }
154: }
155: }
156: {
157: denyCheckBox = new JCheckBox();
158: getContentPane().add(
159: denyCheckBox,
160: new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
161: GridBagConstraints.CENTER,
162: GridBagConstraints.NONE, new Insets(0,
163: 5, 0, 0), 0, 0));
164: denyCheckBox.setText("Deny");
165: }
166: this .setSize(500, 400);
167: } catch (Exception e) {
168: e.printStackTrace();
169: }
170: }
171:
172: public static boolean compareStrings(String str1, String str2) {
173: if (str1 == str2) {
174: return true;
175: }
176: if (str1 == null || str1.trim().length() == 0) {
177: return str2 == null || str2.trim().length() == 0;
178: }
179:
180: return str1.equals(str2);
181: }
182:
183: private boolean ok;
184:
185: public boolean edit() {
186: ok = false;
187: setVisible(true);
188: return ok;
189: }
190:
191: private void okButtonActionPerformed(ActionEvent evt) {
192: data.setProperty("deny", denyCheckBox.isSelected() ? "yes"
193: : "no");
194: data.setDescription(descriptionEditorPane.getText());
195: ok = true;
196: cancelButtonActionPerformed(evt);
197: }
198:
199: private void cancelButtonActionPerformed(ActionEvent evt) {
200: setVisible(false);
201: dispose();
202: }
203: }
|