[openrtm-commit:02604] r735 - in trunk/rtmtools/jp.go.aist.rtm.systemeditor: src/jp/go/aist/rtm/systemeditor/corba 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/views/managercontrolview test/jp/go/aist/rtm/systemeditor test/jp/go/aist/rtm/systemeditor/corba test/jp/go/aist/rtm/systemeditor/ui/dialog
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 5月 7日 (日) 18:27:41 JST
Author: ga
Date: 2017-05-07 18:27:40 +0900 (Sun, 07 May 2017)
New Revision: 735
Added:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/RestoreComponentDialog.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenWithMappingRestoreAction.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/CORBAHelperTest.java
Modified:
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/nl/messages.properties
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialog.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/views/managercontrolview/ManagerControlView.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialogTest.java
Log:
Modified RTC Create Dialog #4033
Modified RTSystem Restoration #4034
Modified: 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 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/corba/CORBAHelper.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -1,12 +1,21 @@
package jp.go.aist.rtm.systemeditor.corba;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_IMPLEMENTATION_ID;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_INSTANCE_NAME;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_MANAGER_NAME;
+
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
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.model.manager.RTCManager;
import jp.go.aist.rtm.toolscommon.synchronizationframework.SynchronizationSupport;
import jp.go.aist.rtm.toolscommon.util.RtsProfileHandler;
@@ -71,8 +80,14 @@
* @return マネージャ
*/
public RTM.Manager findManager(String path) {
+ if (path == null || path.isEmpty()) {
+ return null;
+ }
+ String cid = path;
int index = path.lastIndexOf("/");
- String cid = path.substring(0, index);
+ if (index != -1) {
+ cid = path.substring(0, index);
+ }
return NameServerAccesser.getInstance()
.getManagerFromContextId(cid);
}
@@ -125,6 +140,37 @@
}
/**
+ * CORBA コンポーネントに対するリモートオブジェクトを生成します。(マネージャ指定)
+ *
+ * @param manager
+ * マネージャ
+ * @param comp
+ * CORBA コンポーネント
+ * @param diagram
+ * ダイアグラム
+ * @return リモートオブジェクト
+ * @throws CORBAException
+ */
+ public RTC.RTObject createRTObject(RTCManager manager,
+ CorbaComponent comp, SystemDiagram diagram)
+ throws CORBAException {
+ LOGGER.trace(
+ "createRTObject START manager=<{}> comp=<{}> diagram=<{}>",
+ manager, comp, diagram);
+ if (manager == null) {
+ throw new CORBAException(String.format(
+ "No manager specified: path=<%s>", comp.getPathId()));
+ }
+ String param = buildCreateComponentParam(comp);
+ LOGGER.info("createRTObject: cmd=<{}>", param);
+ Component c = manager.createComponentR(param);
+ if (c instanceof CorbaComponent) {
+ return ((CorbaComponent) c).getCorbaObjectInterface();
+ }
+ return null;
+ }
+
+ /**
* CORBA 複合コンポーネントに対するリモートオブジェクトを生成します。
*
* @param comp
@@ -154,6 +200,40 @@
}
/**
+ * CORBA 複合コンポーネントに対するリモートオブジェクトを生成します。
+ *
+ * @param manager
+ * マネージャ
+ * @param comp
+ * CORBA 複合コンポーネント
+ * @param diagram
+ * ダイアグラム
+ * @return リモートオブジェクト
+ * @throws CORBAException
+ */
+ public RTC.RTObject createCompositeRTObject(RTCManager manager,
+ CorbaComponent comp, SystemDiagram diagram)
+ throws CORBAException {
+ LOGGER.trace(
+ "createCompositeRTObject START manager=<{}> comp=<{}> diagram=<{}>",
+ manager, comp, diagram);
+ if (manager == null) {
+ throw new CORBAException(String.format(
+ "No manager specified: path=<%s>", comp.getPathId()));
+ }
+ String exportedPorts = findConfiguration("exported_ports", comp,
+ diagram);
+ String param = buildCreateCompositeComponentParam(comp,
+ exportedPorts);
+ LOGGER.info("createCompositeRTObject: cmd=<{}>", param);
+ Component c = manager.createComponentR(param);
+ if (c instanceof CorbaComponent) {
+ return ((CorbaComponent) c).getCorbaObjectInterface();
+ }
+ return null;
+ }
+
+ /**
* CORBA 複合コンポーネントのリモートオブジェクトへ、子コンポーネントを割り当てます。<br>
* あらかじめ複合コンポーネント自体のリモートオブジェクトを設定しておくこと
*
@@ -226,10 +306,10 @@
/**
* コンポーネント生成のパラメータを生成します。<br>
- * 次の情報が設定されていること (必須)
+ * 次の情報が設定されていること
* <ul>
- * <li>implementation_id : [プロパティ] コンポーネントの型</li>
- * <li>instance_name : [プロパティ] コンポーネントのインスタンス名</li>
+ * <li>[必須] implementation_id : [プロパティ] コンポーネントの型</li>
+ * <li>[必須] instance_name : [プロパティ] コンポーネントのインスタンス名</li>
* </ul>
*
* @param comp
@@ -237,28 +317,29 @@
* @return コンポーネント生成パラメータ (失敗時はnull)
*/
public String buildCreateComponentParam(CorbaComponent comp) {
- String implementationId = comp.getProperty("implementation_id");
- String instanceName = comp.getProperty("instance_name");
+ String implementationId = comp.getProperty(KEY_IMPLEMENTATION_ID);
+ String instanceName = comp.getProperty(KEY_INSTANCE_NAME);
if (implementationId == null || instanceName == null) {
return null;
}
- StringBuffer ret = new StringBuffer();
- ret.append(implementationId);
- ret.append("?instance_name=").append(instanceName);
- String pg = comp.getProperty("process_group");
- if (pg != null) {
- ret.append("&process_group=").append(pg);
+ String manager = comp.getProperty(KEY_MANAGER_NAME);
+ //
+ CreateComponentParameter param = new CreateComponentParameter(
+ implementationId);
+ param.setInstanceName(instanceName);
+ if (manager != null) {
+ param.setManagerName(manager);
}
- return ret.toString();
+ return param.buildCommand();
}
/**
* 複合コンポーネント生成のパラメータを生成します。<br>
- * 次の情報が設定されていること (必須)
+ * 次の情報が設定されていること
* <ul>
- * <li>compositeType: [属性] 複合コンポーネントタイプ</li>
- * <li>instance_name : [プロパティ] コンポーネントのインスタンス名</li>
- * <li>exportedPorts : [引数] 公開ポート指定</li>
+ * <li>[必須] compositeType : [属性] 複合コンポーネントタイプ</li>
+ * <li>[必須] instance_name : [プロパティ] コンポーネントのインスタンス名</li>
+ * <li>[任意] exportedPorts : [引数] 公開ポート指定</li>
* </ul>
*
* @param comp
@@ -270,17 +351,22 @@
public String buildCreateCompositeComponentParam(CorbaComponent comp,
String exportedPorts) {
String compositeType = comp.getCompositeTypeL();
- String instanceName = comp.getProperty("instance_name");
+ String instanceName = comp.getProperty(KEY_INSTANCE_NAME);
+ if (compositeType == null || instanceName == null) {
+ return null;
+ }
+ String manager = comp.getProperty(KEY_MANAGER_NAME);
//
- StringBuffer ret = new StringBuffer();
- ret.append(buildCreateCompositeComponentParam(compositeType,
- instanceName, exportedPorts));
- //
- String pg = comp.getProperty("process_group");
- if (pg != null) {
- ret.append("&process_group=").append(pg);
+ CreateComponentParameter param = new CreateComponentParameter(
+ compositeType + "Composite");
+ param.setInstanceName(instanceName);
+ if (exportedPorts != null) {
+ param.setExportedPorts(exportedPorts);
}
- return ret.toString();
+ if (manager != null) {
+ param.setManagerName(manager);
+ }
+ return param.buildCommand();
}
/**
@@ -291,22 +377,260 @@
* @param instanceName
* コンポーネントのインスタンス名
* @param exportedPorts
- * 公開ポート指定
+ * 公開ポート指定 [任意]
* @return コンポーネント生成パラメータ (失敗時はnull)
*/
public String buildCreateCompositeComponentParam(String compositeType,
String instanceName, String exportedPorts) {
- if (compositeType == null || instanceName == null
- || exportedPorts == null) {
+ if (compositeType == null || instanceName == null) {
return null;
}
+ //
+ CreateComponentParameter param = new CreateComponentParameter(
+ compositeType + "Composite");
+ param.setInstanceName(instanceName);
+ if (exportedPorts != null) {
+ param.setExportedPorts(exportedPorts);
+ }
+ return param.buildCommand();
+ }
+
+ }
+
+ /**
+ * コンポーネントの生成コマンドのパラメータを表します。
+ */
+ public static class CreateComponentParameter {
+
+ public static final String KEY_IMPLEMENTATION_ID = "implementation_id";
+ public static final String KEY_INSTANCE_NAME = "instance_name";
+ public static final String KEY_EXPORTED_PORTS = "exported_ports";
+ public static final String KEY_MANAGER_NAME = "manager_name";
+ public static final String KEY_LANGUAGE = "language";
+
+ private String implementation_id;
+ private String instance_name;
+ private String exported_ports;
+ private String manager_name;
+ private String language;
+ private Map<String, String> paramMap = new LinkedHashMap<>();
+
+ public CreateComponentParameter(String implementation_id) {
+ this.implementation_id = implementation_id;
+ }
+
+ /**
+ * コンポーネント生成のコマンド列を構築します。
+ */
+ public String buildCommand() {
StringBuffer ret = new StringBuffer();
- ret.append(compositeType).append("Composite");
- ret.append("?instance_name=").append(instanceName);
- ret.append("&exported_ports=").append(exportedPorts);
+ ret.append(this.implementation_id);
+ //
+ List<String> buf = new ArrayList<>();
+ if (getInstanceName() != null) {
+ buf.add(KEY_INSTANCE_NAME + "=" + getInstanceName());
+ }
+ if (getExportedPorts() != null) {
+ buf.add(KEY_EXPORTED_PORTS + "=" + getExportedPorts());
+ }
+ if (getManagerName() != null) {
+ buf.add(KEY_MANAGER_NAME + "=" + getManagerName());
+ }
+ if (getLanguage() != null) {
+ buf.add(KEY_LANGUAGE + "=" + getLanguage());
+ }
+ for (String n : getParamNames()) {
+ buf.add(n + "=" + getParam(n));
+ }
+ //
+ if (!buf.isEmpty()) {
+ ret.append("?");
+ boolean first = true;
+ for (String p : buf) {
+ if (!first) {
+ ret.append("&");
+ }
+ ret.append(p);
+ first = false;
+ }
+ }
return ret.toString();
}
+ /**
+ * インスタンス名を取得します。
+ *
+ * @return
+ */
+ public String getInstanceName() {
+ return this.instance_name;
+ }
+
+ /**
+ * インスタンス名を設定します。
+ *
+ * @param instance_name
+ */
+ public void setInstanceName(String instance_name) {
+ this.instance_name = instance_name;
+ }
+
+ /**
+ * 複合コンポーネントの公開ポート情報を取得します。
+ *
+ * @return
+ */
+ public String getExportedPorts() {
+ return this.exported_ports;
+ }
+
+ /**
+ * 複合コンポーネントの公開ポート情報を設定します。
+ *
+ * @param exported_ports
+ */
+ public void setExportedPorts(String exported_ports) {
+ this.exported_ports = exported_ports;
+ }
+
+ /**
+ * マネージャ名(プロセスグループ)を取得します。
+ *
+ * @return
+ */
+ public String getManagerName() {
+ return this.manager_name;
+ }
+
+ /**
+ * マネージャ名(プロセスグループ)を設定します。
+ *
+ * @param manager_name
+ */
+ public void setManagerName(String manager_name) {
+ this.manager_name = manager_name;
+ }
+
+ /**
+ * 言語を取得します。
+ *
+ * @return
+ */
+ public String getLanguage() {
+ return this.language;
+ }
+
+ /**
+ * 言語を設定します。
+ *
+ * @param language
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * 任意パラメータ群を取得します。<br>
+ * key1=value1&key2=value2... 形式
+ *
+ * @return
+ */
+ public String getParams() {
+ StringBuffer ret = new StringBuffer();
+ for (String name : getParamNames()) {
+ String value = getParam(name);
+ value = (value == null) ? "" : value;
+ if (ret.length() > 0) {
+ ret.append("&");
+ }
+ ret.append(String.format("%s=%s", name, value));
+ }
+ return ret.toString();
+ }
+
+ /**
+ * 任意パラメータ群を設定します。<br>
+ * key1=value1&key2=value2... 形式
+ *
+ * @param params
+ */
+ public void setParams(String params) {
+ String[] pp = (params == null) ? new String[0] : params.split("&");
+ for (String p : pp) {
+ String[] nv = p.split("=");
+ if (nv.length < 2) {
+ continue;
+ }
+ setParam(nv[0], nv[1]);
+ }
+ }
+
+ /**
+ * 名前と値を指定してパラメータを設定します。
+ *
+ * @param name
+ * @param value
+ */
+ public void setParam(String name, String value) {
+ if (value == null) {
+ return;
+ }
+ if (KEY_IMPLEMENTATION_ID.equals(name)) {
+ this.implementation_id = value;
+ } else if (KEY_INSTANCE_NAME.equals(name)) {
+ setInstanceName(value);
+ } else if (KEY_EXPORTED_PORTS.equals(name)) {
+ setExportedPorts(value);
+ } else if (KEY_MANAGER_NAME.equals(name)) {
+ setManagerName(value);
+ } else if (KEY_LANGUAGE.equals(name)) {
+ setLanguage(value);
+ } else {
+ this.paramMap.put(name, value);
+ }
+ }
+
+ /**
+ * 名前を指定してパラメータを取得します。
+ *
+ * @param name
+ * @return
+ */
+ public String getParam(String name) {
+ if (KEY_IMPLEMENTATION_ID.equals(name)) {
+ return this.implementation_id;
+ } else if (KEY_INSTANCE_NAME.equals(name)) {
+ return getInstanceName();
+ } else if (KEY_EXPORTED_PORTS.equals(name)) {
+ return getExportedPorts();
+ } else if (KEY_MANAGER_NAME.equals(name)) {
+ return getManagerName();
+ } else if (KEY_LANGUAGE.equals(name)) {
+ return getLanguage();
+ } else {
+ return this.paramMap.get(name);
+ }
+ }
+
+ /**
+ * 任意パラメータの名前一覧を取得します。
+ *
+ * @return
+ */
+ public Set<String> getParamNames() {
+ return Collections.unmodifiableSet(this.paramMap.keySet());
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "<implementation_id="
+ + this.implementation_id + ", instance_name="
+ + this.instance_name + ", exported_ports="
+ + this.exported_ports + ", manager_name="
+ + this.manager_name + ", language=" + this.language + ", "
+ + this.paramMap + ">";
+ }
+
}
/**
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 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties 2017-05-07 09:27:40 UTC (rev 735)
@@ -93,9 +93,12 @@
NewCompositeComponentDialog.msg.already_exist_name=The component name already exists.
NewCompositeComponentDialog.msg.contain_grouping_fail=The Grouping composite component cannot be included in the composite components other than Grouping.
CreateComponentDialog.2=Type :
-CreateComponentDialog.process_group.title=Process Group :
+CreateComponentDialog.manager_name.title=Manager Name :
+CreateComponentDialog.lang.title=Language :
CreateComponentDialog.3=Parameter :
CreateComponentDialog.6=Invalid parameter format.
+CreateComponentDialog.add_button=Add
+CreateComponentDialog.del_button=Delete
ServiceConnectorCreaterDialog.1=Please enter Port Profile.
ServiceConnectorCreaterDialog.2=Error
ServiceConnectorCreaterDialog.3=No corresponding port interface.
@@ -172,6 +175,8 @@
OpenAndCreateRestoreAction.1=Open and Create Restore...
OpenAction.0=Open...
OpenAction.1=Open...
+OpenWithMappingRestoreAction.0=Open with Mapping Restore...
+OpenWithMappingRestoreAction.1=Open with Mapping Restore...
MoveComponentAction.8=Move
ChangeComponentDirectionAction.2=Change Direction
DeleteCommand.0=Confirm
@@ -283,7 +288,7 @@
ManagerControlView.11=Load
ManagerControlView.13=Unload
ManagerControlView.delete_component=Delete Component
-ManagerControlView.process_group=process group
+ManagerControlView.manager_name=manager name
CompositeComponentView.label.component_name=component:
CompositeComponentView.label.component_type=type:
CompositeComponentView.column.component.label=component
@@ -340,3 +345,7 @@
IconPreferenceDialog.filter.name=Icon image
IconPreferencePage.error.import=Icon profile import failure.
IconPreferencePage.error.export=Icon profile export failure.
+RestoreComponentDialog.head_message=Please map target for components.
+RestoreComponentDialog.msg_no_ep_name=No endpoint name
+RestoreComponentDialog.msg_ep_unreach=Endpoint unreachable
+RestoreComponentDialog.msg_need_create=Creation necessary
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialog.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialog.java 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialog.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -1,67 +1,133 @@
package jp.go.aist.rtm.systemeditor.ui.dialog;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_IMPLEMENTATION_ID;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_LANGUAGE;
+
+import java.util.ArrayList;
import java.util.List;
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.toolscommon.util.SDOUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Table;
/**
* マネージャビューからコンポーネントを作成するダイアログ
- *
*/
public class CreateComponentDialog extends TitleAreaDialog {
private static final String LABEL_TYPE_TITLE = Messages
.getString("CreateComponentDialog.2");
- private static final String LABEL_PROCESS_GROUP_TITLE = Messages
- .getString("CreateComponentDialog.process_group.title");
+ private static final String LABEL_MANAGER_NAME_TITLE = Messages
+ .getString("CreateComponentDialog.manager_name.title");
+ private static final String LABEL_LANGUAGE_TITLE = Messages
+ .getString("CreateComponentDialog.lang.title");
private static final String LABEL_PARAMETER_TITLE = Messages
.getString("CreateComponentDialog.3");
private static final String ERR_INVALID_PARAM = Messages
.getString("CreateComponentDialog.6");
- public static final String CONFIG_NAME = "CONFIG_NAME";
- public static final String CONFIG_VALUE = "CONFIG_VALUE";
+ private static final String LABEL_BUTTON_ADD = Messages
+ .getString("CreateComponentDialog.add_button");
+ private static final String LABEL_BUTTON_DEL = Messages
+ .getString("CreateComponentDialog.del_button");
- public static final int BUTTON_WIDTH = 70;
+ private static final int BUTTON_WIDTH = 70;
- private String parameter;
- private Text paramText;
+ private static final String COL_NAME = "Name";
+ private static final String COL_VALUE = "Value";
+
private Combo typeCombo;
- private Combo processGroupCombo;
- private List<String> typeList;
- private List<String> processGroupList;
+ private Combo managerNameCombo;
+ private Combo langCombo;
+ private TableViewer parameterViewer;
+ private Button parameterAddButton;
+ private Button parameterDeleteButton;
+ private List<Module> moduleList = new ArrayList<>();
+ private List<String> managerNameList = new ArrayList<>();
+ private List<ParameterParam> parameterList = new ArrayList<>();
+ private ParameterParam selectedParam;
+
+ private CORBAHelper.CreateComponentParameter parameter = null;
+
+ /** モジュール情報 */
+ static class Module {
+ String type;
+ String lang;
+ }
+
public CreateComponentDialog(Shell parentShell) {
super(parentShell);
setHelpAvailable(false);
setShellStyle(getShellStyle() | SWT.CENTER | SWT.RESIZE);
}
- public void setTypeList(List<String> typeList) {
- this.typeList = typeList;
+ /**
+ * 対象マネージャがコンポーネント生成可能なモジュール情報の一覧を設定します。
+ *
+ * @param moduleProfileList
+ */
+ public void setModuleProfileList(List<RTM.ModuleProfile> moduleProfileList) {
+ this.moduleList.clear();
+ for (RTM.ModuleProfile prof : moduleProfileList) {
+ String type = SDOUtil.findValueAsString(KEY_IMPLEMENTATION_ID,
+ prof.properties);
+ String lang = SDOUtil.findValueAsString(KEY_LANGUAGE,
+ prof.properties);
+ Module mod = new Module();
+ mod.type = type;
+ mod.lang = lang;
+ this.moduleList.add(mod);
+ }
}
- public void setProcessGroupList(List<String> processGroupList) {
- this.processGroupList = processGroupList;
+ /**
+ * 対象マネージャに属するマネージャ名(プロセスグループ)の一覧を設定します。
+ *
+ * @param managerNameList
+ */
+ public void setManagerNameList(List<String> managerNameList) {
+ this.managerNameList.clear();
+ this.managerNameList.addAll(managerNameList);
}
+ /**
+ * コンポーネント生成のコマンド列を取得します。
+ */
public String getParameter() {
- return this.parameter;
+ return (this.parameter == null) ? null : this.parameter.buildCommand();
}
@Override
@@ -83,56 +149,181 @@
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
this.typeCombo.setLayoutData(gd);
- for (String type : this.typeList) {
- this.typeCombo.add(type);
+ for (Module mod : this.moduleList) {
+ if (mod.type != null) {
+ this.typeCombo.add(mod.type);
+ }
}
this.typeCombo.select(0);
- this.parameter = this.typeCombo.getText();
this.typeCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ String type = typeCombo.getText();
+ Module mod = findModuleByType(type);
+ if (mod != null) {
+ langCombo.removeAll();
+ langCombo.add(mod.lang);
+ }
+ langCombo.select(0);
+ //
notifyModified();
}
});
- Label pgLabel = new Label(mainComposite, SWT.NONE);
- pgLabel.setText(LABEL_PROCESS_GROUP_TITLE);
- this.processGroupCombo = new Combo(mainComposite, SWT.NONE);
+ Label mnLabel = new Label(mainComposite, SWT.NONE);
+ mnLabel.setText(LABEL_MANAGER_NAME_TITLE);
+ this.managerNameCombo = new Combo(mainComposite, SWT.NONE);
gd = new GridData(GridData.GRAB_HORIZONTAL);
gd.minimumWidth = 180;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
- this.processGroupCombo.setLayoutData(gd);
- for (String pg : this.processGroupList) {
- this.processGroupCombo.add(pg);
+ this.managerNameCombo.setLayoutData(gd);
+ for (String mn : this.managerNameList) {
+ this.managerNameCombo.add(mn);
}
- this.processGroupCombo.select(0);
- this.processGroupCombo.addModifyListener(new ModifyListener() {
+ this.managerNameCombo.select(0);
+ this.managerNameCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
notifyModified();
}
});
- Label paramLabel = new Label(mainComposite, SWT.NONE);
- paramLabel.setText(LABEL_PARAMETER_TITLE);
- this.paramText = new Text(mainComposite, SWT.MULTI | SWT.BORDER
- | SWT.V_SCROLL | SWT.WRAP);
- gd = new GridData();
+ Label langLabel = new Label(mainComposite, SWT.NONE);
+ langLabel.setText(LABEL_LANGUAGE_TITLE);
+ this.langCombo = new Combo(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.GRAB_HORIZONTAL);
+ gd.minimumWidth = 180;
gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.heightHint = 240;
- this.paramText.setLayoutData(gd);
- this.paramText.setText("");
- this.paramText.addModifyListener(new ModifyListener() {
+ this.langCombo.setLayoutData(gd);
+ Module mod = findModuleByType(this.typeCombo.getText());
+ if (mod != null) {
+ this.langCombo.add(mod.lang);
+ }
+ this.langCombo.select(0);
+ this.langCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
notifyModified();
}
});
+ Group parameterGroup = new Group(mainComposite, SWT.SHADOW_IN);
+ parameterGroup.setText(LABEL_PARAMETER_TITLE);
+ gl = new GridLayout(2, false);
+ parameterGroup.setLayout(gl);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ parameterGroup.setLayoutData(gd);
+ this.parameterViewer = createParameterTableViewer(parameterGroup);
+ this.parameterViewer.setInput(this.parameterList);
+
return mainComposite;
}
+ private TableViewer createParameterTableViewer(Composite parent) {
+ TableViewer viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 120;
+ gd.widthHint = 120;
+ gd.grabExcessHorizontalSpace = true;
+
+ Table table = viewer.getTable();
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ //
+ TableViewerColumn colName = new TableViewerColumn(viewer, SWT.NONE);
+ colName.getColumn().setText(COL_NAME);
+ colName.getColumn().setWidth(160);
+ colName.getColumn().setResizable(true);
+ colName.getColumn().setMoveable(false);
+ colName.setEditingSupport(new ParameterCellModifier(viewer, 0));
+
+ TableViewerColumn colValue = new TableViewerColumn(viewer, SWT.NONE);
+ colValue.getColumn().setText(COL_VALUE);
+ colValue.getColumn().setWidth(160);
+ colValue.getColumn().setResizable(true);
+ colValue.getColumn().setMoveable(false);
+ colValue.setEditingSupport(new ParameterCellModifier(viewer, 1));
+
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new ParameterLabelProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ StructuredSelection selection = (StructuredSelection) event
+ .getSelection();
+ selectedParam = (ParameterParam) selection.getFirstElement();
+ parameterDeleteButton.setEnabled(true);
+ }
+ });
+ //
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.marginRight = 0;
+ buttonComposite.setLayout(gl);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ gd.verticalAlignment = SWT.BEGINNING;
+ gd.horizontalAlignment = SWT.BEGINNING;
+ buttonComposite.setLayoutData(gd);
+
+ createParameterAddButton(buttonComposite);
+ createParameterDeleteButton(buttonComposite);
+
+ return viewer;
+ }
+
+ private void createParameterAddButton(Composite buttonComposite) {
+ this.parameterAddButton = new Button(buttonComposite, SWT.PUSH);
+ this.parameterAddButton.setText(LABEL_BUTTON_ADD);
+ this.parameterAddButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ParameterParam newParam = new ParameterParam("Name", "Value");
+ parameterList.add(newParam);
+ parameterViewer.refresh();
+ notifyModified();
+ }
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = BUTTON_WIDTH;
+ this.parameterAddButton.setLayoutData(gd);
+ }
+
+ private void createParameterDeleteButton(Composite buttonComposite) {
+ this.parameterDeleteButton = new Button(buttonComposite, SWT.PUSH);
+ this.parameterDeleteButton.setText(LABEL_BUTTON_DEL);
+ this.parameterDeleteButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (selectedParam == null) {
+ return;
+ }
+ parameterList.remove(selectedParam);
+ parameterViewer.refresh();
+ parameterDeleteButton.setEnabled(false);
+ notifyModified();
+ }
+ });
+ this.parameterDeleteButton.setEnabled(false);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = BUTTON_WIDTH;
+ this.parameterDeleteButton.setLayoutData(gd);
+ }
+
+ private String buildParameter() {
+ StringBuilder builder = new StringBuilder();
+ for (int index = 0; index < parameterList.size(); index++) {
+ if (0 < index) {
+ builder.append("&");
+ }
+ ParameterParam target = parameterList.get(index);
+ builder.append(target.getName()).append("=")
+ .append(target.getValue());
+ }
+ return builder.toString();
+ }
+
@Override
protected Control createButtonBar(Composite parent) {
Control composite = super.createButtonBar(parent);
@@ -140,26 +331,27 @@
return composite;
}
- /**
- * 変更を通知します。
- */
- private void notifyModified() {
- this.parameter = this.typeCombo.getText();
- StringBuffer sb = new StringBuffer();
- String pg = this.processGroupCombo.getText();
- if (pg != null && !pg.isEmpty()) {
- sb.append("process_group=" + pg);
+ /** コンポーネント型名からモジュール情報を検索します。 */
+ private Module findModuleByType(String type) {
+ if (type == null || type.isEmpty()) {
+ return null;
}
- String pm = this.paramText.getText();
- if (pm != null && !pm.isEmpty()) {
- if (sb.length() > 0) {
- sb.append("&");
+ for (Module mod : this.moduleList) {
+ if (type.equals(mod.type)) {
+ return mod;
}
- sb.append(pm);
}
- if (sb.length() > 0) {
- this.parameter += "?" + sb.toString();
- }
+ return null;
+ }
+
+ /** 変更を通知します。 */
+ private void notifyModified() {
+ this.parameter = new CORBAHelper.CreateComponentParameter(
+ this.typeCombo.getText());
+ this.parameter.setManagerName(this.managerNameCombo.getText());
+ this.parameter.setLanguage(this.langCombo.getText());
+ this.parameter.setParams(buildParameter());
+ //
if (!validateInput()) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
} else {
@@ -167,22 +359,135 @@
}
}
+ /** 入力内容を検証します。 */
private boolean validateInput() {
- if (this.parameter == null || this.parameter.length() == 0) {
+ String type = this.typeCombo.getText();
+ if (type == null || type.isEmpty()) {
return false;
}
String errmsg = ERR_INVALID_PARAM;
- String p[] = this.parameter.split("\\?");
- if (p.length > 0 && p[0].indexOf("&") != -1) {
+ if (type.indexOf("&") != -1) {
// component_nameに&が入っている
this.setMessage(errmsg, IMessageProvider.WARNING);
return false;
}
- if (p.length == 1) {
- // コンポーネント名のみ指定
+ return true;
+ }
+
+ private class ParameterParam {
+
+ private String name;
+ private String value;
+
+ public ParameterParam(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ }
+
+ private class ParameterLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof ParameterParam == false) {
+ return null;
+ }
+ ParameterParam targetParam = (ParameterParam) element;
+ String result = null;
+ if (columnIndex == 0) {
+ result = targetParam.getName();
+ } else if (columnIndex == 1) {
+ result = targetParam.getValue();
+ }
+ return result;
+ }
+
+ }
+
+ private class ParameterCellModifier extends EditingSupport {
+
+ private CellEditor editor;
+ private int column;
+
+ public ParameterCellModifier(ColumnViewer viewer, int column) {
+ super(viewer);
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ this.column = column;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
return true;
}
- return true;
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if (element instanceof ParameterParam == false) {
+ return null;
+ }
+ ParameterParam targetParam = (ParameterParam) element;
+
+ switch (this.column) {
+ case 0:
+ return targetParam.getName();
+ case 1:
+ return targetParam.getValue();
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ if (element instanceof ParameterParam == false) {
+ return;
+ }
+ ParameterParam targetParam = (ParameterParam) element;
+
+ switch (this.column) {
+ case 0:
+ targetParam.setName((String) value);
+ break;
+ case 1:
+ targetParam.setValue((String) value);
+ break;
+ default:
+ break;
+ }
+
+ getViewer().update(element, null);
+ notifyModified();
+ }
+
}
}
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/RestoreComponentDialog.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/RestoreComponentDialog.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/RestoreComponentDialog.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -0,0 +1,687 @@
+package jp.go.aist.rtm.systemeditor.ui.dialog;
+
+import static jp.go.aist.rtm.systemeditor.ui.util.UIUtil.COLOR_WHITE;
+import static jp.go.aist.rtm.systemeditor.ui.util.UIUtil.getColor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
+import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.manager.ManagerFactory;
+import jp.go.aist.rtm.toolscommon.model.manager.RTCManager;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * RTシステム復元設定を行うダイアログ
+ */
+public class RestoreComponentDialog extends TitleAreaDialog {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(RestoreComponentDialog.class);
+
+ static final String LABEL_MAPPING_MESSAGE = Messages
+ .getString("RestoreComponentDialog.head_message");
+
+ static final String MSG_STATUS_NO_EP_NAME = Messages
+ .getString("RestoreComponentDialog.msg_no_ep_name");
+ static final String MSG_STATUS_EP_UNREACHABLE = Messages
+ .getString("RestoreComponentDialog.msg_ep_unreach");
+ static final String MSG_STATUS_NEED_CREATE = Messages
+ .getString("RestoreComponentDialog.msg_need_create");
+
+ private static final String LABEL_COMPONENT = "component:";
+ private static final String LABEL_MANAGER = "manager:";
+ private static final String LABEL_TARGET = "target:";
+ private static final String LABEL_STATUS = "status:";
+
+ private static final String COL_COMPONENT = "component";
+ private static final String COL_TYPE = "type";
+ private static final String COL_MANAGER = "manager";
+ private static final String COL_ENDPOINT = "endpoint";
+ private static final String COL_TARGET = "target";
+ private static final String COL_STATUS = "status";
+
+ static final String PROP_IMPLEMENTATION_ID = "implementation_id";
+ static final String PROP_CORBA_ENDPOINTS = "corba.endpoints";
+ static final String PROP_MANAGER_NAME = "manager_name";
+
+ private TableViewer tableViewer;
+ private Table table;
+
+ private Label componentNameLabel;
+ private Label typeNameLabel;
+ private Text managerNameText;
+ private Text endpointNameText;
+ private Combo targetCombo;
+ private Label statusLabel;
+
+ private List<TargetInfo> targetList = new ArrayList<>();
+ private TargetInfo selectedTarget;
+
+ private EndpointCache endpoints = new EndpointCache();
+
+ public RestoreComponentDialog(Shell parentShell) {
+ super(parentShell);
+ setHelpAvailable(false);
+ setShellStyle(getShellStyle() | SWT.CENTER | SWT.RESIZE);
+ }
+
+ /**
+ * マッピング対象となる CORBAコンポーネントの一覧を設定します。
+ */
+ public void setCorbaComponents(List<CorbaComponent> list) {
+ if (list == null) {
+ return;
+ }
+ for (CorbaComponent comp : list) {
+ TargetInfo target = new TargetInfo(comp);
+ target.verifyStatus();
+ this.targetList.add(target);
+ String epName = target.getEndpointName();
+ if (epName == null) {
+ continue;
+ }
+ Endpoint ep = this.endpoints.get(epName);
+ RTC.RTObject rtc = ep.getComponent(target.getName());
+ if (rtc != null) {
+ target.setTarget(rtc);
+ }
+ }
+ }
+
+ /**
+ * マッピングの設定結果一覧を取得します。
+ */
+ public List<MappingResult> getMappingResultList() {
+ List<MappingResult> ret = new ArrayList<>();
+ for (TargetInfo target : this.targetList) {
+ ret.add(target.getMappingResult());
+ }
+ return ret;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = (Composite) super.createDialogArea(parent);
+
+ GridLayout gl;
+ GridData gd;
+
+ Composite mainComposite = new Composite(dialogArea, SWT.NONE);
+ gl = new GridLayout(1, false);
+ gd = new GridData(GridData.FILL_BOTH);
+ mainComposite.setLayout(gl);
+ mainComposite.setLayoutData(gd);
+ mainComposite.setFont(parent.getFont());
+
+ Composite detailComposite = new Composite(dialogArea, SWT.NONE);
+ gl = new GridLayout(1, false);
+ gd = new GridData(GridData.FILL_BOTH);
+ detailComposite.setLayout(gl);
+ detailComposite.setLayoutData(gd);
+ detailComposite.setFont(parent.getFont());
+
+ {
+ Label label = new Label(mainComposite, SWT.NONE);
+ label.setText(LABEL_MAPPING_MESSAGE);
+
+ this.tableViewer = new TableViewer(mainComposite,
+ SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
+ this.tableViewer.setContentProvider(new ArrayContentProvider());
+ this.tableViewer
+ .setColumnProperties(new String[] { COL_COMPONENT,
+ COL_TYPE, COL_MANAGER, COL_ENDPOINT, COL_TARGET,
+ COL_STATUS });
+ this.tableViewer.setLabelProvider(new TargetLabelProvider());
+ this.tableViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ StructuredSelection selection = (StructuredSelection) event
+ .getSelection();
+ LOGGER.trace(
+ "Restore: tableViewer.selectionChanged: selectoin=<{}>",
+ selection);
+ selectedTarget = (TargetInfo) selection
+ .getFirstElement();
+ refreshData();
+ }
+ });
+
+ this.table = this.tableViewer.getTable();
+ gl = new GridLayout(1, false);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.heightHint = 250;
+ this.table.setLayout(gl);
+ this.table.setLayoutData(gd);
+ this.table.setLinesVisible(true);
+ this.table.setHeaderVisible(true);
+
+ TableColumn col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_COMPONENT);
+ col.setWidth(150);
+ col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_TYPE);
+ col.setWidth(150);
+ col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_MANAGER);
+ col.setWidth(100);
+ col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_ENDPOINT);
+ col.setWidth(120);
+ col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_TARGET);
+ col.setWidth(150);
+ col = new TableColumn(this.table, SWT.NONE);
+ col.setText(COL_STATUS);
+ col.setWidth(200);
+ }
+ {
+ gl = new GridLayout();
+ gl.numColumns = 3;
+ detailComposite.setLayout(gl);
+
+ Label compLabel = new Label(detailComposite, SWT.NONE);
+ compLabel.setText(LABEL_COMPONENT);
+
+ this.componentNameLabel = new Label(detailComposite, SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.componentNameLabel.setLayoutData(gd);
+ this.componentNameLabel.setBackground(getColor(COLOR_WHITE));
+
+ this.typeNameLabel = new Label(detailComposite, SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.typeNameLabel.setLayoutData(gd);
+ this.typeNameLabel.setBackground(getColor(COLOR_WHITE));
+
+ Label mgrLabel = new Label(detailComposite, SWT.NONE);
+ mgrLabel.setText(LABEL_MANAGER);
+
+ this.managerNameText = new Text(detailComposite, SWT.SINGLE
+ | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.managerNameText.setLayoutData(gd);
+ this.managerNameText.addFocusListener(new FocusListener() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ LOGGER.trace("Restore: managerName.focusLost: event=<{}>",
+ e);
+ notifyModified();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ }
+ });
+
+ this.endpointNameText = new Text(detailComposite, SWT.SINGLE
+ | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.endpointNameText.setLayoutData(gd);
+ this.endpointNameText.addFocusListener(new FocusListener() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ LOGGER.trace("Restore: endpointName.focusLost: event=<{}>",
+ e);
+ String epName = endpointNameText.getText();
+ Endpoint ep = endpoints.get(epName);
+ targetCombo.removeAll();
+ for (String comp : ep.getComponentNames()) {
+ targetCombo.add(comp);
+ }
+ notifyModified();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ }
+ });
+
+ Label tgtLabel = new Label(detailComposite, SWT.NONE);
+ tgtLabel.setText(LABEL_TARGET);
+
+ this.targetCombo = new Combo(detailComposite, SWT.DROP_DOWN);
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.targetCombo.setLayoutData(gd);
+
+ this.targetCombo.select(0);
+ this.targetCombo.addFocusListener(new FocusListener() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ LOGGER.trace("Restore: targetCombo.focusLost: event=<{}>",
+ e);
+ notifyModified();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ }
+ });
+
+ Label stLabel = new Label(detailComposite, SWT.NONE);
+ stLabel.setText(LABEL_STATUS);
+
+ this.statusLabel = new Label(detailComposite, SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ this.statusLabel.setLayoutData(gd);
+ this.statusLabel.setBackground(getColor(COLOR_WHITE));
+ }
+
+ buildData();
+
+ return dialogArea;
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control composite = super.createButtonBar(parent);
+ return composite;
+ }
+
+ /** テーブルの表示内容を構築 */
+ void buildData() {
+ this.tableViewer.setInput(this.targetList);
+ }
+
+ /** 詳細項目の変更を通知します */
+ void notifyModified() {
+ if (this.selectedTarget == null) {
+ return;
+ }
+
+ String managerName = this.managerNameText.getText();
+ String epName = this.endpointNameText.getText();
+ String targetName = this.targetCombo.getText();
+ Endpoint ep = this.endpoints.get(epName);
+ RTC.RTObject rtc = ep.getComponent(targetName);
+
+ this.selectedTarget.setManagerName(managerName);
+ this.selectedTarget.setEndpointName(epName);
+ this.selectedTarget.setTargetName(targetName);
+ this.selectedTarget.setEndpoint(ep);
+ this.selectedTarget.setTarget(rtc);
+
+ this.selectedTarget.verifyStatus();
+ if (this.selectedTarget.getStatus() != null) {
+ this.statusLabel.setText(this.selectedTarget.getStatus());
+ }
+
+ this.tableViewer.refresh();
+ }
+
+ /** テーブル上の行選択を詳細項目へ反映します */
+ void refreshData() {
+ if (this.selectedTarget == null) {
+ this.componentNameLabel.setText("");
+ this.typeNameLabel.setText("");
+ this.managerNameText.setText("");
+ this.endpointNameText.setText("");
+ this.targetCombo.select(0);
+ this.statusLabel.setText("");
+ } else {
+ if (this.selectedTarget.getName() != null) {
+ this.componentNameLabel.setText(this.selectedTarget.getName());
+ }
+ if (this.selectedTarget.getType() != null) {
+ this.typeNameLabel.setText(this.selectedTarget.getType());
+ }
+ if (this.selectedTarget.getManagerName() != null) {
+ this.managerNameText.setText(this.selectedTarget
+ .getManagerName());
+ }
+ if (this.selectedTarget.getEndpointName() != null) {
+ this.endpointNameText.setText(this.selectedTarget
+ .getEndpointName());
+ }
+ if (this.selectedTarget.getTargetName() != null) {
+ this.targetCombo.setText(this.selectedTarget.getTargetName());
+ }
+ if (this.selectedTarget.getStatus() != null) {
+ this.statusLabel.setText(this.selectedTarget.getStatus());
+ }
+ }
+ }
+
+ //
+
+ /**
+ * リストア対象情報
+ */
+ public static class TargetInfo {
+
+ private String name;
+ private String type;
+ private String managerName;
+ private String endpointName;
+ private String targetName;
+ private String status;
+
+ private Endpoint endpoint;
+ private CorbaComponent component;
+
+ public TargetInfo(CorbaComponent component) {
+ this.component = component;
+ this.name = component.getInstanceNameL();
+ this.type = component.getProperty(PROP_IMPLEMENTATION_ID);
+ this.managerName = component.getProperty(PROP_MANAGER_NAME);
+ this.endpointName = component.getProperty(PROP_CORBA_ENDPOINTS);
+ //
+ if (this.endpointName == null) {
+ // エンドポイントのプロパティ設定がない場合は、パスURIから取得(既存互換)
+ String path = component.getPathId();
+ if (path != null && !path.isEmpty()) {
+ path = path.substring(0, path.indexOf("/"));
+ this.endpointName = path;
+ }
+ }
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public String getManagerName() {
+ return this.managerName;
+ }
+
+ public void setManagerName(String managerName) {
+ this.managerName = managerName;
+ }
+
+ public String getEndpointName() {
+ return this.endpointName;
+ }
+
+ public void setEndpointName(String endpointName) {
+ this.endpointName = endpointName;
+ }
+
+ public void setEndpoint(Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public String getTargetName() {
+ return this.targetName;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public void setTarget(RTC.RTObject rtc) {
+ if (this.component != null) {
+ this.component.setCorbaObject(rtc);
+ }
+ }
+
+ public MappingResult getMappingResult() {
+ if (this.component != null) {
+ this.component.setProperty(PROP_CORBA_ENDPOINTS,
+ this.endpointName);
+ this.component.setProperty(PROP_MANAGER_NAME, this.managerName);
+ }
+ RTCManager manager = null;
+ if (this.endpoint != null) {
+ manager = this.endpoint.getManager();
+ }
+ MappingResult ret = new MappingResult(this.component, manager);
+ return ret;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void verifyStatus() {
+ this.status = "";
+ if (this.endpointName == null || this.endpointName.isEmpty()) {
+ // エンドポイント名が未設定
+ this.status = MSG_STATUS_NO_EP_NAME;
+ return;
+ }
+ if (this.endpoint == null
+ || EndpointCache.NULL_ENDPOINT.equals(this.endpoint)) {
+ // エンドポイントへアクセス不可
+ this.status = MSG_STATUS_EP_UNREACHABLE;
+ return;
+ }
+ if (this.targetName == null || this.targetName.isEmpty()) {
+ // コンポーネント生成が必要
+ this.status = MSG_STATUS_NEED_CREATE;
+ return;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "<" + this.name + "|"
+ + this.type + "|" + this.managerName + "|"
+ + this.endpointName + "|" + this.targetName + "|"
+ + this.status + ">";
+ }
+
+ }
+
+ /**
+ * コンポーネントのマッピング結果を表します。
+ */
+ public static class MappingResult {
+
+ private CorbaComponent component;
+ private RTCManager manager;
+
+ public MappingResult(CorbaComponent component, RTCManager manager) {
+ this.component = component;
+ this.manager = manager;
+ }
+
+ public CorbaComponent getComponent() {
+ return this.component;
+ }
+
+ public RTCManager getManager() {
+ return this.manager;
+ }
+
+ public boolean isMapped() {
+ return (this.component != null && this.component
+ .getCorbaObjectInterface() != null);
+ }
+
+ public boolean hasManager() {
+ return (this.manager != null);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "<" + this.component + "|"
+ + this.manager + ">";
+ }
+
+ }
+
+ /**
+ * エンドポイントの検索・キャッシュを表します。
+ */
+ public static class EndpointCache {
+
+ /** エンドポイントの NullObject */
+ public static Endpoint NULL_ENDPOINT = new Endpoint(null);
+
+ private Map<String, Endpoint> cache = new HashMap<>();
+
+ public Endpoint get(String endpoint) {
+ Endpoint ret = this.cache.get(endpoint);
+ if (ret != null) {
+ return ret;
+ }
+ RTM.Manager remote = null;
+ if (endpoint != null) {
+ try {
+ remote = CORBAHelper.ns().findManager(endpoint);
+ } catch (RuntimeException e) {
+ remote = null;
+ }
+ }
+ if (remote == null) {
+ this.cache.put(endpoint, NULL_ENDPOINT);
+ return NULL_ENDPOINT;
+ }
+ RTCManager manager = ManagerFactory.eINSTANCE.createRTCManager();
+ manager.setCorbaObject(remote);
+ ret = new Endpoint(manager);
+ this.cache.put(endpoint, ret);
+ return ret;
+ }
+
+ }
+
+ /**
+ * エンドポイント(マネージャ)を表します。
+ */
+ public static class Endpoint {
+
+ private RTCManager remote;
+ private List<String> managers = null;
+ private List<String> components = null;
+ private Map<String, RTC.RTObject> objects = null;
+
+ Endpoint(RTCManager remote) {
+ this.remote = remote;
+ }
+
+ public RTCManager getManager() {
+ return this.remote;
+ }
+
+ /**
+ * エンドポイントに属する起動中のコンポーネント名一覧を取得します。
+ */
+ public List<String> getComponentNames() {
+ if (this.components != null) {
+ return this.components;
+ }
+ this.components = new ArrayList<>();
+ this.objects = new HashMap<>();
+ if (this.remote == null) {
+ return this.components;
+ }
+ for (RTC.RTObject rtc : this.remote.getComponentsR()) {
+ RTC.ComponentProfile prof = rtc.get_component_profile();
+ this.components.add(prof.instance_name);
+ this.objects.put(prof.instance_name, rtc);
+ }
+ return this.components;
+ }
+
+ /**
+ * コンポーネント名に対する CORBAオブジェクトを取得します。
+ */
+ public RTC.RTObject getComponent(String name) {
+ if (this.objects != null) {
+ return this.objects.get(name);
+ }
+ return null;
+ }
+
+ /**
+ * エンドポイントのマネージャに属するスレーブマネージャ名一覧を取得します。
+ */
+ public List<String> getManagerNames() {
+ if (this.managers != null) {
+ return this.managers;
+ }
+ this.managers = new ArrayList<>();
+ if (this.remote == null) {
+ return this.managers;
+ }
+ this.remote.getSlaveManagersR();
+ for (String name : this.remote.getSlaveManagerNames()) {
+ this.managers.add(name);
+ }
+ return this.managers;
+ }
+
+ }
+
+ public class TargetLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ TargetInfo entry = (TargetInfo) element;
+ if (columnIndex == 0) {
+ return entry.getName();
+ } else if (columnIndex == 1) {
+ return entry.getType();
+ } else if (columnIndex == 2) {
+ return entry.getManagerName();
+ } else if (columnIndex == 3) {
+ return entry.getEndpointName();
+ } else if (columnIndex == 4) {
+ return entry.getTargetName();
+ } else if (columnIndex == 5) {
+ return entry.getStatus();
+ }
+ return "";
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/RestoreComponentDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramContextMenuProvider.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -7,6 +7,7 @@
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.OpenWithMappingRestoreAction;
/**
* システムダイアグラムのContextMenuProviderクラス
@@ -24,6 +25,7 @@
appendAction(menuManager, OpenAndRestoreAction.ID, "save");
appendAction(menuManager, OpenAndQuickRestoreAction.ID, "save");
appendAction(menuManager, OpenAndCreateRestoreAction.ID, "save");
+ appendAction(menuManager, OpenWithMappingRestoreAction.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 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/SystemDiagramEditor.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -6,22 +6,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.gef.ContextMenuProvider;
-import org.eclipse.gef.GraphicalViewer;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.FileEditorInput;
-import org.openrtp.namespaces.rts.version02.RtsProfileExt;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
import jp.go.aist.rtm.systemeditor.extension.LoadProfileExtension;
import jp.go.aist.rtm.systemeditor.factory.ProfileLoader;
import jp.go.aist.rtm.systemeditor.factory.Rehabilitation;
@@ -30,15 +15,35 @@
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.dialog.RestoreComponentDialog;
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.OpenWithMappingRestoreAction;
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.CorbaComponent;
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;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+import org.openrtp.namespaces.rts.version02.RtsProfileExt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* SystemDiagramEditorクラス
*/
@@ -57,6 +62,7 @@
addAction(new OpenAndRestoreAction(this));
addAction(new OpenAndQuickRestoreAction(this));
addAction(new OpenAndCreateRestoreAction(this));
+ addAction(new OpenWithMappingRestoreAction(this));
}
@SuppressWarnings("unchecked")
@@ -96,13 +102,21 @@
protected IEditorInput load(IEditorInput input, final IEditorSite site,
final RestoreOption restore) throws PartInitException {
-
- IEditorInput targetInput = getTargetInput(input
- , Messages.getString("SystemDiagramEditor.10"));
- if (targetInput instanceof FileEditorInput) {
+ IEditorInput targetInput = getTargetInput(input,
+ Messages.getString("SystemDiagramEditor.10"));
+
+ if (getSystemDiagram() != null) {
+ getSystemDiagram().setSynchronizeInterval(0);
+ }
+
+ if (targetInput instanceof FileEditorInput) {
// RTSプロファイルをファイルからロードする
- doLoad(site, restore, (FileEditorInput)targetInput);
+ if (restore.doMapping()) {
+ doLoadWithMapping(site, (FileEditorInput) targetInput);
+ } else {
+ doLoad(site, restore, (FileEditorInput) targetInput);
+ }
}
// システムダイアグラムの同期スレッド開始
@@ -114,25 +128,24 @@
SystemEditorPreferenceManager.SYNC_SYSTEMEDITOR_INTERVAL));
postLoad();
-
+
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();
- if (getSystemDiagram() != null) {
- getSystemDiagram().setSynchronizeInterval(0);
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(site.getShell());
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(
+ site.getShell());
IRunnableWithProgress runable = new IRunnableWithProgress() {
@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$
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(
+ Messages.getString("SystemDiagramEditor.3"), 100);
+ monitor.subTask(Messages.getString("SystemDiagramEditor.4"));
try {
RtsProfileHandler handler = new RtsProfileHandler();
@@ -146,12 +159,14 @@
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;
}
}
@@ -160,18 +175,22 @@
// 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, restore.doCreate());
+ Rehabilitation.rehabilitation(diagram,
+ restore.doCreate());
// 読み込み時に明示的に状態の同期を実行
- List<Component> eComps = new ArrayList<>(diagram.getComponents());
+ List<Component> eComps = new ArrayList<>(
+ diagram.getComponents());
diagram.getComponents().clear();
for (Component c : eComps) {
c.synchronizeManually();
@@ -185,26 +204,30 @@
// 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,
+ throw new InvocationTargetException(
+ e,
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$
+ monitor.subTask(Messages
+ .getString("SystemDiagramEditor.7")); //$NON-NLS-1$
try {
RtsProfileHandler handler = new RtsProfileHandler();
handler.restoreConnection(getSystemDiagram());
@@ -213,7 +236,8 @@
doReplace(getSystemDiagram(), site);
} catch (Exception e) {
LOGGER.error("Fail to replace diagram", e);
- throw new InvocationTargetException(e, Messages.getString("SystemDiagramEditor.8")); //$NON-NLS-1$
+ throw new InvocationTargetException(e,
+ Messages.getString("SystemDiagramEditor.8")); //$NON-NLS-1$
}
}
@@ -222,10 +246,97 @@
};
dialog.run(false, false, runable);
} catch (Exception e) {
- throw new PartInitException(Messages.getString("SystemDiagramEditor.9"), e); //$NON-NLS-1$
+ throw new PartInitException(
+ Messages.getString("SystemDiagramEditor.9"), e); //$NON-NLS-1$
}
}
+ private void doLoadWithMapping(final IEditorSite site,
+ FileEditorInput editorInput) throws PartInitException {
+ try {
+ final String strPath = editorInput.getPath().toOSString();
+
+ try {
+ RtsProfileHandler handler = new RtsProfileHandler();
+ RtsProfileExt profile = handler.load(strPath);
+
+ // プロファイル読込
+ SystemDiagram diagram = handler.load(profile,
+ SystemDiagramKind.ONLINE_LITERAL);
+
+ // CORBAコンポーネント抽出
+ List<CorbaComponent> corbaComponents = new ArrayList<>();
+ for (Component c : diagram.getRegisteredComponents()) {
+ if (c instanceof CorbaComponent) {
+ corbaComponents.add((CorbaComponent) c);
+ }
+ }
+
+ // マッピング設定ダイアログを開始
+ RestoreComponentDialog dialog = new RestoreComponentDialog(
+ getSite().getShell());
+ dialog.setCorbaComponents(corbaComponents);
+ if (dialog.open() != IDialogConstants.OK_ID) {
+ return;
+ }
+
+ // マッピング結果を元にコンポーネント生成
+ for (RestoreComponentDialog.MappingResult mapping : dialog
+ .getMappingResultList()) {
+ if (mapping.isMapped()) {
+ continue;
+ }
+ if (!mapping.hasManager()) {
+ throw new Exception(
+ String.format(
+ "No manager, it can not create component: comp=<%s>",
+ mapping));
+ }
+ CorbaComponent comp = mapping.getComponent();
+ RTC.RTObject rtobj = null;
+ if (comp.isCompositeComponent()) {
+ rtobj = CORBAHelper.factory().createCompositeRTObject(
+ mapping.getManager(), comp, diagram);
+ } else {
+ rtobj = CORBAHelper.factory().createRTObject(
+ mapping.getManager(), comp, diagram);
+ }
+ if (rtobj == null) {
+ throw new Exception(String.format(
+ "Fail to create rtobject: comp=<%s>", mapping));
+ }
+ comp.setCorbaObject(rtobj);
+ }
+
+ // 同期サポート割当
+ SystemEditorWrapperFactory.getInstance()
+ .getSynchronizationManager()
+ .assignSynchonizationSupportToDiagram(diagram);
+
+ // 読み込み時に明示的に状態の同期を実行
+ List<Component> eComps = new ArrayList<>(
+ diagram.getComponents());
+ diagram.getComponents().clear();
+ for (Component c : eComps) {
+ c.synchronizeManually();
+ diagram.addComponent(c);
+ }
+
+ handler.restoreCompositeComponentPort(diagram);
+
+ setSystemDiagram(diagram);
+
+ } catch (Exception e) {
+ throw new InvocationTargetException(e,
+ Messages.getString("SystemDiagramEditor.6") + "\r\n"
+ + e.getMessage());
+ }
+ } catch (Exception e) {
+ throw new PartInitException(
+ Messages.getString("SystemDiagramEditor.9"), e);
+ }
+ }
+
/**
* ロード時の復元を行います。
*/
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenWithMappingRestoreAction.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenWithMappingRestoreAction.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenWithMappingRestoreAction.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -0,0 +1,38 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.action;
+
+import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.systemeditor.ui.editor.AbstractSystemDiagramEditor;
+
+import org.eclipse.gef.ui.actions.EditorPartAction;
+
+/**
+ * RTSプロファイルを読み込み、コンポーネントの割当・生成方法を対話的に指定するアクション
+ */
+public class OpenWithMappingRestoreAction extends EditorPartAction {
+
+ public static final String ID = OpenWithMappingRestoreAction.class
+ .getName();
+
+ public OpenWithMappingRestoreAction(AbstractSystemDiagramEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ protected void init() {
+ setId(ID);
+ setText(Messages.getString("OpenWithMappingRestoreAction.0"));
+ setToolTipText(Messages.getString("OpenWithMappingRestoreAction.1"));
+ }
+
+ @Override
+ protected boolean calculateEnabled() {
+ return true;
+ }
+
+ @Override
+ public void run() {
+ ((AbstractSystemDiagramEditor) getEditorPart())
+ .open(RestoreOption.MAPPING);
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/OpenWithMappingRestoreAction.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 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/action/RestoreOption.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -5,20 +5,27 @@
*/
public enum RestoreOption {
- NONE(), NORMAL(false, true, false), QUICK(true, true, false), CREATE(false, true, true);
+ NONE(), //
+ NORMAL(false, true, false, false), //
+ QUICK(true, true, false, false), //
+ CREATE(false, true, true, false), //
+ MAPPING(false, false, false, true);
private final boolean doQuick;
private final boolean doRelace;
private final boolean doCreate;
+ private final boolean doMapping;
RestoreOption() {
- this(true, false, false);
+ this(true, false, false, false);
}
- RestoreOption(boolean doQuick, boolean doReplace, boolean doCreate) {
+ RestoreOption(boolean doQuick, boolean doReplace, boolean doCreate,
+ boolean doMapping) {
this.doQuick = doQuick;
this.doRelace = doReplace;
this.doCreate = doCreate;
+ this.doMapping = doMapping;
}
public boolean doQuick() {
@@ -33,4 +40,8 @@
return this.doCreate;
}
+ public boolean doMapping() {
+ return this.doMapping;
+ }
+
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/managercontrolview/ManagerControlView.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/managercontrolview/ManagerControlView.java 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/managercontrolview/ManagerControlView.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -47,7 +47,6 @@
/**
* マネージャ管理ビュー
- *
*/
public class ManagerControlView extends ViewPart {
@@ -81,7 +80,7 @@
private static final String LABEL_COMPONENT_COLUMN = Messages
.getString("ManagerControlView.5");
private static final String LABEL_PROCESS_GROUP_COLUMN = Messages
- .getString("ManagerControlView.process_group");
+ .getString("ManagerControlView.manager_name");
private static final String LABEL_URL_TEXT = Messages
.getString("ManagerControlView.10");
@@ -219,8 +218,9 @@
}
CreateComponentDialog dialog = new CreateComponentDialog(
getSite().getShell());
- dialog.setTypeList(targetManager.getFactoryProfileTypeNamesR());
- dialog.setProcessGroupList(targetManager.getSlaveManagerNames());
+ dialog.setModuleProfileList(targetManager
+ .getFactoryModuleProfilesR());
+ dialog.setManagerNameList(targetManager.getSlaveManagerNames());
if (dialog.open() == IDialogConstants.OK_ID) {
String cmd = dialog.getParameter();
LOGGER.info("create command: <{}>", cmd);
@@ -498,10 +498,10 @@
for (RTC.ComponentProfile prof : this.targetManager
.getComponentProfiles()) {
String name = prof.instance_name;
- String pg = SDOUtil.findValueAsString("process_group",
+ String mn = SDOUtil.findValueAsString("manager_name",
prof.properties);
- pg = (pg == null) ? "" : pg;
- this.moduleList.add(new String[] { name, pg });
+ mn = (mn == null) ? "" : mn;
+ this.moduleList.add(new String[] { name, mn });
}
this.modulesTableViewer.setInput(this.moduleList);
}
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/CORBAHelperTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/CORBAHelperTest.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/CORBAHelperTest.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -0,0 +1,249 @@
+package jp.go.aist.rtm.systemeditor.corba;
+
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_EXPORTED_PORTS;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_IMPLEMENTATION_ID;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_INSTANCE_NAME;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_LANGUAGE;
+import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_MANAGER_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.impl.CorbaComponentImpl;
+
+import org.junit.Test;
+
+public class CORBAHelperTest {
+
+ /**
+ * コンポーネント生成のパラメータ作成
+ */
+ @Test
+ public void testFactoryBuildCreateComponentParam() {
+ {
+ CorbaComponent comp = new CorbaComponentMock();
+ String act = CORBAHelper.factory().buildCreateComponentParam(comp);
+ assertEquals(null, act);
+ //
+ comp.setProperty(KEY_IMPLEMENTATION_ID, "Type1");
+ act = CORBAHelper.factory().buildCreateComponentParam(comp);
+ assertEquals(null, act);
+ //
+ comp.setProperty(KEY_INSTANCE_NAME, "type1");
+ act = CORBAHelper.factory().buildCreateComponentParam(comp);
+ assertEquals("Type1?instance_name=type1", act);
+ }
+ {
+ CorbaComponent comp = new CorbaComponentMock();
+ comp.setProperty(KEY_IMPLEMENTATION_ID, "Type1");
+ comp.setProperty(KEY_INSTANCE_NAME, "type1");
+ comp.setProperty(KEY_MANAGER_NAME, "pg1");
+ String act = CORBAHelper.factory().buildCreateComponentParam(comp);
+ assertEquals("Type1?instance_name=type1&manager_name=pg1", act);
+ }
+ }
+
+ /**
+ * 複合コンポーネント生成のパラメータ作成1
+ */
+ @Test
+ public void testFactoryBuildCreateCompositeComponentParam1() {
+ {
+ CorbaComponent comp = new CorbaComponentMock();
+ String act = CORBAHelper.factory()
+ .buildCreateCompositeComponentParam(comp, null);
+ assertEquals(null, act);
+ //
+ comp = new CorbaComponentMock();
+ comp.setCategoryL("composite.ECShared");
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ comp, null);
+ assertEquals(null, act);
+ //
+ comp.setProperty(KEY_INSTANCE_NAME, "type1");
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ comp, null);
+ assertEquals("ECSharedComposite?instance_name=type1", act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ comp, "");
+ assertEquals(
+ "ECSharedComposite?instance_name=type1&exported_ports=",
+ act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ comp, "type1.out");
+ assertEquals(
+ "ECSharedComposite?instance_name=type1&exported_ports=type1.out",
+ act);
+ }
+ {
+ CorbaComponent comp = new CorbaComponentMock();
+ comp.setCategoryL("composite.ECShared");
+ comp.setProperty(KEY_INSTANCE_NAME, "type1");
+ comp.setProperty(KEY_MANAGER_NAME, "pg1");
+ String act = CORBAHelper.factory()
+ .buildCreateCompositeComponentParam(comp, "type1.out");
+ assertEquals(
+ "ECSharedComposite?instance_name=type1&exported_ports=type1.out&manager_name=pg1",
+ act);
+ }
+ }
+
+ /**
+ * 複合コンポーネント生成のパラメータ作成2
+ */
+ @Test
+ public void testFactoryBuildCreateCompositeComponentParam2() {
+ {
+ String act = CORBAHelper.factory()
+ .buildCreateCompositeComponentParam(null, null, null);
+ assertEquals(null, act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ "ECShared", null, null);
+ assertEquals(null, act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ "ECShared", "type1", null);
+ assertEquals("ECSharedComposite?instance_name=type1", act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ "ECShared", "type1", "");
+ assertEquals(
+ "ECSharedComposite?instance_name=type1&exported_ports=",
+ act);
+ //
+ act = CORBAHelper.factory().buildCreateCompositeComponentParam(
+ "ECShared", "type1", "type1.out");
+ assertEquals(
+ "ECSharedComposite?instance_name=type1&exported_ports=type1.out",
+ act);
+ }
+ }
+
+ /**
+ * コンポーネント生成パラメータ : 基本パラメータ
+ */
+ @Test
+ public void testCreateComponentParameter() {
+ CreateComponentParameter param = new CreateComponentParameter("Type2");
+ assertEquals("Type2", param.getParam(KEY_IMPLEMENTATION_ID));
+ assertEquals("Type2", param.buildCommand());
+ param.setParam(KEY_IMPLEMENTATION_ID, "Type1");
+ assertEquals("Type1", param.getParam(KEY_IMPLEMENTATION_ID));
+ assertEquals("Type1", param.buildCommand());
+
+ param.setInstanceName("type2");
+ assertEquals("type2", param.getInstanceName());
+ assertEquals("type2", param.getParam(KEY_INSTANCE_NAME));
+ assertEquals("Type1?instance_name=type2", param.buildCommand());
+ param.setParam(KEY_INSTANCE_NAME, "type1");
+ assertEquals("type1", param.getInstanceName());
+ assertEquals("type1", param.getParam(KEY_INSTANCE_NAME));
+ assertEquals("Type1?instance_name=type1", param.buildCommand());
+
+ param.setManagerName("pg2");
+ assertEquals("pg2", param.getManagerName());
+ assertEquals("pg2", param.getParam(KEY_MANAGER_NAME));
+ assertEquals("Type1?instance_name=type1&manager_name=pg2",
+ param.buildCommand());
+ param.setParam(KEY_MANAGER_NAME, "pg1");
+ assertEquals("pg1", param.getManagerName());
+ assertEquals("pg1", param.getParam(KEY_MANAGER_NAME));
+ assertEquals("Type1?instance_name=type1&manager_name=pg1",
+ param.buildCommand());
+
+ param.setLanguage("Java");
+ assertEquals("Java", param.getLanguage());
+ assertEquals("Java", param.getParam(KEY_LANGUAGE));
+ assertEquals(
+ "Type1?instance_name=type1&manager_name=pg1&language=Java",
+ param.buildCommand());
+ param.setParam(KEY_LANGUAGE, "C++");
+ assertEquals("C++", param.getLanguage());
+ assertEquals("C++", param.getParam(KEY_LANGUAGE));
+ assertEquals("Type1?instance_name=type1&manager_name=pg1&language=C++",
+ param.buildCommand());
+
+ param.setExportedPorts("type1.out");
+ assertEquals("type1.out", param.getExportedPorts());
+ assertEquals("type1.out", param.getParam(KEY_EXPORTED_PORTS));
+ assertEquals(
+ "Type1?instance_name=type1&exported_ports=type1.out&manager_name=pg1&language=C++",
+ param.buildCommand());
+ param.setParam(KEY_EXPORTED_PORTS, "type1.out,type1.in");
+ assertEquals("type1.out,type1.in", param.getExportedPorts());
+ assertEquals("type1.out,type1.in", param.getParam(KEY_EXPORTED_PORTS));
+ assertEquals(
+ "Type1?instance_name=type1&exported_ports=type1.out,type1.in&manager_name=pg1&language=C++",
+ param.buildCommand());
+ assertEquals(
+ "CreateComponentParameter<implementation_id=Type1, instance_name=type1, exported_ports=type1.out,type1.in, manager_name=pg1, language=C++, {}>",
+ param.toString());
+ }
+
+ /**
+ * コンポーネント生成パラメータ : 任意パラメータ
+ */
+ @Test
+ public void testCreateComponentParameterOtherParams() {
+ CreateComponentParameter param = new CreateComponentParameter("Type1");
+ param.setInstanceName("type1");
+ assertEquals("Type1?instance_name=type1", param.buildCommand());
+
+ param.setParam("name1", "value2");
+ assertEquals("value2", param.getParam("name1"));
+ assertEquals("Type1?instance_name=type1&name1=value2",
+ param.buildCommand());
+ param.setParam("name1", "value1");
+ assertEquals("value1", param.getParam("name1"));
+ assertEquals("Type1?instance_name=type1&name1=value1",
+ param.buildCommand());
+
+ param.setParam("name2", "value2");
+ assertEquals("value2", param.getParam("name2"));
+ assertEquals("Type1?instance_name=type1&name1=value1&name2=value2",
+ param.buildCommand());
+
+ param.setParams("name2=valueA&nameB=valueB");
+ assertEquals("valueA", param.getParam("name2"));
+ assertEquals("valueB", param.getParam("nameB"));
+ assertEquals("name1=value1&name2=valueA&nameB=valueB",
+ param.getParams());
+ assertEquals(
+ "Type1?instance_name=type1&name1=value1&name2=valueA&nameB=valueB",
+ param.buildCommand());
+ assertFalse(param.getParamNames().contains("instance_name"));
+ assertTrue(param.getParamNames().contains("name1"));
+ assertTrue(param.getParamNames().contains("name2"));
+ assertTrue(param.getParamNames().contains("nameB"));
+ assertEquals(
+ "CreateComponentParameter<implementation_id=Type1, instance_name=type1, exported_ports=null, manager_name=null, language=null, {name1=value1, name2=valueA, nameB=valueB}>",
+ param.toString());
+ }
+
+ //
+
+ static class CorbaComponentMock extends CorbaComponentImpl {
+
+ private Map<String, String> props = new HashMap<>();
+
+ @Override
+ public void setProperty(String key, String value) {
+ this.props.put(key, value);
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return this.props.get(key);
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/corba/CORBAHelperTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialogTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialogTest.java 2017-05-07 09:26:45 UTC (rev 734)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialogTest.java 2017-05-07 09:27:40 UTC (rev 735)
@@ -20,7 +20,7 @@
shell.open();
EList typeList = setupTypeList();
CreateComponentDialog dialog = new CreateComponentDialog(shell);
- dialog.setTypeList(typeList);
+// dialog.setTypeList(typeList);
dialog.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
openrtm-commit メーリングリストの案内