[openrtm-commit:02641] r739 - in trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor: nl ui/dialog ui/views/managercontrolview

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 6月 18日 (日) 12:22:50 JST


Author: ga
Date: 2017-06-18 12:22:50 +0900 (Sun, 18 Jun 2017)
New Revision: 739

Added:
   trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ManagerConfigurationDialog.java
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/ui/dialog/CreateComponentDialog.java
   trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/managercontrolview/ManagerControlView.java
Log:
Modified Manager View #4122

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-06-18 03:22:25 UTC (rev 738)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/nl/messages.properties	2017-06-18 03:22:50 UTC (rev 739)
@@ -99,6 +99,7 @@
 CreateComponentDialog.6=Invalid parameter format.
 CreateComponentDialog.add_button=Add
 CreateComponentDialog.del_button=Delete
+CreateComponentDialog.apply_button=Apply
 ServiceConnectorCreaterDialog.1=Please enter Port Profile.
 ServiceConnectorCreaterDialog.2=Error
 ServiceConnectorCreaterDialog.3=No corresponding port interface.
@@ -277,18 +278,15 @@
 ConfigurationCondition.23=Format error of hash key [key]
 ManagerControlView.0=Loadable Modules
 ManagerControlView.1=module
-ManagerControlView.2=Loaded Modules
-ManagerControlView.4=Active Components
+ManagerControlView.2=RTC Instances
+ManagerControlView.4=Managers
 ManagerControlView.5=component
 ManagerControlView.6=Create
-ManagerControlView.7=Fork
+ManagerControlView.7=Configure
 ManagerControlView.restart=Restart
 ManagerControlView.8=Shutdown
-ManagerControlView.10=URL : 
-ManagerControlView.11=Load
-ManagerControlView.13=Unload
-ManagerControlView.delete_component=Delete Component
 ManagerControlView.manager_name=manager name
+ManagerControlView.manager_language=manager language
 CompositeComponentView.label.component_name=component: 
 CompositeComponentView.label.component_type=type: 
 CompositeComponentView.column.component.label=component

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-06-18 03:22:25 UTC (rev 738)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/CreateComponentDialog.java	2017-06-18 03:22:50 UTC (rev 739)
@@ -4,6 +4,7 @@
 import static jp.go.aist.rtm.systemeditor.corba.CORBAHelper.CreateComponentParameter.KEY_LANGUAGE;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import jp.go.aist.rtm.systemeditor.corba.CORBAHelper;
@@ -16,6 +17,7 @@
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
 import org.eclipse.jface.viewers.EditingSupport;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ITableLabelProvider;
@@ -26,11 +28,14 @@
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
 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.events.SelectionListener;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -42,10 +47,14 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 
+import _SDOPackage.NameValue;
+
 /**
  * マネージャビューからコンポーネントを作成するダイアログ
  */
 public class CreateComponentDialog extends TitleAreaDialog {
+	private static final int PARAMETER_KEY = 0;
+	private static final int PARAMETER_VALUE = 1;
 
 	private static final String LABEL_TYPE_TITLE = Messages
 			.getString("CreateComponentDialog.2");
@@ -79,13 +88,19 @@
 	private List<String> managerNameList = new ArrayList<>();
 	private List<ParameterParam> parameterList = new ArrayList<>();
 	private ParameterParam selectedParam;
+	private String initManager;
 
 	private CORBAHelper.CreateComponentParameter parameter = null;
+	
+	private ParameterCellModifier keyModifier;
+	private String[] defaultKeyList = {"instance_name", "conf.__widget__.", "conf._constraints__."};
+	private String[] currentKeyList = {};
 
 	/** モジュール情報 */
 	static class Module {
 		String type;
 		String lang;
+		List<String> keyList = new ArrayList<String>();
 	}
 
 	public CreateComponentDialog(Shell parentShell) {
@@ -109,6 +124,9 @@
 			Module mod = new Module();
 			mod.type = type;
 			mod.lang = lang;
+			for(NameValue p : prof.properties) {
+				mod.keyList.add(p.name);
+			}
 			this.moduleList.add(mod);
 		}
 	}
@@ -124,6 +142,15 @@
 	}
 
 	/**
+	 * 画面表示時に表示するマネージャ名(プロセスグループ)を設定します。
+	 * 
+	 * @param target
+	 */
+	public void setInitManager(String target) {
+		this.initManager = target;
+	}
+	
+	/**
 	 * コンポーネント生成のコマンド列を取得します。
 	 */
 	public String getParameter() {
@@ -130,6 +157,10 @@
 		return (this.parameter == null) ? null : this.parameter.buildCommand();
 	}
 
+	protected Point getInitialSize() {
+		return new Point(500, 500);
+	}
+	
 	@Override
 	protected Control createDialogArea(Composite parent) {
 		Composite mainComposite = new Composite(
@@ -162,6 +193,7 @@
 				if (mod != null) {
 					langCombo.removeAll();
 					langCombo.add(mod.lang);
+					setKeyList(mod);
 				}
 				langCombo.select(0);
 				//
@@ -168,6 +200,26 @@
 				notifyModified();
 			}
 		});
+		this.typeCombo.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int selected = typeCombo.getSelectionIndex();
+				if(selected < 0) return;
+				Module mod = moduleList.get(selected);
+				
+				if (mod != null) {
+					langCombo.removeAll();
+					langCombo.add(mod.lang);
+					setKeyList(mod);
+				}
+				langCombo.select(0);
+				//
+				notifyModified();
+			}
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+		});
 
 		Label mnLabel = new Label(mainComposite, SWT.NONE);
 		mnLabel.setText(LABEL_MANAGER_NAME_TITLE);
@@ -180,7 +232,11 @@
 		for (String mn : this.managerNameList) {
 			this.managerNameCombo.add(mn);
 		}
-		this.managerNameCombo.select(0);
+		if(initManager==null) {
+			this.managerNameCombo.select(0);
+		} else {
+			this.managerNameCombo.setText(initManager);
+		}
 		this.managerNameCombo.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				notifyModified();
@@ -215,10 +271,23 @@
 		parameterGroup.setLayoutData(gd);
 		this.parameterViewer = createParameterTableViewer(parameterGroup);
 		this.parameterViewer.setInput(this.parameterList);
