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 com.metaboss.applications.designstudio.Application;
021: import com.metaboss.applications.designstudio.BaseAction;
022: import com.metaboss.applications.designstudio.BasePropertiesDialog;
023: import com.metaboss.applications.designstudio.BaseUserObject;
024: import com.metaboss.applications.designstudio.components.SeparatorAction;
025: import com.metaboss.applications.designstudio.propertiesdialogs.EventSubscriptionPropertiesDialog;
026: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscription;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscriptionClass;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
031:
032: /* Event Subscription user object */
033:
034: public class EventSubscriptionUserObject extends BaseUserObject {
035: public static final int ADD_UPDATEEVENT = 1;
036:
037: private EventSubscription mEventSubscription = null;
038: private AddNewSubscriptionOperationAction mAddNewSubscriptionOperationAction = new AddNewSubscriptionOperationAction();
039: private AddNewEventAction mAddNewEventAction = new AddNewEventAction();
040: private StudyDependenciesAction mShowDataTypeDependenciesAction = new StudyDependenciesAction();
041:
042: public EventSubscriptionUserObject(
043: EventSubscription pEventSubscription) {
044: super (pEventSubscription, Application.EVENTSUBSCRIPTION_ICON);
045: mEventSubscription = pEventSubscription;
046: }
047:
048: public EventSubscriptionUserObject(
049: EventSubscription pEventSubscription, String pCaption,
050: int pMode) {
051: super (pEventSubscription, pCaption, pMode);
052: mEventSubscription = pEventSubscription;
053: }
054:
055: // create new service module
056: public static void addNewEventSubscription(
057: Servicemodule pServicemodule) throws Exception {
058: new EventSubscriptionUserObject(null).addNewObject(
059: getObjectPackage(pServicemodule), pServicemodule
060: .getEventSubscriptions());
061: }
062:
063: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
064: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
065: .getEnterpriseModel();
066: EventSubscriptionClass lClass = lEnterpriseModelPackage
067: .getEventSubscription();
068: return new EventSubscriptionUserObject(lClass
069: .createEventSubscription());
070: }
071:
072: // return object root node captions
073: public String getRootNodeName() {
074: return Application.getString("eventsubscriptions_node");
075: }
076:
077: public EventSubscription getEventSubscription() {
078: return mEventSubscription;
079: }
080:
081: // fill actions list
082: public void fillActionsList(ArrayList pList) {
083: switch (mMode) {
084: case ALL_ACTIONS:
085: super .fillActionsList(pList);
086: pList.add(new SeparatorAction());
087: if (mEventSubscription.getSubscriptionOperation() == null)
088: pList.add(mAddNewSubscriptionOperationAction);
089: pList.add(mAddNewEventAction);
090: pList.add(new SeparatorAction());
091: pList.add(mShowDataTypeDependenciesAction);
092: break;
093: case ADD_UPDATEEVENT:
094: pList.add(mAddNewEventAction);
095: break;
096: }
097: }
098:
099: // get object editor
100: public BasePropertiesDialog getObjectEditor() {
101: return new EventSubscriptionPropertiesDialog();
102: }
103:
104: // add new event
105: private void addNewEvent() throws Exception {
106: EventUserObject.addNewEvent(mEventSubscription);
107: }
108:
109: // add new subscription operation
110: private void addNewSubscriptionOperation() throws Exception {
111: EventSubscriptionOperationUserObject
112: .addNewEventSubscriptionOperation(mEventSubscription);
113: }
114:
115: /* Actions */
116:
117: /* Add New Subscription Operation Action Class */
118:
119: public class AddNewSubscriptionOperationAction extends BaseAction {
120: public AddNewSubscriptionOperationAction() {
121: super ("Add New Subscription Operation", Application
122: .getAddIcon(Application.OPERATION_ICON));
123: }
124:
125: public void actionPerformed(ActionEvent e) {
126: try {
127: addNewSubscriptionOperation();
128: } catch (Throwable t) {
129: t.printStackTrace();
130: }
131: }
132: }
133:
134: /* Add New Event Action Class */
135:
136: public class AddNewEventAction extends BaseAction {
137: public AddNewEventAction() {
138: super ("Add New Event", Application
139: .getAddIcon(Application.EVENT_ICON));
140: }
141:
142: public void actionPerformed(ActionEvent e) {
143: try {
144: addNewEvent();
145: } catch (Throwable t) {
146: t.printStackTrace();
147: }
148: }
149: }
150: }
|