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.userobjects;
016:
017: import java.awt.event.ActionEvent;
018: import java.util.ArrayList;
019:
020: import javax.swing.JTabbedPane;
021:
022: import com.metaboss.applications.designstudio.Application;
023: import com.metaboss.applications.designstudio.BaseAction;
024: import com.metaboss.applications.designstudio.BasePropertiesDialog;
025: import com.metaboss.applications.designstudio.BaseUserObject;
026: import com.metaboss.applications.designstudio.components.SeparatorAction;
027: import com.metaboss.applications.designstudio.fieldstable.FieldsViewPanel;
028: import com.metaboss.applications.designstudio.propertiesdialogs.EventPropertiesDialog;
029: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
031: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Event;
032: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventClass;
033: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscription;
034:
035: /* Event user pbject */
036:
037: public class EventUserObject extends BaseUserObject {
038: public static final int ADD_DATAFIELD = 1;
039: public static final int ADD_MESSAGEFIELD = 2;
040:
041: private Event mEvent = null;
042: private AddNewEventDataFieldAction mAddNewEventDataFieldAction = new AddNewEventDataFieldAction();
043: private AddNewEventMessageFieldAction mAddNewEventMessageFieldAction = new AddNewEventMessageFieldAction();
044: private StudyDependenciesAction mShowDataTypeDependenciesAction = new StudyDependenciesAction();
045:
046: public EventUserObject(Event pEvent) {
047: super (pEvent, Application.EVENT_ICON);
048: mEvent = pEvent;
049: }
050:
051: public EventUserObject(Event pEvent, String pCaption, int pMode) {
052: super (pEvent, pCaption, pMode);
053: mEvent = pEvent;
054: }
055:
056: // create new event
057: public static void addNewEvent(EventSubscription pEventSubscription)
058: throws Exception {
059: EventUserObject lObject = new EventUserObject(null);
060: lObject.addNewObject(getObjectPackage(pEventSubscription),
061: pEventSubscription.getEvents());
062: }
063:
064: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
065: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
066: .getEnterpriseModel();
067: EventClass lClass = lEnterpriseModelPackage.getEvent();
068: return new EventUserObject(lClass.createEvent());
069: }
070:
071: // return object root node captions
072: public String getRootNodeName() {
073: return Application.getString("updateevents_node");
074: }
075:
076: public Event getEvent() {
077: return mEvent;
078: }
079:
080: // get object editor
081: public BasePropertiesDialog getObjectEditor() {
082: return new EventPropertiesDialog();
083: }
084:
085: // fill actions list
086: public void fillActionsList(ArrayList pList) {
087: switch (mMode) {
088: case ALL_ACTIONS:
089: super .fillActionsList(pList);
090: pList.add(new SeparatorAction());
091: pList.add(mAddNewEventDataFieldAction);
092: pList.add(mAddNewEventMessageFieldAction);
093: pList.add(new SeparatorAction());
094: pList.add(mShowDataTypeDependenciesAction);
095: break;
096: case ADD_DATAFIELD:
097: pList.add(mAddNewEventDataFieldAction);
098: break;
099: case ADD_MESSAGEFIELD:
100: pList.add(mAddNewEventMessageFieldAction);
101: break;
102: }
103: }
104:
105: // convert tree element to an action code
106: public int convertCaptionToAction(String pCaption) {
107: if (pCaption.equals(Application.getString("datafields_node")))
108: return ADD_DATAFIELD;
109: else if (pCaption.equals(Application
110: .getString("messagefields_node")))
111: return ADD_MESSAGEFIELD;
112: else
113: return super .convertCaptionToAction(pCaption);
114: }
115:
116: // add extra properties tabs
117: public void addExtraPropertiesTabs(JTabbedPane pTabbedPane) {
118: super .addExtraPropertiesTabs(pTabbedPane);
119: pTabbedPane.insertTab("Data Fields", null, new FieldsViewPanel(
120: mEvent, 1), null, 1);
121: pTabbedPane.insertTab("Message Fields", null,
122: new FieldsViewPanel(mEvent, 2), null, 2);
123: }
124:
125: // add event data field
126: private void addNewEventDataFiled() throws Exception {
127: EventDataFieldUserObject.addNewEventDataFieldField(mEvent);
128: }
129:
130: // add event message field
131: private void addNewEventMessgaeFiled() throws Exception {
132: EventMessageFieldUserObject.addNewField(mEvent);
133: }
134:
135: /* Actions */
136:
137: /* Add New Event Data Field Action Class */
138:
139: public class AddNewEventDataFieldAction extends BaseAction {
140: public AddNewEventDataFieldAction() {
141: super ("Add New Data Field", Application
142: .getAddIcon(Application.FIELDS_ICON));
143: }
144:
145: public void actionPerformed(ActionEvent e) {
146: try {
147: addNewEventDataFiled();
148: } catch (Throwable t) {
149: t.printStackTrace();
150: }
151: }
152: }
153:
154: /* Add New Event Message Field Action Class */
155:
156: public class AddNewEventMessageFieldAction extends BaseAction {
157: public AddNewEventMessageFieldAction() {
158: super ("Add New Message Field", Application
159: .getAddIcon(Application.MESSAGE_ICON));
160: }
161:
162: public void actionPerformed(ActionEvent e) {
163: try {
164: addNewEventMessgaeFiled();
165: } catch (Throwable t) {
166: t.printStackTrace();
167: }
168: }
169: }
170: }
|