+		if(0<moduleList.size()) {
+			setKeyList(moduleList.get(0));
+		}
 
 		return mainComposite;
 	}
 
+	private void setKeyList(Module target) {
+		List<String> keyList = new ArrayList<String>();
+		keyList.addAll(Arrays.asList(defaultKeyList));
+		if(target!=null) {
+			keyList.addAll(target.keyList);
+		}
+		currentKeyList = (String[])keyList.toArray(new String[keyList.size()]);
+		keyModifier.updateKeyList();
+	}
+	
 	private TableViewer createParameterTableViewer(Composite parent) {
 		TableViewer viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
 				| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
@@ -237,7 +306,8 @@
 		colName.getColumn().setWidth(160);
 		colName.getColumn().setResizable(true);
 		colName.getColumn().setMoveable(false);
-		colName.setEditingSupport(new ParameterCellModifier(viewer, 0));
+		keyModifier = new ParameterCellModifier(viewer, PARAMETER_KEY);
+		colName.setEditingSupport(keyModifier);
 
 		TableViewerColumn colValue = new TableViewerColumn(viewer, SWT.NONE);
 		colValue.getColumn().setText(COL_VALUE);
@@ -244,7 +314,7 @@
 		colValue.getColumn().setWidth(160);
 		colValue.getColumn().setResizable(true);
 		colValue.getColumn().setMoveable(false);
-		colValue.setEditingSupport(new ParameterCellModifier(viewer, 1));
+		colValue.setEditingSupport(new ParameterCellModifier(viewer, PARAMETER_VALUE));
 
 		viewer.setContentProvider(new ArrayContentProvider());
 		viewer.setLabelProvider(new ParameterLabelProvider());
@@ -279,7 +349,13 @@
 		this.parameterAddButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				ParameterParam newParam = new ParameterParam("Name", "Value");
+				ParameterParam newParam = null;
+				if( defaultKeyList.length > 0 ) {
+					newParam = new ParameterParam(defaultKeyList[0], "Value");
+				} else {
+					newParam = new ParameterParam("Name", "Value");
+				}
+				
 				parameterList.add(newParam);
 				parameterViewer.refresh();
 				notifyModified();
@@ -432,9 +508,21 @@
 		private CellEditor editor;
 		private int column;
 
+		public void updateKeyList() {
+			if(editor instanceof LocalComboBoxCellEditor) {
+				((LocalComboBoxCellEditor) editor).setItems(currentKeyList);
+			}
+		}
+
 		public ParameterCellModifier(ColumnViewer viewer, int column) {
 			super(viewer);
-			editor = new TextCellEditor(((TableViewer) viewer).getTable());
+			switch (column) {
+			case PARAMETER_KEY:
+				editor = new LocalComboBoxCellEditor(((TableViewer) viewer).getTable(), currentKeyList, SWT.DROP_DOWN);
+				break;
+			default:
+				editor = new TextCellEditor(((TableViewer) viewer).getTable());
+			}
 			this.column = column;
 		}
 
@@ -456,9 +544,10 @@
 			ParameterParam targetParam = (ParameterParam) element;
 
 			switch (this.column) {
-			case 0:
-				return targetParam.getName();
-			case 1:
+			case PARAMETER_KEY:
+				int index = updateDefaultKeyList(targetParam.getName());
+				return new Integer(index);
+			case PARAMETER_VALUE:
 				return targetParam.getValue();
 			default:
 				break;
@@ -474,10 +563,20 @@
 			ParameterParam targetParam = (ParameterParam) element;
 
 			switch (this.column) {
-			case 0:
-				targetParam.setName((String) value);
+			case PARAMETER_KEY:
+				if( value instanceof Integer ) {
+					targetParam.setName(currentKeyList[((Integer) value).intValue()]);
+					if(currentKeyList.length > ((Integer) value).intValue()) {
+						targetParam.setName(
+								currentKeyList[((Integer) value).intValue()]);
+					}
+				}else{
+					// 手入力された場合
+					updateDefaultKeyList((String)value);
+					targetParam.setName((String)value);
+				}
 				break;
-			case 1:
+			case PARAMETER_VALUE:
 				targetParam.setValue((String) value);
 				break;
 			default:
@@ -487,7 +586,54 @@
 			getViewer().update(element, null);
 			notifyModified();
 		}
+		
+		private int searchIndex(String[] sources, String target) {
+			for(int intIdx=0;intIdx<sources.length;intIdx++) {
+				if( target.equals(sources[intIdx]) )
+					return intIdx;
+			}
+			return sources.length;
+		}
+		
+		private int updateDefaultKeyList(String newValue){
+			int index = searchIndex(currentKeyList, newValue);
+			if( index == currentKeyList.length ){
+				// その値がプルダウン選択肢にない場合、選択肢にそれを追加する
+				String[] newDefaultTypeList = new String[currentKeyList.length+1];
+				for( int i=0; i<currentKeyList.length; i++ ){
+					newDefaultTypeList[i] = currentKeyList[i];
+				}
+				newDefaultTypeList[currentKeyList.length] = newValue;
+				
+				currentKeyList = newDefaultTypeList;
+				
+				((CCombo)this.editor.getControl()).setItems(currentKeyList);
+			}
+			return index;
+		}
+	}
 
+	// 選択肢以外の値が入力されている場合に対応するためのComboBoxCellEditor
+	private class LocalComboBoxCellEditor extends ComboBoxCellEditor {
+		private CCombo comboBox;
+
+		public LocalComboBoxCellEditor(Composite parent, String[] items, int style) {
+			super(parent, items, style);
+		}
+
+		@Override
+		protected Control createControl(Composite parent) {
+			comboBox = (CCombo) super.createControl(parent);
+			return comboBox;
+		}
+
+		@Override
+		protected Object doGetValue() {
+			Object value = super.doGetValue();
+			if (value.equals(Integer.valueOf(-1))) { // 選択肢以外が入力された場合
+				return comboBox.getText();
+			}
+			return value;
+		}
 	}
-
 }

Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ManagerConfigurationDialog.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ManagerConfigurationDialog.java	                        (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ManagerConfigurationDialog.java	2017-06-18 03:22:50 UTC (rev 739)
@@ -0,0 +1,400 @@
+package jp.go.aist.rtm.systemeditor.ui.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jp.go.aist.rtm.systemeditor.nl.Messages;
+import jp.go.aist.rtm.toolscommon.model.component.NameValue;
+import jp.go.aist.rtm.toolscommon.model.manager.RTCManager;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.resource.ColorRegistry;
+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.ITableColorProvider;
+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.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * マネージャのコンフィギュレーションを設定するダイアログ
+ */
+public class ManagerConfigurationDialog extends TitleAreaDialog {
+	private static final int PARAMETER_KEY = 0;
+	private static final int PARAMETER_VALUE = 1;
+
+	private static final String MODIFY_COLOR = "MODIFY_COLOR";
+	private static final String WHITE_COLOR = "WHITE_COLOR";
+	
+	private static final String LABEL_BUTTON_ADD = Messages
+			.getString("CreateComponentDialog.add_button");
+	private static final String LABEL_BUTTON_DEL = Messages
+			.getString("CreateComponentDialog.del_button");
+	private static final String LABEL_BUTTON_APPLY = Messages
+			.getString("CreateComponentDialog.apply_button");
+
+	private static final int BUTTON_WIDTH = 70;
+
+	private static final String COL_NAME = "Name";
+	private static final String COL_VALUE = "Value";
+
+	private RTCManager targetManager;
+	
+	private TableViewer parameterViewer;
+	private Button parameterAddButton;
+	private Button parameterDeleteButton;
+	private Button parameterApplyButton;
+
+	private List<ParameterParam> parameterList = new ArrayList<>();
+	private ParameterParam selectedParam;
+	private static ColorRegistry colorRegistry = null;
+
+	public void setManager(RTCManager source) {
+		this.targetManager = source;
+	}
+	
+	public ManagerConfigurationDialog(Shell parentShell) {
+		super(parentShell);
+		setHelpAvailable(false);
+		setShellStyle(getShellStyle() | SWT.CENTER | SWT.RESIZE);
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 600);
+	}
+	
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		if (colorRegistry == null) {
+			colorRegistry = new ColorRegistry();
+			colorRegistry.put(MODIFY_COLOR, new RGB(255, 192, 192));
+			colorRegistry.put(WHITE_COLOR, new RGB(255, 255, 255));
+		}
+		
+		Composite mainComposite = new Composite(
+				(Composite) super.createDialogArea(parent), SWT.NONE);
+
+		GridLayout gl;
+		gl = new GridLayout(2, false);
+		mainComposite.setLayout(gl);
+		mainComposite.setFont(parent.getFont());
+		mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+		List<NameValue> configList = targetManager.getConfigurationR();
+		for (NameValue conf : configList) {
+			if(conf.getName()!=null && 0<conf.getName().length()) {
+				ParameterParam newParam = new ParameterParam(conf.getName(), conf.getValue());
+				parameterList.add(newParam);
+			}
+		}
+
+		this.parameterViewer = createParameterTableViewer(mainComposite);
+		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(230);
+		colName.getColumn().setResizable(true);
+		colName.getColumn().setMoveable(false);
+		colName.setEditingSupport(new ParameterCellModifier(viewer, PARAMETER_KEY));
+
+		TableViewerColumn colValue = new TableViewerColumn(viewer, SWT.NONE);
+		colValue.getColumn().setText(COL_VALUE);
+		colValue.getColumn().setWidth(240);
+		colValue.getColumn().setResizable(true);
+		colValue.getColumn().setMoveable(false);
+		colValue.setEditingSupport(new ParameterCellModifier(viewer, PARAMETER_VALUE));
+
+		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();
+				if(selectedParam!=null) {
+					parameterDeleteButton.setEnabled(selectedParam.isNew());
+				}
+			}
+		});
+		//
+		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);
+		createParameterApplyButton(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");
+				newParam.setNew(true);
+				parameterList.add(newParam);
+				parameterViewer.refresh();
+			}
+		});
+		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);
+			}
+		});
+		this.parameterDeleteButton.setEnabled(false);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.widthHint = BUTTON_WIDTH;
+		this.parameterDeleteButton.setLayoutData(gd);
+	}
+
+	private void createParameterApplyButton(Composite buttonComposite) {
+		this.parameterApplyButton = new Button(buttonComposite, SWT.PUSH);
+		this.parameterApplyButton.setText(LABEL_BUTTON_APPLY);
+		this.parameterApplyButton.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				for(ParameterParam target : parameterList) {
+					if(target.isNew() || target.isUpdated()) {
+						targetManager.setConfigurationR(target.getName(), target.getValue());
+						target.setNormal();
+					}
+				}
+				parameterViewer.refresh();
+			}
+		});
+		this.parameterApplyButton.setEnabled(true);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.widthHint = BUTTON_WIDTH;
+		this.parameterApplyButton.setLayoutData(gd);
+	}
+	
+	@Override
+	protected Control createButtonBar(Composite parent) {
+		Control composite = super.createButtonBar(parent);
+		return composite;
+	}
+
+	private class ParameterParam {
+		private String name;
+		private String value;
+		private String orgValue;
+		private boolean isNew;
+
+		public ParameterParam(String name, String value) {
+			this.name = name;
+			this.value = value;
+			this.orgValue = 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;
+		}
+
+		public boolean isNew() {
+			return isNew;
+		}
+		public void setNew(boolean isNew) {
+			this.isNew = isNew;
+		}
+		
+		public boolean isUpdated() {
+			if(this.value==null || this.orgValue==null) return false;
+			return !(this.value.equals(this.orgValue));
+		}
+		
+		public void setNormal() {
+			this.isNew = false;
+			this.orgValue = this.value;
+		}
+	}
+
+	private class ParameterLabelProvider extends LabelProvider implements
+			ITableLabelProvider, ITableColorProvider {
+
+		@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;
+		}
+
+		@Override
+		public Color getBackground(Object element, int columnIndex) {
+			if (element instanceof ParameterParam == false) {
+				return null;
+			}
+			
+			Color color = colorRegistry.get(WHITE_COLOR);
+			ParameterParam targetParam = (ParameterParam) element;
+			if (columnIndex == 0) {
+				if(targetParam.isNew()) {
+					color = colorRegistry.get(MODIFY_COLOR);
+				}
+			} else if (columnIndex == 1) {
+				if(targetParam.isUpdated()) {
+					color = colorRegistry.get(MODIFY_COLOR);
+				}
+			}
+			
+			return color;
+		}
+		
+		@Override
+		public Color getForeground(Object element, int columnIndex) {
+			return null;
+		}
+	}
+
+	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) {
+			if (element instanceof ParameterParam == false) {
+				return false;
+			}
+			ParameterParam targetParam = (ParameterParam) element;
+			if(this.column == PARAMETER_KEY) {
+				return targetParam.isNew();
+			}
+			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 PARAMETER_KEY:
+				return targetParam.getName();
+			case PARAMETER_VALUE:
+				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 PARAMETER_KEY:
+				targetParam.setName((String) value);
+				break;
+			case PARAMETER_VALUE:
+				targetParam.setValue((String) value);
+				break;
+			default:
+				break;
+			}
+
+			getViewer().update(element, null);
+		}
+	}
+}


Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ManagerConfigurationDialog.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
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-06-18 03:22:25 UTC (rev 738)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/managercontrolview/ManagerControlView.java	2017-06-18 03:22:50 UTC (rev 739)
@@ -6,25 +6,21 @@
 
 import jp.go.aist.rtm.systemeditor.nl.Messages;
 import jp.go.aist.rtm.systemeditor.ui.dialog.CreateComponentDialog;
