[openrtm-commit:02306] r655 - in branches/FSM4RTC: . jp.go.aist.rtm.toolscommon jp.go.aist.rtm.toolscommon/META-INF jp.go.aist.rtm.toolscommon/lib jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/impl jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 1月 22日 (日) 15:12:06 JST


Author: ga
Date: 2017-01-22 15:12:06 +0900 (Sun, 22 Jan 2017)
New Revision: 655

Added:
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/jgraphx.jar
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/rsyntaxtextarea.jar
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/ObjectFactory.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/SCXMLConstraints.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLGraphEditor.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLNotifier.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/OutSource.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLEdge.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLImportExport.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLNode.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/MyUndoManager.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLChangeHandler.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorActions.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorMenuBar.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorPopupMenu.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraph.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphComponent.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphHandler.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLKeyboardHandler.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/EditorKeyboardHandler.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLEditorRoot.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLStateEditor.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLTransitionEditor.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner/SCXMLListener.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/AbstractActionWrapper.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/ListCellSelector.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/Pair.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/XMLUtils.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler/SCXMLConnectionHandler.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/copy.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/cut.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/delete.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/paste.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/redo.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/undo.gif
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/basic-style.xml
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/default-style.xml
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor.properties
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_de.properties
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_zh-CN.properties
Modified:
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/.classpath
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/META-INF/MANIFEST.MF
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/build.properties
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/SystemDiagram.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/impl/SystemDiagramImpl.java
   branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java
Log:


Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/.classpath
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/.classpath	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/.classpath	2017-01-22 06:12:06 UTC (rev 655)
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry exported="true" kind="lib" path="lib/jgraphx.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>

Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/META-INF/MANIFEST.MF
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/META-INF/MANIFEST.MF	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/META-INF/MANIFEST.MF	2017-01-22 06:12:06 UTC (rev 655)
@@ -5,28 +5,49 @@
 Bundle-Name: %pluginName
 Bundle-SymbolicName: jp.go.aist.rtm.toolscommon; singleton:=true
 Bundle-Version: 1.1.0.rc4v20130124
-Bundle-ClassPath: .,lib/commons-lang-2.2.jar
+Bundle-ClassPath: .,
+ lib/commons-lang-2.2.jar,
+ lib/jgraphx.jar,
+ lib/rsyntaxtextarea.jar
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-Export-Package: OpenRTM,RTC,RTM,_SDOPackage,jp.go.aist.rtm.toolscommon
- ,jp.go.aist.rtm.toolscommon.adapterfactory,jp.go.aist.rtm.toolscommon
- .corba,jp.go.aist.rtm.toolscommon.extension,jp.go.aist.rtm.toolscommo
- n.factory,jp.go.aist.rtm.toolscommon.manager,jp.go.aist.rtm.toolscomm
- on.model.component,jp.go.aist.rtm.toolscommon.model.component.impl,jp
- .go.aist.rtm.toolscommon.model.component.util,jp.go.aist.rtm.toolscom
- mon.model.core,jp.go.aist.rtm.toolscommon.model.core.impl,jp.go.aist.
- rtm.toolscommon.model.core.util,jp.go.aist.rtm.toolscommon.model.mana
- ger,jp.go.aist.rtm.toolscommon.model.manager.impl,jp.go.aist.rtm.tool
- scommon.model.manager.util,jp.go.aist.rtm.toolscommon.synchronization
- framework,jp.go.aist.rtm.toolscommon.synchronizationframework.mapping
- ,jp.go.aist.rtm.toolscommon.ui.dialog,jp.go.aist.rtm.toolscommon.ui.p
- erspective,jp.go.aist.rtm.toolscommon.ui.propertysource,jp.go.aist.rt
- m.toolscommon.ui.views.propertysheetview,jp.go.aist.rtm.toolscommon.u
- i.workbenchadapter,jp.go.aist.rtm.toolscommon.util,jp.go.aist.rtm.too
- lscommon.validation,org.apache.commons.lang,org.apache.commons.lang.b
- uilder,org.apache.commons.lang.enums,org.apache.commons.lang.exceptio
- n,org.apache.commons.lang.math,org.apache.commons.lang.mutable,org.ap
- ache.commons.lang.text,org.apache.commons.lang.time
+Export-Package: OpenRTM,
+ RTC,
+ RTM,
+ _SDOPackage,
+ jp.go.aist.rtm.toolscommon,
+ jp.go.aist.rtm.toolscommon.adapterfactory,
+ jp.go.aist.rtm.toolscommon.corba,
+ jp.go.aist.rtm.toolscommon.extension,
+ jp.go.aist.rtm.toolscommon.factory,
+ jp.go.aist.rtm.toolscommon.fsm.editor,
+ jp.go.aist.rtm.toolscommon.manager,
+ jp.go.aist.rtm.toolscommon.model.component,
+ jp.go.aist.rtm.toolscommon.model.component.impl,
+ jp.go.aist.rtm.toolscommon.model.component.util,
+ jp.go.aist.rtm.toolscommon.model.core,
+ jp.go.aist.rtm.toolscommon.model.core.impl,
+ jp.go.aist.rtm.toolscommon.model.core.util,
+ jp.go.aist.rtm.toolscommon.model.manager,
+ jp.go.aist.rtm.toolscommon.model.manager.impl,
+ jp.go.aist.rtm.toolscommon.model.manager.util,
+ jp.go.aist.rtm.toolscommon.synchronizationframework,
+ jp.go.aist.rtm.toolscommon.synchronizationframework.mapping,
+ jp.go.aist.rtm.toolscommon.ui.dialog,
+ jp.go.aist.rtm.toolscommon.ui.perspective,
+ jp.go.aist.rtm.toolscommon.ui.propertysource,
+ jp.go.aist.rtm.toolscommon.ui.views.propertysheetview,
+ jp.go.aist.rtm.toolscommon.ui.workbenchadapter,
+ jp.go.aist.rtm.toolscommon.util,
+ jp.go.aist.rtm.toolscommon.validation,
+ org.apache.commons.lang,
+ org.apache.commons.lang.builder,
+ org.apache.commons.lang.enums,
+ org.apache.commons.lang.exception,
+ org.apache.commons.lang.math,
+ org.apache.commons.lang.mutable,
+ org.apache.commons.lang.text,
+ org.apache.commons.lang.time
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.emf.ecore;visibility:=reexport,
  org.eclipse.emf.ecore.xmi;visibility:=reexport,

Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/build.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/build.properties	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/build.properties	2017-01-22 06:12:06 UTC (rev 655)
@@ -9,7 +9,9 @@
                plugin.xml,\
                plugin.properties,\
                icons/,\
-               schema/
+               schema/,\
+               lib/jgraphx.jar,\
+               lib/rsyntaxtextarea.jar
 jars.compile.order = .
 source.. = src/
 output.. = bin/

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/jgraphx.jar
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/jgraphx.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/rsyntaxtextarea.jar
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/lib/rsyntaxtextarea.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/ObjectFactory.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/ObjectFactory.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/ObjectFactory.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,52 @@
+package jp.go.aist.rtm.toolscommon.fsm.config;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each Java content interface and Java
+ * element interface generated in the test package.
+ * <p>
+ * An ObjectFactory allows you to programatically construct new instances of the
+ * Java representation for XML content. The Java representation of XML content
+ * can consist of schema derived interfaces and classes representing the binding
+ * of schema type definitions, element declarations and model groups. Factory
+ * methods for each of these are provided in this class.
+ * 
+ */
+ at XmlRegistry
+public class ObjectFactory {
+
+	/**
+	 * Create a new ObjectFactory that can be used to create new instances of
+	 * schema derived classes for package: test
+	 * 
+	 */
+	public ObjectFactory() {
+	}
+
+	/**
+	 * Create an instance of {@link SCXMLConstraints }
+	 * 
+	 */
+	public SCXMLConstraints createSCXMLConstraints() {
+		return new SCXMLConstraints();
+	}
+
+	/**
+	 * Create an instance of {@link SCXMLConstraints.RestrictedState }
+	 * 
+	 */
+	public SCXMLConstraints.RestrictedState createSCXMLConstraintsRestrictedState() {
+		return new SCXMLConstraints.RestrictedState();
+	}
+
+	/**
+	 * Create an instance of
+	 * {@link SCXMLConstraints.RestrictedState.PossibleEvent }
+	 * 
+	 */
+	public SCXMLConstraints.RestrictedState.PossibleEvent createSCXMLConstraintsRestrictedStatePossibleEvent() {
+		return new SCXMLConstraints.RestrictedState.PossibleEvent();
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/SCXMLConstraints.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/SCXMLConstraints.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/config/SCXMLConstraints.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,317 @@
+package jp.go.aist.rtm.toolscommon.fsm.config;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ * 
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ * 
+ * <pre>
+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="restrictedState" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="color" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                   <element name="documentation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                   <element name="possibleEvent" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="documentation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                           </sequence>
+ *                           <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "", propOrder = { "restrictedState" })
+ at XmlRootElement(name = "SCXMLConstraints")
+public class SCXMLConstraints implements Serializable {
+
+	@XmlElement(required = true)
+	protected List<SCXMLConstraints.RestrictedState> restrictedState;
+
+	/**
+	 * Gets the value of the restrictedState property.
+	 * 
+	 * <p>
+	 * This accessor method returns a reference to the live list, not a
+	 * snapshot. Therefore any modification you make to the returned list will
+	 * be present inside the JAXB object. This is why there is not a
+	 * <CODE>set</CODE> method for the restrictedState property.
+	 * 
+	 * <p>
+	 * For example, to add a new item, do as follows:
+	 * 
+	 * <pre>
+	 * getRestrictedState().add(newItem);
+	 * </pre>
+	 * 
+	 * 
+	 * <p>
+	 * Objects of the following type(s) are allowed in the list
+	 * {@link SCXMLConstraints.RestrictedState }
+	 * 
+	 * 
+	 */
+	public List<SCXMLConstraints.RestrictedState> getRestrictedState() {
+		if (restrictedState == null) {
+			restrictedState = new ArrayList<SCXMLConstraints.RestrictedState>();
+		}
+		return this.restrictedState;
+	}
+
+	/**
+	 * <p>
+	 * Java class for anonymous complex type.
+	 * 
+	 * <p>
+	 * The following schema fragment specifies the expected content contained
+	 * within this class.
+	 * 
+	 * <pre>
+	 * <complexType>
+	 *   <complexContent>
+	 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+	 *       <sequence>
+	 *         <element name="color" type="{http://www.w3.org/2001/XMLSchema}string"/>
+	 *         <element name="documentation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+	 *         <element name="possibleEvent" maxOccurs="unbounded">
+	 *           <complexType>
+	 *             <complexContent>
+	 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+	 *                 <sequence>
+	 *                   <element name="documentation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+	 *                 </sequence>
+	 *                 <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+	 *               </restriction>
+	 *             </complexContent>
+	 *           </complexType>
+	 *         </element>
+	 *       </sequence>
+	 *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+	 *     </restriction>
+	 *   </complexContent>
+	 * </complexType>
+	 * </pre>
+	 * 
+	 * 
+	 */
+	@XmlAccessorType(XmlAccessType.FIELD)
+	@XmlType(name = "", propOrder = { "color", "documentation", "possibleEvent" })
+	public static class RestrictedState implements Serializable {
+
+		@XmlElement(required = true)
+		protected String color;
+		@XmlElement(required = true)
+		protected String documentation;
+		@XmlElement(required = true)
+		protected List<SCXMLConstraints.RestrictedState.PossibleEvent> possibleEvent;
+		@XmlAttribute(name = "name")
+		protected String name;
+
+		/**
+		 * Gets the value of the color property.
+		 * 
+		 * @return possible object is {@link String }
+		 * 
+		 */
+		public String getColor() {
+			return color;
+		}
+
+		/**
+		 * Sets the value of the color property.
+		 * 
+		 * @param value
+		 *            allowed object is {@link String }
+		 * 
+		 */
+		public void setColor(String value) {
+			this.color = value;
+		}
+
+		/**
+		 * Gets the value of the documentation property.
+		 * 
+		 * @return possible object is {@link String }
+		 * 
+		 */
+		public String getDocumentation() {
+			return documentation;
+		}
+
+		/**
+		 * Sets the value of the documentation property.
+		 * 
+		 * @param value
+		 *            allowed object is {@link String }
+		 * 
+		 */
+		public void setDocumentation(String value) {
+			this.documentation = value;
+		}
+
+		/**
+		 * Gets the value of the possibleEvent property.
+		 * 
+		 * <p>
+		 * This accessor method returns a reference to the live list, not a
+		 * snapshot. Therefore any modification you make to the returned list
+		 * will be present inside the JAXB object. This is why there is not a
+		 * <CODE>set</CODE> method for the possibleEvent property.
+		 * 
+		 * <p>
+		 * For example, to add a new item, do as follows:
+		 * 
+		 * <pre>
+		 * getPossibleEvent().add(newItem);
+		 * </pre>
+		 * 
+		 * 
+		 * <p>
+		 * Objects of the following type(s) are allowed in the list
+		 * {@link SCXMLConstraints.RestrictedState.PossibleEvent }
+		 * 
+		 * 
+		 */
+		public List<SCXMLConstraints.RestrictedState.PossibleEvent> getPossibleEvent() {
+			if (possibleEvent == null) {
+				possibleEvent = new ArrayList<SCXMLConstraints.RestrictedState.PossibleEvent>();
+			}
+			return this.possibleEvent;
+		}
+
+		/**
+		 * Gets the value of the name property.
+		 * 
+		 * @return possible object is {@link String }
+		 * 
+		 */
+		public String getName() {
+			return name;
+		}
+
+		/**
+		 * Sets the value of the name property.
+		 * 
+		 * @param value
+		 *            allowed object is {@link String }
+		 * 
+		 */
+		public void setName(String value) {
+			this.name = value;
+		}
+
+		/**
+		 * <p>
+		 * Java class for anonymous complex type.
+		 * 
+		 * <p>
+		 * The following schema fragment specifies the expected content
+		 * contained within this class.
+		 * 
+		 * <pre>
+		 * <complexType>
+		 *   <complexContent>
+		 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+		 *       <sequence>
+		 *         <element name="documentation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+		 *       </sequence>
+		 *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+		 *     </restriction>
+		 *   </complexContent>
+		 * </complexType>
+		 * </pre>
+		 * 
+		 * 
+		 */
+		@XmlAccessorType(XmlAccessType.FIELD)
+		@XmlType(name = "", propOrder = { "documentation" })
+		public static class PossibleEvent implements Serializable {
+
+			@XmlElement(required = true)
+			protected String documentation;
+			@XmlAttribute(name = "name")
+			protected String name;
+
+			/**
+			 * Gets the value of the documentation property.
+			 * 
+			 * @return possible object is {@link String }
+			 * 
+			 */
+			public String getDocumentation() {
+				return documentation;
+			}
+
+			/**
+			 * Sets the value of the documentation property.
+			 * 
+			 * @param value
+			 *            allowed object is {@link String }
+			 * 
+			 */
+			public void setDocumentation(String value) {
+				this.documentation = value;
+			}
+
+			/**
+			 * Gets the value of the name property.
+			 * 
+			 * @return possible object is {@link String }
+			 * 
+			 */
+			public String getName() {
+				return name;
+			}
+
+			/**
+			 * Sets the value of the name property.
+			 * 
+			 * @param value
+			 *            allowed object is {@link String }
+			 * 
+			 */
+			public void setName(String value) {
+				this.name = value;
+			}
+
+		}
+
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLGraphEditor.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLGraphEditor.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLGraphEditor.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,1405 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.prefs.Preferences;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.DefaultListModel;
+import javax.swing.ImageIcon;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.ListCellRenderer;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.filechooser.FileFilter;
+import javax.xml.bind.JAXBContext;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import com.mxgraph.layout.mxCircleLayout;
+import com.mxgraph.layout.mxCompactTreeLayout;
+import com.mxgraph.layout.mxEdgeLabelLayout;
+import com.mxgraph.layout.mxFastOrganicLayout;
+import com.mxgraph.layout.mxIGraphLayout;
+import com.mxgraph.layout.mxParallelEdgeLayout;
+import com.mxgraph.layout.mxPartitionLayout;
+import com.mxgraph.layout.mxStackLayout;
+import com.mxgraph.layout.hierarchical.mxHierarchicalLayout;
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.swing.mxGraphOutline;
+import com.mxgraph.swing.handler.mxKeyboardHandler;
+import com.mxgraph.swing.handler.mxRubberband;
+import com.mxgraph.swing.util.CellSelector;
+import com.mxgraph.util.StringUtils;
+import com.mxgraph.util.mxConstants;
+import com.mxgraph.util.mxEvent;
+import com.mxgraph.util.mxEventObject;
+import com.mxgraph.util.mxEventSource.mxIEventListener;
+import com.mxgraph.util.mxRectangle;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.util.mxUndoManager;
+import com.mxgraph.util.mxUndoableEdit;
+import com.mxgraph.util.mxUndoableEdit.mxUndoableChange;
+import com.mxgraph.view.mxGraph;
+import com.mxgraph.view.mxMultiplicity;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLImportExport;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.NewSCXMLAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.OpenAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.ToggleIgnoreStoredLayout;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorMenuBar;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorPopupMenu;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraph;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraphComponent;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLKeyboardHandler;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor.SCXMLEditorRoot.Type;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor.SCXMLStateEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor.SCXMLTransitionEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.AbstractActionWrapper;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.ListCellSelector;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.Pair;
+
+public class SCXMLGraphEditor extends JPanel {
+	public Preferences preferences = Preferences.userRoot();
+	private ValidationWarningStatusPane validationStatus;
+	
+	private SCXMLNotifier observer = null;
+	private boolean isReadOnly = false;
+	private CellSelector cellHighlighter = null;
+	public static final String PREFERENCE_IGNORE_STORED_LAYOUT = "IGNORE_STORED_LAYOUT";
+
+	public void setObserver(SCXMLNotifier target) {
+		this.observer = target;
+	}
+	public void setReadOnly(boolean value) {
+		this.isReadOnly = value;
+	}
+	
+	public SCXMLEditorMenuBar menuBar;
+
+	public enum EditorStatus {
+		STARTUP, EDITING, LAYOUT, POPULATING
+	};
+
+	private EditorStatus status = EditorStatus.STARTUP;
+
+	public void setStatus(EditorStatus status) {
+		this.status = status;
+	}
+
+	public EditorStatus getStatus() {
+		return status;
+	}
+
+	private static final long serialVersionUID = -6561623072112577140L;
+	static {
+		mxResources.add("jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor");
+	}
+
+	/**
+	 * the zoomed in view of the graph (just a small portion of the outline
+	 * (typically))
+	 */
+	protected SCXMLGraphComponent graphComponent;
+
+	/**
+	 * a summary view of the entire graph
+	 */
+	protected mxGraphOutline graphOutline;
+
+	protected mxUndoManager undoManager;
+	protected String appTitle;
+	protected JLabel statusBar;
+	protected File currentFile;
+	protected SCXMLImportExport currentFileIOMethod;
+	protected Long lastModifiedDate;
+	private static boolean doLayout;
+	private static String inputFileName, outputFileName, outputFormat;
+
+	/*
+	 * Restricted states configuration
+	 */
+	private SCXMLConstraints restrictedStatesConfig;
+
+	protected boolean modified = false;
+	protected mxRubberband rubberband;
+	protected mxKeyboardHandler keyboardHandler;
+	
+	protected mxIEventListener undoHandler = new mxIEventListener() {
+		public void invoke(Object source, mxEventObject evt) {
+			undoManager.undoableEditHappened((mxUndoableEdit) evt.getProperty("edit"));
+			updateUndoRedoActionState();
+			changeTracker.invoke(null, null);
+		}
+	};
+	private Action undo;
+	private Action redo;
+
+	public void setUndoMenuAction(Action externalAction) {
+		this.undo = externalAction;
+		updateUndoRedoActionState();
+	}
+
+	public void setRedoMenuAction(Action externalAction) {
+		this.redo = externalAction;
+		updateUndoRedoActionState();
+	}
+
+	public void updateUndoRedoActionState() {
+		if (redo != null)
+			redo.setEnabled(undoManager.canRedo());
+		if (undo != null)
+			undo.setEnabled(undoManager.canUndo());
+	}
+
+	private JCheckBoxMenuItem ignoreStoredLayout;
+
+	public void setIgnoreStoredLayoutMenu(JCheckBoxMenuItem menuItem) {
+		this.ignoreStoredLayout = menuItem;
+		updateIgnoreStoredLayoutMenuState();
+	}
+
+	public void updateIgnoreStoredLayoutMenuState() {
+		if (ignoreStoredLayout != null)
+			ignoreStoredLayout.setSelected(ToggleIgnoreStoredLayout.isSelected(this));
+	}
+
+	private HashMap<String, SCXMLGraph> file2graph = new HashMap<String, SCXMLGraph>();
+	private HashMap<String, SCXMLImportExport> file2importer = new HashMap<String, SCXMLImportExport>();
+
+	public void clearDisplayOutsourcedContentStatus() {
+		file2graph.clear();
+		file2importer.clear();
+	}
+
+	public SCXMLGraph attachOutsourcedContentToThisNode(mxCell ond, SCXMLGraph g, boolean display, boolean refresh)
+			throws Exception {
+		SCXMLGraph rootg = getGraphComponent().getGraph();
+		SCXMLNode v = (SCXMLNode) ond.getValue();
+		// get the outsourcing url (SRC field)
+		String src = v.getOutsourcedLocation();
+		// get the file name, the optional namespace and the optional node name
+		// syntax handled: filename#namespace:nodename
+		// or filename#nodename
+		// or filename
+		String namespace, node;
+		int pos = src.indexOf('#', 0);
+		if (pos >= 0) {
+			int nmpos = src.indexOf(':', pos);
+			if (nmpos >= 0) {
+				namespace = src.substring(pos + 1, nmpos);
+				node = src.substring(nmpos + 1);
+			} else {
+				namespace = null;
+				node = src.substring(pos + 1);
+			}
+		} else {
+			namespace = null;
+			node = null;
+		}
+		if ((namespace != null) && (node == null))
+			throw new Exception("node name not given but namespace given in: '" + src + "'");
+		String SCXMLnodename = (node != null) ? (((namespace != null) ? namespace + ":" : "") + node) : v.getID();
+		// normalize the file name to the system absolute path of that file
+
+		File f = getThisFileInCurrentDirectory(src);
+
+		String fileName = f.getAbsolutePath();
+		while (!f.exists()) {
+			JFileChooser fc = new JFileChooser(f.getParent());
+			final String inputFileName = fileName;
+			fc.setFileFilter(new FileFilter() {
+
+				@Override
+				public String getDescription() {
+					return "Find '" + inputFileName + "' file.";
+				}
+
+				@Override
+				public boolean accept(File f) {
+					if (f.getName().equals(inputFileName) || f.isDirectory())
+						return true;
+					else
+						return false;
+				}
+			});
+			fc.setAcceptAllFileFilterUsed(false);
+			int rc = fc.showDialog(this, mxResources.get("findFile") + " '" + fileName + "'");
+			if (rc == JFileChooser.APPROVE_OPTION) {
+				System.out.println("trying this file: '" + fc.getSelectedFile() + "'");
+				f = fc.getSelectedFile();
+			} else {
+				throw new Exception("Aborted by the user.");
+			}
+		}
+		fileName = f.getAbsolutePath();
+		// check to see if the required file has already been read
+		SCXMLImportExport ie = file2importer.get(fileName);
+		SCXMLGraph ig = file2graph.get(fileName);
+		if ((ig == null) || refresh) {
+			// load the required graph
+			assert (!file2importer.containsKey(fileName) || refresh);
+			file2importer.put(fileName, ie = new SCXMLImportExport());
+			// read the graph, this will throw an exception if something goes
+			// wrong
+			System.out.println("reading " + fileName);
+			ie.readInGraph(ig = new SCXMLGraph(),
+					fileName, preferences
+							.getBoolean(PREFERENCE_IGNORE_STORED_LAYOUT, true),
+					getRestrictedStatesConfig());
+			ig.setEditor(this);
+			file2graph.put(fileName, ig);
+		}
+		assert ((ig != null) && (ie != null));
+		System.out.println("attaching node: '" + SCXMLnodename + "' from file '" + fileName + "'");
+		// check that the requested node is there
+		SCXMLNode SCXMLn = ie.getNodeFromSCXMLID(SCXMLnodename);
+		if (SCXMLn == null)
+			SCXMLn = ie.getRoot();
+		if (SCXMLn == null) {
+			JOptionPane.showMessageDialog(this, mxResources.get("nodeNotFound") + ": '" + SCXMLnodename + "'",
+					mxResources.get("error"), JOptionPane.ERROR_MESSAGE);
+			return null;
+		} else {
+			String internalID = SCXMLn.getInternalID();
+			assert (!StringUtils.isEmptyString(internalID));
+			// get the cell corresponding to that node
+			mxCell oc = ie.getCellFromInternalID(internalID);
+			assert (oc != null);
+			// check whether ond has children, issue a warning if it has
+			int cc = ond.getChildCount();
+			if (cc > 0) {
+				// remove all children of ond
+				if (display)
+					System.out.println("WARNING: the node: " + v + " has " + cc + " child(ren). Removing all of them.");
+
+				// insure first that the cells are deletable
+				Set<Object> descendants = new HashSet<Object>();
+				rootg.getAllDescendants(ond, descendants);
+				// don't change ond (ond is the original node in the graph (the
+				// one to which we are adding the outsourced content))
+				descendants.remove(ond);
+				for (Object d : descendants)
+					rootg.setCellAsDeletable(d, true);
+
+				Object[] children = new Object[cc];
+				for (int i = 0; i < cc; i++)
+					children[i] = ond.getChildAt(i);
+				rootg.removeCells(children);
+			}
+			if (display) {
+				// attach copy of oc as only children of ond
+				v.setCluster(true);
+				rootg.setCellStyle(v.getStyle(), ond);
+				HashMap<Object, Object> original2clone = new HashMap<Object, Object>();
+				Object[] noc = g.cloneCells(new Object[] { oc }, false, original2clone);
+
+				// loop through the mapping now created while cloning, if there
+				// are
+				// any cells that are outsourced add this clone to the list of
+				// clones
+				// for them in the graph ig.
+				for (mxCell c : ig.getOutsourcedNodes()) {
+					mxCell clone = (mxCell) original2clone.get(c);
+					if (clone != null) {
+						HashSet<mxCell> clones4ThisOriginal = ig.getOriginal2Clones().get(c);
+						if (clones4ThisOriginal == null)
+							ig.getOriginal2Clones().put(c, clones4ThisOriginal = new HashSet<mxCell>());
+						assert (!clones4ThisOriginal.contains(clone));
+						clones4ThisOriginal.add(clone);
+					}
+				}
+
+				assert (noc.length == 1);
+				mxCell ocCopy = (mxCell) noc[0];
+				rootg.addCell(ocCopy, ond);
+				// block all editing for ocCopy and all its children
+				Set<Object> descendants = new HashSet<Object>();
+				rootg.getAllDescendants(ocCopy, descendants);
+				rootg.setConnectableEdges(false);
+				for (Object d : descendants) {
+					rootg.setCellAsDeletable(d, false);
+					rootg.setCellAsEditable(d, false);
+					rootg.setCellAsConnectable(d, false);
+					// rootg.setCellAsMovable(d, false);
+				}
+			} else {
+				v.setCluster(false);
+				rootg.setCellStyle(v.getStyle(), ond);
+			}
+			return ig;
+		}
+	}
+
+	public File getThisFileInCurrentDirectory(String src) {
+		int pos = src.indexOf('#', 0);
+		String file;
+		if (pos >= 0)
+			file = src.substring(0, pos);
+		else
+			file = src;
+		// add the base directory information
+		String wd = (getCurrentFile() != null) ? getCurrentFile().getParent() : System.getProperty("user.dir");
+		return new File(wd + File.separator + file);
+	}
+
+	public void displayOutsourcedContentInNode(mxCell node, SCXMLGraph g, boolean display, boolean refresh)
+			throws Exception {
+		attachOutsourcedContentToThisNode(node, g, display, refresh);
+	}
+
+	HashSet<mxCell> alreadyDone = new HashSet<mxCell>();
+
+	public void displayOutsourcedContent(SCXMLGraph g, boolean display, boolean isRoot) throws Exception {
+		if (isRoot)
+			alreadyDone.clear();
+		// get the nodes that are outsourced
+		HashSet<mxCell> onds = g.getOutsourcedNodes();
+		for (mxCell ond : onds) {
+			// ig contains the graph from which the content of ond (or all its
+			// clones) is imported
+			SCXMLGraph ig = null;
+			// if isRoot is true, use the original node.
+			// else: check if there are clones for this original node and use
+			// those clones
+			if (isRoot) {
+				if (!alreadyDone.contains(ond)) {
+					ig = attachOutsourcedContentToThisNode(ond, g, display, true);
+					alreadyDone.add(ond);
+				}
+			} else {
+				HashSet<mxCell> clones4Ond = g.getOriginal2Clones().get(ond);
+				if (clones4Ond != null)
+					for (mxCell clonedOnd : clones4Ond) {
+						if (!alreadyDone.contains(clonedOnd)) {
+							ig = attachOutsourcedContentToThisNode(clonedOnd, g, display, true);
+							alreadyDone.add(clonedOnd);
+						}
+					}
+			}
+			// recursively call this function on the graph just created
+			if (ig != null)
+				displayOutsourcedContent(ig, display, false);
+		}
+	}
+
+	private boolean doDisplayOfOutsourcedContent = false;
+	private JCheckBoxMenuItem displayOutsourcedContentMenuItem;
+
+	public void setDisplayOutsourcedContentMenuItem(JCheckBoxMenuItem mi) {
+		displayOutsourcedContentMenuItem = mi;
+	}
+
+	public boolean isDisplayOfOutsourcedContentSelected() {
+		return doDisplayOfOutsourcedContent;
+	}
+
+	public void setDisplayOfOutsourcedContentSelected(boolean b) {
+		doDisplayOfOutsourcedContent = b;
+		if (displayOutsourcedContentMenuItem != null)
+			displayOutsourcedContentMenuItem.setSelected(isDisplayOfOutsourcedContentSelected());
+	}
+
+	/**
+	 * 
+	 */
+	protected mxIEventListener changeTracker = new mxIEventListener() {
+		public void invoke(Object source, mxEventObject evt) {
+			if (undoManager.isUnmodifiedState())
+				setModified(false);
+			else
+				setModified(true);
+		}
+	};
+
+	/**
+	 * 
+	 */
+	public SCXMLGraphEditor(String appTitle, SCXMLGraphComponent component, boolean isReadonly) {
+		// Stores and updates the frame title
+		this.appTitle = appTitle;
+		this.isReadOnly = isReadonly;
+
+		// Stores a reference to the graph and creates the command history
+		graphComponent = component;
+		final SCXMLGraph graph = graphComponent.getGraph();
+		undoManager = new mxUndoManager(100);
+
+		// Updates the modified flag if the graph model changes
+		graph.getModel().addListener(mxEvent.CHANGE, changeTracker);
+
+		// Adds the command history to the model and view
+		graph.getModel().addListener(mxEvent.UNDO, undoHandler);
+		graph.getView().addListener(mxEvent.UNDO, undoHandler);
+
+		// Keeps the selection in sync with the command history
+		mxIEventListener undoHandler = new mxIEventListener() {
+			public void invoke(Object source, mxEventObject evt) {
+				List<mxUndoableChange> changes = ((mxUndoableEdit) evt.getProperty("edit")).getChanges();
+				graph.setSelectionCells(graph.getSelectionCellsForChanges(changes));
+			}
+		};
+
+		undoManager.addListener(mxEvent.UNDO, undoHandler);
+		undoManager.addListener(mxEvent.REDO, undoHandler);
+
+		// Creates the status bar
+		statusBar = createStatusBar();
+
+		// Display some useful information about repaint events
+		installRepaintListener();
+
+		// Puts everything together
+		setLayout(new BorderLayout());
+		add(graphComponent, BorderLayout.CENTER);
+		add(statusBar, BorderLayout.SOUTH);
+
+		updateTitle();
+
+		graph.setAutoSizeCells(true);
+		graph.setEditor(this);
+		graph.setMultigraph(true);
+		graph.setAllowDanglingEdges(false);
+		graph.setConnectableEdges(false);
+		// the following 2 lines are required by the graph validation routines,
+		// otherwise a null pointer exception is generated.
+		mxMultiplicity[] m = {};
+		graph.setMultiplicities(m);
+
+		preferences = Preferences.userRoot();
+
+		/*
+		 * Parse restricted states configuration file
+		 */
+		restrictedStatesConfig = null;
+		InputStream fileInputStream = null;
+		try {
+			File file = new File("restrictedStates.xml");
+			fileInputStream = new FileInputStream(file);
+		} catch (FileNotFoundException e1) {
+			System.out.println(
+					"Restriction configuration file not found. The application starts in normal mode without restriction handling.");
+		}
+		try {
+			JAXBContext context = JAXBContext.newInstance(SCXMLConstraints.class);
+			if (fileInputStream != null) {
+				restrictedStatesConfig = (SCXMLConstraints) context.createUnmarshaller().unmarshal(fileInputStream);
+			}
+		} catch (Exception e) {
+			System.out.println("Error while parsing restrictedStates.xml file: " + e.getMessage());
+		} finally {
+			try {
+				if (fileInputStream != null) {
+					fileInputStream.close();
+				}
+			} catch (IOException e) {
+				System.out.println("Error while closing restriction configuration file!" + e.getMessage());
+			}
+		}
+	}
+
+	/**
+	 * 
+	 */
+	protected void installHandlers() {
+		rubberband = new mxRubberband(graphComponent);
+		if(isReadOnly==false) {
+			keyboardHandler = new SCXMLKeyboardHandler(graphComponent);
+		}
+	}
+
+	/**
+	 * 
+	 */
+	protected JLabel createStatusBar() {
+		JLabel statusBar = new JLabel(mxResources.get("ready"));
+		statusBar.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
+
+		return statusBar;
+	}
+
+	/**
+	 * 
+	 */
+	protected void installRepaintListener() {
+		graphComponent.getGraph().addListener(mxEvent.REPAINT, new mxIEventListener() {
+			public void invoke(Object source, mxEventObject evt) {
+				String buffer = (graphComponent.getTripleBuffer() != null) ? "" : " (unbuffered)";
+				mxRectangle dirty = (mxRectangle) evt.getProperty("region");
+
+				if (dirty == null) {
+					status("Repaint all" + buffer);
+				} else {
+					status("Repaint: x=" + (int) (dirty.getX()) + " y=" + (int) (dirty.getY()) + " w="
+							+ (int) (dirty.getWidth()) + " h=" + (int) (dirty.getHeight()) + buffer);
+				}
+			}
+		});
+	}
+
+	/**
+	 * 
+	 */
+	protected void mouseWheelMoved(MouseWheelEvent e) {
+		Point graphPoint;
+		Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent);
+		graphPoint = ((SCXMLGraphComponent) graphComponent).mouseCoordToGraphMouseCoord(mousePoint);
+		if (e.getWheelRotation() < 0) {
+			graphComponent.zoomIn(graphPoint);
+		} else {
+			graphComponent.zoomOut(graphPoint);
+		}
+
+		status(mxResources.get("scale") + ": " + (int) (100 * graphComponent.getGraph().getView().getScale()) + "%");
+	}
+
+	/**
+	 * 
+	 */
+	protected void showOutlinePopupMenu(MouseEvent e) {
+		Point pt = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent);
+		JCheckBoxMenuItem item = new JCheckBoxMenuItem(mxResources.get("magnifyPage"));
+		item.setSelected(graphOutline.isFitPage());
+
+		item.addActionListener(new ActionListener() {
+			/**
+			 * 
+			 */
+			public void actionPerformed(ActionEvent e) {
+				graphOutline.setFitPage(!graphOutline.isFitPage());
+				graphOutline.repaint();
+			}
+		});
+
+		JCheckBoxMenuItem item2 = new JCheckBoxMenuItem(mxResources.get("showLabels"));
+		item2.setSelected(graphOutline.isDrawLabels());
+
+		item2.addActionListener(new ActionListener() {
+			/**
+			 * 
+			 */
+			public void actionPerformed(ActionEvent e) {
+				graphOutline.setDrawLabels(!graphOutline.isDrawLabels());
+				graphOutline.repaint();
+			}
+		});
+
+		JCheckBoxMenuItem item3 = new JCheckBoxMenuItem(mxResources.get("buffering"));
+		item3.setSelected(graphOutline.isTripleBuffered());
+
+		item3.addActionListener(new ActionListener() {
+			/**
+			 * 
+			 */
+			public void actionPerformed(ActionEvent e) {
+				graphOutline.setTripleBuffered(!graphOutline.isTripleBuffered());
+				graphOutline.repaint();
+			}
+		});
+
+		JPopupMenu menu = new JPopupMenu();
+		menu.add(item);
+		menu.add(item2);
+		menu.add(item3);
+		menu.show(graphComponent, pt.x, pt.y);
+
+		e.consume();
+	}
+
+	/**
+	 * 
+	 */
+	protected void showGraphPopupMenu(MouseEvent e) {
+		Point screenCoord = e.getLocationOnScreen();
+		Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent);
+		Point graphPoint = ((SCXMLGraphComponent) graphComponent).mouseCoordToGraphMouseCoord(mousePoint);
+		SCXMLEditorPopupMenu menu = new SCXMLEditorPopupMenu(this, mousePoint, graphPoint, screenCoord);
+		menu.show(graphComponent, mousePoint.x, mousePoint.y);
+
+		e.consume();
+	}
+
+	protected void showElementEditor(MouseEvent e) {
+		Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent);
+		Point graphPoint = ((SCXMLGraphComponent) graphComponent).mouseCoordToGraphMouseCoord(mousePoint);
+		mxCell cell = (mxCell) graphComponent.getCellAt(graphPoint.x, graphPoint.y);
+		if (cell != null) {
+			if (cell.isVertex()) {
+				try {
+					openElementEditorFor(cell, Type.NODE, e.getLocationOnScreen());
+				} catch (Exception e1) {
+					System.out.println("Error while opening node editor.");
+				}
+			} else if (cell.isEdge()) {
+				try {
+					openElementEditorFor(cell, Type.EDGE, e.getLocationOnScreen());
+				} catch (Exception e1) {
+					System.out.println("Error while opening edge editor.");
+				}
+			}
+		}
+	}
+
+	/**
+	 * 
+	 */
+	protected void mouseLocationChanged(MouseEvent e) {
+		status(e.getX() + ", " + e.getY());
+	}
+
+	public int getScroollingAmount(JScrollBar hs, MouseWheelEvent e) {
+		return (int) (e.getWheelRotation() * hs.getModel().getExtent() * 0.3);
+	}
+
+	/**
+	 * 
+	 */
+	protected void installListeners() {
+		// Installs mouse wheel listener for zooming
+		MouseWheelListener wheelTracker = new MouseWheelListener() {
+			/**
+			 * 
+			 */
+			public void mouseWheelMoved(MouseWheelEvent e) {
+				if (e.getSource() instanceof mxGraphOutline || e.isControlDown()) {
+					SCXMLGraphEditor.this.mouseWheelMoved(e);
+				} else {
+					JScrollBar s = (e.isShiftDown()) ? graphComponent.getHorizontalScrollBar()
+							: graphComponent.getVerticalScrollBar();
+					if (s != null) {
+						int d = getScroollingAmount(s, e);
+						s.setValue(s.getValue() + d);
+					}
+				}
+			}
+
+		};
+
+		// Handles mouse wheel events in the outline and graph component
+		graphOutline.addMouseWheelListener(wheelTracker);
+		graphComponent.addMouseWheelListener(wheelTracker);
+
+		// Installs the popup menu in the outline
+		graphOutline.addMouseListener(new MouseAdapter() {
+			public void mousePressed(MouseEvent e) {
+				// Handles context menu on the Mac where the trigger is on
+				// mousepressed
+				mouseReleased(e);
+			}
+			public void mouseReleased(MouseEvent e) {
+				if (e.isPopupTrigger()) {
+					showOutlinePopupMenu(e);
+				}
+			}
+		});
+
+		// Installs the popup menu in the graph component
+		graphComponent.getGraphControl().addMouseListener(new MouseAdapter() {
+			public void mousePressed(MouseEvent e) {
+				// Handles context menu on the Mac where the trigger is on
+				// mousepressed
+				mouseReleased(e);
+			}
+			public void mouseReleased(MouseEvent e) {
+				if (e.isPopupTrigger() && isReadOnly==false) {
+					showGraphPopupMenu(e);
+				}
+			}
+			@Override
+			public void mouseClicked(MouseEvent e) {
+				if (e.getClickCount() == 2 && isReadOnly==false) {
+					showElementEditor(e);
+				}
+			}
+		});
+
+		// Installs a mouse motion listener to display the mouse location
+		graphComponent.getGraphControl().addMouseMotionListener(new MouseMotionListener() {
+			public void mouseDragged(MouseEvent e) {
+				mouseLocationChanged(e);
+			}
+			public void mouseMoved(MouseEvent e) {
+				mouseDragged(e);
+			}
+		});
+	}
+
+	/**
+	 * 
+	 */
+	public void setCurrentFile(File file, SCXMLImportExport fie) {
+		File oldValue = currentFile;
+		currentFile = file;
+		SCXMLImportExport oldFie = currentFileIOMethod;
+		currentFileIOMethod = fie;
+
+		firePropertyChange("currentFile", oldValue, file);
+		firePropertyChange("currentFileIO", oldFie, fie);
+
+		if (oldValue != file) {
+			updateTitle();
+		}
+		setLastModifiedDate();
+	}
+
+	public void setLastModifiedDate() {
+		File file = getCurrentFile();
+		if (file != null)
+			lastModifiedDate = file.lastModified();
+		else
+			lastModifiedDate = null;
+	}
+
+	public File getCurrentFile() {
+		return currentFile;
+	}
+
+	public SCXMLImportExport getCurrentFileIO() {
+		return currentFileIOMethod;
+	}
+
+	/**
+	 * 
+	 * @param modified
+	 */
+	public void setModified(boolean modified) {
+		boolean oldValue = this.modified;
+		this.modified = modified;
+
+		firePropertyChange("modified", oldValue, modified);
+
+		if (oldValue != modified) {
+			updateTitle();
+		}
+	}
+
+	public SCXMLGraphComponent getGraphComponent() {
+		return graphComponent;
+	}
+
+	public mxUndoManager getUndoManager() {
+		return undoManager;
+	}
+
+	/**
+	 * 
+	 * @param name
+	 * @param action
+	 * @return
+	 */
+	public Action bind(String name, final Action action) {
+		return bind(name, action, null);
+	}
+
+	/**
+	 * 
+	 * @param name
+	 * @param action
+	 * @return
+	 */
+	@SuppressWarnings("serial")
+	public AbstractActionWrapper bind(String name, final Action a, String iconUrl) {
+		return new AbstractActionWrapper(getGraphComponent(), name, a,
+				(iconUrl != null) ? new ImageIcon(SCXMLGraphEditor.class.getResource(iconUrl)) : null);
+	}
+
+	/**
+	 * 
+	 * @param msg
+	 */
+	public void status(String msg) {
+		statusBar.setText(msg);
+	}
+
+	/**
+	 * 
+	 */
+	public void updateTitle() {
+		JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
+
+		if (frame != null) {
+			String title = (currentFile != null) ? currentFile.getAbsolutePath() : mxResources.get("newDiagram");
+
+			if (modified) {
+				title += "*";
+			}
+
+			frame.setTitle(title + " - " + appTitle);
+		}
+	}
+
+	/**
+	 * 
+	 */
+	public void exit() {
+		JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
+
+		if (frame != null) {
+			frame.dispose();
+		}
+	}
+
+	public class SCXMLEditorFrame extends JFrame implements WindowListener {
+		private static final long serialVersionUID = -729543325068516592L;
+		private SCXMLGraphEditor editor;
+
+		public SCXMLEditorFrame(SCXMLGraphEditor e) {
+			super();
+			addWindowListener(this);
+			editor = e;
+		}
+
+		@Override
+		public void windowActivated(WindowEvent arg0) {
+		}
+
+		@Override
+		public void windowClosed(WindowEvent arg0) {
+		}
+
+		@Override
+		public void windowClosing(WindowEvent arg0) {
+			int errNo = validationStatus.getListModel().size();
+			if(0<errNo) {
+				int confirm = JOptionPane.showConfirmDialog(this,
+								"定義した状態遷移にエラーが存在します.このまま保存してもよろしいですか?",
+								"SCXML Editor",
+								JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+				if (confirm!=JOptionPane.YES_OPTION) return;
+			}
+			if(observer!=null) {
+				SCXMLImportExport exporter = new SCXMLImportExport();
+				try {
+					observer.notifyContents(exporter.output(graphComponent));
+				} catch (Exception e1) {
+					e1.printStackTrace();
+				}
+			}
+			editor.exit();
+			getGraphComponent().getValidator().kill();
+		}
+
+		@Override
+		public void windowDeactivated(WindowEvent arg0) {
+		}
+
+		@Override
+		public void windowDeiconified(WindowEvent arg0) {
+		}
+
+		@Override
+		public void windowIconified(WindowEvent arg0) {
+		}
+
+		@Override
+		public void windowOpened(WindowEvent arg0) {
+		}
+	}
+
+	private class ValidationWarningStatusPane extends JPanel implements ListSelectionListener {
+		private static final long serialVersionUID = -2024035745023293045L;
+		
+		private JList scxmlErrorsList;
+		private final DefaultListModel listModel = new DefaultListModel();
+		private ListCellSelector listSelectorHandler;
+
+		
+		public DefaultListModel getListModel() {
+			return listModel;
+		}
+
+		public ValidationWarningStatusPane() {
+			// Create the list and put it in a scroll pane.
+			scxmlErrorsList = buildValidationWarningGUI();
+			setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+			add(new JLabel("Validation errors:"));
+			add(new JScrollPane(scxmlErrorsList));
+
+			listSelectorHandler = new ValidationCellSelector(scxmlErrorsList, graphComponent);
+		}
+
+		private JList buildValidationWarningGUI() {
+			JList list = new JList(listModel);
+			list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+			list.addListSelectionListener(this);
+			list.setVisibleRowCount(10);
+			list.setCellRenderer((ListCellRenderer) new WarningRenderer());
+			return list;
+		}
+
+		class ValidationCellSelector extends ListCellSelector {
+			public ValidationCellSelector(JList list, SCXMLGraphComponent gc) {
+				super(list, gc);
+			}
+
+			@Override
+			public mxCell getCellFromListElement(int selectedIndex) {
+				if (listModel.size() < selectedIndex)
+					return null;
+				Pair<Object, String> element = (Pair<Object, String>) listModel.get(selectedIndex);
+				if (element != null) {
+					Object cell = element.getFirst();
+					if (cell instanceof mxCell)
+						return (mxCell) cell;
+					else
+						return null;
+				} else
+					return null;
+			}
+		}
+
+		class WarningRenderer extends JTextArea implements ListCellRenderer {
+			public Component getListCellRendererComponent(JList list, Object value, // value
+																					// to
+																					// display
+					int index, // cell index
+					boolean isSelected, // is the cell selected
+					boolean cellHasFocus) // the list and the cell have the
+											// focus
+			{
+				String text = "";
+				if (value != null) {
+					text = ((Pair<Object, String>) value).getSecond();
+				}
+				setText(text);
+				if (isSelected) {
+					setBackground(list.getSelectionBackground());
+					setForeground(list.getSelectionForeground());
+				} else {
+					setBackground(list.getBackground());
+					setForeground(list.getForeground());
+				}
+				setEnabled(list.isEnabled());
+				setFont(list.getFont());
+				setOpaque(true);
+				return this;
+			}
+		}
+
+		@Override
+		public void valueChanged(ListSelectionEvent e) {
+			listSelectorHandler.handleSelectEvent(e);
+		}
+
+		public void setWarnings(final HashMap<Object, String> warnings) {
+			SwingUtilities.invokeLater(new Runnable() {
+				@Override
+				public void run() {
+					ArrayList<Integer> indexToBeRemoved = new ArrayList<Integer>();
+					for (int i = 0; i < listModel.size(); i++) {
+						Pair<Object, String> el = (Pair<Object, String>) listModel.get(i);
+						if (el != null) {
+							String warningsForCell = warnings.get(el.getFirst());
+							if (!StringUtils.isEmptyString(warningsForCell)) {
+								warningsForCell = StringUtils.cleanupSpaces(warningsForCell);
+								if (!warningsForCell.equals(el.getSecond()))
+									listModel.set(i, new Pair<Object, String>(el.getFirst(), warningsForCell));
+								warnings.remove(el.getFirst());
+							} else
+								indexToBeRemoved.add(i);
+						} else {
+							indexToBeRemoved.add(i);
+						}
+					}
+					for (int i = indexToBeRemoved.size() - 1; i >= 0; i--)
+						listModel.removeElementAt(indexToBeRemoved.get(i));
+					for (Entry<Object, String> w : warnings.entrySet()) {
+						String warning = StringUtils.cleanupSpaces(w.getValue());
+						if (!StringUtils.isEmptyString(warning)) {
+							System.out.println(warning);
+							listModel.addElement(new Pair<Object, String>(w.getKey(), warning));
+						}
+					}
+				}
+			});
+		}
+	}
+
+	public JFrame createFrame(SCXMLGraphEditor editor) throws IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException,
+			InstantiationException, IllegalAccessException, InvocationTargetException {
+		SCXMLEditorFrame frame = new SCXMLEditorFrame(this);
+		// the contentPane of the JRootPane is a JPanel (that is the
+		// FSMGraphEditor)
+		// frame.setContentPane(this);
+
+		// frame.getContentPane().add(this);
+		// TODO: create menu bar
+
+		// Creates the graph outline component
+		graphOutline = new mxGraphOutline(graphComponent, 200, 200);
+
+		JPanel inner = new JPanel();
+		inner.setLayout(new BoxLayout(inner, BoxLayout.Y_AXIS));
+		validationStatus = new ValidationWarningStatusPane();
+		inner.add(validationStatus);
+		inner.add(graphOutline);
+
+		JSplitPane outer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, inner, graphComponent);
+		outer.setDividerLocation(200);
+		outer.setDividerSize(6);
+		outer.setBorder(null);
+
+		// Puts everything together
+		setLayout(new BorderLayout());
+		add(outer, BorderLayout.CENTER);
+
+		frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+		if(isReadOnly==false) {
+			frame.setJMenuBar(menuBar = new SCXMLEditorMenuBar(editor));
+		}
+		frame.setSize(870, 640);
+
+		// Updates the frame title
+		// Installs rubberband selection and handling for some special
+		// keystrokes such as F2, Control-C, -V, X, A etc.
+		installHandlers();
+		installListeners();
+		updateTitle();
+
+		// Installs automatic validation (use editor.validation = true
+		// if you are using an mxEditor instance)
+		graphComponent.getGraph().getModel().addListener(mxEvent.VALIDATION_DONE, new mxIEventListener() {
+			public void invoke(Object sender, mxEventObject evt) {
+				HashMap<Object, String> warnings = (HashMap<Object, String>) evt.getProperty("warnings");
+				validationStatus.setWarnings(warnings);
+			}
+		});
+		graphComponent.getGraph().getModel().addListener(mxEvent.VALIDATION_PRE_START, new mxIEventListener() {
+			public void invoke(Object sender, mxEventObject evt) {
+				graphComponent.clearSCXMLNodes();
+			}
+		});
+		graphComponent.getGraph().getModel().addListener(mxEvent.CHANGE, new mxIEventListener() {
+			public void invoke(Object sender, mxEventObject evt) {
+				if (getStatus() == EditorStatus.EDITING)
+					graphComponent.validateGraph();
+			}
+		});
+
+		frame.getContentPane().add(this);
+
+		return frame;
+	}
+
+	/**
+	 * Creates and executes the specified layout.
+	 * 
+	 * @param key
+	 *            Key to be used for getting the label from mxResources and also
+	 *            to create the layout instance for the commercial graph editor
+	 *            example.
+	 * @return
+	 */
+	@SuppressWarnings("serial")
+	public Action graphLayout(final String key) {
+		final mxIGraphLayout layout = createLayout(key);
+
+		if (layout != null) {
+			return new AbstractAction(mxResources.get(key)) {
+				public void actionPerformed(ActionEvent e) {
+					if (layout != null) {
+						Object cell = graphComponent.getGraph().getSelectionCell();
+
+						if (cell == null || graphComponent.getGraph().getModel().getChildCount(cell) == 0) {
+							cell = graphComponent.getGraph().getDefaultParent();
+						}
+
+						long t0 = System.currentTimeMillis();
+						layout.execute(cell);
+						status("Layout: " + (System.currentTimeMillis() - t0) + " ms");
+					}
+				}
+
+			};
+		} else {
+			return new AbstractAction(mxResources.get(key)) {
+
+				public void actionPerformed(ActionEvent e) {
+					JOptionPane.showMessageDialog(graphComponent, mxResources.get("noLayout"));
+				}
+
+			};
+		}
+	}
+
+	/**
+	 * Creates a layout instance for the given identifier.
+	 */
+	protected mxIGraphLayout createLayout(String ident) {
+		mxIGraphLayout layout = null;
+
+		if (ident != null) {
+			mxGraph graph = graphComponent.getGraph();
+
+			if (ident.equals("verticalHierarchical")) {
+				layout = new mxHierarchicalLayout(graph);
+			} else if (ident.equals("horizontalHierarchical")) {
+				layout = new mxHierarchicalLayout(graph, JLabel.WEST);
+			} else if (ident.equals("verticalTree")) {
+				layout = new mxCompactTreeLayout(graph, false);
+			} else if (ident.equals("horizontalTree")) {
+				layout = new mxCompactTreeLayout(graph, true);
+			} else if (ident.equals("parallelEdges")) {
+				layout = new mxParallelEdgeLayout(graph);
+			} else if (ident.equals("placeEdgeLabels")) {
+				layout = new mxEdgeLabelLayout(graph);
+			} else if (ident.equals("organicLayout")) {
+				layout = new mxFastOrganicLayout(graph);
+			}
+			if (ident.equals("verticalPartition")) {
+				layout = new mxPartitionLayout(graph, false) {
+					/**
+					 * Overrides the empty implementation to return the size of
+					 * the graph control.
+					 */
+					public mxRectangle getContainerSize() {
+						return graphComponent.getLayoutAreaSize();
+					}
+				};
+			} else if (ident.equals("horizontalPartition")) {
+				layout = new mxPartitionLayout(graph, true) {
+					/**
+					 * Overrides the empty implementation to return the size of
+					 * the graph control.
+					 */
+					public mxRectangle getContainerSize() {
+						return graphComponent.getLayoutAreaSize();
+					}
+				};
+			} else if (ident.equals("verticalStack")) {
+				layout = new mxStackLayout(graph, false) {
+					/**
+					 * Overrides the empty implementation to return the size of
+					 * the graph control.
+					 */
+					public mxRectangle getContainerSize() {
+						return graphComponent.getLayoutAreaSize();
+					}
+				};
+			} else if (ident.equals("horizontalStack")) {
+				layout = new mxStackLayout(graph, true) {
+					/**
+					 * Overrides the empty implementation to return the size of
+					 * the graph control.
+					 */
+					public mxRectangle getContainerSize() {
+						return graphComponent.getLayoutAreaSize();
+					}
+				};
+			} else if (ident.equals("circleLayout")) {
+				layout = new mxCircleLayout(graph);
+			}
+		}
+
+		return layout;
+	}
+
+	public static SCXMLGraphEditor startEditor() {
+		return startEditor(false, false);
+	}
+
+	public static SCXMLGraphEditor startEditor(boolean noGUI, boolean isReadOnly) {
+		try {
+			if (!noGUI)
+				UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+			mxConstants.SHADOW_COLOR = Color.LIGHT_GRAY;
+			SCXMLGraphComponent gc = new SCXMLGraphComponent(new SCXMLGraph());
+			SCXMLGraphEditor editor = new SCXMLGraphEditor("FSM Editor", gc, isReadOnly);
+			if (!noGUI)
+				editor.createFrame(editor).setVisible(true);
+			else
+				gc.getValidator().kill();
+			editor.getGraphComponent().requestFocusInWindow();
+
+			return editor;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static SCXMLGraphEditor openEditor(String targetFile, SCXMLNotifier target, boolean isReadOnly) throws Exception {
+		SCXMLGraphEditor editor = startEditor(false, isReadOnly);
+		editor.setObserver(target);
+		editor.setReadOnly(isReadOnly);
+		if(targetFile==null || targetFile.length()==0) {
+			NewSCXMLAction action = new NewSCXMLAction();
+			action.openNewAction(editor);
+		} else {
+			File sourceFile = new File(targetFile);
+			OpenAction action = new OpenAction(sourceFile);
+			action.doStartAction(editor, isReadOnly);
+		}
+		return editor;
+	}
+
+	public static SCXMLGraphEditor openEditorWithContents(String contents, SCXMLNotifier target, boolean isReadOnly) throws Exception {
+		SCXMLGraphEditor editor = startEditor(false, isReadOnly);
+		editor.setObserver(target);
+		OpenAction action = new OpenAction();
+		action.doStartActionContents(contents, editor, isReadOnly);
+		return editor;
+	}
+	
+	private final HashMap<mxCell, HashMap<Type, JDialog>> editorForCellAndType = new HashMap<mxCell, HashMap<Type, JDialog>>();
+
+	public void closeAllEditors() {
+		for (HashMap<Type, JDialog> te : editorForCellAndType.values()) {
+			for (JDialog e : te.values()) {
+				e.dispose();
+			}
+		}
+	}
+
+	public boolean isCellBeingEdited(mxCell cell) {
+		HashMap<Type, JDialog> editorsForCell = editorForCellAndType.get(cell);
+		if (editorsForCell != null && !editorsForCell.isEmpty()) {
+			for (JDialog e : editorsForCell.values())
+				if (e != null)
+					return true;
+		}
+		return false;
+	}
+
+	public JDialog getEditorForCellAndType(mxCell cell, Type type) {
+		HashMap<Type, JDialog> editorsForCell = editorForCellAndType.get(cell);
+		if (editorsForCell != null) {
+			return editorsForCell.get(type);
+		}
+		return null;
+	}
+
+	public void setEditorForCellAndType(mxCell cell, Type type, JDialog editor) {
+		if (type != null) {
+			HashMap<Type, JDialog> editorsForCell = editorForCellAndType.get(cell);
+			if (editorsForCell == null)
+				editorForCellAndType.put(cell, editorsForCell = new HashMap<Type, JDialog>());
+			editorsForCell.put(type, editor);
+		}
+	}
+
+	public void clearEditorForCellAndType() {
+		editorForCellAndType.clear();
+	}
+
+	public void openElementEditorFor(mxCell cell, Type type, Point pos) throws Exception {
+		JDialog ee = getEditorForCellAndType(cell, type);
+		if (ee != null) {
+			ee.setVisible(true);
+		} else {
+			JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
+			switch (type) {
+			case EDGE:
+				ee = new SCXMLTransitionEditor(frame, cell, this, pos);
+				break;
+			case NODE:
+				SCXMLGraphComponent gc = getGraphComponent();
+				SCXMLGraph graph = gc.getGraph();
+				mxIGraphModel model = graph.getModel();
+				mxCell root = SCXMLImportExport.followUniqueDescendantLineTillSCXMLValueIsFound(model);
+				ee = new SCXMLStateEditor(frame, cell, root, this, pos);
+				break;
+			default:
+				throw new Exception("Unknown element editor type requested: " + type);
+			}
+			setEditorForCellAndType(cell, type, ee);
+		}
+		int screenMaxX = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
+		int screenMaxY = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
+		int dialogMaxXCoordinateOnScreen = pos.x + ee.getWidth();
+		int dialogMaxYCoordinateOnScreen = pos.y + ee.getHeight();
+		int diff;
+		if (dialogMaxXCoordinateOnScreen > screenMaxX) {
+			diff = dialogMaxXCoordinateOnScreen - screenMaxX;
+			pos.x = pos.x - diff;
+		}
+		if (dialogMaxYCoordinateOnScreen > screenMaxY) {
+			diff = dialogMaxYCoordinateOnScreen - screenMaxY;
+			pos.y = pos.y - diff;
+		}
+		ee.setLocation(pos);
+	}
+
+	public SCXMLConstraints getRestrictedStatesConfig() {
+		return restrictedStatesConfig;
+	}
+	
+	public void updateEditor(String target) {
+		mxCell targetCell = null;
+		mxIGraphModel model = getGraphComponent().getGraph().getModel();
+		mxCell root = (mxCell)model.getRoot();
+		int num = model.getChildCount(root);
+		for(int index=0; index<num; index++) {
+			mxCell child = (mxCell)model.getChildAt(root, index);
+			targetCell = searchChildCell(child, target);
+		}
+		//
+		if(targetCell!=null) {
+			if(cellHighlighter==null) cellHighlighter = new CellSelector(getGraphComponent());
+			cellHighlighter.unselectAll();
+			cellHighlighter.selectCell(targetCell);
+		}
+	}
+	
+	private mxCell searchChildCell(mxCell parent, String target) {
+		mxCell result = null;
+		int num = parent.getChildCount();
+		for(int index=0; index<num; index++) {
+			mxCell child = (mxCell)parent.getChildAt(index);
+			if(child.getValue()!=null && child.getValue() instanceof SCXMLNode) {
+				SCXMLNode node = (SCXMLNode)child.getValue();
+				if(node.getID().equals(target)) {
+					return child;
+				}
+			}
+			result = searchChildCell(child, target);
+			if(result!=null) return result;
+		}
+		return null;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLNotifier.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLNotifier.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/SCXMLNotifier.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,6 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor;
+
+public interface SCXMLNotifier {
+	void notifyContents(String contents);
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/OutSource.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/OutSource.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/OutSource.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,38 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport;
+
+import java.io.Serializable;
+
+public class OutSource implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	public enum OUTSOURCETYPE {SRC,XINC};
+
+	private OUTSOURCETYPE type;
+	private String location;
+	public OutSource(OUTSOURCETYPE t,String l) {
+		setLocation(l);
+		setType(t);
+	}
+	public OUTSOURCETYPE getType() {
+		return type;
+	}
+	public String getLocation() {
+		return location;
+	}
+	public void setLocation(String location) {
+		this.location = location;
+	}
+	public void setType(OUTSOURCETYPE type) {
+		this.type = type;
+	}
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof OutSource) {
+			OutSource objOutSource=(OutSource)obj;
+			return (obj!=null && ((objOutSource.location!=null && objOutSource.location.equals(location)) ||
+					(objOutSource.location==null))
+					&& ((objOutSource.type!=null && objOutSource.type.equals(type)) ||
+							(objOutSource.type==null)));
+		} else return super.equals(obj);
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLEdge.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLEdge.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLEdge.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,351 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Matcher;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGeometry;
+import com.mxgraph.util.StringUtils;
+import com.mxgraph.util.mxPoint;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.MyUndoManager;
+
+public class SCXMLEdge implements Serializable {
+	private static final long serialVersionUID = -136975794270718480L;
+
+	public static final String INTERNALID = "internalID";
+	public static final String CONDITION = "cond";
+	public static final String EVENT = "event";
+	public static final String EDGEGEO = "edgeSavedGeometry";
+	public static final String EDGEEXE = "edgeexe";
+	public static final String TARGETS = "targets";
+	public static final String SOURCE = "source";
+	public static final String EDGEORDER = "edgeOrder"; // the order of this
+														// edge with respect to
+														// the other edges
+														// exiting the same node
+	public static final String WITHTARGET = "withTarget"; // an edge can be
+															// without target
+															// (event handler)
+
+	public static final String EVENTUNDO = "EVENTundo";
+	public static final String EVENTDOC = "EVENTdoc";
+	public static final String CONDITIONUNDO = "CONDundo";
+	public static final String CONDITIONDOC = "CONDdoc";
+	public static final String EXEUNDO = "EXEundo";
+	public static final String EXEDOC = "EXEdoc";
+
+	public static final String COMMENTS = "comments";
+	public static final String COMMENTSUNDO = "DMundo";
+	public static final String COMMENTSDOC = "DMdoc";
+
+	private HashMap<String, Object> edge;
+
+	public SCXMLEdge() {
+		edge = new HashMap<String, Object>();
+		edge.put(WITHTARGET, false);
+		setSCXMLTargets(new ArrayList<String>());
+		setEvent("");
+	}
+
+	public SCXMLEdge(String fromSCXMLID, List<String> toSCXMLIDs, String cond, String event, String content,
+			HashMap<String, String> geometry) {
+		edge = new HashMap<String, Object>();
+		edge.put(CONDITION, cond);
+		edge.put(EVENT, event);
+		edge.put(EDGEEXE, content);
+		edge.put(SOURCE, fromSCXMLID);
+		edge.put(EDGEGEO, geometry);
+		if (toSCXMLIDs == null) {
+			ArrayList<String> targets = new ArrayList<String>();
+			targets.add(fromSCXMLID);
+			edge.put(TARGETS, targets);
+			edge.put(WITHTARGET, false);
+		} else {
+			edge.put(TARGETS, toSCXMLIDs);
+			edge.put(WITHTARGET, true);
+		}
+	}
+
+	public boolean isCycle() {
+		ArrayList<String> targets = getSCXMLTargets();
+		return (targets.size() == 1) && (getSCXMLSource().equals(targets.get(0)));
+	}
+
+	public boolean isCycleWithTarget() {
+		return isCycle() && (Boolean) edge.get(WITHTARGET);
+	}
+
+	public void setCycleWithTarget(boolean withTarget) {
+		edge.put(WITHTARGET, withTarget);
+	}
+
+	public String getSCXMLSource() {
+		return (String) edge.get(SOURCE);
+	}
+
+	public void setSCXMLSource(String sourceID) {
+		edge.put(SOURCE, sourceID);
+	}
+
+	public mxGeometry getEdgeGeometry(String target) {
+		HashMap<String, String> geometries = (HashMap<String, String>) edge.get(EDGEGEO);
+		try {
+			if (geometries != null) {
+				String geometry = geometries.get(target);
+				if (!StringUtils.isEmptyString(geometry)) {
+					ArrayList<mxPoint> points = new ArrayList<mxPoint>();
+					mxPoint offset = null, point = null;
+					Matcher m = SCXMLImportExport.xyPattern.matcher(geometry);
+					while (m.find()) {
+						points.add(new mxPoint(Double.parseDouble(m.group(1)), Double.parseDouble(m.group(2))));
+					}
+					m = SCXMLImportExport.offsetPattern.matcher(geometry);
+					while (m.find()) {
+						point = new mxPoint(Double.parseDouble(m.group(1)), Double.parseDouble(m.group(2)));
+						offset = new mxPoint(Double.parseDouble(m.group(3)), Double.parseDouble(m.group(4)));
+					}
+					if ((!points.isEmpty()) || (offset != null)) {
+						mxGeometry geo = new mxGeometry();
+						if (!points.isEmpty())
+							geo.setPoints(points);
+						if (offset != null) {
+							geo.setX(point.getX());
+							geo.setY(point.getY());
+							geo.setOffset(offset);
+						}
+						geo.setRelative(true);
+						return geo;
+					}
+				}
+			}
+		} catch (Exception e) {
+		}
+		return null;
+	}
+
+	public ArrayList<String> getSCXMLTargets() {
+		return (ArrayList<String>) edge.get(TARGETS);
+	}
+
+	public void setSCXMLTargets(ArrayList<String> targetIDs) {
+		edge.put(TARGETS, targetIDs);
+	}
+
+	public String getInternalID() {
+		return (String) edge.get(INTERNALID);
+	}
+
+	public void setInternalID(String internalID) {
+		edge.put(INTERNALID, internalID);
+	}
+
+	public String getEvent() {
+		String ret = null;
+		Document dmd = getEventDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) edge.get(EVENT);
+			}
+		} else
+			ret = (String) edge.get(EVENT);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setEvent(String e) {
+		edge.put(EVENT, e);
+	}
+
+	public String getCondition() {
+		String ret = null;
+		Document dmd = getConditionDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) edge.get(CONDITION);
+			}
+		} else
+			ret = (String) edge.get(CONDITION);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setCondition(String c) {
+		edge.put(CONDITION, c);
+	}
+
+	public String getExe() {
+		String ret = null;
+		Document dmd = getExeDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) edge.get(EDGEEXE);
+			}
+		} else
+			ret = (String) edge.get(EDGEEXE);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setExe(String e) {
+		edge.put(EDGEEXE, e);
+	}
+
+	public MyUndoManager getCommentsUndoManager() {
+		return (MyUndoManager) edge.get(COMMENTSUNDO);
+	}
+
+	public MyUndoManager setCommentsUndoManager(MyUndoManager um) {
+		edge.put(COMMENTSUNDO, um);
+		return um;
+	}
+
+	public Document getCommentsDoc() {
+		return (Document) edge.get(COMMENTSDOC);
+	}
+
+	public Document setCommentsDoc(Document doc) {
+		edge.put(COMMENTSDOC, doc);
+		return doc;
+	}
+
+	public void setComments(String cm) {
+		edge.put(COMMENTS, cm);
+	}
+
+	public String getComments() {
+		String ret = null;
+		Document dmd = getCommentsDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) edge.get(COMMENTS);
+			}
+		} else
+			ret = (String) edge.get(COMMENTS);
+		return (ret == null) ? "" : ret;
+	}
+
+	// getter and setter for document and undomanager for editing event
+	public MyUndoManager getEventUndoManager() {
+		return (MyUndoManager) edge.get(EVENTUNDO);
+	}
+
+	public MyUndoManager setEventUndoManager(MyUndoManager um) {
+		edge.put(EVENTUNDO, um);
+		return um;
+	}
+
+	public Document getEventDoc() {
+		return (Document) edge.get(EVENTDOC);
+	}
+
+	public Document setEventDoc(Document doc) {
+		edge.put(EVENTDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for editing condition
+	public MyUndoManager getConditionUndoManager() {
+		return (MyUndoManager) edge.get(CONDITIONUNDO);
+	}
+
+	public MyUndoManager setConditionUndoManager(MyUndoManager um) {
+		edge.put(CONDITIONUNDO, um);
+		return um;
+	}
+
+	public Document getConditionDoc() {
+		return (Document) edge.get(CONDITIONDOC);
+	}
+
+	public Document setConditionDoc(Document doc) {
+		edge.put(CONDITIONDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for editing executable
+	// content
+	public MyUndoManager getExeUndoManager() {
+		return (MyUndoManager) edge.get(EXEUNDO);
+	}
+
+	public MyUndoManager setExeUndoManager(MyUndoManager um) {
+		edge.put(EXEUNDO, um);
+		return um;
+	}
+
+	public Document getExeDoc() {
+		return (Document) edge.get(EXEDOC);
+	}
+
+	public Document setExeDoc(Document doc) {
+		edge.put(EXEDOC, doc);
+		return doc;
+	}
+
+	public SCXMLEdge cloneEdge() {
+		SCXMLEdge e = new SCXMLEdge();
+		e.edge = (HashMap<String, Object>) this.edge.clone();
+		// as for the node, set all documents to null, but gets the values they
+		// contain because it's the most updated.
+		e.setConditionDoc(null);
+		e.setConditionUndoManager(null);
+		e.setCondition(getCondition());
+		e.setCommentsDoc(null);
+		e.setCommentsUndoManager(null);
+		e.setComments(getComments());
+		e.setEventDoc(null);
+		e.setEventUndoManager(null);
+		e.setEvent(getEvent());
+		e.setExeDoc(null);
+		e.setExeUndoManager(null);
+		e.setExe(getExe());
+		e.setSCXMLTargets(new ArrayList<String>(getSCXMLTargets()));
+		return e;
+	}
+
+	public void setOrder(int o) {
+		assert (o >= 0);
+		edge.put(EDGEORDER, o);
+	}
+
+	public Integer getOrder() {
+		if (edge.containsKey(EDGEORDER))
+			return (Integer) edge.get(EDGEORDER);
+		else
+			return null;
+	}
+
+	private void writeObject(ObjectOutputStream out) throws IOException {
+		SCXMLEdge newe = cloneEdge();
+		HashMap<String, Object> hash = edge;
+		edge = newe.edge;
+		out.defaultWriteObject();
+		edge = hash;
+	}
+
+	public String toString() {
+		return getSCXMLSource() + "-[" + getCondition() + "," + getEvent() + "]->" + getSCXMLTargets();
+	}
+
+	public String getStyle(mxCell cell) {
+		boolean cycle = (cell == null) ? isCycle() : (cell.getTarget() == cell.getSource());
+		String ret = "straight;strokeColor=#888888;";
+		if (cycle && (!isCycleWithTarget()))
+			ret += "strokeWidth=3;dashed=1;";
+		return ret;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLImportExport.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLImportExport.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLImportExport.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,1148 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.JOptionPane;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGeometry;
+import com.mxgraph.model.mxICell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.swing.mxGraphComponent;
+import com.mxgraph.util.StringUtils;
+import com.mxgraph.util.mxPoint;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.util.mxUtils;
+import com.mxgraph.view.mxCellState;
+import com.mxgraph.view.mxGraphView;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints;
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.OutSource.OUTSOURCETYPE;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraph;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraphComponent;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.XMLUtils;
+
+public class SCXMLImportExport {
+
+	private SCXMLNode root = null;
+	private HashMap<String, SCXMLNode> internalID2nodes = new HashMap<String, SCXMLNode>();
+	private HashMap<String, ArrayList<SCXMLNode>> internalID2clusters = new HashMap<String, ArrayList<SCXMLNode>>();
+	private HashMap<String, SCXMLNode> scxmlID2nodes = new HashMap<String, SCXMLNode>();
+	private HashMap<String, HashMap<String, HashSet<SCXMLEdge>>> fromToEdges = new HashMap<String, HashMap<String, HashSet<SCXMLEdge>>>();
+	private int internalIDcounter = 11;
+	public static final String RESTRICTEDSTATECOMMENT = "restriction_type";
+
+	private HashSet<SCXMLEdge> getEdges(String SCXMLfromID, String SCXMLtoID) {
+		assert (!SCXMLfromID.equals(""));
+		HashMap<String, HashSet<SCXMLEdge>> toEdge = fromToEdges.get(SCXMLfromID);
+		return (toEdge == null) ? null : toEdge.get(SCXMLtoID);
+	}
+
+	private int getNumEdgesFrom(String SCXMLfromID) {
+		assert (!SCXMLfromID.equals(""));
+		HashMap<String, HashSet<SCXMLEdge>> toEdge = fromToEdges.get(SCXMLfromID);
+		if (toEdge == null)
+			return 0;
+		else {
+			int tot = 0;
+			for (HashSet<SCXMLEdge> es : toEdge.values()) {
+				tot += es.size();
+			}
+			return tot;
+		}
+	}
+
+	private SCXMLEdge addEdge(HashMap<String, Object> ec) throws Exception {
+		System.out.println("add edge: " + ec.get(SCXMLEdge.SOURCE) + "->" + ec.get(SCXMLEdge.TARGETS));
+		return addEdge((String) ec.get(SCXMLEdge.SOURCE), (List) ec.get(SCXMLEdge.TARGETS),
+				(String) ec.get(SCXMLEdge.CONDITION), (String) ec.get(SCXMLEdge.EVENT),
+				(String) ec.get(SCXMLEdge.EDGEEXE), (HashMap<String, String>) ec.get(SCXMLEdge.EDGEGEO));
+	}
+
+	private SCXMLEdge addEdge(String SCXMLfromID, List<String> targets, String cond, String event, String content,
+			HashMap<String, String> geometry) throws Exception {
+		SCXMLEdge edge = new SCXMLEdge(SCXMLfromID, targets, cond, event, content, geometry);
+		edge.setInternalID(getNextInternalID());
+		int oe = getNumEdgesFrom(SCXMLfromID);
+		edge.setOrder((oe <= 0) ? 0 : oe);
+
+		if (targets == null) {
+			targets = new ArrayList<String>();
+			targets.add(SCXMLfromID);
+		}
+		for (String target : targets) {
+			HashSet<SCXMLEdge> edges = getEdges(SCXMLfromID, target);
+			if (edges == null) {
+				edges = new HashSet<SCXMLEdge>();
+				edges.add(edge);
+				HashMap<String, HashSet<SCXMLEdge>> toEdges = fromToEdges.get(SCXMLfromID);
+				if (toEdges == null) {
+					toEdges = new HashMap<String, HashSet<SCXMLEdge>>();
+					fromToEdges.put(SCXMLfromID, toEdges);
+				}
+				toEdges.put(target, edges);
+			} else {
+				edges.add(edge);
+			}
+		}
+		return edge;
+	}
+
+	private void setNodeAsChildOf(SCXMLNode node, SCXMLNode pn) {
+		if (pn != null) {
+			// make pn a cluster and add node to its children
+			ArrayList<SCXMLNode> cluster = setThisNodeAsCluster(pn);
+			addThisNodeAsChildrenOfCluster(node, cluster);
+		}
+	}
+
+	public ArrayList<SCXMLNode> setThisNodeAsCluster(SCXMLNode node) {
+		ArrayList<SCXMLNode> cluster = null;
+		if (!isThisNodeACluster(node)) {
+			node.setShape(SCXMLNode.CLUSTERSHAPE);
+			internalID2clusters.put(node.getInternalID(), cluster = new ArrayList<SCXMLNode>());
+		} else
+			cluster = internalID2clusters.get(node.getInternalID());
+		return cluster;
+	}
+
+	public void addThisNodeAsChildrenOfCluster(SCXMLNode node, ArrayList<SCXMLNode> cluster) {
+		cluster.add(node);
+	}
+
+	public Boolean isThisNodeACluster(SCXMLNode node) {
+		String internalID = node.getInternalID();
+		return internalID2clusters.containsKey(internalID);
+	}
+
+	public SCXMLNode getClusterNamed(String internalID) {
+		assert (isThisNodeACluster(internalID2nodes.get(internalID)));
+		return internalID2nodes.get(internalID);
+	}
+
+	public SCXMLNode getNodeFromSCXMLID(String scxmlID) {
+		assert (!StringUtils.isEmptyString(scxmlID));
+		return scxmlID2nodes.get(scxmlID);
+	}
+
+	public mxCell getCellFromInternalID(String internalID) {
+		assert (!internalID.equals(""));
+		return internalID2cell.get(internalID);
+	}
+
+	public String getNextInternalID() {
+		return "" + internalIDcounter++;
+	}
+
+	public void addSCXMLNode(SCXMLNode node) {
+		// System.out.println("Adding node: "+node);
+		String scxmlID = node.getID();
+		String internalID = getNextInternalID();
+		node.setInternalID(internalID);
+		if (!StringUtils.isEmptyString(scxmlID))
+			scxmlID2nodes.put(scxmlID, node);
+		internalID2nodes.put(internalID, node);
+	}
+
+	private SCXMLNode buildAndAddBasicNodeAsChildOf(String id, String name, SCXMLNode pn, boolean isFake) {
+		SCXMLNode node;
+		if (id.equals("") || ((node = scxmlID2nodes.get(id)) == null)) {
+			node = new SCXMLNode();
+			node.setID(id);
+			addSCXMLNode(node);
+		}
+		node.setName(name);
+		node.setFake(isFake);
+		// see issue 7 in google code website
+		if (node != pn)
+			setNodeAsChildOf(node, pn);
+		return node;
+	}
+
+	private SCXMLNode handleSCXMLNode(Node n, SCXMLNode pn, Boolean isParallel, Boolean isHistory) throws Exception {
+		NamedNodeMap att = n.getAttributes();
+		Node nodeID = att.getNamedItem("id");
+		String nodeIDString = null, nodeNameString = null;
+		if (nodeID == null) {
+			if (n.getNodeName().toLowerCase().equals(SCXMLNode.ROOTID.toLowerCase())) {
+				nodeIDString = SCXMLNode.ROOTID;
+			} else {
+				nodeIDString = "";
+			}
+		} else {
+			nodeIDString = StringUtils.cleanupSpaces(nodeID.getNodeValue());
+		}
+		Node nodeName = att.getNamedItem("name");
+		nodeNameString = (nodeName == null) ? null : StringUtils.cleanupSpaces(nodeName.getNodeValue());
+
+		Node nodeHistoryType = att.getNamedItem("type");
+		String nodeHistoryTypeString = (nodeHistoryType == null) ? "shallow"
+				: StringUtils.cleanupSpaces(nodeHistoryType.getNodeValue());
+		SCXMLNode.HISTORYTYPE historyType = null;
+		try {
+			historyType = SCXMLNode.HISTORYTYPE.valueOf(nodeHistoryTypeString.toUpperCase());
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		SCXMLNode node = buildAndAddBasicNodeAsChildOf(nodeIDString, nodeNameString, pn, false);
+		if ((!isHistory) || (historyType == null)) {
+			node.setParallel(isParallel);
+			Node isInitial = null;
+			Node isFinal = null;
+			if (((isFinal = att.getNamedItem("final")) != null) && (isFinal.getNodeValue().equals("true"))) {
+				node.setFinal(true);
+			}
+			if (((isInitial = att.getNamedItem("initial")) != null)
+					|| ((isInitial = att.getNamedItem("initialstate")) != null)) {
+				String[] initialStates = StringUtils.cleanupSpaces(isInitial.getNodeValue()).split("[\\s]");
+				for (String initialStateID : initialStates) {
+					SCXMLNode in = getNodeFromSCXMLID(initialStateID);
+					if (in == null)
+						in = new SCXMLNode();
+					in.setID(initialStateID);
+					in.setInitial(true);
+					addSCXMLNode(in);
+				}
+			}
+			// set namespace attribute
+			int na = att.getLength();
+			String namespace = "";
+			for (int i = 0; i < na; i++) {
+				Node a = att.item(i);
+				String name = a.getNodeName().toLowerCase();
+				if (name.startsWith("xmlns")) {
+					namespace += a.getNodeName() + "=\"" + a.getNodeValue() + "\"\n";
+				} else if (name.equals("src")) {
+					setNodeAsOutsourcing(new OutSource(OUTSOURCETYPE.SRC, a.getNodeValue()), node);
+				}
+			}
+			if (!StringUtils.isEmptyString(namespace))
+				node.setNamespace(namespace);
+		} else {
+			node.setAsHistory(historyType);
+			pn.setCluster(true);
+		}
+		// set src attribute
+		return node;
+	}
+
+	public void scanChildrenOf(SCXMLGraphEditor editor, Node el, SCXMLNode pn, File pwd,
+			SCXMLConstraints restrictedConstraints) throws Exception {
+		NodeList states = el.getChildNodes();
+		for (int s = 0; s < states.getLength(); s++) {
+			Node n = states.item(s);
+			getNodeHier(editor, n, pn, pwd, restrictedConstraints);
+		}
+	}
+
+	private static String[] commentsCollector = new String[] { "" };
+
+	private Object addCommentsAndResetCollectorTo(Object thing) throws Exception {
+		if (!StringUtils.isEmptyString(commentsCollector[0])) {
+			if (thing instanceof SCXMLNode) {
+				((SCXMLNode) thing).setComments(commentsCollector[0]);
+			} else if (thing instanceof SCXMLEdge) {
+				((SCXMLEdge) thing).setComments(commentsCollector[0]);
+			} else if (thing instanceof String) {
+				thing = ((String) thing).concat("<!--" + commentsCollector[0] + "-->");
+			} else {
+				throw new Exception("Tried to add comments to unexpected thing: " + thing);
+			}
+			commentsCollector[0] = "";
+		}
+		return thing;
+	}
+
+	public SCXMLNode getNodeHier(SCXMLGraphEditor editor, Node n, SCXMLNode pn, File pwd,
+			SCXMLConstraints restrictedConstraints) throws Exception {
+		SCXMLNode root = null;
+		switch (n.getNodeType()) {
+		case Node.ELEMENT_NODE:
+			String name = n.getNodeName().toLowerCase();
+			// STATE: normal or parallel
+			Boolean isParallel = false;
+			boolean isHistory = false;
+			if (name.equals(SCXMLNode.ROOTID.toLowerCase()) || name.equals("state")
+					|| (isParallel = name.equals("parallel")) || (isHistory = name.equals("history"))) {
+				root = handleSCXMLNode(n, pn, isParallel, isHistory);
+				addCommentsAndResetCollectorTo(root);
+				// continue recursion on the children of this node
+				scanChildrenOf(editor, n, root, pwd, restrictedConstraints);
+				processOutsourcingChildrenForNode(root, pwd);
+			} else if (name.equals("transition")) {
+				SCXMLEdge edge = addEdge(processEdge(pn, n));
+				addCommentsAndResetCollectorTo(edge);
+			} else if (name.equals("final")) {
+				SCXMLNode node = handleSCXMLNode(n, pn, isParallel, false);
+				addCommentsAndResetCollectorTo(node);
+				node.setFinal(true);
+				scanChildrenOf(editor, n, node, pwd, restrictedConstraints);
+			} else if (name.equals("initial")) {
+				// pn.setInitial(true);
+				// only one child that is a transition
+				NodeList cs = n.getChildNodes();
+				for (int i = 0; i < cs.getLength(); i++) {
+					Node c = cs.item(i);
+					if ((c.getNodeType() == Node.ELEMENT_NODE) && c.getNodeName().toLowerCase().equals("transition")) {
+						HashMap<String, Object> edgeContent = processEdge(pn, c);
+						// pn.setOnInitialEntry(edgeContent.get(SCXMLEdge.EDGEEXE));
+						ArrayList<String> inNames = (ArrayList<String>) edgeContent.get(SCXMLEdge.TARGETS);
+						if (inNames.size() > 1)
+							throw new Exception("Unhandled multiple initial states. Report test case.");
+						for (String inName : inNames) {
+							if (inName != null) {
+								SCXMLNode in = getNodeFromSCXMLID(inName);
+								if (in == null)
+									in = new SCXMLNode();
+								in.setID(inName);
+								in.setInitial(true);
+								addSCXMLNode(in);
+								in.setOnInitialEntry((String) edgeContent.get(SCXMLEdge.EDGEEXE));
+							}
+						}
+						break;
+					}
+				}
+			} else if (name.equals("onentry")) {
+				String content = collectAllChildrenInString(n);
+				pn.setOnEntry(content);
+			} else if (name.equals("onexit")) {
+				String content = collectAllChildrenInString(n);
+				pn.setOnExit(content);
+			} else if (name.equals("donedata")) {
+				String content = collectAllChildrenInString(n);
+				pn.setDoneData(content);
+			} else if (name.equals("datamodel")) {
+				String content = collectAllChildrenInString(n);
+				if(content!=null && 0<content.length()) {
+					content = content.replace("</data>", "").replace("<data>", "");
+				}
+				pn.addToDataModel(content);
+			} else if (name.equals("xi:include")) {
+				NamedNodeMap att = n.getAttributes();
+				Node nodeLocation = att.getNamedItem("href");
+				String location = (nodeLocation == null) ? "" : StringUtils.cleanupSpaces(nodeLocation.getNodeValue());
+				location = StringUtils.cleanupSpaces(location);
+				System.out.println(location);
+				if (!StringUtils.isEmptyString(location)) {
+					SCXMLNode child = setNodeAsOutsourcing(new OutSource(OUTSOURCETYPE.XINC, location), pn);
+					scanChildrenOf(editor, n, child, pwd, restrictedConstraints);
+				}
+			} else {
+				String content = XMLUtils.prettyPrintXMLString(XMLUtils.domNode2String(n, true), " ", true);
+				pn.appendToScript(content);
+			}
+			break;
+		case Node.COMMENT_NODE:
+			String nodeValueString = n.getNodeValue();
+			if ((!readNodeGeometry(pn, nodeValueString)) && (!(nodeValueString.contains(RESTRICTEDSTATECOMMENT)))) {
+				commentsCollector[0] += nodeValueString;
+			}
+			if ((nodeValueString.contains(RESTRICTEDSTATECOMMENT)) && (restrictedConstraints != null)) {
+				System.out.println("Contains restriction comment...");
+				if (pn.isFinal()) {
+					JOptionPane.showMessageDialog(
+							editor, mxResources.get("finalNodeCanNotBeToggledWithRestriction") + " [node id: "
+									+ pn.getID() + "]",
+							mxResources.get("restrictionOnFinalNode"), JOptionPane.WARNING_MESSAGE);
+				} else {
+					String[] restrictionTypes = nodeValueString.split(":")[1].replace(" ", "").split(";");
+					boolean isValidRestriction = false;
+					for (int i = 0; i < restrictionTypes.length; i++) {
+						String restrictionType = restrictionTypes[i];
+						for (RestrictedState restrictedState : restrictedConstraints.getRestrictedState()) {
+							if (restrictedState.getName().equals(restrictionType)) {
+								pn.setRestricted(true, restrictedState);
+								isValidRestriction = true;
+							}
+						}
+						if (!isValidRestriction) {
+							JOptionPane.showMessageDialog(editor,
+									mxResources.get("invalidRestrictionTypeMessage") + " [" + restrictionType + "]",
+									mxResources.get("invalidRestrictionTypeTitle"), JOptionPane.WARNING_MESSAGE);
+						}
+					}
+				}
+			}
+			break;
+		}
+		return root;
+	}
+
+	private SCXMLNode setNodeAsOutsourcing(OutSource source, SCXMLNode parent) {
+		String nodeName = (source.getType() == OUTSOURCETYPE.XINC) ? source.getLocation() : parent.getID();
+		SCXMLNode child = buildAndAddBasicNodeAsChildOf(nodeName, null, parent, source.getType() == OUTSOURCETYPE.XINC);
+		child.setSRC(source);
+		return child;
+	}
+
+	// identifies that the outsourcing is done in a way for which we can support
+	// saving to file
+	// preserving the outsourcing to other files.
+	private void processOutsourcingChildrenForNode(SCXMLNode node, File pwd) throws Exception {
+		if (node != null) {
+			HashSet<OutSource> outSources = node.getOutsourcingChildren();
+			if (outSources != null) {
+				for (OutSource source : outSources) {
+					SCXMLNode child = buildAndAddBasicNodeAsChildOf(source.getLocation(), null, node,
+							source.getType() == OUTSOURCETYPE.XINC);
+					child.setSRC(source);
+				}
+			}
+			/*
+			 * if ((outSources.size()==1) && !node.isClusterNode()) {
+			 * node.setSRC(outSources.iterator().next()); } else { for(OutSource
+			 * source:outSources) { if (source.getType()==OUTSOURCETYPE.XINC) {
+			 * saveProblematicNodes.add(node); String fileLocation=new File(pwd,
+			 * source.getLocation()).getAbsolutePath();
+			 * readSCXMLFileContentAndAttachAsChildrenOf(fileLocation, node); }
+			 * else { throw new Exception("Bug: multiple SRC inclusions."); } }
+			 * } }
+			 */
+		}
+	}
+
+	private HashMap<String, Object> processEdge(SCXMLNode pn, Node n) throws Exception {
+		HashMap<String, Object> ret = new HashMap<String, Object>();
+		// event, cond and target attributes
+		NamedNodeMap att = n.getAttributes();
+		Node condNode = att.getNamedItem("cond");
+		String cond = (condNode != null) ? StringUtils.removeLeadingAndTrailingSpaces(condNode.getNodeValue()) : "";
+		Node eventNode = att.getNamedItem("event");
+		String event = (eventNode != null) ? StringUtils.removeLeadingAndTrailingSpaces(eventNode.getNodeValue()) : "";
+		Node targetNode = att.getNamedItem("target");
+		ArrayList<String> targets = null;
+		if (targetNode != null)
+			targets = new ArrayList<String>(
+					Arrays.asList(StringUtils.cleanupSpaces(targetNode.getNodeValue()).split("[\\s]")));
+		// if ((targets!=null) && (targets.size()>1)) throw new
+		// Exception("multiple targets not supported.");
+		HashMap<String, String> edgeGeometry = readEdgeGeometry(n);
+		String exe = collectAllChildrenInString(n);
+		ret.put(SCXMLEdge.CONDITION, cond);
+		ret.put(SCXMLEdge.EVENT, event);
+		ret.put(SCXMLEdge.TARGETS, targets);
+		ret.put(SCXMLEdge.SOURCE, pn.getID());
+		ret.put(SCXMLEdge.EDGEEXE, exe);
+		ret.put(SCXMLEdge.EDGEGEO, edgeGeometry);
+		return ret;
+	}
+
+	private String collectAllChildrenInString(Node n) throws Exception {
+		String content = "";
+		NodeList list = n.getChildNodes();
+		int listLength = list.getLength();
+		for (int i = 0; i < listLength; i++) {
+			content += XMLUtils.domNode2String(list.item(i), true);
+		}
+		return StringUtils.removeLeadingAndTrailingSpaces(content);
+	}
+
+	public SCXMLNode readSCXMLFileContentAndAttachAsChildrenOf(SCXMLGraphEditor editor, String filename,
+			SCXMLNode parent, SCXMLConstraints restrictedConstraints) throws Exception {
+		System.out.println("Parsing file: " + filename);
+		File file = new File(filename);
+		Document doc = mxUtils.parseXMLFile(file, false, false);
+		doc.getDocumentElement().normalize();
+		SCXMLNode rootNode = getNodeHier(editor, doc.getDocumentElement(), parent, file.getParentFile(),
+				restrictedConstraints);
+		System.out.println("Done reading file");
+		return rootNode;
+	}
+
+	public SCXMLNode parseSCXMLContentAndAttachAsChildrenOf(SCXMLGraphEditor editor, String contents,
+			SCXMLNode parent, SCXMLConstraints restrictedConstraints) throws Exception {
+		Document doc = mxUtils.parseXMLString(contents, false, false);
+		doc.getDocumentElement().normalize();
+		SCXMLNode rootNode = getNodeHier(editor, doc.getDocumentElement(), parent, null,
+				restrictedConstraints);
+		return rootNode;
+	}
+	
+	public void readInGraph(SCXMLGraph graph, String filename, boolean ignoreStoredLayout,
+			SCXMLConstraints restrictedConstraints) throws Exception {
+		// clean importer data-structures
+		internalID2cell.clear();
+		internalID2clusters.clear();
+		internalID2nodes.clear();
+		fromToEdges.clear();
+		scxmlID2nodes.clear();
+		internalIDcounter = 11;
+
+		root = readSCXMLFileContentAndAttachAsChildrenOf(graph.getEditor(), filename, null, restrictedConstraints);
+		if (root != scxmlID2nodes.get(SCXMLNode.ROOTID)) {
+			SCXMLNode firstChild = root;
+			mxGeometry geometry = root.getGeometry();
+			root = new SCXMLNode();
+			root.setID(SCXMLNode.ROOTID);
+			addSCXMLNode(root);
+			setNodeAsChildOf(firstChild, root);
+			root.setSaveThisRoot(false);
+			if (geometry != null) {
+				double x = geometry.getX(), y = geometry.getY();
+				root.setGeometry(0, 0, geometry.getWidth() + (2 * x), geometry.getHeight() + (2 * y));
+			}
+		}
+
+		// empty the graph
+		mxCell gr = new mxCell();
+		gr.insert(new mxCell());
+		graph.getModel().setRoot(gr);
+		graph.setDefaultParent(null);
+		graph.clearOutsourcedIndex();
+
+		System.out.println("Populating graph.");
+		populateGraph(graph, ignoreStoredLayout);
+		System.out.println("Done populating graph.");
+		// set the SCXML (this.root) mxCell as not deletable.
+		gr = internalID2cell.get(root.getInternalID());
+		graph.setCellAsDeletable(gr, false);
+
+		graph.setDefaultParent(gr);
+	}
+
+	public void parseInGraph(SCXMLGraph graph, String contents, boolean ignoreStoredLayout,
+			SCXMLConstraints restrictedConstraints) throws Exception {
+		// clean importer data-structures
+		internalID2cell.clear();
+		internalID2clusters.clear();
+		internalID2nodes.clear();
+		fromToEdges.clear();
+		scxmlID2nodes.clear();
+		internalIDcounter = 11;
+
+		root = parseSCXMLContentAndAttachAsChildrenOf(graph.getEditor(), contents, null, restrictedConstraints);
+		if (root != scxmlID2nodes.get(SCXMLNode.ROOTID)) {
+			SCXMLNode firstChild = root;
+			mxGeometry geometry = root.getGeometry();
+			root = new SCXMLNode();
+			root.setID(SCXMLNode.ROOTID);
+			addSCXMLNode(root);
+			setNodeAsChildOf(firstChild, root);
+			root.setSaveThisRoot(false);
+			if (geometry != null) {
+				double x = geometry.getX(), y = geometry.getY();
+				root.setGeometry(0, 0, geometry.getWidth() + (2 * x), geometry.getHeight() + (2 * y));
+			}
+		}
+
+		// empty the graph
+		mxCell gr = new mxCell();
+		gr.insert(new mxCell());
+		graph.getModel().setRoot(gr);
+		graph.setDefaultParent(null);
+		graph.clearOutsourcedIndex();
+
+		System.out.println("Populating graph.");
+		populateGraph(graph, ignoreStoredLayout);
+		System.out.println("Done populating graph.");
+		// set the SCXML (this.root) mxCell as not deletable.
+		gr = internalID2cell.get(root.getInternalID());
+		graph.setCellAsDeletable(gr, false);
+
+		graph.setDefaultParent(gr);
+	}
+	
+	public void clearInternalID2NodesAndSCXMLID2Nodes() {
+		internalID2nodes.clear();
+		scxmlID2nodes.clear();
+		internalID2cell.clear();
+		internalID2clusters.clear();
+		fromToEdges.clear();
+	}
+
+	private HashSet<SCXMLNode> saveProblematicNodes = new HashSet<SCXMLNode>();
+
+	public boolean hasUnhandledXIncludeUsage() {
+		return !saveProblematicNodes.isEmpty();
+	}
+
+	public int displayWarningAboutUnhandledXIncludeUsage(SCXMLGraphEditor editor, boolean asQuestion) {
+		String message = mxResources.get("xincludeSaveProblem") + "\n";
+		for (SCXMLNode n : saveProblematicNodes)
+			message += n.getID() + "\n";
+		if (asQuestion) {
+			String[] options = { mxResources.get("continue"), mxResources.get("cancel") };
+			return JOptionPane.showOptionDialog(editor, message, "XInclude problem", JOptionPane.OK_CANCEL_OPTION,
+					JOptionPane.WARNING_MESSAGE, null, options, options[1]);
+		} else
+			JOptionPane.showMessageDialog(editor, message, "XInclude problem", JOptionPane.WARNING_MESSAGE);
+		return -1;
+	}
+
+	public void read(String from, mxGraphComponent graphComponent, SCXMLConstraints restrictedConstraints) throws Exception {
+		SCXMLGraphComponent gc = (SCXMLGraphComponent) graphComponent;
+		SCXMLGraphEditor editor = gc.getGraph().getEditor();
+		saveProblematicNodes.clear();
+		SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+		readInGraph(graph, from, true, restrictedConstraints);
+		if (hasUnhandledXIncludeUsage())
+			displayWarningAboutUnhandledXIncludeUsage(editor, false);
+		gc.validateGraph();
+	}
+
+	public void parse(String from, mxGraphComponent graphComponent, 
+			SCXMLConstraints restrictedConstraints) throws Exception {
+		SCXMLGraphComponent gc = (SCXMLGraphComponent) graphComponent;
+		SCXMLGraphEditor editor = gc.getGraph().getEditor();
+		saveProblematicNodes.clear();
+		SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+		parseInGraph(graph, from, true, restrictedConstraints);
+		if (hasUnhandledXIncludeUsage())
+			displayWarningAboutUnhandledXIncludeUsage(editor, false);
+		gc.validateGraph();
+	}
+	
+	private HashMap<String, mxCell> internalID2cell = new HashMap<String, mxCell>();
+
+	private void populateGraph(SCXMLGraph graph, boolean ignoreStoredLayout) throws Exception {
+		mxIGraphModel model = graph.getModel();
+		model.beginUpdate();
+		try {
+			// first process the clusters
+			for (String internalID : internalID2clusters.keySet()) {
+				SCXMLNode cluster = internalID2nodes.get(internalID);
+				addOrUpdateNode(graph, cluster, null);
+				// mxCell pn = (mxCell) graph.insertVertex(clusterCell,
+				// getNextInternalID(), "aaaaaaa", 0, 0, 0, 0, "rounded=1");
+				// pn.setVisible(false);
+				for (SCXMLNode n : internalID2clusters.get(internalID)) {
+					addOrUpdateNode(graph, n, cluster);
+					// String id=getNextInternalID();
+					// mxCell e=(mxCell)
+					// graph.insertEdge(internalID2cell.get(root.getInternalID()),
+					// id, "", pn,internalID2cell.get(n.getInternalID()) ,"");
+					// e.setVisible(false);
+				}
+			}
+			// then go through all nodes and make sure all have been created
+			for (String internalID : internalID2nodes.keySet()) {
+				SCXMLNode n = internalID2nodes.get(internalID);
+				mxCell cn = internalID2cell.get(internalID);
+				// mxCell cn=addOrUpdateNode(graph,n,null);
+				// System.out.println(n.getStyle());
+				// set geometry and size
+				if (cn != null) {
+					cn.setStyle(n.getStyle());
+					mxGeometry g = n.getGeometry();
+					if ((g != null) && !ignoreStoredLayout) {
+						// graph.setCellAsMovable(cn, false);
+						model.setGeometry(cn, g);
+					} else if (!internalID2clusters.containsKey(internalID)) {
+						graph.updateCellSize(internalID2cell.get(internalID));
+					}
+				}
+			}
+			// then add the edges
+			for (String fromSCXMLID : fromToEdges.keySet()) {
+				HashMap<String, HashSet<SCXMLEdge>> toEdge = fromToEdges.get(fromSCXMLID);
+				for (String toSCXMLID : toEdge.keySet()) {
+					HashSet<SCXMLEdge> es = toEdge.get(toSCXMLID);
+					for (SCXMLEdge e : es) {
+						ArrayList<mxCell> ces = addOrUpdateEdge(graph, e, toSCXMLID, ignoreStoredLayout);
+						for (mxCell ce : ces)
+							ce.setStyle(e.getStyle(ce));
+					}
+				}
+			}
+		} finally {
+			model.endUpdate();
+		}
+	}
+
+	private ArrayList<mxCell> addOrUpdateEdge(SCXMLGraph graph, SCXMLEdge edge, String toSCXMLID,
+			boolean ignoreStoredLayout) throws Exception {
+		ArrayList<mxCell> ret = new ArrayList<mxCell>();
+		SCXMLNode sourceNode = scxmlID2nodes.get(edge.getSCXMLSource());
+		if (sourceNode == null)
+			throw new Exception("Source node for edge: " + edge + " not found.");
+		mxCell source = internalID2cell.get(sourceNode.getInternalID());
+		for (String targetSCXMLID : edge.getSCXMLTargets()) {
+			if (targetSCXMLID.equals(toSCXMLID)) {
+				SCXMLNode targetNode = scxmlID2nodes.get(targetSCXMLID);
+				if (targetNode == null)
+					throw new Exception("Target '" + targetSCXMLID + "' for edge: " + edge + " not found.");
+				mxCell target = internalID2cell.get(targetNode.getInternalID());
+				System.out.println("add edge (" + source + "->" + target + ")to graph: " + edge);
+				mxCell e = (mxCell) graph.insertEdge(internalID2cell.get(root.getInternalID()), edge.getInternalID(),
+						edge, source, target);
+				if (!ignoreStoredLayout) {
+					mxGeometry geo = edge.getEdgeGeometry(toSCXMLID);
+					if (geo != null)
+						e.setGeometry(geo);
+				}
+				internalID2cell.put(edge.getInternalID(), e);
+				ret.add(e);
+			}
+		}
+		return ret;
+	}
+
+	private mxCell addOrUpdateNode(SCXMLGraph graph, SCXMLNode node, SCXMLNode parent) {
+		mxCell n = internalID2cell.get(node.getInternalID());
+		mxCell p = null;
+		if (parent != null) {
+			p = internalID2cell.get(parent.getInternalID());
+			if (p == null) {
+				p = (mxCell) graph.insertVertex(null, node.getInternalID(), node, 0, 0, 0, 0, "");
+				internalID2cell.put(parent.getInternalID(), p);
+			}
+		}
+		if (n == null) {
+			n = (mxCell) graph.insertVertex((parent == null) ? null : p, node.getInternalID(), node, 0, 0, 0, 0, "");
+			internalID2cell.put(node.getInternalID(), n);
+		} else if (parent != null) {
+			n.removeFromParent();
+			graph.addCell(n, p);
+		}
+		if (node.isOutsourcedNode())
+			graph.addToOutsourced(n);
+		return n;
+	}
+
+	public Object buildNodeValue() {
+		SCXMLNode n = new SCXMLNode();
+		String internalID = getNextInternalID();
+		n.setID("new_node" + getNextInternalID());
+		n.setInternalID(internalID);
+		return n;
+	}
+
+	public Object buildEdgeValue() {
+		SCXMLEdge e = new SCXMLEdge();
+		String internalID = getNextInternalID();
+		e.setInternalID(internalID);
+		return e;
+	}
+
+	public SCXMLNode getRoot() {
+		return root;
+	}
+
+	public void setRoot(SCXMLNode r) {
+		root = r;
+	}
+
+	public Object cloneValue(Object value) {
+		if (value instanceof SCXMLNode) {
+			return ((SCXMLNode) value).cloneNode();
+		} else if (value instanceof SCXMLEdge) {
+			return ((SCXMLEdge) value).cloneEdge();
+		} else
+			return null;
+	}
+
+	public String output(mxGraphComponent from) throws Exception {
+		SCXMLGraph graph = (SCXMLGraph) from.getGraph();
+		mxGraphView view = graph.getView();
+		mxIGraphModel model = graph.getModel();
+		mxCell root = followUniqueDescendantLineTillSCXMLValueIsFound(model);
+		String scxml = "";
+		if (root != null && 0<root.getChildCount()) {
+			scxml = mxVertex2SCXMLString(view, root, true);
+			System.out.println(scxml);
+			scxml = XMLUtils.prettyPrintXMLString(scxml, " ", true);
+			System.out.println(scxml);
+		}
+		return scxml;
+	}
+	
+	private String mxVertex2SCXMLString(mxGraphView view, mxCell n, boolean isRoot) throws Exception {
+		String ret = "";
+		String ID = null;
+		String name = null;
+		String datamodel = null;
+		String onentry = null;
+		String onexit = null;
+		String oninitialentry = null;
+		String donedata = null;
+		String transitions = null;
+		String comments = null;
+		String otherContent = null;
+		assert (n.isVertex());
+		SCXMLNode value = (SCXMLNode) n.getValue();
+		boolean isFake = value.getFake();
+
+		comments = StringUtils.removeLeadingAndTrailingSpaces(value.getComments());
+
+		ID = StringUtils.removeLeadingAndTrailingSpaces(value.getID());
+		name = StringUtils.removeLeadingAndTrailingSpaces(value.getName());
+		datamodel = StringUtils.removeLeadingAndTrailingSpaces(value.getDatamodel());
+		if (value.isFinal())
+			donedata = StringUtils.removeLeadingAndTrailingSpaces(value.getDoneData());
+		onentry = StringUtils.removeLeadingAndTrailingSpaces(value.getOnEntry());
+		onexit = StringUtils.removeLeadingAndTrailingSpaces(value.getOnExit());
+		otherContent = StringUtils.removeLeadingAndTrailingSpaces(value.getScript());
+
+		transitions = edgesOfmxVertex2SCXMLString(n, value, view);
+
+		SCXMLNode initialChild = getInitialChildOfmxCell(n);
+		if (initialChild != null)
+			oninitialentry = StringUtils.removeLeadingAndTrailingSpaces(initialChild.getOnInitialEntry());
+		String close = "";
+		if (!isRoot || value.shouldThisRootBeSaved()) {
+			if (isRoot) {
+				ret = "<scxml version=\"1.0\"";
+				close = "</scxml>";
+			} else if (value.isParallel()) {
+				ret = "<parallel";
+				close = "</parallel>";
+			} else if (value.isFinal()) {
+				ret = "<final";
+				close = "</final>";
+			} else if (value.isHistoryNode()) {
+				ret = "<history type=\"" + ((value.isDeepHistory()) ? "deep" : "shallow") + "\"";
+				close = "</history>";
+			} else {
+				ret = "<state";
+				close = "</state>";
+			}
+			if (!StringUtils.isEmptyString(comments)) {
+				if (!isRoot)
+					ret = "<!--" + comments + "-->\n" + ret;
+				else
+					System.out.println("BUG: Ignoring comment associated to SCXML root.");
+			}
+			String namespace = StringUtils.removeLeadingAndTrailingSpaces(value.getNamespace().replace("\n", " "));
+			if (!StringUtils.isEmptyString(namespace))
+				ret += " " + namespace;
+			if (value.isOutsourcedNode() && value.isOutsourcedNodeUsingSRC()) {
+				assert (!isFake);
+				String src = value.getSRC().getLocation();
+				ret += " src=\"" + src + "\"";
+			}
+			if (!isRoot && !StringUtils.isEmptyString(ID))
+				ret += " id=\"" + ID + "\"";
+			if (!StringUtils.isEmptyString(name))
+				ret += " name=\"" + name + "\"";
+			if (StringUtils.isEmptyString(oninitialentry) && (initialChild != null))
+				ret += " initial=\"" + initialChild.getID() + "\"";
+			ret += ">";
+
+			// save the geometric information of this node:
+			String nodeGeometry = getGeometryString(view, n);
+
+			if (value.isOutsourcedNode() && value.isOutsourcedNodeUsingXInclude()) {
+				assert (isFake);
+				String src = value.getSRC().getLocation();
+				ret = ((isFake) ? "" : ret) + "<xi:include href=\"" + src + "\" parse=\"xml\">";
+				if (isFake)
+					close = "";
+				if (!StringUtils.isEmptyString(nodeGeometry))
+					ret += "<!-- " + nodeGeometry + " -->";
+				ret += "</xi:include>";
+			} else if (!StringUtils.isEmptyString(nodeGeometry))
+				ret += "<!-- " + nodeGeometry + " -->";
+
+			// save restriction type
+			if (value.isRestricted()) {
+				String restrictionNames = "";
+				for (RestrictedState restrictionState : value.getRestrictedStates()) {
+					restrictionNames += restrictionState.getName() + ";";
+				}
+				ret += "<!-- restriction_type:" + restrictionNames + " -->";
+			}
+
+			if (!isFake) {
+				if (!StringUtils.isEmptyString(datamodel))
+					ret += "<datamodel><data>" + datamodel + "</data></datamodel>";
+				if ((!StringUtils.isEmptyString(oninitialentry)) && (initialChild != null))
+					if (isRoot) {
+						System.out.println("Ignoring executable content for initial child of root: " + initialChild);
+					} else {
+						ret += "<initial><transition target=\"" + initialChild.getID() + "\">" + oninitialentry
+								+ "</transition></initial>";
+					}
+				if (!StringUtils.isEmptyString(donedata))
+					ret += "<donedata>" + donedata + "</donedata>";
+				if (!StringUtils.isEmptyString(onentry))
+					ret += "<onentry>" + onentry + "</onentry>";
+				if (!StringUtils.isEmptyString(onexit))
+					ret += "<onexit>" + onexit + "</onexit>";
+				if (!StringUtils.isEmptyString(transitions))
+					ret += transitions;
+			}
+		}
+		// additional content that is not a comment
+		if (!StringUtils.isEmptyString(otherContent)) {
+			ret += otherContent;
+		}
+		// add the children only if the node is not outsourced
+		if (!value.isOutsourcedNode()) {
+			int nc = n.getChildCount();
+			for (int i = 0; i < nc; i++) {
+				mxCell c = (mxCell) n.getChildAt(i);
+				if (c.isVertex())
+					ret += mxVertex2SCXMLString(view, c, false);
+			}
+		}
+		ret += close;
+		return ret;
+	}
+
+	private String getGeometryString(mxGraphView view, mxCell n) {
+		DecimalFormat numberFormatter = new DecimalFormat("#.##");
+		double scale = view.getScale();
+		mxCellState ns = view.getState(n);
+		if (n.isVertex()) {
+			mxICell p = n.getParent();
+			double xp = 0;
+			double yp = 0;
+			if (p != null) {
+				mxCellState ps = view.getState(p);
+				if (ps != null) {
+					xp = ps.getX();
+					yp = ps.getY();
+				}
+			}
+			double x = ((ns.getX() - xp) / scale);
+			double y = ((ns.getY() - yp) / scale);
+			double w = (ns.getWidth() / scale);
+			double h = (ns.getHeight() / scale);
+			if (ns != null)
+				return " node-size-and-position x=" + numberFormatter.format(x) + " y=" + numberFormatter.format(y)
+						+ " w=" + numberFormatter.format(w) + " h=" + numberFormatter.format(h);
+			else
+				return null;
+		} else if (n.isEdge()) {
+			String target = getIDOfThisEdgeTarget(n);
+			mxGeometry geo = n.getGeometry();
+			mxPoint offset = geo.getOffset();
+			List<mxPoint> points = geo.getPoints();
+			String ret = null;
+			if ((points != null) || (offset != null)) {
+				ret = " edge-path [" + ((StringUtils.isEmptyString(target)) ? "" : target) + "] ";
+				if (points != null) {
+					for (mxPoint p : points) {
+						ret += " x=" + numberFormatter.format(p.getX()) + " y=" + numberFormatter.format(p.getY());
+					}
+				}
+				if (offset != null) {
+					mxPoint pt = view.getPoint(ns, geo);
+					ret += " pointx=" + numberFormatter.format(geo.getX()) + " pointy="
+							+ numberFormatter.format(geo.getY()) + " offsetx=" + numberFormatter.format(offset.getX())
+							+ " offsety=" + numberFormatter.format(offset.getY());
+				}
+			}
+			return ret;
+		} else
+			return null;
+	}
+
+	private String getIDOfThisEdgeTarget(mxCell n) {
+		String targetID = ((SCXMLNode) n.getTarget().getValue()).getID();
+		assert (!StringUtils.isEmptyString(targetID));
+		return targetID;
+	}
+
+	private static final String numberPattern = "[\\deE\\+\\-\\.]+";
+	public static final String xyPatternString = "[\\s]*x=(" + numberPattern + ")[\\s]*y=(" + numberPattern + ")[\\s]*";
+	public static final String offsetPatternString = "[\\s]*pointx=(" + numberPattern + ")[\\s]*pointy=("
+			+ numberPattern + ")[\\s]*offsetx=(" + numberPattern + ")[\\s]*offsety=(" + numberPattern + ")[\\s]*";
+	public static final Pattern xyPattern = Pattern.compile(xyPatternString);
+	public static final Pattern offsetPattern = Pattern.compile(offsetPatternString);
+	private static final Pattern nodesizePattern = Pattern.compile("[\\s]*node-size-and-position[\\s]*"
+			+ xyPatternString + "[\\s]*w=(" + numberPattern + ")[\\s]*h=(" + numberPattern + ")[\\s]*");
+	public static final Pattern edgepathPattern = Pattern.compile(
+			"[\\s]*edge-path[\\s]*\\[(.*)\\]((" + xyPatternString + ")*[\\s]*(" + offsetPatternString + ")*)[\\s]*");
+
+	private boolean readNodeGeometry(SCXMLNode pn, String positionString) {
+		Matcher m = nodesizePattern.matcher(positionString);
+		if (m.matches() && (m.groupCount() == 4)) {
+			try {
+				double x = Double.parseDouble(m.group(1));
+				double y = Double.parseDouble(m.group(2));
+				double w = Double.parseDouble(m.group(3));
+				double h = Double.parseDouble(m.group(4));
+				((SCXMLNode) pn).setGeometry(x, y, w, h);
+				return true;
+			} catch (Exception e) {
+			}
+		}
+		return false;
+	}
+
+	private HashMap<String, String> readEdgeGeometry(Node root) {
+		// this will search for all geometries available (one geometry for each
+		// edge target)
+		HashMap<String, String> ret = new HashMap<String, String>();
+		NodeList states = root.getChildNodes();
+		for (int s = 0; s < states.getLength(); s++) {
+			Node n = states.item(s);
+			switch (n.getNodeType()) {
+			case Node.COMMENT_NODE:
+				String comment = n.getNodeValue();
+				Matcher m = edgepathPattern.matcher(comment);
+				if (m.matches()) {
+					ret.put(m.group(1), m.group(2));
+					root.removeChild(n); // remove the used comment node
+				}
+				break;
+			}
+		}
+		return (ret.isEmpty()) ? null : ret;
+	}
+
+	private SCXMLNode getInitialChildOfmxCell(mxCell n) {
+		int nc = n.getChildCount();
+		for (int i = 0; i < nc; i++) {
+			mxCell c = (mxCell) n.getChildAt(i);
+			if (c.isVertex()) {
+				SCXMLNode value = (SCXMLNode) c.getValue();
+				assert (value != null);
+				if (value.isInitial())
+					return value;
+			}
+		}
+		return null;
+	}
+
+	private String edgesOfmxVertex2SCXMLString(mxCell n, SCXMLNode value, mxGraphView view) throws Exception {
+		HashMap<Integer, ArrayList<mxCell>> edges = buildListSortedEdges(n);
+		int maxOutgoingEdge = -1;
+		for (Integer order : edges.keySet())
+			if (order > maxOutgoingEdge)
+				maxOutgoingEdge = order;
+		if (!edges.isEmpty() && (maxOutgoingEdge >= 0)) {
+			String[] sortedEdges = new String[maxOutgoingEdge + 1];
+			for (int order = 0; order <= maxOutgoingEdge; order++) {
+				ArrayList<mxCell> edges4order = edges.get(order);
+				if ((edges4order != null) && !edges4order.isEmpty()) {
+					mxCell e = edges4order.get(0);
+					mxCell source = (mxCell) e.getSource();
+					mxCell target = (mxCell) e.getTarget();
+					SCXMLNode targetValue = (SCXMLNode) target.getValue();
+					SCXMLEdge edgeValue = (SCXMLEdge) e.getValue();
+					String ret = "";
+					String cond = XMLUtils
+							.escapeStringForXML(StringUtils.removeLeadingAndTrailingSpaces(edgeValue.getCondition()));
+					String event = XMLUtils
+							.escapeStringForXML(StringUtils.removeLeadingAndTrailingSpaces(edgeValue.getEvent()));
+					String exe = StringUtils.removeLeadingAndTrailingSpaces(edgeValue.getExe());
+					String comments = StringUtils.removeLeadingAndTrailingSpaces(edgeValue.getComments());
+					ret = "<transition";
+					if (!StringUtils.isEmptyString(comments)) {
+						ret = "<!--" + comments + "-->\n" + ret;
+					}
+					if (!StringUtils.isEmptyString(event))
+						ret += " event=\"" + event + "\"";
+					if (!StringUtils.isEmptyString(cond))
+						ret += " cond=\"" + cond + "\"";
+					if ((!edgeValue.isCycle()) || edgeValue.isCycleWithTarget()) {
+						ret += " target=\"";
+						boolean first = true;
+						for (mxCell edge : edges4order) {
+							if (first)
+								first = false;
+							else
+								ret += " ";
+							ret += ((SCXMLNode) edge.getTarget().getValue()).getID();
+						}
+						ret += "\"";
+					}
+					ret += ">";
+					if (!StringUtils.isEmptyString(exe))
+						ret += exe;
+					for (mxCell edge : edges4order) {
+						String edgeGeometry = getGeometryString(view, edge);
+						if (!StringUtils.isEmptyString(edgeGeometry))
+							ret += "<!-- " + edgeGeometry + " -->";
+					}
+					ret += "</transition>";
+					if (maxOutgoingEdge < order)
+						maxOutgoingEdge = order;
+					sortedEdges[order] = ret;
+				}
+			}
+			String ret = "";
+			for (int i = 0; i <= maxOutgoingEdge; i++) {
+				ret += sortedEdges[i];
+			}
+			return ret;
+		} else
+			return null;
+	}
+
+	private HashMap<Integer, ArrayList<mxCell>> buildListSortedEdges(mxCell n) throws Exception {
+		HashMap<Integer, ArrayList<mxCell>> ret = new HashMap<Integer, ArrayList<mxCell>>();
+		int ec = n.getEdgeCount();
+		for (int i = 0; i < ec; i++) {
+			mxCell e = (mxCell) n.getEdgeAt(i);
+			mxCell source = (mxCell) e.getSource();
+			mxCell target = (mxCell) e.getTarget();
+			if (source == n) {
+				SCXMLEdge edgeValue = (SCXMLEdge) e.getValue();
+				int order = edgeValue.getOrder();
+				ArrayList<mxCell> edges4order = ret.get(order);
+				if (edges4order == null)
+					ret.put(order, edges4order = new ArrayList<mxCell>());
+				edges4order.add(e);
+			}
+		}
+		for (ArrayList<mxCell> edges : ret.values()) {
+			if (edges.size() > 1) {
+				SCXMLEdge first = (SCXMLEdge) edges.get(0).getValue();
+				for (mxCell edge : edges) {
+					if (edge.getValue() != first)
+						throw new Exception("Error in multitarget edges.");
+				}
+			}
+		}
+		return ret;
+	}
+
+	private String mxEdge2SCXMLString(mxCell e) {
+		assert (e.isEdge());
+		return null;
+	}
+
+	public static mxCell followUniqueDescendantLineTillSCXMLValueIsFound(mxIGraphModel model) {
+		mxCell n = (mxCell) model.getRoot();
+		while (true) {
+			Object v = n.getValue();
+			if (v instanceof SCXMLNode) {
+				return n;
+			} else {
+				if (n.getChildCount() == 1) {
+					n = (mxCell) n.getChildAt(0);
+				} else {
+					return null;
+				}
+			}
+		}
+	}
+
+	public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
+		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+		docBuilderFactory.setXIncludeAware(true);
+		docBuilderFactory.setNamespaceAware(true);
+		docBuilderFactory.setValidating(true);
+		docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+				"http://www.w3.org/2001/XMLSchema");
+		docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
+				"http://www.w3.org/2011/04/SCXML/scxml.xsd");
+		DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+		File inp = new File("C:\\Users\\morbini\\Desktop\\scxml-experiments\\ex2.scxml");
+		docBuilder.parse(inp);
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLNode.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLNode.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/fileimportexport/SCXMLNode.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,942 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+
+import com.mxgraph.model.mxGeometry;
+import com.mxgraph.util.StringUtils;
+import com.mxgraph.util.mxConstants;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState;
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState.PossibleEvent;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.OutSource.OUTSOURCETYPE;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.MyUndoManager;
+
+public class SCXMLNode implements Serializable {
+	private static final long serialVersionUID = -2136349535452806563L;
+
+	public static final String GEOX = "geometryX";
+	public static final String GEOY = "geometryY";
+	public static final String GEOW = "geometryW";
+	public static final String GEOH = "geometryH";
+
+	public static final String INTERNALID = "internalID";
+	public static final String ID = "id";
+	public static final String NAME = "name";
+	public static final String TYPE = "type";
+	public static final String RESTRICTEDSTATE = "restrictedState";
+	public static final String INITIAL = "initial";
+	public static final String CLUSTER = "cluster";
+	public static final String FINAL = "final";
+	public static final String ONENTRYEXE = "onentryexe";
+	public static final String INITEXE = "initexe";
+	public static final String ONEXITEXE = "onexitexe";
+	public static final String SCRIPT = "script";
+
+	public static final String HISTORY = "history";
+	public static final String PARALLEL = "parallel";
+	public static final String NORMAL = "normal";
+	public static final String RESTICTED = "restricted";
+	public static final String STYLE = "style";
+	public static final String DATAMODEL = "datamodel";
+	public static final String DONEDATA = "donedata";
+
+	public enum HISTORYTYPE {
+		DEEP, SHALLOW
+	};
+
+	public static final String DEFAULTFILLCOLOR = "#cdd5ff";
+	public static final String DEFAULTSTROKECOLOR = "#000000";
+	public static final String DEFAULTSHAPE = "rounded=1";
+	public static final String PARALLELFILLCOLOR = "#c2d200";
+	public static final String PARALLELSTROKECOLOR = "#c2d200";
+	public static final String INITIALFILLCOLOR = "#ffab75";
+	public static final String FINALSTROKECOLOR = "#FF0000";
+	public static final String DEEPHISTORYFILLCOLOR = "#bb00a6";
+	public static final String SHALLOWHISTORYFILLCOLOR = "#dd6fd1";
+
+	public static final String INITIALSHAPE = "ellipse";
+	public static final String CLUSTERSHAPE = "swimlane";
+
+	public static final String COMMENTS = "comments";
+	public static final String COMMENTSUNDO = "COundo";
+	public static final String COMMENTSDOC = "COdoc";
+
+	public static final String DATAMODELUNDO = "DMundo";
+	public static final String DATAMODELDOC = "DMdoc";
+
+	public static final String SCXMLIDUNDO = "SCXMLIDundo";
+	public static final String SCXMLIDDOC = "SCXMLIDdoc";
+	public static final String NAMEUNDO = "NAMEundo";
+	public static final String NAMEDOC = "NAMEdoc";
+	public static final String ONENTRYUNDO = "ENTRYundo";
+	public static final String ONENTRYDOC = "ENTRYdoc";
+	public static final String ONEXITUNDO = "EXITundo";
+	public static final String ONEXITDOC = "EXITdoc";
+	public static final String SCRIPTUNDO = "SCRIPTundo";
+	public static final String SCRIPTDOC = "SCRIPTdoc";
+	// only initial states
+	public static final String ONINITIALENTRYUNDO = "INITIALundo";
+	public static final String ONINITIALENTRYDOC = "INITIALdoc";
+	// only final states
+	public static final String FINALDONEDATAUNDO = "FINALundo";
+	public static final String FINALDONEDATADOC = "FINALdoc";
+
+	// all non root states
+	public static final String SRC = "src";
+	public static final String SRCUNDO = "SRCundo";
+	public static final String SRCDOC = "SRCdoc";
+
+	// only root state
+	public static final String NAMESPACE = "namespace";
+	public static final String NAMESPACEUNDO = "namespaceundo";
+	public static final String NAMESPACEDOC = "namespacedoc";
+
+	public static final String ROOTID = "SCXML";
+
+	private HashMap<String, Object> node;
+	private HashSet<OutSource> outSourcingChildren;
+	private boolean saveRoot = true;
+	private boolean isFake = false;
+
+	public SCXMLNode() {
+		node = new HashMap<String, Object>();
+		node.put(TYPE, NORMAL);
+		setShape(DEFAULTSHAPE);
+		setStrokeColor(DEFAULTSTROKECOLOR);
+		setInitial(false);
+		setCluster(false);
+		setFinal(false);
+		setParallel(false);
+		outSourcingChildren = new HashSet<OutSource>();
+		setFillColorFromState();
+	}
+
+	public boolean getFake() {
+		return isFake;
+	}
+
+	public void setFake(boolean f) {
+		isFake = f;
+	}
+
+	public boolean shouldThisRootBeSaved() {
+		return !isRoot() || saveRoot;
+	}
+
+	public void setSaveThisRoot(boolean save) {
+		if (isRoot())
+			saveRoot = save;
+		else
+			saveRoot = true;
+	}
+
+	public boolean isRoot() {
+		return getID().equals(ROOTID);
+	}
+
+	public String getInternalID() {
+		return (String) node.get(INTERNALID);
+	}
+
+	public void setInternalID(String internalID) {
+		node.put(INTERNALID, internalID);
+	}
+
+	public void addToOutsourcingChildren(OutSource source) {
+		outSourcingChildren.add(source);
+	}
+
+	public HashSet<OutSource> getOutsourcingChildren() {
+		return outSourcingChildren;
+	}
+
+	public OutSource getSRC() {
+		OutSource ret = null;
+		ret = (OutSource) node.get(SRC);
+		if (ret == null)
+			node.put(SRC, ret = new OutSource(OUTSOURCETYPE.SRC, ""));
+		Document dmd = getSRCDoc();
+		if (dmd != null) {
+			try {
+				String location = dmd.getText(0, dmd.getLength());
+				ret.setLocation(location);
+			} catch (BadLocationException e) {
+			}
+		}
+		return ret;
+	}
+
+	public void setSRC(String src, OUTSOURCETYPE type) {
+		node.put(SRC, new OutSource(type, src));
+	}
+
+	public void setSRC(OutSource src) {
+		node.put(SRC, src);
+	}
+
+	public String getOutsourcedLocation() {
+		return (isOutsourcedNode()) ? StringUtils.removeLeadingAndTrailingSpaces(getSRC().getLocation()) : "";
+	}
+
+	public void setOutsourcedLocation(String location) {
+		if (isOutsourcedNode())
+			getSRC().setLocation(location);
+		else
+			setSRC(location, OUTSOURCETYPE.SRC);
+	}
+
+	public boolean isOutsourcedNode() {
+		OutSource src = getSRC();
+		return (src != null) && (!StringUtils.isEmptyString(src.getLocation()));
+	}
+
+	public boolean isOutsourcedNodeUsingSRC() {
+		OutSource src = getSRC();
+		return (src != null) && src.getType() == OUTSOURCETYPE.SRC;
+	}
+
+	public boolean isOutsourcedNodeUsingXInclude() {
+		OutSource src = getSRC();
+		return (src != null) && src.getType() == OUTSOURCETYPE.XINC;
+	}
+
+	// getter and setter for document and undomanager for the SRC field of a
+	// node
+	public MyUndoManager getSRCUndoManager() {
+		return (MyUndoManager) node.get(SRCUNDO);
+	}
+
+	public MyUndoManager setSRCUndoManager(MyUndoManager um) {
+		node.put(SRCUNDO, um);
+		return um;
+	}
+
+	public Document getSRCDoc() {
+		return (Document) node.get(SRCDOC);
+	}
+
+	public Document setSRCDoc(Document doc) {
+		node.put(SRCDOC, doc);
+		return doc;
+	}
+
+	public String getNamespace() {
+		String ret = null;
+		Document dmd = getNamespaceDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(NAMESPACE);
+			}
+		} else
+			ret = (String) node.get(NAMESPACE);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setNamespace(String namespace) {
+		node.put(NAMESPACE, namespace);
+	}
+
+	// getter and setter for document and undomanager for the NAMESPACE field of
+	// a node
+	public MyUndoManager getNamespaceUndoManager() {
+		return (MyUndoManager) node.get(NAMESPACEUNDO);
+	}
+
+	public MyUndoManager setNamespaceUndoManager(MyUndoManager um) {
+		node.put(NAMESPACEUNDO, um);
+		return um;
+	}
+
+	public Document getNamespaceDoc() {
+		return (Document) node.get(NAMESPACEDOC);
+	}
+
+	public Document setNamespaceDoc(Document doc) {
+		node.put(NAMESPACEDOC, doc);
+		return doc;
+	}
+
+	public String getID() {
+		String ret = null;
+		Document dmd = getIDDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(ID);
+			}
+		} else
+			ret = (String) node.get(ID);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setID(String scxmlID) {
+		node.put(ID, scxmlID);
+	}
+
+	public String getName() {
+		String ret = null;
+		Document dmd = getNameDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(NAME);
+			}
+		} else
+			ret = (String) node.get(NAME);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setName(String name) {
+		node.put(NAME, name);
+	}
+
+	public String getOnEntry() {
+		String ret = null;
+		Document dmd = getOnEntryDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(ONENTRYEXE);
+			}
+		} else
+			ret = (String) node.get(ONENTRYEXE);
+		return (ret == null) ? "" : ret;
+	}
+
+	public String getOnExit() {
+		String ret = null;
+		Document dmd = getOnExitDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(ONEXITEXE);
+			}
+		} else
+			ret = (String) node.get(ONEXITEXE);
+		return (ret == null) ? "" : ret;
+	}
+
+	public String getOnInitialEntry() {
+		String ret = null;
+		Document dmd = getOnInitialEntryDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(INITEXE);
+			}
+		} else
+			ret = (String) node.get(INITEXE);
+		return (ret == null) ? "" : ret;
+	}
+
+	public String getScript() {
+		String ret = null;
+		Document dmd = getScriptDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(SCRIPT);
+			}
+		} else
+			ret = (String) node.get(SCRIPT);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setOnEntry(String exe) {
+		node.put(ONENTRYEXE, exe);
+	}
+
+	public void setOnExit(String exe) {
+		node.put(ONEXITEXE, exe);
+	}
+
+	public void setOnInitialEntry(String exe) {
+		node.put(INITEXE, exe);
+	}
+
+	public void setScript(String script) {
+		node.put(SCRIPT, script);
+	}
+
+	public void appendToScript(String script) {
+		String existingContent = getScript();
+		node.put(SCRIPT, (StringUtils.isEmptyString(existingContent)) ? script : existingContent + script);
+	}
+
+	public void setDoneData(String dd) {
+		node.put(DONEDATA, dd);
+	}
+
+	public String getDoneData() {
+		String ret = null;
+		Document dmd = getDoneDataDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(DONEDATA);
+			}
+		} else
+			ret = (String) node.get(DONEDATA);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setDatamodel(String dm) {
+		node.put(DATAMODEL, dm);
+	}
+
+	public void addToDataModel(String dm) {
+		String pdm = getDatamodel();
+		node.put(DATAMODEL, (pdm == null) ? dm : pdm + dm);
+	}
+
+	public String getDatamodel() {
+		String ret = null;
+		Document dmd = getDatamodelDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(DATAMODEL);
+			}
+		} else
+			ret = (String) node.get(DATAMODEL);
+		return (ret == null) ? "" : ret;
+	}
+
+	public MyUndoManager getCommentsUndoManager() {
+		return (MyUndoManager) node.get(COMMENTSUNDO);
+	}
+
+	public MyUndoManager setCommentsUndoManager(MyUndoManager um) {
+		node.put(COMMENTSUNDO, um);
+		return um;
+	}
+
+	public Document getCommentsDoc() {
+		return (Document) node.get(COMMENTSDOC);
+	}
+
+	public Document setCommentsDoc(Document doc) {
+		node.put(COMMENTSDOC, doc);
+		return doc;
+	}
+
+	public void setComments(String cm) {
+		node.put(COMMENTS, cm);
+	}
+
+	public String getComments() {
+		String ret = null;
+		Document dmd = getCommentsDoc();
+		if (dmd != null) {
+			try {
+				ret = dmd.getText(0, dmd.getLength());
+			} catch (BadLocationException e) {
+				ret = (String) node.get(COMMENTS);
+			}
+		} else
+			ret = (String) node.get(COMMENTS);
+		return (ret == null) ? "" : ret;
+	}
+
+	public void setParallel(boolean b) {
+		setStrokeColor((isFinal()) ? FINALSTROKECOLOR : ((b) ? PARALLELSTROKECOLOR : DEFAULTSTROKECOLOR));
+		node.put(TYPE, (b) ? PARALLEL : NORMAL);
+		if (b)
+			setCluster(true); // a parallel node must be a cluster
+		setFillColorFromState();
+	}
+
+	public boolean isParallel() {
+		if (node.get(TYPE).equals(PARALLEL))
+			return true;
+		else
+			return false;
+	}
+
+	private void setShapeFromState() {
+		Boolean cluster = isClusterNode();
+		if (cluster != null && cluster)
+			setShape(CLUSTERSHAPE);
+		else if (isInitial())
+			setShape(INITIALSHAPE);
+		else
+			setShape(DEFAULTSHAPE);
+	}
+
+	public void setInitial(Boolean b) {
+		node.put(INITIAL, b);
+		setShapeFromState();
+		setFillColorFromState();
+	}
+
+	public Boolean isInitial() {
+		return (Boolean) node.get(INITIAL);
+	}
+
+	public void setRestricted(Boolean b, RestrictedState restrictedState) {
+		if (isRestricted()) {
+			List<RestrictedState> nodeRestrictions = getRestrictedStates();
+			if ((isRestricted(restrictedState)) && (!b)) {
+				nodeRestrictions.remove(restrictedState);
+				if (nodeRestrictions.isEmpty()) {
+					setStrokeColor(DEFAULTSTROKECOLOR);
+					setStrokeWidth(null);
+					node.put(TYPE, NORMAL);
+					node.remove(RESTRICTEDSTATE);
+				}
+			} else if ((b) && (!isRestricted(restrictedState))) {
+				nodeRestrictions.add(restrictedState);
+			}
+		} else if (b) {
+			setStrokeColor(restrictedState.getColor());
+			setStrokeWidth("4");
+			node.put(TYPE, RESTICTED);
+			List<RestrictedState> nodeRestrictions = new LinkedList<RestrictedState>();
+			nodeRestrictions.add(restrictedState);
+			node.put(RESTRICTEDSTATE, nodeRestrictions);
+		}
+	}
+
+	public Boolean isRestricted() {
+		if (node.get(TYPE).equals(RESTICTED)) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	public Boolean isRestricted(RestrictedState restrictedState) {
+		if (isRestricted()) {
+			List<RestrictedState> restrictedStates = getRestrictedStates();
+			for (RestrictedState tempState : restrictedStates) {
+				if (restrictedState.getName().equals(tempState.getName())) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	public List<RestrictedState> getRestrictedStates() {
+		if (isRestricted()) {
+			return (List<RestrictedState>) node.get(RESTRICTEDSTATE);
+		} else {
+			return null;
+		}
+	}
+
+	public List<PossibleEvent> getPossibleEvents() {
+		List<PossibleEvent> possibleEvents = null;
+		if (isRestricted()) {
+			possibleEvents = new LinkedList<PossibleEvent>();
+			for (RestrictedState tempState : getRestrictedStates()) {
+				possibleEvents.addAll(tempState.getPossibleEvent());
+			}
+		}
+		return possibleEvents;
+	}
+
+	public void setAsHistory(final HISTORYTYPE type) {
+		node.put(HISTORY, type);
+		setFillColorFromState();
+	}
+
+	public Boolean isHistoryNode() {
+		return (node.get(HISTORY) instanceof HISTORYTYPE);
+	}
+
+	public HISTORYTYPE getHistoryType() {
+		return (HISTORYTYPE) node.get(HISTORY);
+	}
+
+	public Boolean isDeepHistory() {
+		return ((node.get(HISTORY) != null) && (node.get(HISTORY).equals(HISTORYTYPE.DEEP)));
+	}
+
+	public Boolean isShallowHistory() {
+		return ((node.get(HISTORY) != null) && (node.get(HISTORY).equals(HISTORYTYPE.SHALLOW)));
+	}
+
+	public void setCluster(Boolean b) {
+		node.put(CLUSTER, b);
+		setShapeFromState();
+	}
+
+	public Boolean isClusterNode() {
+		return (Boolean) node.get(CLUSTER);
+	}
+
+	public void setFinal(Boolean b) {
+		setStrokeColor((b) ? FINALSTROKECOLOR : ((isParallel()) ? PARALLELSTROKECOLOR : DEFAULTSTROKECOLOR));
+		node.put(FINAL, b);
+	}
+
+	public Boolean isFinal() {
+		return (Boolean) node.get(FINAL);
+	}
+
+	@Override
+	public String toString() {
+		String ret = "<" + getID();
+		// for (String i:node.keySet()) ret+=i+": "+node.get(i)+"; ";
+		return ret + ">";
+	}
+
+	public void setShape(String shape) {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		if (sh == null) {
+			node.put(STYLE, sh = new HashMap<String, String>());
+		}
+		sh.put("root", shape);
+	}
+
+	public String getShape() {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		return (sh == null) ? null : sh.get("root");
+	}
+
+	private void setFillColorFromState() {
+		String fillColor = DEFAULTFILLCOLOR;
+		String gradientColor;
+		boolean isHistory = isHistoryNode();
+		boolean isInitial = isInitial();
+		boolean isParallel = isParallel();
+		assert (!(isHistory && isParallel));
+
+		if (isHistory) {
+			HISTORYTYPE historyType = getHistoryType();
+			if (historyType.equals(HISTORYTYPE.DEEP))
+				fillColor = DEEPHISTORYFILLCOLOR;
+			else if (historyType.equals(HISTORYTYPE.SHALLOW))
+				fillColor = SHALLOWHISTORYFILLCOLOR;
+		}
+
+		if (isParallel)
+			fillColor = PARALLELFILLCOLOR;
+
+		gradientColor = null;
+		if (isInitial)
+			gradientColor = INITIALFILLCOLOR;
+
+		setFillColor(fillColor);
+		setGradientColor(gradientColor);
+	}
+
+	public void setFillColor(String color) {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		if (sh == null) {
+			node.put(STYLE, sh = new HashMap<String, String>());
+		}
+		if (color == null)
+			sh.remove(mxConstants.STYLE_FILLCOLOR);
+		else
+			sh.put(mxConstants.STYLE_FILLCOLOR, color);
+	}
+
+	public void setGradientColor(String color) {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		if (sh == null) {
+			node.put(STYLE, sh = new HashMap<String, String>());
+		}
+		if (color == null)
+			sh.remove(mxConstants.STYLE_GRADIENTCOLOR);
+		else
+			sh.put(mxConstants.STYLE_GRADIENTCOLOR, color);
+	}
+
+	public String getFillColor() {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		return (sh == null) ? null : sh.get(mxConstants.STYLE_FILLCOLOR);
+	}
+
+	public void setStrokeColor(String color) {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		if (sh == null) {
+			node.put(STYLE, sh = new HashMap<String, String>());
+		}
+		if (color == null)
+			sh.remove(mxConstants.STYLE_STROKECOLOR);
+		else
+			sh.put(mxConstants.STYLE_STROKECOLOR, color);
+	}
+
+	public String getStrokeColor() {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		return (sh == null) ? null : sh.get(mxConstants.STYLE_STROKECOLOR);
+	}
+
+	public void setStrokeWidth(String w) {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		if (sh == null) {
+			node.put(STYLE, sh = new HashMap<String, String>());
+		}
+		if (w == null)
+			sh.remove(mxConstants.STYLE_STROKEWIDTH);
+		else
+			sh.put(mxConstants.STYLE_STROKEWIDTH, w);
+	}
+
+	public String getStrokeWidth() {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		return (sh == null) ? null : sh.get(mxConstants.STYLE_STROKEWIDTH);
+	}
+
+	public String getStyle() {
+		HashMap<String, String> sh = (HashMap<String, String>) node.get(STYLE);
+		String ret = sh.get("root") + ";";
+		boolean outSourced = isOutsourcedNode();
+		for (String k : sh.keySet()) {
+			if (!k.equals("root")) {
+				if (!outSourced || (!k.equals(mxConstants.STYLE_STROKEWIDTH) && !k.equals(mxConstants.STYLE_DASHED)))
+					ret += k + "=" + sh.get(k) + ";";
+			}
+		}
+		if (outSourced)
+			ret += "strokeWidth=3;dashed=1;";
+		return ret;
+	}
+
+	// getter and setter for document and undomanager for the datamodel editor
+	public MyUndoManager getDatamodelUndoManager() {
+		return (MyUndoManager) node.get(DATAMODELUNDO);
+	}
+
+	public MyUndoManager setDatamodelUndoManager(MyUndoManager um) {
+		node.put(DATAMODELUNDO, um);
+		return um;
+	}
+
+	public Document getDatamodelDoc() {
+		return (Document) node.get(DATAMODELDOC);
+	}
+
+	public Document setDatamodelDoc(Document doc) {
+		node.put(DATAMODELDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for the onentry editor
+	public MyUndoManager getOnEntryUndoManager() {
+		return (MyUndoManager) node.get(ONENTRYUNDO);
+	}
+
+	public MyUndoManager setOnEntryUndoManager(MyUndoManager um) {
+		node.put(ONENTRYUNDO, um);
+		return um;
+	}
+
+	public Document getOnEntryDoc() {
+		return (Document) node.get(ONENTRYDOC);
+	}
+
+	public Document setOnEntryDoc(Document doc) {
+		node.put(ONENTRYDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for the onexit editor
+	public MyUndoManager getOnExitUndoManager() {
+		return (MyUndoManager) node.get(ONEXITUNDO);
+	}
+
+	public MyUndoManager setOnExitUndoManager(MyUndoManager um) {
+		node.put(ONEXITUNDO, um);
+		return um;
+	}
+
+	public Document getOnExitDoc() {
+		return (Document) node.get(ONEXITDOC);
+	}
+
+	public Document setOnExitDoc(Document doc) {
+		node.put(ONEXITDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for the executable content
+	// for the the editor for the initial entry in an initial node
+	public MyUndoManager getOnInitialEntryUndoManager() {
+		return (MyUndoManager) node.get(ONINITIALENTRYUNDO);
+	}
+
+	public MyUndoManager setOnInitialEntryUndoManager(MyUndoManager um) {
+		node.put(ONINITIALENTRYUNDO, um);
+		return um;
+	}
+
+	public Document getOnInitialEntryDoc() {
+		return (Document) node.get(ONINITIALENTRYDOC);
+	}
+
+	public Document setOnInitialEntryDoc(Document doc) {
+		node.put(ONINITIALENTRYDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for extra unknown content
+	// (including script)
+	public MyUndoManager getScriptUndoManager() {
+		return (MyUndoManager) node.get(SCRIPTUNDO);
+	}
+
+	public MyUndoManager setScriptUndoManager(MyUndoManager um) {
+		node.put(SCRIPTUNDO, um);
+		return um;
+	}
+
+	public Document getScriptDoc() {
+		return (Document) node.get(SCRIPTDOC);
+	}
+
+	public Document setScriptDoc(Document doc) {
+		node.put(SCRIPTDOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for the donedata field of
+	// a final node
+	public MyUndoManager getDoneDataUndoManager() {
+		return (MyUndoManager) node.get(FINALDONEDATAUNDO);
+	}
+
+	public MyUndoManager setDoneDataUndoManager(MyUndoManager um) {
+		node.put(FINALDONEDATAUNDO, um);
+		return um;
+	}
+
+	public Document getDoneDataDoc() {
+		return (Document) node.get(FINALDONEDATADOC);
+	}
+
+	public Document setDoneDataDoc(Document doc) {
+		node.put(FINALDONEDATADOC, doc);
+		return doc;
+	}
+
+	// getter and setter for document and undomanager for the SCXML ID field of
+	// a node
+	public MyUndoManager getIDUndoManager() {
+		return (MyUndoManager) node.get(SCXMLIDUNDO);
+	}
+
+	public MyUndoManager setIDUndoManager(MyUndoManager um) {
+		node.put(SCXMLIDUNDO, um);
+		return um;
+	}
+
+	public Document getIDDoc() {
+		return (Document) node.get(SCXMLIDDOC);
+	}
+
+	public Document setIDDoc(Document doc) {
+		node.put(SCXMLIDDOC, doc);
+		return doc;
+	}
+
+	public MyUndoManager getNameUndoManager() {
+		return (MyUndoManager) node.get(NAMEUNDO);
+	}
+
+	public MyUndoManager setNameUndoManager(MyUndoManager um) {
+		node.put(NAMEUNDO, um);
+		return um;
+	}
+
+	public Document getNameDoc() {
+		return (Document) node.get(NAMEDOC);
+	}
+
+	public Document setNameDoc(Document doc) {
+		node.put(NAMEDOC, doc);
+		return doc;
+	}
+
+	public SCXMLNode cloneNode() {
+		SCXMLNode n = new SCXMLNode();
+		n.node = (HashMap<String, Object>) node.clone();
+		// removes the documents in the original value (if there). But get their
+		// values (because if there they have the
+		// real value of the property they represent (the document)
+		n.setDatamodelDoc(null);
+		n.setDatamodelUndoManager(null);
+		n.setDatamodel(getDatamodel());
+		n.setCommentsDoc(null);
+		n.setCommentsUndoManager(null);
+		n.setComments(getComments());
+		n.setDoneDataDoc(null);
+		n.setDoneDataUndoManager(null);
+		n.setDoneData(getDoneData());
+		n.setOnInitialEntryDoc(null);
+		n.setOnInitialEntryUndoManager(null);
+		n.setOnInitialEntry(getOnInitialEntry());
+		n.setOnEntryDoc(null);
+		n.setOnEntryUndoManager(null);
+		n.setOnEntry(getOnEntry());
+		n.setOnExitDoc(null);
+		n.setOnExitUndoManager(null);
+		n.setOnExit(getOnExit());
+		n.setScriptDoc(null);
+		n.setScriptUndoManager(null);
+		n.setScript(getScript());
+		n.setIDDoc(null);
+		n.setIDUndoManager(null);
+		n.setNameUndoManager(null);
+		n.setNameDoc(null);
+		n.setSRC(getSRC());
+		n.setSRCDoc(null);
+		n.setSRCUndoManager(null);
+		n.setNamespace(getNamespace());
+		n.setNamespaceDoc(null);
+		n.setNamespaceUndoManager(null);
+		n.setID(getID());
+		n.setName(getName());
+		n.setFake(getFake());
+		return n;
+	}
+
+	public void setGeometry(double x, double y, double w, double h) {
+		node.put(GEOX, x);
+		node.put(GEOY, y);
+		node.put(GEOW, w);
+		node.put(GEOH, h);
+	}
+
+	public mxGeometry getGeometry() {
+		if (node.containsKey(GEOX)) {
+			double x, y, h, w;
+			x = (Double) node.get(GEOX);
+			y = (Double) node.get(GEOY);
+			w = (Double) node.get(GEOW);
+			h = (Double) node.get(GEOH);
+			return new mxGeometry(x, y, w, h);
+		} else
+			return null;
+	}
+
+	private void writeObject(ObjectOutputStream out) throws IOException {
+		SCXMLNode newn = cloneNode();
+		HashMap<String, Object> hash = node;
+		node = newn.node;
+		out.defaultWriteObject();
+		node = hash;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/MyUndoManager.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/MyUndoManager.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/MyUndoManager.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,65 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.util.Vector;
+
+import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.UndoManager;
+import javax.swing.undo.UndoableEdit;
+
+public class MyUndoManager extends UndoManager {
+
+	private static final long serialVersionUID = 1L;
+
+	public Vector<UndoableEdit> getEdits() {
+		return edits;
+	}
+
+	protected UndoableEdit getNextUndoableEdit() {
+		int size = edits.size();
+		for (int i = size - 1; i >= 0; i--) {
+			UndoableEdit u = (UndoableEdit) edits.elementAt(i);
+			if (u.canUndo() && u.isSignificant())
+				return u;
+		}
+		return null;
+	}
+
+	protected UndoableEdit getInitialEdit() {
+		return (edits.isEmpty()) ? null : edits.elementAt(0);
+	}
+
+	public synchronized void undoTo(UndoableEdit to, boolean excludeTo) {
+		int size = edits.size();
+		for (int i = size - 1; i >= 0; i--) {
+			UndoableEdit u = (UndoableEdit) edits.elementAt(i);
+			if (canUndo()) {
+				if ((u == to) && excludeTo)
+					return;
+				else
+					undo();
+			}
+			if (u == to)
+				return;
+		}
+	}
+
+	public synchronized void redoTo(UndoableEdit to, boolean excludeTo) {
+		int size = edits.size();
+		for (int i = 0; i < size; i++) {
+			UndoableEdit u = (UndoableEdit) edits.elementAt(i);
+			if (canRedo()) {
+				if ((u == to) && excludeTo)
+					return;
+				else
+					redo();
+			}
+			if (u == to)
+				return;
+		}
+	}
+
+	@Override
+	public synchronized void undo() throws CannotUndoException {
+		super.undo();
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLChangeHandler.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLChangeHandler.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLChangeHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,415 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import javax.swing.text.Document;
+import javax.swing.undo.UndoableEdit;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.util.mxUndoableEdit.mxUndoableChange;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.OutSource.OUTSOURCETYPE;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode.HISTORYTYPE;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.Pair;
+
+public class SCXMLChangeHandler {
+
+	private static final SCXMLChangeHandler instance = new SCXMLChangeHandler();
+
+	public abstract class SCXMLChange implements mxUndoableChange {
+		@Override
+		public String getInfoString() {
+			return this.getClass().getSimpleName();
+		}
+	}
+
+	public class SCXMLInitialStateProperty extends SCXMLChange {
+		SCXMLNode node = null;
+		Boolean valueToBeRestored = null;
+
+		public SCXMLInitialStateProperty(SCXMLNode node) {
+			this.node = node;
+			this.valueToBeRestored = node.isInitial();
+		}
+
+		@Override
+		public void execute() {
+			boolean currentValue = node.isInitial();
+			node.setInitial(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	public class SCXMLFinalStateProperty extends SCXMLChange {
+		SCXMLNode node = null;
+		Boolean valueToBeRestored = null;
+
+		public SCXMLFinalStateProperty(SCXMLNode node) {
+			this.node = node;
+			this.valueToBeRestored = node.isFinal();
+		}
+
+		@Override
+		public void execute() {
+			boolean currentValue = node.isFinal();
+			node.setFinal(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	public class SCXMLHistoryStateProperty extends SCXMLChange {
+		SCXMLNode node = null;
+		HISTORYTYPE valueToBeRestored = null;
+
+		public SCXMLHistoryStateProperty(SCXMLNode node) {
+			this.node = node;
+			this.valueToBeRestored = node.getHistoryType();
+		}
+
+		@Override
+		public void execute() {
+			HISTORYTYPE currentValue = node.getHistoryType();
+			node.setAsHistory(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	public class SCXMLClusterStateProperty extends SCXMLChange {
+		SCXMLNode node = null;
+		Boolean valueToBeRestored = null;
+
+		public SCXMLClusterStateProperty(SCXMLNode node) {
+			this.node = node;
+			this.valueToBeRestored = node.isClusterNode();
+		}
+
+		@Override
+		public void execute() {
+			boolean currentValue = node.isClusterNode();
+			node.setCluster(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	public class SCXMLParallelStateProperty extends SCXMLChange {
+		SCXMLNode node = null;
+		Boolean valueToBeRestored = null;
+
+		public SCXMLParallelStateProperty(SCXMLNode node) {
+			this.node = node;
+			this.valueToBeRestored = node.isParallel();
+		}
+
+		@Override
+		public void execute() {
+			boolean currentValue = node.isParallel();
+			node.setParallel(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	public class SCXMLGenericTextProperty<T> extends SCXMLChange {
+		boolean toBeUndone = true;
+		T thing = null;
+		String oldString = null;
+		Document oldDoc = null;
+		private UndoableEdit oldUndoPos = null;
+		private UndoableEdit redoPos = null;
+		private boolean undoExcludesTarget = false;
+		private Method docGetter, undoGetter, stringSetter, stringGetter, docSetter;
+
+		public SCXMLGenericTextProperty(T thing, Method stringReader, Method docReader, Method undoReader,
+				Method stringSetter, Method docSetter) {
+			this.toBeUndone = true;
+			this.thing = thing;
+
+			this.docGetter = docReader;
+			this.undoGetter = undoReader;
+			this.stringSetter = stringSetter;
+			this.stringGetter = stringReader;
+			this.docSetter = docSetter;
+
+			try {
+				this.oldString = (String) stringGetter.invoke(thing);
+				this.oldDoc = (Document) docReader.invoke(thing);
+				MyUndoManager um = (MyUndoManager) undoReader.invoke(thing);
+
+				this.oldUndoPos = (um != null) ? um.getNextUndoableEdit() : null;
+				this.undoExcludesTarget = (this.oldUndoPos != null);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+
+		@Override
+		public void execute() {
+			try {
+				if (oldDoc == null)
+					oldDoc = (Document) docGetter.invoke(thing);
+				docSetter.invoke(thing, oldDoc);
+				MyUndoManager um = (MyUndoManager) undoGetter.invoke(thing);
+				if ((oldUndoPos == null) && (um != null))
+					oldUndoPos = um.getInitialEdit();
+				if (toBeUndone && (um != null) && (oldUndoPos != null)) {
+					toBeUndone = false;
+					redoPos = (um != null) ? um.getNextUndoableEdit() : null;
+					um.undoTo(oldUndoPos, undoExcludesTarget);
+				} else if (!toBeUndone && (um != null) && (redoPos != null)) {
+					toBeUndone = true;
+					um.redoTo(redoPos, false);
+				}
+				stringSetter.invoke(thing, (String) stringGetter.invoke(thing));
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public class SCXMLOutsourcingStateProperty extends SCXMLChange {
+		private SCXMLGenericTextProperty<SCXMLNode> srcLocationState;
+		private SCXMLNode node;
+		private OUTSOURCETYPE typeToBeRestored;
+
+		public SCXMLOutsourcingStateProperty(SCXMLNode node) {
+			this.node = node;
+			srcLocationState = new SCXMLGenericTextProperty<SCXMLNode>(node, getSRC, getSRCDoc, getSRCUndoManager,
+					setSRC, setSRCDoc);
+			this.typeToBeRestored = node.getSRC().getType();
+		}
+
+		@Override
+		public void execute() {
+			srcLocationState.execute();
+			OUTSOURCETYPE currentType = node.getSRC().getType();
+			node.getSRC().setType(typeToBeRestored);
+			node.setFake(typeToBeRestored == OUTSOURCETYPE.XINC);
+			typeToBeRestored = currentType;
+		}
+	}
+
+	public class SCXMLOrderOutgoingEdgesStateProperty extends SCXMLChange {
+		ArrayList<Pair<SCXMLEdge, Integer>> oldOrder;
+		mxCell node;
+
+		public SCXMLOrderOutgoingEdgesStateProperty(mxCell node) {
+			this.node = node;
+			oldOrder = new ArrayList<Pair<SCXMLEdge, Integer>>();
+			saveCurrentOrderOfOutgoingEdges(node, oldOrder);
+		}
+
+		private void saveCurrentOrderOfOutgoingEdges(mxCell n, ArrayList<Pair<SCXMLEdge, Integer>> saveTo) {
+			int l = n.getEdgeCount();
+			for (int i = 0; i < l; i++) {
+				mxCell e = (mxCell) n.getEdgeAt(i);
+				if (e.getSource() == n) {
+					SCXMLEdge v = (SCXMLEdge) e.getValue();
+					int o = v.getOrder();
+					saveTo.add(new Pair<SCXMLEdge, Integer>(v, o));
+				}
+			}
+		}
+
+		@Override
+		public void execute() {
+			ArrayList<Pair<SCXMLEdge, Integer>> currentOrder = new ArrayList<Pair<SCXMLEdge, Integer>>();
+			saveCurrentOrderOfOutgoingEdges(node, currentOrder);
+			for (Pair<SCXMLEdge, Integer> eo : oldOrder) {
+				eo.getFirst().setOrder(eo.getSecond());
+			}
+			oldOrder = currentOrder;
+		}
+	}
+
+	public class SCXMLWithTargetEdgeProperty extends SCXMLChange {
+		SCXMLEdge edge = null;
+		Boolean valueToBeRestored = null;
+
+		public SCXMLWithTargetEdgeProperty(SCXMLEdge edge) {
+			this.edge = edge;
+			this.valueToBeRestored = edge.isCycleWithTarget();
+		}
+
+		@Override
+		public void execute() {
+			boolean currentValue = edge.isCycleWithTarget();
+			edge.setCycleWithTarget(valueToBeRestored);
+			valueToBeRestored = currentValue;
+		}
+	}
+
+	private static Method getSRC, getID, getName, getOnEntry, getOnExit, getOnInitialEntry, getDoneData, getDatamodel,
+			getNamespace, getExe, getCondition, getEvent, getNodeComments, getEdgeComments;
+	private static Method getSRCDoc, getIDDoc, getNameDoc, getOnEntryDoc, getOnExitDoc, getOnInitialEntryDoc,
+			getDoneDataDoc, getDatamodelDoc, getNamespaceDoc, getExeDoc, getConditionDoc, getEventDoc,
+			getNodeCommentsDoc, getEdgeCommentsDoc;
+	private static Method getSRCUndoManager, getIDUndoManager, getNameUndoManager, getOnEntryUndoManager,
+			getOnExitUndoManager, getOnInitialEntryUndoManager, getDoneDataUndoManager, getDatamodelUndoManager,
+			getNamespaceUndoManager, getExeUndoManager, getConditionUndoManager, getEventUndoManager,
+			getNodeCommentsUndoManager, getEdgeCommentsUndoManager;
+	private static Method setSRC, setID, setName, setOnEntry, setOnExit, setOnInitialEntry, setDoneData, setDatamodel,
+			setNamespace, setExe, setCondition, setEvent, setNodeComments, setEdgeComments;
+	private static Method setSRCDoc, setIDDoc, setNameDoc, setOnEntryDoc, setOnExitDoc, setOnInitialEntryDoc,
+			setDoneDataDoc, setDatamodelDoc, setNamespaceDoc, setExeDoc, setConditionDoc, setEventDoc,
+			setNodeCommentsDoc, setEdgeCommentsDoc;
+	private static Method setSRCUndoManager, setIDUndoManager, setNameUndoManager, setOnEntryUndoManager,
+			setOnExitUndoManager, setOnInitialEntryUndoManager, setDoneDataUndoManager, setDatamodelUndoManager,
+			setNamespaceUndoManager, setExeUndoManager, setConditionUndoManager, setEventUndoManager,
+			setNodeCommentsUndoManager, setEdgeCommentsUndoManager;
+	static {
+		try {
+			// getters
+			getSRC = SCXMLNode.class.getDeclaredMethod("getOutsourcedLocation");
+			getID = SCXMLNode.class.getDeclaredMethod("getID");
+			getName = SCXMLNode.class.getDeclaredMethod("getName");
+			getOnEntry = SCXMLNode.class.getDeclaredMethod("getOnEntry");
+			getOnExit = SCXMLNode.class.getDeclaredMethod("getOnExit");
+			getOnInitialEntry = SCXMLNode.class.getDeclaredMethod("getOnInitialEntry");
+			getDoneData = SCXMLNode.class.getDeclaredMethod("getDoneData");
+			getDatamodel = SCXMLNode.class.getDeclaredMethod("getDatamodel");
+			getNamespace = SCXMLNode.class.getDeclaredMethod("getNamespace");
+			getExe = SCXMLEdge.class.getDeclaredMethod("getExe");
+			getCondition = SCXMLEdge.class.getDeclaredMethod("getCondition");
+			getEvent = SCXMLEdge.class.getDeclaredMethod("getEvent");
+			getNodeComments = SCXMLNode.class.getDeclaredMethod("getComments");
+			getEdgeComments = SCXMLEdge.class.getDeclaredMethod("getComments");
+
+			getSRCDoc = SCXMLNode.class.getDeclaredMethod("getSRCDoc");
+			getIDDoc = SCXMLNode.class.getDeclaredMethod("getIDDoc");
+			getNameDoc = SCXMLNode.class.getDeclaredMethod("getNameDoc");
+			getOnEntryDoc = SCXMLNode.class.getDeclaredMethod("getOnEntryDoc");
+			getOnExitDoc = SCXMLNode.class.getDeclaredMethod("getOnExitDoc");
+			getOnInitialEntryDoc = SCXMLNode.class.getDeclaredMethod("getOnInitialEntryDoc");
+			getDoneDataDoc = SCXMLNode.class.getDeclaredMethod("getDoneDataDoc");
+			getDatamodelDoc = SCXMLNode.class.getDeclaredMethod("getDatamodelDoc");
+			getNamespaceDoc = SCXMLNode.class.getDeclaredMethod("getNamespaceDoc");
+			getExeDoc = SCXMLEdge.class.getDeclaredMethod("getExeDoc");
+			getConditionDoc = SCXMLEdge.class.getDeclaredMethod("getConditionDoc");
+			getEventDoc = SCXMLEdge.class.getDeclaredMethod("getEventDoc");
+			getNodeCommentsDoc = SCXMLNode.class.getDeclaredMethod("getCommentsDoc");
+			getEdgeCommentsDoc = SCXMLEdge.class.getDeclaredMethod("getCommentsDoc");
+
+			getSRCUndoManager = SCXMLNode.class.getDeclaredMethod("getSRCUndoManager");
+			getIDUndoManager = SCXMLNode.class.getDeclaredMethod("getIDUndoManager");
+			getNameUndoManager = SCXMLNode.class.getDeclaredMethod("getNameUndoManager");
+			getOnEntryUndoManager = SCXMLNode.class.getDeclaredMethod("getOnEntryUndoManager");
+			getOnExitUndoManager = SCXMLNode.class.getDeclaredMethod("getOnExitUndoManager");
+			getOnInitialEntryUndoManager = SCXMLNode.class.getDeclaredMethod("getOnInitialEntryUndoManager");
+			getDoneDataUndoManager = SCXMLNode.class.getDeclaredMethod("getDoneDataUndoManager");
+			getDatamodelUndoManager = SCXMLNode.class.getDeclaredMethod("getDatamodelUndoManager");
+			getNamespaceUndoManager = SCXMLNode.class.getDeclaredMethod("getNamespaceUndoManager");
+			getExeUndoManager = SCXMLEdge.class.getDeclaredMethod("getExeUndoManager");
+			getConditionUndoManager = SCXMLEdge.class.getDeclaredMethod("getConditionUndoManager");
+			getEventUndoManager = SCXMLEdge.class.getDeclaredMethod("getEventUndoManager");
+			getNodeCommentsUndoManager = SCXMLNode.class.getDeclaredMethod("getCommentsUndoManager");
+			getEdgeCommentsUndoManager = SCXMLEdge.class.getDeclaredMethod("getCommentsUndoManager");
+			// setters
+			setSRC = SCXMLNode.class.getDeclaredMethod("setOutsourcedLocation", String.class);
+			setID = SCXMLNode.class.getDeclaredMethod("setID", String.class);
+			setName = SCXMLNode.class.getDeclaredMethod("setName", String.class);
+			setOnEntry = SCXMLNode.class.getDeclaredMethod("setOnEntry", String.class);
+			setOnExit = SCXMLNode.class.getDeclaredMethod("setOnExit", String.class);
+			setOnInitialEntry = SCXMLNode.class.getDeclaredMethod("setOnInitialEntry", String.class);
+			setDoneData = SCXMLNode.class.getDeclaredMethod("setDoneData", String.class);
+			setDatamodel = SCXMLNode.class.getDeclaredMethod("setDatamodel", String.class);
+			setNamespace = SCXMLNode.class.getDeclaredMethod("setNamespace", String.class);
+			setExe = SCXMLEdge.class.getDeclaredMethod("setExe", String.class);
+			setCondition = SCXMLEdge.class.getDeclaredMethod("setCondition", String.class);
+			setEvent = SCXMLEdge.class.getDeclaredMethod("setEvent", String.class);
+			setNodeComments = SCXMLNode.class.getDeclaredMethod("setComments", String.class);
+			setEdgeComments = SCXMLEdge.class.getDeclaredMethod("setComments", String.class);
+
+			setSRCDoc = SCXMLNode.class.getDeclaredMethod("setSRCDoc", Document.class);
+			setIDDoc = SCXMLNode.class.getDeclaredMethod("setIDDoc", Document.class);
+			setNameDoc = SCXMLNode.class.getDeclaredMethod("setNameDoc", Document.class);
+			setOnEntryDoc = SCXMLNode.class.getDeclaredMethod("setOnEntryDoc", Document.class);
+			setOnExitDoc = SCXMLNode.class.getDeclaredMethod("setOnExitDoc", Document.class);
+			setOnInitialEntryDoc = SCXMLNode.class.getDeclaredMethod("setOnInitialEntryDoc", Document.class);
+			setDoneDataDoc = SCXMLNode.class.getDeclaredMethod("setDoneDataDoc", Document.class);
+			setDatamodelDoc = SCXMLNode.class.getDeclaredMethod("setDatamodelDoc", Document.class);
+			setNamespaceDoc = SCXMLNode.class.getDeclaredMethod("setNamespaceDoc", Document.class);
+			setExeDoc = SCXMLEdge.class.getDeclaredMethod("setExeDoc", Document.class);
+			setConditionDoc = SCXMLEdge.class.getDeclaredMethod("setConditionDoc", Document.class);
+			setEventDoc = SCXMLEdge.class.getDeclaredMethod("setEventDoc", Document.class);
+			setNodeCommentsDoc = SCXMLNode.class.getDeclaredMethod("setCommentsDoc", Document.class);
+			setEdgeCommentsDoc = SCXMLEdge.class.getDeclaredMethod("setCommentsDoc", Document.class);
+
+			setSRCUndoManager = SCXMLNode.class.getDeclaredMethod("setSRCUndoManager", MyUndoManager.class);
+			setIDUndoManager = SCXMLNode.class.getDeclaredMethod("setIDUndoManager", MyUndoManager.class);
+			setNameUndoManager = SCXMLNode.class.getDeclaredMethod("setNameUndoManager", MyUndoManager.class);
+			setOnEntryUndoManager = SCXMLNode.class.getDeclaredMethod("setOnEntryUndoManager", MyUndoManager.class);
+			setOnExitUndoManager = SCXMLNode.class.getDeclaredMethod("setOnExitUndoManager", MyUndoManager.class);
+			setOnInitialEntryUndoManager = SCXMLNode.class.getDeclaredMethod("setOnInitialEntryUndoManager",
+					MyUndoManager.class);
+			setDoneDataUndoManager = SCXMLNode.class.getDeclaredMethod("setDoneDataUndoManager", MyUndoManager.class);
+			setDatamodelUndoManager = SCXMLNode.class.getDeclaredMethod("setDatamodelUndoManager", MyUndoManager.class);
+			setNamespaceUndoManager = SCXMLNode.class.getDeclaredMethod("setNamespaceUndoManager", MyUndoManager.class);
+			setExeUndoManager = SCXMLEdge.class.getDeclaredMethod("setExeUndoManager", MyUndoManager.class);
+			setConditionUndoManager = SCXMLEdge.class.getDeclaredMethod("setConditionUndoManager", MyUndoManager.class);
+			setEventUndoManager = SCXMLEdge.class.getDeclaredMethod("setEventUndoManager", MyUndoManager.class);
+			setNodeCommentsUndoManager = SCXMLNode.class.getDeclaredMethod("setCommentsUndoManager",
+					MyUndoManager.class);
+			setEdgeCommentsUndoManager = SCXMLEdge.class.getDeclaredMethod("setCommentsUndoManager",
+					MyUndoManager.class);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public static void addStateOfNodeInCurrentEdit(mxCell cell, mxIGraphModel model) {
+		if ((cell != null) && (cell.getValue() != null)) {
+			SCXMLNode node = (SCXMLNode) cell.getValue();
+			try {
+				model.addChangeToCurrentEdit(instance.new SCXMLParallelStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLClusterStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLInitialStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLFinalStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLOrderOutgoingEdgesStateProperty(cell));
+				model.addChangeToCurrentEdit(instance.new SCXMLHistoryStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLOutsourcingStateProperty(node));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getID, getIDDoc,
+						getIDUndoManager, setID, setIDDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getName, getNameDoc,
+						getNameUndoManager, setName, setNameDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getOnEntry,
+						getOnEntryDoc, getOnEntryUndoManager, setOnEntry, setOnEntryDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getOnExit,
+						getOnExitDoc, getOnExitUndoManager, setOnExit, setOnExitDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getOnInitialEntry,
+						getOnInitialEntryDoc, getOnInitialEntryUndoManager, setOnInitialEntry, setOnInitialEntryDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getDoneData,
+						getDoneDataDoc, getDoneDataUndoManager, setDoneData, setDoneDataDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getDatamodel,
+						getDatamodelDoc, getDatamodelUndoManager, setDatamodel, setDatamodelDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getNamespace,
+						getNamespaceDoc, getNamespaceUndoManager, setNamespace, setNamespaceDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLNode>(node, getNodeComments,
+						getNodeCommentsDoc, getNodeCommentsUndoManager, setNodeComments, setNodeCommentsDoc));
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public static void addStateOfEdgeInCurrentEdit(mxCell cell, mxIGraphModel model) {
+		if ((cell != null) && (cell.getValue() != null)) {
+			SCXMLEdge edge = (SCXMLEdge) cell.getValue();
+			try {
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLEdge>(edge, getEvent,
+						getEventDoc, getEventUndoManager, setEvent, setEventDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLEdge>(edge, getCondition,
+						getConditionDoc, getConditionUndoManager, setCondition, setConditionDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLEdge>(edge, getExe, getExeDoc,
+						getExeUndoManager, setExe, setExeDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLGenericTextProperty<SCXMLEdge>(edge, getEdgeComments,
+						getEdgeCommentsDoc, getEdgeCommentsUndoManager, setEdgeComments, setEdgeCommentsDoc));
+				model.addChangeToCurrentEdit(instance.new SCXMLWithTargetEdgeProperty(edge));
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorActions.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorActions.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorActions.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,867 @@
+	package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.awt.Component;
+import java.awt.MouseInfo;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import com.mxgraph.layout.mxClusterLayout;
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGeometry;
+import com.mxgraph.model.mxGraphModel;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.swing.mxGraphComponent;
+import com.mxgraph.swing.util.mxGraphActions.DeleteAction;
+import com.mxgraph.util.mxPoint;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.view.mxCellState;
+import com.mxgraph.view.mxGraph;
+import com.mxgraph.view.mxGraphView;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor.EditorStatus;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLImportExport;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor.SCXMLEditorRoot;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor.SCXMLEditorRoot.Type;
+
+/**
+ * @author Administrator
+ * 
+ */
+public class SCXMLEditorActions {
+
+	/**
+	 * 
+	 * @param e
+	 * @return Returns the graph for the given action event.
+	 */
+	public static final SCXMLGraphEditor getEditor(ActionEvent e) {
+		if (e.getSource() instanceof Component) {
+			Component component = (Component) e.getSource();
+
+			while (component != null && !(component instanceof SCXMLGraphEditor)) {
+				component = component.getParent();
+			}
+
+			return (SCXMLGraphEditor) component;
+		}
+
+		return null;
+	}
+
+	public static class AddAction extends AbstractAction {
+		private Point pos;
+		mxCell parent;
+
+		// p must be a swimlane
+		public AddAction(Point pt, mxCell p) {
+			pos = pt;
+			parent = p;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			SCXMLGraphComponent c = (SCXMLGraphComponent) editor.getGraphComponent();
+			SCXMLNode value = (SCXMLNode) editor.getCurrentFileIO().buildNodeValue();
+
+			if (!(e.getActionCommand().equals(mxResources.get("addNode")))) {
+				RestrictedState restrictedState = null;
+				for (RestrictedState tempState : editor.getRestrictedStatesConfig().getRestrictedState()) {
+					if (tempState.getName().equals(e.getActionCommand())) {
+						restrictedState = tempState;
+					}
+				}
+				value.setRestricted(true, restrictedState);
+			}
+
+			pos = c.mouseCoordToGraphCoord(pos);
+			// the state contains the absolute coordinate
+			mxGraphView view = graph.getView();
+			double scale = view.getScale();
+			mxCellState parentState = view.getState(parent);
+			double parentX = parentState.getX() / scale;
+			double parentY = parentState.getY() / scale;
+			mxCell p = (mxCell) graph.insertVertex(parent, value.getInternalID(), value, pos.x - parentX,
+					pos.y - parentY, 75, 75, value.getStyle());
+		}
+	}
+
+	public static class EditEdgeAction extends AbstractAction {
+		private Point pos;
+		private mxCell cell;
+
+		public EditEdgeAction(mxCell c, Point pt) {
+			cell = c;
+			pos = pt;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			assert (cell.isEdge());
+			SCXMLGraphEditor editor = getEditor(e);
+			JFrame frame = (JFrame) SwingUtilities.windowForComponent(editor);
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfEdgeInCurrentEdit(cell, model);
+				editor.openElementEditorFor(cell, SCXMLEditorRoot.Type.EDGE, pos);
+			} catch (Exception ex) {
+				ex.printStackTrace();
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class AddCornerToEdgeAction extends AbstractAction {
+		private Point pos, unscaledPos;
+		private mxCell cell;
+		private int index;
+
+		public AddCornerToEdgeAction(mxCell c, Point pt, Point unscaledPt, int i) {
+			this.cell = c;
+			this.pos = pt;
+			this.unscaledPos = unscaledPt;
+			this.index = i;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			assert (cell.isEdge());
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraphComponent gc = editor.getGraphComponent();
+			mxGraphView gv = gc.getGraph().getView();
+			mxCellState cs = gv.getState(cell);
+			// List<mxPoint> pts = cs.getAbsolutePoints();
+			mxGeometry cg = cell.getGeometry();
+
+			if (cg.isRelative()) {
+				mxCellState ps = gv.getState(cell.getParent());
+				pos = ps.relativizePointToThisState(unscaledPos, gv.getScale(), gv.getTranslate());
+			}
+
+			List<mxPoint> ptsAlreadyThere = (cg.getPoints() == null) ? new ArrayList<mxPoint>()
+					: new ArrayList<mxPoint>(cg.getPoints());
+			if (index >= ptsAlreadyThere.size())
+				ptsAlreadyThere.add(new mxPoint(pos.x, pos.y));
+			else
+				ptsAlreadyThere.add(index, new mxPoint(pos.x, pos.y));
+
+			mxGraphModel model = (mxGraphModel) gc.getGraph().getModel();
+			mxGeometry geometry = (mxGeometry) cg.clone();
+			geometry.setPoints(ptsAlreadyThere);
+			model.setGeometry(cell, geometry);
+
+			// cg.setPoints(ptsAlreadyThere);
+			// mxGraphModel model=(mxGraphModel) gc.getGraph().getModel();
+			// model.execute(new mxGeometryChange(model, cell, cg));
+		}
+	}
+
+	public static class RemoveCornerToEdgeAction extends AbstractAction {
+		private int index;
+		private mxCell cell;
+
+		public RemoveCornerToEdgeAction(mxCell c, int i) {
+			cell = c;
+			index = i;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			assert (cell.isEdge());
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraphComponent gc = editor.getGraphComponent();
+			mxCellState cs = gc.getGraph().getView().getState(cell);
+			// List<mxPoint> pts = cs.getAbsolutePoints();
+			mxGeometry cg = cell.getGeometry();
+			List<mxPoint> ptsAlreadyThere = new ArrayList<mxPoint>(cg.getPoints());
+
+			ptsAlreadyThere.remove(index);
+
+			mxGraphModel model = (mxGraphModel) gc.getGraph().getModel();
+			mxGeometry geometry = (mxGeometry) cg.clone();
+			geometry.setPoints(ptsAlreadyThere);
+			model.setGeometry(cell, geometry);
+
+			// mxGraphModel model=(mxGraphModel) gc.getGraph().getModel();
+			// model.execute(new mxGeometryChange(model, cell, cg));
+		}
+	}
+
+	public static class EditNodeAction extends AbstractAction {
+		private Point pos;
+		private mxCell cell;
+		private mxCell rootOfGraph;
+
+		public EditNodeAction(mxCell c, mxCell root, Point pt) {
+			cell = c;
+			rootOfGraph = root;
+			pos = pt;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			assert (cell.isVertex());
+			SCXMLGraphEditor editor = getEditor(e);
+			JFrame frame = (JFrame) SwingUtilities.windowForComponent(editor);
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				editor.openElementEditorFor(cell, Type.NODE, pos);
+			} catch (Exception ex) {
+				ex.printStackTrace();
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class SetNodeAsInitial extends AbstractAction {
+		private mxCell cell;
+
+		public SetNodeAsInitial(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				n.setInitial(!n.isInitial());
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class ToggleWithTargetAction extends AbstractAction {
+		private mxCell cell;
+
+		public ToggleWithTargetAction(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isEdge());
+			SCXMLEdge n = (SCXMLEdge) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfEdgeInCurrentEdit(cell, model);
+				n.setCycleWithTarget(!n.isCycleWithTarget());
+				graph.setCellStyle(n.getStyle(cell), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class ToggleIgnoreStoredLayout extends AbstractAction {
+		public static boolean isSelected(SCXMLGraphEditor editor) {
+			return editor.preferences
+					.getBoolean(SCXMLGraphEditor.PREFERENCE_IGNORE_STORED_LAYOUT, true);
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			boolean ignoreStoredLayout = isSelected(editor);
+			editor.preferences.putBoolean(SCXMLGraphEditor.PREFERENCE_IGNORE_STORED_LAYOUT,
+					!ignoreStoredLayout);
+			editor.updateIgnoreStoredLayoutMenuState();
+		}
+	}
+
+	public static class SetNodeAsFinal extends AbstractAction {
+		private mxCell cell;
+
+		public SetNodeAsFinal(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				n.setFinal(!n.isFinal());
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class SetNodeAsCluster extends AbstractAction {
+		private mxCell cell;
+
+		public SetNodeAsCluster(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				n.setCluster(!n.isClusterNode());
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class SetNodeAsParallel extends AbstractAction {
+		private mxCell cell;
+
+		public SetNodeAsParallel(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				n.setParallel(!n.isParallel());
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class SetNodeAsRestricted extends AbstractAction {
+
+		private mxCell cell;
+
+		public SetNodeAsRestricted(mxCell c) {
+			cell = c;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				RestrictedState restrictedState = null;
+				for (RestrictedState tempState : editor.getRestrictedStatesConfig().getRestrictedState()) {
+					if (tempState.getName().equals(e.getActionCommand())) {
+						restrictedState = tempState;
+					}
+				}
+				n.setRestricted(!n.isRestricted(restrictedState), restrictedState);
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public static class SetNodeAsHistory extends AbstractAction {
+		private mxCell cell;
+		private boolean deep;
+
+		public SetNodeAsHistory(mxCell c, boolean d) {
+			cell = c;
+			this.deep = d;
+		}
+
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			mxGraph graph = editor.getGraphComponent().getGraph();
+			assert (cell.isVertex());
+			SCXMLNode n = (SCXMLNode) cell.getValue();
+
+			mxIGraphModel model = editor.getGraphComponent().getGraph().getModel();
+			model.beginUpdate();
+			try {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit(cell, model);
+				if (deep) {
+					if (n.isDeepHistory())
+						n.setAsHistory(null);
+					else
+						n.setAsHistory(SCXMLNode.HISTORYTYPE.DEEP);
+				} else {
+					if (n.isShallowHistory())
+						n.setAsHistory(null);
+					else
+						n.setAsHistory(SCXMLNode.HISTORYTYPE.SHALLOW);
+				}
+				graph.setCellStyle(n.getStyle(), cell);
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	/**
+	 *
+	 */
+	@SuppressWarnings("serial")
+	public static class HistoryAction extends AbstractAction {
+		/**
+		 * 
+		 */
+		protected boolean undo;
+
+		/**
+		 * 
+		 */
+		public HistoryAction(boolean undo) {
+			this.undo = undo;
+			// setEnabled(shouldBeEnabled(undo));
+		}
+
+		/**
+		 * 
+		 */
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+
+			if (editor != null) {
+				Collection<Object> modifiedObjects;
+				if (undo) {
+					modifiedObjects = editor.getUndoManager().undo();
+				} else {
+					modifiedObjects = editor.getUndoManager().redo();
+				}
+
+				editor.updateUndoRedoActionState();
+			}
+		}
+
+	}
+
+	public static class NewSCXMLAction {
+		public void openNewAction(SCXMLGraphEditor editor) {
+				editor.setCurrentFile(null,new SCXMLImportExport());
+				
+				SCXMLGraphComponent gc = editor.getGraphComponent();
+				SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+				
+				//Memory leak fix
+				gc.clearSCXMLNodes();
+				editor.clearEditorForCellAndType();
+				graph.clearUndeletable();
+				graph.getModel().clearCells();
+				
+				mxCell root = new mxCell();
+				root.insert(new mxCell());
+				graph.getModel().setRoot(root);
+				graph.setDefaultParent(null);
+
+				SCXMLNode value=(SCXMLNode)editor.getCurrentFileIO().buildNodeValue();
+				((SCXMLImportExport)editor.getCurrentFileIO()).setRoot(value);
+				value.setID(SCXMLNode.ROOTID);
+				value.setName("Top");
+				value.setNamespace("xmlns=\"http://www.w3.org/2005/07/scxml\"");
+				value.setCluster(true);
+				mxCell p = (mxCell) graph.insertVertex(null, value.getInternalID(), value, 0, 0, gc.getSize().width, gc.getSize().height, value.getStyle());
+				p.setValue(value);
+				graph.setDefaultParent(p);
+
+				graph.setCellAsDeletable(p, false);
+				editor.setModified(false);
+				editor.getUndoManager().clear();
+				editor.getUndoManager().resetUnmodifiedState();
+				editor.updateUndoRedoActionState();
+				editor.clearDisplayOutsourcedContentStatus();
+				
+				editor.closeAllEditors();
+				editor.setDisplayOfOutsourcedContentSelected(false);
+				
+				editor.setStatus(EditorStatus.EDITING);
+		}
+	}
+
+	/**
+	 *
+	 */
+	@SuppressWarnings("serial")
+	public static class DoLayoutAction extends AbstractAction {
+		mxGraph graph;
+		mxClusterLayout layout;
+		mxCell parentToLayout;
+		private int depth;
+
+		public DoLayoutAction(mxGraph g, mxCell p, int depth) {
+			graph = g;
+			layout = new mxClusterLayout(g);
+			parentToLayout = p;
+			this.depth = depth;
+		}
+
+		/**
+		 * 
+		 */
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			EditorStatus oldStatus = editor.getStatus();
+			editor.setStatus(EditorStatus.LAYOUT);
+			editor.getUndoManager().setCollectionMode(true);
+			layout.execute((parentToLayout == null) ? graph.getDefaultParent() : parentToLayout, depth);
+			editor.getUndoManager().setCollectionMode(false);
+			editor.setStatus(oldStatus);
+		}
+	}
+
+	/**
+	 *
+	 */
+	@SuppressWarnings("serial")
+	public static class OpenAction extends AbstractAction {
+		/**
+		 * 
+		 */
+		protected String lastDir;
+		protected File file;
+		private boolean inNewWindow;
+
+		public OpenAction(File file, boolean inNewWindow) {
+			this.file = file;
+			this.inNewWindow = inNewWindow;
+		}
+
+		public OpenAction(File file) {
+			this(file, false);
+		}
+
+		public OpenAction() {
+			this(null, false);
+		}
+		
+		/**
+		 * 
+		 */
+		public void doStartAction(SCXMLGraphEditor editor, boolean isReadOnly) {
+			SCXMLGraphComponent gc = editor.getGraphComponent();
+			SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+			gc.clearSCXMLNodes();
+			editor.clearEditorForCellAndType();
+			graph.clearUndeletable();
+			graph.getModel().clearCells();
+
+			openInEditor(editor, isReadOnly);
+		}
+		
+		public void doStartActionContents(String contents, SCXMLGraphEditor editor, boolean isReadOnly) {
+			SCXMLGraphComponent gc = editor.getGraphComponent();
+			SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+			gc.clearSCXMLNodes();
+			editor.clearEditorForCellAndType();
+			graph.clearUndeletable();
+			graph.getModel().clearCells();
+
+			openInEditorContents(contents, editor, isReadOnly);
+		}
+		
+		public void actionPerformed(ActionEvent e) {
+			// Memory leak fix
+			SCXMLGraphEditor editor = getEditor(e);
+			SCXMLGraphComponent gc = editor.getGraphComponent();
+			SCXMLGraph graph = (SCXMLGraph) gc.getGraph();
+			gc.clearSCXMLNodes();
+			editor.clearEditorForCellAndType();
+			graph.clearUndeletable();
+			graph.getModel().clearCells();
+
+			if (inNewWindow) {
+				Thread openingThread = new Thread(new Runnable() {
+					@Override
+					public void run() {
+						openInEditor(SCXMLGraphEditor.startEditor(), false);
+					}
+				});
+				openingThread.setName("threadFor" + file);
+				openingThread.start();
+			} else {
+				openInEditor(getEditor(e), false);
+			}
+		}
+
+		private void openInEditor(SCXMLGraphEditor editor, boolean isReadOnly) {
+			if (editor != null) {
+				editor.setStatus(EditorStatus.POPULATING);
+				editor.closeAllEditors();
+				openSelectedFile(editor, isReadOnly);
+				editor.setDisplayOfOutsourcedContentSelected(false);
+				editor.setStatus(EditorStatus.EDITING);
+			}
+		}
+
+		private void openInEditorContents(String contents, SCXMLGraphEditor editor, boolean isReadOnly) {
+			if (editor != null) {
+				editor.setStatus(EditorStatus.POPULATING);
+				editor.closeAllEditors();
+				openSelectedContents(contents, editor, isReadOnly);
+				editor.setDisplayOfOutsourcedContentSelected(false);
+				editor.setStatus(EditorStatus.EDITING);
+			}
+		}
+		
+		private void openSelectedFile(SCXMLGraphEditor editor, boolean isReadOnly) {
+			File selectedFile = file;
+			SCXMLGraph graph = editor.getGraphComponent().getGraph();
+			if ((graph != null) && (selectedFile != null)) {
+				lastDir = selectedFile.getParent();
+				try {
+					editor.clearDisplayOutsourcedContentStatus();
+					mxGraphComponent graphComponent = editor.getGraphComponent();
+					SCXMLImportExport fie = new SCXMLImportExport();
+					// run the selected importer
+					fie.read(selectedFile.getAbsolutePath(), graphComponent, editor.getRestrictedStatesConfig());
+
+					mxClusterLayout clusterLayout = new mxClusterLayout(graph);
+					clusterLayout.execute(graph.getDefaultParent());
+
+					editor.setModified(false);
+					editor.setCurrentFile(selectedFile, fie);
+					editor.getUndoManager().clear();
+					editor.getUndoManager().resetUnmodifiedState();
+					editor.updateUndoRedoActionState();
+					
+					graph.setReadOnly(isReadOnly);
+					((SCXMLGraphComponent)editor.getGraphComponent()).setReadOnly(isReadOnly);
+
+				} catch (Exception ex) {
+					ex.printStackTrace();
+					JOptionPane.showMessageDialog(editor.getGraphComponent(), ex.toString(), mxResources.get("error"),
+							JOptionPane.ERROR_MESSAGE);
+				}
+
+			}
+		}
+		
+		private void openSelectedContents(String contents, SCXMLGraphEditor editor, boolean isReadOnly) {
+			SCXMLGraph graph = editor.getGraphComponent().getGraph();
+			if ((graph != null) && (contents != null)) {
+				try {
+					editor.clearDisplayOutsourcedContentStatus();
+					mxGraphComponent graphComponent = editor.getGraphComponent();
+					SCXMLImportExport io = new SCXMLImportExport();
+					io.parse(contents, graphComponent, editor.getRestrictedStatesConfig());
+
+					// apply layout to each cluster from the leaves up:
+					mxClusterLayout clusterLayout = new mxClusterLayout(graph);
+					clusterLayout.execute(graph.getDefaultParent());
+
+					editor.setModified(false);
+					editor.getUndoManager().clear();
+					editor.getUndoManager().resetUnmodifiedState();
+					editor.updateUndoRedoActionState();
+
+					graph.setReadOnly(isReadOnly);
+					((SCXMLGraphComponent)editor.getGraphComponent()).setReadOnly(isReadOnly);
+					
+				} catch (Exception ex) {
+					ex.printStackTrace();
+					JOptionPane.showMessageDialog(editor.getGraphComponent(), ex.toString(), mxResources.get("error"),
+							JOptionPane.ERROR_MESSAGE);
+				}
+
+			}
+		}
+	}
+
+	public static class EditSelectedCellAction extends AbstractAction {
+		private mxCell cell;
+
+		public EditSelectedCellAction(mxCell cell) {
+			this.cell = cell;
+		}
+
+		/**
+		 * 
+		 */
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			SCXMLGraphComponent gc = editor.getGraphComponent();
+			SCXMLGraph graph = gc.getGraph();
+
+			if (cell == null) {
+				cell = (mxCell) graph.getSelectionCell();
+
+				if (cell != null && !graph.isCellEditable(cell)) {
+					cell = null;
+				}
+			}
+			if (cell != null) {
+				Point screenCoord = MouseInfo.getPointerInfo().getLocation();
+				Point mousePoint = SwingUtilities.convertPoint(gc, screenCoord, gc);
+				if (cell.isEdge()) {
+					new EditEdgeAction(cell, mousePoint).actionPerformed(e);
+				} else if (cell.isVertex()) {
+					mxIGraphModel model = graph.getModel();
+					mxCell root = SCXMLImportExport.followUniqueDescendantLineTillSCXMLValueIsFound(model);
+					new EditNodeAction(cell, root, mousePoint).actionPerformed(e);
+				}
+			}
+			cell = null;
+		}
+	}
+
+	public static class ToggleDisplayOutsourcedContentInNode extends AbstractAction {
+
+		private mxCell node = null;
+		private boolean refresh;
+
+		public ToggleDisplayOutsourcedContentInNode(mxCell n) {
+			this(n, false);
+		}
+
+		public ToggleDisplayOutsourcedContentInNode(mxCell n, boolean refresh) {
+			this.node = n;
+			this.refresh = refresh;
+		}
+
+		@Override
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			SCXMLGraph graph = editor.getGraphComponent().getGraph();
+			try {
+				editor.getUndoManager().setCollectionMode(true);
+				if (refresh) {
+					if (node.getChildCount() > 0) {
+						editor.displayOutsourcedContentInNode(node, graph, false, false);
+						editor.displayOutsourcedContentInNode(node, graph, true, true);
+					}
+				} else {
+					if (node.getChildCount() > 0) {
+						// disable
+						editor.displayOutsourcedContentInNode(node, graph, false, false);
+					} else {
+						// enable
+						editor.displayOutsourcedContentInNode(node, graph, true, false);
+					}
+				}
+				// apply layout to each cluster from the leaves up:
+				mxClusterLayout clusterLayout = new mxClusterLayout(graph);
+				clusterLayout.execute(graph.getDefaultParent());
+				editor.setDisplayOfOutsourcedContentSelected(false);
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+			editor.getUndoManager().setCollectionMode(false);
+		}
+	}
+
+	public static class ToggleDisplayOutsourcedContent extends AbstractAction {
+		@Override
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			SCXMLGraph graph = editor.getGraphComponent().getGraph();
+			mxIGraphModel model = graph.getModel();
+			try {
+				editor.getUndoManager().setCollectionMode(true);
+				if (editor.isDisplayOfOutsourcedContentSelected()) {
+					// disable
+					editor.displayOutsourcedContent(graph, false, true);
+				} else {
+					// enable
+					editor.displayOutsourcedContent(graph, true, true);
+				}
+				// apply layout to each cluster from the leaves up:
+				mxClusterLayout clusterLayout = new mxClusterLayout(graph);
+				clusterLayout.execute(graph.getDefaultParent());
+				editor.setDisplayOfOutsourcedContentSelected(!editor.isDisplayOfOutsourcedContentSelected());
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+			editor.getUndoManager().setCollectionMode(false);
+		}
+	}
+
+	public static class ZoomIN extends AbstractAction {
+		/**
+		 * 
+		 */
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			editor.getGraphComponent().zoomIn();
+		}
+	}
+
+	public static class ZoomOUT extends AbstractAction {
+		/**
+		 * 
+		 */
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			editor.getGraphComponent().zoomOut();
+		}
+	}
+
+	public static class SCXMLDelete extends DeleteAction {
+
+		public SCXMLDelete() {
+			super("delete");
+		}
+
+		@Override
+		public void actionPerformed(ActionEvent e) {
+			SCXMLGraphEditor editor = getEditor(e);
+			SCXMLGraphComponent graphComponent = editor.getGraphComponent();
+			SCXMLGraph graph = graphComponent.getGraph();
+			Object[] cells = graph.getDeletableCells(graph.addAllEdges(graph.getSelectionCells()));
+			boolean cannotDelete = false;
+			if (cells != null && cells.length > 0) {
+				for (Object cell : cells) {
+					if (editor.isCellBeingEdited((mxCell) cell)) {
+						cannotDelete = true;
+						break;
+					}
+				}
+			}
+			if (cannotDelete) {
+				JOptionPane.showMessageDialog(editor.getGraphComponent(),
+						"Some elements are being edited. Please close all edit dialogs before deleting an element.\nSome may be indirectly deleted elements (e.g. edges connecting to a node being deleted)",
+						mxResources.get("error"), JOptionPane.ERROR_MESSAGE);
+			} else {
+				super.actionPerformed(e);
+			}
+		}
+
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorMenuBar.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorMenuBar.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorMenuBar.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,90 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.awt.event.KeyEvent;
+import java.io.File;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Box;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.TransferHandler;
+
+import com.mxgraph.swing.util.mxGraphActions;
+import com.mxgraph.util.mxResources;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.HistoryAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SCXMLDelete;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.ToggleDisplayOutsourcedContent;
+
+public class SCXMLEditorMenuBar extends JMenuBar {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 4060203894740766714L;
+	private static final String PREFERENCE_LASTFILE_KEY = "LASTFILE_";
+	SCXMLGraphEditor editor;
+
+	public String getLastOpenedDir() {
+		String fileName = editor.preferences.get(PREFERENCE_LASTFILE_KEY, null);
+		if (fileName != null) {
+			File file = new File(fileName);
+			return file.getParent();
+		}
+		return null;
+	}
+
+	@SuppressWarnings("serial")
+	public SCXMLEditorMenuBar(final SCXMLGraphEditor ed) {
+		this.editor = ed;
+		JMenu menu = null;
+
+		// Creates the edit menu
+		menu = add(new JMenu(mxResources.get("edit")));
+		menu.setMnemonic(KeyEvent.VK_E);
+
+		AbstractAction internalAction = new HistoryAction(true);
+		Action externalAction = editor.bind(mxResources.get("undo"), internalAction,
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/undo.gif");
+		menu.add(externalAction);
+		editor.setUndoMenuAction(externalAction);
+		internalAction = new HistoryAction(false);
+		externalAction = editor.bind(mxResources.get("redo"), internalAction,
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/redo.gif");
+		menu.add(externalAction);
+		editor.setRedoMenuAction(externalAction);
+
+		menu.addSeparator();
+
+		menu.add(editor.bind(mxResources.get("cut"), TransferHandler.getCutAction(),
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/cut.gif"));
+		menu.add(editor.bind(mxResources.get("copy"), TransferHandler.getCopyAction(),
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/copy.gif"));
+		menu.add(editor.bind(mxResources.get("paste"), TransferHandler.getPasteAction(),
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/paste.gif"));
+
+		menu.addSeparator();
+
+		menu.add(editor.bind(mxResources.get("delete"), new SCXMLDelete(),
+				"/jp/go/aist/rtm/toolscommon/fsm/editor/images/delete.gif"));
+
+		menu.addSeparator();
+
+		menu.add(editor.bind(mxResources.get("selectAll"), mxGraphActions.getSelectAllAction()));
+		menu.add(editor.bind(mxResources.get("selectNone"), mxGraphActions.getSelectNoneAction()));
+
+		menu = add(new JMenu(mxResources.get("view")));
+		menu.setMnemonic(KeyEvent.VK_V);
+		internalAction = new ToggleDisplayOutsourcedContent();
+		JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(
+				externalAction = editor.bind(mxResources.get("toggleDisplayContentOutsourced"), internalAction));
+		menu.add(menuItem);
+		editor.setDisplayOutsourcedContentMenuItem(menuItem);
+		editor.setDisplayOfOutsourcedContentSelected(editor.isDisplayOfOutsourcedContentSelected());
+
+		add(Box.createHorizontalGlue());
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorPopupMenu.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorPopupMenu.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLEditorPopupMenu.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,226 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.awt.Point;
+import java.io.File;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxICell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.view.mxCellState;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.OutSource;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLImportExport;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.AddAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.AddCornerToEdgeAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.DoLayoutAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.EditEdgeAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.EditNodeAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.OpenAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.RemoveCornerToEdgeAction;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsCluster;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsFinal;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsHistory;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsInitial;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsParallel;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.SetNodeAsRestricted;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.ToggleDisplayOutsourcedContentInNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLEditorActions.ToggleWithTargetAction;
+
+public class SCXMLEditorPopupMenu extends JPopupMenu {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -3132749140550242191L;
+
+	public SCXMLEditorPopupMenu(SCXMLGraphEditor editor, Point mousePt, Point graphPt, Point screenCoord) {
+		SCXMLGraphComponent gc = editor.getGraphComponent();
+		mxCell c = (mxCell) gc.getCellAt(graphPt.x, graphPt.y);
+		SCXMLGraph graph = gc.getGraph();
+		mxIGraphModel model = graph.getModel();
+
+		boolean inOutsourcedNode = false;
+		// if the cell is not editable set it back to null so the menu doesn't
+		// allow editing.
+		inOutsourcedNode = (c != null) && !graph.isCellEditable(c);
+
+		Point unscaledGraphPoint = gc.unscaledGraphCoordinates(graphPt);
+
+		// edit node/transition (change text accordingly to type of element
+		// under cursor)
+		if (c != null) {
+			if (c.isEdge()) {
+				SCXMLNode source = (SCXMLNode) c.getSource().getValue();
+				if (!inOutsourcedNode) {
+					// for an edge, find out if the pointer is on a control
+					// point, or not.
+					// if on a control point find out if it's the beginning or
+					// end of the endge.
+					// -add control point if not on a control point
+					// -remove control point if on one that is neither the
+					// beginning nor the end.
+					if (!((source != null) && (source.isHistoryNode()))) {
+						add(editor.bind(mxResources.get("editEdge"), new EditEdgeAction(c, screenCoord)));
+						addSeparator();
+					}
+					// if the edge is not a loop you can add/remove corners
+					if (c.getSource() != c.getTarget()) {
+						mxCellState cellState = graph.getView().getState(c);
+						int index;
+						int lastIndex = cellState.getAbsolutePointCount() - 1;
+						if ((index = cellState.getIndexOfEdgePointAt(graphPt.x, graphPt.y, gc.getTolerance())) == -1) {
+							int indexOfNewPoint = cellState.getIndexOfNewPoint(graphPt.x, graphPt.y, gc.getTolerance())
+									- 1;
+							if (indexOfNewPoint >= 0) {
+								add(editor.bind(mxResources.get("addCorner"),
+										new AddCornerToEdgeAction(c, unscaledGraphPoint, graphPt, indexOfNewPoint)));
+							}
+						} else if (index > 0 && index < lastIndex)
+							add(editor.bind(mxResources.get("removeCorner"),
+									new RemoveCornerToEdgeAction(c, index - 1)));
+					} else {
+						JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(
+								editor.bind(mxResources.get("toggleWithTarget"), new ToggleWithTargetAction(c)));
+						menuItem.setSelected(((SCXMLEdge) (c.getValue())).isCycleWithTarget());
+						add(menuItem);
+					}
+				}
+			} else if (c.isVertex()) {
+				boolean nodeIsOutsourced = ((SCXMLNode) (c.getValue())).isOutsourcedNode();
+				boolean nodeIsFake = ((SCXMLNode) (c.getValue())).getFake();
+				mxICell parent = c.getParent();
+				boolean isHistoryNode = ((SCXMLNode) (c.getValue())).isHistoryNode();
+				boolean isParallelNode = ((SCXMLNode) (c.getValue())).isParallel();
+				boolean isFinalNode = ((SCXMLNode) (c.getValue())).isFinal();
+				boolean isClusterNode = ((SCXMLNode) (c.getValue())).isClusterNode();
+				if (!inOutsourcedNode) {
+					// add node in case the cell under the pointer is a swimlane
+					boolean addNodeEnabled = graph.isSwimlane(c) && (editor.getCurrentFileIO() != null);
+					add(editor.bind(mxResources.get("addNode"), new AddAction(mousePt, c))).setEnabled(addNodeEnabled);
+					/*
+					 * Add new, restricted node
+					 */
+					if (editor.getRestrictedStatesConfig() != null) {
+						JMenu addRestrictedNodeMenu = new JMenu(mxResources.get("addRestrictedNode"));
+						addRestrictedNodeMenu.setEnabled(addNodeEnabled);
+						List<RestrictedState> restrictedStatesList = editor.getRestrictedStatesConfig()
+								.getRestrictedState();
+						if (restrictedStatesList != null) {
+							for (RestrictedState restrictedState : restrictedStatesList) {
+								JMenuItem addRestrictedStateMenuItem = new JMenuItem(
+										editor.bind(restrictedState.getName(), new AddAction(mousePt, c)));
+								addRestrictedStateMenuItem.setEnabled(addNodeEnabled);
+								addRestrictedStateMenuItem.setToolTipText(restrictedState.getDocumentation());
+								addRestrictedNodeMenu.add(addRestrictedStateMenuItem);
+							}
+						}
+						add(addRestrictedNodeMenu);
+					}
+
+					addSeparator();
+					mxCell root = SCXMLImportExport.followUniqueDescendantLineTillSCXMLValueIsFound(model);
+					add(editor.bind(mxResources.get("editNode"), new EditNodeAction(c, root, screenCoord)));
+					if (c != root) {
+						if (!nodeIsFake) {
+							if (!isHistoryNode)
+								addSeparator();
+							JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(
+									editor.bind(mxResources.get("setAsInitialNode"), new SetNodeAsInitial(c)));
+							menuItem.setSelected(((SCXMLNode) (c.getValue())).isInitial());
+							add(menuItem);
+							if (!isHistoryNode) {
+								menuItem = new JCheckBoxMenuItem(
+										editor.bind(mxResources.get("setAsFinalNode"), new SetNodeAsFinal(c)));
+								menuItem.setSelected(((SCXMLNode) (c.getValue())).isFinal());
+								menuItem.setEnabled(!((SCXMLNode) (c.getValue())).isRestricted());
+								add(menuItem);
+								menuItem = new JCheckBoxMenuItem(
+										editor.bind(mxResources.get("setAsClusterNode"), new SetNodeAsCluster(c)));
+								menuItem.setSelected(((SCXMLNode) (c.getValue())).isClusterNode());
+								menuItem.setEnabled(!((SCXMLNode) (c.getValue())).isOutsourcedNode());
+								add(menuItem);
+//								menuItem = new JCheckBoxMenuItem(
+//										editor.bind(mxResources.get("setAsParallelNode"), new SetNodeAsParallel(c)));
+//								menuItem.setSelected(((SCXMLNode) (c.getValue())).isParallel());
+								add(menuItem);
+
+								/*
+								 * Toggle node as restricted
+								 */
+								if (editor.getRestrictedStatesConfig() != null) {
+									JMenu toggleRestrictedMenu = new JMenu(mxResources.get("setAsRestrictedNode"));
+									List<RestrictedState> restrictedStatesList = editor.getRestrictedStatesConfig()
+											.getRestrictedState();
+									SCXMLNode tempNode = (SCXMLNode) c.getValue();
+									toggleRestrictedMenu.setEnabled(!tempNode.isFinal());
+									if (restrictedStatesList != null) {
+										for (RestrictedState restrictedState : restrictedStatesList) {
+											menuItem = new JCheckBoxMenuItem(
+													editor.bind(restrictedState.getName(), new SetNodeAsRestricted(c)));
+											menuItem.setToolTipText(restrictedState.getDocumentation());
+											menuItem.setSelected(tempNode.isRestricted(restrictedState));
+											menuItem.setEnabled(!tempNode.isFinal());
+											toggleRestrictedMenu.add(menuItem);
+										}
+									}
+									add(toggleRestrictedMenu);
+								}
+							}
+							if ((parent != root) && ((SCXMLNode) parent.getValue()).isClusterNode()) {
+								if (!isParallelNode && !isClusterNode && !isFinalNode) {
+									addSeparator();
+									menuItem = new JCheckBoxMenuItem(editor.bind(
+											mxResources.get("setAsDeepHistoryNode"), new SetNodeAsHistory(c, true)));
+									menuItem.setSelected(((SCXMLNode) (c.getValue())).isDeepHistory());
+									add(menuItem);
+									menuItem = new JCheckBoxMenuItem(
+											editor.bind(mxResources.get("setAsShallowHistoryNode"),
+													new SetNodeAsHistory(c, false)));
+									menuItem.setSelected(((SCXMLNode) (c.getValue())).isShallowHistory());
+									add(menuItem);
+								}
+							}
+						}
+					}
+				}
+				if (nodeIsOutsourced) {
+					JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(
+							editor.bind(mxResources.get("toggleViewOutsourcedContent"),
+									new ToggleDisplayOutsourcedContentInNode(c)));
+					menuItem.setSelected(c.getChildCount() > 0);
+					add(menuItem);
+					if (c.getChildCount() > 0) {
+						JMenuItem itemMenu = new JMenuItem(editor.bind(mxResources.get("refreshViewOutsourcedContent"),
+								new ToggleDisplayOutsourcedContentInNode(c, true)));
+						add(itemMenu);
+					}
+
+					SCXMLNode value = ((SCXMLNode) (c.getValue()));
+					OutSource src = value.getSRC();
+					File f = editor.getThisFileInCurrentDirectory(src.getLocation());
+					Action itemAction = editor.bind(mxResources.get("openInNewWindow") + " " + f.getName(),
+							new OpenAction(f, true));
+					JMenuItem itemMenu = new JMenuItem(itemAction);
+					add(itemMenu);
+				}
+				addSeparator();
+				add(editor.bind(mxResources.get("doRecursiveLayout"), new DoLayoutAction(graph, c, -1)));
+				add(editor.bind(mxResources.get("doSimpleLayout"), new DoLayoutAction(graph, c, 0)));
+			}
+		} else {
+			add(editor.bind(mxResources.get("editNodeEdge"), null)).setEnabled(false);
+		}
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraph.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraph.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraph.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,922 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.JOptionPane;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGeometry;
+import com.mxgraph.model.mxICell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.util.StringUtils;
+import com.mxgraph.util.mxEvent;
+import com.mxgraph.util.mxEventObject;
+import com.mxgraph.util.mxPoint;
+import com.mxgraph.util.mxRectangle;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.view.mxCellState;
+import com.mxgraph.view.mxGraph;
+
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState;
+import jp.go.aist.rtm.toolscommon.fsm.config.SCXMLConstraints.RestrictedState.PossibleEvent;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor.EditorStatus;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLImportExport;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils.XMLUtils;
+
+/**
+ * A graph that creates new edges from a given template edge.
+ */
+public class SCXMLGraph extends mxGraph {
+	/**
+	 * Holds the shared number formatter.
+	 * 
+	 * @see NumberFormat#getInstance()
+	 */
+	public static final NumberFormat numberFormat = NumberFormat.getInstance();
+	private SCXMLGraphEditor editor;
+	private HashSet<Object> immovable = new HashSet<Object>();
+	private HashSet<Object> undeletable = new HashSet<Object>();
+	private HashSet<Object> uneditable = new HashSet<Object>();
+	private HashSet<mxCell> outsourced = new HashSet<mxCell>();
+	private HashMap<mxCell, HashSet<mxCell>> original2clones = new HashMap<mxCell, HashSet<mxCell>>();
+	private HashMap<String, SCXMLImportExport> ourced = new HashMap<String, SCXMLImportExport>();
+
+	private boolean isReadOnly = false;
+	public void setReadOnly(boolean value) {
+		this.isReadOnly = value;
+	}
+	
+	public void addToOutsourced(mxCell n) {
+		assert (((SCXMLNode) n.getValue()).isOutsourcedNode());
+		outsourced.add(n);
+	}
+
+	public void removeFromOutsourced(mxCell n) {
+		outsourced.remove(n);
+	}
+
+	public HashSet<mxCell> getOutsourcedNodes() {
+		return outsourced;
+	}
+
+	public HashMap<mxCell, HashSet<mxCell>> getOriginal2Clones() {
+		return original2clones;
+	}
+
+	public void clearOutsourcedIndex() {
+		outsourced.clear();
+	}
+
+	public void setCellAsMovable(Object cell, Boolean m) {
+		if (m)
+			immovable.remove(cell);
+		else
+			immovable.add(cell);
+	}
+
+	public void setCellAsDeletable(Object cell, Boolean d) {
+		if (d)
+			undeletable.remove(cell);
+		else
+			undeletable.add(cell);
+	}
+
+	public void setCellAsEditable(Object cell, boolean e) {
+		if (e)
+			uneditable.remove(cell);
+		else
+			uneditable.add(cell);
+	}
+
+	public void setCellAsConnectable(Object cell, boolean c) {
+		if (cell instanceof mxCell)
+			((mxCell) cell).setConnectable(c);
+	}
+
+	@Override
+	public mxRectangle getPaintBounds(Object[] cells) {
+		return getBoundsForCells(cells, false, true, true);
+	}
+
+	@Override
+	public boolean isCellFoldable(Object cell, boolean collapse) {
+		return isSwimlane(cell);
+	}
+
+	@Override
+	public boolean isValidDropTarget(Object cell, Object[] cells) {
+		return (cell != null) && isSwimlane(cell);
+	}
+
+	@Override
+	public String validateCell(Object cell, Hashtable<Object, Object> context) {
+		EditorStatus status = getEditor().getStatus();
+		SCXMLGraphComponent gc = getEditor().getGraphComponent();
+		String warnings = "";
+		if (isCellEditable(cell) && (status == EditorStatus.EDITING)) {
+			if (model.isVertex(cell)) {
+				mxCell node = (mxCell) cell;
+
+				mxICell parent = node.getParent();
+				if ((parent != null) && (parent.getValue() instanceof SCXMLNode)) {
+					mxCellState stateChild = view.getState(cell);
+					// mxCellState stateParent = view.getState(parent);
+					// System.out.println(node+" "+parent+" "+stateChild+"
+					// "+stateParent);
+					Object container = gc.getCellAt((int) stateChild.getCenterX(), (int) stateChild.getCenterY(), true,
+							null, cell, true);
+					// System.out.println(container);
+					if (container != parent)
+						warnings += node + " is not graphically contained in its parent " + parent + ".\n";
+				}
+
+				SCXMLNode nodeValue = (SCXMLNode) node.getValue();
+				String nodeValueID = nodeValue.getID();
+				if(nodeValue.isRoot()) {
+					nodeValueID = nodeValue.getName();
+				}
+
+				if (nodeValueID.matches(".*[\\s]+.*"))
+					warnings += "node name contains spaces.\n";
+				// check if the executable content is parsable xml
+				String error = XMLUtils.isParsableXMLString(nodeValue.getOnEntry());
+				if (error != null)
+					warnings += "OnEntry content of node " + nodeValueID + " caused a parser error: " + error + "\n";
+				error = XMLUtils.isParsableXMLString(nodeValue.getOnExit());
+				if (error != null)
+					warnings += "OnExit content of node " + nodeValueID + " caused a parser error: " + error + "\n";
+				error = XMLUtils.isParsableXMLString(nodeValue.getOnInitialEntry());
+				if (error != null)
+					warnings += "On initial content of node " + nodeValueID + " caused a parser error: " + error + "\n";
+				error = XMLUtils.isParsableXMLString(nodeValue.getDoneData());
+				if (error != null)
+					warnings += "Done data of node " + nodeValueID + " caused a parser error: " + error + "\n";
+				error = XMLUtils.isParsableXMLString(nodeValue.getDatamodel());
+				if (error != null)
+					warnings += "Data model of node " + nodeValueID + " caused a parser error: " + error + "\n";
+				if (!nodeValue.isOutsourcedNode()) {
+					// check if the namespace has been included
+					String SCXMLid = nodeValueID;
+					int pos = SCXMLid.indexOf(':');
+					boolean namespaceGood = true;
+					String namespace = "";
+					if (pos > 0) {
+						namespaceGood = false;
+						namespace = SCXMLid.substring(0, pos);
+						mxIGraphModel model = getModel();
+						mxCell root = SCXMLImportExport.followUniqueDescendantLineTillSCXMLValueIsFound(model);
+						SCXMLNode rootValue = (SCXMLNode) root.getValue();
+						String[] namespaces = rootValue.getNamespace().split("\n");
+
+						Pattern p = Pattern.compile("^[\\s]*xmlns:([^\\s=:]+)[\\s]*=.*$");
+						for (String ns : namespaces) {
+							Matcher m = p.matcher(ns);
+							if (m.matches() && (m.groupCount() == 1)) {
+								ns = m.group(1);
+								if (namespace.equals(ns)) {
+									namespaceGood = true;
+									break;
+								}
+							}
+						}
+					}
+					if (!namespaceGood)
+						warnings += "Namespace '" + namespace + "' is used but not defined.\n";
+				}
+				if (!StringUtils.isEmptyString(nodeValueID)) {
+					SCXMLNode parentValue = null;
+					if (parent == null || ((parentValue = (SCXMLNode) parent.getValue()) == null)
+							|| !parentValue.getFake() || !nodeValueID.equals(SCXMLNode.ROOTID)) {
+						if (gc.isSCXMLNodeAlreadyThere(nodeValue)) {
+							warnings += "duplicated node name: " + nodeValueID + "\n";
+						} else {
+							gc.addSCXMLNode(nodeValue, node);
+						}
+					}
+				}
+
+				// for issue #74, not ideal solution. should be done on the
+				// listener of the changes but too many updates are sent there.
+				int edges = node.getEdgeCount();
+				for (int i = 0; i < edges; i++) {
+					mxCell e = (mxCell) node.getEdgeAt(i);
+
+					if (e != null && e.getValue() != null && e.getValue() instanceof SCXMLEdge) {
+						SCXMLEdge v = (SCXMLEdge) e.getValue();
+						if (e.getSource() == node) {
+							// outgoing edge from node
+							if (!v.getSCXMLSource().equals(nodeValueID))
+								v.setSCXMLSource(nodeValueID);
+						} else if (e.getTarget() == node) {
+							// incoming edge into node
+							ArrayList<String> ts = v.getSCXMLTargets();
+							boolean updated = false, found = false;
+							if (ts != null) {
+								Iterator<String> it = ts.iterator();
+								while (it.hasNext()) {
+									String tid = it.next();
+									if (gc.getSCXMLNodeForID(tid) == null) {
+										it.remove();
+										updated = true;
+									}
+									if (!found && tid.equals(nodeValueID))
+										found = true;
+								}
+								if (!found) {
+									updated = true;
+									ts.add(nodeValueID);
+								}
+								if (updated)
+									v.setSCXMLTargets(ts);
+							}
+						}
+					}
+				}
+
+				// Restricted node should have at least one related event
+				if (nodeValue.isRestricted()) {
+					List<RestrictedState> restrictionsOnNode = nodeValue.getRestrictedStates();
+					Object[] allOutgoingEdges = editor.getGraphComponent().getGraph().getAllOutgoingEdges(node);
+					List<String> existingEventsOnSourceNode = new LinkedList<String>();
+					for (Object object : allOutgoingEdges) {
+						SCXMLEdge tempEdge = (SCXMLEdge) ((mxCell) object).getValue();
+						existingEventsOnSourceNode.add(tempEdge.getEvent());
+					}
+					for (RestrictedState restrictedState : restrictionsOnNode) {
+						List<String> possibleEventNames = new LinkedList<String>();
+						for (PossibleEvent possibleEvent : restrictedState.getPossibleEvent()) {
+							possibleEventNames.add(possibleEvent.getName());
+						}
+						possibleEventNames.retainAll(existingEventsOnSourceNode);
+						if (possibleEventNames.isEmpty()) {
+							warnings += "There is no event for restriction [" + restrictedState.getName()
+									+ "] on node [" + nodeValue.getID() + "]\n";
+						}
+					}
+				}
+				if (nodeValue.isClusterNode()) {
+					int numInitialChildren = 0;
+					int numOutGoingTransitions = 0;
+					int numChildren = node.getChildCount();
+					for (int i = 0; i < numChildren; i++) {
+						mxCell c = (mxCell) node.getChildAt(i);
+						if (c.isVertex()) {
+							SCXMLNode cValue = (SCXMLNode) c.getValue();
+							if (cValue.isInitial()) {
+								numInitialChildren++;
+							}
+							if ((numInitialChildren > 0) && nodeValue.isParallel())
+								warnings += "Parallel nodes (" + nodeValueID
+										+ ") don't support a child marked as intiial.\n";
+							if (numInitialChildren > 1)
+								warnings += "More than 1 children of " + nodeValueID + " is marked as initial.\n";
+						} else {
+							if (nodeValue.isHistoryNode()) {
+								if (c.getSource().equals(node)) {
+									numOutGoingTransitions++;
+									if (numOutGoingTransitions > 1)
+										warnings += "History node '" + nodeValueID
+												+ "' has more than 1 outgoing transition.\n";
+									if (!StringUtils.isEmptyString(((SCXMLEdge) c.getValue()).getCondition())
+											|| !StringUtils.isEmptyString(((SCXMLEdge) c.getValue()).getEvent())) {
+										warnings += "Outgoing transition of history node has non null event or condition.\n";
+									}
+								}
+							}
+						}
+					}
+				}
+			} else if (model.isEdge(cell)) {
+				// check that source and target have non null SCXML ids.
+				mxCell edge = (mxCell) cell;
+				SCXMLEdge edgeValue = (SCXMLEdge) edge.getValue();
+				if ((edge.getSource() == null) || (edge.getTarget() == null))
+					warnings += "unconnected edge.\n";
+				String error = XMLUtils.isParsableXMLString(edgeValue.getExe());
+				SCXMLNode source = (SCXMLNode) edge.getSource().getValue();
+				SCXMLNode target = (SCXMLNode) edge.getTarget().getValue();
+				if (edgeValue != null) {
+					if (edgeValue.getSCXMLSource() != null) {
+						if (!edgeValue.getSCXMLSource().equals(source.getID()))
+							warnings += " edge with incorrect SOURCE property.\n";
+					}
+					if (edgeValue.getSCXMLTargets() != null) {
+						boolean found = false;
+						for (String t : edgeValue.getSCXMLTargets()) {
+							if (t.equals(target.getID())) {
+								found = true;
+								break;
+							}
+						}
+						if (!found)
+							warnings += " edge with incorrect TARGETS property.\n";
+					}
+				}
+				if (error != null)
+					warnings += "Executable content of one edge from " + source.getID() + " to " + target.getID()
+							+ " caused a parser error: " + error + "\n";
+				if (StringUtils.isEmptyString(source.getID()) || StringUtils.isEmptyString(target.getID())) {
+					warnings += "target and source of a transition must have not empty name.\n";
+				}
+				Object lca = model.getNearestCommonAncestor(edge.getSource(), edge.getTarget());
+				if (lca != null && lca instanceof mxCell) {
+					SCXMLNode scxmlLCA = (SCXMLNode) ((mxCell) lca).getValue();
+					if (scxmlLCA.isParallel())
+						warnings += source.getID() + " and " + target.getID()
+								+ " are (descendats of) siblings of a parallel node (" + scxmlLCA.getID() + ").\n";
+				}
+
+				String edgeEventName = edgeValue.getEvent();
+				// check that edge event is allowed by the restriction on the
+				// source node
+				if (source.isRestricted()) {
+					boolean isEventPossible = false;
+					for (PossibleEvent possibleEvent : source.getPossibleEvents()) {
+						if (possibleEvent.getName().equals(edgeEventName)) {
+							isEventPossible = true;
+						}
+					}
+					if (!isEventPossible) {
+						warnings += "Invalid event from " + source.getID() + " to " + target.getID() + "!\n";
+					}
+				}
+
+				// check if the source node is final
+				if (source.isFinal()) {
+					warnings += "Outgoing edge from a final node!\n";
+				}
+			}
+		}
+		if (StringUtils.isEmptyString(warnings))
+			return null;
+		else
+			return warnings;
+	}
+
+	@Override
+	public boolean isCellMovable(Object cell) {
+		return isCellsMovable() && !isCellLocked(cell) && !immovable.contains(cell);
+	}
+
+	@Override
+	public boolean isCellDeletable(Object cell) {
+		return isCellsDeletable() && !undeletable.contains(cell);
+	}
+
+	@Override
+	public boolean isCellEditable(Object cell) {
+		return isCellsEditable() && !uneditable.contains(cell);
+	}
+
+	@Override
+	public RootStrength vertexShouldBeRoot(Object cell, Object parent, boolean invert) {
+		if (cell instanceof mxCell) {
+			mxCell c = (mxCell) cell;
+			Object v = c.getValue();
+			if ((v != null) && (v instanceof SCXMLNode)) {
+				return new RootStrength((invert) ? ((SCXMLNode) v).isFinal() : ((SCXMLNode) v).isInitial(), 0);
+			} else
+				return super.vertexShouldBeRoot(cell, parent, invert);
+		} else
+			return super.vertexShouldBeRoot(cell, parent, invert);
+	}
+
+	@Override
+	public Object insertEdge(Object parent, String id, Object value, Object source, Object target) {
+		if(isReadOnly) return null;
+		// System.out.println("insert edge: parent:"+parent+" value:"+value+"
+		// source:"+source+" target:"+target);
+		try {
+			int size = getAllOutgoingEdges(source).length;
+			if (value == null) {
+				value = getEditor().getCurrentFileIO().buildEdgeValue();
+			} else if (!(value instanceof SCXMLEdge)) {
+				System.out.println(
+						"WARNING: non NULL and non SCXMLEdge value passed for new edge (insertEdge in SCXMLGraph)");
+				value = getEditor().getCurrentFileIO().buildEdgeValue();
+			}
+			updateConnectionOfSCXMLEdge((SCXMLEdge) value, source, target, null);
+			if (((SCXMLEdge) value).getOrder() == null)
+				((SCXMLEdge) value).setOrder(size);
+			Object edge = insertEdge(parent, ((SCXMLEdge) value).getInternalID(), value, source, target, "");
+			setCellStyle(((SCXMLEdge) value).getStyle((mxCell) edge), edge);
+			return edge;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	@Override
+	public void askToUseThisEdgeValue(Object clone, Object otherEdgeValue) {
+		int answer = JOptionPane.showConfirmDialog(editor, mxResources.get("createAsNewTargetForMultitarget"),
+				mxResources.get("edgeCreationOption"), JOptionPane.YES_NO_OPTION);
+		if (answer == JOptionPane.YES_OPTION) {
+			model.setValue(clone, otherEdgeValue);
+		} else {
+			SCXMLEdge value = (SCXMLEdge) model.getValue(clone);
+			value.getSCXMLTargets().clear();
+		}
+	}
+
+	@Override
+	public Object[] cloneCells(Object[] cells, boolean allowInvalidEdges, Map<Object, Object> mapping) {
+		Object[] clones = null;
+
+		if (cells != null) {
+			Collection<Object> tmp = new LinkedHashSet<Object>(cells.length);
+			tmp.addAll(Arrays.asList(cells));
+
+			if (!tmp.isEmpty()) {
+				double scale = view.getScale();
+				mxPoint trans = view.getTranslate();
+				clones = model.cloneCells(cells, true, mapping);
+
+				for (int i = 0; i < cells.length; i++) {
+					Object newValue = ((SCXMLImportExport) getEditor().getCurrentFileIO())
+							.cloneValue(((mxCell) clones[i]).getValue());
+					((mxCell) clones[i]).setValue(newValue);
+					if (!allowInvalidEdges && model.isEdge(clones[i]) && getEdgeValidationError(clones[i],
+							model.getTerminal(clones[i], true), model.getTerminal(clones[i], false)) != null) {
+						clones[i] = null;
+					} else {
+						mxGeometry g = model.getGeometry(clones[i]);
+
+						if (g != null) {
+							mxCellState state = view.getState(cells[i]);
+							mxCellState pstate = view.getState(model.getParent(cells[i]));
+
+							if (state != null && pstate != null) {
+								double dx = pstate.getOrigin().getX();
+								double dy = pstate.getOrigin().getY();
+
+								if (model.isEdge(clones[i])) {
+									// Checks if the source is cloned or sets
+									// the terminal point
+									Object src = model.getTerminal(cells[i], true);
+
+									while (src != null && !tmp.contains(src)) {
+										src = model.getParent(src);
+									}
+
+									if (src == null) {
+										mxPoint pt = state.getAbsolutePoint(0);
+										g.setTerminalPoint(new mxPoint(pt.getX() / scale - trans.getX(),
+												pt.getY() / scale - trans.getY()), true);
+									}
+
+									// Checks if the target is cloned or sets
+									// the terminal point
+									Object trg = model.getTerminal(cells[i], false);
+
+									while (trg != null && !tmp.contains(trg)) {
+										trg = model.getParent(trg);
+									}
+
+									if (trg == null) {
+										mxPoint pt = state.getAbsolutePoint(state.getAbsolutePointCount() - 1);
+										g.setTerminalPoint(new mxPoint(pt.getX() / scale - trans.getX(),
+												pt.getY() / scale - trans.getY()), false);
+									}
+
+									// Translates the control points
+									List<mxPoint> points = g.getPoints();
+
+									if (points != null) {
+										Iterator<mxPoint> it = points.iterator();
+
+										while (it.hasNext()) {
+											mxPoint pt = it.next();
+											pt.setX(pt.getX() + dx);
+											pt.setY(pt.getY() + dy);
+										}
+									}
+								} else {
+									g.setX(g.getX() + dx);
+									g.setY(g.getY() + dy);
+								}
+							}
+						}
+					}
+				}
+			} else {
+				clones = new Object[] {};
+			}
+		}
+
+		return clones;
+	}
+
+	@Override
+	public void cellsRemoved(Object[] cells) {
+		if (cells != null && cells.length > 0) {
+			double scale = view.getScale();
+			mxPoint tr = view.getTranslate();
+
+			model.beginUpdate();
+			try {
+				Collection<Object> cellSet = new HashSet<Object>();
+				cellSet.addAll(Arrays.asList(cells));
+				for (int i = 0; i < cells.length; i++) {
+					mxCell cell = (mxCell) cells[i];
+					// Disconnects edges which are not in cells
+					Object[] edges = getConnections(cell);
+
+					for (int j = 0; j < edges.length; j++) {
+						if (!cellSet.contains(edges[j])) {
+							mxGeometry geo = model.getGeometry(edges[j]);
+
+							if (geo != null) {
+								mxCellState state = view.getState(edges[j]);
+
+								if (state != null) {
+									geo = (mxGeometry) geo.clone();
+									boolean source = view.getVisibleTerminal(edges[j], true) == cell;
+									int n = (source) ? 0 : state.getAbsolutePointCount() - 1;
+									mxPoint pt = state.getAbsolutePoint(n);
+
+									geo.setTerminalPoint(
+											new mxPoint(pt.getX() / scale - tr.getX(), pt.getY() / scale - tr.getY()),
+											source);
+									model.setTerminal(edges[j], null, source);
+									model.setGeometry(edges[j], geo);
+								}
+							}
+						}
+					}
+					model.remove(cell);
+					if (cell.isEdge()) {
+						// check if this edge has a source with other outgoing
+						// edges and
+						// the source is not going to be deleted. In that case
+						// reorder the
+						// remaining outgoing edges closing the potential hole
+						// that
+						// removing this edge may be causing.
+						mxCell source = (mxCell) cell.getSource();
+						if (!cellSet.contains(source) && getAllOutgoingEdges(source).length > 0) {
+							SCXMLChangeHandler.addStateOfNodeInCurrentEdit(source, model);
+							reOrderOutgoingEdges(source);
+						}
+						// if deleted edge was part of multitarget edge, remove
+						// the target pointed by this deleted edge.
+						Collection<Object> siblings = getEditor().getGraphComponent().getSiblingsOfCell(cell);
+						if (siblings.size() > 1) {
+							SCXMLEdge edgeValue = (SCXMLEdge) cell.getValue();
+							SCXMLNode targetNode = (SCXMLNode) cell.getTarget().getValue();
+							assert (edgeValue.getSCXMLTargets().contains(targetNode.getID()));
+							edgeValue.getSCXMLTargets().remove(targetNode.getID());
+						}
+					}
+				}
+				fireEvent(new mxEventObject(mxEvent.CELLS_REMOVED, "cells", cells));
+			} finally {
+				model.endUpdate();
+			}
+		}
+	}
+
+	public void reOrderOutgoingEdges(mxCell source) {
+		HashMap<Integer, ArrayList<SCXMLEdge>> pos = new HashMap<Integer, ArrayList<SCXMLEdge>>();
+		int min = 0, max = 0;
+		for (Object s : getAllOutgoingEdges(source)) {
+			mxCell c = (mxCell) s;
+			SCXMLEdge v = (SCXMLEdge) c.getValue();
+			int o = v.getOrder();
+			ArrayList<SCXMLEdge> l = pos.get(o);
+			if (l == null)
+				pos.put(o, l = new ArrayList<SCXMLEdge>());
+			l.add(v);
+			if (o < min)
+				min = o;
+			if (o > max)
+				max = o;
+		}
+		int neworder = 0;
+		for (int i = min; i <= max; i++) {
+			if (pos.containsKey(i)) {
+				for (SCXMLEdge e : pos.get(i)) {
+					e.setOrder(neworder++);
+				}
+			}
+		}
+	}
+
+	@Override
+	public Object connectCell(Object edge, Object terminal, boolean source) {
+		// System.out.println("connect cell: edge:"+edge+" terminal:"+terminal+"
+		// source:"+source);
+		model.beginUpdate();
+		try {
+			SCXMLChangeHandler.addStateOfEdgeInCurrentEdit((mxCell) edge, model);
+			SCXMLGraphComponent gc = (SCXMLGraphComponent) getEditor().getGraphComponent();
+			Collection<Object> siblings = gc.getSiblingsOfCell(edge);
+			if (siblings.size() > 1) {
+				if (source) {
+					JOptionPane.showMessageDialog(editor, "Detaching edge from multitarget edge.",
+							mxResources.get("warning"), JOptionPane.WARNING_MESSAGE);
+					SCXMLEdge oldValue = (SCXMLEdge) ((mxCell) edge).getValue();
+					SCXMLEdge newValue = (SCXMLEdge) ((SCXMLImportExport) getEditor().getCurrentFileIO())
+							.cloneValue(oldValue);
+					((mxCell) edge).setValue(newValue);
+					SCXMLNode targetNodeValue = (SCXMLNode) model.getValue(model.getTerminal(edge, false));
+					oldValue.getSCXMLTargets().remove(targetNodeValue.getID());
+					ArrayList<String> targets = newValue.getSCXMLTargets();
+					targets.clear();
+					targets.add(targetNodeValue.getID());
+				}
+			}
+			// connect edge to new terminal (source or target)
+			Object previous = model.getTerminal(edge, source);
+			cellConnected(edge, terminal, source);
+			fireEvent(new mxEventObject(mxEvent.CONNECT_CELL, "edge", edge, "terminal", terminal, "source", source,
+					"previous", previous));
+			// update the order of edges in case we move the source of an edge
+			// from one node to another.
+			if (source) {
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit((mxCell) previous, model);
+				reOrderOutgoingEdges((mxCell) previous);
+				SCXMLChangeHandler.addStateOfNodeInCurrentEdit((mxCell) terminal, model);
+				reOrderOutgoingEdges((mxCell) terminal);
+			}
+			SCXMLEdge edgeValue = (SCXMLEdge) ((mxCell) edge).getValue();
+			// Synchronize the source and targets stored in the value of the
+			// modified edge with the graphical properties here updated.
+			updateConnectionOfSCXMLEdge(edgeValue, (source) ? terminal : null, (source) ? null : terminal, previous);
+			// update edge style
+			setCellStyle(edgeValue.getStyle((mxCell) edge), edge);
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			model.endUpdate();
+		}
+
+		return edge;
+	}
+
+	private void updateConnectionOfSCXMLEdge(SCXMLEdge value, Object source, Object target, Object previous)
+			throws Exception {
+		// System.out.println("update connectiopn: value:"+value+"
+		// source:"+source+" target:"+target+" previous:"+previous);
+		String sourceID = null, targetID = null;
+		if (source != null) {
+			sourceID = ((SCXMLNode) ((mxCell) source).getValue()).getID();
+			value.setSCXMLSource(sourceID);
+		}
+		if (target != null) {
+			targetID = ((SCXMLNode) ((mxCell) target).getValue()).getID();
+			if (previous == null) {
+				// add a target to an edge (new edge without any previous
+				// target)
+				ArrayList<String> targets = value.getSCXMLTargets();
+				if (!targets.contains(targetID))
+					value.getSCXMLTargets().add(targetID);
+			} else {
+				// update an edge belonging to a multitarget edge
+				String previousTargetID = ((SCXMLNode) ((mxCell) previous).getValue()).getID();
+				if (!value.getSCXMLTargets().contains(previousTargetID))
+					throw new Exception(
+							"updateConnectionOfSCXMLEdge: Error while moving target of edge with multiple targets. Old target not found.");
+				value.getSCXMLTargets().remove(previousTargetID);
+				value.getSCXMLTargets().add(targetID);
+			}
+		}
+	}
+
+	public void setEditor(SCXMLGraphEditor scxmlGraphEditor) {
+		this.editor = scxmlGraphEditor;
+	}
+
+	public SCXMLGraphEditor getEditor() {
+		return this.editor;
+	}
+
+	public mxCell findCellContainingAllOtherCells() {
+
+		return null;
+	}
+
+	@Override
+	public String convertValueToString(Object cell) {
+		Object v = model.getValue(cell);
+		if (v instanceof SCXMLNode) {
+			SCXMLNode node = ((SCXMLNode) v);
+			if (!StringUtils.isEmptyString(node.getName()))
+				return node.getID() + "[" + node.getName() + "]";
+			else
+				return node.getID();
+		} else if (v instanceof SCXMLEdge) {
+			SCXMLEdge edge = ((SCXMLEdge) v);
+			return edge.getEvent();
+		} else {
+			return "";
+		}
+	}
+
+	/**
+	 * Holds the edge to be used as a template for inserting new edges.
+	 */
+	protected Object edgeTemplate;
+
+	/**
+	 * Custom graph that defines the alternate edge style to be used when the
+	 * middle control point of edges is double clicked (flipped).
+	 */
+	public SCXMLGraph() {
+		setAlternateEdgeStyle("edgeStyle=mxEdgeStyle.ElbowConnector;elbow=vertical");
+		setAutoSizeCells(true);
+		setAllowLoops(true);
+	}
+
+	/**
+	 * Sets the edge template to be used to inserting edges.
+	 */
+	public void setEdgeTemplate(Object template) {
+		edgeTemplate = template;
+	}
+
+	/**
+	 * Prints out some useful information about the cell in the tooltip.
+	 */
+	public String getToolTipForCell(Object cell) {
+		String tip = null;
+		if (cell instanceof mxCell) {
+			if (((mxCell) cell).isEdge()) {
+				tip = "<html>";
+				SCXMLEdge v = (SCXMLEdge) ((mxCell) cell).getValue();
+				tip += "order: " + v.getOrder() + "<br>";
+				tip += "event: " + v.getEvent() + "<br>";
+				tip += "condition: <pre>" + XMLUtils.escapeStringForXML(v.getCondition()) + "</pre><br>";
+				tip += "exe: <pre>" + XMLUtils.escapeStringForXML(v.getExe()) + "</pre><br>";
+				tip += "</html>";
+			} else if (((mxCell) cell).isVertex()) {
+				SCXMLNode v = (SCXMLNode) ((mxCell) cell).getValue();
+				String src = v.getOutsourcedLocation();
+				if (!StringUtils.isEmptyString(src)) {
+					tip = "<html>";
+					tip += "src: " + src + "<br>";
+					tip += "type: " + v.getSRC().getType() + "<br>";
+					tip += "</html>";
+				} else {
+					String tipBody = "";
+					if (v.isRestricted()) {
+						tipBody += "Restrictions:<br><pre>";
+						for (RestrictedState restriction : v.getRestrictedStates()) {
+							tipBody += restriction.getName() + "<br>";
+						}
+						tipBody += "</pre><br>";
+					}
+					if (v.isInitial())
+						tipBody += "onInitialEntry: <pre>" + XMLUtils.escapeStringForXML(v.getOnInitialEntry())
+								+ "</pre><br>";
+					String onEntry = v.getOnEntry();
+					if ((onEntry != null) && (!(onEntry.isEmpty()))) {
+						tipBody += "onEntry:<br><pre>" + XMLUtils.escapeStringForXML(onEntry) + "</pre><br>";
+					}
+					String onExit = v.getOnExit();
+					if ((onExit != null) && (!(onExit.isEmpty()))) {
+						tipBody += "onExit:<br><pre>" + XMLUtils.escapeStringForXML(onExit) + "</pre><br>";
+					}
+					if (v.isFinal())
+						tipBody += "exitData: " + v.getDoneData() + "<br>";
+					if (!tipBody.isEmpty()) {
+						tip = "<html>";
+						tip += tipBody;
+						tip += "</html>";
+					}
+				}
+			}
+		}
+		return tip;
+	}
+	// public String getToolTipForCell(Object cell)
+	// {
+	// String tip = "<html>";
+	// mxGeometry geo = getModel().getGeometry(cell);
+	// mxCellState state = getView().getState(cell);
+	//
+	// if (getModel().isEdge(cell))
+	// {
+	// tip += "points={";
+	//
+	// if (geo != null)
+	// {
+	// List<mxPoint> points = geo.getPoints();
+	//
+	// if (points != null)
+	// {
+	// Iterator<mxPoint> it = points.iterator();
+	//
+	// while (it.hasNext())
+	// {
+	// mxPoint point = it.next();
+	// tip += "[x=" + numberFormat.format(point.getX())
+	// + ",y=" + numberFormat.format(point.getY())
+	// + "],";
+	// }
+	//
+	// tip = tip.substring(0, tip.length() - 1);
+	// }
+	// }
+	//
+	// tip += "}<br>";
+	// tip += "absPoints={";
+	//
+	// if (state != null)
+	// {
+	//
+	// for (int i = 0; i < state.getAbsolutePointCount(); i++)
+	// {
+	// mxPoint point = state.getAbsolutePoint(i);
+	// tip += "[x=" + numberFormat.format(point.getX())
+	// + ",y=" + numberFormat.format(point.getY())
+	// + "],";
+	// }
+	//
+	// tip = tip.substring(0, tip.length() - 1);
+	// }
+	//
+	// tip += "}";
+	// }
+	// else
+	// {
+	// tip += "geo=[";
+	//
+	// if (geo != null)
+	// {
+	// tip += "x=" + numberFormat.format(geo.getX()) + ",y="
+	// + numberFormat.format(geo.getY()) + ",width="
+	// + numberFormat.format(geo.getWidth()) + ",height="
+	// + numberFormat.format(geo.getHeight());
+	// }
+	//
+	// tip += "]<br>";
+	// tip += "state=[";
+	//
+	// if (state != null)
+	// {
+	// tip += "x=" + numberFormat.format(state.getX()) + ",y="
+	// + numberFormat.format(state.getY()) + ",width="
+	// + numberFormat.format(state.getWidth())
+	// + ",height="
+	// + numberFormat.format(state.getHeight());
+	// }
+	//
+	// tip += "]";
+	// }
+	//
+	// mxPoint trans = getView().getTranslate();
+	//
+	// tip += "<br>scale=" + numberFormat.format(getView().getScale())
+	// + ", translate=[x=" + numberFormat.format(trans.getX())
+	// + ",y=" + numberFormat.format(trans.getY()) + "]";
+	// tip += "</html>";
+	//
+	// return tip;
+	// }
+
+	/**
+	 * Overrides the method to use the currently selected edge template for new
+	 * edges.
+	 * 
+	 * @param graph
+	 * @param parent
+	 * @param id
+	 * @param value
+	 * @param source
+	 * @param target
+	 * @param style
+	 * @return
+	 */
+	public Object createEdge(Object parent, String id, Object value, Object source, Object target, String style) {
+		if (edgeTemplate != null) {
+			mxCell edge = (mxCell) cloneCells(new Object[] { edgeTemplate })[0];
+			edge.setId(id);
+
+			return edge;
+		}
+
+		return super.createEdge(parent, id, value, source, target, style);
+	}
+
+	public void clearUndeletable() {
+		undeletable.clear();
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphComponent.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphComponent.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphComponent.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,224 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.w3c.dom.Document;
+
+import com.mxgraph.io.mxCodec;
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGraphModel;
+import com.mxgraph.model.mxICell;
+import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.swing.mxGraphComponent;
+import com.mxgraph.swing.handler.mxConnectionHandler;
+import com.mxgraph.swing.handler.mxGraphHandler;
+import com.mxgraph.util.mxEvent;
+import com.mxgraph.util.mxEventObject;
+import com.mxgraph.util.mxUtils;
+import com.mxgraph.view.mxGraph;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.handler.SCXMLConnectionHandler;
+
+/**
+ * 
+ */
+public class SCXMLGraphComponent extends mxGraphComponent // implements
+															// ComponentListener
+{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -6833603133512882012L;
+	private static SCXMLConnectionHandler handler = null;
+	
+	public void setReadOnly(boolean value) {
+		handler.setReadOnly(value);
+	}
+
+	/**
+	 * 
+	 * @param graph
+	 */
+	public SCXMLGraphComponent(mxGraph graph) {
+		super(graph);
+
+		setWheelScrollingEnabled(false);
+
+		// addComponentListener(this);
+		setDragEnabled(true);
+
+		// Sets switches typically used in an editor
+		setPageVisible(false);
+		setGridVisible(true);
+		setToolTips(true);
+		getConnectionHandler().setCreateTarget(true);
+
+		// Loads the defalt stylesheet from an external file
+		mxCodec codec = new mxCodec();
+		Document doc = mxUtils.loadDocument(SCXMLGraphEditor.class
+				.getResource("/jp/go/aist/rtm/toolscommon/fsm/editor/resources/default-style.xml").toString());
+		
+		codec.decode(doc.getDocumentElement(), graph.getStylesheet());
+
+		// Sets the background to white
+		getViewport().setOpaque(false);
+		setBackground(Color.WHITE);
+	}
+
+	@Override
+	// disable double click editing event
+	public boolean isEditEvent(MouseEvent e) {
+		return false;
+	}
+
+	@Override
+	public SCXMLGraph getGraph() {
+		return (SCXMLGraph) graph;
+	}
+
+	@Override
+	protected mxConnectionHandler createConnectionHandler() {
+		handler = new SCXMLConnectionHandler(this);
+		return handler	;
+	}
+
+	/**
+	 * Overrides drop behaviour to set the cell style if the target is not a
+	 * valid drop target and the cells are of the same type (eg. both vertices
+	 * or both edges).
+	 */
+	public Object[] importCells(Object[] cells, double dx, double dy, Object target, Point location) {
+		/*
+		 * if (target == null && cells.length == 1 && location != null) { target
+		 * = getCellAt(location.x, location.y);
+		 * 
+		 * if (target instanceof mxICell && cells[0] instanceof mxICell) {
+		 * mxICell targetCell = (mxICell) target; mxICell dropCell = (mxICell)
+		 * cells[0];
+		 * 
+		 * if (targetCell.isVertex() == dropCell.isVertex() ||
+		 * targetCell.isEdge() == dropCell.isEdge()) { mxIGraphModel model =
+		 * graph.getModel(); model.setStyle(target, model.getStyle(cells[0]));
+		 * graph.setSelectionCell(target);
+		 * 
+		 * return null; } } }
+		 */
+		mxIGraphModel model = getGraph().getModel();
+		for (Object cell : cells) {
+			Object value = model.getValue(cell);
+			if (value instanceof SCXMLNode) {
+				model.setStyle(cell, ((SCXMLNode) value).getStyle());
+			} else if (value instanceof SCXMLEdge) {
+				model.setStyle(cell, ((SCXMLEdge) value).getStyle((mxCell) cell));
+			}
+		}
+		return super.importCells(cells, dx, dy, target, location);
+	}
+
+	private HashMap<String, mxCell> scxmlNodes = new HashMap<String, mxCell>();
+
+	public void addSCXMLNode(SCXMLNode n, mxCell node) {
+		if(n.isRoot()) {
+			scxmlNodes.put(n.getName(), node);
+		} else {
+			scxmlNodes.put(n.getID(), node);
+		}
+	}
+
+	public boolean isSCXMLNodeAlreadyThere(SCXMLNode n) {
+		if(n.isRoot()) {
+			return scxmlNodes.containsKey(n.getName());
+		} else {
+			return scxmlNodes.containsKey(n.getID());
+		}
+	}
+
+	public mxCell getSCXMLNodeForID(String id) {
+		return scxmlNodes.get(id);
+	}
+
+	public void clearSCXMLNodes() {
+		scxmlNodes.clear();
+	}
+
+	public void validateGraph() {
+		mxGraphModel model = (mxGraphModel) graph.getModel();
+		model.fireEvent(new mxEventObject(mxEvent.REQUEST_VALIDATION, "root", model.getRoot()));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * com.mxgraph.swing.mxGraphComponent#getSiblingsOfCell(java.lang.Object)
+	 */
+	@Override
+	public Collection<Object> getSiblingsOfCell(Object c) {
+		ArrayList<Object> ret = new ArrayList<Object>();
+		ret.add(c);
+		mxCell cell = (mxCell) c;
+		SCXMLEdge value = null;
+		ArrayList<String> targets = null;
+		if (cell.isEdge() && ((value = (SCXMLEdge) cell.getValue()) != null)
+				&& ((targets = value.getSCXMLTargets()) != null) && (targets.size() > 1)) {
+			mxICell source = cell.getSource();
+			if (source != null) {
+				int numEdges = source.getEdgeCount();
+				for (int i = 0; i < numEdges; i++) {
+					mxICell child = source.getEdgeAt(i);
+					if ((child != c) && (child.getValue() == value)) {
+						ret.add(child);
+					}
+				}
+			}
+		}
+		return ret;
+	}
+
+	@Override
+	protected mxGraphHandler createGraphHandler() {
+		return new SCXMLGraphHandler(this);
+	}
+
+	/*
+	 * @Override public void componentHidden(ComponentEvent e) { // TODO
+	 * Auto-generated method stub
+	 * 
+	 * }
+	 * 
+	 * @Override public void componentMoved(ComponentEvent e) { // TODO
+	 * Auto-generated method stub
+	 * 
+	 * }
+	 * 
+	 * @Override public void componentResized(ComponentEvent e) {
+	 * System.out.println("resize??"); FSMEditor editor =
+	 * ((CustomGraph)this.getGraph()).getEditor(); mxGraphComponent gc =
+	 * editor.getGraphComponent(); if ((gc!=null) &&
+	 * (editor.getCurrentFileIO()!=null)) { mxIGraphModel model =
+	 * gc.getGraph().getModel(); mxCell
+	 * root=((SCXMLImportExport)editor.getCurrentFileIO()).
+	 * followUniqueDescendantLineTillSCXMLValueIsFound(model); mxGeometry g =
+	 * root.getGeometry(); model.setGeometry(root, new mxGeometry(g.getX(),
+	 * g.getY(),
+	 * gc.getSize().width/graph.getView().getScale(),gc.getSize().height/graph.
+	 * getView().getScale())); //Object[] a={root}; //mxRectangle[]
+	 * b={root.getGeometry()}; //graph.cellsResized(a,b); } zoomAndCenter(); }
+	 * 
+	 * @Override public void componentShown(ComponentEvent e) { // TODO
+	 * Auto-generated method stub
+	 * 
+	 * }
+	 * 
+	 */
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphHandler.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphHandler.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLGraphHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,95 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import javax.swing.TransferHandler;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.swing.mxGraphComponent;
+import com.mxgraph.swing.handler.mxCellMarker;
+import com.mxgraph.swing.handler.mxGraphHandler;
+import com.mxgraph.swing.handler.mxGraphTransferHandler;
+import com.mxgraph.view.mxCellState;
+import com.mxgraph.view.mxGraph;
+
+public class SCXMLGraphHandler extends mxGraphHandler {
+
+	private static final long serialVersionUID = 1L;
+
+	public SCXMLGraphHandler(mxGraphComponent graphComponent) {
+		super(graphComponent);
+	}
+
+	@Override
+	protected mxCellMarker createMarker() {
+		mxCellMarker marker = new mxCellMarker(graphComponent, Color.BLUE) {
+			HashSet<Object> localHashSetOfCells = new HashSet<Object>();
+
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = -8451338653189373347L;
+
+			/**
+			 * 
+			 */
+			public boolean isEnabled() {
+				return graphComponent.getGraph().isDropEnabled();
+			}
+
+			@Override
+			public void reset() {
+				super.reset();
+				localHashSetOfCells.clear();
+			}
+
+			@Override
+			protected boolean isValidState(mxCellState state) {
+				if (cells != null) {
+					if (localHashSetOfCells.isEmpty() && (cells.length > 0))
+						localHashSetOfCells.addAll(Arrays.asList(cells));
+					mxCell targetCell = (mxCell) state.getCell();
+					while (targetCell != null) {
+						// avoid cycles. return invalid if the drop target is a
+						// child of one of the moved nodes.
+						if (localHashSetOfCells.contains(targetCell))
+							return false;
+						else
+							targetCell = (mxCell) targetCell.getParent();
+					}
+				}
+				return true;
+			}
+
+			/**
+			 * 
+			 */
+			public Object getCell(MouseEvent e) {
+				TransferHandler th = graphComponent.getTransferHandler();
+				boolean isLocal = th instanceof mxGraphTransferHandler && ((mxGraphTransferHandler) th).isLocalDrag();
+
+				mxGraph graph = graphComponent.getGraph();
+				Object cell = super.getCell(e);
+				Object[] cells = (isLocal) ? graph.getSelectionCells() : dragCells;
+				cell = graph.getDropTarget(cells, e.getPoint(), cell);
+				boolean clone = graphComponent.isCloneEvent(e) && cloneEnabled;
+
+				if (isLocal && cell != null && cells.length > 0 && !clone
+						&& graph.getModel().getParent(cells[0]) == cell) {
+					cell = null;
+				}
+
+				return cell;
+			}
+
+		};
+
+		// Swimlane content area will not be transparent drop targets
+		marker.setSwimlaneContentEnabled(true);
+
+		return marker;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLKeyboardHandler.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLKeyboardHandler.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/SCXMLKeyboardHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,66 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml;
+
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+
+import com.mxgraph.swing.mxGraphComponent;
+import com.mxgraph.swing.handler.mxKeyboardHandler;
+import com.mxgraph.swing.util.mxGraphActions;
+
+/**
+ * @author Administrator
+ * 
+ */
+public class SCXMLKeyboardHandler extends mxKeyboardHandler {
+
+	/**
+	 * 
+	 * @param graphComponent
+	 */
+	public SCXMLKeyboardHandler(mxGraphComponent graphComponent) {
+		super(graphComponent);
+	}
+
+	/**
+	 * Return JTree's input map.
+	 */
+	protected InputMap getInputMap(int condition) {
+		InputMap map = super.getInputMap(condition);
+
+		if ((condition == JComponent.WHEN_FOCUSED) && map != null) {
+			map.put(KeyStroke.getKeyStroke("DELETE"), "delete");
+			map.put(KeyStroke.getKeyStroke("control Z"), "undo");
+			map.put(KeyStroke.getKeyStroke("control Y"), "redo");
+			map.put(KeyStroke.getKeyStroke("control shift V"), "selectVertices");
+			map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
+			map.put(KeyStroke.getKeyStroke("control A"), "selectAll");
+			map.put(KeyStroke.getKeyStroke("ESCAPE"), "selectNone");
+			map.put(KeyStroke.getKeyStroke("control PAGE_UP"), "zoomIN");
+			map.put(KeyStroke.getKeyStroke("control PAGE_DOWN"), "zoomOUT");
+		}
+
+		return map;
+	}
+
+	/**
+	 * Return the mapping between JTree's input map and JGraph's actions.
+	 */
+	protected ActionMap createActionMap() {
+		ActionMap map = super.createActionMap();
+
+		map.put("delete", new SCXMLEditorActions.SCXMLDelete());
+		map.put("undo", new SCXMLEditorActions.HistoryAction(true));
+		map.put("redo", new SCXMLEditorActions.HistoryAction(false));
+		map.put("selectVertices", mxGraphActions.getSelectVerticesAction());
+		map.put("selectEdges", mxGraphActions.getSelectEdgesAction());
+		map.put("selectAll", mxGraphActions.getSelectAllAction());
+		map.put("selectNone", mxGraphActions.getSelectNoneAction());
+		map.put("zoomIN", new SCXMLEditorActions.ZoomIN());
+		map.put("zoomOUT", new SCXMLEditorActions.ZoomOUT());
+		map.put("edit", new SCXMLEditorActions.EditSelectedCellAction(null));
+		return map;
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/EditorKeyboardHandler.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/EditorKeyboardHandler.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/EditorKeyboardHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,49 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor;
+
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+import javax.swing.text.DefaultEditorKit;
+
+public class EditorKeyboardHandler {
+	
+	private SCXMLEditorRoot editor;
+
+	public EditorKeyboardHandler(SCXMLEditorRoot e)
+	{
+		editor=e;
+		updateInputMap(editor.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
+	}
+
+	public void updateInputMap(InputMap map)
+	{
+		map.put(KeyStroke.getKeyStroke("control Z"), "undo");
+		map.put(KeyStroke.getKeyStroke("control Y"), "redo");			
+		map.put(KeyStroke.getKeyStroke("control A"), "selectAll");
+		map.put(KeyStroke.getKeyStroke("CUT"), "cut");
+		map.put(KeyStroke.getKeyStroke("control C"), "copy");
+		map.put(KeyStroke.getKeyStroke("COPY"), "copy");
+		map.put(KeyStroke.getKeyStroke("control V"), "paste");
+		map.put(KeyStroke.getKeyStroke("PASTE"), "paste");
+		map.put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+	}
+
+	ActionMap map=null;
+	public ActionMap updateActionMap()
+	{
+		if (map==null) {
+			map = new ActionMap();
+			editor.getRootPane().setActionMap(map);
+		}
+
+		map.put("undo", editor.getActionByName(SCXMLEditorRoot.undoAction));
+		map.put("redo", editor.getActionByName(SCXMLEditorRoot.redoAction));
+		map.put("selectAll", editor.getActionByName(DefaultEditorKit.selectAllAction));
+		map.put("cut", editor.getActionByName(DefaultEditorKit.cutAction));
+		map.put("copy", editor.getActionByName(DefaultEditorKit.copyAction));
+		map.put("paste", editor.getActionByName(DefaultEditorKit.pasteAction));
+		map.put("close", editor.closeAction);
+		return map;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLEditorRoot.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLEditorRoot.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLEditorRoot.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,178 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.model.mxGraphModel;
+import com.mxgraph.swing.util.CellSelector;
+import com.mxgraph.util.mxEvent;
+import com.mxgraph.util.mxEventObject;
+import com.mxgraph.util.mxResources;
+import com.mxgraph.util.mxUndoableEdit;
+import com.mxgraph.util.mxUndoableEdit.mxUndoableChange;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+	
+public class SCXMLEditorRoot extends JDialog implements ActionListener, WindowListener {
+	private static final long serialVersionUID = -3257633395118679718L;
+	
+	public static final String undoAction = "Undo";
+	public static final String redoAction = "Redo";
+	public final CloseAction closeAction;
+
+	protected HashMap<Object, Action> actions = new HashMap<Object, Action>();
+
+	protected SCXMLGraphEditor editor;
+
+	private mxCell cell = null;
+
+	protected JButton idButton;
+	private CellSelector cellSelector;
+
+	public static enum Type {
+		EDGE, NODE
+	};
+	
+	public SCXMLEditorRoot(JFrame parent, SCXMLGraphEditor e, mxCell cell) {
+		super(parent);
+		this.cell = cell;
+		closeAction = new CloseAction();
+		editor = e;
+
+		cellSelector = new CellSelector(editor.getGraphComponent());
+
+		idButton = new JButton(mxResources.get("showCell"));
+		idButton.setActionCommand("id");
+		idButton.addActionListener(this);
+		idButton.setEnabled(true);
+
+		addWindowListener(this);
+
+		getContentPane().add(idButton, BorderLayout.SOUTH);
+	}
+	
+	public class CloseAction extends AbstractAction {
+		public void actionPerformed(ActionEvent e) {
+			editor.setEditorForCellAndType(cell, getTypeForEditorClass(), null);
+			cellSelector.unselectAll();
+			dispose();
+		}
+	}
+
+	public Type getTypeForEditorClass() {
+		String cn = this.getClass().getName();
+		if (cn.equals(SCXMLTransitionEditor.class.getName()))
+			return Type.EDGE;
+		else if (cn.equals(SCXMLStateEditor.class.getName()))
+			return Type.NODE;
+		return null;
+	}
+
+	public Action getActionByName(String name) {
+		return actions.get(name);
+	}
+	
+	protected void addUIParts(JPanel panel, JComponent comp, GridBagLayout gbl, int x, int y, int w, int h) {
+		GridBagConstraints gbc = new GridBagConstraints();
+	    gbc.fill = GridBagConstraints.BOTH;
+	    gbc.gridx = x;
+	    gbc.gridy = y;
+	    gbc.gridwidth = w;
+	    gbc.gridheight = h;
+	    gbc.insets = new Insets(2, 5, 2, 5);
+	    panel.add(comp, gbc);
+    }
+	
+	// any time a change is made to the document, the scxml editor "modified"
+	// flag is set
+	protected class DocumentChangeListener implements DocumentListener {
+		private SCXMLGraphEditor editor;
+		private final List<mxUndoableChange> changes = new ArrayList<mxUndoableEdit.mxUndoableChange>();
+
+		public DocumentChangeListener(SCXMLGraphEditor e) {
+			this.editor = e;
+		}
+
+		public void insertUpdate(DocumentEvent e) {
+			mxGraphModel model = (mxGraphModel) editor.getGraphComponent().getGraph().getModel();
+			model.fireEvent(new mxEventObject(mxEvent.CHANGE, "changes", changes, "revalidate", false));
+		}
+
+		public void removeUpdate(DocumentEvent e) {
+			mxGraphModel model = (mxGraphModel) editor.getGraphComponent().getGraph().getModel();
+			model.fireEvent(new mxEventObject(mxEvent.CHANGE, "changes", changes, "revalidate", false));
+		}
+
+		public void changedUpdate(DocumentEvent e) {
+			mxGraphModel model = (mxGraphModel) editor.getGraphComponent().getGraph().getModel();
+			model.fireEvent(new mxEventObject(mxEvent.CHANGE, "changes", changes, "revalidate", false));
+		}
+	}
+	
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		String cmd = e.getActionCommand();
+		if (cmd.equals("id")) {
+			cellSelector.toggleSelection(cell);
+		}
+	}
+
+	@Override
+	public void windowActivated(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void windowClosed(WindowEvent e) {
+	}
+
+	@Override
+	public void windowClosing(WindowEvent e) {
+		closeAction.actionPerformed(null);
+	}
+
+	@Override
+	public void windowDeactivated(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void windowDeiconified(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void windowIconified(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void windowOpened(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLStateEditor.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLStateEditor.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLStateEditor.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,113 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor;
+
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.text.Document;
+
+import com.mxgraph.model.mxCell;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+
+public class SCXMLStateEditor extends SCXMLEditorRoot {
+	private static final long serialVersionUID = -1937899100474024531L;
+	
+	private static final String STR_ON = "<log label=\"ON\"></log>";
+
+	public SCXMLStateEditor(JFrame parent, mxCell nn, mxCell rootOfGraph, SCXMLGraphEditor editor, Point pos) {
+		super(parent, editor, nn);
+//		setTitle(mxResources.get("titleNodeEditor"));
+		setTitle("State Editor");
+		setLocation(pos);
+		
+		final SCXMLNode node = (SCXMLNode) nn.getValue();
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		
+		DocumentChangeListener changeListener = new DocumentChangeListener(editor);
+		
+		JPanel panel = new JPanel();
+		getContentPane().add(panel);
+		GridBagLayout gbl = new GridBagLayout();
+		panel.setLayout(gbl);
+		editor.toString();
+		
+        addUIParts(panel, new JLabel("State Name"), gbl, 0, 0, 1, 1);
+        JTextField txtName = null;
+        Document docName = null;
+		if (nn!=rootOfGraph) {
+	        txtName = new JTextField(node.getID());
+	        docName = txtName.getDocument();
+			node.setIDDoc(docName);
+		} else {
+	        txtName = new JTextField(node.getName());
+	        docName = txtName.getDocument();
+			node.setNameDoc(docName);
+		}
+		docName.addDocumentListener(changeListener);
+		
+        txtName.setPreferredSize(new Dimension(300, 20));
+        addUIParts(panel, txtName, gbl, 1, 0, 2, 1);
+        //
+        addUIParts(panel, new JLabel("Actions"), gbl, 0, 1, 1, 1);
+        final JCheckBox chkEntry = new JCheckBox("On Entry");
+        addUIParts(panel, chkEntry, gbl, 1, 1, 1, 1);
+        if(node.getOnEntry().equals(STR_ON)) {
+        	chkEntry.setSelected(true);
+        }
+        chkEntry.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				if(chkEntry.isSelected()) {
+					node.setOnEntry(STR_ON);	
+				} else {
+					node.setOnEntry("");	
+				}
+			}
+		});
+        //
+        final JCheckBox chkExit = new JCheckBox("On Exit");
+        addUIParts(panel, chkExit, gbl, 2, 1, 1, 1);
+        if(node.getOnExit().equals(STR_ON)) {
+        	chkExit.setSelected(true);
+        }
+        chkExit.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				if(chkExit.isSelected()) {
+					node.setOnExit(STR_ON);	
+				} else {
+					node.setOnExit("");	
+				}
+			}
+		});
+		//
+        addUIParts(panel, new JLabel("Data"), gbl, 0, 2, 1, 1);
+        JTextField txtData = new JTextField(node.getDatamodel());
+        txtData.setPreferredSize(new Dimension(300, 20));
+        addUIParts(panel, txtData, gbl, 1, 2, 2, 1);
+        Document docData = node.getDatamodelDoc();
+		if (docData == null) {
+			node.setDatamodelDoc(docData = txtData.getDocument());
+		}
+		docData.addDocumentListener(changeListener);
+		//
+		if (nn==rootOfGraph) {
+			chkEntry.setEnabled(false);
+			chkExit.setEnabled(false);
+			txtData.setEnabled(false);
+		}
+		
+		pack();
+		setVisible(true);
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLTransitionEditor.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLTransitionEditor.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/eleditor/SCXMLTransitionEditor.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,62 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.eleditor;
+
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.Point;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.text.Document;
+
+import com.mxgraph.model.mxCell;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLEdge;
+
+public class SCXMLTransitionEditor extends SCXMLEditorRoot {
+
+	private static final long serialVersionUID = -6967742868602449986L;
+
+	public SCXMLTransitionEditor(JFrame parent, mxCell en, SCXMLGraphEditor editor, Point pos) {
+		super(parent, editor, en);
+//		setTitle(mxResources.get("titleNodeEditor"));
+		setTitle("Transition Editor");
+		setLocation(pos);
+		
+		SCXMLEdge edge = (SCXMLEdge) en.getValue();
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		
+		DocumentChangeListener changeListener = new DocumentChangeListener(editor);
+		
+		JPanel panel = new JPanel();
+		getContentPane().add(panel);
+		GridBagLayout gbl = new GridBagLayout();
+		panel.setLayout(gbl);
+		
+        addUIParts(panel, new JLabel("Event"), gbl, 0, 0, 1, 1);
+        JTextField txtEvent = new JTextField(edge.getEvent());
+        txtEvent.setPreferredSize(new Dimension(300, 20));
+        addUIParts(panel, txtEvent, gbl, 1, 0, 2, 1);
+        Document docEvent = edge.getEventDoc();
+		if (docEvent == null) {
+			edge.setEventDoc(docEvent = txtEvent.getDocument());
+		}
+		docEvent.addDocumentListener(changeListener);
+		//
+        addUIParts(panel, new JLabel("Condition"), gbl, 0, 1, 1, 1);
+        JTextField txtCondition = new JTextField(edge.getCondition());
+        txtCondition.setPreferredSize(new Dimension(300, 20));
+        addUIParts(panel, txtCondition, gbl, 1, 1, 2, 1);
+        Document docCondition = edge.getConditionDoc();
+		if (docCondition == null) {
+			edge.setConditionDoc(docCondition = txtCondition.getDocument());
+		}
+		docCondition.addDocumentListener(changeListener);
+		
+		pack();
+		setVisible(true);
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner/SCXMLListener.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner/SCXMLListener.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/scxml/listner/SCXMLListener.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,20 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.listner;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.swing.util.CellSelector;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraphComponent;
+
+public class SCXMLListener {
+	private CellSelector cellHighlighter;
+	private SCXMLGraphComponent graphComponent;
+
+	public SCXMLListener(SCXMLGraphEditor editor) {
+		cellHighlighter = new CellSelector(editor.getGraphComponent());
+	}
+	
+	public void showCell(mxCell cell) {
+		cellHighlighter.selectCell(cell);
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/AbstractActionWrapper.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/AbstractActionWrapper.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/AbstractActionWrapper.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,33 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+
+public class AbstractActionWrapper extends AbstractAction {
+
+	private Action action;
+	private Object eventSource;
+
+	public AbstractActionWrapper(Object es, String name, Action a, ImageIcon icon) {
+		super(name, icon);
+		action = a;
+		eventSource = es;
+	}
+
+	public void setInternalAction(Action a) {
+		action = a;
+	}
+
+	public Action getInternalAction() {
+		return action;
+	}
+
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		action.actionPerformed(new ActionEvent(eventSource, e.getID(), e.getActionCommand()));
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/ListCellSelector.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/ListCellSelector.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/ListCellSelector.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,39 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+import javax.swing.event.ListSelectionEvent;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.swing.util.CellSelector;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraphComponent;
+
+public class ListCellSelector extends CellSelector {
+	private JList list;
+	protected DefaultListModel listModel;
+
+	public ListCellSelector(JList list, SCXMLGraphComponent gc) {
+		super(gc);
+		this.list = list;
+		listModel = (DefaultListModel) list.getModel();
+	}
+
+	public mxCell getCellFromListElement(int selectedIndex) {
+		return (mxCell) listModel.get(selectedIndex);
+	}
+
+	public void handleSelectEvent(ListSelectionEvent e) {
+		if (e.getValueIsAdjusting() == false) {
+			int selectedIndex = list.getSelectedIndex();
+
+			if ((selectedIndex >= 0) && (selectedIndex < listModel.size())) {
+				mxCell c = getCellFromListElement(selectedIndex);
+				unselectAll();
+				selectCell(c);
+			} else {
+				unselectAll();
+			}
+		}
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/Pair.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/Pair.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/Pair.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,50 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils;
+
+import java.io.Serializable;
+
+// taken from http://en.wikipedia.org/wiki/Generics_in_Java
+public class Pair<T, S> implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	public Pair(T f, S s) {
+		first = f;
+		second = s;
+	}
+
+	public T getFirst() {
+		return first;
+	}
+
+	public S getSecond() {
+		return second;
+	}
+
+	public void setFirst(T f) {
+		first = f;
+	}
+
+	public void setSecond(S s) {
+		second = s;
+	}
+
+	public String toString() {
+		return "(" + first.toString() + ", " + second.toString() + ")";
+	}
+
+	@Override
+	public boolean equals(Object other) {
+		if (other instanceof Pair<?, ?>) {
+			return ((getFirst() != null) && getFirst().equals(((Pair) other).getFirst()) && (getSecond() != null)
+					&& getSecond().equals(((Pair) other).getSecond()));
+		} else
+			return false;
+	}
+
+	@Override
+	public int hashCode() {
+		return (getFirst() + "||" + getSecond()).hashCode();
+	}
+
+	private T first;
+	private S second;
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/XMLUtils.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/XMLUtils.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/editor/utils/XMLUtils.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,186 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.editor.utils;
+
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXParseException;
+
+import com.mxgraph.util.mxUtils;
+
+public class XMLUtils {
+
+	public static String escapeStringForXML(String aText) {
+		final StringBuilder result = new StringBuilder();
+		final StringCharacterIterator iterator = new StringCharacterIterator(aText);
+		char character = iterator.current();
+		while (character != CharacterIterator.DONE) {
+			if (character == '<') {
+				result.append("<");
+			} else if (character == '>') {
+				result.append(">");
+			} else if (character == '\"') {
+				result.append(""");
+			} else if (character == '\'') {
+				result.append("'");
+			} else if (character == '&') {
+				result.append("&");
+			} else {
+				// the char is not a special one
+				// add it to the result as is
+				result.append(character);
+			}
+			character = iterator.next();
+		}
+		return result.toString();
+	}
+
+	public static String domNode2String(Node node, boolean escapeStrings) {
+		String ret = "";
+		switch (node.getNodeType()) {
+
+		case Node.DOCUMENT_NODE:
+			// recurse on each child
+			NodeList nodes = node.getChildNodes();
+			if (nodes != null) {
+				for (int i = 0; i < nodes.getLength(); i++) {
+					ret += domNode2String(nodes.item(i), escapeStrings);
+				}
+			}
+			break;
+
+		case Node.ELEMENT_NODE:
+			String name = node.getNodeName();
+			ret += "<" + name;
+			NamedNodeMap attributes = node.getAttributes();
+			for (int i = 0; i < attributes.getLength(); i++) {
+				Node current = attributes.item(i);
+				ret += " " + current.getNodeName() + "=\""
+						+ ((escapeStrings) ? escapeStringForXML(current.getNodeValue()) : current.getNodeValue())
+						+ "\"";
+			}
+			ret += ">";
+
+			// recurse on each child
+			NodeList children = node.getChildNodes();
+			if (children != null) {
+				for (int i = 0; i < children.getLength(); i++) {
+					ret += domNode2String(children.item(i), escapeStrings);
+				}
+			}
+
+			ret += "</" + name + ">";
+			break;
+
+		case Node.TEXT_NODE:
+			ret += (escapeStrings) ? escapeStringForXML(node.getNodeValue()) : node.getNodeValue();
+			break;
+		case Node.COMMENT_NODE:
+			ret += "<!--" + node.getNodeValue() + "-->";
+			break;
+		}
+		return ret;
+	}
+
+	private static String BI = " ";
+
+	private static String prettyPrintDom(Node node, String indent, boolean isRoot, boolean escapeStrings) {
+		String ret = "";
+		switch (node.getNodeType()) {
+
+		case Node.DOCUMENT_NODE:
+			// recurse on each child
+			NodeList nodes = node.getChildNodes();
+			if (nodes != null) {
+				for (int i = 0; i < nodes.getLength(); i++) {
+					ret += prettyPrintDom(nodes.item(i), indent, isRoot, escapeStrings);
+				}
+			}
+			break;
+
+		case Node.ELEMENT_NODE:
+			String name = node.getNodeName();
+			ret += indent + "<" + name;
+			NamedNodeMap attributes = node.getAttributes();
+			for (int i = 0; i < attributes.getLength(); i++) {
+				Node current = attributes.item(i);
+				ret += " " + current.getNodeName() + "=\""
+						+ ((escapeStrings) ? escapeStringForXML(current.getNodeValue()) : current.getNodeValue())
+						+ "\"";
+			}
+			ret += ">";
+
+			// recurse on each child
+			NodeList children = node.getChildNodes();
+			if (children != null) {
+				for (int i = 0; i < children.getLength(); i++) {
+					String tmp = prettyPrintDom(children.item(i), indent + ((isRoot) ? "" : BI), false, escapeStrings);
+					if (!tmp.replaceAll("[\\s]+", "").equals(""))
+						if (tmp.endsWith("\n"))
+							if (ret.endsWith("\n"))
+								ret += tmp;
+							else
+								ret += "\n" + tmp;
+						else
+							ret += tmp;
+				}
+			}
+			if (ret.endsWith("\n"))
+				ret += indent + "</" + name + ">\n";
+			else
+				ret += "</" + name + ">\n";
+			break;
+
+		case Node.TEXT_NODE:
+			ret += (escapeStrings) ? escapeStringForXML(node.getNodeValue()) : node.getNodeValue();
+			break;
+
+		case Node.COMMENT_NODE:
+			ret += "<!-- " + node.getNodeValue() + " -->";
+			break;
+		}
+		return ret;
+	}
+
+	public static String prettyPrintXMLString(String xml, String indent, boolean escapeStrings) throws Exception {
+		if (xml == null)
+			return null;
+		// add surrounding top level node just in case
+		xml = "<xml>" + xml + "</xml>";
+		BI = indent;
+		Document doc = mxUtils.parseXMLString(xml, false, false);
+		xml = prettyPrintDom(doc, "", true, escapeStrings);
+		// remove added top level node.
+		xml = xml.replaceAll("^[\\s]*<xml>[\\s]*|[\\s]*</xml>[\\s]*$", "");
+		return xml;
+	}
+
+	public static void main(String[] args) {
+		String a = "<data name=\"information_state\"> <is:promised> <is:give-safety>false</is:give-safety> <is:give-secrecy>false</is:give-secrecy> <is:financial-reward>false</is:financial-reward> </is:promised> <is:preferenceCount> <is:give-safety>0</is:give-safety> <is:give-secrecy>0</is:give-secrecy> <is:financial-reward>0</is:financial-reward> </is:preferenceCount> <is:elicitCount> <is:give-safety>0</is:give-safety> <is:give-secrecy>0</is:give-secrecy> <is:financial-reward>0</is:financial-reward> </is:elicitCount> <is:number-of-offers>0</is:number-of-offers> <is:number-of-threats>0</is:number-of-threats> <is:number-of-compliments>0</is:number-of-compliments> <is:number-of-insults>0</is:number-of-insults> <is:wants-to-lie>false</is:wants-to-lie> <is:dialogue-length>0</is:dialogue-length> <is:turn-contains-elicit>false</is:turn-contains-elicit> </data>";
+		String c = "<scxml xmlns=\"http://www.w3.org/2005/07/scxml\" version=\"1.0\" profile=\"ecmascript\" intial=\"amani\"><state id=\"amani\"><parallel><state id=\"networks\"><parallel intial=\"network.question_answer\"><state id=\"network.question_answer\"><state id=\"question_resolved\"><onentry></onentry><transition event=\"player.ynq\" target=\"question_not_resolved\"/><transition event=\"player.whq\" target=\"question_not_resolved\"/><transition event=\"player.assert\" target=\"question_not_resolved\"/></state><state id=\"question_not_resolved\"><onentry></onentry><transition event=\"amani.assert\" cond=\"Data(question_analysis,'qa:is-sensitive')ne'true'\" target=\"question_not_resolved\"/><transition event=\"amani.assert\" cond=\"Data(information_state,'is:wants-to-lie')ne'true'andData(question_analysis,'qa:is-sensitive')eq'true'andData(question_analysis,'qa:constraint-satisfied')eq'true'andData(information_state,'is:turn-contains-elicit')ne'true'\" target=\"question_not_resolved\"/><transition event=\"amani.assert_lie\" cond=\"Data(information_state,'is:wants-to-lie')eq'true'andData(question_analysis,'qa:is-sensitive')eq'true'\" target=\"question_not_resolved\"/><transition event=\"amani.refuse_answer\" cond=\"!empty(_eventdata)\" target=\"question_not_resolved\"/><transition event=\"player.ynq\" target=\"question_not_resolved\"/><transition event=\"player.whq\" target=\"question_not_resolved\"/><transition event=\"player.assert\" target=\"question_not_resolved\"/></state></state><state id=\"network.thanks\"><state id=\"not_thanked\"><transition event=\"player.thanks\" target=\"thanked\"/></state><state id=\"thanked\"><transition event=\"amani.response-thanks\" target=\"not_thanked\"/></state></state><state id=\"network.greeting\"><state id=\"both_not_greeted\"><transition event=\"player.greeting\" target=\"amani_greeted\"/></state><state id=\"player_greeted\"><transition event=\"player.greeting\" target=\"both_greeted\"/></state><state id=\"amani_greeted\"><transition event=\"amani.greeting\" target=\"both_greeted\"/></state><state id=\"both_greeted\"><transition event=\"player.greeting\" target=\"amani_greeted\"/></state></state><state id=\"network.offer\"><state id=\"offer_not_elicited\"><onentry></onentry><transition event=\"player.offer\" target=\"offer_given\"></transition><transition event=\"amani.elicit-offer\" cond=\"In('question_not_resolved')\" target=\"offer_elicited\"><var expr=\"Data(offer, 'speech_act//offer/@name')\" name=\"offerName\"></var><assign expr=\"Data(information_state, 'is:preferenceCount/is:' + offerName) - 1\" location=\"Data(information_state, 'is:preferenceCount/is:' + offerName)\"></assign><assign expr=\"Data(information_state, 'is:elicitCount/is:' + offerName) + 1\" location=\"Data(information_state, 'is:elicitCount/is:' + offerName)\"></assign></transition><transition event=\"player.clarify_elicit_offer\" target=\"offer_not_elicited\"/></state><state id=\"offer_elicited\"><transition event=\"player.offer\" target=\"offer_given\"><assign expr=\"_eventdata\" location=\"Data(offer, 'speech_act')\"></assign></transition><transition event=\"amani.elicit-offer\" cond=\"In('question_not_resolved')\" target=\"offer_elicited\"><assign expr=\"_eventdata\" location=\"Data(offer, 'speech_act')\"></assign> <var expr=\"Data(offer, 'speech_act//offer/@name')\" name=\"offerName\"></var> <assign expr=\"Data(information_state, 'is:preferenceCount/is:' + offerName) - 1\" location=\"Data(information_state, 'is:preferenceCount/is:' + offerName)\"></assign> <assign expr=\"Data(information_state, 'is:elicitCount/is:' + offerName) + 1\" location=\"Data(information_state, 'is:elicitCount/is:' + offerName)\"></assign></transition><transition event=\"player.accept\" target=\"offer_elicited\"/><transition event=\"player.reject\" target=\"offer_elicited\"/><transition event=\"player.yes\" target=\"offer_elicited\"/><transition event=\"player.no\" target=\"offer_elicited\"/><transition event=\"player.clarify_elicit_offer\" target=\"offer_elicited\"/><transition event=\"player.unknown\" target=\"offer_elicited\"/><transition event=\"player.whq\" target=\"offer_elicited\"/><transition event=\"player.ynq\" target=\"offer_elicited\"/><transition event=\"player.assert\" target=\"offer_elicited\"/></state><state id=\"offer_given\"><onentry><assign expr=\"true\" location=\"Data(information_state, 'is:promised/is:' + Data(offer,'speech_act//offer/@name'))\"></assign> <assign expr=\"0\" location=\"Data(information_state, 'is:preferenceCount/is:' + Data(offer,'speech_act//offer/@name'))\"></assign> <assign expr=\"1 + Data(information_state, 'is:number-of-offers')\" location=\"Data(information_state, 'is:number-of-offers')\"></assign></onentry><transition event=\"player.offer\" target=\"offer_given\"><assign expr=\"_eventdata\" location=\"Data(offer, 'speech_act')\"></assign></transition><transition event=\"amani.response-offer\" target=\"offer_not_elicited\"/></state><state id=\"offer_not_given\"><transition event=\"amani.refuse_answer\" target=\"offer_not_given\"/></state></state><state id=\"network.threat\"><state id=\"threat_not_elicited\"><onentry><assign expr=\"Data(util,'empty')\" location=\"Data(threat, 'speech_act')\"></assign></onentry><transition event=\"player.threat\" target=\"threat_given\"><assign expr=\"_eventdata\" location=\"Data(threat, 'speech_act')\"></assign></transition><transition event=\"amani.elicit-threat\" cond=\"In('both_greeted')||In('player_greeted')\" target=\"threat_elicited\"><assign expr=\"_eventdata\" location=\"Data(threat, 'speech_act')\"></assign> <var expr=\"Data(offer, 'speech_act//threat/@name')\" name=\"threatName\"></var> <assign expr=\"Data(information_state, 'is:preferenceCount/is:' + threatName) - 1\" location=\"Data(information_state, 'is:preferenceCount/is:' + threatName)\"></assign> <assign expr=\"Data(information_state, 'is:elicitCount/is:' + threatName) + 1\" location=\"Data(information_state, 'is:elicitCount/is:' + threatName)\"></assign></transition></state><state id=\"threat_elicited\"><transition event=\"player.threat\" target=\"threat_given\"><assign expr=\"_eventdata\" location=\"Data(threat, 'speech_act')\"></assign></transition><transition event=\"player.accept\" target=\"threat_given\"/><transition event=\"player.yes\" target=\"threat_given\"/><transition event=\"player.reject\" target=\"threat_not_given\"/><transition event=\"player.no\" target=\"threat_not_given\"/><transition event=\"amani.elicit-threat\" target=\"threat_elicited\"><assign expr=\"_eventdata\" location=\"Data(threat, 'speech_act')\"></assign> <var expr=\"Data(offer, 'speech_act//threat/@name')\" name=\"threatName\"></var> <assign expr=\"Data(information_state, 'is:preferenceCount/is:' + threatName) - 1\" location=\"Data(information_state, 'is:preferenceCount/is:' + threatName)\"></assign> <assign expr=\"Data(information_state, 'is:elicitCount/is:' + threatName) + 1\" location=\"Data(information_state, 'is:elicitCount/is:' + threatName)\"></assign></transition><transition event=\"player.clarify_elicit_offer\" target=\"threat_elicited\"/><transition event=\"player.unknown\" target=\"threat_elicited\"/><transition event=\"player.whq\" target=\"threat_elicited\"/><transition event=\"player.ynq\" target=\"threat_elicited\"/><transition event=\"player.assert\" target=\"threat_elicited\"/></state><state id=\"threat_given\"><onentry><assign expr=\"true\" location=\"Data(information_state, 'is:promised/is:' + Data(_eventdata,'speech_act//threat/@name'))\"></assign> <assign expr=\"0\" location=\"Data(information_state, 'is:preferenceCount/is:' + Data(_eventdata,'speech_act//threat/@name'))\"></assign> <assign expr=\"1 + Data(information_state, 'is:number-of-threats')\" location=\"Data(information_state, 'is:number-of-threats')\"></assign></onentry><transition event=\"amani.response-threat\" target=\"threat_not_elicited\"/><transition event=\"player.threat\" target=\"threat_given\"><assign expr=\"_eventdata\" location=\"Data(threat, 'speech_act')\"></assign></transition></state><state id=\"threat_not_given\"><transition event=\"amani.refuse_answer\" target=\"threat_not_given\"/></state></state><state id=\"network.compliment\"><state id=\"compliment_replied\"><onentry><assign expr=\"Data(util,'empty')\" location=\"Data(compliment,'speech_act')\"></assign></onentry><transition event=\"player.compliment\" target=\"compliment_given\"/></state><state id=\"compliment_given\"><onentry><assign expr=\"_eventdata\" location=\"Data(compliment,'speech_act')\"></assign> <assign expr=\"1 + Data(information_state, 'is:number-of-compliments')\" location=\"Data(information_state, 'is:number-of-compliments')\"></assign> <assign expr=\"Data(information_state, 'is:number-of-compliments') le Data(information_state, 'is:number-of-insults')\" location=\"Data(information_state, 'is:wants-to-lie')\"></assign></onentry><transition event=\"player.compliment\" target=\"compliment_given\"/><transition event=\"amani.response-compliment\" target=\"compliment_given\"/></state></state><state id=\"network.insult\"><state id=\"insult_replied\"><onentry><assign expr=\"Data(util,'empty')\" location=\"Data(insult,'speech_act')\"></assign></onentry><transition event=\"player.insult\" target=\"insult_given\"/></state><state id=\"insult_given\"><onentry><assign expr=\"_eventdata\" location=\"Data(insult,'speech_act')\"></assign> <assign expr=\"1 + Data(information_state, 'is:number-of-insults')\" location=\"Data(information_state, 'is:number-of-insults')\"></assign> <assign expr=\"Data(information_state, 'is:number-of-compliments') le Data(information_state, 'is:number-of-insults')\" location=\"Data(information_state, 'is:wants-to-lie')\"></assign></onentry><transition event=\"player.insult\" target=\"insult_given\"/><transition event=\"amani.response-insult\" target=\"insult_given\"/></state></state><state id=\"network.pre_closing\"><state id=\"pre_closing_dormant\"><transition event=\"player.pre_closing\" target=\"pre_closing_amani\"/></state><state id=\"pre_closing\"><transition event=\"player.pre_closing\" target=\"pre_closing_amani\"/></state><state id=\"pre_closing_amani\"><transition event=\"amani.pre_closing\" target=\"pre_closing\"/></state></state><state id=\"network.closing\"><state id=\"closing_dormant\"><transition event=\"amani.closing\" cond=\"In('pre_closing')\" target=\"closing\"/><transition event=\"player.closing\" target=\"closing_amani\"/></state><state id=\"closing\"><transition event=\"player.closing\" target=\"closing_amani\"/></state><state id=\"closing_amani\"><transition event=\"amani.closing\" target=\"closing\"/></state></state><state id=\"network.goal\"><state id=\"goal_responded\"><transition event=\"player.goal\" target=\"goal_not_responded\"/></state><state id=\"goal_not_responded\"><transition event=\"player.goal\" target=\"goal_not_responded\"/><transition event=\"amani.goal\" target=\"goal_responded\"/></state></state><state id=\"network.unknown\"><state id=\"unknown_responded\"><transition event=\"player.unknown\" target=\"do_request_repair\"/></state><state id=\"do_request_repair\"><transition event=\"amani.request_repair_object\" cond=\"Data(conversation_topic,'topic/@name')ne''\" target=\"do_request_repair\"/><transition event=\"amani.request_repair\" cond=\"Data(conversation_topic,'topic/@name')eq''\" target=\"do_request_repair\"/></state><state id=\"do_confirm\"><transition event=\"player.yes\" target=\"do_confirm\"/><transition event=\"player.no\" target=\"do_confirm\"><assign expr=\"''\" location=\"Data(conversation_topic,'topic/@name')\"></assign></transition><transition event=\"player.unknown\" target=\"do_confirm\"><assign expr=\"''\" location=\"Data(conversation_topic,'topic/@name')\"></assign></transition><transition event=\"player.*\" target=\"do_confirm\"/></state><state id=\"do_request_repair_attribute\"><transition event=\"amani.request_repair_attribute\" target=\"do_request_repair_attribute\"/></state></state><state id=\"network.grounding\"><state id=\"topic_grounded\"><transition event=\"player.repeat_back\" target=\"topic_grounded\"/><transition event=\"player.request_repair_object\" target=\"topic_grounded\"/><transition event=\"player.request_repair\" target=\"topic_grounded\"/></state><state id=\"need_to_confirm_topic\"><transition event=\"amani.repeat_back\" target=\"need_to_confirm_topic\"/></state><state id=\"need_to_repeat\"><transition event=\"amani.repeat\" target=\"need_to_repeat\"/><transition event=\"*\" target=\"need_to_repeat\"/></state></state><state id=\"network.topic_shift\"><state id=\"topic_shift_responded\"><transition event=\"player.topic_shift\" target=\"topic_shift_not_responded\"/></state><state id=\"topic_shift_not_responded\"><transition event=\"amani.ack\" target=\"topic_shift_responded\"/><transition event=\"player.topic_shift\" target=\"topic_shift_not_responded\"/></state></state><state id=\"network.topic\"><state id=\"track-topic\"><transition event=\"player.whq\" cond=\"Data(conversation_topic,'topic/@name')neData(_eventdata,'//speech_act/primitive_speech_act/whq/object/@name')\" target=\"track-topic\"><assign expr=\"Data(_eventdata, '//speech_act/primitive_speech_act/whq/object/@name')\" location=\"Data(conversation_topic, 'topic/@name')\"></assign></transition><transition event=\"player.ynq\" cond=\"Data(conversation_topic,'topic/@name')neData(_eventdata,'//speech_act/primitive_speech_act/ynq/object/@name')\" target=\"track-topic\"><assign expr=\"Data(_eventdata, '//speech_act/primitive_speech_act/ynq/object/@name')\" location=\"Data(conversation_topic, 'topic/@name')\"></assign></transition><transition event=\"player.assert\" cond=\"Data(conversation_topic,'topic/@name')neData(_eventdata,'//speech_act/primitive_speech_act/assert/object/@name')\" target=\"track-topic\"><assign expr=\"Data(_eventdata, '//speech_act/primitive_speech_act/assert/object/@name')\" location=\"Data(conversation_topic, 'topic/@name')\"></assign></transition></state><state id=\"repeat-back\"><transition event=\"amani.repeat_back\" target=\"repeat-back\"/></state></state></parallel></state><state id=\"mind\"><parallel intial=\"single-node-network.question\"><state id=\"single-node-network.question\"><state id=\"analyze-question\"><transition event=\"player.whq\" target=\"analyze-question\"><assign SIAttribute=\"name\" SIName=\"1_strange_man_name\" SIObject=\"strange_man\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"strange_man\"]/attribute/@name') eq 'name'\" location=\"Data(analysis_variables, 'av:about_1_strange_man_name')\" type=\"match\"></assign> <assign SIAttribute=\"location\" SIName=\"2_strange_man_location\" SIObject=\"strange_man\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"strange_man\"]/attribute/@name') eq 'location'\" location=\"Data(analysis_variables, 'av:about_2_strange_man_location')\" type=\"match\"></assign> <assign SIAttribute=\"general_description\" SIName=\"3_strange_man_general_description\" SIObject=\"strange_man\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"strange_man\"]/attribute/@name') eq 'general_description'\" location=\"Data(analysis_variables, 'av:about_3_strange_man_general_description')\" type=\"match\"></assign> <assign SIAttribute=\"daily_routine\" SIName=\"4_strange_man_daily_routine\" SIObject=\"strange_man\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"strange_man\"]/attribute/@name') eq 'daily_routine'\" location=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine')\" type=\"match\"></assign> <assign SIAttribute=\"occupant\" SIName=\"5_the_shop_occupant\" SIObject=\"the_shop\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"the_shop\"]/attribute/@name') eq 'occupant'\" location=\"Data(analysis_variables, 'av:about_5_the_shop_occupant')\" type=\"match\"></assign> <assign SIAttribute=\"perpetrator\" SIName=\"6_the_incident_perpetrator\" SIObject=\"the_incident\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"the_incident\"]/attribute/@name') eq 'perpetrator'\" location=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator')\" type=\"match\"></assign></transition><transition event=\"player.ynq\" target=\"analyze-question\"><assign SIName=\"1_strange_man_name\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"strange_man\"]/attribute/@name') eq 'name'\" location=\"Data(analysis_variables, 'av:about_1_strange_man_name')\" type=\"match\"></assign> <assign SIName=\"2_strange_man_location\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"strange_man\"]/attribute/@name') eq 'location'\" location=\"Data(analysis_variables, 'av:about_2_strange_man_location')\" type=\"match\"></assign> <assign SIName=\"3_strange_man_general_description\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"strange_man\"]/attribute/@name') eq 'general_description'\" location=\"Data(analysis_variables, 'av:about_3_strange_man_general_description')\" type=\"match\"></assign> <assign SIName=\"4_strange_man_daily_routine\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"strange_man\"]/attribute/@name') eq 'daily_routine'\" location=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine')\" type=\"match\"></assign> <assign SIName=\"5_the_shop_occupant\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"the_shop\"]/attribute/@name') eq 'occupant'\" location=\"Data(analysis_variables, 'av:about_5_the_shop_occupant')\" type=\"match\"></assign> <assign SIName=\"6_the_incident_perpetrator\" expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/ynq/object[@name=\"the_incident\"]/attribute/@name') eq 'perpetrator'\" location=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator')\" type=\"match\"></assign></transition></state></state><state id=\"single-node-network.sensitive-information\"><state id=\"analyze-sensitive-information\"><onentry><assign SIName=\"1_strange_man_name\" expr=\"Data(analysis_variables, 'av:about_1_strange_man_name') and (Data(information_state, 'is:promised/is:give-safety'))\" location=\"Data(analysis_variables, 'av:about_1_strange_man_name_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"1_strange_man_name\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_1_strange_man_name') and ! Data(analysis_variables, 'av:about_1_strange_man_name_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-safety')\"></assign> </if> <assign SIName=\"2_strange_man_location\" expr=\"Data(analysis_variables, 'av:about_2_strange_man_location') and (Data(information_state, 'is:promised/is:give-secrecy'))\" location=\"Data(analysis_variables, 'av:about_2_strange_man_location_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"2_strange_man_location\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_2_strange_man_location') and ! Data(analysis_variables, 'av:about_2_strange_man_location_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-secrecy')\"></assign> </if> <assign SIName=\"3_strange_man_general_description\" expr=\"Data(analysis_variables, 'av:about_3_strange_man_general_description') and (Data(information_state, 'is:promised/is:give-safety'))\" location=\"Data(analysis_variables, 'av:about_3_strange_man_general_description_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"3_strange_man_general_description\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_3_strange_man_general_description') and ! Data(analysis_variables, 'av:about_3_strange_man_general_description_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-safety')\"></assign> </if> <assign SIName=\"4_strange_man_daily_routine\" expr=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine') and (Data(information_state, 'is:promised/is:financial-reward'))\" location=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"4_strange_man_daily_routine\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_4_strange_man_daily_routine') and ! Data(analysis_variables, 'av:about_4_strange_man_daily_routine_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:financial-reward')\"></assign> </if> <assign SIName=\"5_the_shop_occupant\" expr=\"Data(analysis_variables, 'av:about_5_the_shop_occupant') and (Data(information_state, 'is:promised/is:give-secrecy'))\" location=\"Data(analysis_variables, 'av:about_5_the_shop_occupant_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"5_the_shop_occupant\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_5_the_shop_occupant') and ! Data(analysis_variables, 'av:about_5_the_shop_occupant_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-secrecy')\"></assign> </if> <assign SIName=\"6_the_incident_perpetrator\" expr=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator') and ((Data(information_state, 'is:promised/is:give-safety')) and (Data(information_state, 'is:promised/is:give-secrecy')))\" location=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator_ConstraintSatisfied')\" type=\"constraint\"></assign> <if SIName=\"6_the_incident_perpetrator\" cond=\"(! Data(information_state, 'is:wants-to-lie') and Data(analysis_variables, 'av:about_6_the_incident_perpetrator') and ! Data(analysis_variables, 'av:about_6_the_incident_perpetrator_ConstraintSatisfied'))\" type=\"preference\"> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-safety')\"></assign> <assign expr=\"1\" location=\"Data(information_state, 'is:preferenceCount/is:give-secrecy')\"></assign> </if> <assign expr=\"false || Data(analysis_variables, 'av:about_1_strange_man_name') || Data(analysis_variables, 'av:about_2_strange_man_location') || Data(analysis_variables, 'av:about_3_strange_man_general_description') || Data(analysis_variables, 'av:about_4_strange_man_daily_routine') || Data(analysis_variables, 'av:about_5_the_shop_occupant') || Data(analysis_variables, 'av:about_6_the_incident_perpetrator')\" location=\"Data(question_analysis, 'qa:is-sensitive')\"></assign> <assign expr=\"false || Data(analysis_variables, 'av:about_1_strange_man_name_ConstraintSatisfied') || Data(analysis_variables, 'av:about_2_strange_man_location_ConstraintSatisfied') || Data(analysis_variables, 'av:about_3_strange_man_general_description_ConstraintSatisfied') || Data(analysis_variables, 'av:about_4_strange_man_daily_routine_ConstraintSatisfied') || Data(analysis_variables, 'av:about_5_the_shop_occupant_ConstraintSatisfied') || Data(analysis_variables, 'av:about_6_the_incident_perpetrator_ConstraintSatisfied')\" location=\"Data(question_analysis, 'qa:constraint-satisfied')\"></assign></onentry><transition event=\"player.whq\" target=\"analyze-sensitive-information\"/><transition event=\"player.ynq\" target=\"analyze-sensitive-information\"/></state></state><state id=\"single-node-network.sensitive-information-constraint\"><state id=\"analyze-sensitive-information-constraint\"><onentry><assign SIName=\"1_strange_man_name\" expr=\"Data(analysis_variables, 'av:about_1_strange_man_name') and (Data(information_state, 'is:promised/is:give-safety'))\" location=\"Data(analysis_variables, 'av:about_1_strange_man_name_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign SIName=\"2_strange_man_location\" expr=\"Data(analysis_variables, 'av:about_2_strange_man_location') and (Data(information_state, 'is:promised/is:give-secrecy'))\" location=\"Data(analysis_variables, 'av:about_2_strange_man_location_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign SIName=\"3_strange_man_general_description\" expr=\"Data(analysis_variables, 'av:about_3_strange_man_general_description') and (Data(information_state, 'is:promised/is:give-safety'))\" location=\"Data(analysis_variables, 'av:about_3_strange_man_general_description_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign SIName=\"4_strange_man_daily_routine\" expr=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine') and (Data(information_state, 'is:promised/is:financial-reward'))\" location=\"Data(analysis_variables, 'av:about_4_strange_man_daily_routine_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign SIName=\"5_the_shop_occupant\" expr=\"Data(analysis_variables, 'av:about_5_the_shop_occupant') and (Data(information_state, 'is:promised/is:give-secrecy'))\" location=\"Data(analysis_variables, 'av:about_5_the_shop_occupant_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign SIName=\"6_the_incident_perpetrator\" expr=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator') and ((Data(information_state, 'is:promised/is:give-safety')) and (Data(information_state, 'is:promised/is:give-secrecy')))\" location=\"Data(analysis_variables, 'av:about_6_the_incident_perpetrator_ConstraintSatisfied')\" type=\"constraint\"></assign> <assign expr=\"false || Data(analysis_variables, 'av:about_1_strange_man_name') || Data(analysis_variables, 'av:about_2_strange_man_location') || Data(analysis_variables, 'av:about_3_strange_man_general_description') || Data(analysis_variables, 'av:about_4_strange_man_daily_routine') || Data(analysis_variables, 'av:about_5_the_shop_occupant') || Data(analysis_variables, 'av:about_6_the_incident_perpetrator')\" location=\"Data(question_analysis, 'qa:is-sensitive')\"></assign> <assign expr=\"false || Data(analysis_variables, 'av:about_1_strange_man_name_ConstraintSatisfied') || Data(analysis_variables, 'av:about_2_strange_man_location_ConstraintSatisfied') || Data(analysis_variables, 'av:about_3_strange_man_general_description_ConstraintSatisfied') || Data(analysis_variables, 'av:about_4_strange_man_daily_routine_ConstraintSatisfied') || Data(analysis_variables, 'av:about_5_the_shop_occupant_ConstraintSatisfied') || Data(analysis_variables, 'av:about_6_the_incident_perpetrator_ConstraintSatisfied')\" location=\"Data(question_analysis, 'qa:constraint-satisfied')\"></assign></onentry><transition event=\"*\" target=\"analyze-sensitive-information-constraint\"/></state></state><state id=\"single-node-network.lie\"><state id=\"analyze-lie\"><transition event=\"player.threat\" cond=\"Data(information_state,'is:number-of-threats')gt0\" target=\"analyze-lie\"><assign expr=\"true\" location=\"Data(information_state, 'is:wants-to-lie')\"></assign></transition></state></state><state id=\"single-node-network.commitment-updater\"><state id=\"update-commitment\"><transition event=\"amani.assert\" target=\"update-commitment\"><actions:merge expr=\"Data(_eventdata, '//speech_act/primitive_speech_act/assert/object')\" location=\"Data(commitments, 'commitments/character[@name=\"amani\"]')\"></actions:merge></transition><transition event=\"player.assert\" target=\"update-commitment\"><actions:merge expr=\"Data(_eventdata, '//speech_act/primitive_speech_act/assert/object')\" location=\"Data(commitments, 'commitments/character[@name=\"player\"]')\"></actions:merge></transition></state></state><state id=\"single-node-network.last-speech-act-updater\"><state id=\"update-last-speech-act\"><transition event=\"amani.*\" cond=\"Data(_eventdata,'//speech_act/@speaker')eq'amani'\" target=\"update-last-speech-act\"><assign expr=\"Data(_eventdata, '//speech_act')\" location=\"Data(last_speech_act,'speech_act[@speaker=\"amani\"]')\"></assign> <actions:appendNode expr=\"Data(_eventdata, '//speech_act')\" location=\"Data(last_turn, 'turn[@speaker=\"amani\"]')\"></actions:appendNode> <assign expr=\"! empty( Data(last_turn, 'turn[@speaker=\"amani\"]//elicit//offer/@name') )\" location=\"Data(information_state,'is:turn-contains-elicit')\"></assign></transition><transition event=\"player.*\" target=\"update-last-speech-act\"><assign expr=\"Data(util,'empty')\" location=\"Data(last_turn,'turn[@speaker=\"amani\"]')\"></assign> <assign expr=\"false\" location=\"Data(information_state,'is:turn-contains-elicit')\"></assign></transition></state></state><state id=\"single-node-network.dialog-length\"><state id=\"analyze-length\"><transition event=\"*\" target=\"analyze-length\"></transition></state></state></parallel></state></parallel></state></scxml>";
+		String d = "<assign expr=\"Data(_eventdata,'//speech_act/primitive_speech_act/whq/object[@name=\"strange_man\"]/attribute/@name') eq 'name'\" location=\"Data(analysis_variables, 'av:about_1_strange_man_name')\" type=\"match\"></assign>";
+		String e = "<x a=\"a"\"/>";
+		try {
+			System.out.println(prettyPrintXMLString(d, " ", true));
+			Document doc = mxUtils.parseXMLString(d, false, false);
+			String b = prettyPrintDom(doc, "", true, true);
+			System.out.println(b);
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+	}
+
+	public static String isParsableXMLString(String xml) {
+		try {
+			xml = "<xml>" + xml + "</xml>";
+			mxUtils.parseXMLString(xml, false, false);
+		} catch (SAXParseException e) {
+			return e.getMessage();
+		} catch (Exception e) {
+		}
+		return null;
+	}
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler/SCXMLConnectionHandler.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler/SCXMLConnectionHandler.java	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/handler/SCXMLConnectionHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,59 @@
+package jp.go.aist.rtm.toolscommon.fsm.editor.handler;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+
+import com.mxgraph.model.mxCell;
+import com.mxgraph.swing.handler.mxConnectionHandler;
+import com.mxgraph.util.mxPoint;
+import com.mxgraph.view.mxGraph;
+
+import jp.go.aist.rtm.toolscommon.fsm.editor.SCXMLGraphEditor;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.fileimportexport.SCXMLNode;
+import jp.go.aist.rtm.toolscommon.fsm.editor.editor.scxml.SCXMLGraphComponent;
+
+public class SCXMLConnectionHandler extends mxConnectionHandler {
+	private boolean isReadOnly = false;
+	public void setReadOnly(boolean value) {
+		this.isReadOnly = value;
+	}
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 592305036573256904L;
+
+	public SCXMLConnectionHandler(SCXMLGraphComponent graphComponent) {
+		super(graphComponent);
+	}
+
+	@Override
+	public Object createTargetVertex(MouseEvent e, Object source) {
+		if(isReadOnly) return null;
+		mxGraph graph = graphComponent.getGraph();
+		SCXMLGraphEditor editor = getEditor(e);
+		SCXMLGraphComponent gc = editor.getGraphComponent();
+		mxPoint point = graphComponent.getPointForEvent(e);
+		mxCell parent = (mxCell) gc.getCellAt((int) point.getX(), (int) point.getY());
+		SCXMLNode value = (SCXMLNode) editor.getCurrentFileIO().buildNodeValue();
+		mxCell createdCell = (mxCell) graph.insertVertex(parent, value.getInternalID(), value, point.getX() - 50,
+				point.getY() - 50, 75, 75, value.getStyle());
+
+		return createdCell;
+	}
+
+	private SCXMLGraphEditor getEditor(MouseEvent e) {
+		if (e.getSource() instanceof Component) {
+			Component component = (Component) e.getSource();
+
+			while (component != null && !(component instanceof SCXMLGraphEditor)) {
+				component = component.getParent();
+			}
+
+			return (SCXMLGraphEditor) component;
+		}
+
+		return null;
+	}
+
+}

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/copy.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/copy.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/cut.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/cut.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/delete.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/delete.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/paste.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/paste.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/redo.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/redo.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/undo.gif
===================================================================
(Binary files differ)


Property changes on: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/images/undo.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/basic-style.xml
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/basic-style.xml	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/basic-style.xml	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,76 @@
+<mxStylesheet>
+	<add as="defaultVertex">
+		<add as="shape" value="label"/>
+		<add as="perimeter" value="rectanglePerimeter"/>
+		<add as="fontSize" value="11"/>
+		<add as="align" value="center"/>
+		<add as="verticalAlign" value="middle"/>
+		<add as="strokeColor" value="black"/>
+		<add as="fillColor" value="white"/>
+	</add>
+	<add as="defaultEdge">
+		<add as="shape" value="connector"/>
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="endArrow" value="classic"/>
+		<add as="fontSize" value="10"/>
+		<add as="align" value="center"/>
+		<add as="verticalAlign" value="middle"/>
+		<add as="strokeColor" value="black"/>
+	</add>
+	<add as="entity" extend="defaultEdge">
+		<add as="edgeStyle" value="entityRelationEdgeStyle"/>
+	</add>
+	<add as="vertical" extend="defaultEdge">
+		<add as="elbow" value="vertical"/>
+	</add>
+	<add as="straight" extend="defaultVertex">
+		<add as="shape" value="connector"/>
+		<add as="endArrow" value="classic"/>
+	</add>
+	<add as="arrow" extend="defaultVertex">
+		<add as="shape" value="arrow"/>
+		<add as="fillColor" value="red"/>
+	</add>
+	<add as="swimlane" extend="defaultVertex">
+		<add as="shape" value="swimlane"/>
+		<add as="fontSize" value="12"/>
+		<add as="fontStyle" value="1"/>
+		<add as="startSize" value="23"/>
+	</add>
+	<add as="group" extend="defaultVertex">
+		<add as="verticalAlign" value="top"/>
+		<add as="dashed" value="1"/>
+		<add as="opacity" value="50"/>
+	</add>
+	<add as="ellipse" extend="defaultVertex">
+		<add as="shape" value="ellipse"/>
+		<add as="perimeter" value="ellipsePerimeter"/>
+	</add>
+	<add as="rhombus" extend="defaultVertex">
+		<add as="shape" value="rhombus"/>
+		<add as="perimeter" value="rhombusPerimeter"/>
+	</add>
+	<add as="triangle" extend="defaultVertex">
+		<add as="shape" value="triangle"/>
+		<add as="perimeter" value="trianglePerimeter"/>
+	</add>
+	<add as="line" extend="defaultVertex">
+		<add as="shape" value="line"/>
+		<add as="strokeWidth" value="4"/>
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="verticalAlign" value="top"/>
+		<add as="spacingTop" value="8"/>
+	</add>
+	<add as="image" extend="defaultVertex">
+		<add as="shape" value="image"/>
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="verticalLabelPosition" value="bottom"/>
+		<add as="verticalAlign" value="top"/>
+	</add>
+	<add as="roundImage" extend="image">
+		<add as="perimeter" value="ellipsePerimeter"/>
+	</add>
+	<add as="rhombusImage" extend="image">
+		<add as="perimeter" value="rhombusPerimeter"/>
+	</add>
+</mxStylesheet>

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/default-style.xml
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/default-style.xml	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/default-style.xml	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,67 @@
+<mxStylesheet>
+	<include name="/jp/go/aist/rtm/toolscommon/fsm/editor/resources/basic-style.xml"/>
+	<add as="defaultVertex" extend="defaultVertex">
+		<add as="strokeColor" value="#000000"/>
+		<add as="fillColor" value="#E8EEF7"/>
+	</add>
+	<add as="defaultEdge" extend="defaultEdge">
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="rounded" value="1"/>
+		<add as="edgeStyle" value="elbowEdgeStyle"/>
+	</add>
+	<add as="entity" extend="defaultEdge">
+		<add as="edgeStyle" value="entityRelationEdgeStyle"/>
+	</add>
+	<add as="vertical" extend="defaultEdge">
+		<add as="elbow" value="vertical"/>
+	</add>
+	<add as="straight" extend="defaultVertex">
+		<add as="shape" value="connector"/>
+		<add as="endArrow" value="classic"/>
+	</add>
+	<add as="arrow" extend="defaultVertex">
+		<add as="shape" value="arrow"/>
+	</add>
+	<add as="swimlane" extend="defaultVertex">
+		<add as="shape" value="swimlane"/>
+		<add as="fontSize" value="12"/>
+		<add as="fontStyle" value="1"/>
+		<add as="startSize" value="23"/>
+	</add>
+	<add as="group" extend="defaultVertex">
+		<add as="verticalAlign" value="top"/>
+		<add as="dashed" value="1"/>
+		<add as="opacity" value="50"/>
+	</add>
+	<add as="ellipse" extend="defaultVertex">
+		<add as="shape" value="ellipse"/>
+		<add as="perimeter" value="ellipsePerimeter"/>
+	</add>
+	<add as="rhombus" extend="defaultVertex">
+		<add as="shape" value="rhombus"/>
+		<add as="perimeter" value="rhombusPerimeter"/>
+	</add>
+	<add as="triangle" extend="defaultVertex">
+		<add as="shape" value="triangle"/>
+		<add as="perimeter" value="trianglePerimeter"/>
+	</add>
+	<add as="line" extend="defaultVertex">
+		<add as="shape" value="line"/>
+		<add as="strokeWidth" value="4"/>
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="verticalAlign" value="top"/>
+		<add as="spacingTop" value="8"/>
+	</add>
+	<add as="image" extend="defaultVertex">
+		<add as="shape" value="image"/>
+		<add as="labelBackgroundColor" value="white"/>
+		<add as="verticalLabelPosition" value="bottom"/>
+		<add as="verticalAlign" value="top"/>
+	</add>
+	<add as="roundImage" extend="image">
+		<add as="perimeter" value="ellipsePerimeter"/>
+	</add>
+	<add as="rhombusImage" extend="image">
+		<add as="perimeter" value="rhombusPerimeter"/>
+	</add>
+</mxStylesheet>

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor.properties
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor.properties	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor.properties	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,261 @@
+shapes=Shapes
+images=Images
+symbols=Symbols
+file=File
+new=New
+newscxml=New SCXML
+openFile=Open file
+openFileInNewWindow=Open file in new window
+save=Save
+saveAs=Save as
+pageSetup=Page Setup
+print=Print
+exit=Exit
+edit=Edit
+undo=Undo
+redo=Redo
+cut=Cut
+copy=Copy
+paste=Paste
+delete=Delete
+selectAll=Select All
+selectNone=Select None
+warning=Warning
+view=View
+pageLayout=Page Layout
+antialias=Antialias
+grid=Grid
+rulers=Rulers
+zoom=Zoom
+custom=Custom
+zoomIn=Zoom In
+zoomOut=Zoom Out
+page=Page
+width=Width
+actualSize=Actual Size
+format=Format
+alignment=Alignment
+left=Left
+center=Center
+right=Right
+top=Top
+middle=Middle
+bottom=Bottom
+fontcolor=Fontcolor
+linecolor=Linecolor
+fillcolor=Fillcolor
+gradient=Gradient
+label=Label
+labelFill=Label Fill
+labelBorder=Label Border
+position=Position
+shadow=Shadow
+opacity=Opacity
+textOpacity=Text opacity
+hide=Hide
+connector=Connector
+line=Line
+straight=Straight
+horizontal=Horizontal
+vertical=Vertical
+entityRelation=Entity Relation
+arrow=Arrow
+plain=Plain
+rounded=Rounded
+dashed=Dashed
+linewidth=Linewidth
+linestart=Linestart
+open=Open
+openInNewWindow=Open in new window
+classic=Classic
+block=Block
+diamond=Diamond
+oval=Oval
+none=None
+size=Size
+lineend=Lineend
+spacing=Spacing
+sourceSpacing=Source spacing
+targetSpacing=target spacing
+perimeter=Perimeter
+global=Global
+direction=Direction
+north=North
+east=East
+south=South
+west=West
+rotateLabel=Rotate Label
+rotation=Rotation
+image=Image
+style=Style
+shape=Shape
+home=Home
+enterGroup=Enter group
+exitGroup=Exit group
+group=Group
+ungroup=Ungroup
+removeFromGroup=Remove from group
+updateGroupBounds=Update group bounds
+collapse=Collapse
+expand=Expand
+toBack=To Back
+toFront=To Front
+align=Align
+autosize=Autosize
+diagram=Diagram
+outline=Outline
+background=Background
+backgroundColor=Background Color
+backgroundImage=Background Image
+pageBackground=Page background
+layout=Layout
+verticalHierarchical=Vertical Hierarchical
+horizontalHierarchical=Horizontal Hierarchical
+verticalPartition=Vertical Partition
+horizontalPartition=Horizontal Partition
+verticalStack=Vertical Stack
+horizontalStack=Horizontal Stack
+verticalTree=Vertical Tree
+horizontalTree=Horizontal Tree
+parallelEdges=Parallel Edges
+placeEdgeLabels=Edge Labels
+organicLayout=Organic
+circleLayout=Circle
+selection=Selection
+selectPath=Select Path
+selectDirectedPath=Select Directed Path
+selectTree=Select Tree
+selectDirectedTree=Select Directed Tree
+stylesheet=Stylesheet
+basicStyle=Basic Style
+defaultStyle=Default Style
+options=Options
+display=Display
+buffering=Buffering
+dirty=Dirty
+centerPage=Center Page
+centerZoom=Center Zoom
+zoomToSelection=Zoom to Selection
+preferPageSize=Prefer Pagesize
+pageBreaks=Page Breaks
+tolerance=Tolerance
+gridSize=Grid Size
+gridColor=Grid Color
+dot=Dot
+line=Line
+cross=Cross
+dragAndDrop=Drag and Drop
+dragEnabled=Drag Enabled
+dropEnabled=Drop Enabled
+imagePreview=Image Preview
+labels=Labels
+htmlLabels=HTML Labels
+showLabels=Show Labels
+showCell=Show edited cell
+moveEdgeLabels=Move Edge Labels
+moveVertexLabels=Move Vertex Labels
+handleReturn=Handle Return
+connections=Connections
+connectable=Connectable
+connectableEdges=Connectable Edges
+createTarget=Create Target
+connectMode=Connect Mode
+validation=Validation
+allowDanglingEdges=Allow Dangling Edges
+cloneInvalidEdges=Clone Invalid Edges
+allowLoops=Allow Loops
+multigraph=Multigraph
+disconnectOnMove=Disconnect on Move
+window=Window
+help=Help
+aboutGraphEditor=About mxGraph Editor
+magnifyPage=Magnify Page
+selectVertices=Select Vertices
+selectEdges=Select Edges
+newDiagram=New Diagram
+ready=Ready.
+scale=Scale
+value=Value
+file=File
+allImages=All Images
+overwriteExistingFile=Overwrite existing file?
+transparentBackground=Transparent Background?
+noImageData=No Image Data
+invalidImageFormat=Image format unrecognized
+noSourceAndTargetSelected=No source and target selected.
+enterWarningMessage=Enter warning message
+noCellSelected=No cell selected.
+loseChanges=Lose Changes?
+saveChanges=Save Changes?
+fileModified=The file has been modified, overwrite?
+noLayout=Layout unavailable
+error=Error
+nodeNotFound=This node was not found
+addNode=Add node
+addRestrictedNode=Add restricted node
+editNode=Edit node
+editEdge=Edit Transition
+addCorner=Add corner
+removeCorner=Remove corner
+editNodeEdge=Edit node/transition
+editDataModel=Edit datamodel
+editNamespace=Edit namespace
+toggleWithTarget=This cycle has target
+setAsInitialNode=Toggle initial
+setAsFinalNode=Toggle final
+setAsClusterNode=Toggle cluster
+setAsParallelNode=Toggle parallel
+setAsRestrictedNode=Toggle restricted
+setAsDeepHistoryNode=Toggle deep history
+setAsShallowHistoryNode=Toggle shallow history
+toggleViewOutsourcedContent=Toggle display of outsourced content
+refreshViewOutsourcedContent=Reload display of outsourced content
+toggleDisplayContentOutsourced=Toggle display of outsourced content
+doRecursiveLayout=Recursive auto-layout
+doSimpleLayout=Auto-layout
+tools=Tools
+showSCXMLListener=SCXML execution listener
+reloadSCXMLListener=Reload events
+startSCXMLListener=Start
+stopSCXMLListener=Stop
+waitForConnection=Waiting for connection
+ok=Ok
+continue=Continue
+cancel=Cancel
+moveEdgeUp=Move up
+moveEdgeDown=Move down
+findFile=Find file
+find=Find
+ignoreStoredLayout=Ignore stored layout
+createAsNewTargetForMultitarget=Create new edge as an additional target for cloned edge?
+edgeCreationOption=New edge
+SCXMLsrc=Outsourced using SRC attribute
+SCXMLxinclude=Outsourced using Xinclude
+nodeIDTAB=SCXML ID
+nodeNameTAB=Name
+commentsTAB=Comments
+scriptTAB=Other
+outsourceTAB=Source URL
+eventTAB=Event
+changeEvent=change_event#&@
+conditionTAB=Condition
+exeTAB=Executable content
+onEntryTAB=On entry
+onExitTAB=On exit
+finalDataTAB=Final event data
+initialEntryTAB=On initial entry
+namespaceTAB=Namespaces
+datamodelTAB=Datamodel
+titleOutsourceEditor=Set source file to fill the content of this node
+titleEdgeEditor=SCXML edge editor
+titleNodeEditor=SCXML node editor
+titleEdgeOrderEditor=Edge order editor
+xincludeSaveProblem=The following nodes use xinclude in a way incompatible with\nthe old SRC attribute.\nSaving to root file xincluded files for these nodes:
+invalidRestrictionTypeMessage=There is an invalid restriction type in the imported file! This restriction is ignored.
+finalNodeCanNotBeToggledWithRestriction=There is a restricted node in the imported file which is final. Final nodes can not be restricted - the restrictions on this node are ignored.
+invalidRestrictionTypeTitle=Invalid restriction
+restrictionOnFinalNode=Restriction on final node
+userRestrictionConfigNotFoundMessage=The configuration file - which contains user defined restricted states - is not found. Loading the default configuration file...
+userRestrictionConfigNotFoundTitle=Restriction configuration
+eventNameTitle=Event name:
+eventDocumentationTitle=Event documentation:
\ No newline at end of file

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_de.properties
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_de.properties	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_de.properties	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,185 @@
+shapes=Elemente
+images=Bilder
+symbols=Symbole
+file=Datei
+new=Neu
+openFile=Datei öffnen
+save=Speichern
+saveAs=Speichern unter
+pageSetup=Seite einrichten
+print=Drucken
+exit=Beenden
+edit=Bearbeiten
+undo=Rückgänging
+redo=Wiederherstellen
+cut=Ausschneiden
+copy=Kopieren
+paste=Einfügen
+delete=Löschen
+selectAll=Alle markieren
+selectNone=Markierung aufheben
+warning=Warnung
+view=Ansicht
+pageLayout=Seitenansicht
+antialias=Kanten glätten
+grid=Gitter
+rulers=Lineal
+zoom=Zoom
+custom=Anpassen
+zoomIn=Hineinzoomen
+zoomOut=Herauszoomen
+page=Seite
+width=Breite
+actualSize=Tatsächliche Grösse
+format=Format
+alignment=Ausrichtung
+left=Links
+center=Zentriert
+right=Rechts
+top=Oben
+middle=Mitte
+bottom=Unten
+fontcolor=Schriftfarbe
+linecolor=Linienfarbe
+fillcolor=Füllfarbe
+gradient=Farbverlauf
+label=Beschriftung
+labelFill=Beschriftung Füllfarbe
+labelBorder=Beschriftung Rahmenfarbe
+position=Position
+shadow=Schatten
+opacity=Deckkraft
+textOpacity=Text Deckkraft
+hide=Verstecken
+connector=Verbindung
+line=Linie
+straight=Gerade
+horizontal=Horizontal
+vertical=Vertikal
+entityRelation=Entity Relation
+arrow=Pfeil
+plain=Einfach
+rounded=Abgerundet
+dashed=Gestrichelt
+linewidth=Linienbreite
+linestart=Linienanfang
+open=Offen
+classic=Klassisch
+block=Block
+diamond=Diamant
+oval=Oval
+none=Keine
+size=Grösse
+lineend=Linienende
+spacing=Abstand
+sourceSpacing=Anfangsabstand
+targetSpacing=Endabstand
+perimeter=Umriss
+global=Global
+direction=Richtung
+north=Norden
+east=Osten
+south=Süden
+west=Westen
+rotateLabel=Beschriftung rotieren
+rotation=Rotation
+image=Bild
+style=Stil
+shape=Element
+home=Oberste Ebene
+enterGroup=In Gruppe hinein
+exitGroup=Aus Gruppe heraus
+group=Gruppieren
+ungroup=Gruppe aufheben
+removeFromGroup=Aus Gruppe herauslösen
+updateGroupBounds=Gruppengrenzen aktualisieren
+collapse=Zusammenziehen
+expand=Expandieren
+toBack=Nach Hinten
+toFront=Nach Vorne
+align=Ausrichten
+autosize=Automatische Grösse
+diagram=Diagramm
+outline=Übersicht
+background=Hintergrund
+backgroundColor=Hintergrundfarbe
+backgroundImage=Hintergrundbild
+pageBackground=Seitenhintergrund
+layout=Anordnung
+verticalHierarchical=Vertikal Hierarchisch
+horizontalHierarchical=Horizontal Hierarchisch
+verticalPartition=Vertikale Partitionierung
+horizontalPartition=Horizontale Partitionierung
+verticalStack=Vertiker Stapel
+horizontalStack=Horizontaler Stapel
+verticalTree=Vertikaler Baum
+horizontalTree=Horizontaler Baum
+parallelEdges=Parallele Kanten
+placeEdgeLabels=Kantenbeschriftungen
+organicLayout=Organisch
+circleLayout=Kreis
+selection=Markierung
+selectPath=Pfad markieren
+selectDirectedPath=Gerichteten Pfad markieren
+selectTree=Baum markieren
+selectDirectedTree=Gerichteten Baum markieren
+stylesheet=Stylesheet
+basicStyle=Basic Style
+defaultStyle=Default Style
+options=Optionen
+display=Darstellung
+buffering=Buffering
+dirty=Dirty
+centerPage=Seite zentrieren
+centerZoom=Zoom zentrieren
+zoomToSelection=Zur Markierung zoomen
+preferPageSize=Seitengrösse vorziehen
+pageBreaks=Seitenumbruch anzeigen
+tolerance=Toleranz
+gridSize=Gittergrösse
+gridColor=Gitterfarbe
+dot=Punkt
+line=Linie
+cross=Kreuz
+dragAndDrop=Drag and Drop
+dragEnabled=Drag zulassen
+dropEnabled=Drop zulassen
+imagePreview=Bildvorschau
+labels=Beschriftungen
+htmlLabels=HTML Beschriftungen
+showLabels=Beschriftungen anzeigen
+moveEdgeLabels=Kantenbeschriftungen verschieben
+moveVertexLabels=Knotenberschriftungen verschieben
+handleReturn=Return behandeln
+connections=Verbindungen
+connectable=Verbindungen zulassen
+connectableEdges=Verbindungen zwischen Kanten zulassen
+createTarget=Ziel erstellen
+connectMode=Verbindungsmethode
+validation=Validierung
+allowDanglingEdges=Schwebende Kanten zulassen
+cloneInvalidEdges=Ungültige Kanten klonen
+allowLoops=Schlaufen zulassen
+multigraph=Multigraph
+disconnectOnMove=Trennen beim verschieben
+window=Fenster
+help=Hilfe
+aboutGraphEditor=Über mxGraph Editor
+magnifyPage=Seite vergrössern
+selectVertices=Knoten markieren
+selectEdges=Kanten markieren
+newDiagram=Neues Diagramm
+ready=Bereit.
+scale=Skalierung
+value=Wert
+file=Datei
+allImages=Alle Bilddateien
+overwriteExistingFile=Vorhandene Datei überschreiben?
+transparentBackground=Transparenter Hintegrund?
+noImageData=Kein Bilddaten
+noSourceAndTargetSelected=Keine Quelle und Ziel markiert.
+enterWarningMessage=Warnung eingeben
+noCellSelected=Keine Zelle markiert.
+loseChanges=Änderungen verlieren?
+noLayout=Layout nicht verfügbar
+error=Fehler

Added: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_zh-CN.properties
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_zh-CN.properties	                        (rev 0)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/fsm/editor/resources/editor_zh-CN.properties	2017-01-22 06:12:06 UTC (rev 655)
@@ -0,0 +1,183 @@
+shapes=Shapes
+images=Images
+symbols=Symbols
+file=File
+new=New
+openFile=Open File
+save=\u4FDD\u5B58
+saveAs=Save As
+pageSetup=Page Setup
+print=Print
+exit=Exit
+edit=Edit
+undo=Undo
+redo=Redo
+cut=Cut
+copy=Copy
+paste=Paste
+delete=Delete
+selectAll=Select All
+selectNone=Select None
+warning=Warning
+view=View
+pageLayout=Page Layout
+antialias=Antialias
+grid=Grid
+rulers=Rulers
+zoom=Zoom
+custom=Custom
+zoomIn=Zoom In
+zoomOut=Zoom Out
+page=Page
+width=Width
+actualSize=Actual Size
+format=Format
+alignment=Alignment
+left=Left
+center=Center
+right=Right
+top=Top
+middle=Middle
+bottom=Bottom
+fontcolor=Fontcolor
+linecolor=Linecolor
+fillcolor=Fillcolor
+gradient=Gradient
+label=Label
+labelFill=Label Fill
+labelBorder=Label Border
+position=Position
+shadow=Shadow
+opacity=Opacity
+textOpacity=Text opacity
+hide=Hide
+connector=Connector
+line=Line
+straight=Straight
+horizontal=Horizontal
+vertical=Vertical
+entityRelation=Entity Relation
+arrow=Arrow
+plain=Plain
+rounded=Rounded
+dashed=Dashed
+linewidth=Linewidth
+linestart=Linestart
+open=Open
+classic=Classic
+block=Block
+diamond=Diamond
+oval=Oval
+none=None
+size=Size
+lineend=Lineend
+spacing=Spacing
+sourceSpacing=Source spacing
+targetSpacing=target spacing
+perimeter=Perimeter
+global=Global
+direction=Direction
+north=North
+east=East
+south=South
+west=West
+rotateLabel=Rotate Label
+rotation=Rotation
+image=Image
+style=Style
+shape=Shape
+home=Home
+enterGroup=Enter group
+exitGroup=Exit group
+group=Group
+ungroup=Ungroup
+removeFromGroup=Remove from group
+collapse=Collapse
+expand=Expand
+toBack=To Back
+toFront=To Front
+align=Align
+autosize=Autosize
+diagram=Diagram
+outline=Outline
+background=Background
+backgroundColor=Background Color
+backgroundImage=Background Image
+pageBackground=Page background
+layout=Layout
+verticalHierarchical=Vertical Hierarchical
+horizontalHierarchical=Horizontal Hierarchical
+verticalPartition=Vertical Partition
+horizontalPartition=Horizontal Partition
+verticalStack=Vertical Stack
+horizontalStack=Horizontal Stack
+verticalTree=Vertical Tree
+horizontalTree=Horizontal Tree
+parallelEdges=Parallel Edges
+placeEdgeLabels=Edge Labels
+organicLayout=Organic
+circleLayout=Circle
+selection=Selection
+selectPath=Select Path
+selectDirectedPath=Select Directed Path
+selectTree=Select Tree
+selectDirectedTree=Select Directed Tree
+stylesheet=Stylesheet
+basicStyle=Basic Style
+defaultStyle=Default Style
+options=Options
+display=Display
+buffering=Buffering
+dirty=Dirty
+centerPage=Center Page
+centerZoom=Center Zoom
+zoomToSelection=Zoom to Selection
+preferPageSize=Prefer Pagesize
+pageBreaks=Page Breaks
+tolerance=Tolerance
+gridSize=Grid Size
+gridColor=Grid Color
+dot=Dot
+line=Line
+cross=Cross
+dragAndDrop=Drag and Drop
+dragEnabled=Drag Enabled
+dropEnabled=Drop Enabled
+imagePreview=Image Preview
+labels=Labels
+htmlLabels=HTML Labels
+showLabels=Show Labels
+moveEdgeLabels=Move Edge Labels
+moveVertexLabels=Move Vertex Labels
+handleReturn=Handle Return
+connections=Connections
+connectable=Connectable
+connectableEdges=Connectable Edges
+createTarget=Create Target
+connectMode=Connect Mode
+validation=Validation
+allowDanglingEdges=Allow Dangling Edges
+cloneInvalidEdges=Clone Invalid Edges
+allowLoops=Allow Loops
+multigraph=Multigraph
+disconnectOnMove=Disconnect on Move
+window=Window
+help=Help
+aboutGraphEditor=About mxGraph Editor
+magnifyPage=Magnify Page
+selectVertices=Select Vertices
+selectEdges=Select Edges
+newDiagram=New Diagram
+ready=Ready.
+scale=Scale
+value=Value
+file=File
+allImages=All Images
+overwriteExistingFile=Overwrite existing file?
+transparentBackground=Transparent Background?
+noImageData=No Image Data
+noSourceAndTargetSelected=No source and target selected.
+enterWarningMessage=Enter warning message
+noCellSelected=No cell selected.
+loseChanges=Lose Changes?
+noLayout=This layout is not available in the open source- and demo-version.

Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/SystemDiagram.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/SystemDiagram.java	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/SystemDiagram.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -5,6 +5,7 @@
 import java.util.Map;
 
 import jp.go.aist.rtm.toolscommon.model.core.ModelElement;
+import jp.go.aist.rtm.toolscommon.model.core.Point;
 
 import org.eclipse.emf.common.util.EList;
 import org.openrtp.namespaces.rts.version02.RtsProfileExt;
@@ -252,6 +253,13 @@
 	Map<String, PortConnector> getConnectorMap();
 
 	/**
+	 * @param connectorId
+	 *            コネクタID
+	 * @return 対象コネクタのベンドポイント設定をマップで返します。
+	 */
+	Map<Integer, Point> getPortConnectorRoutingConstraint(String connectorId);
+
+	/**
 	 * @param component	削除するコンポーネント
 	 */
 	void removeComponent(Component component);

Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/impl/SystemDiagramImpl.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/impl/SystemDiagramImpl.java	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/component/impl/SystemDiagramImpl.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -13,6 +13,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
 
 import jp.go.aist.rtm.toolscommon.model.component.Component;
 import jp.go.aist.rtm.toolscommon.model.component.ComponentFactory;
@@ -24,6 +25,7 @@
 import jp.go.aist.rtm.toolscommon.model.component.SystemDiagramKind;
 import jp.go.aist.rtm.toolscommon.model.component.util.CorbaObserverStore;
 import jp.go.aist.rtm.toolscommon.model.component.util.PropertyMap;
+import jp.go.aist.rtm.toolscommon.model.core.Point;
 import jp.go.aist.rtm.toolscommon.model.core.impl.ModelElementImpl;
 import jp.go.aist.rtm.toolscommon.synchronizationframework.RefreshThread;
 import jp.go.aist.rtm.toolscommon.synchronizationframework.SynchronizationSupport;
@@ -816,7 +818,7 @@
 		return result.toString();
 	}
 
-	@SuppressWarnings("unchecked")
+	@SuppressWarnings("rawtypes")
 	@Override
 	public java.lang.Object getAdapter(Class adapter) {
 		java.lang.Object result = null;
@@ -839,14 +841,28 @@
 		this.profile = profile;
 	}
 
-	private Map<String, PortConnector> connectorMap = new HashMap<String, PortConnector>();
+	private Map<String, PortConnector> connectorMap = new HashMap<>();
 
 	@Override
 	public Map<String, PortConnector> getConnectorMap() {
 		return connectorMap;
 	}
 
+	private Map<String, Map<Integer, Point>> portConnectorRoutingConstraintMap = new HashMap<>();
+
 	@Override
+	public Map<Integer, Point> getPortConnectorRoutingConstraint(
+			String connectorId) {
+		Map<Integer, Point> ret = this.portConnectorRoutingConstraintMap
+				.get(connectorId);
+		if (ret == null) {
+			ret = new TreeMap<>();
+			this.portConnectorRoutingConstraintMap.put(connectorId, ret);
+		}
+		return ret;
+	}
+
+	@Override
 	public void dispose() {
 		if (syncLocalThread != null) {
 			syncLocalThread.setSynchronizeInterval(-1);

Modified: branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java	2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java	2017-01-22 06:12:06 UTC (rev 655)
@@ -17,9 +17,19 @@
 
 import jp.go.aist.rtm.toolscommon.corba.CorbaUtil;
 import jp.go.aist.rtm.toolscommon.factory.ComponentLoader;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
 import jp.go.aist.rtm.toolscommon.model.component.ComponentFactory;
+import jp.go.aist.rtm.toolscommon.model.component.ComponentSpecification;
+import jp.go.aist.rtm.toolscommon.model.component.ConfigurationSet;
+import jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile;
+import jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile.PROP;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+import jp.go.aist.rtm.toolscommon.model.component.NameValue;
+import jp.go.aist.rtm.toolscommon.model.component.Port;
+import jp.go.aist.rtm.toolscommon.model.component.PortConnector;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
 import jp.go.aist.rtm.toolscommon.model.component.SystemDiagramKind;
-import jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile.PROP;
 import jp.go.aist.rtm.toolscommon.model.component.util.PortConnectorFactory;
 import jp.go.aist.rtm.toolscommon.model.core.Point;
 import jp.go.aist.rtm.toolscommon.model.core.Rectangle;
@@ -27,36 +37,9 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.emf.common.util.EList;
-import org.openrtp.namespaces.rts.version02.Component;
-import org.openrtp.namespaces.rts.version02.ComponentExt;
-import org.openrtp.namespaces.rts.version02.ConfigurationData;
-import org.openrtp.namespaces.rts.version02.ConfigurationSet;
-import org.openrtp.namespaces.rts.version02.Dataport;
-import org.openrtp.namespaces.rts.version02.DataportConnector;
-import org.openrtp.namespaces.rts.version02.DataportConnectorExt;
-import org.openrtp.namespaces.rts.version02.DataportExt;
-import org.openrtp.namespaces.rts.version02.ExecutionContext;
-import org.openrtp.namespaces.rts.version02.ExecutionContextExt;
-import org.openrtp.namespaces.rts.version02.Location;
-import org.openrtp.namespaces.rts.version02.ObjectFactory;
-import org.openrtp.namespaces.rts.version02.Participants;
-import org.openrtp.namespaces.rts.version02.Property;
-import org.openrtp.namespaces.rts.version02.RtsProfile;
-import org.openrtp.namespaces.rts.version02.RtsProfileExt;
-import org.openrtp.namespaces.rts.version02.Serviceport;
-import org.openrtp.namespaces.rts.version02.ServiceportConnector;
-import org.openrtp.namespaces.rts.version02.ServiceportConnectorExt;
-import org.openrtp.namespaces.rts.version02.ServiceportExt;
-import org.openrtp.namespaces.rts.version02.TargetComponent;
-import org.openrtp.namespaces.rts.version02.TargetComponentExt;
-import org.openrtp.namespaces.rts.version02.TargetPort;
-import org.openrtp.namespaces.rts.version02.TargetPortExt;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import RTC.RTObject;
-import RTC.RTObjectHelper;
-
 import com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl;
 
 /**
@@ -69,10 +52,10 @@
 			.getLogger(RtsProfileHandler.class);
 
 	private boolean online;
-	private RtsProfileExt originalProfile;
+	private org.openrtp.namespaces.rts.version02.RtsProfileExt originalProfile;
 	private List<String> savedConnectors;
-	private ObjectFactory factory;
-	private jp.go.aist.rtm.toolscommon.model.component.SystemDiagram diagram;
+	private org.openrtp.namespaces.rts.version02.ObjectFactory factory;
+	private SystemDiagram diagram;
 	private ComponentLoader loader = new ComponentLoader();
 
 	static final String KEY_COMPONENT_PATH_ID = "COMPONENT_PATH_ID";
@@ -86,21 +69,22 @@
 	 * @return				ロードしたシステムダイアグラム
 	 * @throws Exception
 	 */
-	public jp.go.aist.rtm.toolscommon.model.component.SystemDiagram load(
-			String targetFile, SystemDiagramKind kind) throws Exception {
-		RtsProfileExt profile = load(targetFile);
+	public SystemDiagram load(String targetFile, SystemDiagramKind kind)
+			throws Exception {
+		org.openrtp.namespaces.rts.version02.RtsProfileExt profile = load(targetFile);
 		return load(profile, kind);
 	}
 
-	public RtsProfileExt load(String targetFile) throws Exception {
+	public org.openrtp.namespaces.rts.version02.RtsProfileExt load(String targetFile) throws Exception {
 		LOGGER.debug("load: targetFile=<{}>", targetFile);
 		XmlHandler handler = new XmlHandler();
-		RtsProfileExt profile = handler.loadXmlRts(targetFile);
+		org.openrtp.namespaces.rts.version02.RtsProfileExt profile = handler.loadXmlRts(targetFile);
 		return profile;
 	}
 
-	public jp.go.aist.rtm.toolscommon.model.component.SystemDiagram load(
-			RtsProfileExt profile, SystemDiagramKind kind) throws Exception {
+	public SystemDiagram load(
+			org.openrtp.namespaces.rts.version02.RtsProfileExt profile,
+			SystemDiagramKind kind) throws Exception {
 		diagram = ComponentFactory.eINSTANCE.createSystemDiagram();
 		diagram.setProfile(profile);
 		diagram.setKind(kind);
@@ -115,20 +99,19 @@
 	 * ダイアグラムの直下に含まれる全コンポーネントに対し、IORからCORABAオブジェクトを設定する
 	 * @param eDiagram
 	 */
-	public void populateCorbaBaseObject(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
+	public void populateCorbaBaseObject(SystemDiagram eDiagram) {
 		for (Object element : eDiagram.getRegisteredComponents()) {
-			if (!(element instanceof jp.go.aist.rtm.toolscommon.model.component.CorbaComponent)) continue;
-			jp.go.aist.rtm.toolscommon.model.component.CorbaComponent eCorbaComp = (jp.go.aist.rtm.toolscommon.model.component.CorbaComponent)element;
+			if (!(element instanceof CorbaComponent)) continue;
+			CorbaComponent eCorbaComp = (CorbaComponent)element;
 			String ior = eCorbaComp.getIor();
 			if (ior == null) continue;
 			eCorbaComp.setCorbaObject(getRTObject(ior));
 		}
 	}
 
-	private RTObject getRTObject(String ior) {
+	private RTC.RTObject getRTObject(String ior) {
 		try {
-			return RTObjectHelper.narrow(CorbaUtil.stringToObject(ior));
+			return RTC.RTObjectHelper.narrow(CorbaUtil.stringToObject(ior));
 		} catch (Exception e) {
 			return null;
 		}
@@ -138,15 +121,13 @@
 	 * RTSプロファイルからダイアグラム内にあるコンポーネント間の接続を復元させる
 	 * @param eDiagram
 	 */
-	public void restoreConnection(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
+	public void restoreConnection(SystemDiagram eDiagram) {
 		this.diagram = eDiagram;
 		setOnline(eDiagram.getKind() == SystemDiagramKind.ONLINE_LITERAL);
 		loader.setKind(eDiagram.getKind());
 		loader.setDiagram(diagram);
-		RtsProfileExt profile = eDiagram.getProfile();
-		List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps
-			= eDiagram.getRegisteredComponents();
+		org.openrtp.namespaces.rts.version02.RtsProfileExt profile = eDiagram.getProfile();
+		List<Component> eComps = eDiagram.getRegisteredComponents();
 		populateDataConnector(eComps, profile.getDataPortConnectors());
 		populateServiceConnector(eComps, profile.getServicePortConnectors());
 	}
@@ -155,21 +136,17 @@
 	 * RTSプロファイルからダイアグラム内にあるコンポーネントのコンフィグセットを復元させる
 	 * @param eDiagram
 	 */
-	public void restoreConfigSet(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eDiagram
-				.getRegisteredComponents()) {
-			Component component = findComponent(eComp, eDiagram.getProfile()
+	public void restoreConfigSet(SystemDiagram eDiagram) {
+		for (Component eComp : eDiagram.getRegisteredComponents()) {
+			org.openrtp.namespaces.rts.version02.Component component = findComponent(eComp, eDiagram.getProfile()
 					.getComponents());
 			populateConfigSets(eComp, component);
 		}
 	}
 
-	public void restoreConfigSetbyIOR(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eDiagram
-				.getRegisteredComponents()) {
-			Component component = findComponentByIOR(eComp, eDiagram
+	public void restoreConfigSetbyIOR(SystemDiagram eDiagram) {
+		for (Component eComp : eDiagram.getRegisteredComponents()) {
+			org.openrtp.namespaces.rts.version02.Component component = findComponentByIOR(eComp, eDiagram
 					.getProfile().getComponents());
 			populateConfigSets(eComp, component);
 		}
@@ -179,12 +156,10 @@
 	 * オフラインの複合コンポーネントのポートを復元させる
 	 * @param eDiagram
 	 */
-	public void restoreCompositeComponentPort(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
-		List<Component> source = eDiagram.getProfile().getComponents();
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eDiagram
-				.getRegisteredComponents()) {
-			Component component = findComponent(eComp, source);
+	public void restoreCompositeComponentPort(SystemDiagram eDiagram) {
+		List<org.openrtp.namespaces.rts.version02.Component> source = eDiagram.getProfile().getComponents();
+		for (Component eComp : eDiagram.getRegisteredComponents()) {
+			org.openrtp.namespaces.rts.version02.Component component = findComponent(eComp, source);
 			populateCompositeComponentPort(eComp, component);
 		}
 	}
@@ -194,23 +169,20 @@
 	 * 
 	 * @param eDiagram
 	 */
-	public void restoreExecutionContext(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
-		List<Component> components = eDiagram.getProfile().getComponents();
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eDiagram
-				.getRegisteredComponents()) {
-			Component comp = findComponent(eComp, components);
+	public void restoreExecutionContext(SystemDiagram eDiagram) {
+		List<org.openrtp.namespaces.rts.version02.Component> components = eDiagram.getProfile().getComponents();
+		for (Component eComp : eDiagram.getRegisteredComponents()) {
+			org.openrtp.namespaces.rts.version02.Component comp = findComponent(eComp, components);
 			if (comp == null) {
 				continue;
 			}
-			if (!online
-					&& eComp instanceof jp.go.aist.rtm.toolscommon.model.component.ComponentSpecification) {
+			if (!online && eComp instanceof ComponentSpecification) {
 				// オフラインの場合は owned ECを作成
 				// 事前にリポジトリからコピーされたECはクリアし、RTSプロファイルのものを優先
 				eComp.getExecutionContexts().clear();
 				eComp.getExecutionContextHandler().clear();
-				for (ExecutionContext ec : comp.getExecutionContexts()) {
-					jp.go.aist.rtm.toolscommon.model.component.ExecutionContext eEc = ComponentFactory.eINSTANCE
+				for (org.openrtp.namespaces.rts.version02.ExecutionContext ec : comp.getExecutionContexts()) {
+					ExecutionContext eEc = ComponentFactory.eINSTANCE
 							.createExecutionContext();
 					if ("PERIODIC".equals(ec.getKind())) {
 						eEc.setKindL(KIND_PERIODIC);
@@ -224,10 +196,10 @@
 					eEc.setRateR(ec.getRate());
 					eEc.setOwner(eComp);
 
-					if (ec instanceof ExecutionContextExt) {
-						ExecutionContextExt ecExt = (ExecutionContextExt) ec;
+					if (ec instanceof org.openrtp.namespaces.rts.version02.ExecutionContextExt) {
+						org.openrtp.namespaces.rts.version02.ExecutionContextExt ecExt = (org.openrtp.namespaces.rts.version02.ExecutionContextExt) ec;
 						// ECのプロパティ設定
-						for (Property prop : ecExt.getProperties()) {
+						for (org.openrtp.namespaces.rts.version02.Property prop : ecExt.getProperties()) {
 							eEc.setProperty(prop.getName(), prop.getValue());
 						}
 					}
@@ -237,9 +209,8 @@
 				eComp.getExecutionContextHandler().sync();
 			} else {
 				// オンラインの場合は rateを更新
-				for (jp.go.aist.rtm.toolscommon.model.component.ExecutionContext eEc : eComp
-						.getExecutionContexts()) {
-					ExecutionContext ec = findExecutionContext(eEc, eComp, comp
+				for (ExecutionContext eEc : eComp.getExecutionContexts()) {
+					org.openrtp.namespaces.rts.version02.ExecutionContext ec = findExecutionContext(eEc, eComp, comp
 							.getExecutionContexts());
 					if (ec == null) {
 						continue;
@@ -248,16 +219,15 @@
 				}
 			}
 			// ECのparticipantの設定
-			for (jp.go.aist.rtm.toolscommon.model.component.ExecutionContext eEc : eComp
-					.getExecutionContexts()) {
-				ExecutionContext ec = findExecutionContext(eEc, eComp, comp
+			for (ExecutionContext eEc : eComp.getExecutionContexts()) {
+				org.openrtp.namespaces.rts.version02.ExecutionContext ec = findExecutionContext(eEc, eComp, comp
 						.getExecutionContexts());
 				if (ec == null) {
 					continue;
 				}
-				for (TargetComponent tc : ec.getParticipants()) {
-					jp.go.aist.rtm.toolscommon.model.component.Component eComp2 = findEMFComponentByTargetComponent(
-							tc, eDiagram.getRegisteredComponents());
+				for (org.openrtp.namespaces.rts.version02.TargetComponent tc : ec.getParticipants()) {
+					Component eComp2 = findEMFComponentByTargetComponent(tc,
+							eDiagram.getRegisteredComponents());
 					if (eComp2 == null) {
 						continue;
 					}
@@ -275,8 +245,8 @@
 	 * @param eDiagram
 	 * @return
 	 */
-	public RtsProfileExt save(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram) {
+	public org.openrtp.namespaces.rts.version02.RtsProfileExt save(
+			SystemDiagram eDiagram) {
 		this.diagram = eDiagram;
 
 		setOnline(eDiagram.getKind() == SystemDiagramKind.ONLINE_LITERAL);
@@ -284,8 +254,8 @@
 		originalProfile = eDiagram.getProfile();
 		savedConnectors = new ArrayList<String>();
 
-		factory = new ObjectFactory();
-		RtsProfileExt profile = factory.createRtsProfileExt();
+		factory = new org.openrtp.namespaces.rts.version02.ObjectFactory();
+		org.openrtp.namespaces.rts.version02.RtsProfileExt profile = factory.createRtsProfileExt();
 		profile.setId(eDiagram.getSystemId());
 		DatatypeFactory dateFactory = new DatatypeFactoryImpl();
 		profile.setCreationDate(dateFactory.newXMLGregorianCalendar(eDiagram.getCreationDate()));
@@ -309,49 +279,49 @@
 	}
 
 	// Open時にRTSプロファイルをシステムダイアログに変換する
-	public void populate(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram,
-			RtsProfileExt profile) {
+	public void populate(SystemDiagram eDiagram,
+			org.openrtp.namespaces.rts.version02.RtsProfileExt profile) {
 		eDiagram.setSystemId(profile.getId());
 		eDiagram.setCreationDate(profile.getCreationDate().toString());
 		eDiagram.setUpdateDate(profile.getUpdateDate().toString());
 		populate(eDiagram.getComponents(), profile);
 		// ダイアグラムのプロパティ設定
-		for (Property prop : profile.getProperties()) {
+		for (org.openrtp.namespaces.rts.version02.Property prop : profile.getProperties()) {
 			eDiagram.setProperty(prop.getName(), prop.getValue());
 		}
 		// ポートはCORBAObjectまたはRTCProfileを正とするので、この段階ではまだ接続できない
-	}
 
-	// ベンドポイントの文字列表現をMap表現に変換する
-	public Map<Integer, Point> convertFromBendPointString(String bendPoint) {
-		if (StringUtils.isBlank(bendPoint)) return null;
-		String content = bendPoint.trim();
-		content = content.substring(1, content.length() - 1).trim(); // { }除去
-		
-		Map<Integer, Point> result = new HashMap<Integer, Point>();
-		while(content.length() > 0) {
-			content = populatePoint(result, content);
+		// ポート接続のベンドポイントは描画用の情報なのでダイアグラムへ格納し、モデルと分離しておく
+		// データポート接続
+		for (org.openrtp.namespaces.rts.version02.DataportConnector conn : profile
+				.getDataPortConnectors()) {
+			String connectorId = conn.getConnectorId();
+			Map<Integer, Point> bp = getBendPoint(conn);
+			eDiagram.getPortConnectorRoutingConstraint(connectorId).putAll(bp);
 		}
-		
-		return result;
+		// サービスポート接続
+		for (org.openrtp.namespaces.rts.version02.ServiceportConnector conn : profile
+				.getServicePortConnectors()) {
+			String connectorId = conn.getConnectorId();
+			Map<Integer, Point> bp = getBendPoint(conn);
+			eDiagram.getPortConnectorRoutingConstraint(connectorId).putAll(bp);
+		}
 	}
 
 	// Save時にシステムダイアログ内に含まれるコンポーネントをRTSプロファイル内にセットする
 	private void populateComponents(
-			jp.go.aist.rtm.toolscommon.model.component.SystemDiagram eDiagram,
-			RtsProfileExt rtsProfile) {
-		List<Component> components = rtsProfile.getComponents();
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp:
-				eDiagram.getRegisteredComponents()) {
-			ComponentExt target = factory.createComponentExt();
+			SystemDiagram eDiagram,
+			org.openrtp.namespaces.rts.version02.RtsProfileExt rtsProfile) {
+		List<org.openrtp.namespaces.rts.version02.Component> components = rtsProfile.getComponents();
+		for (Component eComp : eDiagram.getRegisteredComponents()) {
+			org.openrtp.namespaces.rts.version02.ComponentExt target = factory.createComponentExt();
 			target.setId(eComp.getComponentId());
 			target.setPathUri(eComp.getPathId());
 			target.setInstanceName(eComp.getInstanceNameL());
 			target.setCompositeType(eComp.getCompositeTypeL());
 			target.setIsRequired(eComp.isRequired());
 
-			Component original = findOriginalComponent(eComp);
+			org.openrtp.namespaces.rts.version02.Component original = findOriginalComponent(eComp);
 
 			populateExecutionContext(eComp, target, original);			
 			populateComponentLocation(eComp, target);			
@@ -368,23 +338,25 @@
 	// Save時にシステムダイアログ内に含まれるデータポートとそれらの接続をRTSプロファイル内にセットする
 	// Save時にダイアグラム内に含まれるサービスポート(とその接続)の情報をRTSプロファイル内にセットする
 	private void populatePorts(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			ComponentExt target, Component original, RtsProfileExt rtsProfile) {
-		for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp.getOutports()) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original,
+			org.openrtp.namespaces.rts.version02.RtsProfileExt rtsProfile) {
+		for (Port ePort : eComp.getOutports()) {
 			addDataPort(ePort, target, original);
-			for (jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
+			for (ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
 				addDataPortConnector(eConnProf, rtsProfile, ePort);
 			}
 		}
-		for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp.getInports()) {
+		for (Port ePort : eComp.getInports()) {
 			addDataPort(ePort, target, original);
-			for (jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
+			for (ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
 				addDataPortConnector(eConnProf, rtsProfile, ePort);
 			}
 		}
-		for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp.getServiceports()) {
+		for (Port ePort : eComp.getServiceports()) {
 			addServicePort(ePort, target, original);
-			for (jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
+			for (ConnectorProfile eConnProf : ePort.getConnectorProfiles()) {
 				addServicePortConnector(eConnProf, rtsProfile, ePort);
 			}
 		}
@@ -392,9 +364,9 @@
 
 	// データポートコネクタをRTSに追加する
 	private void addDataPortConnector(
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf,
-			RtsProfileExt rtsProfile,
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort) {
+			ConnectorProfile eConnProf,
+			org.openrtp.namespaces.rts.version02.RtsProfileExt rtsProfile,
+			Port ePort) {
 		String connectorId = eConnProf.getConnectorId();
 		if(savedConnectors.contains(connectorId) ) return;
 		rtsProfile.getDataPortConnectors().add(saveDataPortConnector(ePort, eConnProf));
@@ -403,9 +375,9 @@
 
 	// サービスポートコネクタをRTSに追加する
 	private void addServicePortConnector(
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf,
-			RtsProfileExt rtsProfile,
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort) {
+			ConnectorProfile eConnProf,
+			org.openrtp.namespaces.rts.version02.RtsProfileExt rtsProfile,
+			Port ePort) {
 		String connectorId = eConnProf.getConnectorId();
 		if(savedConnectors.contains(connectorId) ) return;
 		rtsProfile.getServicePortConnectors().add(saveServicePortConnector(ePort, eConnProf));
@@ -413,10 +385,9 @@
 	}
 
 	// Save時にシステムダイアログ内に含まれるデータポート接続をRTSプロファイル内の該当要素に変換する
-	private DataportConnector saveDataPortConnector(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf) {
-		DataportConnectorExt connector = factory.createDataportConnectorExt();
+	private org.openrtp.namespaces.rts.version02.DataportConnector saveDataPortConnector(
+			Port ePort, ConnectorProfile eConnProf) {
+		org.openrtp.namespaces.rts.version02.DataportConnectorExt connector = factory.createDataportConnectorExt();
 		connector.setConnectorId(eConnProf.getConnectorId());
 		connector.setName(eConnProf.getName());
 		connector.setInterfaceType(eConnProf.getInterfaceType());
@@ -430,14 +401,14 @@
 		}
 
 		// ベンドポイントの保存
-		jp.go.aist.rtm.toolscommon.model.component.PortConnector ePortConnector = diagram
-				.getConnectorMap().get(eConnProf.getConnectorId());
+		PortConnector ePortConnector = diagram.getConnectorMap().get(
+				eConnProf.getConnectorId());
 		if (ePortConnector != null) {
 			saveBendPoint(ePortConnector.getRoutingConstraint().map(),
 					connector.getProperties());
 		}
 
-		DataportConnector original = findOrignalDataportConnector(eConnProf
+		org.openrtp.namespaces.rts.version02.DataportConnector original = findOrignalDataportConnector(eConnProf
 				.getConnectorId());
 
 		if (eConnProf.getSourceString() != null) {
@@ -451,8 +422,8 @@
 					original == null ? null : original.getTargetDataPort()));
 		}
 
-		if (original instanceof DataportConnectorExt) {
-			DataportConnectorExt originalExt = (DataportConnectorExt) original;
+		if (original instanceof org.openrtp.namespaces.rts.version02.DataportConnectorExt) {
+			org.openrtp.namespaces.rts.version02.DataportConnectorExt originalExt = (org.openrtp.namespaces.rts.version02.DataportConnectorExt) original;
 			connector.setComment(originalExt.getComment());
 			if (!originalExt.isVisible()) {
 				connector.setVisible(Boolean.valueOf(originalExt.isVisible()));
@@ -526,23 +497,22 @@
 	}
 
 	// Save時にシステムダイアログ内に含まれるサービスポート接続をRTSプロファイル内の該当要素に変換する
-	private ServiceportConnector saveServicePortConnector(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf) {
-		ServiceportConnectorExt connector = factory
+	private org.openrtp.namespaces.rts.version02.ServiceportConnector saveServicePortConnector(
+			Port ePort, ConnectorProfile eConnProf) {
+		org.openrtp.namespaces.rts.version02.ServiceportConnectorExt connector = factory
 				.createServiceportConnectorExt();
 		connector.setConnectorId(eConnProf.getConnectorId());
 		connector.setName(eConnProf.getName());
 
 		// ベンドポイントの保存
-		jp.go.aist.rtm.toolscommon.model.component.PortConnector ePortConnector = diagram
-				.getConnectorMap().get(eConnProf.getConnectorId());
+		PortConnector ePortConnector = diagram.getConnectorMap().get(
+				eConnProf.getConnectorId());
 		if (ePortConnector != null) {
 			saveBendPoint(ePortConnector.getRoutingConstraint().map(),
 					connector.getProperties());
 		}
 
-		ServiceportConnector original = findOrignalServiceportConnector(eConnProf
+		org.openrtp.namespaces.rts.version02.ServiceportConnector original = findOrignalServiceportConnector(eConnProf
 				.getConnectorId());
 
 		if (eConnProf.getSourceString() != null) {
@@ -556,11 +526,11 @@
 					original == null ? null : original.getTargetServicePort()));
 		}
 
-		if (original instanceof ServiceportConnectorExt) {
+		if (original instanceof org.openrtp.namespaces.rts.version02.ServiceportConnectorExt) {
 			if (original != null) {
 				connector.setTransMethod(original.getTransMethod());
 			}
-			ServiceportConnectorExt originalExt = (ServiceportConnectorExt) original;
+			org.openrtp.namespaces.rts.version02.ServiceportConnectorExt originalExt = (org.openrtp.namespaces.rts.version02.ServiceportConnectorExt) original;
 			connector.setComment(originalExt.getComment());
 			if (!originalExt.isVisible()) {
 				connector.setVisible(Boolean.valueOf(originalExt.isVisible()));
@@ -577,29 +547,29 @@
 	}
 
 	// ベンドポイントをRTSプロファイル内に保存する
-	@SuppressWarnings("unchecked")
-	private void saveBendPoint(Map map,
-			List<Property> rtsProperties) {
-		if (map == null || map.isEmpty()) return;
-		
-		Property propt = factory.createProperty();
+	private void saveBendPoint(Map<Integer, Point> map,
+			List<org.openrtp.namespaces.rts.version02.Property> rtsProperties) {
+		if (map == null || map.isEmpty()) {
+			return;
+		}
+		org.openrtp.namespaces.rts.version02.Property propt = factory
+				.createProperty();
 		propt.setName(KEY_BEND_POINT);
 		propt.setValue(convertToBendPointString(map));
 		rtsProperties.add(propt);
 	}
 
 	// ベンドポイントのMapを文字列表現に変換する
-	@SuppressWarnings("unchecked")
-	private String convertToBendPointString(Map map) {
+	private String convertToBendPointString(Map<Integer, Point> map) {
 		StringBuffer buffer = new StringBuffer();
-		for (Object key :map.keySet()) {
+		for (Object key : map.keySet()) {
 			if (buffer.length() == 0) {
 				buffer.append("{");
 			} else {
 				buffer.append(",");
 			}
 			buffer.append(key).append(":").append("(");
-			jp.go.aist.rtm.toolscommon.model.core.Point point = (Point) map.get(key);
+			Point point = (Point) map.get(key);
 			buffer.append(point.getX()).append(",").append(point.getY());
 			buffer.append(")");
 		}
@@ -608,24 +578,24 @@
 	}
 
 	// プロファイルのTargetPortを生成して返す
-	private TargetPort createTargetPort(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			TargetPort original) {
-		TargetPortExt port = factory.createTargetPortExt();
-		final jp.go.aist.rtm.toolscommon.model.component.Component eComp = (jp.go.aist.rtm.toolscommon.model.component.Component) ePort.eContainer();
+	private org.openrtp.namespaces.rts.version02.TargetPort createTargetPort(
+			Port ePort,
+			org.openrtp.namespaces.rts.version02.TargetPort original) {
+		org.openrtp.namespaces.rts.version02.TargetPortExt port = factory.createTargetPortExt();
+		final Component eComp = (Component) ePort.eContainer();
 		port.setComponentId(eComp.getComponentId());
 		port.setInstanceName(eComp.getInstanceNameL());
 		port.setPortName(ePort.getNameL());
 
 		// pathIdをプロパティにセットする
-		Property propt = factory.createProperty();
+		org.openrtp.namespaces.rts.version02.Property propt = factory.createProperty();
 		propt.setName(KEY_COMPONENT_PATH_ID);
 		propt.setValue(eComp.getPathId());
 		port.getProperties().add(propt);
 
-		if (original instanceof TargetPortExt) {
-			TargetPortExt originalPort = (TargetPortExt) original;
-			for (Property property : originalPort.getProperties()) {
+		if (original instanceof org.openrtp.namespaces.rts.version02.TargetPortExt) {
+			org.openrtp.namespaces.rts.version02.TargetPortExt originalPort = (org.openrtp.namespaces.rts.version02.TargetPortExt) original;
+			for (org.openrtp.namespaces.rts.version02.Property property : originalPort.getProperties()) {
 				if (property.getName().equals(KEY_COMPONENT_PATH_ID)) continue;
 				port.getProperties().add(property);
 			}
@@ -635,13 +605,13 @@
 
 	// Save時にComponentのConfigurationSetの情報をRTSプロファイルにセットする
 	private void populateConfigurationSet(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp, ComponentExt target) {
-		for (jp.go.aist.rtm.toolscommon.model.component.ConfigurationSet eConfigSet : eComp.getConfigurationSets()) {
-			ConfigurationSet config = factory.createConfigurationSet();
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target) {
+		for (ConfigurationSet eConfigSet : eComp.getConfigurationSets()) {
+			org.openrtp.namespaces.rts.version02.ConfigurationSet config = factory.createConfigurationSet();
 			config.setId(eConfigSet.getId());
-			for (jp.go.aist.rtm.toolscommon.model.component.NameValue nv : eConfigSet
-					.getConfigurationData()) {
-				ConfigurationData data = factory.createConfigurationData();
+			for (NameValue nv : eConfigSet.getConfigurationData()) {
+				org.openrtp.namespaces.rts.version02.ConfigurationData data = factory.createConfigurationData();
 				data.setName(nv.getName());
 				data.setData(nv.getValueAsString());
 				config.getConfigurationData().add(data);
@@ -655,11 +625,11 @@
 
 	// Save時に子RTCの情報をRTSプロファイルにセットする
 	private void populateParticipants(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			ComponentExt target, Component original) {
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eChildComp : eComp
-				.getComponents()) {
-			Participants participants = null;
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
+		for (Component eChildComp : eComp.getComponents()) {
+			org.openrtp.namespaces.rts.version02.Participants participants = null;
 			if (original != null) {
 				participants = findParticipants(eChildComp, original.getParticipants());
 			}
@@ -667,12 +637,12 @@
 				target.getParticipants().add(participants);
 				continue;
 			}
-			TargetComponentExt child = factory.createTargetComponentExt();
+			org.openrtp.namespaces.rts.version02.TargetComponentExt child = factory.createTargetComponentExt();
 			child.setComponentId(eChildComp.getComponentId());
 			child.setInstanceName(eChildComp.getInstanceNameL());
 
 			// pathIdをプロパティにセットする
-			Property propt = factory.createProperty();
+			org.openrtp.namespaces.rts.version02.Property propt = factory.createProperty();
 			propt.setName(KEY_COMPONENT_PATH_ID);
 			propt.setValue(eChildComp.getPathId());
 			child.getProperties().add(propt);
@@ -685,14 +655,15 @@
 
 	// Save時にデータポートの情報をRTSプロファイルに追加する
 	private void addDataPort(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			ComponentExt target, Component original) {
-		DataportExt port = factory.createDataportExt();
+			Port ePort,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
+		org.openrtp.namespaces.rts.version02.DataportExt port = factory.createDataportExt();
 		port.setName(ePort.getNameL());
 		if (original != null) {
-			Dataport originalPort = findOriginalPort(original.getDataPorts(), port.getName());
-			if (originalPort instanceof DataportExt) {
-				DataportExt source = (DataportExt) originalPort;
+			org.openrtp.namespaces.rts.version02.Dataport originalPort = findOriginalPort(original.getDataPorts(), port.getName());
+			if (originalPort instanceof org.openrtp.namespaces.rts.version02.DataportExt) {
+				org.openrtp.namespaces.rts.version02.DataportExt source = (org.openrtp.namespaces.rts.version02.DataportExt) originalPort;
 				port.setComment(source.getComment());
 				if (!source.isVisible()) {
 					port.setVisible(Boolean.valueOf(source.isVisible()));
@@ -709,14 +680,15 @@
 
 	// Save時にサービスポートの情報をRTSプロファイルに追加する
 	private void addServicePort(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			ComponentExt target, Component original) {
-		ServiceportExt port = factory.createServiceportExt();
+			Port ePort,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
+		org.openrtp.namespaces.rts.version02.ServiceportExt port = factory.createServiceportExt();
 		port.setName(ePort.getNameL());
 		if (original != null) {
-			Serviceport originalPort = findOriginalServicePort(original.getServicePorts(), port.getName());
-			if (originalPort instanceof ServiceportExt) {
-				ServiceportExt source = (ServiceportExt) originalPort;
+			org.openrtp.namespaces.rts.version02.Serviceport originalPort = findOriginalServicePort(original.getServicePorts(), port.getName());
+			if (originalPort instanceof org.openrtp.namespaces.rts.version02.ServiceportExt) {
+				org.openrtp.namespaces.rts.version02.ServiceportExt source = (org.openrtp.namespaces.rts.version02.ServiceportExt) originalPort;
 				port.setComment(source.getComment());
 				if (!source.isVisible()) {
 					port.setVisible(Boolean.valueOf(source.isVisible()));
@@ -733,8 +705,9 @@
 
 	// Save時にコンポーネントのプロパティをセットする
 	private void populateComponentProperty(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			ComponentExt target, Component original) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
 		// プロパティ設定
 		for (String key : eComp.getPropertyKeys()) {
 			//デプロイ情報は除外
@@ -747,9 +720,10 @@
 	}
 
 	// Save時にコンポーネントの位置情報をセットする
-	private void populateComponentLocation(jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			ComponentExt target) {
-		target.setLocation(new Location());
+	private void populateComponentLocation(
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target) {
+		target.setLocation(new org.openrtp.namespaces.rts.version02.Location());
 		target.getLocation().setX(BigInteger.valueOf(eComp.getConstraint().getX()));
 		target.getLocation().setY(BigInteger.valueOf(eComp.getConstraint().getY()));
 		target.getLocation().setHeight(BigInteger.valueOf(eComp.getConstraint().getHeight()));
@@ -758,30 +732,33 @@
 	}
 	
 	// IORを保存する
-	private void populateIOR(List<Property> rtsProperties,
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp) {
-		if (!(eComp instanceof jp.go.aist.rtm.toolscommon.model.component.CorbaComponent)) return;
-		RTObject corbaObjectInterface = ((jp.go.aist.rtm.toolscommon.model.component.CorbaComponent) eComp).getCorbaObjectInterface();
+	private void populateIOR(
+			List<org.openrtp.namespaces.rts.version02.Property> rtsProperties,
+			Component eComp) {
+		if (!(eComp instanceof CorbaComponent)) return;
+		RTC.RTObject corbaObjectInterface = ((CorbaComponent) eComp).getCorbaObjectInterface();
 		if (corbaObjectInterface == null) return;
 		rtsProperties.add(newProperty(KEY_IOR, corbaObjectInterface.toString()));
 	}
 
 	// IORを復元する
 	private void populateIOR(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<Property> properties) {
-		if (!(eComp instanceof jp.go.aist.rtm.toolscommon.model.component.CorbaComponent)) return;
-		for (Property prop : properties) {
+			Component eComp,
+			List<org.openrtp.namespaces.rts.version02.Property> properties) {
+		if (!(eComp instanceof CorbaComponent)) return;
+		for (org.openrtp.namespaces.rts.version02.Property prop : properties) {
 			if (prop.getName().equals(KEY_IOR)) {
-				((jp.go.aist.rtm.toolscommon.model.component.CorbaComponent) eComp).setIor(prop.getValue());
+				((CorbaComponent) eComp).setIor(prop.getValue());
 			}
 		}
 	}
 
 	// Save時に元のファイルにあったコンポーネントの拡張属性をセットする
-	private void populateFromProfileOnly(ComponentExt target, Component original) {
-		if (!(original instanceof ComponentExt)) return;
-		ComponentExt source = (ComponentExt) original;
+	private void populateFromProfileOnly(
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
+		if (!(original instanceof org.openrtp.namespaces.rts.version02.ComponentExt)) return;
+		org.openrtp.namespaces.rts.version02.ComponentExt source = (org.openrtp.namespaces.rts.version02.ComponentExt) original;
 		target.setComment(source.getComment());
 		if (!source.isVisible()) {
 			target.setVisible(Boolean.valueOf(source.isVisible()));
@@ -790,21 +767,20 @@
 
 	// Save時にExecutionContextの情報をRTSプロファイルにセットする
 	private void populateExecutionContext(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			ComponentExt target, Component original) {
-		for (jp.go.aist.rtm.toolscommon.model.component.ExecutionContext eEc : eComp
-				.getExecutionContexts()) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.ComponentExt target,
+			org.openrtp.namespaces.rts.version02.Component original) {
+		for (ExecutionContext eEc : eComp.getExecutionContexts()) {
 			String id = eComp.getExecutionContextHandler().getId(eEc);
-			ExecutionContextExt ec = factory.createExecutionContextExt();
+			org.openrtp.namespaces.rts.version02.ExecutionContextExt ec = factory.createExecutionContextExt();
 			ec.setId((id == null) ? "" : id);
 			ec.setKind(eEc.getKindName());
 			ec.setRate(eEc.getRateL());
-			for (jp.go.aist.rtm.toolscommon.model.component.Component c : eEc
-					.getParticipants()) {
-				TargetComponentExt tc = factory.createTargetComponentExt();
+			for (Component c : eEc.getParticipants()) {
+				org.openrtp.namespaces.rts.version02.TargetComponentExt tc = factory.createTargetComponentExt();
 				tc.setComponentId(c.getComponentId());
 				tc.setInstanceName(c.getInstanceNameL());
-				Property prop = newProperty(KEY_COMPONENT_PATH_ID, c
+				org.openrtp.namespaces.rts.version02.Property prop = newProperty(KEY_COMPONENT_PATH_ID, c
 						.getPathId());
 				tc.getProperties().add(prop);
 				ec.getParticipants().add(tc);
@@ -818,7 +794,7 @@
 	}
 
 	// Save時に、元のRTSプロファイル内だけに存在し、システムエディタでは使用しない要素を書き戻す
-	private void populateFromProfileOnly(RtsProfileExt target) {
+	private void populateFromProfileOnly(org.openrtp.namespaces.rts.version02.RtsProfileExt target) {
 		if (originalProfile == null) return;
 		target.setAbstract(originalProfile.getAbstract());
 		target.getGroups().addAll(originalProfile.getGroups());
@@ -852,12 +828,11 @@
 
 	// RTSプロファイルからEMFコンポーネントを復元する
 	private void populate(
-			EList<jp.go.aist.rtm.toolscommon.model.component.Component> target,
-			RtsProfile profile) {
-		List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps = new ArrayList<jp.go.aist.rtm.toolscommon.model.component.Component>();
-		for (Component component : profile.getComponents()) {
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp = loader
-					.create(component, profile);
+			EList<Component> target,
+			org.openrtp.namespaces.rts.version02.RtsProfile profile) {
+		List<Component> eComps = new ArrayList<>();
+		for (org.openrtp.namespaces.rts.version02.Component component : profile.getComponents()) {
+			Component eComp = loader.create(component, profile);
 			if (eComp == null) {
 				continue;
 			}
@@ -870,11 +845,10 @@
 			// portはCORBAObjectまたはRTEProfileを正とする
 			// CORBA経由で取得したコンフィグセットを正とする
 
-			if (eComp instanceof jp.go.aist.rtm.toolscommon.model.component.ComponentSpecification) {
+			if (eComp instanceof ComponentSpecification) {
 				// オフラインの場合はポート名を正規化する
-				jp.go.aist.rtm.toolscommon.model.component.Component spec = (jp.go.aist.rtm.toolscommon.model.component.Component) eComp;
-				for (jp.go.aist.rtm.toolscommon.model.component.Port port : spec
-						.getPorts()) {
+				Component spec = (Component) eComp;
+				for (Port port : spec.getPorts()) {
 					String name = ComponentUtil.createPortName(spec
 							.getInstanceNameL(), port.getNameL());
 					port.setNameL(name);
@@ -886,55 +860,52 @@
 				populateConfigSets(eComp, component);
 			}
 
-			if (component instanceof ComponentExt) {
-				ComponentExt componentExt = (ComponentExt)component;
+			if (component instanceof org.openrtp.namespaces.rts.version02.ComponentExt) {
+				org.openrtp.namespaces.rts.version02.ComponentExt componentExt = (org.openrtp.namespaces.rts.version02.ComponentExt)component;
 				eComp.setConstraint(toRectangle(componentExt.getLocation()));
 				eComp.setOutportDirection(componentExt.getLocation().getDirection());
 
 				// コンポーネントのプロパティ設定
-				for (Property prop : componentExt.getProperties()) {
+				for (org.openrtp.namespaces.rts.version02.Property prop : componentExt.getProperties()) {
 					if (KEY_IOR.equals(prop.getName())) {
 						continue;
 					}
 					eComp.setProperty(prop.getName(), prop.getValue());
 				}
 				// ポートのプロパティ設定
-				for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp
-						.getOutports()) {
+				for (Port ePort : eComp.getOutports()) {
 					populateDataPortProperty(ePort, componentExt.getDataPorts());
 				}
-				for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp
-						.getInports()) {
+				for (Port ePort : eComp.getInports()) {
 					populateDataPortProperty(ePort, componentExt.getDataPorts());
 				}
-				for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : eComp
-						.getServiceports()) {
-					populateServicePortProperty(ePort, componentExt
-							.getServicePorts());
+				for (Port ePort : eComp.getServiceports()) {
+					populateServicePortProperty(ePort,
+							componentExt.getServicePorts());
 				}
 
 				populateIOR(eComp, componentExt.getProperties());
 			}
 			eComps.add(eComp);
 		}
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eComps) {
+		for (Component eComp : eComps) {
 			if (isShown(eComp, eComps, profile.getComponents()))
 				target.add(eComp);
 		}
 	}
 
 	void populateDataPortProperty(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			List<Dataport> ports) {
-		for (Dataport dp : ports) {
+			Port ePort,
+			List<org.openrtp.namespaces.rts.version02.Dataport> ports) {
+		for (org.openrtp.namespaces.rts.version02.Dataport dp : ports) {
 			if (!dp.getName().equals(ePort.getNameL())) {
 				continue;
 			}
-			if (!(dp instanceof DataportExt)) {
+			if (!(dp instanceof org.openrtp.namespaces.rts.version02.DataportExt)) {
 				continue;
 			}
-			DataportExt dpExt = (DataportExt) dp;
-			for (Property prop : dpExt.getProperties()) {
+			org.openrtp.namespaces.rts.version02.DataportExt dpExt = (org.openrtp.namespaces.rts.version02.DataportExt) dp;
+			for (org.openrtp.namespaces.rts.version02.Property prop : dpExt.getProperties()) {
 				ePort.getSynchronizer().setProperty(prop.getName(),
 						prop.getValue());
 			}
@@ -942,17 +913,17 @@
 	}
 
 	void populateServicePortProperty(
-			jp.go.aist.rtm.toolscommon.model.component.Port ePort,
-			List<Serviceport> ports) {
-		for (Serviceport sp : ports) {
+			Port ePort,
+			List<org.openrtp.namespaces.rts.version02.Serviceport> ports) {
+		for (org.openrtp.namespaces.rts.version02.Serviceport sp : ports) {
 			if (!sp.getName().equals(ePort.getNameL())) {
 				continue;
 			}
-			if (!(sp instanceof ServiceportExt)) {
+			if (!(sp instanceof org.openrtp.namespaces.rts.version02.ServiceportExt)) {
 				continue;
 			}
-			ServiceportExt spExt = (ServiceportExt) sp;
-			for (Property prop : spExt.getProperties()) {
+			org.openrtp.namespaces.rts.version02.ServiceportExt spExt = (org.openrtp.namespaces.rts.version02.ServiceportExt) sp;
+			for (org.openrtp.namespaces.rts.version02.Property prop : spExt.getProperties()) {
 				ePort.getSynchronizer().setProperty(prop.getName(),
 						prop.getValue());
 			}
@@ -961,16 +932,15 @@
 
 	// ルートのシステムダイアグラムに表示されるのであれば、trueを返す
 	private boolean isShown(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps,
-			List<Component> source) {
+			Component eComp,
+			List<Component> eComps,
+			List<org.openrtp.namespaces.rts.version02.Component> source) {
 		// targetComponentをparentComponentの子として追加する処理をここで行う
 		for (int i = 0; i < eComps.size(); i++) {
-			jp.go.aist.rtm.toolscommon.model.component.Component eParentComponent 
-				= eComps.get(i);
-			Component component = source.get(i);
-			for (Participants participants : component.getParticipants()) {
-				TargetComponent tc = participants.getParticipant();
+			Component eParentComponent = eComps.get(i);
+			org.openrtp.namespaces.rts.version02.Component component = source.get(i);
+			for (org.openrtp.namespaces.rts.version02.Participants participants : component.getParticipants()) {
+				org.openrtp.namespaces.rts.version02.TargetComponent tc = participants.getParticipant();
 				if (eComp.getComponentId().equals(tc.getComponentId())
 						&& eComp.getInstanceNameL().equals(tc.getInstanceName())) {
 					// pathIdもチェックする
@@ -985,7 +955,7 @@
 	}
 
 	// RtsプロファイルのLocationをRectangleに変換する
-	private Rectangle toRectangle(Location location) {
+	private Rectangle toRectangle(org.openrtp.namespaces.rts.version02.Location location) {
 		Rectangle result = new Rectangle();
 		result.setX(location.getX().intValue());
 		result.setY(location.getY().intValue());
@@ -996,22 +966,21 @@
 
 	// 複合コンポーネントのポートを復元させる(オフライン)
 	private void populateCompositeComponentPort(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			Component component) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.Component component) {
 		if (!eComp.isCompositeComponent()) return;
 		if (!online || eComp.getCompositeTypeL().equals(COMPOSITETYPE_GROUPING)) {
-				List<jp.go.aist.rtm.toolscommon.model.component.Component> emptyList 
-					= Collections.emptyList();
-				eComp.addComponentsR(emptyList);
+			List<Component> emptyList = Collections.emptyList();
+			eComp.addComponentsR(emptyList);
 		}
 	}
 
 	// データポートの接続を復元させる
 	private void populateDataConnector(
-			List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps,
-			List<DataportConnector> dataPortConnectors) {
-		for (DataportConnector connBase : dataPortConnectors) {
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile conn = ComponentFactory.eINSTANCE.createConnectorProfile();
+			List<Component> eComps,
+			List<org.openrtp.namespaces.rts.version02.DataportConnector> dataPortConnectors) {
+		for (org.openrtp.namespaces.rts.version02.DataportConnector connBase : dataPortConnectors) {
+			ConnectorProfile conn = ComponentFactory.eINSTANCE.createConnectorProfile();
 			conn.setConnectorId(connBase.getConnectorId());
 			conn.setName(connBase.getName());
 			conn.setInterfaceType(connBase.getInterfaceType());
@@ -1021,9 +990,9 @@
 			if(connBase.getPushInterval()!=null) conn.setPushRate(connBase.getPushInterval());
 
 			// 追加プロパティの設定
-			if (connBase instanceof DataportConnectorExt) {
-				DataportConnectorExt connExt = (DataportConnectorExt) connBase;
-				for (Property p : connExt.getProperties()) {
+			if (connBase instanceof org.openrtp.namespaces.rts.version02.DataportConnectorExt) {
+				org.openrtp.namespaces.rts.version02.DataportConnectorExt connExt = (org.openrtp.namespaces.rts.version02.DataportConnectorExt) connBase;
+				for (org.openrtp.namespaces.rts.version02.Property p : connExt.getProperties()) {
 					String name = p.getName();
 					String value = p.getValue();
 					if (PROP.PUSH_POLICY.equals(name)) {
@@ -1098,25 +1067,24 @@
 				}
 			}
 
-			connectPorts(conn, eComps,
-					connBase.getTargetDataPort(), connBase.getSourceDataPort()
-					, getBendPoint(connBase));
+			connectPorts(conn, eComps, connBase.getTargetDataPort(),
+					connBase.getSourceDataPort());
 		}
 	}
 
 	// RTSプロファイルのサービスポート接続から接続を復元する
 	private void populateServiceConnector(
-			List<jp.go.aist.rtm.toolscommon.model.component.Component> eComp,
-			List<ServiceportConnector> servicePortConnectors) {
-		for (ServiceportConnector connBase : servicePortConnectors) {
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf = ComponentFactory.eINSTANCE.createConnectorProfile();
+			List<Component> eComp,
+			List<org.openrtp.namespaces.rts.version02.ServiceportConnector> servicePortConnectors) {
+		for (org.openrtp.namespaces.rts.version02.ServiceportConnector connBase : servicePortConnectors) {
+			ConnectorProfile eConnProf = ComponentFactory.eINSTANCE.createConnectorProfile();
 			eConnProf.setConnectorId(connBase.getConnectorId());
 			eConnProf.setName(connBase.getName());
 
 			// 追加プロパティの設定
-			if (connBase instanceof ServiceportConnectorExt) {
-				ServiceportConnectorExt connExt = (ServiceportConnectorExt) connBase;
-				for (Property p : connExt.getProperties()) {
+			if (connBase instanceof org.openrtp.namespaces.rts.version02.ServiceportConnectorExt) {
+				org.openrtp.namespaces.rts.version02.ServiceportConnectorExt connExt = (org.openrtp.namespaces.rts.version02.ServiceportConnectorExt) connBase;
+				for (org.openrtp.namespaces.rts.version02.Property p : connExt.getProperties()) {
 					if (isIOR(p.getValue())
 							|| KEY_BEND_POINT.equals(p.getName())) {
 						continue;
@@ -1126,7 +1094,7 @@
 			}
 
 			connectPorts(eConnProf, eComp, connBase.getTargetServicePort(),
-					connBase.getSourceServicePort(), getBendPoint(connBase));
+					connBase.getSourceServicePort());
 		}
 	}
 	
@@ -1134,35 +1102,15 @@
 		return (value != null && value.startsWith("IOR:"));
 	}
 
-	// ベンドポイントをプロパティから復元する
-	private Map<Integer, Point> getBendPoint(DataportConnector connBase) {
-		if (!(connBase instanceof DataportConnectorExt)) return null;
-		DataportConnectorExt connBaseExt = (DataportConnectorExt) connBase;
-		return getBendPoint(connBaseExt.getProperties());
-	}
-
-	// ベンドポイントをプロパティから復元する
-	private Map<Integer, Point> getBendPoint(ServiceportConnector connBase) {
-		if (!(connBase instanceof ServiceportConnectorExt)) return null;
-		ServiceportConnectorExt connBaseExt = (ServiceportConnectorExt) connBase;
-		return getBendPoint(connBaseExt.getProperties());
-	}
-
-	// ベンドポイントをプロパティから復元する
-	private Map<Integer, Point> getBendPoint(List<Property> properties) {
-		String bendPointString = findProperyValue(KEY_BEND_POINT, properties);
-		if (bendPointString == null) return null;
-		return convertFromBendPointString(bendPointString);
-	}
-
 	// ポート間の接続を復元する
 	private void connectPorts(
-			jp.go.aist.rtm.toolscommon.model.component.ConnectorProfile eConnProf,
-			List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps,
-			TargetPort target, TargetPort source, Map<Integer, Point> bendPoint) {
-		jp.go.aist.rtm.toolscommon.model.component.Component eComp = null;
-		jp.go.aist.rtm.toolscommon.model.component.Port eSource = null;
-		jp.go.aist.rtm.toolscommon.model.component.Port eTarget = null;
+			ConnectorProfile eConnProf,
+			List<Component> eComps,
+			org.openrtp.namespaces.rts.version02.TargetPort target,
+			org.openrtp.namespaces.rts.version02.TargetPort source) {
+		Component eComp = null;
+		Port eSource = null;
+		Port eTarget = null;
 		if (source != null) {
 			eComp = findEMFComponentByTargetComponent(source, eComps);
 			if (eComp != null) {
@@ -1175,15 +1123,28 @@
 				eTarget = findEMFPortByTargetPort(target, eComp.getPorts());
 			}
 		}
-		jp.go.aist.rtm.toolscommon.model.component.PortConnector eConnector = PortConnectorFactory
-				.createPortConnector(eSource, eTarget);
+		// すでにポート間が接続済みの場合は重複接続しない
+		String eSourceId = eSource.getOriginalPortString();
+		String eTargetId = eTarget.getOriginalPortString();
+		for (ConnectorProfile prof : eSource.getConnectorProfiles()) {
+			String sname = prof.getSourceString();
+			String tname = prof.getTargetString();
+			LOGGER.trace(
+					"connectPorts: verify existing connection: sourceId=<{}> targetId=<{}> prof.sourceId=<{}> prof.targetId=<{}>",
+					eSourceId, eTargetId, sname, tname);
+			if (eSourceId.equals(sname) && eTargetId.equals(tname)) {
+				LOGGER.info(
+						"connectPorts: already connected ports: source=<{}> target=<{}> sourceId=<{}> targetId=<{}>",
+						eSource.getNameL(), eTarget.getNameL(), eSourceId,
+						eTargetId);
+				return;
+			}
+		}
+		PortConnector eConnector = PortConnectorFactory.createPortConnector(
+				eSource, eTarget);
 		eConnector.setSource(eSource);
 		eConnector.setTarget(eTarget);
 		eConnector.setConnectorProfile(eConnProf);
-		if (bendPoint != null && !bendPoint.isEmpty()) {
-			eConnector.getRoutingConstraint().map().clear();
-			eConnector.getRoutingConstraint().map().putAll(bendPoint);
-		}
 		if (!online) {
 			diagram.getConnectorMap().put(eConnProf.getConnectorId(),
 					eConnector);
@@ -1193,7 +1154,7 @@
 
 	// RTSプロファイルからコンポジット種別を復元する
 	private void populateCompositeType(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
+			Component eComp,
 			String compositeType) {
 		if (compositeType.equals("None")) return;
 		eComp.setCategoryL("composite." + compositeType);
@@ -1201,19 +1162,19 @@
 
 	// RTSプロファイルからコンフィグセットを復元する
 	private void populateConfigSets(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			Component component) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.Component component) {
 		if (component == null) {
 			return;
 		}
 		eComp.getConfigurationSets().clear();
 		String activeId = component.getActiveConfigurationSet();
-		for (ConfigurationSet configSet : component.getConfigurationSets()) {
-			jp.go.aist.rtm.toolscommon.model.component.ConfigurationSet eConfigSet = ComponentFactory.eINSTANCE.createConfigurationSet();
+		for (org.openrtp.namespaces.rts.version02.ConfigurationSet configSet : component.getConfigurationSets()) {
+			ConfigurationSet eConfigSet = ComponentFactory.eINSTANCE.createConfigurationSet();
 			if (configSet.getId().equals(activeId)) eComp.setActiveConfigurationSet(eConfigSet);
 			eConfigSet.setId(configSet.getId());
-			for (ConfigurationData configData : configSet.getConfigurationData()) {
-				jp.go.aist.rtm.toolscommon.model.component.NameValue nv = ComponentFactory.eINSTANCE.createNameValue();
+			for (org.openrtp.namespaces.rts.version02.ConfigurationData configData : configSet.getConfigurationData()) {
+				NameValue nv = ComponentFactory.eINSTANCE.createNameValue();
 				nv.setName(configData.getName());
 				nv.setValue(configData.getData());
 				eConfigSet.getConfigurationData().add(nv);
@@ -1222,9 +1183,55 @@
 		}
 	}
 
+	// ベンドポイントをプロパティから復元する
+	private Map<Integer, Point> getBendPoint(
+			org.openrtp.namespaces.rts.version02.DataportConnector connBase) {
+		if (!(connBase instanceof org.openrtp.namespaces.rts.version02.DataportConnectorExt)) {
+			return null;
+		}
+		org.openrtp.namespaces.rts.version02.DataportConnectorExt connBaseExt = (org.openrtp.namespaces.rts.version02.DataportConnectorExt) connBase;
+		return getBendPoint(connBaseExt.getProperties());
+	}
+
+	// ベンドポイントをプロパティから復元する
+	private Map<Integer, Point> getBendPoint(
+			org.openrtp.namespaces.rts.version02.ServiceportConnector connBase) {
+		if (!(connBase instanceof org.openrtp.namespaces.rts.version02.ServiceportConnectorExt)) {
+			return null;
+		}
+		org.openrtp.namespaces.rts.version02.ServiceportConnectorExt connBaseExt = (org.openrtp.namespaces.rts.version02.ServiceportConnectorExt) connBase;
+		return getBendPoint(connBaseExt.getProperties());
+	}
+
+	// ベンドポイントをプロパティから復元する
+	private Map<Integer, Point> getBendPoint(
+			List<org.openrtp.namespaces.rts.version02.Property> properties) {
+		String bendPointString = findProperyValue(KEY_BEND_POINT, properties);
+		if (bendPointString == null) {
+			return null;
+		}
+		return convertFromBendPointString(bendPointString);
+	}
+
+	// ベンドポイントの文字列表現をMap表現に変換する
+	public Map<Integer, Point> convertFromBendPointString(String bendPoint) {
+		if (StringUtils.isBlank(bendPoint)) {
+			return null;
+		}
+		String content = bendPoint.trim();
+		content = content.substring(1, content.length() - 1).trim(); // { }除去
+		Map<Integer, Point> result = new HashMap<Integer, Point>();
+		while (content.length() > 0) {
+			content = populatePoint(result, content);
+		}
+		return result;
+	}
+
 	/** キーと値を指定してプロパティリストを更新(キーに一致する要素があれば値を上書き) */
-	void setProperty(String name, String value, List<Property> properties) {
-		Property prop = findProperty(name, properties);
+	void setProperty(String name, String value,
+			List<org.openrtp.namespaces.rts.version02.Property> properties) {
+		org.openrtp.namespaces.rts.version02.Property prop = findProperty(name,
+				properties);
 		if (prop != null) {
 			prop.setValue(value);
 		} else {
@@ -1234,8 +1241,10 @@
 	}
 
 	/** キーと値を指定してプロパティ要素を作成 */
-	Property newProperty(String name, String value) {
-		Property prop = factory.createProperty();
+	org.openrtp.namespaces.rts.version02.Property newProperty(String name,
+			String value) {
+		org.openrtp.namespaces.rts.version02.Property prop = factory
+				.createProperty();
 		prop.setName(name);
 		prop.setValue(value);
 		return prop;
@@ -1243,8 +1252,8 @@
 
 	/** TargetComponentがPathIdを持ち、EMFコンポーネントのPathIdが等しい場合はtrue */
 	private boolean equalsPathId(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			TargetComponent tc) {
+			Component eComp,
+			org.openrtp.namespaces.rts.version02.TargetComponent tc) {
 		String pathId = getPathId(tc);
 		if (pathId == null) {
 			return true;
@@ -1253,24 +1262,24 @@
 	}
 
 	/** TargetComponent、もしくはTargetPortのプロパティからPathIdを取り出す */
-	private String getPathId(TargetComponent tc) {
-		if (tc instanceof TargetPortExt) {
-			TargetPortExt saved = (TargetPortExt) tc;
+	private String getPathId(org.openrtp.namespaces.rts.version02.TargetComponent tc) {
+		if (tc instanceof org.openrtp.namespaces.rts.version02.TargetPortExt) {
+			org.openrtp.namespaces.rts.version02.TargetPortExt saved = (org.openrtp.namespaces.rts.version02.TargetPortExt) tc;
 			return findProperyValue(KEY_COMPONENT_PATH_ID, saved.getProperties());
 		}
-		if (tc instanceof TargetComponentExt) {
-			TargetComponentExt saved = (TargetComponentExt) tc;
+		if (tc instanceof org.openrtp.namespaces.rts.version02.TargetComponentExt) {
+			org.openrtp.namespaces.rts.version02.TargetComponentExt saved = (org.openrtp.namespaces.rts.version02.TargetComponentExt) tc;
 			return findProperyValue(KEY_COMPONENT_PATH_ID, saved.getProperties());
 		}
 		return null;
 	}
 
 	/** Open時に読み込んだRTSプロファイルから該当するデータポート接続を見つけ出す */
-	private DataportConnector findOrignalDataportConnector(String connectorId) {
+	private org.openrtp.namespaces.rts.version02.DataportConnector findOrignalDataportConnector(String connectorId) {
 		if (originalProfile == null) {
 			return null;
 		}
-		for (DataportConnector temp : originalProfile.getDataPortConnectors()) {
+		for (org.openrtp.namespaces.rts.version02.DataportConnector temp : originalProfile.getDataPortConnectors()) {
 			if (temp.getConnectorId().equals(connectorId)) {
 				return temp;
 			}
@@ -1279,12 +1288,12 @@
 	}
 
 	/** Open時に読み込んだRTSプロファイルから該当するサービスポート接続を見つけ出す */
-	private ServiceportConnector findOrignalServiceportConnector(
+	private org.openrtp.namespaces.rts.version02.ServiceportConnector findOrignalServiceportConnector(
 			String connectorId) {
 		if (originalProfile == null) {
 			return null;
 		}
-		for (ServiceportConnector temp : originalProfile
+		for (org.openrtp.namespaces.rts.version02.ServiceportConnector temp : originalProfile
 				.getServicePortConnectors()) {
 			if (temp.getConnectorId().equals(connectorId)) {
 				return temp;
@@ -1294,8 +1303,8 @@
 	}
 
 	/** OpenしたRTSプロファイルに存在したDataport要素を探し出す */
-	private Dataport findOriginalPort(List<Dataport> ports, String name) {
-		for (Dataport port : ports) {
+	private org.openrtp.namespaces.rts.version02.Dataport findOriginalPort(List<org.openrtp.namespaces.rts.version02.Dataport> ports, String name) {
+		for (org.openrtp.namespaces.rts.version02.Dataport port : ports) {
 			if (port.getName().equals(name)) {
 				return port;
 			}
@@ -1304,8 +1313,8 @@
 	}
 
 	/** OpenしたRTSプロファイルに存在したServiceport要素を探し出す */
-	private Serviceport findOriginalServicePort(List<Serviceport> ports, String name) {
-		for (Serviceport port : ports) {
+	private org.openrtp.namespaces.rts.version02.Serviceport findOriginalServicePort(List<org.openrtp.namespaces.rts.version02.Serviceport> ports, String name) {
+		for (org.openrtp.namespaces.rts.version02.Serviceport port : ports) {
 			if (port.getName().equals(name)) {
 				return port;
 			}
@@ -1314,8 +1323,8 @@
 	}
 
 	/** OpenしたRTSプロファイルに存在したComponent要素を探し出す */
-	private Component findOriginalComponent(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp) {
+	private org.openrtp.namespaces.rts.version02.Component findOriginalComponent(
+			Component eComp) {
 		if (originalProfile == null) {
 			return null;
 		}
@@ -1323,10 +1332,10 @@
 	}
 
 	/** EMFコンポーネントに合致するRTSコンポーネントを探し出す */
-	public static Component findComponent(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<Component> components) {
-		for (Component component : components) {
+	public static org.openrtp.namespaces.rts.version02.Component findComponent(
+			Component eComp,
+			List<org.openrtp.namespaces.rts.version02.Component> components) {
+		for (org.openrtp.namespaces.rts.version02.Component component : components) {
 			if (component.getId().equals(eComp.getComponentId())
 					&& component.getInstanceName().equals(
 							eComp.getInstanceNameL())
@@ -1338,18 +1347,18 @@
 	}
 
 	/** EMFコンポーネントのIORに合致するRTSコンポーネントを探し出す */
-	public static Component findComponentByIOR(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<Component> components) {
-		if (!(eComp instanceof jp.go.aist.rtm.toolscommon.model.component.CorbaComponent)) {
+	public static org.openrtp.namespaces.rts.version02.Component findComponentByIOR(
+			Component eComp,
+			List<org.openrtp.namespaces.rts.version02.Component> components) {
+		if (!(eComp instanceof CorbaComponent)) {
 			return null;
 		}
-		jp.go.aist.rtm.toolscommon.model.component.CorbaComponent eCorbaComp = (jp.go.aist.rtm.toolscommon.model.component.CorbaComponent) eComp;
-		for (Component c : components) {
-			if (!(c instanceof ComponentExt)) {
+		CorbaComponent eCorbaComp = (CorbaComponent) eComp;
+		for (org.openrtp.namespaces.rts.version02.Component c : components) {
+			if (!(c instanceof org.openrtp.namespaces.rts.version02.ComponentExt)) {
 				continue;
 			}
-			ComponentExt cx = (ComponentExt) c;
+			org.openrtp.namespaces.rts.version02.ComponentExt cx = (org.openrtp.namespaces.rts.version02.ComponentExt) c;
 			String compIor = findProperyValue(KEY_IOR, cx.getProperties());
 			if (compIor == null) {
 				continue;
@@ -1362,11 +1371,11 @@
 	}
 
 	/** EMFコンポーネントに合致するParticipants要素を探し出す */
-	private Participants findParticipants(
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<Participants> participants) {
-		for (Participants participant : participants) {
-			TargetComponent tc = participant.getParticipant();
+	private org.openrtp.namespaces.rts.version02.Participants findParticipants(
+			Component eComp,
+			List<org.openrtp.namespaces.rts.version02.Participants> participants) {
+		for (org.openrtp.namespaces.rts.version02.Participants participant : participants) {
+			org.openrtp.namespaces.rts.version02.TargetComponent tc = participant.getParticipant();
 			if (tc.getComponentId().equals(eComp.getComponentId())
 					&& tc.getInstanceName().equals(eComp.getInstanceNameL())) {
 				// pathIdもチェックする
@@ -1379,15 +1388,15 @@
 	}
 
 	/** EMFコンポーネントのECに合致するECを探し出す */
-	public static ExecutionContext findExecutionContext(
-			jp.go.aist.rtm.toolscommon.model.component.ExecutionContext eEc,
-			jp.go.aist.rtm.toolscommon.model.component.Component eComp,
-			List<ExecutionContext> contexts) {
+	public static org.openrtp.namespaces.rts.version02.ExecutionContext findExecutionContext(
+			ExecutionContext eEc,
+			Component eComp,
+			List<org.openrtp.namespaces.rts.version02.ExecutionContext> contexts) {
 		String id = eComp.getExecutionContextHandler().getId(eEc);
 		if (id == null) {
 			return null;
 		}
-		for (ExecutionContext ec : contexts) {
+		for (org.openrtp.namespaces.rts.version02.ExecutionContext ec : contexts) {
 			if (id.equals(ec.getId()) && eEc.getKindName().equals(ec.getKind())) {
 				return ec;
 			}
@@ -1396,10 +1405,10 @@
 	}
 
 	/** TargetComponentに合致するEMFコンポーネントを探し出す */
-	private jp.go.aist.rtm.toolscommon.model.component.Component findEMFComponentByTargetComponent(
-			TargetComponent tc,
-			List<jp.go.aist.rtm.toolscommon.model.component.Component> eComps) {
-		for (jp.go.aist.rtm.toolscommon.model.component.Component eComp : eComps) {
+	private Component findEMFComponentByTargetComponent(
+			org.openrtp.namespaces.rts.version02.TargetComponent tc,
+			List<Component> eComps) {
+		for (Component eComp : eComps) {
 			if (eComp.getComponentId().equals(tc.getComponentId())
 					&& eComp.getInstanceNameL().equals(tc.getInstanceName())) {
 				// pathIdもチェックする
@@ -1412,16 +1421,17 @@
 	}
 
 	/** TargetPortに合致するEMFポートを探し出す */
-	private jp.go.aist.rtm.toolscommon.model.component.Port findEMFPortByTargetPort(
-			TargetPort tp,
-			List<jp.go.aist.rtm.toolscommon.model.component.Port> ePorts) {
+	private Port findEMFPortByTargetPort(
+			org.openrtp.namespaces.rts.version02.TargetPort tp,
+			List<Port> ePorts) {
 		String name = tp.getPortName();
-		if (name.split("\\.").length < 2 && !name.startsWith(tp.getInstanceName())) {
+		if (name.split("\\.").length < 2
+				&& !name.startsWith(tp.getInstanceName())) {
 			// オフラインの場合はポート名を正規化する
-			name = ComponentUtil.createPortName(tp.getInstanceName(), tp
-					.getPortName());
+			name = ComponentUtil.createPortName(tp.getInstanceName(),
+					tp.getPortName());
 		}
-		for (jp.go.aist.rtm.toolscommon.model.component.Port ePort : ePorts) {
+		for (Port ePort : ePorts) {
 			if (name.equals(ePort.getNameL())) {
 				return ePort;
 			}
@@ -1430,11 +1440,13 @@
 	}
 
 	/** RTSプロファイルのプロパティのリストから、指定したキーのプロパティを探し出す */
-	static Property findProperty(String name, List<Property> properties) {
+	static org.openrtp.namespaces.rts.version02.Property findProperty(
+			String name,
+			List<org.openrtp.namespaces.rts.version02.Property> properties) {
 		if (name == null) {
 			return null;
 		}
-		for (Property p : properties) {
+		for (org.openrtp.namespaces.rts.version02.Property p : properties) {
 			if (name.equals(p.getName())) {
 				return p;
 			}
@@ -1443,8 +1455,10 @@
 	}
 
 	/** RTSプロファイルのプロパティのリストから、指定したキーの値を探し出す */
-	static String findProperyValue(String name, List<Property> properties) {
-		Property p = findProperty(name, properties);
+	static String findProperyValue(String name,
+			List<org.openrtp.namespaces.rts.version02.Property> properties) {
+		org.openrtp.namespaces.rts.version02.Property p = findProperty(name,
+				properties);
 		return (p != null) ? p.getValue() : null;
 	}
 



More information about the openrtm-commit mailing list