001: /*--
002:
003: Copyright (C) 2002 Anthony Eden.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: me@anthonyeden.com.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Anthony Eden (me@anthonyeden.com).
027:
028: In addition, I request (but do not require) that you include in the
029: end-user documentation provided with the redistribution and/or in the
030: software itself an acknowledgement equivalent to the following:
031: "This product includes software developed by
032: Anthony Eden (http://www.anthonyeden.com/)."
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
038: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
039: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
040: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
041: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
042: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
043: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
044: POSSIBILITY OF SUCH DAMAGE.
045:
046: For more information on OBE, please see <http://obe.sourceforge.net/>.
047:
048: */
049:
050: package org.obe.designer.editor;
051:
052: import java.awt.Insets;
053: import java.awt.GridBagLayout;
054: import java.awt.GridBagConstraints;
055:
056: import javax.swing.JPanel;
057: import javax.swing.JLabel;
058: import javax.swing.JTextArea;
059: import javax.swing.JTextField;
060: import javax.swing.JScrollPane;
061: import javax.swing.BorderFactory;
062:
063: import org.obe.xpdl.model.misc.AbstractWFElement;
064: import org.obe.xpdl.model.misc.AbstractWFElement;
065: import org.obe.designer.util.Constants;
066: import org.obe.designer.panel.ExtendedAttributesPanel;
067:
068: public class EntityEditor extends JPanel {
069:
070: private AbstractWFElement element;
071:
072: private JLabel idLabel;
073: private JTextField idField;
074: private JLabel nameLabel;
075: private JTextField nameField;
076: private JLabel descriptionLabel;
077: private JTextArea descriptionArea;
078: private ExtendedAttributesPanel extendedAttributesPanel;
079:
080: public EntityEditor() {
081: init();
082: }
083:
084: public EntityEditor(AbstractWFElement element) {
085: init();
086: setElement(element);
087: }
088:
089: public AbstractWFElement getElement() {
090: return element;
091: }
092:
093: public void setElement(AbstractWFElement element) {
094: this .element = element;
095: revert();
096: }
097:
098: public String getId() {
099: return idField.getText();
100: }
101:
102: public String getName() {
103: return nameField.getText();
104: }
105:
106: public String getDescription() {
107: return descriptionArea.getText();
108: }
109:
110: /*
111: public Map getExtendedAttributes(Map extendedAttributes){
112:
113: }
114: */
115:
116: public boolean save() {
117: if (element != null) {
118: element.setId(idField.getText());
119: element.setName(nameField.getText());
120: element.setDescription(descriptionArea.getText());
121: //element.setExtendedAttributes();
122: }
123: return true;
124: }
125:
126: public void revert() {
127: if (element != null) {
128: idField.setText(element.getId());
129: nameField.setText(element.getName());
130: descriptionArea.setText(element.getDescription());
131: extendedAttributesPanel.setExtendedAttributes(element
132: .getExtendedAttributes());
133: }
134: }
135:
136: private void init() {
137: GridBagLayout gbl = new GridBagLayout();
138: GridBagConstraints gbc = new GridBagConstraints();
139: setLayout(gbl);
140:
141: gbc.insets = new Insets(1, 1, 1, 1);
142: gbc.anchor = GridBagConstraints.WEST;
143: gbc.fill = GridBagConstraints.HORIZONTAL;
144:
145: idLabel = new JLabel("ID");
146: gbc.weightx = 0;
147: gbc.gridwidth = 1;
148: gbl.setConstraints(idLabel, gbc);
149: add(idLabel);
150:
151: idField = new JTextField();
152: idField.setColumns(Constants.DEFAULT_COLUMNS);
153: gbc.weightx = 1;
154: gbc.gridwidth = GridBagConstraints.REMAINDER;
155: gbl.setConstraints(idField, gbc);
156: add(idField);
157:
158: nameLabel = new JLabel("Name");
159: gbc.weightx = 0;
160: gbc.gridwidth = 1;
161: gbl.setConstraints(nameLabel, gbc);
162: add(nameLabel);
163:
164: nameField = new JTextField();
165: gbc.weightx = 1;
166: gbc.gridwidth = GridBagConstraints.REMAINDER;
167: gbl.setConstraints(nameField, gbc);
168: add(nameField);
169:
170: descriptionLabel = new JLabel("Description");
171: gbc.weightx = 0;
172: gbc.gridwidth = 1;
173: gbc.anchor = GridBagConstraints.NORTHWEST;
174: gbl.setConstraints(descriptionLabel, gbc);
175: add(descriptionLabel);
176:
177: descriptionArea = new JTextArea();
178: descriptionArea.setRows(2);
179: descriptionArea.setColumns(32);
180: JScrollPane sp = new JScrollPane(descriptionArea);
181: gbc.gridwidth = GridBagConstraints.REMAINDER;
182: gbc.weighty = 1;
183: gbc.fill = GridBagConstraints.BOTH;
184: gbl.setConstraints(sp, gbc);
185: add(sp);
186:
187: extendedAttributesPanel = new ExtendedAttributesPanel();
188: extendedAttributesPanel.setBorder(BorderFactory
189: .createTitledBorder("Extended Attributes"));
190: gbc.weighty = 0;
191: gbc.fill = GridBagConstraints.BOTH;
192: gbl.setConstraints(extendedAttributesPanel, gbc);
193: add(extendedAttributesPanel);
194: }
195:
196: }
|