+import jp.go.aist.rtm.systemeditor.ui.dialog.ManagerConfigurationDialog;
 import jp.go.aist.rtm.toolscommon.model.manager.RTCManager;
-import jp.go.aist.rtm.toolscommon.ui.views.propertysheetview.RtcPropertySheetPage;
 import jp.go.aist.rtm.toolscommon.util.AdapterUtil;
 import jp.go.aist.rtm.toolscommon.util.SDOUtil;
 
+import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITableColorProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 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.events.SelectionListener;
@@ -34,14 +30,16 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,13 +53,13 @@
 
 	private static final String LABEL_LOADABLE_MODULE_BUTTON = Messages
 			.getString("ManagerControlView.0");
-	private static final String LABEL_LOADED_MODULE_BUTTON = Messages
+	private static final String LABEL_RTC_INSTANCE_BUTTON = Messages
 			.getString("ManagerControlView.2");
-	private static final String LABEL_ACTIVE_COMPONENT_BUTTON = Messages
+	private static final String LABEL_MANAGERS_BUTTON = Messages
 			.getString("ManagerControlView.4");
 	private static final String LABEL_CREATE_BUTTON = Messages
 			.getString("ManagerControlView.6");
-	private static final String LABEL_FORK_BUTTON = Messages
+	private static final String LABEL_CONFIGURE_BUTTON = Messages
 			.getString("ManagerControlView.7");
 	private static final String LABEL_RESTART_BUTTON = Messages
 			.getString("ManagerControlView.restart");
