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.JEditorPane;
034: import javax.swing.JFrame;
035: import javax.swing.JScrollPane;
036: import javax.swing.JTabbedPane;
037: import javax.swing.JTextPane;
038:
039: import biz.hammurapi.diagram.Descriptable;
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 NamelessDiagramElementPropertiesDialog extends
052: javax.swing.JDialog {
053: private JButton okButton;
054:
055: private JButton cancelButton;
056:
057: private JEditorPane descriptionEditorPane;
058:
059: private JScrollPane descriptionScrollPane;
060:
061: private JTabbedPane tabbedPanel;
062:
063: private Descriptable 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: NamelessDiagramElementPropertiesDialog inst = new NamelessDiagramElementPropertiesDialog(
072: frame, null);
073: inst.setVisible(true);
074: frame.dispose();
075: //System.exit(0);
076: }
077:
078: public NamelessDiagramElementPropertiesDialog(Frame frame,
079: Descriptable data) {
080: super (frame);
081: this .data = data;
082: initGUI();
083: descriptionEditorPane.setText(data.getDescription());
084: }
085:
086: private void initGUI() {
087: try {
088: GridBagLayout this Layout = new GridBagLayout();
089: this Layout.rowWeights = new double[] { 0.1, 0.0 };
090: this Layout.rowHeights = new int[] { 303, 7 };
091: this Layout.columnWeights = new double[] { 0.0, 0.1, 0.0 };
092: this Layout.columnWidths = new int[] { 45, 354, 7 };
093: getContentPane().setLayout(this Layout);
094: this .setName("Properties");
095: this .setModal(true);
096: this .setTitle("Properties");
097: {
098: okButton = new JButton();
099: getContentPane().add(
100: okButton,
101: new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
102: GridBagConstraints.EAST,
103: GridBagConstraints.NONE, new Insets(3,
104: 0, 3, 3), 0, 0));
105: okButton.setText("OK");
106: okButton.addActionListener(new ActionListener() {
107: public void actionPerformed(ActionEvent evt) {
108: okButtonActionPerformed(evt);
109: }
110: });
111: }
112: {
113: cancelButton = new JButton();
114: getContentPane().add(
115: cancelButton,
116: new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
117: GridBagConstraints.WEST,
118: GridBagConstraints.NONE, new Insets(3,
119: 0, 3, 3), 0, 0));
120: cancelButton.setText("Cancel");
121: cancelButton.addActionListener(new ActionListener() {
122: public void actionPerformed(ActionEvent evt) {
123: cancelButtonActionPerformed(evt);
124: }
125: });
126: }
127: {
128: tabbedPanel = new JTabbedPane();
129: getContentPane().add(
130: tabbedPanel,
131: new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
132: GridBagConstraints.NORTHWEST,
133: GridBagConstraints.BOTH, new Insets(0,
134: 0, 0, 0), 0, 0));
135: {
136: descriptionScrollPane = new JScrollPane();
137: tabbedPanel.addTab("Description", null,
138: descriptionScrollPane, null);
139: descriptionScrollPane
140: .setPreferredSize(new java.awt.Dimension(
141: 360, 159));
142: descriptionScrollPane.setAutoscrolls(true);
143: {
144: descriptionEditorPane = new JTextPane();
145: descriptionScrollPane
146: .setViewportView(descriptionEditorPane);
147: descriptionEditorPane.setText("Description");
148: descriptionEditorPane
149: .setPreferredSize(new java.awt.Dimension(
150: 185, 74));
151: }
152: }
153: }
154: this .setSize(500, 400);
155: } catch (Exception e) {
156: e.printStackTrace();
157: }
158: }
159:
160: public static boolean compareStrings(String str1, String str2) {
161: if (str1 == str2) {
162: return true;
163: }
164: if (str1 == null || str1.trim().length() == 0) {
165: return str2 == null || str2.trim().length() == 0;
166: }
167:
168: return str1.equals(str2);
169: }
170:
171: private boolean ok;
172:
173: public boolean edit() {
174: ok = false;
175: setVisible(true);
176: return ok;
177: }
178:
179: private void okButtonActionPerformed(ActionEvent evt) {
180: data.setDescription(descriptionEditorPane.getText());
181: ok = true;
182: cancelButtonActionPerformed(evt);
183: }
184:
185: private void cancelButtonActionPerformed(ActionEvent evt) {
186: setVisible(false);
187: dispose();
188: }
189: }
|