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.structuresmodel;
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.StructureUserObject;
23: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
24: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
26: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.DiagramModelElement;
27: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.ServicemoduleStructuresDiagram;
28:
29: /* Structures diagram Model class */
30:
31: public class StructuresModel extends BaseGraphModel {
32: /** Constructor. */
33: public StructuresModel(ServicemoduleStructuresDiagram pDiagram)
34: throws Exception {
35: super (pDiagram.getServicemodule(), pDiagram);
36: }
37:
38: // return service module
39: public Servicemodule getServiceModule() {
40: Object lObject = getBOObject();
41: if (lObject != null && lObject instanceof Servicemodule)
42: return (Servicemodule) lObject;
43: else
44: return null;
45: }
46:
47: // load graph model
48: public void loadModel() throws Exception {
49: super .loadModel();
50:
51: ServicemoduleStructuresDiagram lDiagram = (ServicemoduleStructuresDiagram) mDiagram;
52: Object[] lElements = lDiagram.getElements().toArray();
53:
54: // Entity cells
55: for (int i = 0; i < lElements.length; i++) {
56: DiagramModelElement lElement = (DiagramModelElement) lElements[i];
57: ModelElement lModelElement = lElement.getModelElement();
58: if (lModelElement != null
59: && lModelElement instanceof Structure) {
60: Structure lStructure = (Structure) lModelElement;
61: addStructureCell(lStructure, getPosition(lStructure));
62: }
63: }
64: }
65:
66: // add structure cell
67: public DefaultGraphCell addStructureCell(Structure pStructure,
68: Point lPosition) throws Exception {
69: return addVertex(new StructureUserObject(pStructure),
70: lPosition, null, getVertexStyle());
71: }
72: }
|