@@ -68,13 +66,6 @@
 	private static final String LABEL_SHUTDOWN_BUTTON = Messages
 			.getString("ManagerControlView.8");
 
-	private static final String LABEL_LOAD_BUTTON = Messages
-			.getString("ManagerControlView.11");
-	private static final String LABEL_UPLOAD_BUTTON = Messages
-			.getString("ManagerControlView.13");
-	private static final String LABEL_DELETE_COMPONENT_BUTTON = Messages
-			.getString("ManagerControlView.delete_component");
-
 	private static final String LABEL_MODULE_COLUMN = Messages
 			.getString("ManagerControlView.1");
 	private static final String LABEL_COMPONENT_COLUMN = Messages
@@ -81,36 +72,33 @@
 			.getString("ManagerControlView.5");
 	private static final String LABEL_PROCESS_GROUP_COLUMN = Messages
 			.getString("ManagerControlView.manager_name");
+	private static final String LABEL_LANGUAGE_COLUMN = Messages
+			.getString("ManagerControlView.manager_language");
 
-	private static final String LABEL_URL_TEXT = Messages
-			.getString("ManagerControlView.10");
+	private static final int MENU_BUTTON_WIDTH = 110;
+	private static final int EXEC_BUTTON_WIDTH = 110;
 
-	private static final int MENU_BUTTON_WIDTH = 160;
-	private static final int EXEC_BUTTON_WIDTH = 160;
-
 	private Composite composite = null;
-	private Button loadedModuleButton;
 	private Button loadableModuleButton;
-	private Button activeComponentButton;
-	private Button createButton;
-	private Button forkButton;
-	private Button restartButton;
-	private Button shutdownButton;
+	private Button rtcInstanceButton;
+	private Button managersButton;
+	
 	private Table modulesTable;
 	private TableViewer modulesTableViewer;
 	private TableColumn moduleColumn1;
 	private TableColumn moduleColumn2;
-	private Button loadButton;
-	private Button unloadButton;
-	private Button deleteComponentButton;
-	private Text urlText;
+	
+	private Button createButton;
+	private Button configureButton;
+	private Button restartButton;
+	private Button shutdownButton;
 
 	private boolean isSelectedLoadableModules;
-	private boolean isSelectedLoadedModules;
-	private boolean isSelectedActiveComponents;
+	private boolean isSelectedRtcInstances;
+	private boolean isSelectedManagers;
 
 	private RTCManager targetManager;
-	private List<String[]> moduleList;
+	private List<Profile> profileList;
 
 	public ManagerControlView() {
 	}
@@ -145,140 +133,59 @@
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				isSelectedLoadableModules = false;
-				isSelectedLoadedModules = false;
-				isSelectedActiveComponents = false;
+				isSelectedRtcInstances = false;
+				isSelectedManagers = false;
 				if (targetManager != null) {
 					moduleColumn1.setText(LABEL_MODULE_COLUMN);
 					moduleColumn2.setText("");
 					isSelectedLoadableModules = true;
-					// キャッシュ更新
-					targetManager.getLoadableModuleProfilesR();
 				}
 				refreshModuleListData();
 			}
 		});
 
-		this.loadedModuleButton = new Button(menuButtonComposite, SWT.TOP);
-		this.loadedModuleButton.setText(LABEL_LOADED_MODULE_BUTTON);
+		this.rtcInstanceButton = new Button(menuButtonComposite, SWT.TOP);
+		this.rtcInstanceButton.setText(LABEL_RTC_INSTANCE_BUTTON);
 		gd = new GridData();
 		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.loadedModuleButton.setLayoutData(gd);
