[openrtm-commit:00120] r183 - trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview

openrtm @ openrtm.org openrtm @ openrtm.org
2011年 5月 27日 (金) 18:36:24 JST


Author: ta
Date: 2011-05-27 18:36:24 +0900 (Fri, 27 May 2011)
New Revision: 183

Modified:
   trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/ConfigurationView.java
Log:
add adapter for update configuration on configurationview.

Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/ConfigurationView.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/ConfigurationView.java	2011-05-27 09:36:11 UTC (rev 182)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/ConfigurationView.java	2011-05-27 09:36:24 UTC (rev 183)
@@ -23,6 +23,8 @@
 import jp.go.aist.rtm.toolscommon.util.AdapterUtil;
 import jp.go.aist.rtm.toolscommon.util.SDOUtil;
 
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -841,19 +843,52 @@
 		return super.getAdapter(adapter);
 	}
 
+	/** CORBAの同期による変更通知を受け取るアダプタ */
+	AdapterImpl eAdapter = new AdapterImpl() {
+		@Override
+		public void notifyChanged(Notification msg) {
+			if (msg.getOldValue() == this || msg.getNewValue() == this) {
+				return;
+			}
+			boolean update = false;
+			if (ComponentPackage.eINSTANCE.getComponent_ConfigurationSets()
+					.equals(msg.getFeature())) {
+				update = true;
+			}
+			if (ComponentPackage.eINSTANCE
+					.getComponent_ActiveConfigurationSet().equals(
+							msg.getFeature())) {
+				update = true;
+			}
+			if (!update) {
+				return;
+			}
+			leftTableViewer.getControl().getDisplay().asyncExec(new Runnable() {
+				@Override
+				public void run() {
+					buildData();
+				}
+			});
+		}
+	};
+
 	/**
 	 * 選択を監視するリスナ
 	 */
 	private ISelectionListener selectionListener = new ISelectionListener() {
 		public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+			if (targetComponent != null) {
+				targetComponent.eAdapters().remove(eAdapter);
+			}
 			targetComponent = null;
 			if (selection instanceof IStructuredSelection) {
 				IStructuredSelection sSelection = (IStructuredSelection) selection;
-				Object selectedComponent = AdapterUtil.getAdapter(sSelection.getFirstElement(),
-										Component.class);
+				Object selectedComponent = AdapterUtil.getAdapter(sSelection
+						.getFirstElement(), Component.class);
 				if (selectedComponent != null) {
 					targetComponent = (Component) selectedComponent;
 					targetComponent.synchronizeManually();
+					targetComponent.eAdapters().add(eAdapter);
 				}
 			}
 			buildData();



openrtm-commit メーリングリストの案内