|
What this is
Other links
The source code// $Id: UMLStateDiagram.java,v 1.58 2004/09/19 09:46:09 mvw Exp $ // Copyright (c) 1996-2004 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this // software and its documentation without fee, and without a written // agreement is hereby granted, provided that the above copyright notice // and this paragraph appear in all copies. This software program and // documentation are copyrighted by The Regents of the University of // California. The software program and documentation are supplied "AS // IS", without any accompanying services from The Regents. The Regents // does not warrant that the operation of the program will be // uninterrupted or error-free. The end-user understands that the program // was developed for research purposes and is advised not to rely // exclusively on the program for any reason. IN NO EVENT SHALL THE // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. // File: UMLStateDiagram.java // Classes: UMLStateDiagram // Original Author: your email here // $Id: UMLStateDiagram.java,v 1.58 2004/09/19 09:46:09 mvw Exp $ package org.argouml.uml.diagram.state.ui; import java.beans.PropertyVetoException; import javax.swing.Action; import org.apache.log4j.Logger; import org.argouml.kernel.ProjectManager; import org.argouml.model.ModelFacade; import org.argouml.ui.CmdCreateNode; import org.argouml.ui.CmdSetMode; import org.argouml.uml.diagram.state.StateDiagramGraphModel; import org.argouml.uml.diagram.ui.RadioAction; import org.argouml.uml.diagram.ui.UMLDiagram; import org.tigris.gef.base.LayerPerspective; import org.tigris.gef.base.LayerPerspectiveMutable; import org.tigris.gef.base.ModeCreatePolyEdge; /** The correct name for this class is "UMLStatechartDiagram". See issue 2306. * */ public class UMLStateDiagram extends UMLDiagram { /** logger */ private static final Logger LOG = Logger.getLogger(UMLStateDiagram.class); /** * this diagram needs to be deleted when its statemachine is deleted. */ private Object theStateMachine; //////////////// // actions for toolbar private static Action actionState = new RadioAction( new CmdCreateNode(ModelFacade.STATE, "State")); private static Action actionCompositeState = new RadioAction( new CmdCreateNode(ModelFacade.COMPOSITESTATE, "CompositeState")); // start state, end state, forks, joins, etc. private static Action actionStartPseudoState = new RadioAction( new ActionCreatePseudostate( ModelFacade.INITIAL_PSEUDOSTATEKIND, "Initial")); private static Action actionFinalPseudoState = new RadioAction( new CmdCreateNode(ModelFacade.FINALSTATE, "FinalState")); private static Action actionBranchPseudoState = new RadioAction( new ActionCreatePseudostate( ModelFacade.BRANCH_PSEUDOSTATEKIND, "Choice")); private static Action actionForkPseudoState = new RadioAction( new ActionCreatePseudostate(ModelFacade.FORK_PSEUDOSTATEKIND, "Fork")); private static Action actionJoinPseudoState = new RadioAction( new ActionCreatePseudostate(ModelFacade.JOIN_PSEUDOSTATEKIND, "Join")); private static Action actionShallowHistoryPseudoState = new RadioAction( new ActionCreatePseudostate( ModelFacade.SHALLOWHISTORY_PSEUDOSTATEKIND, "ShallowHistory")); private static Action actionDeepHistoryPseudoState = new RadioAction( new ActionCreatePseudostate( ModelFacade.DEEPHISTORY_PSEUDOSTATEKIND, "DeepHistory")); private static Action actionTransition = new RadioAction( new CmdSetMode( ModeCreatePolyEdge.class, "edgeClass", ModelFacade.TRANSITION, "Transition")); private static Action actionJunctionPseudoState = new RadioAction( new ActionCreatePseudostate( ModelFacade.JUNCTION_PSEUDOSTATEKIND, "Junction")); private static int stateDiagramSerial = 1; //////////////////////////////////////////////////////////////// // contructors /** * this constructor is used to build a dummy statechart diagram so * that a project will load properly. */ public UMLStateDiagram() { try { setName(getNewDiagramName()); } catch (PropertyVetoException pve) { } } /** constructor * @param namespace the NameSpace for the new diagram * @param sm the StateMachine */ public UMLStateDiagram(Object namespace, Object sm) { this(); if (!ModelFacade.isAStateMachine(sm)) throw new IllegalArgumentException(); if (sm != null && namespace == null) { Object context = ModelFacade.getContext(sm); if (ModelFacade.isAClassifier(context)) { namespace = context; } else if (ModelFacade.isABehavioralFeature(context)) { namespace = ModelFacade.getOwner(context); } } if (namespace != null && ModelFacade.getName(namespace) != null) { String name = null, diagramName = ModelFacade.getName(namespace); int number = (ModelFacade.getBehaviors(namespace)) == null ? 0 : ModelFacade.getBehaviors(namespace).size(); name = diagramName + " " + (number++); LOG.info("UMLStateDiagram constructor: String name = " + name); try { setName(name); } catch (PropertyVetoException pve) { } } if (namespace != null) { setup(namespace, sm); } } /** * The owner of a statechart diagram is the statechart diagram * it's showing. * @see org.argouml.uml.diagram.ui.UMLDiagram#getOwner() */ public Object getOwner() { StateDiagramGraphModel gm = (StateDiagramGraphModel) getGraphModel(); return gm.getMachine(); } /** * Called by the PGML parser to initialize the statechart * diagram. First the parser creates a statechart diagram via the * default constructor. Then this method is called. * * @see org.tigris.gef.base.Diagram#initialize(Object) */ public void initialize(Object o) { if (ModelFacade.isAStateMachine(o)) { Object sm = /*(MStateMachine)*/ o; Object context = ModelFacade.getContext(sm); Object contextNamespace = null; if (ModelFacade.isAClassifier(context)) { contextNamespace = context; } else if (ModelFacade.isABehavioralFeature(context)) { contextNamespace = ModelFacade.getNamespace(ModelFacade.getOwner(context)); } if (contextNamespace != null) { setup(contextNamespace, sm); } } else { throw new IllegalStateException( "Cannot find context namespace " + "while initializing " + "statechart diagram"); } } /** * Method to perform a number of important initializations of a * StateDiagram. |
... this post is sponsored by my books ... | |
![]() #1 New Release! |
![]() FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.