-		this.loadedModuleButton.setEnabled(false);
-		this.loadedModuleButton.addSelectionListener(new SelectionAdapter() {
+		this.rtcInstanceButton.setLayoutData(gd);
+		this.rtcInstanceButton.setEnabled(false);
+		this.rtcInstanceButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				isSelectedLoadableModules = false;
-				isSelectedLoadedModules = false;
-				isSelectedActiveComponents = false;
+				isSelectedRtcInstances = false;
+				isSelectedManagers = false;
 				if (targetManager != null) {
-					moduleColumn1.setText(LABEL_MODULE_COLUMN);
-					moduleColumn2.setText("");
-					isSelectedLoadedModules = true;
-					// キャッシュ更新
-					targetManager.getLoadedModuleProfilesR();
+					moduleColumn1.setText(LABEL_COMPONENT_COLUMN);
+					moduleColumn2.setText(LABEL_PROCESS_GROUP_COLUMN);
+					isSelectedRtcInstances = true;
 				}
 				refreshModuleListData();
 			}
 		});
 
-		this.activeComponentButton = new Button(menuButtonComposite, SWT.TOP);
-		this.activeComponentButton.setText(LABEL_ACTIVE_COMPONENT_BUTTON);
+		this.managersButton = new Button(menuButtonComposite, SWT.TOP);
+		this.managersButton.setText(LABEL_MANAGERS_BUTTON);
 		gd = new GridData();
 		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.activeComponentButton.setLayoutData(gd);
-		this.activeComponentButton.setEnabled(false);
-		this.activeComponentButton.addSelectionListener(new SelectionAdapter() {
+		this.managersButton.setLayoutData(gd);
+		this.managersButton.setEnabled(false);
+		this.managersButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				isSelectedLoadableModules = false;
-				isSelectedLoadedModules = false;
-				isSelectedActiveComponents = false;
+				isSelectedRtcInstances = false;
+				isSelectedManagers = false;
 				if (targetManager != null) {
-					moduleColumn1.setText(LABEL_COMPONENT_COLUMN);
-					moduleColumn2.setText(LABEL_PROCESS_GROUP_COLUMN);
-					isSelectedActiveComponents = true;
-					// キャッシュ更新
-					targetManager.getComponentProfilesR();
+					moduleColumn1.setText(LABEL_PROCESS_GROUP_COLUMN);
+					moduleColumn2.setText(LABEL_LANGUAGE_COLUMN);
+					isSelectedManagers = true;
 				}
 				refreshModuleListData();
 			}
 		});
 
-		this.createButton = new Button(menuButtonComposite, SWT.TOP);
-		this.createButton.setText(LABEL_CREATE_BUTTON);
-		gd = new GridData();
-		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.createButton.setLayoutData(gd);
-		this.createButton.setEnabled(false);
-		this.createButton.addSelectionListener(new SelectionAdapter() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				if (targetManager == null) {
-					return;
-				}
-				CreateComponentDialog dialog = new CreateComponentDialog(
-						getSite().getShell());
-				dialog.setModuleProfileList(targetManager
-						.getFactoryModuleProfilesR());
-				dialog.setManagerNameList(targetManager.getSlaveManagerNames());
-				if (dialog.open() == IDialogConstants.OK_ID) {
-					String cmd = dialog.getParameter();
-					LOGGER.info("create command: <{}>", cmd);
-					targetManager.createComponentR(cmd);
-				}
-			}
-		});
-
-		this.forkButton = new Button(menuButtonComposite, SWT.TOP);
-		this.forkButton.setText(LABEL_FORK_BUTTON);
-		gd = new GridData();
-		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.forkButton.setLayoutData(gd);
-		this.forkButton.setEnabled(false);
-		this.forkButton.addSelectionListener(new SelectionAdapter() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				if (targetManager != null) {
-					targetManager.forkR();
-				}
-				buildData();
-			}
-		});
-
-		this.restartButton = new Button(menuButtonComposite, SWT.TOP);
-		this.restartButton.setText(LABEL_RESTART_BUTTON);
-		gd = new GridData();
-		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.restartButton.setLayoutData(gd);
-		this.restartButton.setEnabled(false);
-		this.restartButton.addSelectionListener(new SelectionAdapter() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				if (targetManager != null) {
-					targetManager.restartR();
-					targetManager = null;
-				}
-				buildData();
-			}
-		});
-
-		this.shutdownButton = new Button(menuButtonComposite, SWT.TOP);
-		this.shutdownButton.setText(LABEL_SHUTDOWN_BUTTON);
-		gd = new GridData();
-		gd.widthHint = MENU_BUTTON_WIDTH;
-		this.shutdownButton.setLayoutData(gd);
-		this.shutdownButton.setEnabled(false);
-		this.shutdownButton.addSelectionListener(new SelectionAdapter() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				if (targetManager != null) {
-					targetManager.shutdownR();
-					targetManager = null;
-				}
-				buildData();
-			}
-		});
-
 		final Composite listComposite = new Composite(this.composite, SWT.FILL);
 		gl = new GridLayout();
 		gl.marginWidth = 0;
@@ -311,11 +218,11 @@
 		this.modulesTable.setHeaderVisible(true);
 		this.modulesTable.addSelectionListener(new SelectionListener() {
 			public void widgetSelected(SelectionEvent e) {
-				updateEnableLoadButton();
+				updateEnableButton();
 			}
 
 			public void widgetDefaultSelected(SelectionEvent e) {
-				updateEnableLoadButton();
+				updateEnableButton();
 			}
 		});
 
@@ -326,26 +233,8 @@
 		this.moduleColumn2.setText("");
 		this.moduleColumn2.setWidth(300);
 
-		this.modulesTableViewer.setLabelProvider(new ModuleLabelProvider());
+		this.modulesTableViewer.setLabelProvider(new ProfileLabelProvider());
 
