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.SimpleObjectPropertiesdialog;
026: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System;
031: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.SystemClass;
032:
033: /* BOSystem user object class */
034:
035: public class SystemUserObject extends BaseUserObject {
036: public static final int APPLICATION_ACTION = 1;
037: public static final int DOMAIN_ACTION = 2;
038: public static final int SERVICEMODULE_ACTION = 3;
039: public static final int PUBLICINTERFACES_ACTION = 4;
040: public static final int IMPLEMETATIONCOMPONENTS_ACTION = 5;
041:
042: private System mSystem = null;
043: private AddNewApplicationAction mAddNewApplicationAction = new AddNewApplicationAction();
044: private AddNewDomainAction mAddNewDomainAction = new AddNewDomainAction();
045: private AddNewServiceModuleAction mAddServiceModuleAction = new AddNewServiceModuleAction();
046: private StudyDependenciesAction mShowDataTypeDependenciesAction = new StudyDependenciesAction();
047: private AddNewUsageSpecificationAction mAddNewUsageSpecificationAction = new AddNewUsageSpecificationAction();
048:
049: public SystemUserObject(System pSystem) {
050: super (pSystem, Application.SYSTEM_ICON);
051: mSystem = pSystem;
052: }
053:
054: public SystemUserObject(System pSystem, String pCaption, int pMode) {
055: super (pSystem, pCaption, pMode);
056: mSystem = pSystem;
057: }
058:
059: // create new system
060: public static SystemUserObject addNewSystem(Enterprise pEnterprise)
061: throws Exception {
062: return (SystemUserObject) new SystemUserObject(null)
063: .addNewObject(getObjectPackage(pEnterprise),
064: pEnterprise.getSystems());
065: }
066:
067: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
068: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
069: .getEnterpriseModel();
070: SystemClass lSystemClass = lEnterpriseModelPackage.getSystem();
071: return new SystemUserObject(lSystemClass.createSystem());
072: }
073:
074: // return object root node captions
075: public String getRootNodeName() {
076: return Application.getString("systems_node");
077: }
078:
079: // convert tree element to an action code
080: public int convertCaptionToAction(String pCaption) {
081: if (pCaption.equals(Application
082: .getString("publicinterfaces_node")))
083: return PUBLICINTERFACES_ACTION;
084: else if (pCaption.equals(Application
085: .getString("servicemodules_node")))
086: return SERVICEMODULE_ACTION;
087: else if (pCaption.equals(Application
088: .getString("implemetationcomponents_node")))
089: return IMPLEMETATIONCOMPONENTS_ACTION;
090: else if (pCaption.equals(Application.getString("domains_node")))
091: return DOMAIN_ACTION;
092: else
093: return super .convertCaptionToAction(pCaption);
094: }
095:
096: public System getSystem() {
097: return mSystem;
098: }
099:
100: // fill actions list
101: public void fillActionsList(ArrayList pList) {
102: switch (mMode) {
103: case ALL_ACTIONS:
104: super .fillActionsList(pList);
105: pList.add(new SeparatorAction());
106: //???pList.add(mAddNewApplicationAction);
107: pList.add(mAddNewDomainAction);
108: pList.add(mAddServiceModuleAction);
109: if (mSystem.getUsageSpecification() == null)
110: pList.add(mAddNewUsageSpecificationAction);
111: pList.add(new SeparatorAction());
112: pList.add(mShowDataTypeDependenciesAction);
113: break;
114: case APPLICATION_ACTION:
115: pList.add(mAddNewApplicationAction);
116: break;
117: case DOMAIN_ACTION:
118: pList.add(mAddNewDomainAction);
119: break;
120: case SERVICEMODULE_ACTION:
121: pList.add(mAddServiceModuleAction);
122: break;
123: case PUBLICINTERFACES_ACTION:
124: pList.add(mAddServiceModuleAction);
125: break;
126: case IMPLEMETATIONCOMPONENTS_ACTION:
127: pList.add(mAddNewDomainAction);
128: break;
129: }
130: }
131:
132: // add new Domain
133: public void addNewDomain() throws Exception {
134: DomainUserObject.addNewDomain(mSystem);
135: }
136:
137: // add new service module
138: public void addNewServiceModule() throws Exception {
139: ServicemoduleUserObject.addNewServiceModule(mSystem);
140: }
141:
142: // add new state machine
143: public void addNewUsageSpecification() throws Exception {
144: UsageSpecificationUserObject.addNewStateMachine(mSystem);
145: }
146:
147: // get object editor
148: public BasePropertiesDialog getObjectEditor() {
149: return new SimpleObjectPropertiesdialog("System");
150: }
151:
152: // returns true if drop object could be accepted
153: public boolean canAcceptDropObject(BaseUserObject pUserObject,
154: boolean pCopy) {
155: if (pUserObject != null
156: && super .canAcceptDropObject(pUserObject, pCopy)) {
157: if ((pUserObject instanceof ServicemoduleUserObject && (mMode == BaseUserObject.ALL_ACTIONS || mMode == SystemUserObject.SERVICEMODULE_ACTION))) {
158: return (pCopy) ? pUserObject.canDuplicate() : true;
159: }
160: }
161: return false;
162: }
163:
164: // acccept drop target in transaction
165: protected void transactionalAccept(BaseUserObject pUserObject,
166: boolean pCopy) throws Exception {
167: if (pUserObject != null) {
168: if (pUserObject instanceof ServicemoduleUserObject) {
169: ServicemoduleUserObject lUserObject = (ServicemoduleUserObject) pUserObject;
170: if (pCopy) {
171: Servicemodule lServicemodule = (Servicemodule) Application.sModelRepository
172: .duplicateModelElement(lUserObject
173: .getServiceModule());
174: lServicemodule.setSystem(mSystem);
175: } else
176: lUserObject.getServiceModule().setSystem(mSystem);
177: }
178: }
179: }
180:
181: /* Actions */
182:
183: /* Add New Application Action Class */
184:
185: public class AddNewApplicationAction extends BaseAction {
186: public AddNewApplicationAction() {
187: super ("Add New Applciation", Application
188: .getAddIcon(Application.APPLICATION_ICON));
189: }
190:
191: public void actionPerformed(ActionEvent e) {
192: try {
193: //???addNewApplication();
194: } catch (Throwable t) {
195: t.printStackTrace();
196: }
197: }
198: }
199:
200: /* Add New Domain Action Class */
201:
202: public class AddNewDomainAction extends BaseAction {
203: public AddNewDomainAction() {
204: super ("Add New Domain", Application
205: .getAddIcon(Application.DOMAIN_ICON));
206: }
207:
208: public void actionPerformed(ActionEvent e) {
209: try {
210: addNewDomain();
211: } catch (Throwable t) {
212: t.printStackTrace();
213: }
214: }
215: }
216:
217: /* Add New Service Module Action Class */
218:
219: public class AddNewServiceModuleAction extends BaseAction {
220: public AddNewServiceModuleAction() {
221: super ("Add New Service Module", Application
222: .getAddIcon(Application.SERVICEMODULE_ICON));
223: }
224:
225: public void actionPerformed(ActionEvent e) {
226: try {
227: addNewServiceModule();
228: } catch (Throwable t) {
229: t.printStackTrace();
230: }
231: }
232: }
233:
234: /* Add New Usage Specification Class */
235:
236: public class AddNewUsageSpecificationAction extends BaseAction {
237: public AddNewUsageSpecificationAction() {
238: super ("Add New Usage Specification", Application
239: .getAddIcon(Application.USAGESPECIFICATION_ICON));
240: }
241:
242: public void actionPerformed(ActionEvent e) {
243: try {
244: addNewUsageSpecification();
245: } catch (Throwable t) {
246: t.printStackTrace();
247: }
248: }
249: }
250: }
|