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.interaction;
024:
025: import java.awt.GridBagConstraints;
026: import java.awt.GridBagLayout;
027: import java.awt.Insets;
028: import java.awt.event.ActionEvent;
029: import java.awt.event.ActionListener;
030:
031: import javax.swing.ComboBoxModel;
032: import javax.swing.DefaultComboBoxModel;
033: import javax.swing.JButton;
034: import javax.swing.JCheckBox;
035: import javax.swing.JComboBox;
036: import javax.swing.JEditorPane;
037: import javax.swing.JFrame;
038: import javax.swing.JLabel;
039: import javax.swing.JScrollPane;
040: import javax.swing.JTabbedPane;
041: import javax.swing.JTextArea;
042: import javax.swing.JTextField;
043: import javax.swing.JTextPane;
044:
045: /**
046: * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
047: * Builder, which is free for non-commercial use. If Jigloo is being used
048: * commercially (ie, by a corporation, company or business for any purpose
049: * whatever) then you should purchase a license for each developer using Jigloo.
050: * Please visit www.cloudgarden.com for details. Use of Jigloo implies
051: * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
052: * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
053: * ANY CORPORATE OR COMMERCIAL PURPOSE.
054: */
055: public class InteractionPropertiesDialog extends javax.swing.JDialog {
056: private JButton okButton;
057:
058: private JButton cancelButton;
059:
060: private JTextArea afterTextArea;
061:
062: private JScrollPane afterScrollPane;
063:
064: private JTextArea beforeTextArea;
065:
066: private JScrollPane beforeScrollPane;
067:
068: private JCheckBox verticalCheckBox;
069: private JComboBox scopeComboBox;
070: private JLabel scopeLabel;
071:
072: private JLabel nameLabel;
073:
074: private JEditorPane descriptionEditorPane;
075:
076: private JScrollPane descriptionScrollPane;
077:
078: private JTabbedPane tabbedPanel;
079:
080: private JTextField nameField;
081:
082: private Interaction data;
083:
084: /**
085: * Auto-generated main method to display this JDialog
086: */
087: public static void main(String[] args) {
088: JFrame frame = new JFrame();
089: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
090: InteractionPropertiesDialog inst = new InteractionPropertiesDialog(
091: frame, null);
092: inst.setVisible(true);
093: frame.dispose();
094: //System.exit(0);
095: }
096:
097: public InteractionPropertiesDialog(JFrame frame, Interaction data) {
098: super (frame);
099: this .data = data;
100: initGUI();
101: nameField.setText(data.getName());
102: afterTextArea.setText(data.getAfterCode());
103: beforeTextArea.setText(data.getBeforeCode());
104: //descriptionEditorPane.setEditorKit(new HTMLEditorKit());
105: descriptionEditorPane.setText(data.getDescription());
106: verticalCheckBox.setSelected(data.getIsVertical());
107: scopeComboBox.setSelectedItem(data.getScope());
108: if (scopeComboBox.getSelectedIndex() == -1) {
109: scopeComboBox.setSelectedIndex(0);
110: }
111: }
112:
113: private void initGUI() {
114: try {
115: GridBagLayout this Layout = new GridBagLayout();
116: this Layout.rowWeights = new double[] { 0.0, 0.1, 0.0 };
117: this Layout.rowHeights = new int[] { 32, 303, 7 };
118: this Layout.columnWeights = new double[] { 0.0, 0.0, 0.0,
119: 0.1, 0.0 };
120: this Layout.columnWidths = new int[] { 45, 85, 42, 20, 7 };
121: getContentPane().setLayout(this Layout);
122: this .setName("Properties");
123: this .setModal(true);
124: this .setTitle("Properties");
125: this .setFocusable(false);
126: {
127: nameField = new JTextField();
128: getContentPane().add(
129: nameField,
130: new GridBagConstraints(1, 0, 4, 1, 0.0, 0.0,
131: GridBagConstraints.WEST,
132: GridBagConstraints.HORIZONTAL,
133: new Insets(0, 0, 0, 0), 0, 0));
134: nameField.setText("Step name");
135: nameField.setSize(200, 20);
136: }
137: {
138: okButton = new JButton();
139: getContentPane().add(
140: okButton,
141: new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
142: GridBagConstraints.EAST,
143: GridBagConstraints.NONE, new Insets(3,
144: 0, 3, 5), 0, 0));
145: okButton.setText("OK");
146: okButton.addActionListener(new ActionListener() {
147: public void actionPerformed(ActionEvent evt) {
148: okButtonActionPerformed(evt);
149: }
150: });
151: }
152: {
153: cancelButton = new JButton();
154: getContentPane().add(
155: cancelButton,
156: new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
157: GridBagConstraints.WEST,
158: GridBagConstraints.NONE, new Insets(3,
159: 0, 3, 3), 0, 0));
160: cancelButton.setText("Cancel");
161: cancelButton.addActionListener(new ActionListener() {
162: public void actionPerformed(ActionEvent evt) {
163: cancelButtonActionPerformed(evt);
164: }
165: });
166: }
167: {
168: tabbedPanel = new JTabbedPane();
169: getContentPane().add(
170: tabbedPanel,
171: new GridBagConstraints(0, 1, 5, 1, 0.0, 0.0,
172: GridBagConstraints.NORTHWEST,
173: GridBagConstraints.BOTH, new Insets(0,
174: 0, 0, 0), 0, 0));
175: {
176: descriptionScrollPane = new JScrollPane();
177: tabbedPanel.addTab("Description", null,
178: descriptionScrollPane, null);
179: descriptionScrollPane
180: .setPreferredSize(new java.awt.Dimension(
181: 360, 159));
182: descriptionScrollPane.setAutoscrolls(true);
183: {
184: descriptionEditorPane = new JTextPane();
185: descriptionScrollPane
186: .setViewportView(descriptionEditorPane);
187: descriptionEditorPane.setText("Description");
188: descriptionEditorPane
189: .setPreferredSize(new java.awt.Dimension(
190: 411, 284));
191: }
192: }
193: {
194: beforeScrollPane = new JScrollPane();
195: tabbedPanel.addTab("Before", null,
196: beforeScrollPane, null);
197: {
198: beforeTextArea = new JTextArea();
199: beforeScrollPane
200: .setViewportView(beforeTextArea);
201: beforeTextArea
202: .setText("// Put condition code here");
203: beforeTextArea.setFont(new java.awt.Font(
204: "Courier New", 0, 11));
205: beforeTextArea.setTabSize(4);
206: }
207: }
208: {
209: afterScrollPane = new JScrollPane();
210: tabbedPanel.addTab("After", null, afterScrollPane,
211: null);
212: afterScrollPane
213: .setPreferredSize(new java.awt.Dimension(
214: 501, 287));
215: {
216: afterTextArea = new JTextArea();
217: afterScrollPane.setViewportView(afterTextArea);
218: afterTextArea
219: .setText("// Put action code here");
220: afterTextArea.setFont(new java.awt.Font(
221: "Courier New", 0, 11));
222: afterTextArea.setTabSize(4);
223: }
224: }
225: }
226: {
227: nameLabel = new JLabel();
228: getContentPane().add(
229: nameLabel,
230: new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
231: GridBagConstraints.CENTER,
232: GridBagConstraints.NONE, new Insets(0,
233: 0, 0, 5), 0, 0));
234: nameLabel.setText("Name");
235: }
236: {
237: verticalCheckBox = new JCheckBox();
238: getContentPane().add(
239: verticalCheckBox,
240: new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,
241: GridBagConstraints.WEST,
242: GridBagConstraints.NONE, new Insets(0,
243: 5, 0, 0), 0, 0));
244: verticalCheckBox.setText("Vertical orientation");
245: }
246: {
247: scopeLabel = new JLabel();
248: getContentPane().add(
249: scopeLabel,
250: new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
251: GridBagConstraints.WEST,
252: GridBagConstraints.NONE, new Insets(0,
253: 5, 0, 0), 0, 0));
254: scopeLabel.setText("Scope");
255: }
256: {
257: ComboBoxModel scopeComboBoxModel = new DefaultComboBoxModel(
258: new String[] { "Public", "Parent", "Hidden" });
259: scopeComboBox = new JComboBox();
260: getContentPane().add(
261: scopeComboBox,
262: new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
263: GridBagConstraints.WEST,
264: GridBagConstraints.NONE, new Insets(0,
265: 2, 0, 0), 0, 0));
266: scopeComboBox.setModel(scopeComboBoxModel);
267: }
268: this .setSize(500, 400);
269: } catch (Exception e) {
270: e.printStackTrace();
271: }
272: }
273:
274: private void okButtonActionPerformed(ActionEvent evt) {
275: data.setAfterCode(afterTextArea.getText());
276: data.setBeforeCode(beforeTextArea.getText());
277: data.setName(nameField.getText());
278: data.setDescription(descriptionEditorPane.getText());
279: data.setIsVertical(verticalCheckBox.isSelected());
280: Object scope = scopeComboBox.getSelectedItem();
281: data.setScope(scope == null ? null : scope.toString());
282: data.getApplet().modelChanged();
283: cancelButtonActionPerformed(evt);
284: }
285:
286: private void cancelButtonActionPerformed(ActionEvent evt) {
287: setVisible(false);
288: dispose();
289: }
290: }
|