-		Label urlLabel = new Label(listComposite, SWT.NONE);
-		gd = new GridData();
-		urlLabel.setLayoutData(gd);
-		urlLabel.setText(LABEL_URL_TEXT);
-
-		this.urlText = new Text(listComposite, SWT.SINGLE | SWT.BORDER);
-		gd = new GridData();
-		gd.horizontalAlignment = SWT.FILL;
-		gd.grabExcessHorizontalSpace = true;
-		this.urlText.setLayoutData(gd);
-		this.urlText.setTextLimit(255);
-		this.urlText.setEnabled(false);
-		this.urlText.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				updateEnableLoadButton();
-			}
-		});
-
 		final Composite execButtonComposite = new Composite(this.composite,
 				SWT.NONE);
 		gl = new GridLayout();
@@ -356,78 +245,94 @@
 		execButtonComposite.setLayout(gl);
 		execButtonComposite.setLayoutData(gd);
 
-		this.loadButton = new Button(execButtonComposite, SWT.TOP);
-		this.loadButton.setText(LABEL_LOAD_BUTTON);
+		this.createButton = new Button(execButtonComposite, SWT.TOP);
+		this.createButton.setText(LABEL_CREATE_BUTTON);
 		gd = new GridData();
 		gd.widthHint = EXEC_BUTTON_WIDTH;
-		this.loadButton.setLayoutData(gd);
-		this.loadButton.setEnabled(false);
-		this.loadButton.addSelectionListener(new SelectionAdapter() {
+		this.createButton.setLayoutData(gd);
+		this.createButton.setEnabled(false);
+		this.createButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				if (targetManager != null) {
-					String module = null;
-					if (modulesTable.getSelectionIndex() != -1) {
-						if (isSelectedLoadableModules) {
-							String[] m = moduleList.get(modulesTable
-									.getSelectionIndex());
-							module = m[0];
-						}
-					} else if (urlText.getText().length() > 0) {
-						module = urlText.getText();
-					}
-					if (module != null) {
-						// TODO initfuncはどこで指定?
-						targetManager.loadModuleR(module, ""); //$NON-NLS-1$
-					}
+				if (targetManager == null) {
+					return;
 				}
-				refreshModuleListData();
+				CreateComponentDialog dialog = new CreateComponentDialog(
+						getSite().getShell());
+				dialog.setModuleProfileList(targetManager
+						.getLoadableModuleProfilesR());
+				//
+				List<String> managerList = new ArrayList<String>();
+				managerList.add(SDOUtil.findValueAsString("instance_name", targetManager.getManagerProfile().properties));
+				managerList.addAll(targetManager.getSlaveManagerNames());
+				dialog.setManagerNameList(managerList);
+				int selectedIndex = modulesTable.getSelectionIndex();
+				if (selectedIndex != -1 && isSelectedManagers) {
+					String initManager = profileList.get(selectedIndex).getManager_name();
+					dialog.setInitManager(initManager);
+				}
+				if (dialog.open() == IDialogConstants.OK_ID) {
+					String cmd = dialog.getParameter();
+					LOGGER.info("create command: <{}>", cmd);
+					targetManager.createComponentR(cmd);
+				}
 			}
 		});
 
-		this.unloadButton = new Button(execButtonComposite, SWT.TOP);
-		this.unloadButton.setText(LABEL_UPLOAD_BUTTON);
+		this.configureButton = new Button(execButtonComposite, SWT.TOP);
+		this.configureButton.setText(LABEL_CONFIGURE_BUTTON);
 		gd = new GridData();
 		gd.widthHint = EXEC_BUTTON_WIDTH;
-		this.unloadButton.setLayoutData(gd);
-		this.unloadButton.setEnabled(false);
-		this.unloadButton.addSelectionListener(new SelectionAdapter() {
+		this.configureButton.setLayoutData(gd);
+		this.configureButton.setEnabled(false);
+		this.configureButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
+				if (targetManager == null) {
+					return;
+				}
+				ManagerConfigurationDialog dialog = new ManagerConfigurationDialog(
+						getSite().getShell());
+				dialog.setManager(targetManager);
+				if (dialog.open() == IDialogConstants.OK_ID) {
+//					String cmd = dialog.getParameter();
+//					LOGGER.info("create command: <{}>", cmd);
+//					targetManager.createComponentR(cmd);
+				}
+			}
+		});
+
+		this.restartButton = new Button(execButtonComposite, SWT.TOP);
+		this.restartButton.setText(LABEL_RESTART_BUTTON);
+		gd = new GridData();
+		gd.widthHint = EXEC_BUTTON_WIDTH;
+		this.restartButton.setLayoutData(gd);
+		this.restartButton.setEnabled(false);
+		this.restartButton.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
 				if (targetManager != null) {
-					if (isSelectedLoadedModules) {
-						if (modulesTable.getSelectionIndex() != -1) {
-							String[] m = moduleList.get(modulesTable
-									.getSelectionIndex());
-							String module = m[0];
-							targetManager.unloadModuleR(module);
-						}
-					}
+					targetManager.restartR();
+					targetManager = null;
 				}
-				refreshModuleListData();
+				buildData();
 			}
 		});
 
-		this.deleteComponentButton = new Button(execButtonComposite, SWT.TOP);
-		this.deleteComponentButton.setText(LABEL_DELETE_COMPONENT_BUTTON);
+		this.shutdownButton = new Button(execButtonComposite, SWT.TOP);
+		this.shutdownButton.setText(LABEL_SHUTDOWN_BUTTON);
 		gd = new GridData();
 		gd.widthHint = EXEC_BUTTON_WIDTH;
-		this.deleteComponentButton.setLayoutData(gd);
-		this.deleteComponentButton.setEnabled(false);
-		this.deleteComponentButton.addSelectionListener(new SelectionAdapter() {
+		this.shutdownButton.setLayoutData(gd);
+		this.shutdownButton.setEnabled(false);
+		this.shutdownButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				if (targetManager != null) {
-					if (isSelectedActiveComponents) {
-						if (modulesTable.getSelectionIndex() != -1) {
-							String[] m = moduleList.get(modulesTable
-									.getSelectionIndex());
-							String comp = m[0];
-							targetManager.deleteComponentR(comp);
-						}
-					}
+					targetManager.shutdownR();
+					targetManager = null;
 				}
-				refreshModuleListData();
+				buildData();
 			}
 		});
 
