001: package org.enhydra.jawe.components.graph;
002:
003: import org.enhydra.jawe.JaWEConstants;
004: import org.enhydra.jawe.JaWEManager;
005: import org.enhydra.jawe.base.tooltip.TooltipGenerator;
006: import org.enhydra.shark.xpdl.XMLComplexElement;
007: import org.enhydra.shark.xpdl.elements.Transition;
008: import org.jgraph.graph.DefaultPort;
009:
010: /**
011: * Used to define Transition object in the graph.
012: * @author Sasa Bojanic
013: */
014: public class DefaultGraphTransition extends GraphTransitionInterface {
015:
016: /**
017: * Creates transition.
018: */
019: public DefaultGraphTransition(Transition tra) {
020: super ();
021: setUserObject(tra);
022:
023: }
024:
025: /**
026: * Returns source activity.
027: */
028: public GraphActivityInterface getSourceActivity() {
029: return (GraphActivityInterface) ((DefaultPort) source)
030: .getParent();
031: }
032:
033: /**
034: * Returns target activity.
035: */
036: public GraphActivityInterface getTargetActivity() {
037: return (GraphActivityInterface) ((DefaultPort) target)
038: .getParent();
039: }
040:
041: public XMLComplexElement getPropertyObject() {
042: if (userObject instanceof XMLComplexElement) {
043: return (XMLComplexElement) userObject;
044: }
045: return null;
046: }
047:
048: /**
049: * Gets a tooltip text for transition.
050: */
051: public String getTooltip() {
052: TooltipGenerator ttg = JaWEManager.getInstance()
053: .getTooltipGenerator();
054: if (userObject != null && ttg != null) {
055: return ttg.getTooltip(getPropertyObject());
056: }
057: return "";
058: }
059:
060: /**
061: * Returns an empty string.
062: */
063: public String toString() {
064: // org.enhydra.shark.xpdl.elements.Transition tr=
065: // (org.enhydra.shark.xpdl.elements.Transition)userObject;
066: // return tr.getCondition().toValue();
067: return "";
068: }
069:
070: //HM: enable Transition-copy/paste
071: protected Object cloneUserObject() {
072: if (userObject instanceof Transition) {
073: return ((Transition) userObject).clone();
074: }
075: return null;
076: }
077:
078: public boolean hasCondition() {
079: return !getCondition().equals("");
080: }
081:
082: public String getConditionType() {
083: if (!(userObject instanceof Transition))
084: return "";
085: Transition tr = (Transition) userObject;
086: return tr.getCondition().getType();
087: }
088:
089: public String getCondition() {
090: if (!(userObject instanceof Transition))
091: return "";
092: Transition tr = (Transition) userObject;
093: return tr.getCondition().toValue();
094: }
095:
096: public String getType() {
097: if (userObject != null) {
098: return JaWEManager.getInstance().getJaWEController()
099: .getTypeResolver().getJaWEType(
100: (Transition) userObject).getTypeId();
101: }
102:
103: return JaWEConstants.TRANSITION_TYPE_UNCONDITIONAL;
104: }
105: }
|