Source Code Cross Referenced for StatesModel.java in  » UML » MetaBoss » com » metaboss » applications » designstudio » statesmodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » MetaBoss » com.metaboss.applications.designstudio.statesmodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.statesmodel;
016:
017:        import java.awt.Color;
018:        import java.awt.Point;
019:        import java.util.Map;
020:
021:        import javax.swing.Icon;
022:        import javax.swing.ImageIcon;
023:
024:        import org.jgraph.graph.DefaultEdge;
025:        import org.jgraph.graph.DefaultGraphCell;
026:        import org.jgraph.graph.DefaultPort;
027:        import org.jgraph.graph.GraphConstants;
028:
029:        import com.metaboss.applications.designstudio.Application;
030:        import com.metaboss.applications.designstudio.BaseGraphModel;
031:        import com.metaboss.applications.designstudio.icons.IconsHolder;
032:        import com.metaboss.applications.designstudio.userobjects.StateUserObject;
033:        import com.metaboss.applications.designstudio.userobjects.TransitionUserObject;
034:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
035:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
036:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.State;
037:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.StateTypeEnum;
038:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.Transition;
039:        import com.metaboss.sdlctools.models.metabossmodel.visualmodel.DiagramModelElement;
040:        import com.metaboss.sdlctools.models.metabossmodel.visualmodel.EntityStateDiagram;
041:
042:        /*		Entity States diagram Model class 		*/
043:
044:        public class StatesModel extends BaseGraphModel {
045:            public static ImageIcon sInitialStateIcon = IconsHolder
046:                    .loadIcon("initialstate.gif");
047:            public static ImageIcon sFinalStateIcon = IconsHolder
048:                    .loadIcon("finalstate.gif");
049:
050:            /** Constructor. */
051:            public StatesModel(EntityStateDiagram pDiagram) throws Exception {
052:                super (pDiagram.getEntity(), pDiagram);
053:            }
054:
055:            // return entity
056:            public Entity getEntity() {
057:                Object lObject = getBOObject();
058:                if (lObject != null && lObject instanceof  Entity)
059:                    return (Entity) lObject;
060:                else
061:                    return null;
062:            }
063:
064:            // get diagram interface
065:            /*public Diagram getDiaram() throws Exception
066:            {
067:            	Entity lEntity = getEntity();
068:            	if (lEntity!=null)
069:            	{
070:            		Object[] lDigrams = lEntity.getEntityStateDiagrams().toArray();
071:            		if (lDigrams.length>0) 
072:            			return (Diagram)lDigrams[0];
073:            		else
074:            		{
075:            			Diagram lDiagram = null;
076:            			Application.beginTransaction();
077:            			try
078:            			{
079:            				lDiagram = getPackage().getVisualModel().getEntityStateDiagram().createEntityStateDiagram();
080:            				lDiagram.setName("EntityStateDiagram");
081:            				lEntity.getEntityStateDiagrams().add(lDiagram);
082:            				Application.commit();
083:            			}
084:            			finally
085:            			{
086:            				if (Application.isInTransaction()) Application.rollback();
087:            			}
088:            			return lDiagram;
089:            		}
090:            	}
091:            	return null;
092:            }*/
093:
094:            // load graph model
095:            public void loadModel() throws Exception {
096:                super .loadModel();
097:
098:                EntityStateDiagram lDiagram = (EntityStateDiagram) mDiagram;
099:                Object[] lElements = lDiagram.getElements().toArray();
100:
101:                // States cells
102:                for (int i = 0; i < lElements.length; i++) {
103:                    DiagramModelElement lElement = (DiagramModelElement) lElements[i];
104:                    ModelElement lModelElement = lElement.getModelElement();
105:                    if (lModelElement != null && lModelElement instanceof  State) {
106:                        State lState = (State) lModelElement;
107:                        addStateCell(lState, getPosition(lState));
108:                    }
109:                }
110:                // Associations
111:                for (int i = 0; i < lElements.length; i++) {
112:                    DiagramModelElement lElement = (DiagramModelElement) lElements[i];
113:                    ModelElement lModelElement = lElement.getModelElement();
114:                    if (lModelElement != null
115:                            && lModelElement instanceof  Transition) {
116:                        Transition lTransition = (Transition) lModelElement;
117:                        addTransition(lTransition);
118:                    }
119:                }
120:            }
121:
122:            // add state cell
123:            public DefaultGraphCell addStateCell(State pState, Point lPosition)
124:                    throws Exception {
125:                return addVertex(new StateUserObject(pState), lPosition, null,
126:                        createStateStyle(pState));
127:            }
128:
129:            // create State vertex Style
130:            public Map createStateStyle(State pState) throws Exception {
131:                Map lResult = getVertexStyle();
132:                if (pState != null) {
133:                    Icon lIcon = getStateIcon(pState);
134:                    if (lIcon != null)
135:                        GraphConstants.setIcon(lResult, lIcon);
136:                }
137:                return lResult;
138:            }
139:
140:            public Icon getStateIcon(State pState) {
141:                if (pState != null) {
142:                    if (pState.getType() == StateTypeEnum.FINAL)
143:                        return sFinalStateIcon;
144:                    else if (pState.getType() == StateTypeEnum.INITIAL)
145:                        return sInitialStateIcon;
146:                }
147:                return null;
148:            }
149:
150:            public void checkState(State pState) throws Exception {
151:                DefaultGraphCell lCell = findElementCell(pState);
152:                if (lCell != null) {
153:                    Icon lIcon = getStateIcon(pState);
154:                    if (lIcon != null)
155:                        GraphConstants.setIcon(lCell.getAttributes(), lIcon);
156:                    else
157:                        lCell.getAttributes().remove(GraphConstants.ICON);
158:                }
159:            }
160:
161:            // add transition edge
162:            public void addTransition(Transition pTransition) throws Exception {
163:                TransitionUserObject lUserObject = new TransitionUserObject(
164:                        pTransition);
165:                java.util.List lPoints = loadEdgePoints(lUserObject
166:                        .getBOObject());
167:                String lFrom = (pTransition.getStartState() != null) ? pTransition
168:                        .getStartState().refMofId()
169:                        : null;
170:                String lTo = (pTransition.getEndState() != null) ? pTransition
171:                        .getEndState().refMofId() : null;
172:
173:                addEdge(lUserObject, null, lPoints, lFrom, lTo,
174:                        getAssociationStyle());
175:            }
176:
177:            // check transition
178:            public void checkTransition(Transition pTransition, Map pViewMap)
179:                    throws Exception {
180:                DefaultEdge lTransitionEdge = (DefaultEdge) findElementCell(pTransition);
181:                //if (lTransitionEdge==null)
182:                //	addTransition(pTransition);		
183:                //else
184:                if (lTransitionEdge != null) {
185:                    State lStartState = pTransition.getStartState();
186:                    State lEndState = pTransition.getEndState();
187:                    if (lStartState != null && lEndState != null) {
188:                        Object lFromPort = getPort(lStartState.refMofId());
189:                        Object lToPort = getPort(lEndState.refMofId());
190:
191:                        lTransitionEdge.setSource(lFromPort);
192:                        lTransitionEdge.setTarget(lToPort);
193:
194:                        java.util.List lList = GraphConstants
195:                                .clonePoints(GraphConstants
196:                                        .getPoints(lTransitionEdge
197:                                                .getAttributes()));
198:                        Point lPoint = GraphConstants
199:                                .getLabelPosition(lTransitionEdge
200:                                        .getAttributes());
201:                        GraphConstants.setPoints(lTransitionEdge
202:                                .getAttributes(), lList);
203:                        GraphConstants.setLabelPosition(lTransitionEdge
204:                                .getAttributes(), lPoint);
205:
206:                        pViewMap.put(lTransitionEdge, lTransitionEdge
207:                                .getAttributes());
208:                    }
209:                }
210:            }
211:
212:            public DefaultGraphCell findInitialState() {
213:                for (int i = 0; i < getRootCount(); i++) {
214:                    DefaultGraphCell lObject = (DefaultGraphCell) getRootAt(i);
215:                    Object lCellUserObject = lObject.getUserObject();
216:                    if (lCellUserObject instanceof  StateUserObject) {
217:                        State lState = ((StateUserObject) lCellUserObject)
218:                                .getState();
219:                        if (lState != null
220:                                && lState.getType() == StateTypeEnum.INITIAL)
221:                            return lObject;
222:                    }
223:                }
224:                return null;
225:            }
226:
227:            // process cell change	
228:            protected void processCellChange(DefaultGraphCell pCell) {
229:                super .processCellChange(pCell);
230:                if (pCell == null)
231:                    return;
232:
233:                Object lChangedCellUserObject = pCell.getUserObject();
234:                if (lChangedCellUserObject instanceof  TransitionUserObject) {
235:                    Transition lTransition = ((TransitionUserObject) lChangedCellUserObject)
236:                            .getStateTransition();
237:                    Object lSourceStateObject = ((DefaultEdge) pCell)
238:                            .getSource();
239:                    Object lTargetStateObject = ((DefaultEdge) pCell)
240:                            .getTarget();
241:                    try {
242:                        State lStartState = null;
243:                        State lStopState = null;
244:                        if (lSourceStateObject != null) {
245:                            Object lObject = ((DefaultPort) lSourceStateObject)
246:                                    .getUserObject();
247:                            if (lObject != null
248:                                    && lObject instanceof  StateUserObject)
249:                                lStartState = ((StateUserObject) lObject)
250:                                        .getState();
251:                        }
252:                        if (lTargetStateObject != null) {
253:                            Object lObject = ((DefaultPort) lTargetStateObject)
254:                                    .getUserObject();
255:                            if (lObject != null
256:                                    && lObject instanceof  StateUserObject)
257:                                lStopState = ((StateUserObject) lObject)
258:                                        .getState();
259:                        }
260:
261:                        Application.beginTransaction();
262:                        try {
263:                            lTransition.setStartState(lStartState);
264:                            lTransition.setEndState(lStopState);
265:                            Application.commit();
266:                            Application
267:                                    .fireRefreshDiagram(
268:                                            mDiagram,
269:                                            (TransitionUserObject) lChangedCellUserObject);
270:                        } finally {
271:                            Application.checkAndRollback();
272:                        }
273:                    } catch (Exception e) {
274:                        e.printStackTrace();
275:                    }
276:                }
277:            }
278:
279:            public Map getVertexStyle() {
280:                Map lStyle = super .getVertexStyle();
281:                GraphConstants.setBackground(lStyle, Color.yellow);
282:                return lStyle;
283:            }
284:
285:            /*protected Object[] getVertexesObjects()
286:            {
287:            	Entity lEntity = getEntity();
288:            	if (lEntity!=null && getEntity().getStateMachine()!=null) 
289:            		return getEntity().getStateMachine().getStates().toArray(); 
290:            	else
291:            		return null;
292:            }*/
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.