01: //THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: //CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: //BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: //OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: //LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: //EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: //POSSIBILITY OF SUCH DAMAGE.
13: //
14: //Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.usecasesmodel;
16:
17: import java.awt.Point;
18:
19: import org.jgraph.graph.DefaultGraphCell;
20:
21: import com.metaboss.applications.designstudio.BaseGraphModel;
22: import com.metaboss.applications.designstudio.userobjects.ActorsUserObject;
23: import com.metaboss.applications.designstudio.userobjects.UseCaseUserObject;
24: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.AbstractNamespace;
26: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.Actor;
27: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.UseCase;
28: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.DiagramModelElement;
29: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.SystemUseCasesDiagram;
30:
31: /* Use cases diagram model */
32:
33: public class UseCasesModel extends BaseGraphModel {
34: public UseCasesModel(SystemUseCasesDiagram pDiagram)
35: throws Exception {
36: super (pDiagram.getUsageSpecificationNamespace(), pDiagram);
37: }
38:
39: // return absract namespace
40: public AbstractNamespace getNamespace() {
41: Object lObject = getBOObject();
42: if (lObject != null && lObject instanceof AbstractNamespace)
43: return (AbstractNamespace) lObject;
44: else
45: return null;
46: }
47:
48: // load graph model
49: public void loadModel() throws Exception {
50: super .loadModel();
51:
52: SystemUseCasesDiagram lDiagram = (SystemUseCasesDiagram) mDiagram;
53: Object[] lElements = lDiagram.getElements().toArray();
54:
55: // Entity cells
56: for (int i = 0; i < lElements.length; i++) {
57: DiagramModelElement lElement = (DiagramModelElement) lElements[i];
58: ModelElement lModelElement = lElement.getModelElement();
59:
60: if (lModelElement != null) {
61: if (lModelElement instanceof UseCase) {
62: UseCase lUseCase = (UseCase) lModelElement;
63: addUseCaseCell(lUseCase, getPosition(lUseCase));
64: } else if (lModelElement instanceof Actor) {
65: Actor lActor = (Actor) lModelElement;
66: addActorCell(lActor, getPosition(lActor));
67: }
68: }
69: }
70: }
71:
72: // add structure cell
73: public DefaultGraphCell addUseCaseCell(UseCase pUseCase,
74: Point lPosition) throws Exception {
75: return addVertex(new UseCaseUserObject(pUseCase), lPosition,
76: null, getVertexStyle());
77: }
78:
79: // add actor cell
80: public DefaultGraphCell addActorCell(Actor pActor, Point lPosition)
81: throws Exception {
82: return addVertex(new ActorsUserObject(pActor), lPosition, null,
83: getVertexStyle());
84: }
85: }
|