001: //THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: //CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: //BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: //OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: //LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: //EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: //POSSIBILITY OF SUCH DAMAGE.
013: //
014: //Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.propertiesdialogs;
016:
017: import java.awt.Dimension;
018:
019: import javax.swing.JComboBox;
020: import javax.swing.JTextArea;
021:
022: import com.metaboss.applications.designstudio.Application;
023: import com.metaboss.applications.designstudio.BaseUserObject;
024: import com.metaboss.applications.designstudio.complexfield.ComplexBox;
025: import com.metaboss.applications.designstudio.userobjects.EventItem;
026: import com.metaboss.applications.designstudio.userobjects.UserObjectFactory;
027: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscription;
029:
030: /* Event Subscription object properties dialog */
031:
032: public class EventSubscriptionPropertiesDialog extends
033: ModelElementPropertiesDialog {
034: private String mName = "";
035: private JComboBox mEventField = new EventField(
036: "Synchronisation Event");
037: private JTextArea mDescriptionField = new JTextArea(8, 40);
038:
039: public EventSubscriptionPropertiesDialog() {
040: super ("Event Subscription", new Dimension(500, 300));
041:
042: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
043: //addComboBox(mPropertiesPanel, "Synchronisation Event: ", mEventField, 2, false);
044: addComplexFieldWithEdit(mPropertiesPanel,
045: (ComplexBox) mEventField, 2, false);
046: addTextArea(mPropertiesPanel, "Description: ",
047: mDescriptionField, 3, false);
048:
049: mEventField.addItemListener(new NameElementChangeListener());
050: }
051:
052: // load service module properties
053: public void loadProperties(ModelElement pObject) throws Exception {
054: if (pObject != null && pObject instanceof EventSubscription) {
055: EventSubscription lEventSubscription = (EventSubscription) pObject;
056:
057: EventItem.loadBoxWithEvents(mEventField,
058: lEventSubscription, true);
059:
060: mNameField.setText(pObject.getName());
061: mEventField.setSelectedIndex(EventItem.findEventItemIndex(
062: mEventField, lEventSubscription
063: .getSynchronisationEvent()));
064: mDescriptionField.setText(pObject.getDescription());
065: }
066: super .loadProperties(pObject);
067: }
068:
069: // save service module proeprties
070: public void saveProperties(ModelElement pObject) throws Exception {
071: super .saveProperties(pObject);
072: if (pObject != null && pObject instanceof EventSubscription) {
073: EventSubscription lEventSubscription = (EventSubscription) pObject;
074:
075: pObject.setName(mNameField.getText());
076: pObject.setDescription(mDescriptionField.getText());
077:
078: EventItem lItem = (EventItem) mEventField.getSelectedItem();
079: if (lItem != null)
080: lEventSubscription
081: .setSynchronisationEvent(lItem.mEvent);
082: else
083: lEventSubscription.setSynchronisationEvent(null);
084: }
085: }
086:
087: // check fields data
088: public boolean checkProperties() {
089: if (mNameField.getText().length() == 0) {
090: Application.showError("Name field could not be blank!");
091: return false;
092: }
093: return super .checkProperties();
094: }
095:
096: /* Event Field */
097:
098: public class EventField extends ComplexBox {
099: public EventField(String pCaption) {
100: super (pCaption);
101: }
102:
103: public BaseUserObject getSelectedUserObject() {
104: EventItem lItem = (EventItem) mEventField.getSelectedItem();
105: return (lItem != null) ? UserObjectFactory
106: .createUserObject(lItem.mEvent) : null;
107: }
108: }
109: }
|