@@ -442,29 +347,26 @@
 
 	private void buildData() {
 		this.isSelectedLoadableModules = false;
-		this.isSelectedLoadedModules = false;
-		this.isSelectedActiveComponents = false;
+		this.isSelectedRtcInstances = false;
+		this.isSelectedManagers = false;
 		refreshData();
 	}
 
 	private void refreshData() {
 		this.loadableModuleButton.setEnabled(false);
-		this.loadedModuleButton.setEnabled(false);
-		this.activeComponentButton.setEnabled(false);
+		this.rtcInstanceButton.setEnabled(false);
+		this.managersButton.setEnabled(false);
 		this.createButton.setEnabled(false);
-		this.forkButton.setEnabled(false);
+		this.configureButton.setEnabled(false);
 		this.restartButton.setEnabled(false);
 		this.shutdownButton.setEnabled(false);
-		this.loadButton.setEnabled(false);
-		this.unloadButton.setEnabled(false);
-		this.urlText.setEnabled(false);
 
 		if (this.targetManager != null) {
 			this.loadableModuleButton.setEnabled(true);
-			this.loadedModuleButton.setEnabled(true);
-			this.activeComponentButton.setEnabled(true);
+			this.rtcInstanceButton.setEnabled(true);
+			this.managersButton.setEnabled(true);
 			this.createButton.setEnabled(true);
-			this.forkButton.setEnabled(true);
+			this.configureButton.setEnabled(true);
 			this.restartButton.setEnabled(true);
 			this.shutdownButton.setEnabled(true);
 		}
@@ -473,57 +375,45 @@
 
 	private void refreshModuleListData() {
 		this.modulesTableViewer.setInput(Collections.EMPTY_LIST);
-		if (this.moduleList == null) {
-			this.moduleList = new ArrayList<String[]>();
+		if (this.profileList == null) {
+			this.profileList = new ArrayList<Profile>();
 		}
-		this.moduleList.clear();
-		this.urlText.setText("");
-		this.urlText.setEnabled(false);
-		this.loadButton.setEnabled(false);
-		this.unloadButton.setEnabled(false);
-		this.deleteComponentButton.setEnabled(false);
+		this.profileList.clear();
 		if (this.targetManager != null) {
 			if (this.isSelectedLoadableModules) {
-				for (String m : this.targetManager.getLoadableModuleFileNames()) {
-					this.moduleList.add(new String[] { m });
+				for (RTM.ModuleProfile module : this.targetManager
+						.getLoadableModuleProfilesR()) {
+					this.profileList.add(new Profile(module));
 				}
-				this.modulesTableViewer.setInput(this.moduleList);
-				this.urlText.setEnabled(true);
-			} else if (this.isSelectedLoadedModules) {
-				for (String m : this.targetManager.getLoadedModuleFileNames()) {
-					this.moduleList.add(new String[] { m });
+				this.modulesTableViewer.setInput(this.profileList);
+			} else if (this.isSelectedRtcInstances) {
+				for (RTC.ComponentProfile component : this.targetManager
+						.getComponentProfilesR()) {
+					this.profileList.add(new Profile(component));
 				}
-				this.modulesTableViewer.setInput(this.moduleList);
-			} else if (this.isSelectedActiveComponents) {
-				for (RTC.ComponentProfile prof : this.targetManager
-						.getComponentProfiles()) {
-					String name = prof.instance_name;
-					String mn = SDOUtil.findValueAsString("manager_name",
-							prof.properties);
-					mn = (mn == null) ? "" : mn;
-					this.moduleList.add(new String[] { name, mn });
+				this.modulesTableViewer.setInput(this.profileList);
+			} else if (this.isSelectedManagers) {
+				this.profileList.add(new Profile(this.targetManager.getProfileR()));
+				for (RTCManager manager : this.targetManager
+						.getSlaveManagersR()) {
+					this.profileList.add(new Profile(manager.getProfileR()));
 				}
-				this.modulesTableViewer.setInput(this.moduleList);
+				this.modulesTableViewer.setInput(this.profileList);
 			}
 		}
-		updateEnableLoadButton();
+		updateEnableButton();
 	}
 
-	private void updateEnableLoadButton() {
-		this.loadButton.setEnabled(false);
-		this.unloadButton.setEnabled(false);
-		this.deleteComponentButton.setEnabled(false);
+	private void updateEnableButton() {
+		this.configureButton.setEnabled(false);
+		this.restartButton.setEnabled(false);
+		this.shutdownButton.setEnabled(false);
 		if (this.modulesTable.getSelectionIndex() != -1) {
-			if (this.isSelectedLoadableModules) {
-				this.loadButton.setEnabled(true);
-			} else if (this.isSelectedLoadedModules) {
-				this.unloadButton.setEnabled(true);
-			} else if (this.isSelectedActiveComponents) {
-				this.deleteComponentButton.setEnabled(true);
+			if (this.isSelectedManagers) {
+				this.configureButton.setEnabled(true);
+				this.restartButton.setEnabled(true);
+				this.shutdownButton.setEnabled(true);
 			}
-		} else if (this.urlText.getText().length() > 0) {
-			// URL指定の場合
-			this.loadButton.setEnabled(true);
 		}
 	}
 
@@ -531,14 +421,162 @@
 	@Override
 	public Object getAdapter(Class adapter) {
 		if (adapter.equals(IPropertySheetPage.class)) {
-			return new RtcPropertySheetPage();
+			return new PropertySheetPage();
 		}
 		return super.getAdapter(adapter);
 	}
 
-	/** モジュール/コンポーネント一覧表示のLabelProvider */
-	public class ModuleLabelProvider extends LabelProvider implements
+	/** 各種プロファイルを格納するラッパ */
+	public static class Profile implements IAdaptable {
+
+		private RTM.ModuleProfile module = null;
+		private RTC.ComponentProfile component = null;
+		private RTM.ManagerProfile manager = null;
+
+		Profile(RTM.ModuleProfile module) {
+			this.module = module;
+		}
+
+		Profile(RTC.ComponentProfile component) {
+			this.component = component;
+		}
+
+		Profile(RTM.ManagerProfile manager) {
+			this.manager = manager;
+		}
+
+		public boolean hasModuleProfile() {
+			return this.module != null;
+		}
+
+		public boolean hasComponentProfile() {
+			return this.component != null;
+		}
+
+		public boolean hasManagerProfile() {
+			return this.manager != null;
+		}
+
+		public RTM.ModuleProfile getModuleProfile() {
+			return this.module;
+		}
+
+		public RTC.ComponentProfile getComponentProfile() {
+			return this.component;
+		}
+
+		public RTM.ManagerProfile getManagerProfile() {
+			return this.manager;
+		}
+
+		/** モジュールプロファイル: ファイルパスを取得します */
+		public String getModule_file_path() {
+			return SDOUtil.findValueAsString("module_file_path",
+					this.module.properties);
+		}
+
+		/** コンポーネントプロファイル: インスタンス名を取得します */
+		public String getComponent_instance_name() {
+			return this.component.instance_name;
+		}
+
+		/** コンポーネントプロファイル: マネージャ名を取得します */
+		public String getComponent_manager_name() {
+			return SDOUtil.findValueAsString("manager_name",
+					this.component.properties);
+		}
+
+		/** マネージャプロファイル: マネージャ名を取得します */
+		public String getManager_name() {
+			return SDOUtil.findValueAsString("instance_name",
+					this.manager.properties);
+		}
+
+		/** マネージャプロファイル: 言語を取得します */
+		public String getManager_language() {
+			return SDOUtil.findValueAsString("language",
+					this.manager.properties);
+//			return SDOUtil.findValueAsString("supported_languages",
+//					this.manager.properties);
+		}
+
+		@SuppressWarnings("rawtypes")
+		@Override
+		public Object getAdapter(Class adapter) {
+			if (adapter.equals(IPropertySource.class)) {
+				return new ProfilePropertySource(this);
+			}
+			return null;
+		}
+
+	}
+	
+	/** 各種プロファイルのプロパティ表示のためのPropertySource */
+	public static class ProfilePropertySource implements IPropertySource {
+
+		private Profile profile;
+
+		ProfilePropertySource(Profile profile) {
+			this.profile = profile;
+		}
+
+		@Override
+		public Object getEditableValue() {
+			return null;
+		}
+
+		@Override
+		public IPropertyDescriptor[] getPropertyDescriptors() {
+			if (this.profile == null) {
+				return new IPropertyDescriptor[0];
+			}
+			_SDOPackage.NameValue[] props = new _SDOPackage.NameValue[0];
+			if (this.profile.hasModuleProfile()) {
+				props = this.profile.getModuleProfile().properties;
+			} else if (this.profile.hasComponentProfile()) {
+				props = this.profile.getComponentProfile().properties;
+			} else if (this.profile.hasManagerProfile()) {
+				props = this.profile.getManagerProfile().properties;
+			}
+			List<IPropertyDescriptor> descs = new ArrayList<>();
+			for (_SDOPackage.NameValue nv : props) {
+				descs.add(new TextPropertyDescriptor(nv.name, nv.name));
+			}
+			return descs.toArray(new IPropertyDescriptor[0]);
+		}
+
+		@Override
+		public Object getPropertyValue(Object id) {
+			_SDOPackage.NameValue[] props = new _SDOPackage.NameValue[0];
+			if (this.profile.hasModuleProfile()) {
+				props = this.profile.getModuleProfile().properties;
+			} else if (this.profile.hasComponentProfile()) {
+				props = this.profile.getComponentProfile().properties;
+			} else if (this.profile.hasManagerProfile()) {
+				props = this.profile.getManagerProfile().properties;
+			}
+			return SDOUtil.findValueAsString((String) id, props);
+		}
+
+		@Override
+		public boolean isPropertySet(Object id) {
+			return false;
+		}
+
+		@Override
+		public void resetPropertyValue(Object id) {
+		}
+
+		@Override
+		public void setPropertyValue(Object id, Object value) {
+		}
+
+	}
+	
+	/** 各種プロファイル一覧表示のLabelProvider */
+	public class ProfileLabelProvider extends LabelProvider implements
 			ITableLabelProvider, ITableColorProvider {
+
 		@Override
 		public Image getColumnImage(Object element, int columnIndex) {
 			return null;
@@ -546,8 +584,32 @@
 
 		@Override
 		public String getColumnText(Object element, int columnIndex) {
-			String[] entry = (String[]) element;
-			return (columnIndex < entry.length) ? entry[columnIndex] : "";
+			Profile profile = (Profile) element;
+			if (profile.hasModuleProfile()) {
+				if (columnIndex == 0) {
+					return profile.getModule_file_path();
+				} else {
+					return "";
+				}
+			} else if (profile.hasComponentProfile()) {
+				if (columnIndex == 0) {
+					return profile.getComponent_instance_name();
+				} else if (columnIndex == 1) {
+					return profile.getComponent_manager_name();
+				} else {
+					return "";
+				}
+			} else if (profile.hasManagerProfile()) {
+				if (columnIndex == 0) {
+					return profile.getManager_name();
+				} else if (columnIndex == 1) {
+					return profile.getManager_language();
+				} else {
+					return "";
+				}
+			} else {
+				return "";
+			}
 		}
 
 		@Override
@@ -559,12 +621,12 @@
 		public Color getForeground(Object element, int columnIndex) {
 			return null;
 		}
+
 	}
 
 	private ISelectionListener selectionListener = new ISelectionListener() {
 		@Override
 		public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-			targetManager = null;
 			if (selection instanceof IStructuredSelection) {
 				IStructuredSelection ss = (IStructuredSelection) selection;
 				Object firstElement = ss.getFirstElement();
@@ -573,9 +635,9 @@
 				if (adapter != null) {
 					targetManager = (RTCManager) adapter;
 					targetManager.synchronizeManually();
+					buildData();
 				}
 			}
-			buildData();
 		}
 	};
 
@@ -592,26 +654,7 @@
 				.addSelectionListener(this.selectionListener);
 
 		// SelectionProviderを登録(プロパティ・ビュー連携)
-		getSite().setSelectionProvider(new ISelectionProvider() {
-			public void addSelectionChangedListener(
-					ISelectionChangedListener listener) {
-			}
-
-			public ISelection getSelection() {
-				StructuredSelection result = null;
-				if (targetManager != null) {
-					result = new StructuredSelection(targetManager);
-				}
-				return result;
-			}
-
-			public void removeSelectionChangedListener(
-					ISelectionChangedListener listener) {
-			}
-
-			public void setSelection(ISelection selection) {
-			}
-		});
+		getSite().setSelectionProvider(this.modulesTableViewer);
 	}
 
 }



More information about the openrtm-commit mailing list