[openrtm-commit:03234] r814 - in trunk/rtmtools/jp.go.aist.rtm.systemeditor: . src/jp/go/aist/rtm/systemeditor/ui/action src/jp/go/aist/rtm/systemeditor/ui/editor/editpart src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy src/jp/go/aist/rtm/systemeditor/ui/editor/figure src/jp/go/aist/rtm/systemeditor/ui/util src/jp/go/aist/rtm/systemeditor/ui/views src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview src/jp/go/aist/rtm/systemeditor/ui/views/executioncontextview test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 9日 (金) 15:41:17 JST
Author: ga
Date: 2018-03-09 15:41:17 +0900 (Fri, 09 Mar 2018)
New Revision: 814
Added:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ColorHelper.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ECEditPart.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ToolTipHelper.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/ECSelectionEditPolicy.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentChildFigure.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ECFigure.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/util/ComponentComparator.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/ActionOrderView.java
Modified:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.properties
trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.xml
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/action/AllComponentActionDelegate.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ComponentEditPart.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/PortFigure.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/executioncontextview/ExecutionContextView.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java
Log:
Add ActionOrderView #4442
Hide LogView
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.properties 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.properties 2018-03-09 06:41:17 UTC (rev 814)
@@ -34,6 +34,7 @@
Composite_Component_View =Composite Component View
ExecutionContext_View =Execution Context View
RT_Log_View =RT Log View
+Action_Order_View =Action Order View
# preferencePages
Connection =Connection
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.xml
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.xml 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/plugin.xml 2018-03-09 06:41:17 UTC (rev 814)
@@ -18,8 +18,10 @@
<editpart seq="200" targetclass="jp.go.aist.rtm.toolscommon.model.component.OutPort" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.OutPortEditPart" />
<editpart seq="300" targetclass="jp.go.aist.rtm.toolscommon.model.component.ServicePort" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ServicePortEditPart" />
<editpart seq="400" targetclass="jp.go.aist.rtm.toolscommon.model.component.PortConnector" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.PortConnectorEditPart" />
- <editpart seq="500" targetclass="jp.go.aist.rtm.toolscommon.model.component.Component" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart" />
- <editpart seq="600" targetclass="jp.go.aist.rtm.toolscommon.model.component.SystemDiagram" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.SystemDiagramEditPart" />
+ <editpart seq="600" targetclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart$OwnEC" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart$OwnECEditPart" />
+ <editpart seq="610" targetclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart$PartEC" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart$PartECEditPart" />
+ <editpart seq="1000" targetclass="jp.go.aist.rtm.toolscommon.model.component.Component" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart" />
+ <editpart seq="1500" targetclass="jp.go.aist.rtm.toolscommon.model.component.SystemDiagram" editpartclass="jp.go.aist.rtm.systemeditor.ui.editor.editpart.SystemDiagramEditPart" />
</extension>
<extension point="org.eclipse.ui.perspectives">
@@ -84,12 +86,19 @@
class="jp.go.aist.rtm.systemeditor.ui.views.executioncontextview.ExecutionContextView"
id="jp.go.aist.rtm.systemeditor.ui.views.executioncontextview.ExecutionContextView">
</view>
- <view
+<!-- <view
name="%RT_Log_View"
icon="icons/RT_icon.png"
category="rtse"
class="jp.go.aist.rtm.systemeditor.ui.views.logview.LogView"
id="jp.go.aist.rtm.systemeditor.ui.views.logview.LogView">
+ </view>-->
+ <view
+ name="%Action_Order_View"
+ icon="icons/RT_icon.png"
+ category="rtse"
+ class="jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView"
+ id="jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView">
</view>
</extension>
@@ -500,10 +509,15 @@
relationship="stack"
relative="jp.go.aist.rtm.systemeditor.ui.views.configurationview.ConfigurationView">
</view>
- <view
+<!-- <view
id="jp.go.aist.rtm.systemeditor.ui.views.logview.LogView"
relationship="stack"
relative="jp.go.aist.rtm.systemeditor.ui.views.configurationview.ConfigurationView">
+ </view>-->
+ <view
+ id="jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView"
+ relationship="stack"
+ relative="jp.go.aist.rtm.systemeditor.ui.views.configurationview.ConfigurationView">
</view>
<viewShortcut id="jp.go.aist.rtm.nameserviceview.ui.views.nameserviceview.NameServiceView"/>
<viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.configurationview.ConfigurationView"/>
@@ -510,7 +524,8 @@
<viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.managercontrolview.ManagerControlView"/>
<viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.compositecomponentview.CompositeComponentView"/>
<viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.executioncontextview.ExecutionContextView"/>
- <viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.logview.LogView"/>
+ <!--<viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.logview.LogView"/>-->
+ <viewShortcut id="jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView"/>
</perspectiveExtension>
</extension>
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/action/AllComponentActionDelegate.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/action/AllComponentActionDelegate.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/action/AllComponentActionDelegate.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -1,14 +1,18 @@
package jp.go.aist.rtm.systemeditor.ui.action;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
import jp.go.aist.rtm.systemeditor.nl.Messages;
import jp.go.aist.rtm.systemeditor.ui.editor.SystemDiagramEditor;
+import jp.go.aist.rtm.systemeditor.ui.util.ComponentComparator;
+import jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView.ActionName;
+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.core.ModelElement;
-import jp.go.aist.rtm.toolscommon.model.core.Visiter;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
@@ -143,58 +147,54 @@
}
private void doAllStop(SystemDiagram systemDiagram) {
- systemDiagram.accept(new Visiter() {
- @SuppressWarnings("unchecked")
- public void visit(ModelElement element) {
- if (element instanceof CorbaComponent) {
- ((CorbaComponent) element).stopAll();
- }
- }
- });
+ List<Component> targetComps = getTargetComps(systemDiagram);
+ Collections.sort(targetComps, new ComponentComparator(ActionName.ACTION_SHUT_DOWN));
+ for(int index=0; index<targetComps.size(); index++) {
+ ((CorbaComponent)targetComps.get(index)).stopAll();
+ }
}
private void doAllStart(SystemDiagram systemDiagram) {
- systemDiagram.accept(new Visiter() {
- @SuppressWarnings("unchecked")
- public void visit(ModelElement element) {
- if (element instanceof CorbaComponent) {
- ((CorbaComponent) element).startAll();
- }
- }
- });
+ List<Component> targetComps = getTargetComps(systemDiagram);
+ Collections.sort(targetComps, new ComponentComparator(ActionName.ACTION_START_UP));
+ for(int index=0; index<targetComps.size(); index++) {
+ ((CorbaComponent)targetComps.get(index)).startAll();
+ }
}
private void doAllActivate(SystemDiagram systemDiagram) {
- systemDiagram.accept(new Visiter() {
- @SuppressWarnings("unchecked")
- public void visit(ModelElement element) {
- if (element instanceof CorbaComponent) {
- ((CorbaComponent) element).activateAll();
- }
- }
- });
+ List<Component> targetComps = getTargetComps(systemDiagram);
+ Collections.sort(targetComps, new ComponentComparator(ActionName.ACTION_ACTIVATION));
+ for(int index=0; index<targetComps.size(); index++) {
+ ((CorbaComponent)targetComps.get(index)).activateAll();
+ }
}
private void doAllDectivate(SystemDiagram systemDiagram) {
- systemDiagram.accept(new Visiter() {
- @SuppressWarnings("unchecked")
- public void visit(ModelElement element) {
- if (element instanceof CorbaComponent) {
- ((CorbaComponent) element).deactivateAll();
- }
- }
- });
+ List<Component> targetComps = getTargetComps(systemDiagram);
+ Collections.sort(targetComps, new ComponentComparator(ActionName.ACTION_DEACTIVATION));
+ for(int index=0; index<targetComps.size(); index++) {
+ ((CorbaComponent)targetComps.get(index)).deactivateAll();
+ }
}
private void doAllExit(SystemDiagram systemDiagram) {
- systemDiagram.accept(new Visiter() {
- @SuppressWarnings("unchecked")
- public void visit(ModelElement element) {
- if (element instanceof CorbaComponent) {
- ((CorbaComponent) element).exitR();
- }
+ List<Component> targetComps = getTargetComps(systemDiagram);
+ Collections.sort(targetComps, new ComponentComparator(ActionName.ACTION_FINALIZE));
+ for(int index=0; index<targetComps.size(); index++) {
+ ((CorbaComponent)targetComps.get(index)).exitR();
+ }
+ }
+
+ private List<Component> getTargetComps(SystemDiagram systemDiagram) {
+ List<Component> targetComps = new ArrayList<Component>();
+ for (Component comp : systemDiagram.getRegisteredComponents()) {
+ if (!(comp instanceof CorbaComponent)) {
+ continue;
}
- });
+ targetComps.add(comp);
+ }
+ return targetComps;
}
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ColorHelper.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ColorHelper.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ColorHelper.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,93 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.editpart;
+
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_EXECUTION_CONTEXT_RUNNING;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_EXECUTION_CONTEXT_STOPPED;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_ACTIVE;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_CREATED;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_ERROR;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_INACTIVE;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_UNCERTAIN;
+import static jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager.COLOR_RTC_STATE_UNKNOWN;
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaExecutionContext;
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+
+import org.eclipse.swt.graphics.Color;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * システムの色設定から色を取得します。
+ */
+public class ColorHelper {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ColorHelper.class);
+
+ /**
+ * システム設定から ECの枠色を取得します。
+ *
+ * @param ec
+ * @return
+ */
+ public static Color getECBorderColor(ExecutionContext ec) {
+ SystemEditorPreferenceManager manager = SystemEditorPreferenceManager
+ .getInstance();
+ //
+ Color ret = manager.getColor(COLOR_RTC_STATE_UNKNOWN);
+ if (ec instanceof CorbaExecutionContext) {
+ CorbaExecutionContext cec = (CorbaExecutionContext) ec;
+ if (cec.getStateL() == ExecutionContext.STATE_RUNNING) {
+ ret = manager.getColor(COLOR_RTC_EXECUTION_CONTEXT_RUNNING);
+ } else if (cec.getStateL() == ExecutionContext.STATE_STOPPED) {
+ ret = manager.getColor(COLOR_RTC_EXECUTION_CONTEXT_STOPPED);
+ } else if (cec.getStateL() == ExecutionContext.STATE_UNKNOWN) {
+ ret = manager.getColor(COLOR_RTC_STATE_UNKNOWN);
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * システム設定から ECの本体色を取得します。
+ *
+ * @param ec
+ * @return
+ */
+ public static Color getECBodyColor(ExecutionContext ec) {
+ SystemEditorPreferenceManager manager = SystemEditorPreferenceManager
+ .getInstance();
+ //
+ Color ret = manager.getColor(COLOR_RTC_STATE_UNKNOWN);
+ if (ec instanceof CorbaExecutionContext) {
+ CorbaExecutionContext cec = (CorbaExecutionContext) ec;
+// LOGGER.info("getECBodyColor: ec={}", ec);
+// LOGGER.info("getECBodyColor: container={}", ec.eContainer());
+// LOGGER.info("getECBodyColor: owner={}", ec.getOwner());
+// LOGGER.info("getECBodyColor: participants={}", ec.getParticipants());
+ CorbaComponent comp = (CorbaComponent) ec.eContainer();
+ if (comp == null) {
+ comp = (CorbaComponent) ec.getOwner();
+ }
+ if (comp != null) {
+ int status = cec.getComponentState(comp);
+ if (status == ExecutionContext.RTC_ACTIVE) {
+ ret = manager.getColor(COLOR_RTC_STATE_ACTIVE);
+ } else if (status == ExecutionContext.RTC_CREATED) {
+ ret = manager.getColor(COLOR_RTC_STATE_CREATED);
+ } else if (status == ExecutionContext.RTC_ERROR) {
+ ret = manager.getColor(COLOR_RTC_STATE_ERROR);
+ } else if (status == ExecutionContext.RTC_INACTIVE) {
+ ret = manager.getColor(COLOR_RTC_STATE_INACTIVE);
+ } else if (status == ExecutionContext.RTC_UNKNOWN) {
+ ret = manager.getColor(COLOR_RTC_STATE_UNKNOWN);
+ } else if (status == ExecutionContext.RTC_UNCERTAIN) {
+ ret = manager.getColor(COLOR_RTC_STATE_UNCERTAIN);
+ }
+ }
+ }
+ return ret;
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ColorHelper.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/editor/editpart/ComponentEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ComponentEditPart.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ComponentEditPart.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -16,6 +15,8 @@
import jp.go.aist.rtm.systemeditor.ui.action.OpenCompositeComponentAction;
import jp.go.aist.rtm.systemeditor.ui.editor.AbstractSystemDiagramEditor;
import jp.go.aist.rtm.systemeditor.ui.editor.action.ChangeComponentDirectionAction;
+import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart.OwnEC;
+import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ECEditPart.PartEC;
import jp.go.aist.rtm.systemeditor.ui.editor.editpart.direct.NameCellEditorLocator;
import jp.go.aist.rtm.systemeditor.ui.editor.editpart.direct.NameDirectEditManager;
import jp.go.aist.rtm.systemeditor.ui.editor.editpolicy.ChangeDirectionEditPolicy;
@@ -52,23 +53,30 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* コンポーネントのEditPart
* <p>
* GEFの仕様では子供のEditPartは親のEditPartに含まれなければならないが、ポートをコンポーネントからはみ出して表示しなければならない。
- * これを満たしながら、一見コンポーネントの外にポートが出ているように見せるために、コンポーネントのボディのドローイングの範囲を狭めることで実現しているため、特殊な実装になっている。
+ * これを満たしながら、一見コンポーネントの外にポートが出ているように見せるために、コンポーネントのボディのドローイングの範囲を狭めることで実現しているため、
+ * 特殊な実装になっている。
*/
public class ComponentEditPart extends AbstractEditPart {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ComponentEditPart.class);
+
/** コンポーネントの周りとコンポーネントのボディまでのスペース(ポートあり) */
public static final int PORT_SPACE = 32;
/** コンポーネントの周りとコンポーネントのボディまでのスペース(ポートなし) */
- public static final int NONE_SPACE = 7;
+ public static final int NONE_SPACE = 16;
/** コンポーネントアイコンのサイズ */
public static final int ICON_SIZE = 16;
@@ -94,6 +102,8 @@
@Override
protected IFigure createFigure() {
+// LOGGER.trace("createFigure");
+
iconImage = ComponentIconStore.eINSTANCE.findImageByComp(getModel());
Figure result = new Panel() {
@@ -108,14 +118,18 @@
*/
@Override
protected void paintFigure(Graphics graphics) {
+// LOGGER.trace("paintFigure");
if (isOpaque()) {
- ComponentLayout cl = (ComponentLayout)this.getLayoutManager();
+ ComponentLayout cl = (ComponentLayout) this
+ .getLayoutManager();
Rectangle bound = new Rectangle(getBounds());
// ポートのある側のスペースを広くとる 2009.2.2
if (cl.isVerticalDirection()) {
- graphics.fillRectangle(bound.expand(-NONE_SPACE, -PORT_SPACE));
+ graphics.fillRectangle(bound.expand(-NONE_SPACE,
+ -PORT_SPACE));
} else {
- graphics.fillRectangle(bound.expand(-PORT_SPACE, -NONE_SPACE));
+ graphics.fillRectangle(bound.expand(-PORT_SPACE,
+ -NONE_SPACE));
}
Color saveForegroundColor = graphics.getForegroundColor();
@@ -171,17 +185,18 @@
public void mousePressed(MouseEvent me) {
if (me.button == 3) { // right click
IAction action = null;
- if (me.getState() == MouseEvent.SHIFT) {
+ if (me.getState() == SWT.SHIFT) {
action = getActionRegistry()
.getAction(
ChangeComponentDirectionAction.VERTICAL_DIRECTION_ACTION_ID);
- } else if (me.getState() == MouseEvent.CONTROL){
+ } else if (me.getState() == SWT.CONTROL) {
action = getActionRegistry()
.getAction(
ChangeComponentDirectionAction.HORIZON_DIRECTION_ACTION_ID);
}
- if (action != null) action.run();
+ if (action != null)
+ action.run();
}
}
});
@@ -198,7 +213,7 @@
componentLabel.setSize(30, 10);
getRoot().refresh();
-
+
return result;
}
@@ -211,14 +226,12 @@
}
};
- @SuppressWarnings("unchecked")
@Override
public void activate() {
+ LOGGER.trace("activate");
super.activate();
if (getModel().isCompositeComponent()) {
- for (Iterator iterator = getModel().getAllComponents().iterator(); iterator
- .hasNext();) {
- Component component = (Component) iterator.next();
+ for (Component component : getModel().getAllComponents()) {
component.eAdapters().add(this);
}
}
@@ -226,15 +239,13 @@
preferenceChangeListener);
}
- @SuppressWarnings("unchecked")
@Override
public void deactivate() {
+ LOGGER.trace("deactivate");
componentLabel.deactivate();
super.deactivate();
if (getModel().isCompositeComponent()) {
- for (Iterator iterator = getModel().getAllComponents().iterator(); iterator
- .hasNext();) {
- Component component = (Component) iterator.next();
+ for (Component component : getModel().getAllComponents()) {
component.eAdapters().remove(this);
}
}
@@ -254,14 +265,16 @@
@Override
protected void refreshVisuals() {
+ LOGGER.trace("refreshVisuals");
+
getFigure().setBackgroundColor(getNewBodyColor());
-
getFigure().setForegroundColor(getNewBorderColor());
jp.go.aist.rtm.toolscommon.model.core.Rectangle constraint = getModel()
.getConstraint();
- if (constraint == null) return;
-
+ if (constraint == null)
+ return;
+
Rectangle modelRec = Draw2dUtil.toDraw2dRectangle(constraint);
Rectangle newRectangle = modelRec.getCopy();
@@ -315,7 +328,7 @@
stateColor = this.getStateColor(component.getComponentState());
- } else if (getModel() instanceof ComponentSpecification){
+ } else if (getModel() instanceof ComponentSpecification) {
ComponentSpecification component = (ComponentSpecification) getModel();
if (component.inOnlineSystemDiagram()
@@ -342,8 +355,10 @@
stateColor = this.getStateColor(state);
} else {
- stateColor = SystemEditorPreferenceManager.getInstance().getColor(
- SystemEditorPreferenceManager.COLOR_RTC_STATE_INACTIVE);
+ stateColor = SystemEditorPreferenceManager
+ .getInstance()
+ .getColor(
+ SystemEditorPreferenceManager.COLOR_RTC_STATE_INACTIVE);
}
}
return stateColor;
@@ -379,37 +394,45 @@
return (Component) super.getModel();
}
- @SuppressWarnings("unchecked")
+ @Override
public void notifyChanged(Notification notification) {
+// LOGGER.trace("notifyChanged: feature=<{}>", notification.getFeature());
if (ComponentPackage.eINSTANCE.getComponent_Components().equals(
- notification.getFeature())) {
+ notification.getFeature())) {
if (notification.getEventType() == Notification.ADD) {
- Component component = (Component)notification.getNewValue();
+ Component component = (Component) notification.getNewValue();
component.eAdapters().add(this);
if (component.isCompositeComponent()) {
- for (Iterator iterator = component.getAllComponents()
- .iterator(); iterator.hasNext();) {
- ((Component) iterator.next()).eAdapters().add(this);
+ for (Component comp : component.getAllComponents()) {
+ comp.eAdapters().add(this);
}
}
- }else if (notification.getEventType() == Notification.REMOVE) {
- ((Component)notification.getOldValue()).eAdapters().remove(this);
+ } else if (notification.getEventType() == Notification.REMOVE) {
+ ((Component) notification.getOldValue()).eAdapters().remove(
+ this);
}
refreshComponent();
- ((SystemDiagramEditPart)getParent()).refreshSystemDiagram();
+ ((SystemDiagramEditPart) getParent()).refreshSystemDiagram();
+ } else if (ComponentPackage.eINSTANCE
+ .getCorbaComponent_RTCComponentProfile().equals(
+ notification.getFeature())) {
+ // コンポーネントの状態通知 (featureは仮)
+ refreshComponent();
} else if (CorePackage.eINSTANCE.getModelElement_Constraint().equals(
- notification.getFeature())
- || ComponentPackage.eINSTANCE.getCorbaComponent_ComponentState()
+ notification.getFeature())
+ || ComponentPackage.eINSTANCE
+ .getComponent_PrimaryExecutionContext().equals(
+ notification.getFeature())
+ || ComponentPackage.eINSTANCE.getComponent_ExecutionContexts()
.equals(notification.getFeature())
|| ComponentPackage.eINSTANCE
- .getCorbaComponent_ExecutionContextState().equals(
+ .getComponent_ParticipationContexts().equals(
notification.getFeature())
- || ComponentPackage.eINSTANCE
- .getComponent_OutportDirection().equals(
- notification.getFeature())){
- refreshComponent();
- } else if (ComponentPackage.eINSTANCE.getComponent_Ports()
+ || ComponentPackage.eINSTANCE.getComponent_OutportDirection()
.equals(notification.getFeature())) {
+ refreshComponent();
+ } else if (ComponentPackage.eINSTANCE.getComponent_Ports().equals(
+ notification.getFeature())) {
refreshComponent2();
} else if (ComponentPackage.eINSTANCE.getComponent_InstanceNameL()
.equals(notification.getFeature())) {
@@ -416,12 +439,13 @@
if (notification.getEventType() == Notification.SET) {
componentLabel.setText(notification.getNewStringValue());
}
- }else if (getModel() instanceof ComponentSpecification) {
+ } else if (getModel() instanceof ComponentSpecification) {
refreshComponent();
}
}
private void refreshComponent() {
+ LOGGER.trace("refreshComponent");
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
@@ -435,6 +459,7 @@
}
private void refreshComponent2() {
+ LOGGER.trace("refreshComponent2");
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
@@ -446,53 +471,48 @@
}
}
- @SuppressWarnings("unchecked")
private void refreshChildren2() {
- int i;
- EditPart editPart;
- Object model;
+ LOGGER.trace("refreshChildren2");
+ Map<Object, EditPart> modelToEditPart = new HashMap<>();
+ List<?> children = getChildren();
- Map modelToEditPart = new HashMap();
- List children = getChildren();
-
- for (i = 0; i < children.size(); i++) {
- editPart = (EditPart)children.get(i);
+ for (Object o : children) {
+ EditPart editPart = (EditPart) o;
modelToEditPart.put(editPart.getModel(), editPart);
}
- List modelObjects = getModelChildren();
-
+ List<?> modelObjects = getModelChildren();
+ int i;
for (i = 0; i < modelObjects.size(); i++) {
- model = modelObjects.get(i);
+ Object model = modelObjects.get(i);
EditPart ep = (EditPart) children.get(i);
- //Do a quick check to see if editPart[i] == model[i]
- if (i < children.size()
- && ep.getModel() == model) {
+ // Do a quick check to see if editPart[i] == model[i]
+ if (i < children.size() && ep.getModel() == model) {
ep.refresh();
- continue;
+ continue;
}
+ // Look to see if the EditPart is already around but in the
+ // wrong location
+ EditPart editPart = (EditPart) modelToEditPart.get(model);
- //Look to see if the EditPart is already around but in the wrong location
- editPart = (EditPart)modelToEditPart.get(model);
-
- if (editPart != null)
- reorderChild (editPart, i);
- else {
- //An editpart for this model doesn't exist yet. Create and insert one.
+ if (editPart != null) {
+ reorderChild(editPart, i);
+ } else {
+ // An editpart for this model doesn't exist yet. Create
+ // and insert one.
editPart = createChild(model);
addChild(editPart, i);
}
}
- List trash = new ArrayList();
- for (; i < children.size(); i++)
- trash.add(children.get(i));
- for (i = 0; i < trash.size(); i++) {
- EditPart ep = (EditPart)trash.get(i);
+ List<EditPart> trash = new ArrayList<>();
+ for (; i < children.size(); i++) {
+ trash.add((EditPart) children.get(i));
+ }
+ for (EditPart ep : trash) {
removeChild(ep);
}
}
-
- @SuppressWarnings("unchecked")
+
private void refreshChildDiagram() {
// 複合RTCエディタ内の子RTCのポート再描画
SystemDiagram diagram = getModel().getChildSystemDiagram();
@@ -499,16 +519,16 @@
if (diagram != null) {
AbstractSystemDiagramEditor editor = ComponentUtil
.findEditor(diagram);
- if (editor == null) return;
- for (Object o : editor.getSystemDiagram().getComponents()) {
- if (!(o instanceof Component))
- continue;
- Component ac = (Component) o;
+ if (editor == null)
+ return;
+ for (Component ac : editor.getSystemDiagram()
+ .getComponents()) {
EditPart ep = editor.findEditPart(ac);
if (!(ep instanceof ComponentEditPart))
continue;
ComponentEditPart cep = (ComponentEditPart) ep;
- List childList = new ArrayList(cep.getChildren());
+ @SuppressWarnings("unchecked")
+ List<?> childList = new ArrayList<>(cep.getChildren());
for (Object o2 : childList) {
if (!(o2 instanceof PortEditPart))
continue;
@@ -522,10 +542,10 @@
}
/** ポート公開/非公開時にPortEditPartを更新します */
- @SuppressWarnings("unchecked")
public void refreshPortEditPart(final PortEditPart portPart) {
+ LOGGER.trace("refreshPortEditPart: port={}", portPart);
Object model = portPart.getModel();
- List children = getModelChildren();
+ List<?> children = getModelChildren();
int index = children.indexOf(model);
setFocus(false);
@@ -543,15 +563,22 @@
});
}
- @SuppressWarnings("unchecked")
@Override
- protected List getModelChildren() {
- List result = new ArrayList();
+ protected List<?> getModelChildren() {
+ List<Object> result = new ArrayList<>();
// 複合コンポーネントに直接属するポートだけを表示させる 2008.11.26
+ result.addAll(getModel().getOutports());
+ //
result.addAll(getModel().getInports());
- result.addAll(getModel().getOutports());
result.addAll(getModel().getServiceports());
-
+ //
+ for (ExecutionContext ec : getModel().getExecutionContexts()) {
+ result.add(new OwnEC(ec));
+ }
+ //
+ for (ExecutionContext ec : getModel().getParticipationContexts()) {
+ result.add(new PartEC(ec));
+ }
return result;
}
@@ -580,8 +607,8 @@
IAction action = getActionRegistry().getAction(
OpenCompositeComponentAction.ACTION_ID);
OpenCompositeComponentAction openAction = new OpenCompositeComponentAction(
- ((OpenCompositeComponentAction) action)
- .getParentSystemDiagramEditor());
+ ((OpenCompositeComponentAction) action)
+ .getParentSystemDiagramEditor());
openAction.setCompositeComponent(getModel());
openAction.run();
}
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ECEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ECEditPart.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ECEditPart.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,298 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.editpart;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.systemeditor.ui.editor.editpolicy.ECSelectionEditPolicy;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.ECFigure;
+import jp.go.aist.rtm.toolscommon.model.component.ComponentPackage;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaExecutionContext;
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.ui.PlatformUI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ECの EditPartを表します。
+ *
+ * @param <F>
+ */
+public abstract class ECEditPart<F extends IFigure> extends AbstractEditPart
+ implements NodeEditPart {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ECEditPart.class);
+
+ public ECEditPart(ActionRegistry actionRegistry) {
+ super(actionRegistry);
+ LOGGER.trace("new: actionRegistry=<{}>", actionRegistry);
+ }
+
+ @Override
+ public abstract ExecutionContext getModel();
+
+ protected Object getWrappedModel() {
+ return super.getModel();
+ }
+
+ @Override
+ protected void createEditPolicies() {
+ LOGGER.trace("createEditPolicies");
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
+ new ECSelectionEditPolicy());
+ }
+
+ @Override
+ public IFigure getFigure() {
+ if (this.invalid) {
+ setInvalid(false);
+ IFigure newFig = createFigure();
+ if (newFig != this.figure) {
+ newFig.setParent(this.figure.getParent());
+ }
+ setFigure(newFig);
+ return this.figure;
+ }
+ return super.getFigure();
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ getFigure().setBackgroundColor(ColorHelper.getECBodyColor(getModel()));
+ getFigure()
+ .setForegroundColor(ColorHelper.getECBorderColor(getModel()));
+ getFigure().setToolTip(ToolTipHelper.getECToolTip(getModel()));
+ }
+
+ private boolean invalid = false;
+
+ public void setInvalid(boolean invalid) {
+ this.invalid = invalid;
+ }
+
+ /**
+ * 設定マネージャを監視するリスナ
+ */
+ PropertyChangeListener preferenceChangeListener = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ refreshVisuals();
+ }
+ };
+
+ @Override
+ public void activate() {
+ LOGGER.trace("activate");
+ super.activate();
+ SystemEditorPreferenceManager.getInstance().addPropertyChangeListener(
+ preferenceChangeListener);
+ }
+
+ @Override
+ public void deactivate() {
+ LOGGER.trace("deactivate");
+ super.deactivate();
+ SystemEditorPreferenceManager.getInstance()
+ .removePropertyChangeListener(preferenceChangeListener);
+ }
+
+ /**
+ * Owned EC の EditPart
+ */
+ public static class OwnECEditPart extends ECEditPart<ECFigure.OwnECFigure> {
+
+ public OwnECEditPart(ActionRegistry actionRegistry) {
+ super(actionRegistry);
+ }
+
+ @Override
+ public ExecutionContext getModel() {
+ return (ExecutionContext) ((ECEditPart.OwnEC) super
+ .getWrappedModel()).getModel();
+ }
+
+ @Override
+ protected IFigure createFigure() {
+ LOGGER.trace("createFigure");
+
+ IFigure result = new ECFigure.OwnECFigure(getModel());
+
+ // 代表の ECの場合は選択中として描画 (仮)
+ CorbaComponent comp = (CorbaComponent) getModel().eContainer();
+ if (comp != null) {
+ CorbaExecutionContext cec = (CorbaExecutionContext) getModel();
+ if (cec == comp.getPrimaryExecutionContext()) {
+ result = new ECFigure.SelectedOwnECFigure(getModel());
+ }
+ }
+
+ result.setLocation(new Point(0, 0));
+
+ return result;
+ }
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connection) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connection) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (ComponentPackage.eINSTANCE.getExecutionContext_StateL().equals(
+ notification.getFeature())) {
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (isActive()) {
+ refreshVisuals();
+ }
+ }
+ });
+ }
+ }
+
+ }
+
+ /**
+ * Participant ECの EditPartを表します。
+ */
+ public static class PartECEditPart extends
+ ECEditPart<ECFigure.PartECFigure> {
+
+ public PartECEditPart(ActionRegistry actionRegistry) {
+ super(actionRegistry);
+ }
+
+ @Override
+ public ExecutionContext getModel() {
+ return (ExecutionContext) ((ECEditPart.PartEC) super
+ .getWrappedModel()).getModel();
+ }
+
+ @Override
+ protected IFigure createFigure() {
+ LOGGER.trace("createFigure");
+
+ IFigure result = new ECFigure.PartECFigure(getModel());
+
+ result.setLocation(new Point(0, 0));
+ return result;
+ }
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connection) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connection) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (ComponentPackage.eINSTANCE.getExecutionContext_StateL().equals(
+ notification.getFeature())) {
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (isActive()) {
+ refreshVisuals();
+ }
+ }
+ });
+ }
+ }
+
+ }
+
+ /**
+ * Owned ECのモデルのラッパを表します。<br>
+ * ※モデル上は Owned/Participantの ECに違いはなく、Componentの関連によって決まるが、 モデルと
+ * EditPartの対応付けで別クラスにする必要があり、ここでラップクラスを設けます。
+ */
+ public static class OwnEC {
+
+ private ExecutionContext ec;
+
+ public OwnEC(ExecutionContext ec) {
+ this.ec = ec;
+ }
+
+ public ExecutionContext getModel() {
+ return this.ec;
+ }
+
+ }
+
+ /**
+ * Participant ECのモデルのラッパを表します。<br>
+ * ※モデル上は Owned/Participantの ECに違いはなく、Componentの関連によって決まるが、 モデルと
+ * EditPartの対応付けで別クラスにする必要があり、ここでラップクラスを設けます。
+ */
+ public static class PartEC {
+
+ private ExecutionContext ec;
+
+ public PartEC(ExecutionContext ec) {
+ this.ec = ec;
+ }
+
+ public ExecutionContext getModel() {
+ return this.ec;
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ECEditPart.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ToolTipHelper.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ToolTipHelper.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ToolTipHelper.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,58 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.editpart;
+
+import jp.go.aist.rtm.toolscommon.model.component.CorbaComponent;
+import jp.go.aist.rtm.toolscommon.model.component.CorbaExecutionContext;
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.Panel;
+import org.eclipse.draw2d.StackLayout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ツールチップ作成ヘルパー
+ */
+public class ToolTipHelper {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ToolTipHelper.class);
+
+ private static final String CRLF = "\r\n";
+
+ /**
+ * ECのツールチップを取得します。
+ *
+ * @param ec
+ * @return
+ */
+ public static Panel getECToolTip(ExecutionContext ec) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("kind: ").append(nv(ec.getKindName())).append(CRLF);
+ sb.append("rate: ").append(nv(ec.getRateL())).append(CRLF);
+ sb.append("state: ").append(nv(ec.getStateName()));
+ if (ec instanceof CorbaExecutionContext) {
+ CorbaExecutionContext cec = (CorbaExecutionContext) ec;
+ CorbaComponent comp = (CorbaComponent) ec.eContainer();
+ if (comp != null) {
+ sb.append(CRLF);
+ sb.append("component state: ").append(
+ nv(cec.getComponentStateName(comp)));
+ }
+ }
+ return buildPanel(sb.toString());
+ }
+
+ private static Panel buildPanel(String label) {
+ Panel ret = new Panel();
+ ret.setLayoutManager(new StackLayout());
+ Label label1 = new Label(label);
+ ret.add(label1);
+ return ret;
+ }
+
+ private static String nv(Object s) {
+ return s == null ? "<unknown>" : s.toString();
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ToolTipHelper.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/ECSelectionEditPolicy.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/ECSelectionEditPolicy.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/ECSelectionEditPolicy.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,36 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.editpolicy;
+
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+
+import org.eclipse.gef.editpolicies.SelectionEditPolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class ECSelectionEditPolicy extends SelectionEditPolicy {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ECSelectionEditPolicy.class);
+
+ @Override
+ protected void hideSelection() {
+ LOGGER.info("hideSelection: host={} model={}", getHost(), getHost().getModel());
+
+ }
+
+ @Override
+ protected void showSelection() {
+ LOGGER.info("showSelection: host={} model={}", getHost(), getHost().getModel());
+
+ ExecutionContext ec = (ExecutionContext) getHost().getModel();
+ Component comp = (Component) ec.eContainer();
+
+ if (comp != null) {
+ comp.setPrimaryExecutionContext(ec);
+ }
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/ECSelectionEditPolicy.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentChildFigure.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentChildFigure.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentChildFigure.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,89 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.figure;
+
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * コンポーネントの子要素の Figure
+ */
+public abstract class ComponentChildFigure extends PolygonDecoration {
+
+ private String direction;
+
+ protected void init() {
+ setScale(1.0, 1.0);
+ setFill(true);
+ }
+
+ /**
+ * 方向を取得する
+ *
+ * @return 方向
+ */
+ public String getDirection() {
+ return direction;
+ }
+
+ /**
+ * 方向を設定する
+ *
+ * @param direction
+ * 方向
+ */
+ public void setDirection(String direction) {
+ this.direction = direction;
+ double rotation = getRotation(direction);
+ setRotation(rotation);
+ }
+
+ /**
+ * 回転角度を算出します
+ *
+ * @param direction
+ * @return
+ */
+ protected double getRotation(String direction) {
+ double ret = 0;
+ if (direction.equals(Component.OUTPORT_DIRECTION_RIGHT_LITERAL)) {
+ ret = 0;
+ } else if (direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL)) {
+ ret = Math.PI / 2;
+ } else if (direction.equals(Component.OUTPORT_DIRECTION_LEFT_LITERAL)) {
+ ret = Math.PI;
+ } else if (direction.equals(Component.OUTPORT_DIRECTION_UP_LITERAL)) {
+ ret = Math.PI * 3 / 2;
+ }
+ return ret;
+ }
+
+ @Override
+ public void setLocation(Point p) {
+ super.setLocation(p);
+ fireFigureMoved();
+ }
+
+ public Rectangle getBaseBounds() {
+ return (getParent() != null) ? getParent().getBounds()
+ : new Rectangle();
+ }
+
+ /**
+ * 子要素のスタイル定義を表します。
+ */
+ public static class FigureStyle {
+
+ public final Color bg;
+ public final Color fg;
+
+ FigureStyle(Color bg, Color fg) {
+ this.bg = bg;
+ this.fg = fg;
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentChildFigure.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/editor/figure/ComponentLayout.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ComponentLayout.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -1,6 +1,11 @@
package jp.go.aist.rtm.systemeditor.ui.editor.figure;
-import java.util.Iterator;
+import static jp.go.aist.rtm.toolscommon.model.component.Component.OUTPORT_DIRECTION_DOWN_LITERAL;
+import static jp.go.aist.rtm.toolscommon.model.component.Component.OUTPORT_DIRECTION_LEFT_LITERAL;
+import static jp.go.aist.rtm.toolscommon.model.component.Component.OUTPORT_DIRECTION_RIGHT_LITERAL;
+import static jp.go.aist.rtm.toolscommon.model.component.Component.OUTPORT_DIRECTION_UP_LITERAL;
+import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.XYLayout;
@@ -7,10 +12,9 @@
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import jp.go.aist.rtm.systemeditor.ui.editor.editpart.ComponentEditPart;
-import jp.go.aist.rtm.toolscommon.model.component.Component;
-
/**
* コンポーネントFigureの内部で使用されるレイアウト
* <p>
@@ -18,14 +22,18 @@
*/
public class ComponentLayout extends XYLayout {
- private static final int MIN_WIDTH = 60;
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ComponentLayout.class);
+
+ private static final int MIN_WIDTH = 25;
private static final int MIN_HEIGHT = 25;
- private static final int MIN_Component_INTERBAL = 22;
+ private static final int MIN_Component_INTERVAL = 22;
- private static final Class<?>[] OUTPUT_CLASSES = new Class[] { OutPortFigure.class, ServicePortFigure.class };
+ private OutPortLayouter outportLayouter;
+ private InPortLayouter inportLayouter;
+ private OwnECLayouter ownEcLayouter;
+ private PartECLayouter partEcLayouter;
- private static final Class<?>[] OUTPUT_180_CLASSES = new Class[] { InPortFigure.class };
-
private Component component;
/**
@@ -36,15 +44,39 @@
*/
public ComponentLayout(Component component) {
this.component = component;
+ //
+ this.outportLayouter = new OutPortLayouter(this);
+ this.inportLayouter = new InPortLayouter(this);
+ this.ownEcLayouter = new OwnECLayouter(this);
+ this.partEcLayouter = new PartECLayouter(this);
}
+ public Component getComponent() {
+ return this.component;
+ }
+
+ public ChildLayouter getChildLayouter(IFigure child) {
+ ChildLayouter layouter = null;
+ if (this.outportLayouter.isAssignable(child.getClass())) {
+ layouter = this.outportLayouter;
+ } else if (this.inportLayouter.isAssignable(child.getClass())) {
+ layouter = this.inportLayouter;
+ } else if (this.ownEcLayouter.isAssignable(child.getClass())) {
+ layouter = this.ownEcLayouter;
+ } else if (this.partEcLayouter.isAssignable(child.getClass())) {
+ layouter = this.partEcLayouter;
+ }
+ return layouter;
+ }
+
@Override
public void layout(IFigure parent) {
- Iterator<?> children = parent.getChildren().iterator();
- IFigure child;
- while (children.hasNext()) {
- child = (IFigure) children.next();
- Rectangle bounds = getLocation(parent, child);
+ for (Object o : parent.getChildren()) {
+ IFigure child = (IFigure) o;
+
+ ChildLayouter layouter = getChildLayouter(child);
+ Rectangle bounds = layouter.getLocation(parent, child);
+
child.setLocation(new Point(bounds.x, bounds.y));
child.setBounds(child.getBounds());
parent.setBounds(parent.getBounds());
@@ -58,99 +90,328 @@
|| direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL);
}
- private Rectangle getLocation(IFigure parent, IFigure child) {
- Rectangle bounds = child.getBounds().getCopy();
- Point offset = getOrigin(parent);
+ /**
+ * 子要素のレイアウト処理を表します。
+ */
+ public static abstract class ChildLayouter {
- Rectangle clientArea = parent.getClientArea();
- String direction = getDirection(child.getClass(), component.getOutportDirection());
+ protected ComponentLayout layout;
- Class<?>[] figureClass = null;
- if (isAssignable(child.getClass(), OUTPUT_180_CLASSES)) {
- figureClass = OUTPUT_180_CLASSES;
- } else if (isAssignable(child.getClass(), OUTPUT_CLASSES)) {
- figureClass = OUTPUT_CLASSES;
+ public ChildLayouter(ComponentLayout layout) {
+ this.layout = layout;
}
- // ポートの描画位置へのオフセット 2009.2.2
- int portOffset = ComponentEditPart.PORT_SPACE - 2;
- int portNumber = getTargetOccurenceNumber(parent, child, figureClass);
+ /**
+ * 対象の子要素のクラスを取得します。
+ *
+ * @return
+ */
+ public abstract Class<?>[] getTargetClasses();
- if (direction.equals(Component.OUTPORT_DIRECTION_LEFT_LITERAL)) {
- bounds.x = clientArea.x + portOffset;
- bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
- + MIN_Component_INTERBAL * (portNumber - 1);
- } else if (direction.equals(Component.OUTPORT_DIRECTION_RIGHT_LITERAL)) {
- bounds.x = clientArea.x + clientArea.width - portOffset;
- bounds.y = clientArea.y + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
- + MIN_Component_INTERBAL * (portNumber - 1);
- } else if (direction.equals(Component.OUTPORT_DIRECTION_UP_LITERAL)) {
- bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
- + MIN_Component_INTERBAL * (portNumber - 1);
- bounds.y = clientArea.y + portOffset;
- } else if (direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL)) {
- bounds.x = clientArea.x + ComponentEditPart.NONE_SPACE + (MIN_HEIGHT / 2)
- + MIN_Component_INTERBAL * (portNumber - 1);
- bounds.y = clientArea.y + clientArea.height - portOffset;
+ /**
+ * 子要素の向きを取得します。
+ *
+ * @return
+ */
+ public abstract String getChildDirection();
+
+ /**
+ * 子要素の配置スペックを取得します。
+ *
+ * @return
+ */
+ public abstract Spec getSpec();
+
+ /**
+ * ベースとなる親要素の向きを表します。
+ *
+ * @return
+ */
+ public String getParentDirection() {
+ return this.layout.getComponent().getOutportDirection();
}
- ((PortFigure) child).setDirection(direction);
- bounds = bounds.getTranslated(offset);
- return bounds;
- }
+ /**
+ * 子要素の順番を取得します。
+ */
+ public int getChildIndex(IFigure parent, IFigure child) {
+ int count = 0;
+ for (Object o : parent.getChildren()) {
+ IFigure fig = (IFigure) o;
+ if (child == fig) {
+ ++count;
+ break;
+ }
+ if (isAssignable(fig.getClass())) {
+ ++count;
+ }
+ }
+ return count;
+ }
- private String getDirection(Class<? extends IFigure> clazz, String outportDirection) {
- if (isAssignable(clazz, OUTPUT_CLASSES)) {
- return outportDirection;
- } else if (isAssignable(clazz, OUTPUT_180_CLASSES)) {
- if (Component.OUTPORT_DIRECTION_RIGHT_LITERAL.equals(outportDirection)) {
- return Component.OUTPORT_DIRECTION_LEFT_LITERAL;
- } else if (Component.OUTPORT_DIRECTION_LEFT_LITERAL.equals(outportDirection)) {
- return Component.OUTPORT_DIRECTION_RIGHT_LITERAL;
- } else if (Component.OUTPORT_DIRECTION_UP_LITERAL.equals(outportDirection)) {
- return Component.OUTPORT_DIRECTION_DOWN_LITERAL;
- } else if (Component.OUTPORT_DIRECTION_DOWN_LITERAL.equals(outportDirection)) {
- return Component.OUTPORT_DIRECTION_UP_LITERAL;
+ /**
+ * 子要素の数を取得します。
+ *
+ * @param parent
+ * @return
+ */
+ public int getChildCount(IFigure parent) {
+ int count = 0;
+ for (Object o : parent.getChildren()) {
+ IFigure child = (IFigure) o;
+ if (isAssignable(child.getClass())) {
+ ++count;
+ }
}
+ return count;
}
- return Component.OUTPORT_DIRECTION_RIGHT_LITERAL;
+
+ /**
+ * 子要素の配置を算出します。
+ *
+ * @param parent
+ * @param child
+ * @return
+ */
+ public Rectangle getLocation(IFigure parent, IFigure child) {
+ LOGGER.trace("getLocation: parent={} child={}", parent.getClass(),
+ child.getClass());
+
+ Rectangle bounds = child.getBounds().getCopy();
+ Point offset = this.layout.getOrigin(parent);
+
+ Rectangle clientArea = parent.getClientArea();
+ String direction = getChildDirection();
+
+ int childIndex = getChildIndex(parent, child);
+
+ Spec spec = getSpec();
+ LOGGER.trace(
+ "getLocation: bounds={} offset={} client={} childDirection={} h_spase={} v_space={}",
+ bounds, offset, clientArea, direction, spec.h_space,
+ spec.v_space);
+
+ if (direction.equals(OUTPORT_DIRECTION_LEFT_LITERAL)) {
+ // 子要素:左向き
+ bounds.x = clientArea.x + spec.h_space;
+ bounds.y = clientArea.y + spec.v_space + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERVAL * (childIndex - 1);
+ } else if (direction.equals(OUTPORT_DIRECTION_RIGHT_LITERAL)) {
+ // 子要素:右向き
+ bounds.x = clientArea.x + clientArea.width - spec.h_space;
+ bounds.y = clientArea.y + spec.v_space + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERVAL * (childIndex - 1);
+ } else if (direction.equals(OUTPORT_DIRECTION_UP_LITERAL)) {
+ // 子要素:上向き
+ bounds.x = clientArea.x + spec.v_space + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERVAL * (childIndex - 1);
+ bounds.y = clientArea.y + spec.h_space;
+ } else if (direction.equals(OUTPORT_DIRECTION_DOWN_LITERAL)) {
+ // 子要素:下向き
+ bounds.x = clientArea.x + spec.v_space + (MIN_HEIGHT / 2)
+ + MIN_Component_INTERVAL * (childIndex - 1);
+ bounds.y = clientArea.y + clientArea.height - spec.h_space;
+ }
+
+ ((ComponentChildFigure) child).setDirection(direction);
+ bounds = bounds.getTranslated(offset);
+ return bounds;
+ }
+
+ /**
+ * 対象の子要素かを判定します。
+ *
+ * @param target
+ * @return
+ */
+ public boolean isAssignable(Class<?> target) {
+ for (Class<?> tmp : getTargetClasses()) {
+ if (tmp.isAssignableFrom(target)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 配置のスペックを表します。
+ */
+ public static class Spec {
+ int h_space;
+ int v_space;
+ }
+
}
- private int getAllOccurenceCount(IFigure parent, Class[] targetClasses) {
- int count = 0;
- for (Iterator<?> iter = parent.getChildren().iterator(); iter.hasNext();) {
- IFigure child = (IFigure) iter.next();
- if (isAssignable(child.getClass(), targetClasses)) {
- ++count;
+ /**
+ * 出力ポートの配置を表します。
+ */
+ public static class OutPortLayouter extends ChildLayouter {
+
+ public static final Class<?>[] CLASSES = new Class[] {
+ OutPortFigure.class, ServicePortFigure.class };
+
+ public OutPortLayouter(ComponentLayout layout) {
+ super(layout);
+ }
+
+ @Override
+ public Class<?>[] getTargetClasses() {
+ return CLASSES;
+ }
+
+ @Override
+ public String getChildDirection() {
+ return getParentDirection();
+ }
+
+ @Override
+ public Spec getSpec() {
+ Spec ret = new Spec();
+ ret.h_space = ComponentEditPart.PORT_SPACE - 2;
+ ret.v_space = ComponentEditPart.NONE_SPACE;
+ return ret;
+ }
+
+ }
+
+ /**
+ * 入力ポートの配置を表します。(サービスポート含む)
+ */
+ public static class InPortLayouter extends ChildLayouter {
+
+ public static final Class<?>[] CLASSES = new Class[] { InPortFigure.class };
+
+ public InPortLayouter(ComponentLayout layout) {
+ super(layout);
+ }
+
+ @Override
+ public Class<?>[] getTargetClasses() {
+ return CLASSES;
+ }
+
+ @Override
+ public String getChildDirection() {
+ String parentDirection = getParentDirection();
+ if (OUTPORT_DIRECTION_RIGHT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_LEFT_LITERAL;
+ } else if (OUTPORT_DIRECTION_LEFT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_RIGHT_LITERAL;
+ } else if (OUTPORT_DIRECTION_UP_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_DOWN_LITERAL;
+ } else if (OUTPORT_DIRECTION_DOWN_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_UP_LITERAL;
}
+ return OUTPORT_DIRECTION_LEFT_LITERAL;
}
- return count;
+
+ @Override
+ public Spec getSpec() {
+ Spec ret = new Spec();
+ ret.h_space = ComponentEditPart.PORT_SPACE - 2;
+ ret.v_space = ComponentEditPart.NONE_SPACE;
+ return ret;
+ }
+
}
- private int getTargetOccurenceNumber(IFigure parent, IFigure target, Class<?>[] targetClasses) {
- int count = 0;
- for (Iterator<?> iter = parent.getChildren().iterator(); iter.hasNext();) {
- IFigure child = (IFigure) iter.next();
- if (child == target) {
- ++count;
- break;
+ /**
+ * Owned ECの配置を表します。
+ */
+ public static class OwnECLayouter extends ChildLayouter {
+
+ public static final Class<?>[] CLASSES = new Class[] { ECFigure.OwnECFigure.class };
+
+ public OwnECLayouter(ComponentLayout layout) {
+ super(layout);
+ }
+
+ @Override
+ public Class<?>[] getTargetClasses() {
+ return CLASSES;
+ }
+
+ @Override
+ public String getChildDirection() {
+ String parentDirection = getParentDirection();
+ if (OUTPORT_DIRECTION_RIGHT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_DOWN_LITERAL;
+ } else if (OUTPORT_DIRECTION_LEFT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_UP_LITERAL;
+ } else if (OUTPORT_DIRECTION_UP_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_RIGHT_LITERAL;
+ } else if (OUTPORT_DIRECTION_DOWN_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_LEFT_LITERAL;
}
- if (isAssignable(child.getClass(), targetClasses)) {
- ++count;
- }
+ return OUTPORT_DIRECTION_DOWN_LITERAL;
}
- return count;
+
+ @Override
+ public Spec getSpec() {
+ Spec ret = new Spec();
+ ret.h_space = ComponentEditPart.NONE_SPACE;
+ ret.v_space = ComponentEditPart.PORT_SPACE;
+ return ret;
+ }
+
}
/**
- * {@inheritDoc}
+ * Participant ECの配置を表します。
*/
+ public static class PartECLayouter extends ChildLayouter {
+
+ public static final Class<?>[] CLASSES = new Class[] { ECFigure.PartECFigure.class };
+
+ public PartECLayouter(ComponentLayout layout) {
+ super(layout);
+ }
+
+ @Override
+ public Class<?>[] getTargetClasses() {
+ return CLASSES;
+ }
+
+ @Override
+ public String getChildDirection() {
+ String parentDirection = getParentDirection();
+ if (OUTPORT_DIRECTION_RIGHT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_UP_LITERAL;
+ } else if (OUTPORT_DIRECTION_LEFT_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_DOWN_LITERAL;
+ } else if (OUTPORT_DIRECTION_UP_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_LEFT_LITERAL;
+ } else if (OUTPORT_DIRECTION_DOWN_LITERAL.equals(parentDirection)) {
+ return OUTPORT_DIRECTION_RIGHT_LITERAL;
+ }
+ return OUTPORT_DIRECTION_UP_LITERAL;
+ }
+
+ @Override
+ public Spec getSpec() {
+ Spec ret = new Spec();
+ ret.h_space = ComponentEditPart.NONE_SPACE;
+ ret.v_space = ComponentEditPart.PORT_SPACE;
+ return ret;
+ }
+
+ }
+
@Override
public Dimension getMinimumSize(IFigure container, int wHint, int hHint) {
- int count = Math.max(getAllOccurenceCount(container, OUTPUT_180_CLASSES),
- getAllOccurenceCount(container, OUTPUT_CLASSES));
- int height = ComponentEditPart.NONE_SPACE * 2 + MIN_HEIGHT + MIN_Component_INTERBAL * (count - 1);
- int width = 111;
+ int portCount = Math.max(this.outportLayouter.getChildCount(container),
+ this.inportLayouter.getChildCount(container));
+ int ecCount = Math.max(this.ownEcLayouter.getChildCount(container),
+ this.partEcLayouter.getChildCount(container));
+
+ int height = ComponentEditPart.NONE_SPACE * 2 + MIN_HEIGHT
+ + MIN_Component_INTERVAL * (portCount - 1);
+ int width = ComponentEditPart.PORT_SPACE * 2 + MIN_WIDTH
+ + MIN_Component_INTERVAL * (ecCount - 1);
+
+ width = Math.max(width, 111);
+
Dimension result = new Dimension();
if (isVerticalDirection()) {
result.height = Math.max(width, MIN_WIDTH);
@@ -163,23 +424,6 @@
}
/**
- * 対象クラスがclassesに含まれているかどうか
- *
- * @param target
- * @param classes
- */
- private boolean isAssignable(Class<?> target, Class<?>[] classes) {
- boolean result = false;
- for (Class<?> tmp : classes) {
- if (tmp.isAssignableFrom(target)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- /**
* {@inheritDoc}
*/
@Override
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ECFigure.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ECFigure.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ECFigure.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,99 @@
+package jp.go.aist.rtm.systemeditor.ui.editor.figure;
+
+import jp.go.aist.rtm.toolscommon.model.component.ExecutionContext;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.geometry.PointList;
+
+/**
+ * ECの Figureを表します。
+ */
+public class ECFigure extends ComponentChildFigure {
+
+ /** ECの描画テンプレート */
+ public static final PointList P_EC;
+
+ /** 選択中 ECの描画テンプレート */
+ public static final PointList P_EC_SELECTED;
+
+ /** 自ECのスタイル */
+ public static final FigureStyle S_OWN;
+ /** 部分ECのスタイル */
+ public static final FigureStyle S_PART;
+
+ static {
+ PointList p = new PointList(4);
+ p.addPoint(4, -6);
+ p.addPoint(14, -6);
+ p.addPoint(14, 6);
+ p.addPoint(4, 6);
+ P_EC = p;
+
+ p = new PointList(4);
+ p.addPoint(0, -6);
+ p.addPoint(14, -6);
+ p.addPoint(14, 6);
+ p.addPoint(0, 6);
+ P_EC_SELECTED = p;
+
+ S_OWN = new FigureStyle(ColorConstants.darkBlue, ColorConstants.red);
+ S_PART = new FigureStyle(ColorConstants.darkBlue, ColorConstants.red);
+ }
+
+ public ECFigure(ExecutionContext ec) {
+ init();
+
+ // TODO
+ setBackgroundColor(ECFigure.S_OWN.bg);
+ setForegroundColor(ECFigure.S_OWN.fg);
+ }
+
+ /**
+ * Owned ECの Figureを表します。
+ */
+ public static class OwnECFigure extends ECFigure {
+
+ public OwnECFigure(ExecutionContext ec) {
+ super(ec);
+ setTemplate(P_EC);
+ }
+
+ }
+
+ /**
+ * Participant ECの Figureを表します。
+ */
+ public static class PartECFigure extends ECFigure {
+
+ public PartECFigure(ExecutionContext ec) {
+ super(ec);
+ setTemplate(P_EC);
+ }
+
+ }
+
+ /**
+ * 選択中の Owned ECの Figureを表します。
+ */
+ public static class SelectedOwnECFigure extends OwnECFigure {
+
+ public SelectedOwnECFigure(ExecutionContext ec) {
+ super(ec);
+ setTemplate(P_EC_SELECTED);
+ }
+
+ }
+
+ /**
+ * 選択中の Participant ECの Figureを表します。
+ */
+ public static class SelectedPartECFigure extends PartECFigure {
+
+ public SelectedPartECFigure(ExecutionContext ec) {
+ super(ec);
+ setTemplate(P_EC_SELECTED);
+ }
+
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/ECFigure.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/editor/figure/PortFigure.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/PortFigure.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/figure/PortFigure.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -1,22 +1,18 @@
package jp.go.aist.rtm.systemeditor.ui.editor.figure;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+import jp.go.aist.rtm.toolscommon.model.component.Port;
+
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Panel;
-import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.StackLayout;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.graphics.Color;
-import jp.go.aist.rtm.toolscommon.model.component.Component;
-import jp.go.aist.rtm.toolscommon.model.component.Port;
-
/**
* PortのFigure
*/
-public class PortFigure extends PolygonDecoration {
+public class PortFigure extends ComponentChildFigure {
/** 出力ポートの描画テンプレート */
public static final PointList P_OUTPORT;
@@ -33,11 +29,11 @@
public static final PointList P_SVCPORT_EXPORTED;
/** 出力ポートのスタイル */
- public static final PortFigureStyle S_OUTPORT;
+ public static final FigureStyle S_OUTPORT;
/** 入力ポートのスタイル */
- public static final PortFigureStyle S_INPORT;
+ public static final FigureStyle S_INPORT;
/** サービスポートのスタイル */
- public static final PortFigureStyle S_SVCPORT;
+ public static final FigureStyle S_SVCPORT;
static {
PointList p = new PointList(5);
@@ -110,52 +106,28 @@
p.addPoint(12, 0);
P_SVCPORT_EXPORTED = p;
- S_OUTPORT = new PortFigureStyle(ColorConstants.darkGreen, ColorConstants.red);
- S_INPORT = new PortFigureStyle(ColorConstants.darkBlue, ColorConstants.red);
- S_SVCPORT = new PortFigureStyle(ColorConstants.lightBlue, ColorConstants.red);
+ S_OUTPORT = new FigureStyle(ColorConstants.darkGreen,
+ ColorConstants.red);
+ S_INPORT = new FigureStyle(ColorConstants.darkBlue, ColorConstants.red);
+ S_SVCPORT = new FigureStyle(ColorConstants.lightBlue,
+ ColorConstants.red);
}
- private String direction;
-
- protected void init() {
- setScale(1.0, 1.0);
- setFill(true);
- }
-
- /**
- * 方向を設定する
- *
- * @param direction
- * 方向
- */
- public void setDirection(String direction) {
- this.direction = direction;
- setRotation(getRotation(direction));
- }
-
- private double getRotation(String direction) {
+ @Override
+ protected double getRotation(String direction) {
if (direction.equals(Component.OUTPORT_DIRECTION_RIGHT_LITERAL)) {
return 0;
+ } else if (direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL)) {
+ return Math.PI / 2;
} else if (direction.equals(Component.OUTPORT_DIRECTION_LEFT_LITERAL)) {
return Math.PI;
} else if (direction.equals(Component.OUTPORT_DIRECTION_UP_LITERAL)) {
return Math.PI * 3 / 2;
- } else if (direction.equals(Component.OUTPORT_DIRECTION_DOWN_LITERAL)) {
- return Math.PI / 2;
}
return 0;
}
/**
- * 方向を取得する
- *
- * @return 方向
- */
- public String getDirection() {
- return direction;
- }
-
- /**
* データポートのツールチップを取得する
*
* @param profile
@@ -168,7 +140,9 @@
String labelString = "";
try {
- labelString = labelString + (port.getNameL() == null ? "<unknown>" : port.getNameL()) + ""; // \r\nは最後はいらない
+ labelString = labelString
+ + (port.getNameL() == null ? "<unknown>" : port.getNameL())
+ + ""; // \r\nは最後はいらない
} catch (RuntimeException e) {
// void
}
@@ -178,27 +152,4 @@
return tooltip;
}
- @Override
- public void setLocation(Point p) {
- super.setLocation(p);
- fireFigureMoved();
- }
-
- public Rectangle getBaseBounds() {
- return (getParent() != null) ? getParent().getBounds() : new Rectangle();
- }
-
- /**
- * ポートのスタイル定義を表します。
- */
- public static class PortFigureStyle {
- public final Color bg;
- public final Color fg;
-
- PortFigureStyle(Color bg, Color fg) {
- this.bg = bg;
- this.fg = fg;
- }
- }
-
}
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/util/ComponentComparator.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/util/ComponentComparator.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/util/ComponentComparator.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,39 @@
+package jp.go.aist.rtm.systemeditor.ui.util;
+
+import java.util.Comparator;
+
+import jp.go.aist.rtm.systemeditor.ui.views.actionorderview.ActionOrderView.ActionName;
+import jp.go.aist.rtm.toolscommon.model.component.Component;
+
+public class ComponentComparator implements Comparator<Component> {
+ private ActionName type;
+
+ public ComponentComparator(ActionName type) {
+ this.type = type;
+ }
+ @Override
+ public int compare(Component o1, Component o2) {
+ switch (type) {
+ case ACTION_START_UP:
+ return compare(o1.getStartUp(), o2.getStartUp());
+ case ACTION_SHUT_DOWN:
+ return compare(o1.getShutDown(), o2.getShutDown());
+ case ACTION_ACTIVATION:
+ return compare(o1.getActivation(), o2.getActivation());
+ case ACTION_DEACTIVATION:
+ return compare(o1.getDeActivation(), o2.getDeActivation());
+ case ACTION_RESETTING:
+ return compare(o1.getResetting(), o2.getResetting());
+ case ACTION_INITIALIZE:
+ return compare(o1.getInitialize(), o2.getInitialize());
+ default:
+ return compare(o1.getFinalize(), o2.getFinalize());
+ }
+ }
+
+ private int compare(String str1, String str2) {
+ if(str1 == null) return 1;
+ if(str2 == null) return -1;
+ return str1.compareTo(str2);
+ }
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/util/ComponentComparator.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/ActionOrderView.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/ActionOrderView.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/ActionOrderView.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -0,0 +1,667 @@
+package jp.go.aist.rtm.systemeditor.ui.views.actionorderview;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import jp.go.aist.rtm.systemeditor.ui.util.ComponentComparator;
+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.AdapterUtil;
+
+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.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+
+public class ActionOrderView extends ViewPart {
+ private static final int BUTTON_WIDTH = 40;
+
+ private TableViewer orderTableViewer;
+ private List<TableViewer> actionOrderlistTableViewer;
+
+ private SystemDiagram targetDiagram;
+// private RTCStore rtcStore;
+ private ActionOrder actionOrder = new ActionOrder();
+ private int selectedTable = -1;
+
+ public enum ActionName {
+ ACTION_START_UP,
+ ACTION_SHUT_DOWN,
+ ACTION_ACTIVATION,
+ ACTION_DEACTIVATION,
+ ACTION_RESETTING,
+ ACTION_INITIALIZE,
+ ACTION_FINALIZE
+ }
+
+ public ActionOrderView() {
+ }
+
+ public ActionOrderView getActionOrderView() {
+ return this;
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ GridLayout gl;
+ GridData gd;
+
+ gl = new GridLayout();
+ gl.numColumns = 3;
+ parent.setLayout(gl);
+
+ SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = 2;
+ sashForm.setLayoutData(gd);
+
+ createActionOrderListPart(sashForm);
+
+ setSiteSelection();
+ }
+
+ Composite createActionOrderListPart(SashForm sash) {
+ GridLayout gl;
+ GridData gd;
+
+ Composite composite = new Composite(sash, SWT.FILL);
+ gl = new GridLayout();
+ gl.horizontalSpacing = 0;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
+ gl.numColumns = 9;
+ composite.setLayout(gl);
+ /////
+ orderTableViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.HIDE_SELECTION
+ | SWT.SINGLE | SWT.BORDER);
+ orderTableViewer.setContentProvider(new ArrayContentProvider());
+
+ Table orderTable = orderTableViewer.getTable();
+ orderTable.setLinesVisible(true);
+ orderTable.setHeaderVisible(true);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ orderTable.setLayoutData(gd);
+ orderTable.getHorizontalBar().setVisible(false);
+
+ gl = new GridLayout(1, false);
+ gl.numColumns = 1;
+ orderTable.setLayout(gl);
+
+ TableViewerColumn noColumn = createColumn(orderTableViewer, "No.", 40);
+ noColumn.getColumn().setResizable(false);
+
+ orderTableViewer.setLabelProvider(new OrderLabelProvider());
+ orderTableViewer.getTable().addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ selectedTable = -1;
+ super.focusGained(e);
+ }
+ });
+ //
+ actionOrderlistTableViewer = new ArrayList<TableViewer>();
+ for(ActionName target : ActionName.values()) {
+ TableViewer tableViewer = createActionTable(composite, target);
+ actionOrderlistTableViewer.add(tableViewer);
+ }
+ actionOrder.update();
+ //
+ Composite buttonCompsite = new Composite(composite, SWT.BOTTOM);
+ gl = new GridLayout();
+ gl.numColumns = 1;
+ buttonCompsite.setLayout(gl);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ buttonCompsite.setLayoutData(gd);
+
+ Label dummy01 = new Label(buttonCompsite, SWT.NONE);
+ gd = new GridData();
+ gd.grabExcessVerticalSpace = true;
+ dummy01.setLayoutData(gd);
+
+ Button upButton = new Button(buttonCompsite, SWT.NONE);
+ upButton.setText("▲");
+ upButton.setEnabled(true);
+ gd = new GridData();
+ gd.widthHint = BUTTON_WIDTH;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = SWT.BEGINNING;
+ upButton.setLayoutData(gd);
+ upButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(selectedTable<0) return;
+ int rowIndex = actionOrderlistTableViewer.get(selectedTable).getTable().getSelectionIndex();
+ actionOrder.upElement(selectedTable, rowIndex);
+ }
+ });
+
+ Label dummy02 = new Label(buttonCompsite, SWT.NONE);
+ gd = new GridData();
+ gd.grabExcessVerticalSpace = true;
+ dummy02.setLayoutData(gd);
+
+ Button downButton = new Button(buttonCompsite, SWT.NONE);
+ downButton.setText("▼");
+ downButton.setEnabled(true);
+ gd = new GridData();
+ gd.widthHint = BUTTON_WIDTH;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = SWT.END;
+ downButton.setLayoutData(gd);
+ downButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(selectedTable<0) return;
+ int rowIndex = actionOrderlistTableViewer.get(selectedTable).getTable().getSelectionIndex();
+ actionOrder.downElement(selectedTable, rowIndex);
+ }
+ });
+
+ Label dummy03 = new Label(buttonCompsite, SWT.NONE);
+ gd = new GridData();
+ gd.grabExcessVerticalSpace = true;
+ dummy03.setLayoutData(gd);
+
+ return composite;
+ }
+
+ private TableViewer createActionTable(Composite composite, final ActionName target) {
+ GridLayout gl;
+ GridData gd;
+ TableViewer actionTableViewer = new TableViewer(composite, SWT.FULL_SELECTION
+ | SWT.SINGLE | SWT.BORDER);
+ actionTableViewer.setContentProvider(new ArrayContentProvider());
+
+ final Table actionTable = actionTableViewer.getTable();
+ actionTable.setLinesVisible(true);
+ actionTable.setHeaderVisible(true);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ actionTable.setLayoutData(gd);
+
+ gl = new GridLayout(1, false);
+ gl.numColumns = 1;
+ actionTable.setLayout(gl);
+
+ switch(target) {
+ case ACTION_START_UP:
+ createColumn(actionTableViewer, "Startup", 120);
+ break;
+ case ACTION_SHUT_DOWN:
+ createColumn(actionTableViewer, "Shutdown", 120);
+ break;
+ case ACTION_ACTIVATION:
+ createColumn(actionTableViewer, "Activation", 120);
+ break;
+ case ACTION_DEACTIVATION:
+ createColumn(actionTableViewer, "Deactivation", 120);
+ break;
+ case ACTION_RESETTING:
+ createColumn(actionTableViewer, "Resetting", 120);
+ break;
+ case ACTION_INITIALIZE:
+ createColumn(actionTableViewer, "Initialize", 120);
+ break;
+ case ACTION_FINALIZE:
+ createColumn(actionTableViewer, "Finalize", 120);
+ break;
+ }
+
+ actionTableViewer.setLabelProvider(new ActionOrderLabelProvider());
+
+ actionTableViewer.getTable().addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ selectedTable = target.ordinal();
+ super.focusGained(e);
+ }
+ });
+ /////
+ Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
+ DragSource source = new DragSource(actionTable, DND.DROP_MOVE);
+ source.setTransfer(types);
+
+ source.addDragListener(new DragSourceAdapter() {
+ public void dragSetData(DragSourceEvent event) {
+ int rowIndex = actionTable.getSelectionIndex();
+ event.data = actionOrder.getElement(selectedTable, rowIndex);
+ }
+ });
+
+ DropTarget dragTarget = new DropTarget(actionTable, DND.DROP_MOVE);
+ dragTarget.setTransfer(types);
+ dragTarget.addDropListener(new DropTargetAdapter() {
+ public void dragEnter(DropTargetEvent event) {
+ if (TextTransfer.getInstance().isSupportedType(event.dataTypes[0])) {
+ if(selectedTable!=target.ordinal()) {
+ event.detail = DND.DROP_NONE;
+ } else {
+ event.currentDataType = event.dataTypes[0];
+ }
+ }
+ }
+
+ public void dragOver(DropTargetEvent event) {
+ event.feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_INSERT_BEFORE;
+ }
+ public void drop(DropTargetEvent event) {
+ if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ // Get the dropped data
+ String data = (String) event.data;
+ Widget targetItem = event.item;
+ if(targetItem==null) {
+ actionOrder.moveBackElement(selectedTable, data);
+ } else {
+ String targetData = ((TableItem)targetItem).getText();
+ actionOrder.swapElement(selectedTable, data, targetData);
+ }
+ }
+ }
+ });
+ return actionTableViewer;
+ }
+
+ TableViewerColumn createColumn(TableViewer viewer, String title, int width) {
+ TableViewerColumn col;
+ col = new TableViewerColumn(viewer, SWT.NONE);
+ col.getColumn().setText(title);
+ col.getColumn().setWidth(width);
+ col.getColumn().setResizable(false);
+ return col;
+ }
+
+ /** 内部モデル(RTC一覧)から表示 */
+ void refreshData() {
+ if(targetDiagram==null) return;
+ List<Component> targetComps = new ArrayList<Component>();
+ for (Component comp : targetDiagram.getRegisteredComponents()) {
+ if (!(comp instanceof CorbaComponent)) {
+ continue;
+ }
+ targetComps.add(comp);
+ }
+ actionOrder.updateElement(targetComps);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+// /** RTC一覧を表すクラス */
+// static class RTCStore {
+// static Map<SystemDiagram, RTCStore> store = new HashMap<SystemDiagram, RTCStore>();
+//
+// public static RTCStore get(SystemDiagram diagram) {
+// RTCStore result = store.get(diagram);
+// if (result == null) {
+// result = new RTCStore();
+// store.put(diagram, result);
+// }
+// result.reset(diagram);
+// return result;
+// }
+//
+// List<RTC> rtcs = new ArrayList<RTC>();
+//
+// void reset(SystemDiagram diagram) {
+// List<String> pathes = new ArrayList<String>();
+// for (RTC rtc : rtcs) {
+// if (rtc.display) {
+// pathes.add(rtc.comp.getPathId());
+// }
+// }
+// rtcs.clear();
+// for (Component comp : diagram.getRegisteredComponents()) {
+// if (!(comp instanceof CorbaComponent)) {
+// continue;
+// }
+// CorbaComponent corbaComp = (CorbaComponent) comp;
+// if (corbaComp.getLogObserver() == null) {
+// continue;
+// }
+// RTC rtc = new RTC(corbaComp);
+// if (pathes.contains(comp.getPathId())) {
+// rtc.display = true;
+// }
+// rtcs.add(rtc);
+// }
+// }
+//
+// static class RTC {
+// boolean display;
+// CorbaComponent comp;
+//
+// RTC(CorbaComponent comp) {
+// this.comp = comp;
+// this.display = false;
+// }
+// }
+// }
+
+ private class ActionOrder {
+ private List<Component> startupOrder = new ArrayList<Component>();
+ private List<Component> shutdownOrder = new ArrayList<Component>();
+ private List<Component> activationOrder = new ArrayList<Component>();
+ private List<Component> deactivationOrder = new ArrayList<Component>();
+ private List<Component> resettingOrder = new ArrayList<Component>();
+ private List<Component> initializeOrder = new ArrayList<Component>();
+ private List<Component> finalizeOrder = new ArrayList<Component>();
+
+ public void updateElement(List<Component> targetComps) {
+ List<Component> removeComps = new ArrayList<Component>();
+ for(Component target : startupOrder) {
+ boolean isHit = false;
+ for(Component source : targetComps) {
+ if(target.getPathId().equals(source.getPathId()) && target.getInstanceNameL().equals(source.getInstanceNameL())) {
+ isHit = true;
+ break;
+ }
+ }
+ if(isHit==false) {
+ removeComps.add(target);
+ }
+ }
+ if(0<removeComps.size()) {
+ for(Component target : removeComps) {
+ startupOrder.remove(target);
+ shutdownOrder.remove(target);
+ activationOrder.remove(target);
+ deactivationOrder.remove(target);
+ resettingOrder.remove(target);
+ initializeOrder.remove(target);
+ finalizeOrder.remove(target);
+ }
+ }
+ //
+ for(Component source : targetComps) {
+ boolean isHit = false;
+ for(Component target : startupOrder) {
+ if(target.getPathId().equals(source.getPathId()) && target.getInstanceNameL().equals(source.getInstanceNameL())) {
+ isHit = true;
+ break;
+ }
+ }
+ if(isHit==false) {
+ startupOrder.add(source);
+ shutdownOrder.add(source);
+ activationOrder.add(source);
+ deactivationOrder.add(source);
+ resettingOrder.add(source);
+ initializeOrder.add(source);
+ finalizeOrder.add(source);
+ }
+ }
+ //
+ Collections.sort(startupOrder, new ComponentComparator(ActionName.ACTION_START_UP));
+ Collections.sort(shutdownOrder, new ComponentComparator(ActionName.ACTION_SHUT_DOWN));
+ Collections.sort(activationOrder, new ComponentComparator(ActionName.ACTION_ACTIVATION));
+ Collections.sort(deactivationOrder, new ComponentComparator(ActionName.ACTION_DEACTIVATION));
+ Collections.sort(resettingOrder, new ComponentComparator(ActionName.ACTION_RESETTING));
+ Collections.sort(initializeOrder, new ComponentComparator(ActionName.ACTION_INITIALIZE));
+ Collections.sort(finalizeOrder, new ComponentComparator(ActionName.ACTION_FINALIZE));
+ //
+ updateOrder();
+ orderTableViewer.refresh();
+ for(int index=0; index<7; index++) {
+ actionOrderlistTableViewer.get(index).refresh();
+ }
+ }
+
+ public String getElement(int colIndex, int rowIndex) {
+ switch(colIndex) {
+ case 0:
+ return startupOrder.get(rowIndex).getInstanceNameL();
+ case 1:
+ return shutdownOrder.get(rowIndex).getInstanceNameL();
+ case 2:
+ return activationOrder.get(rowIndex).getInstanceNameL();
+ case 3:
+ return deactivationOrder.get(rowIndex).getInstanceNameL();
+ case 4:
+ return resettingOrder.get(rowIndex).getInstanceNameL();
+ case 5:
+ return initializeOrder.get(rowIndex).getInstanceNameL();
+ default:
+ return finalizeOrder.get(rowIndex).getInstanceNameL();
+ }
+ }
+
+ public void swapElement(int tableIndex, String source, String target) {
+ if(tableIndex<0 || source==null || source.length()<=0 || target==null || target.length()<=0) return;
+ List<Component> targetData;
+ targetData = getTargetData(tableIndex);
+ int srcIndex = getIndex(source, targetData);
+ int trgIndex = getIndex(target, targetData);
+ Collections.swap(targetData, srcIndex, trgIndex);
+ //
+ updateOrder();
+ actionOrderlistTableViewer.get(tableIndex).refresh();
+ actionOrderlistTableViewer.get(tableIndex).getTable().setSelection(trgIndex);
+ }
+
+ public void moveBackElement(int tableIndex, String source) {
+ if(tableIndex<0 || source==null || source.length()<=0) return;
+ List<Component> targetData;
+ targetData = getTargetData(tableIndex);
+ int srcIndex = getIndex(source, targetData);
+ Component elem = targetData.remove(srcIndex);
+ targetData.add(elem);
+ //
+ updateOrder();
+ actionOrderlistTableViewer.get(tableIndex).refresh();
+ actionOrderlistTableViewer.get(tableIndex).getTable().setSelection(targetData.size()-1);
+ }
+
+ public void upElement(int tableIndex, int rowIndex) {
+ if(tableIndex<0 || rowIndex<=0) return;
+ List<Component> targetData;
+ targetData = getTargetData(tableIndex);
+ Component selected = targetData.remove(rowIndex);
+ targetData.add(rowIndex-1, selected);
+ //
+ updateOrder();
+ actionOrderlistTableViewer.get(tableIndex).refresh();
+ actionOrderlistTableViewer.get(tableIndex).getTable().setSelection(rowIndex-1);
+ }
+
+ public void downElement(int tableIndex, int rowIndex) {
+ if(tableIndex<0 || startupOrder.size()-1<=rowIndex) return;
+ List<Component> targetData;
+ targetData = getTargetData(tableIndex);
+ Component selected = targetData.remove(rowIndex);
+ targetData.add(rowIndex+1, selected);
+ //
+ updateOrder();
+ actionOrderlistTableViewer.get(tableIndex).refresh();
+ actionOrderlistTableViewer.get(tableIndex).getTable().setSelection(rowIndex+1);
+ }
+
+ public void update() {
+ orderTableViewer.setInput(startupOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_START_UP.ordinal()).setInput(startupOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_SHUT_DOWN.ordinal()).setInput(shutdownOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_ACTIVATION.ordinal()).setInput(activationOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_DEACTIVATION.ordinal()).setInput(deactivationOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_RESETTING.ordinal()).setInput(resettingOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_INITIALIZE.ordinal()).setInput(initializeOrder);
+ actionOrderlistTableViewer.get(ActionName.ACTION_FINALIZE.ordinal()).setInput(finalizeOrder);
+ }
+
+ private List<Component> getTargetData(int tableIndex) {
+ List<Component> targetData;
+ switch(tableIndex) {
+ case 0: targetData = startupOrder; break;
+ case 1: targetData = shutdownOrder; break;
+ case 2: targetData = activationOrder; break;
+ case 3: targetData = deactivationOrder; break;
+ case 4:targetData = resettingOrder; break;
+ case 5: targetData = initializeOrder; break;
+ default: targetData = finalizeOrder; break;
+ }
+ return targetData;
+ }
+
+ private int getIndex(String source, List<Component> targetData) {
+ for(int index=0; index<targetData.size(); index++) {
+ Component target = targetData.get(index);
+ if(source.equals(target.getInstanceNameL())) return index;
+ }
+ return -1;
+ }
+
+ private void updateOrder() {
+ for(int index=0; index<startupOrder.size(); index++) {
+ Component startup = startupOrder.get(index);
+ startup.setStartUp(Integer.valueOf(index+1).toString());
+ //
+ Component shutdown = shutdownOrder.get(index);
+ shutdown.setShutDown(Integer.valueOf(index+1).toString());
+ //
+ Component activation = activationOrder.get(index);
+ activation.setActivation(Integer.valueOf(index+1).toString());
+ //
+ Component deactivation = deactivationOrder.get(index);
+ deactivation.setDeActivation(Integer.valueOf(index+1).toString());
+ //
+ Component resetting = resettingOrder.get(index);
+ resetting.setResetting(Integer.valueOf(index+1).toString());
+ //
+ Component initialize = initializeOrder.get(index);
+ initialize.setInitialize(Integer.valueOf(index+1).toString());
+ //
+ Component finalize = finalizeOrder.get(index);
+ finalize.setFinalize(Integer.valueOf(index+1).toString());
+ }
+ }
+ }
+
+ public class OrderLabelProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ Component entry = (Component) element;
+ return Integer.valueOf(actionOrder.startupOrder.indexOf(entry) + 1).toString();
+ }
+ }
+ /** RTC一覧表示のLabelProvider */
+ public class ActionOrderLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ return ((Component)element).getInstanceNameL();
+ }
+ }
+
+ ISelectionListener selectionListener = new ISelectionListener() {
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ targetDiagram = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object firstElement = ss.getFirstElement();
+ Object adapter = AdapterUtil.getAdapter(firstElement,
+ SystemDiagram.class);
+ if (adapter != null) {
+ SystemDiagram sd = (SystemDiagram) adapter;
+ if (SystemDiagramKind.ONLINE_LITERAL.equals(sd.getKind())) {
+ targetDiagram = sd;
+ }
+ }
+ }
+ refreshData();
+ }
+ };
+
+ void setSiteSelection() {
+ if (getSite() == null) {
+ return;
+ }
+ getSite().getWorkbenchWindow().getSelectionService()
+ .addSelectionListener(selectionListener);
+
+ // SelectionProviderを登録(プロパティ・ビュー連携)
+ getSite().setSelectionProvider(new ISelectionProvider() {
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ StructuredSelection result = null;
+ if (targetDiagram != null) {
+ result = new StructuredSelection(targetDiagram);
+ }
+ return result;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ }
+ });
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/actionorderview/ActionOrderView.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/executioncontextview/ExecutionContextView.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/executioncontextview/ExecutionContextView.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/executioncontextview/ExecutionContextView.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -948,37 +948,46 @@
ISelectionListener selectionListener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (targetComponent != null) {
- targetComponent.eAdapters().remove(eAdapter);
- for (ExecutionContext ec : targetComponent
- .getExecutionContexts()) {
- ec.eAdapters().remove(eAdapter);
- }
- for (ExecutionContext ec : targetComponent
- .getParticipationContexts()) {
- ec.eAdapters().remove(eAdapter);
- }
+ if (!(selection instanceof IStructuredSelection)) {
+ return;
}
- targetComponent = null;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) selection;
- Object firstElement = ss.getFirstElement();
- Object adapter = AdapterUtil.getAdapter(firstElement,
- Component.class);
- if (adapter != null) {
- targetComponent = (Component) adapter;
- targetComponent.synchronizeManually();
- targetComponent.eAdapters().add(eAdapter);
- for (ExecutionContext ec : targetComponent
- .getExecutionContexts()) {
- ec.eAdapters().add(eAdapter);
- }
- for (ExecutionContext ec : targetComponent
- .getParticipationContexts()) {
- ec.eAdapters().add(eAdapter);
- }
- }
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object firstElement = ss.getFirstElement();
+ Object compObj = AdapterUtil.getAdapter(firstElement,
+ Component.class);
+ Object ctxtObj = AdapterUtil.getAdapter(firstElement,
+ ExecutionContext.class);
+ Component comp = null;
+ ExecutionContext ctxt = null;
+ if (compObj != null) {
+ comp = (Component) compObj;
+ ctxt = null;
+ } else if (ctxtObj != null) {
+ ctxt = (ExecutionContext) ctxtObj;
+ comp = (Component) ctxt.eContainer();
}
+ if (comp == null || comp == targetComponent) {
+ return;
+ }
+ targetComponent = comp;
+ ExecutionContext targetEc = ctxt;
+ //
+ targetComponent.eAdapters().remove(eAdapter);
+ for (ExecutionContext ec : targetComponent.getExecutionContexts()) {
+ ec.eAdapters().remove(eAdapter);
+ }
+ for (ExecutionContext ec : targetComponent
+ .getParticipationContexts()) {
+ ec.eAdapters().remove(eAdapter);
+ }
+ targetComponent.eAdapters().add(eAdapter);
+ for (ExecutionContext ec : targetComponent.getExecutionContexts()) {
+ ec.eAdapters().add(eAdapter);
+ }
+ for (ExecutionContext ec : targetComponent
+ .getParticipationContexts()) {
+ ec.eAdapters().add(eAdapter);
+ }
if (part instanceof AbstractSystemDiagramEditor) {
targetEditor = (AbstractSystemDiagramEditor) part;
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java 2018-03-09 06:40:24 UTC (rev 813)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java 2018-03-09 06:41:17 UTC (rev 814)
@@ -647,4 +647,100 @@
// TODO Auto-generated method stub
}
+ @Override
+ public ExecutionContext getPrimaryExecutionContext() {
+ // TODO 自動生成されたメソッド・スタブ
+ return null;
+ }
+
+ @Override
+ public void setPrimaryExecutionContext(ExecutionContext value) {
+ // TODO 自動生成されたメソッド・スタブ
+
+ }
+
+ @Override
+ public String getStartUp() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setStartUp(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getShutDown() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setShutDown(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getActivation() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setActivation(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getDeActivation() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setDeActivation(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getResetting() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setResetting(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getInitialize() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setInitialize(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getFinalize() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setFinalize(String value) {
+ // TODO Auto-generated method stub
+
+ }
+
}
openrtm-commit メーリングリストの案内