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.statemachine;
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.JButton;
032: import javax.swing.JEditorPane;
033: import javax.swing.JFrame;
034: import javax.swing.JLabel;
035: import javax.swing.JScrollPane;
036: import javax.swing.JTabbedPane;
037: import javax.swing.JTextArea;
038: import javax.swing.JTextField;
039: import javax.swing.JTextPane;
040:
041: /**
042: * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
043: * Builder, which is free for non-commercial use. If Jigloo is being used
044: * commercially (ie, by a corporation, company or business for any purpose
045: * whatever) then you should purchase a license for each developer using Jigloo.
046: * Please visit www.cloudgarden.com for details. Use of Jigloo implies
047: * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
048: * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
049: * ANY CORPORATE OR COMMERCIAL PURPOSE.
050: */
051: public class TransitionPropertiesDialog extends javax.swing.JDialog {
052: private JButton okButton;
053:
054: private JButton cancelButton;
055:
056: private JTextArea guardTextArea;
057:
058: private JScrollPane guardScrollPane;
059:
060: private JLabel nameLabel;
061:
062: private JEditorPane descriptionEditorPane;
063:
064: private JScrollPane descriptionScrollPane;
065:
066: private JTabbedPane tabbedPanel;
067:
068: private JTextField nameField;
069:
070: private Transition data;
071:
072: /**
073: * Auto-generated main method to display this JDialog
074: */
075: public static void main(String[] args) {
076: JFrame frame = new JFrame();
077: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
078: TransitionPropertiesDialog inst = new TransitionPropertiesDialog(
079: frame, null);
080: inst.setVisible(true);
081: frame.dispose();
082: //System.exit(0);
083: }
084:
085: public TransitionPropertiesDialog(JFrame frame, Transition data) {
086: super (frame);
087: this .data = data;
088: initGUI();
089: nameField.setText(data.getName());
090: descriptionEditorPane.setText(data.getDescription());
091: guardTextArea.setText(data.getGuard());
092: }
093:
094: private void initGUI() {
095: try {
096: GridBagLayout this Layout = new GridBagLayout();
097: this Layout.rowWeights = new double[] { 0.0, 0.1, 0.0 };
098: this Layout.rowHeights = new int[] { 32, 303, 7 };
099: this Layout.columnWeights = new double[] { 0.0, 0.1, 0.0 };
100: this Layout.columnWidths = new int[] { 45, 354, 7 };
101: getContentPane().setLayout(this Layout);
102: this .setName("Properties");
103: this .setModal(true);
104: this .setTitle("Properties");
105: {
106: nameField = new JTextField();
107: getContentPane().add(
108: nameField,
109: new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0,
110: GridBagConstraints.WEST,
111: GridBagConstraints.HORIZONTAL,
112: new Insets(0, 0, 0, 0), 0, 0));
113: nameField.setText("Tansition name");
114: nameField.setSize(200, 20);
115: }
116: {
117: okButton = new JButton();
118: getContentPane().add(
119: okButton,
120: new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
121: GridBagConstraints.EAST,
122: GridBagConstraints.NONE, new Insets(3,
123: 0, 3, 3), 0, 0));
124: okButton.setText("OK");
125: okButton.addActionListener(new ActionListener() {
126: public void actionPerformed(ActionEvent evt) {
127: okButtonActionPerformed(evt);
128: }
129: });
130: }
131: {
132: cancelButton = new JButton();
133: getContentPane().add(
134: cancelButton,
135: new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
136: GridBagConstraints.WEST,
137: GridBagConstraints.NONE, new Insets(3,
138: 0, 3, 3), 0, 0));
139: cancelButton.setText("Cancel");
140: cancelButton.addActionListener(new ActionListener() {
141: public void actionPerformed(ActionEvent evt) {
142: cancelButtonActionPerformed(evt);
143: }
144: });
145: }
146: {
147: tabbedPanel = new JTabbedPane();
148: getContentPane().add(
149: tabbedPanel,
150: new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0,
151: GridBagConstraints.NORTHWEST,
152: GridBagConstraints.BOTH, new Insets(0,
153: 0, 0, 0), 0, 0));
154: {
155: descriptionScrollPane = new JScrollPane();
156: tabbedPanel.addTab("Description", null,
157: descriptionScrollPane, null);
158: descriptionScrollPane
159: .setPreferredSize(new java.awt.Dimension(
160: 360, 159));
161: descriptionScrollPane.setAutoscrolls(true);
162: {
163: descriptionEditorPane = new JTextPane();
164: descriptionScrollPane
165: .setViewportView(descriptionEditorPane);
166: descriptionEditorPane.setText("Description");
167: descriptionEditorPane
168: .setPreferredSize(new java.awt.Dimension(
169: 185, 74));
170: }
171: }
172: {
173: guardScrollPane = new JScrollPane();
174: tabbedPanel.addTab("Guard", null, guardScrollPane,
175: null);
176: {
177: guardTextArea = new JTextArea();
178: guardScrollPane.setViewportView(guardTextArea);
179: guardTextArea
180: .setText("// Put condition code here");
181: guardTextArea.setFont(new java.awt.Font(
182: "Courier New", 0, 11));
183: guardTextArea.setTabSize(4);
184: }
185: }
186: }
187: {
188: nameLabel = new JLabel();
189: getContentPane().add(
190: nameLabel,
191: new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
192: GridBagConstraints.CENTER,
193: GridBagConstraints.NONE, new Insets(0,
194: 0, 0, 5), 0, 0));
195: nameLabel.setText("Name");
196: }
197: this .setSize(500, 400);
198: } catch (Exception e) {
199: e.printStackTrace();
200: }
201: }
202:
203: public static boolean compareStrings(String str1, String str2) {
204: if (str1 == str2) {
205: return true;
206: }
207: if (str1 == null || str1.trim().length() == 0) {
208: return str2 == null || str2.trim().length() == 0;
209: }
210:
211: return str1.equals(str2);
212: }
213:
214: private void okButtonActionPerformed(ActionEvent evt) {
215: data.setName(nameField.getText());
216: data.setDescription(descriptionEditorPane.getText());
217: data.setGuard(guardTextArea.getText());
218: data.getStateMachine().getApplet().modelChanged();
219: cancelButtonActionPerformed(evt);
220: }
221:
222: private void cancelButtonActionPerformed(ActionEvent evt) {
223: setVisible(false);
224: dispose();
225: }
226: }
|