[openrtm-commit:00869] r332 - trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 7月 10日 (火) 21:01:59 JST


Author: 
Date: 2012-07-10 21:01:59 +0900 (Tue, 10 Jul 2012)
New Revision: 332

Modified:
   trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RTSELoadComponentExtension.java
Log:
Modified RtsProfile loadling on OFFLINE Editor

Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RTSELoadComponentExtension.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RTSELoadComponentExtension.java	2012-07-07 14:30:42 UTC (rev 331)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RTSELoadComponentExtension.java	2012-07-10 12:01:59 UTC (rev 332)
@@ -2,11 +2,23 @@
 
 import static jp.go.aist.rtm.toolscommon.model.component.Component.COMPOSITETYPE_NONE;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
 import jp.go.aist.rtm.repositoryView.RepositoryAccessor;
+import jp.go.aist.rtm.repositoryView.model.LocalRVRootItem;
+import jp.go.aist.rtm.repositoryView.model.RepositoryViewFactory;
+import jp.go.aist.rtm.repositoryView.model.RepositoryViewItem;
+import jp.go.aist.rtm.repositoryView.model.RepositoryViewLeafItem;
+import jp.go.aist.rtm.repositoryView.ui.views.RepositoryView;
 import jp.go.aist.rtm.toolscommon.extension.LoadComponentExtension;
 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.profiles.util.IDUtil;
+import jp.go.aist.rtm.toolscommon.util.RtcProfileHandler;
 
 public class RTSELoadComponentExtension extends LoadComponentExtension {
 
@@ -29,9 +41,42 @@
 				Component spec = RepositoryAccessor.eINSTANCE.findComponent(
 						componentid, pathId);
 				if (spec == null) {
-					throw new IllegalStateException("Target Component["
-							+ componentid + "](" + pathId
-							+ ") does not exist in RepositoryView.");
+					//リポジトリビューに登録されていない場合には,Profileを読み込み
+//					throw new IllegalStateException("Target Component["
+//							+ componentid + "](" + pathId
+//							+ ") does not exist in RepositoryView.");
+					ComponentSpecification module = null;
+			    	RtcProfileHandler handler = new RtcProfileHandler();
+			    	String targetFileName = null;
+					try {
+				    	URI uri = new URI(target.getPathUri());
+				    	targetFileName = uri.getPath();
+						module = handler.createComponent(targetFileName);
+					} catch (URISyntaxException e) {
+						throw new IllegalStateException("Target Component["
+						+ componentid + "](" + pathId
+						+ ") does not exist in RepositoryView.");
+					} catch (Exception e) {
+						throw new IllegalStateException("Target Component["
+								+ componentid + "](" + pathId
+								+ ") does not exist in RepositoryView.");
+					}
+					String fileName = targetFileName.substring(targetFileName.lastIndexOf(File.separator) + 1);
+					module.setAliasName(module.getInstanceNameL() + "(" + fileName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+					module.setPathId(target.getPathUri());
+					//
+					RepositoryView viewer = RepositoryAccessor.eINSTANCE.getView();
+			    	RepositoryViewItem rootItem = new RepositoryViewItem("root", 0); //$NON-NLS-1$
+			    	rootItem.setChildren((List<RepositoryViewItem>)viewer.getViewer().getInput());
+
+			 		RepositoryViewItem itemFirst = rootItem.getChild(module.getPathId());
+			 		if( itemFirst==null ) {
+			    		itemFirst = new LocalRVRootItem(module.getPathId());
+						rootItem.addChild(itemFirst);
+			 		}
+					RepositoryViewFactory.buildTree(itemFirst, module, RepositoryViewLeafItem.RTC_LEAF);
+					viewer.getViewer().refresh();
+					spec = RepositoryAccessor.eINSTANCE.findComponent(componentid, pathId);
 				}
 				return spec.copy();
 			}



More information about the openrtm-commit mailing list