[openrtm-commit:01863] r592 - in trunk/rtmtools/jp.go.aist.rtm.systemeditor: META-INF src/jp/go/aist/rtm/systemeditor src/jp/go/aist/rtm/systemeditor/corba src/jp/go/aist/rtm/systemeditor/extension src/jp/go/aist/rtm/systemeditor/factory src/jp/go/aist/rtm/systemeditor/nl src/jp/go/aist/rtm/systemeditor/ui/dialog src/jp/go/aist/rtm/systemeditor/ui/editor src/jp/go/aist/rtm/systemeditor/ui/editor/action src/jp/go/aist/rtm/systemeditor/ui/editor/editpart src/jp/go/aist/rtm/systemeditor/ui/editor/figure test/jp/go/aist/rtm/systemeditor/ui/dialog
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 3月 17日 (木) 21:49:43 JST
Author: ga
Date: 2016-03-17 21:49:43 +0900 (Thu, 17 Mar 2016)
New Revision: 592
Added:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/package-info.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenAndCreateRestoreAction.java
Modified:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/META-INF/MANIFEST.MF
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RehabilitateComponentExtension.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/CompositeComponentCreator.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/Rehabilitation.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogData.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramContextMenuProvider.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramEditor.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/RestoreOption.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortHelper.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogTest.java
Log:
Modified system restore procedures #3446
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/META-INF/MANIFEST.MF
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/META-INF/MANIFEST.MF 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/META-INF/MANIFEST.MF 2016-03-17 12:49:43 UTC (rev 592)
@@ -7,25 +7,36 @@
Bundle-Version: 1.1.0.rc4v20130124
Bundle-Activator: jp.go.aist.rtm.systemeditor.RTSystemEditorPlugin
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.gef;visibility:=reexport,jp.go.aist.rtm.to
- olscommon,jp.go.aist.rtm.nameserviceview,jp.go.aist.rtm.toolscommon.p
- rofiles,jp.go.aist.rtm.repositoryView
+Require-Bundle: org.eclipse.gef;visibility:=reexport,
+ jp.go.aist.rtm.toolscommon,
+ jp.go.aist.rtm.nameserviceview,
+ jp.go.aist.rtm.toolscommon.profiles,
+ jp.go.aist.rtm.repositoryView
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Export-Package: jp.go.aist.rtm.systemeditor,jp.go.aist.rtm.systemedito
- r._debug,jp.go.aist.rtm.systemeditor._test,jp.go.aist.rtm.systemedito
- r.adapterfactory,jp.go.aist.rtm.systemeditor.extension,jp.go.aist.rtm
- .systemeditor.factory,jp.go.aist.rtm.systemeditor.manager,jp.go.aist.
- rtm.systemeditor.nl,jp.go.aist.rtm.systemeditor.ui.action,jp.go.aist.
- rtm.systemeditor.ui.dialog,jp.go.aist.rtm.systemeditor.ui.editor,jp.g
- o.aist.rtm.systemeditor.ui.editor.action,jp.go.aist.rtm.systemeditor.
- ui.editor.command,jp.go.aist.rtm.systemeditor.ui.editor.dnd,jp.go.ais
- t.rtm.systemeditor.ui.editor.editpart,jp.go.aist.rtm.systemeditor.ui.
- editor.editpart.factory,jp.go.aist.rtm.systemeditor.ui.editor.editpar
- t.router,jp.go.aist.rtm.systemeditor.ui.editor.editpolicy,jp.go.aist.
- rtm.systemeditor.ui.editor.figure,jp.go.aist.rtm.systemeditor.ui.pref
- erence,jp.go.aist.rtm.systemeditor.ui.util,jp.go.aist.rtm.systemedito
- r.ui.workbenchadapter,jp.go.aist.rtm.systemeditor.extension
+Export-Package: jp.go.aist.rtm.systemeditor,
+ jp.go.aist.rtm.systemeditor._debug,
+ jp.go.aist.rtm.systemeditor._test,
+ jp.go.aist.rtm.systemeditor.adapterfactory,
+ jp.go.aist.rtm.systemeditor.corba,
+ jp.go.aist.rtm.systemeditor.extension,
+ jp.go.aist.rtm.systemeditor.factory,
+ jp.go.aist.rtm.systemeditor.manager,
+ jp.go.aist.rtm.systemeditor.nl,
+ jp.go.aist.rtm.systemeditor.ui.action,
+ jp.go.aist.rtm.systemeditor.ui.dialog,
+ jp.go.aist.rtm.systemeditor.ui.editor,
+ jp.go.aist.rtm.systemeditor.ui.editor.action,
+ jp.go.aist.rtm.systemeditor.ui.editor.command,
+ jp.go.aist.rtm.systemeditor.ui.editor.dnd,
+ jp.go.aist.rtm.systemeditor.ui.editor.editpart,
+ jp.go.aist.rtm.systemeditor.ui.editor.editpart.factory,
+ jp.go.aist.rtm.systemeditor.ui.editor.editpart.router,
+ jp.go.aist.rtm.systemeditor.ui.editor.editpolicy,
+ jp.go.aist.rtm.systemeditor.ui.editor.figure,
+ jp.go.aist.rtm.systemeditor.ui.preference,
+ jp.go.aist.rtm.systemeditor.ui.util,
+ jp.go.aist.rtm.systemeditor.ui.workbenchadapter
Bundle-Vendor: %providerName
Eclipse-BuddyPolicy: registered
Built-By: ngd
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -0,0 +1,296 @@
+package jp.go.aist.rtm.systemeditor.corba;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openrtp.namespaces.rts.version02.ConfigurationData;
+import org.openrtp.namespaces.rts.version02.ConfigurationSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import jp.go.aist.rtm.nameserviceview.corba.NameServerAccesser;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
+import jp.go.aist.rtm.toolscommon.synchronizationframework.SynchronizationSupport;
+import jp.go.aist.rtm.toolscommon.util.RtsProfileHandler;
+
+/**
+ * CORBA操作に関するヘルパー
+ */
+public class CORBAHelper {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CORBAHelper.class);
+
+ private static NS _ns = new NS();
+ private static Factory _factory = new Factory();
+
+ /**
+ * CORBA ネーミングサービスに関するヘルパーを取得します (Singleton)。
+ *
+ * @return ネーミングサービスに関するヘルパー
+ */
+ public static NS ns() {
+ return _ns;
+ }
+
+ /**
+ * CORBA コンポーネント生成に関するヘルパーを取得します (Singleton)。
+ *
+ * @return コンポーネント生成に関するヘルパー
+ */
+ public static Factory factory() {
+ return _factory;
+ }
+
+ /**
+ * ネーミングサービスに関するヘルパー
+ */
+ public static class NS {
+
+ private NS() {
+ }
+
+ /**
+ * パスから CORBA オブジェクトを解決します。
+ *
+ * @param path
+ * CORBAオブジェクトのパス
+ * @return CORBAオブジェクト
+ */
+ public org.omg.CORBA.Object resolve(String path) {
+ org.omg.CORBA.Object result = NameServerAccesser.getInstance().getObjectFromPathId(path);
+ return result;
+ }
+
+ /**
+ * パスのコンテキスト部に対するマネージャを検索します。
+ *
+ * @param path
+ * CORBAオブジェクトのパス
+ * @return マネージャ
+ */
+ public RTM.Manager findManager(String path) {
+ int index = path.lastIndexOf("/");
+ String cid = path.substring(0, index);
+ return NameServerAccesser.getInstance().getManagerFromContextId(cid);
+ }
+
+ }
+
+ /**
+ * コンポーネント生成に関するヘルパー
+ */
+ public static class Factory {
+
+ private Factory() {
+ }
+
+ /**
+ * CORBAコンポーネントのリモートオブジェクトが生存しているか判定します。
+ *
+ * @param comp
+ * CORBAコンポーネント
+ * @return リモートオブジェクトが生存している場合はtrue
+ */
+ public boolean isAvailable(CorbaComponent comp) {
+ return (comp.getCorbaObject() != null && SynchronizationSupport.ping(comp.getCorbaObject()));
+ }
+
+ /**
+ * CORBA コンポーネントに対するリモートオブジェクトを生成します。
+ *
+ * @param comp
+ * CORBA コンポーネント
+ * @param diagram
+ * ダイアグラム
+ * @return リモートオブジェクト
+ * @throws CORBAException
+ */
+ public RTC.RTObject createRTObject(CorbaComponent comp, SystemDiagram diagram) throws CORBAException {
+ LOGGER.trace("createRTObject START comp=<{}> diagram=<{}>", comp, diagram);
+ RTM.Manager manager = ns().findManager(comp.getPathId());
+ if (manager == null) {
+ throw new CORBAException(String.format("Fail to find manager: path=<%s>", comp.getPathId()));
+ }
+ String param = buildCreateComponentParam(comp);
+ RTC.RTObject rtobj = manager.create_component(param);
+ return rtobj;
+ }
+
+ /**
+ * CORBA 複合コンポーネントに対するリモートオブジェクトを生成します。
+ *
+ * @param comp
+ * CORBA 複合コンポーネント
+ * @param diagram
+ * ダイアグラム
+ * @return リモートオブジェクト
+ * @throws CORBAException
+ */
+ public RTC.RTObject createCompositeRTObject(CorbaComponent comp, SystemDiagram diagram) throws CORBAException {
+ LOGGER.trace("createCompositeRTObject START comp=<{}> diagram=<{}>", comp, diagram);
+ RTM.Manager manager = ns().findManager(comp.getPathId());
+ if (manager == null) {
+ throw new CORBAException(String.format("Fail to find manager: path=<%s>", comp.getPathId()));
+ }
+ String exportedPorts = findConfiguration("exported_ports", comp, diagram);
+ String param = buildCreateCompositeComponentParam(comp, exportedPorts);
+ RTC.RTObject rtobj = manager.create_component(param);
+ return rtobj;
+ }
+
+ /**
+ * CORBA 複合コンポーネントのリモートオブジェクトへ、子コンポーネントを割り当てます。<br>
+ * あらかじめ複合コンポーネント自体のリモートオブジェクトを設定しておくこと
+ *
+ * @param comp
+ * CORBA 複合コンポーネント
+ * @throws CORBAException
+ */
+ public void setCompositeMembers(CorbaComponent comp) throws CORBAException {
+ LOGGER.trace("setCompositeMembers START comp=<{}>", comp);
+ RTC.RTObject remote = comp.getCorbaObjectInterface();
+ if (remote == null) {
+ throw new CORBAException(String.format("Remote object does not loaded: comp=<{}>", comp));
+ }
+ // 子RTCの CORBAオブジェクトリストを生成
+ List<_SDOPackage.SDO> sdolist = new ArrayList<_SDOPackage.SDO>();
+ for (Component o : comp.getComponents()) {
+ CorbaComponent c = (CorbaComponent) o;
+ RTC.RTObject rtobj = c.getCorbaObjectInterface();
+ if (rtobj == null) {
+ throw new CORBAException(String.format("Remote object of child does not loaded: comp=<{}>", c));
+ }
+ sdolist.add(rtobj);
+ }
+ _SDOPackage.SDO[] sdos = sdolist.toArray(new _SDOPackage.SDO[0]);
+ try {
+ remote.get_owned_organizations()[0].set_members(sdos);
+ } catch (Exception e) {
+ remote.exit();
+ throw new CORBAException(String.format("Fail to set members: remote=<{}> sdos=<{}>", remote, sdos));
+ }
+ }
+
+ /**
+ * このダイアグラムの RTSProfileから、コンポーネントの ConfigurationSet 設定値を検索します。
+ *
+ * @param key
+ * パラメータ名
+ * @param comp
+ * EMFコンポーネント(CORBA)
+ * @param diagram
+ * ダイアグラム
+ * @return 設定値、パラメータが存在しなかった場合はブランク("")
+ */
+ public String findConfiguration(String key, CorbaComponent comp, SystemDiagram diagram) {
+ org.openrtp.namespaces.rts.version02.Component orig = RtsProfileHandler.findComponent(comp,
+ diagram.getProfile().getComponents());
+ String activeId = orig.getActiveConfigurationSet();
+ for (ConfigurationSet cs : orig.getConfigurationSets()) {
+ if (!cs.getId().equals(activeId)) {
+ continue;
+ }
+ for (ConfigurationData cd : cs.getConfigurationData()) {
+ if (cd.getName().equals(key)) {
+ return cd.getData();
+ }
+ }
+ }
+ return "";
+ }
+
+ /**
+ * コンポーネント生成のパラメータを生成します。<br>
+ * 次の情報が設定されていること (必須)
+ * <ul>
+ * <li>implementation_id : [プロパティ] コンポーネントの型</li>
+ * <li>instance_name : [プロパティ] コンポーネントのインスタンス名</li>
+ * </ul>
+ *
+ * @param comp
+ * CORBA コンポーネント
+ * @return コンポーネント生成パラメータ (失敗時はnull)
+ */
+ public String buildCreateComponentParam(CorbaComponent comp) {
+ String implementationId = comp.getProperty("implementation_id");
+ String instanceName = comp.getProperty("instance_name");
+ if (implementationId == null || instanceName == null) {
+ return null;
+ }
+ StringBuffer ret = new StringBuffer();
+ ret.append(implementationId).append("?instance_name=");
+ ret.append(instanceName);
+ return ret.toString();
+ }
+
+ /**
+ * 複合コンポーネント生成のパラメータを生成します。<br>
+ * 次の情報が設定されていること (必須)
+ * <ul>
+ * <li>compositeType: [属性] 複合コンポーネントタイプ</li>
+ * <li>instance_name : [プロパティ] コンポーネントのインスタンス名</li>
+ * <li>exportedPorts : [引数] 公開ポート指定</li>
+ * </ul>
+ *
+ * @param comp
+ * CORBA 複合コンポーネント
+ * @param exportedPorts
+ * 公開ポート指定
+ * @return コンポーネント生成パラメータ (失敗時はnull)
+ */
+ public String buildCreateCompositeComponentParam(CorbaComponent comp, String exportedPorts) {
+ String compositeType = comp.getCompositeTypeL();
+ String instanceName = comp.getProperty("instance_name");
+ return buildCreateCompositeComponentParam(compositeType, instanceName, exportedPorts);
+ }
+
+ /**
+ * 複合コンポーネント生成のパラメータを生成します。
+ *
+ * @param compositeType
+ * 複合コンポーネントタイプ
+ * @param instanceName
+ * コンポーネントのインスタンス名
+ * @param exportedPorts
+ * 公開ポート指定
+ * @return コンポーネント生成パラメータ (失敗時はnull)
+ */
+ public String buildCreateCompositeComponentParam(String compositeType, String instanceName,
+ String exportedPorts) {
+ if (compositeType == null || instanceName == null || exportedPorts == null) {
+ return null;
+ }
+ StringBuffer ret = new StringBuffer();
+ ret.append(compositeType).append("Composite?instance_name=");
+ ret.append(instanceName);
+ ret.append("&exported_ports=");
+ ret.append(exportedPorts);
+ return ret.toString();
+ }
+
+ }
+
+ /**
+ * CORBA 操作に関する例外
+ */
+ public static class CORBAException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public CORBAException(String msg) {
+ super(msg);
+ }
+
+ public CORBAException(Throwable cause) {
+ super(cause);
+ }
+
+ public CORBAException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/package-info.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/package-info.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/package-info.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -0,0 +1,4 @@
+/**
+ * CORBAに関するサポートパッケージ
+ */
+package jp.go.aist.rtm.systemeditor.corba;
\ No newline at end of file
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RehabilitateComponentExtension.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RehabilitateComponentExtension.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/extension/RehabilitateComponentExtension.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -1,21 +1,18 @@
package jp.go.aist.rtm.systemeditor.extension;
-import java.util.ArrayList;
-import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import org.openrtp.namespaces.rts.version02.ConfigurationData;
-import org.openrtp.namespaces.rts.version02.ConfigurationSet;
-
-import jp.go.aist.rtm.nameserviceview.corba.NameServerAccesser;
-import jp.go.aist.rtm.systemeditor.ui.dialog.NewCompositeComponentDialogData;
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CORBAException;
import jp.go.aist.rtm.toolscommon.model.component.Component;
import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
-import jp.go.aist.rtm.toolscommon.synchronizationframework.SynchronizationSupport;
-import jp.go.aist.rtm.toolscommon.util.RtsProfileHandler;
public abstract class RehabilitateComponentExtension {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RehabilitateComponentExtension.class);
+
protected Component component;
protected SystemDiagram diagram;
@@ -28,16 +25,29 @@
}
/**
+ * この拡張が対象の EMFコンポーネントを復元可能か判定します。
+ *
* @return 復元可能な場合は true
*/
public abstract boolean canRehabilitate();
/**
- * @return 復元済みの EMFコンポーネント
+ * EMFコンポーネントに対するリモートオブジェクトを復元します。
+ *
+ * @param doCreate
+ * リモートオブジェクトが存在しないときに生成する場合はtrue
+ * @return 復元された EMFコンポーネント
*/
- public abstract Component rehabilitate();
+ public abstract Component rehabilitateComponent(boolean doCreate);
/**
+ * EMFコンポーネントの構造を復元します (複合コンポーネント)。
+ *
+ * @return 復元された EMFコンポーネント
+ */
+ public abstract Component rehabilitateStructure();
+
+ /**
* CORBA用ユーティリティ
*/
public static class CORBA {
@@ -50,15 +60,15 @@
* ダイアグラム
* @return 解決済みの CORBAオブジェクトをセットした EMFコンポーネント(CORBA)
*/
- public static CorbaComponent rehabilitate(CorbaComponent comp,
- SystemDiagram diagram) {
- if (comp.getCorbaObject() != null
- && SynchronizationSupport.ping(comp.getCorbaObject())) {
+ public static CorbaComponent rehabilitate(CorbaComponent comp, SystemDiagram diagram) {
+ if (CORBAHelper.factory().isAvailable(comp)) {
return comp;
}
- org.omg.CORBA.Object remote = resolveCorbaName(comp.getPathId());
- RTC.RTObject narrow = RTC.RTObjectHelper.narrow(remote);
- comp.setCorbaObject(narrow);
+ org.omg.CORBA.Object remote = CORBAHelper.ns().resolve(comp.getPathId());
+ if (remote != null) {
+ RTC.RTObject narrow = RTC.RTObjectHelper.narrow(remote);
+ comp.setCorbaObject(narrow);
+ }
return comp;
}
@@ -71,17 +81,19 @@
* ダイアグラム
* @return 生成した CORBAオブジェクトをセットした EMFコンポーネント(CORBA)
*/
- public static CorbaComponent createComponent(CorbaComponent comp,
- SystemDiagram diagram) {
- RTM.Manager manager = findManager(comp.getPathId());
- if (manager == null) {
- return comp;
+ public static CorbaComponent createComponent(CorbaComponent comp, SystemDiagram diagram) {
+ try {
+ RTC.RTObject rtobj = null;
+ if (comp.isCompositeComponent()) {
+ rtobj = CORBAHelper.factory().createCompositeRTObject(comp, diagram);
+ } else {
+ rtobj = CORBAHelper.factory().createRTObject(comp, diagram);
+ }
+ comp.setCorbaObject(rtobj);
+ } catch (CORBAException e) {
+ LOGGER.error("Fail to create component: composite=<{}> comp=<{}>", comp.isCompositeComponent(), comp);
+ LOGGER.error("Fail to create component:", e);
}
- String param = NewCompositeComponentDialogData.getParam(comp
- .getCompositeTypeL(), comp.getInstanceNameL(),
- getExportedPortString(comp, diagram));
- RTC.RTObject remote = manager.create_component(param);
- comp.setCorbaObject(remote);
return comp;
}
@@ -94,26 +106,12 @@
* ダイアグラム
* @return 子RTCを設定した EMFコンポーネント(CORBA)
*/
- public static CorbaComponent setCompositeMembers(CorbaComponent comp,
- SystemDiagram diagram) {
- if (comp.getCorbaObject() == null) {
- return comp;
- }
- RTC.RTObject remote = comp.getCorbaObjectInterface();
- // 子RTCの CORBAオブジェクトリストを生成
- List<_SDOPackage.SDO> sdolist = new ArrayList<_SDOPackage.SDO>();
- for (Component o : comp.getComponents()) {
- CorbaComponent c = (CorbaComponent) o;
- rehabilitate(c, diagram);
- sdolist.add(c.getCorbaObjectInterface());
- }
- sdolist.toArray(new _SDOPackage.SDO[0]);
- //
+ public static CorbaComponent setCompositeMembers(CorbaComponent comp, SystemDiagram diagram) {
try {
- remote.get_owned_organizations()[0].set_members(sdolist
- .toArray(new _SDOPackage.SDO[0]));
- } catch (Exception e) {
- remote.exit();
+ CORBAHelper.factory().setCompositeMembers(comp);
+ } catch (CORBAException e) {
+ LOGGER.error("Fail to set composite members: comp=<{}>", comp);
+ LOGGER.error("Fail to set composite members:", e);
comp.setCorbaObject(null);
}
return comp;
@@ -128,38 +126,23 @@
* ダイアグラム
* @return 公開ポート情報(exported_ports)
*/
- public static String getExportedPortString(CorbaComponent comp,
- SystemDiagram diagram) {
- org.openrtp.namespaces.rts.version02.Component orig = RtsProfileHandler
- .findComponent(comp, diagram.getProfile().getComponents());
- String activeId = orig.getActiveConfigurationSet();
- for (ConfigurationSet cs : orig.getConfigurationSets()) {
- if (!cs.getId().equals(activeId)) {
- continue;
- }
- for (ConfigurationData cd : cs.getConfigurationData()) {
- if (cd.getName().equals("exported_ports")) {
- return cd.getData();
- }
- }
- }
- return "";
+ @Deprecated
+ public static String getExportedPortString(CorbaComponent comp, SystemDiagram diagram) {
+ return CORBAHelper.factory().findConfiguration("exported_ports", comp, diagram);
}
/** パスIDを元に CORBAの名前解決を行います */
+ @Deprecated
public static org.omg.CORBA.Object resolveCorbaName(String path) {
- org.omg.CORBA.Object result = NameServerAccesser.getInstance()
- .getObjectFromPathId(path);
- return result;
+ return CORBAHelper.ns().resolve(path);
}
/** パスIDを元に RTM.Managerを検索します */
+ @Deprecated
public static RTM.Manager findManager(String path) {
- int index = path.lastIndexOf("/");
- String cid = path.substring(0, index);
- return NameServerAccesser.getInstance()
- .getManagerFromContextId(cid);
+ return CORBAHelper.ns().findManager(path);
}
+
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/CompositeComponentCreator.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/CompositeComponentCreator.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/CompositeComponentCreator.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -11,9 +11,9 @@
import org.eclipse.core.runtime.Platform;
import jp.go.aist.rtm.systemeditor.RTSystemEditorPlugin;
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
import jp.go.aist.rtm.systemeditor.extension.CreateCompositeComponentExtension;
import jp.go.aist.rtm.systemeditor.ui.dialog.NewCompositeComponentDialog;
-import jp.go.aist.rtm.systemeditor.ui.dialog.NewCompositeComponentDialogData;
import jp.go.aist.rtm.systemeditor.ui.editor.AbstractSystemDiagramEditor;
import jp.go.aist.rtm.systemeditor.ui.util.TimeoutWrappedJob;
import jp.go.aist.rtm.systemeditor.ui.util.TimeoutWrapper;
@@ -302,14 +302,12 @@
return composite;
} else {
- String param = NewCompositeComponentDialogData.getParam(
- base.compositeType, base.instanceName,
- base.exportedPorts);
+ String param = CORBAHelper.factory().buildCreateCompositeComponentParam(base.compositeType,
+ base.instanceName, base.exportedPorts);
Component composite = base.manager.createComponentR(param);
String childPathId = base.components.get(0).getPathId();
- composite.setPathId(childPathId.substring(0, childPathId
- .lastIndexOf("/") + 1)
- + base.instanceName + ".rtc");
+ composite.setPathId(
+ childPathId.substring(0, childPathId.lastIndexOf("/") + 1) + base.instanceName + ".rtc");
return composite;
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/Rehabilitation.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/Rehabilitation.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/factory/Rehabilitation.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -3,16 +3,18 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.Platform;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import jp.go.aist.rtm.systemeditor.RTSystemEditorPlugin;
import jp.go.aist.rtm.systemeditor.extension.RehabilitateComponentExtension;
import jp.go.aist.rtm.toolscommon.model.component.Component;
import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.Platform;
-
/**
* アクセスできないオブジェクトに対して、PathIdや名前から修復を行うクラス
* <p>
@@ -22,42 +24,85 @@
*/
public class Rehabilitation {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Rehabilitation.class);
+
static final String EXTENTION_POINT_NAME = "rehabilitatecomponent";
- static List<RehabilitateComponentExtension> rehabilitaters;
+ static List<RehabilitateComponentExtension> rehabilitaters = null;
public static void rehabilitation(SystemDiagram diagram) {
+ rehabilitation(diagram, false);
+ }
+
+ public static void rehabilitation(SystemDiagram diagram, boolean doCreate) {
if (rehabilitaters == null) {
buildRehabilitaters();
}
for (Component c : diagram.getRegisteredComponents()) {
- RehabilitateComponentExtension rehabilitater = null;
- for (RehabilitateComponentExtension ext : rehabilitaters) {
- ext.setComponent(c);
- ext.setDiagram(diagram);
- if (!ext.canRehabilitate()) {
- continue;
- }
- rehabilitater = ext;
- break;
+ rehabilitateComponent(c, diagram, doCreate);
+ }
+ for (Component c : diagram.getRegisteredComponents()) {
+ rehabilitateStructure(c, diagram);
+ }
+ if (doCreate) {
+ // コンポーネントを生成した場合、生成後のRTCProfileの変更が反映されないので強制的に更新 (OpenRTMの不具合)
+ LOGGER.info("Re-rehabilitating the component structure on doCreate mode.");
+ for (Component c : diagram.getRegisteredComponents()) {
+ rehabilitateStructure(c, diagram);
}
- rehabilitater.rehabilitate();
}
}
+ public static void rehabilitateComponent(Component comp, SystemDiagram diagram, boolean doCreate) {
+ if (rehabilitaters == null) {
+ buildRehabilitaters();
+ }
+ RehabilitateComponentExtension rehabilitater = findExtension(comp, diagram);
+ if (rehabilitater == null) {
+ LOGGER.info("Rehabilitate extension does not defined. comp=<{}> diagram=<{}>", comp, diagram);
+ return;
+ }
+ rehabilitater.rehabilitateComponent(doCreate);
+ }
+
+ public static void rehabilitateStructure(Component comp, SystemDiagram diagram) {
+ if (rehabilitaters == null) {
+ buildRehabilitaters();
+ }
+ RehabilitateComponentExtension rehabilitater = findExtension(comp, diagram);
+ if (rehabilitater == null) {
+ LOGGER.info("Rehabilitate extension does not defined. comp=<{}> diagram=<{}>", comp, diagram);
+ return;
+ }
+ rehabilitater.rehabilitateStructure();
+ }
+
+ public static RehabilitateComponentExtension findExtension(Component comp, SystemDiagram diagram) {
+ RehabilitateComponentExtension ret = null;
+ for (RehabilitateComponentExtension ext : rehabilitaters) {
+ ext.setComponent(comp);
+ ext.setDiagram(diagram);
+ if (!ext.canRehabilitate()) {
+ continue;
+ }
+ ret = ext;
+ break;
+ }
+ return ret;
+ }
+
static void buildRehabilitaters() {
- rehabilitaters = new ArrayList<RehabilitateComponentExtension>();
+ List<RehabilitateComponentExtension> exts = new ArrayList<RehabilitateComponentExtension>();
//
String ns = RTSystemEditorPlugin.class.getPackage().getName();
- IExtension[] extensions = Platform.getExtensionRegistry()
- .getExtensionPoint(ns, EXTENTION_POINT_NAME).getExtensions();
+ IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(ns, EXTENTION_POINT_NAME)
+ .getExtensions();
for (IExtension ex : extensions) {
for (IConfigurationElement ce : ex.getConfigurationElements()) {
Object obj;
try {
obj = ce.createExecutableExtension("extensionclass");
if (obj instanceof RehabilitateComponentExtension) {
- rehabilitaters
- .add((RehabilitateComponentExtension) obj);
+ exts.add((RehabilitateComponentExtension) obj);
}
} catch (Exception e) {
throw new RuntimeException(e);
@@ -75,29 +120,45 @@
}
@Override
- public Component rehabilitate() {
+ public Component rehabilitateComponent(boolean doCreate) {
CorbaComponent comp = (CorbaComponent) component;
try {
comp = CORBA.rehabilitate(comp, diagram);
} catch (Exception e) {
- if (!comp.isCompositeComponent()) {
- throw new RuntimeException("cannot access: "
- + comp.getPathId() + "\n" + e.getMessage());
+ LOGGER.warn("Fail to resolve component: comp=<{}> cause=<{}>", comp, e.getMessage());
+ comp.setCorbaObject(null);
+ }
+ if (comp.getCorbaObject() != null) {
+ return comp;
+ }
+ if (doCreate) {
+ try {
+ comp = CORBA.createComponent(comp, diagram);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Fail to create component: path=<%s>\n<%s>",
+ comp.getPathId(), e.getMessage()), e);
}
}
- if (comp.getCorbaObject() == null
- && comp.isCompositeComponent()) {
- comp = CORBA.createComponent(comp, diagram);
- comp = CORBA.setCompositeMembers(comp, diagram);
+ return comp;
+ }
+
+ @Override
+ public Component rehabilitateStructure() {
+ CorbaComponent comp = (CorbaComponent) this.component;
+ if (comp.getCorbaObject() != null) {
+ if (comp.isCompositeComponent()) {
+ comp = CORBA.setCompositeMembers(comp, diagram);
+ }
}
if (comp.getCorbaObject() == null) {
- throw new RuntimeException("cannot access: "
- + comp.getPathId());
+ throw new RuntimeException(String.format("Fail to set composite: path=<%s>", comp.getPathId()));
}
return comp;
}
};
- rehabilitaters.add(ext);
+ exts.add(ext);
+
+ rehabilitaters = exts;
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties 2016-03-17 12:49:43 UTC (rev 592)
@@ -163,10 +163,12 @@
AbstractSystemDiagramEditor.29=yyyy_MM_dd_hh_mm_ss_SSS
AbstractSystemDiagramEditor.32=Files have not been saved. Save the files?
AbstractSystemDiagramEditor.33=Validation error.
+OpenAndQuickRestoreAction.0=Open and Quick Restore...
+OpenAndQuickRestoreAction.1=Open and Quick Restore...
OpenAndRestoreAction.0=Open and Restore...
OpenAndRestoreAction.1=Open and Restore...
-OpenAndQuickRestoreAction.0=Open and Quick Restore...
-OpenAndQuickRestoreAction.1=Open and Quick Restore...
+OpenAndCreateRestoreAction.0=Open and Create Restore...
+OpenAndCreateRestoreAction.1=Open and Create Restore...
OpenAction.0=Open...
OpenAction.1=Open...
MoveComponentAction.8=Move
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogData.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogData.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogData.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -34,15 +34,4 @@
return ports;
}
- // 複合コンポーネント生成時にマネージャに渡すパラメータを返す
- public static String getParam(String compositeType, String instanceName,
- String exportedPortString) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(compositeType).append("Composite?instance_name=");
- buffer.append(instanceName);
- buffer.append("&exported_ports=");
- buffer.append(exportedPortString);
- return buffer.toString();
- }
-
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -881,18 +881,14 @@
save = MessageDialog.openQuestion(getSite().getShell(), "", //$NON-NLS-1$
Messages.getString("AbstractSystemDiagramEditor.32")); //$NON-NLS-1$
}
-
if (save) {
doSave(null);
}
-
title = null;
-
IFile createNewFile = createNewFilebySelection(null, SWT.OPEN);
if (createNewFile != null) {
try {
- load(new FileEditorInput(createNewFile), getEditorSite(),
- restore);
+ load(new FileEditorInput(createNewFile), getEditorSite(), restore);
} catch (PartInitException e) {
LOGGER.error("Fail to load file. file=" + createNewFile, e);
if (e.getStatus().getException() != null)
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramContextMenuProvider.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramContextMenuProvider.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramContextMenuProvider.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -1,21 +1,19 @@
package jp.go.aist.rtm.systemeditor.ui.editor;
-import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndQuickRestoreAction;
-import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndRestoreAction;
-
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IMenuManager;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndCreateRestoreAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndQuickRestoreAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndRestoreAction;
+
/**
* システムダイアグラムのContextMenuProviderクラス
*/
-public class SystemDiagramContextMenuProvider extends
- AbstractSystemDiagramContextMenuProvider {
+public class SystemDiagramContextMenuProvider extends AbstractSystemDiagramContextMenuProvider {
- public SystemDiagramContextMenuProvider(EditPartViewer viewer,
- ActionRegistry actionRegistry) {
-
+ public SystemDiagramContextMenuProvider(EditPartViewer viewer, ActionRegistry actionRegistry) {
super(viewer, actionRegistry);
}
@@ -25,6 +23,7 @@
appendAction(menuManager, OpenAndRestoreAction.ID, "save");
appendAction(menuManager, OpenAndQuickRestoreAction.ID, "save");
+ appendAction(menuManager, OpenAndCreateRestoreAction.ID, "save");
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramEditor.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramEditor.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramEditor.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -6,22 +6,6 @@
import java.util.ArrayList;
import java.util.List;
-import jp.go.aist.rtm.systemeditor.extension.LoadProfileExtension;
-import jp.go.aist.rtm.systemeditor.factory.ProfileLoader;
-import jp.go.aist.rtm.systemeditor.factory.Rehabilitation;
-import jp.go.aist.rtm.systemeditor.factory.SystemEditorWrapperFactory;
-import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
-import jp.go.aist.rtm.systemeditor.nl.Messages;
-import jp.go.aist.rtm.systemeditor.restoration.Restoration;
-import jp.go.aist.rtm.systemeditor.restoration.Result;
-import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndQuickRestoreAction;
-import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndRestoreAction;
-import jp.go.aist.rtm.systemeditor.ui.editor.action.RestoreOption;
-import jp.go.aist.rtm.toolscommon.model.component.Component;
-import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
-import jp.go.aist.rtm.toolscommon.model.component.SystemDiagramKind;
-import jp.go.aist.rtm.toolscommon.util.RtsProfileHandler;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.GraphicalViewer;
@@ -38,13 +22,29 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import jp.go.aist.rtm.systemeditor.extension.LoadProfileExtension;
+import jp.go.aist.rtm.systemeditor.factory.ProfileLoader;
+import jp.go.aist.rtm.systemeditor.factory.Rehabilitation;
+import jp.go.aist.rtm.systemeditor.factory.SystemEditorWrapperFactory;
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.systemeditor.restoration.Restoration;
+import jp.go.aist.rtm.systemeditor.restoration.Result;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndCreateRestoreAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndQuickRestoreAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.OpenAndRestoreAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.action.RestoreOption;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagramKind;
+import jp.go.aist.rtm.toolscommon.util.RtsProfileHandler;
+
/**
* SystemDiagramEditorクラス
*/
public class SystemDiagramEditor extends AbstractSystemDiagramEditor {
- private static final Logger LOGGER = LoggerFactory
- .getLogger(SystemDiagramEditor.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(SystemDiagramEditor.class);
/**
* システムダイアグラムエディタのID
@@ -56,7 +56,9 @@
super.createActions();
addAction(new OpenAndRestoreAction(this));
addAction(new OpenAndQuickRestoreAction(this));
+ addAction(new OpenAndCreateRestoreAction(this));
}
+
@SuppressWarnings("unchecked")
private void addAction(IAction action) {
getActionRegistry().registerAction(action);
@@ -116,22 +118,19 @@
return targetInput;
}
- private void doLoad(final IEditorSite site, final RestoreOption restore,
- FileEditorInput editorInput) throws PartInitException {
+ private void doLoad(final IEditorSite site, final RestoreOption restore, FileEditorInput editorInput)
+ throws PartInitException {
try {
- final String strPath =editorInput.getPath().toOSString();
-
+ final String strPath = editorInput.getPath().toOSString();
+
if (getSystemDiagram() != null) {
getSystemDiagram().setSynchronizeInterval(0);
}
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(site
- .getShell());
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(site.getShell());
IRunnableWithProgress runable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
-
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.getString("SystemDiagramEditor.3"), 100); //$NON-NLS-1$
monitor.subTask(Messages.getString("SystemDiagramEditor.4")); //$NON-NLS-1$
@@ -147,14 +146,12 @@
monitor.internalWorked(20);
ProfileLoader creator = new ProfileLoader();
- for (LoadProfileExtension.ErrorInfo info : creator
- .preLoad(profile, strPath)) {
+ for (LoadProfileExtension.ErrorInfo info : creator.preLoad(profile, strPath)) {
if (info.isError()) {
openError(DIALOG_TITLE_ERROR, info.getMessage());
return;
} else {
- if (!openConfirm(DIALOG_TITLE_CONFIRM, info
- .getMessage())) {
+ if (!openConfirm(DIALOG_TITLE_CONFIRM, info.getMessage())) {
return;
}
}
@@ -163,20 +160,18 @@
// STEP3: RTSプロファイルオブジェクトからダイアグラムを作成
monitor.internalWorked(20);
- SystemDiagram diagram = handler.load(profile,
- SystemDiagramKind.ONLINE_LITERAL);
+ SystemDiagram diagram = handler.load(profile, SystemDiagramKind.ONLINE_LITERAL);
if (restore.doQuick()) {
handler.populateCorbaBaseObject(diagram);
}
- SystemEditorWrapperFactory.getInstance()
- .getSynchronizationManager()
+ SystemEditorWrapperFactory.getInstance().getSynchronizationManager()
.assignSynchonizationSupportToDiagram(diagram);
- Rehabilitation.rehabilitation(diagram);
+ // リモートコンのポーネントが未起動時に、コンポーネントを生成するか指定
+ Rehabilitation.rehabilitation(diagram, restore.doCreate());
// 読み込み時に明示的に状態の同期を実行
- List<Component> eComps = new ArrayList<Component>(
- diagram.getComponents());
+ List<Component> eComps = new ArrayList<>(diagram.getComponents());
diagram.getComponents().clear();
for (Component c : eComps) {
c.synchronizeManually();
@@ -190,29 +185,27 @@
// STEP4: 拡張ポイント (ダイアグラム生成後)
monitor.internalWorked(20);
- for (LoadProfileExtension.ErrorInfo info : creator
- .postLoad(diagram, profile, oldDiagram)) {
+ for (LoadProfileExtension.ErrorInfo info : creator.postLoad(diagram, profile, oldDiagram)) {
if (info.isError()) {
openError(DIALOG_TITLE_ERROR, info.getMessage());
return;
} else {
- if (!openConfirm(DIALOG_TITLE_CONFIRM, info
- .getMessage())) {
+ if (!openConfirm(DIALOG_TITLE_CONFIRM, info.getMessage())) {
return;
}
}
}
-
} catch (Exception e) {
monitor.done();
throw new InvocationTargetException(e,
- Messages.getString("SystemDiagramEditor.6") + "\r\n" + e.getMessage()); //$NON-NLS-1$
+ Messages.getString("SystemDiagramEditor.6") + "\r\n" + e.getMessage()); //$NON-NLS-1$
}
+
monitor.internalWorked(35);
if (restore.doReplace()) {
monitor.subTask(Messages.getString("SystemDiagramEditor.7")); //$NON-NLS-1$
- try{
+ try {
RtsProfileHandler handler = new RtsProfileHandler();
handler.restoreConnection(getSystemDiagram());
handler.restoreConfigSet(getSystemDiagram());
@@ -223,11 +216,10 @@
throw new InvocationTargetException(e, Messages.getString("SystemDiagramEditor.8")); //$NON-NLS-1$
}
}
- //
+
monitor.done();
}
};
-
dialog.run(false, false, runable);
} catch (Exception e) {
throw new PartInitException(Messages.getString("SystemDiagramEditor.9"), e); //$NON-NLS-1$
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenAndCreateRestoreAction.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenAndCreateRestoreAction.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenAndCreateRestoreAction.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -0,0 +1,36 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.action;
+
+import org.eclipse.gef.ui.actions.EditorPartAction;
+
+import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.systemeditor.ui.editor.AbstractSystemDiagramEditor;
+
+/**
+ * RTSプロファイルを読み込んで、コンポーネント生成まで行うアクション
+ */
+public class OpenAndCreateRestoreAction extends EditorPartAction {
+
+ public static final String ID = OpenAndCreateRestoreAction.class.getName();
+
+ public OpenAndCreateRestoreAction(AbstractSystemDiagramEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ protected void init() {
+ setId(ID);
+ setText(Messages.getString("OpenAndCreateRestoreAction.0"));
+ setToolTipText(Messages.getString("OpenAndCreateRestoreAction.1"));
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return true;
+ }
+
+ @Override
+ public void run() {
+ ((AbstractSystemDiagramEditor) getEditorPart()).open(RestoreOption.CREATE);
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenAndCreateRestoreAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/RestoreOption.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/RestoreOption.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/RestoreOption.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -2,27 +2,35 @@
/**
* オンラインシステムダイアグラムにRTSプロファイルをロードするときの復元オプション
- *
*/
public enum RestoreOption {
- NONE(), NORMAL(false, true), QUICK(true, true);
+ NONE(), NORMAL(false, true, false), QUICK(true, true, false), CREATE(false, true, true);
+
private final boolean doQuick;
private final boolean doRelace;
-
- RestoreOption(){
- this(true, false);
+ private final boolean doCreate;
+
+ RestoreOption() {
+ this(true, false, false);
}
- RestoreOption(boolean doQuick, boolean doReplace) {
+
+ RestoreOption(boolean doQuick, boolean doReplace, boolean doCreate) {
this.doQuick = doQuick;
this.doRelace = doReplace;
+ this.doCreate = doCreate;
}
-
+
public boolean doQuick() {
- return doQuick;
+ return this.doQuick;
}
public boolean doReplace() {
- return doRelace;
+ return this.doRelace;
}
+
+ public boolean doCreate() {
+ return this.doCreate;
+ }
+
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -40,13 +40,12 @@
/**
* ポートのEditPartクラス
*/
-public abstract class PortEditPart extends AbstractEditPart implements
- NodeEditPart {
+public abstract class PortEditPart extends AbstractEditPart implements NodeEditPart {
private static final Logger LOGGER = LoggerFactory.getLogger(PortEditPart.class);
FloatingLabel portLabel;
-
+
/**
* コンストラクタ
*
@@ -59,13 +58,12 @@
@Override
protected IFigure createFigure() {
- portLabel = new FloatingLabel(((AbstractGraphicalEditPart) getParent()
- .getParent()).getFigure());
+ portLabel = new FloatingLabel(((AbstractGraphicalEditPart) getParent().getParent()).getFigure());
portLabel.setText(getPortBaseName());
portLabel.setSize(30, 10);
return null;
}
-
+
String getPortBaseName() {
String name = getModel().getNameL();
if (name == null) {
@@ -77,23 +75,20 @@
}
return name;
}
-
- public void setLabelBounds(Rectangle baseRect, Rectangle rect,
- String direction) {
+
+ public void setLabelBounds(Rectangle baseRect, Rectangle rect, String direction) {
if (portLabel == null) {
return;
}
Rectangle labelRect = portLabel.getTextBounds().getCopy();
if (Component.OUTPORT_DIRECTION_RIGHT_LITERAL.equals(direction)) {
Point p = rect.getTopRight();
- labelRect.x = baseRect.x + p.x;
- labelRect.y = baseRect.y + p.y - labelRect.height
- + (rect.height / 2);
+ labelRect.x = baseRect.x + p.x + 1;
+ labelRect.y = baseRect.y + p.y - labelRect.height + (rect.height / 2) - 1;
} else if (Component.OUTPORT_DIRECTION_LEFT_LITERAL.equals(direction)) {
Point p = rect.getTopLeft();
- labelRect.x = baseRect.x + p.x - labelRect.width;
- labelRect.y = baseRect.y + p.y - labelRect.height
- + (rect.height / 2);
+ labelRect.x = baseRect.x + p.x - labelRect.width - 1;
+ labelRect.y = baseRect.y + p.y - labelRect.height + (rect.height / 2) - 1;
} else if (Component.OUTPORT_DIRECTION_UP_LITERAL.equals(direction)) {
Point p = rect.getTop();
labelRect.x = baseRect.x + p.x - labelRect.width / 2;
@@ -105,23 +100,20 @@
}
portLabel.setBounds(labelRect);
}
-
+
@Override
protected void createEditPolicies() {
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
- new PortGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new PortGraphicalNodeEditPolicy());
}
@Override
- public ConnectionAnchor getSourceConnectionAnchor(
- ConnectionEditPart connection) {
+ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
LOGGER.trace("getSourceConnectionAnchor: editpart=<{}>", connection);
return new PortAnchor(getFigure());
}
@Override
- public ConnectionAnchor getTargetConnectionAnchor(
- ConnectionEditPart connection) {
+ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
LOGGER.trace("getTargetConnectionAnchor: editpart=<{}>", connection);
return new PortAnchor(getFigure());
}
@@ -137,7 +129,7 @@
LOGGER.trace("getTargetConnectionAnchor: request=<{}>", request);
return new PortAnchor(getFigure());
}
-
+
@Override
public PortFigure getFigure() {
if (invalid) {
@@ -152,15 +144,13 @@
return (PortFigure) super.getFigure();
}
- @SuppressWarnings("unchecked")
@Override
- protected List getModelTargetConnections() {
+ protected List<?> getModelTargetConnections() {
return CompositeFilter.getModelTargetConnections(getModel());
}
- @SuppressWarnings("unchecked")
@Override
- protected List getModelSourceConnections() {
+ protected List<?> getModelSourceConnections() {
return CompositeFilter.getModelSourceConnections(getModel());
}
@@ -178,15 +168,13 @@
refreshVisuals();
}
};
-
+
private boolean invalid = false;
@Override
public void activate() {
super.activate();
-
- SystemEditorPreferenceManager.getInstance().addPropertyChangeListener(
- preferenceChangeListener);
+ SystemEditorPreferenceManager.getInstance().addPropertyChangeListener(preferenceChangeListener);
if (getModel().eContainer() instanceof ComponentSpecification) {
getModel().eAdapters().add(new Adapter());
}
@@ -196,16 +184,14 @@
public void deactivate() {
portLabel.deactivate();
super.deactivate();
-
- SystemEditorPreferenceManager.getInstance()
- .removePropertyChangeListener(preferenceChangeListener);
+ SystemEditorPreferenceManager.getInstance().removePropertyChangeListener(preferenceChangeListener);
}
-
+
// ポートが公開されているかを返す
protected boolean isExported() {
return PortHelper.isExported(getModel());
}
-
+
protected boolean isConnected() {
return PortHelper.isConnected(getModel());
}
@@ -213,20 +199,16 @@
private class Adapter extends AdapterImpl {
@Override
public void notifyChanged(Notification msg) {
- if (ComponentPackage.eINSTANCE.getPort_ConnectorProfiles().equals(
- msg.getFeature())
- && (msg.getEventType() == Notification.ADD || msg
- .getEventType() == Notification.REMOVE)) {
+ if (ComponentPackage.eINSTANCE.getPort_ConnectorProfiles().equals(msg.getFeature())
+ && (msg.getEventType() == Notification.ADD || msg.getEventType() == Notification.REMOVE)) {
if (getModel().eContainer().eContainer() instanceof SystemDiagram) {
- SystemDiagram systemDiagram = (SystemDiagram) getModel()
- .eContainer().eContainer();
+ SystemDiagram systemDiagram = (SystemDiagram) getModel().eContainer().eContainer();
SystemDiagram rootDiagram = systemDiagram.getRootDiagram();
if (rootDiagram.isConnectorProcessing()) {
// void
} else {
rootDiagram.setConnectorProcessing(true);
- AbstractSystemDiagramEditor editor = ComponentUtil
- .findEditor(systemDiagram);
+ AbstractSystemDiagramEditor editor = ComponentUtil.findEditor(systemDiagram);
if (editor != null)
editor.refresh();
}
@@ -251,33 +233,32 @@
// ターゲットのポートのEditPartが存在しない時に走るときがある。
@Override
protected void addSourceConnection(ConnectionEditPart connection, int index) {
-
// ターゲット側の設定も行う
PortConnector connectionModel = (PortConnector) connection.getModel();
PortEditPart targetPart = (PortEditPart) getViewer().getEditPartRegistry().get(connectionModel.getTarget());
- if (targetPart == null) return;
+ if (targetPart == null)
+ return;
targetPart.primAddTargetConnection(connection, index);
- GraphicalEditPart target = (GraphicalEditPart) connection.getTarget();
- if (target != null)
- target.getTargetConnections().remove(connection);
-
- GraphicalEditPart source = (GraphicalEditPart) connection.getSource();
- if (source != null)
- source.getSourceConnections().remove(connection);
+ GraphicalEditPart target = (GraphicalEditPart) connection.getTarget();
+ if (target != null)
+ target.getTargetConnections().remove(connection);
- connection.setSource(null);
+ GraphicalEditPart source = (GraphicalEditPart) connection.getSource();
+ if (source != null)
+ source.getSourceConnections().remove(connection);
+
+ connection.setSource(null);
connection.setTarget(targetPart);
targetPart.fireTargetConnectionAdded(connection, index);
// 元々のソース側の設定を行う
primAddSourceConnection(connection, index);
-
+
connection.setSource(this);
fireSourceConnectionAdded(connection, index);
-
+
connection.activate();
-// System.out.println("addSourceConnection from " + connection.getSource() + " to " + connection.getTarget());
}
@Override
@@ -285,48 +266,48 @@
// ソース側の設定も行う
PortConnector connectionModel = (PortConnector) connection.getModel();
PortEditPart sourcePart = (PortEditPart) getViewer().getEditPartRegistry().get(connectionModel.getSource());
- if (sourcePart == null) return;
+ if (sourcePart == null)
+ return;
sourcePart.primAddSourceConnection(connection, index);
- GraphicalEditPart source = (GraphicalEditPart) connection.getSource();
- if (source != null)
- source.getSourceConnections().remove(connection);
-
- GraphicalEditPart target = (GraphicalEditPart) connection.getTarget();
- if (target != null)
- target.getTargetConnections().remove(connection);
+ GraphicalEditPart source = (GraphicalEditPart) connection.getSource();
+ if (source != null)
+ source.getSourceConnections().remove(connection);
- connection.setTarget(null);
+ GraphicalEditPart target = (GraphicalEditPart) connection.getTarget();
+ if (target != null)
+ target.getTargetConnections().remove(connection);
+
+ connection.setTarget(null);
connection.setSource(sourcePart);
sourcePart.fireSourceConnectionAdded(connection, index);
// 元々のターゲット側の設定を行う
primAddTargetConnection(connection, index);
-
+
connection.setTarget(this);
fireTargetConnectionAdded(connection, index);
-
+
connection.activate();
-// System.out.println("addTargetConnection from " + connection.getSource() + " to " + connection.getTarget());
}
- @SuppressWarnings("unchecked")
@Override
protected void refreshSourceConnections() {
int i;
ConnectionEditPart editPart;
Object model;
- Map modelToEditPart = new HashMap();
- List editParts = getSourceConnections();
+ Map<Object, ConnectionEditPart> modelToEditPart = new HashMap<>();
+ List<?> editParts = getSourceConnections();
- List modelObjects = getModelSourceConnections();
- if (modelObjects == null) modelObjects = new ArrayList();
+ List<?> modelObjects = getModelSourceConnections();
+ if (modelObjects == null)
+ modelObjects = new ArrayList<>();
- List trash = new ArrayList ();
+ List<ConnectionEditPart> trash = new ArrayList<>();
for (i = 0; i < editParts.size(); i++) {
- editPart = (ConnectionEditPart)editParts.get(i);
+ editPart = (ConnectionEditPart) editParts.get(i);
model = editPart.getModel();
if (modelObjects.contains(model)) {
modelToEditPart.put(model, editPart);
@@ -334,39 +315,36 @@
trash.add(editPart);
}
}
-
// Add new EditParts
for (i = 0; i < modelObjects.size(); i++) {
model = modelObjects.get(i);
-
if (!modelToEditPart.containsKey(model)) {
editPart = createOrFindConnection(model);
addSourceConnection(editPart, 0);
}
}
-
- //Remove the remaining EditParts
+ // Remove the remaining EditParts
for (i = 0; i < trash.size(); i++)
- removeSourceConnection((ConnectionEditPart)trash.get(i));
+ removeSourceConnection((ConnectionEditPart) trash.get(i));
}
- @SuppressWarnings("unchecked")
@Override
protected void refreshTargetConnections() {
int i;
ConnectionEditPart editPart;
Object model;
- Map mapModelToEditPart = new HashMap();
- List connections = getTargetConnections();
+ Map<Object, ConnectionEditPart> mapModelToEditPart = new HashMap<>();
+ List<?> connections = getTargetConnections();
- List modelObjects = getModelTargetConnections();
- if (modelObjects == null) modelObjects = new ArrayList();
+ List<?> modelObjects = getModelTargetConnections();
+ if (modelObjects == null)
+ modelObjects = new ArrayList<>();
- List trash = new ArrayList ();
+ List<ConnectionEditPart> trash = new ArrayList<>();
for (i = 0; i < connections.size(); i++) {
- editPart = (ConnectionEditPart)connections.get(i);
+ editPart = (ConnectionEditPart) connections.get(i);
model = editPart.getModel();
if (modelObjects.contains(model)) {
mapModelToEditPart.put(model, editPart);
@@ -374,20 +352,17 @@
trash.add(editPart);
}
}
-
// Add new EditParts
for (i = 0; i < modelObjects.size(); i++) {
model = modelObjects.get(i);
-
if (!mapModelToEditPart.containsKey(model)) {
editPart = createOrFindConnection(model);
addTargetConnection(editPart, 0);
}
}
-
- //Remove the remaining Connection EditParts
+ // Remove the remaining Connection EditParts
for (i = 0; i < trash.size(); i++)
- removeTargetConnection((ConnectionEditPart)trash.get(i));
- }
-
+ removeTargetConnection((ConnectionEditPart) trash.get(i));
+ }
+
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortHelper.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortHelper.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortHelper.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -2,7 +2,12 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.graphics.Color;
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.InPortFigure;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.OutPortFigure;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.PortFigure;
import jp.go.aist.rtm.toolscommon.model.component.Component;
import jp.go.aist.rtm.toolscommon.model.component.Port;
import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
@@ -86,12 +91,28 @@
* 接続可能な場合はtrue
*/
public static void refreshViewPortAsConnectable(PortEditPart port, boolean connectable) {
+ PortFigure figure = port.getFigure();
+ Color colorNoConnected;
+ Color colorConnected;
+ SystemEditorPreferenceManager pref = SystemEditorPreferenceManager.getInstance();
+ if (figure instanceof InPortFigure) {
+ colorNoConnected = PortFigure.S_INPORT.fg;
+ colorConnected = pref.getColor(SystemEditorPreferenceManager.COLOR_DATAPORT_CONNECTED);
+ } else if (figure instanceof OutPortFigure) {
+ colorNoConnected = PortFigure.S_OUTPORT.fg;
+ colorConnected = pref.getColor(SystemEditorPreferenceManager.COLOR_DATAPORT_CONNECTED);
+ } else {
+ colorNoConnected = PortFigure.S_SVCPORT.fg;
+ colorConnected = pref.getColor(SystemEditorPreferenceManager.COLOR_SERVICEPORT_CONNECTED);
+ }
if (connectable) {
- port.getFigure().setLineWidth(2);
- port.getFigure().setScale(1.2, 1.2);
+ figure.setLineWidth(2);
+ figure.setScale(1.2, 1.2);
+ figure.setForegroundColor(colorConnected);
} else {
- port.getFigure().setLineWidth(1);
- port.getFigure().setScale(1.0, 1.0);
+ figure.setLineWidth(1);
+ figure.setScale(1.0, 1.0);
+ figure.setForegroundColor(colorNoConnected);
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -2,34 +2,30 @@
import java.util.Iterator;
-import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart;
-import jp.go.aist.rtm.toolscommon.model.component.Component;
-
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+
/**
* コンポーネントFigureの内部で使用されるレイアウト
* <p>
* コンポーネントFigureのデフォルトサイズ(ポートの数から計算)、方向やポートの位置を計算する
*/
public class ComponentLayout extends XYLayout {
- private static final int MIN_WIDTH = 60;
+ private static final int MIN_WIDTH = 60;
private static final int MIN_HEIGHT = 25;
+ private static final int MIN_Component_INTERBAL = 22;
- private static final int MIN_Component_INTERBAL = 20;
+ private static final Class<?>[] OUTPUT_CLASSES = new Class[] { OutPortFigure.class, ServicePortFigure.class };
- @SuppressWarnings("unchecked")
- private static final Class[] OUTPUT_CLASSES = new Class[] {
- OutPortFigure.class, ServicePortFigure.class };
+ private static final Class<?>[] OUTPUT_180_CLASSES = new Class[] { InPortFigure.class };
- @SuppressWarnings("unchecked")
- private static final Class[] OUTPUT_180_CLASSES = new Class[] { InPortFigure.class };
-
private Component component;
/**
@@ -42,10 +38,9 @@
this.component = component;
}
- @SuppressWarnings("unchecked")
@Override
public void layout(IFigure parent) {
- Iterator children = parent.getChildren().iterator();
+ Iterator<?> children = parent.getChildren().iterator();
IFigure child;
while (children.hasNext()) {
child = (IFigure) children.next();
@@ -63,7 +58,6 @@
|| direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL);
}
- @SuppressWarnings("unchecked")
private Rectangle getLocation(IFigure parent, IFigure child) {
Rectangle bounds = child.getBounds().getCopy();
Point offset = getOrigin(parent);
@@ -71,7 +65,7 @@
Rectangle clientArea = parent.getClientArea();
String direction = getDirection(child.getClass(), component.getOutportDirection());
- Class[] figureClass = null;
+ Class<?>[] figureClass = null;
if (isAssignable(child.getClass(), OUTPUT_180_CLASSES)) {
figureClass = OUTPUT_180_CLASSES;
} else if (isAssignable(child.getClass(), OUTPUT_CLASSES)) {
@@ -80,29 +74,23 @@
// ポートの描画位置へのオフセット 2009.2.2
int portOffset = ComponentEditPart.PORT_SPACE - 2;
- int portNumber = getTargetOccurenceNumber(parent, child,
- figureClass);
+ int portNumber = getTargetOccurenceNumber(parent, child, figureClass);
if (direction.equals(Component.OUTPORT_DIRECTION_LEFT_LITERAL)) {
bounds.x = clientArea.x + portOffset;
- bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE
- + (MIN_HEIGHT / 2) + MIN_Component_INTERBAL
- * (portNumber - 1);
-
- } else if(direction.equals(Component.OUTPORT_DIRECTION_RIGHT_LITERAL)) {
+ bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERBAL * (portNumber - 1);
+ } else if (direction.equals(Component.OUTPORT_DIRECTION_RIGHT_LITERAL)) {
bounds.x = clientArea.x + clientArea.width - portOffset;
- bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE
- + (MIN_HEIGHT / 2) + MIN_Component_INTERBAL
- * (portNumber - 1);
+ bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERBAL * (portNumber - 1);
} else if (direction.equals(Component.OUTPORT_DIRECTION_UP_LITERAL)) {
- bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE
- + (MIN_HEIGHT / 2) + MIN_Component_INTERBAL
- * (portNumber - 1);
+ bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERBAL * (portNumber - 1);
bounds.y = clientArea.y + portOffset;
} else if (direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL)) {
- bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE
- + (MIN_HEIGHT / 2) + MIN_Component_INTERBAL
- * (portNumber - 1);
+ bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERBAL * (portNumber - 1);
bounds.y = clientArea.y + clientArea.height - portOffset;
}
@@ -111,8 +99,7 @@
return bounds;
}
- private String getDirection(Class<? extends IFigure> clazz,
- String outportDirection) {
+ private String getDirection(Class<? extends IFigure> clazz, String outportDirection) {
if (isAssignable(clazz, OUTPUT_CLASSES)) {
return outportDirection;
} else if (isAssignable(clazz, OUTPUT_180_CLASSES)) {
@@ -129,24 +116,20 @@
return Component.OUTPORT_DIRECTION_RIGHT_LITERAL;
}
- @SuppressWarnings("unchecked")
private int getAllOccurenceCount(IFigure parent, Class[] targetClasses) {
int count = 0;
- for (Iterator iter = parent.getChildren().iterator(); iter.hasNext();) {
+ for (Iterator<?> iter = parent.getChildren().iterator(); iter.hasNext();) {
IFigure child = (IFigure) iter.next();
if (isAssignable(child.getClass(), targetClasses)) {
++count;
}
}
-
return count;
}
- @SuppressWarnings("unchecked")
- private int getTargetOccurenceNumber(IFigure parent, IFigure target,
- Class[] targetClasses) {
+ private int getTargetOccurenceNumber(IFigure parent, IFigure target, Class<?>[] targetClasses) {
int count = 0;
- for (Iterator iter = parent.getChildren().iterator(); iter.hasNext();) {
+ for (Iterator<?> iter = parent.getChildren().iterator(); iter.hasNext();) {
IFigure child = (IFigure) iter.next();
if (child == target) {
++count;
@@ -156,33 +139,26 @@
++count;
}
}
-
return count;
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
public Dimension getMinimumSize(IFigure container, int wHint, int hHint) {
- int count = Math.max(
- getAllOccurenceCount(container, OUTPUT_180_CLASSES),
+ int count = Math.max(getAllOccurenceCount(container, OUTPUT_180_CLASSES),
getAllOccurenceCount(container, OUTPUT_CLASSES));
-
- int height = ComponentEditPart.NONE_SPACE * 2 + MIN_HEIGHT
- + MIN_Component_INTERBAL * (count - 1);
+ int height = ComponentEditPart.NONE_SPACE * 2 + MIN_HEIGHT + MIN_Component_INTERBAL * (count - 1);
int width = 111;
-
Dimension result = new Dimension();
-
if (isVerticalDirection()) {
result.height = Math.max(width, MIN_WIDTH);
- result.width = Math.max(height, MIN_HEIGHT);
+ result.width = Math.max(height, MIN_HEIGHT);
} else {
result.height = Math.max(height, MIN_HEIGHT);
- result.width = Math.max(width, MIN_WIDTH);
+ result.width = Math.max(width, MIN_WIDTH);
}
-
return result;
}
@@ -192,24 +168,23 @@
* @param target
* @param classes
*/
- @SuppressWarnings("unchecked")
- private boolean isAssignable(Class target, Class[] classes) {
+ private boolean isAssignable(Class<?> target, Class<?>[] classes) {
boolean result = false;
- for (Class tmp : classes) {
+ for (Class<?> tmp : classes) {
if (tmp.isAssignableFrom(target)) {
result = true;
break;
}
}
-
return result;
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
public Dimension getPreferredSize(IFigure container, int wHint, int hHint) {
return getMinimumSize(container, wHint, hHint);
}
+
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogTest.java 2016-03-17 12:48:00 UTC (rev 591)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/NewCompositeComponentDialogTest.java 2016-03-17 12:49:43 UTC (rev 592)
@@ -32,13 +32,6 @@
assertEquals("def.out", ports.get(1));
}
- public void testGetParam() throws Exception {
- String compositeType = "PeriodicECShared";
- String instanceName = "MyCompositeComponent";
- String exportedPortString = "SequenceOutComponent0.Short,SequenceOutComponent0.ShortSeq,ConsoleIn0.out";
- assertEquals("PeriodicECSharedComposite?instance_name=MyCompositeComponent&exported_ports=SequenceOutComponent0.Short,SequenceOutComponent0.ShortSeq,ConsoleIn0.out"
- , NewCompositeComponentDialogData.getParam(compositeType, instanceName, exportedPortString));
- }
// public void testCreateCompositeComponentSpecification() throws Exception {
// NewCompositeComponentDialog dialog = new NewCompositeComponentDialog(null, true, null, null){
// @Override
More information about the openrtm-commit
mailing list