[openrtm-commit:02303] r652 - in branches/FSM4RTC: . jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/command jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 1月 22日 (日) 15:09:03 JST
Author: ga
Date: 2017-01-22 15:09:03 +0900 (Sun, 22 Jan 2017)
New Revision: 652
Added:
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/
Modified:
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/command/MoveLineCommand.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/InPortEditPart.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/OutPortEditPart.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortConnectorEditPart.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ServicePortEditPart.java
branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/PortConnectorBendpointEditPolicy.java
Log:
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/command/MoveLineCommand.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/command/MoveLineCommand.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/command/MoveLineCommand.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -1,94 +1,120 @@
package jp.go.aist.rtm.systemeditor.ui.editor.command;
+import java.util.Map;
+
import jp.go.aist.rtm.systemeditor.ui.util.Draw2dUtil;
import jp.go.aist.rtm.toolscommon.model.component.PortConnector;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.gef.commands.Command;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* コネクタのラインを移動するコマンド
*/
public class MoveLineCommand extends Command {
- private PortConnector model;
- private int index;
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MoveLineCommand.class);
+ private Integer index;
private Point point;
-
private Point oldpoint;
- @Override
- /**
- * {@inheritDoc}
- */
- public void execute() {
- this.oldpoint = getPoint();
- setPoint(point);
- }
+ private PortConnector model;
+ private SystemDiagram diagram;
+ private String connectorId;
- @SuppressWarnings("unchecked")
- private void setPoint(Point p) {
- EMap routingConstraint = model.getRoutingConstraint();
- if (p == null) {
- routingConstraint.remove(new Integer(index));
- } else {
- // routingConstraintには、既に存在するkeyのPutを行った場合に、変更の通知が行われないバグがある。
- // このため、以下の方法で変更を行う。
- routingConstraint.put(new Integer(index), Draw2dUtil
- .toRtcLinkPoint(p));
-
- routingConstraint.removeKey(new Integer(Integer.MAX_VALUE));
- routingConstraint.put(new Integer(Integer.MAX_VALUE), null);
- routingConstraint.removeKey(new Integer(Integer.MAX_VALUE));
- }
- }
-
- @SuppressWarnings("unchecked")
- private Point getPoint() {
- Point result = null;
- if (model.getRoutingConstraint() instanceof EMap) {
- result = Draw2dUtil
- .toDraw2dPoint((jp.go.aist.rtm.toolscommon.model.core.Point) ((EMap) model
- .getRoutingConstraint()).get(new Integer(index)));
- }
-
- return result;
- }
-
/**
- * 変更対象のモデルを設定する
+ * 編集対象のコネクタのモデルを設定します。
*
* @param model
- * 変更対象のモデル
+ * 編集対象のコネクタのモデル
*/
public void setModel(PortConnector model) {
this.model = model;
+ this.connectorId = model.getConnectorProfile().getConnectorId();
}
- @Override
/**
- * {@inheritDoc}
+ * 編集対象のダイアグラムを設定します。
+ *
+ * @param diagram
+ * 編集対象のダイアグラム
*/
- public void undo() {
- setPoint(oldpoint);
- oldpoint = null;
+ public void setDiagram(SystemDiagram diagram) {
+ this.diagram = diagram;
}
/**
* インデックスを設定する
- * @param index インデックス
+ *
+ * @param index
+ * インデックス
*/
public void setIndex(int index) {
- this.index = index;
+ this.index = new Integer(index);
}
/**
* ロケーションを設定する
- * @param point ロケーション
+ *
+ * @param point
+ * ロケーション
*/
public void setLocation(Point point) {
this.point = point;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void execute() {
+ LOGGER.trace("execute: this=<{}> point=<{}>", this.connectorId,
+ this.point);
+ this.oldpoint = getPoint();
+ setPoint(this.point);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void undo() {
+ LOGGER.trace("undo: this=<{}> oldpoint=<{}>", this.connectorId,
+ this.oldpoint);
+ setPoint(this.oldpoint);
+ this.oldpoint = null;
+ }
+
+ private void setPoint(Point p) {
+ Map<Integer, jp.go.aist.rtm.toolscommon.model.core.Point> constraint = this.diagram
+ .getPortConnectorRoutingConstraint(this.connectorId);
+ EMap<Integer, jp.go.aist.rtm.toolscommon.model.core.Point> routingConstraint = this.model
+ .getRoutingConstraint();
+ if (p == null) {
+ constraint.remove(this.index);
+ routingConstraint.remove(this.index);
+ } else {
+ jp.go.aist.rtm.toolscommon.model.core.Point ePoint = Draw2dUtil
+ .toRtcLinkPoint(p);
+ constraint.put(this.index, ePoint);
+ // EMap にはすでに存在するキーに対する put() で変更通知されないバグがあるため、delete-set する。
+ routingConstraint.remove(this.index);
+ routingConstraint.put(this.index, ePoint);
+ }
+ }
+
+ private Point getPoint() {
+ Point result = null;
+ Map<Integer, jp.go.aist.rtm.toolscommon.model.core.Point> constraint = this.diagram
+ .getPortConnectorRoutingConstraint(this.connectorId);
+ result = Draw2dUtil.toDraw2dPoint(constraint.get(this.index));
+ return result;
+ }
+
}
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/InPortEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/InPortEditPart.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/InPortEditPart.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -1,5 +1,11 @@
package jp.go.aist.rtm.systemeditor.ui.editor.editpart;
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.ExportedInPortFigure;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.InPortFigure;
+import jp.go.aist.rtm.toolscommon.model.component.InPort;
+import jp.go.aist.rtm.toolscommon.model.component.Port;
+
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Panel;
@@ -11,18 +17,17 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.PlatformUI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
-import jp.go.aist.rtm.systemeditor.ui.editor.figure.ExportedInPortFigure;
-import jp.go.aist.rtm.systemeditor.ui.editor.figure.InPortFigure;
-import jp.go.aist.rtm.toolscommon.model.component.InPort;
-import jp.go.aist.rtm.toolscommon.model.component.Port;
-
/**
* InPortのEditPartクラス
*/
public class InPortEditPart extends PortEditPart {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(InPortEditPart.class);
+
/**
* コンストラクタ
*
@@ -40,6 +45,8 @@
@Override
public void notifyChanged(Notification notification) {
+ LOGGER.trace("notifyChanged: this=<{}> notification=<{}>", getModel()
+ .getNameL(), notification);
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/OutPortEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/OutPortEditPart.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/OutPortEditPart.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -1,5 +1,11 @@
package jp.go.aist.rtm.systemeditor.ui.editor.editpart;
+import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.ExportedOutPortFigure;
+import jp.go.aist.rtm.systemeditor.ui.editor.figure.OutPortFigure;
+import jp.go.aist.rtm.toolscommon.model.component.OutPort;
+import jp.go.aist.rtm.toolscommon.model.component.impl.PortConnectorImpl;
+
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;
@@ -17,18 +23,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jp.go.aist.rtm.systemeditor.manager.SystemEditorPreferenceManager;
-import jp.go.aist.rtm.systemeditor.ui.editor.figure.ExportedOutPortFigure;
-import jp.go.aist.rtm.systemeditor.ui.editor.figure.OutPortFigure;
-import jp.go.aist.rtm.toolscommon.model.component.OutPort;
-import jp.go.aist.rtm.toolscommon.model.component.impl.PortConnectorImpl;
-
/**
* OutPortのEditPartクラス
*/
public class OutPortEditPart extends PortEditPart {
- private static final Logger LOGGER = LoggerFactory.getLogger(OutPortEditPart.class);
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(OutPortEditPart.class);
/**
* コンストラクタ
@@ -47,6 +48,8 @@
@Override
public void notifyChanged(Notification notification) {
+ LOGGER.trace("notifyChanged: this=<{}> notification=<{}>", getModel()
+ .getNameL(), notification);
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortConnectorEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortConnectorEditPart.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortConnectorEditPart.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -10,27 +10,38 @@
import jp.go.aist.rtm.systemeditor.ui.editor.editpolicy.PortConnectorEditPolicy;
import jp.go.aist.rtm.systemeditor.ui.editor.editpolicy.PortConnectorEndpointEditPolicy;
import jp.go.aist.rtm.systemeditor.ui.util.Draw2dUtil;
+import jp.go.aist.rtm.toolscommon.model.component.ComponentPackage;
import jp.go.aist.rtm.toolscommon.model.component.PortConnector;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
import jp.go.aist.rtm.toolscommon.model.core.ModelElement;
import jp.go.aist.rtm.toolscommon.util.AdapterUtil;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EMap;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* コネクタのEditPartクラス
*/
public class PortConnectorEditPart extends AbstractConnectionEditPart {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(PortConnectorEditPart.class);
+
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
this);
+
+ private SystemDiagram diagram;
+ private String connectorId;
+
/**
* コンストラクタ
*
@@ -38,6 +49,7 @@
*/
public PortConnectorEditPart(ActionRegistry actionRegistry) {
super();
+ LOGGER.trace("new: actionRegistry=<{}>", actionRegistry);
}
/**
@@ -46,10 +58,16 @@
protected Adapter modelListener = new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
- if (getParent() == null) return;
- if (getViewer() == null) return;
- if (getViewer().getControl() == null) return;
-
+ if (getParent() == null || getViewer() == null
+ || getViewer().getControl() == null) {
+ return;
+ }
+ if (!(ComponentPackage.eINSTANCE
+ .getPortConnector_RoutingConstraint().equals(msg
+ .getFeature()))) {
+ return;
+ }
+ LOGGER.trace("notifyChanged: this=<{}> msg=<{}>", connectorId, msg);
getViewer().getControl().getDisplay().asyncExec(new Runnable() {
public void run() {
if (isActive()) {
@@ -60,95 +78,108 @@
}
};
- @Override
/**
* {@inheritDoc}
*/
+ @Override
protected void createEditPolicies() {
+ LOGGER.trace("createEditPolicies");
installEditPolicy(EditPolicy.CONNECTION_ROLE,
new PortConnectorEditPolicy());
installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
new PortConnectorEndpointEditPolicy());
+ //
+ this.diagram = ((SystemDiagramEditPart) getRoot().getContents())
+ .getModel();
+ this.connectorId = getModel().getConnectorProfile().getConnectorId();
+ LOGGER.trace("createEditPolicies: connectorId=<{}> diagram=<{}>",
+ this.connectorId, this.diagram);
+ PortConnectorBendpointEditPolicy bendpointEditPolicy = new PortConnectorBendpointEditPolicy();
+ bendpointEditPolicy.setDiagram(this.diagram);
installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE,
- new PortConnectorBendpointEditPolicy());
+ bendpointEditPolicy);
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
protected IFigure createFigure() {
+ LOGGER.trace("createFigure");
PolylineConnection result = new PolylineConnection();
result.setLineWidth(1);
result.setConnectionRouter(new EditableManhattanConnectorRouter());
-
return result;
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
public void activate() {
+ LOGGER.trace("activate: this=<{}>", this.connectorId);
super.activate();
- ((ModelElement) getModel()).eAdapters().add(modelListener);
+ ((ModelElement) getModel()).eAdapters().add(this.modelListener);
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
public void deactivate() {
+ LOGGER.trace("deactivate: this=<{}>", this.connectorId);
super.deactivate();
- ((ModelElement) getModel()).eAdapters().remove(modelListener);
+ ((ModelElement) getModel()).eAdapters().remove(this.modelListener);
}
/**
- * ベンドポイントを再設定する
+ * {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
- protected void refreshBendPoint() {
- Map routingConstraint = Draw2dUtil.toDraw2dPointMap(((EMap) getModel()
- .getRoutingConstraint()).map());
- if (routingConstraint == null) {
- routingConstraint = Collections.EMPTY_MAP;
- }
-
- getConnectionFigure().setRoutingConstraint(routingConstraint);
- }
-
@Override
- /**
- * {@inheritDoc}
- */
public PortConnector getModel() {
return (PortConnector) super.getModel();
}
- @Override
/**
* {@inheritDoc}
*/
+ @Override
protected void refreshVisuals() {
super.refreshVisuals();
refreshBendPoint();
}
- @SuppressWarnings("unchecked")
- @Override
+
/**
* {@inheritDoc}
* <p>
* モデルのオブジェクトに委譲している
*/
+ @SuppressWarnings("rawtypes")
+ @Override
public Object getAdapter(Class key) {
Object result = AdapterUtil.getAdapter(getModel(), key);
if (result == null) {
result = super.getAdapter(key);
}
-
return result;
}
+
/**
+ * ベンドポイントを再設定する
+ */
+ protected void refreshBendPoint() {
+ Map<Integer, Point> routingConstraint = Draw2dUtil
+ .toDraw2dPointMap(this.diagram
+ .getPortConnectorRoutingConstraint(this.connectorId));
+ LOGGER.trace("refreshBendPoint: this=<{}> constraint=<{}>",
+ this.connectorId, routingConstraint);
+ if (routingConstraint == null) {
+ routingConstraint = Collections.emptyMap();
+ }
+ getConnectionFigure().setRoutingConstraint(routingConstraint);
+ }
+
+ /**
* コンポーネントFigureの変更の通知を行うリスナを登録する
*
* @param listener
@@ -164,5 +195,6 @@
*/
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
- }
+ }
+
}
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/PortEditPart.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -54,10 +54,12 @@
*/
public PortEditPart(ActionRegistry actionRegistry) {
super(actionRegistry);
+ LOGGER.trace("new: actionRegistry=<{}>", actionRegistry);
}
@Override
protected IFigure createFigure() {
+ LOGGER.trace("createFigure");
portLabel = new FloatingLabel(((AbstractGraphicalEditPart) getParent().getParent()).getFigure());
portLabel.setText(getPortBaseName());
portLabel.setSize(30, 10);
@@ -103,30 +105,35 @@
@Override
protected void createEditPolicies() {
+ LOGGER.trace("createEditPolicies");
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new PortGraphicalNodeEditPolicy());
}
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
- LOGGER.trace("getSourceConnectionAnchor: editpart=<{}>", connection);
+ LOGGER.trace("getSourceConnectionAnchor: this=<{}> editpart=<{}>",
+ getModel().getNameL(), connection);
return new PortAnchor(getFigure());
}
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
- LOGGER.trace("getTargetConnectionAnchor: editpart=<{}>", connection);
+ LOGGER.trace("getTargetConnectionAnchor: this=<{}> editpart=<{}>",
+ getModel().getNameL(), connection);
return new PortAnchor(getFigure());
}
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- LOGGER.trace("getSourceConnectionAnchor: request=<{}>", request);
+ LOGGER.trace("getSourceConnectionAnchor: this=<{}> request=<{}>",
+ getModel().getNameL(), request);
return new PortAnchor(getFigure());
}
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
- LOGGER.trace("getTargetConnectionAnchor: request=<{}>", request);
+ LOGGER.trace("getTargetConnectionAnchor: this=<{}> request=<{}>",
+ getModel().getNameL(), request);
return new PortAnchor(getFigure());
}
@@ -173,6 +180,7 @@
@Override
public void activate() {
+ LOGGER.trace("activate: this=<{}>", getModel().getNameL());
super.activate();
SystemEditorPreferenceManager.getInstance().addPropertyChangeListener(preferenceChangeListener);
if (getModel().eContainer() instanceof ComponentSpecification) {
@@ -182,6 +190,7 @@
@Override
public void deactivate() {
+ LOGGER.trace("deactivate: this=<{}>", getModel().getNameL());
portLabel.deactivate();
super.deactivate();
SystemEditorPreferenceManager.getInstance().removePropertyChangeListener(preferenceChangeListener);
@@ -199,6 +208,8 @@
private class Adapter extends AdapterImpl {
@Override
public void notifyChanged(Notification msg) {
+ LOGGER.trace("notifyChanged: this=<{}> msg=<{}>", getModel()
+ .getNameL(), msg);
if (ComponentPackage.eINSTANCE.getPort_ConnectorProfiles().equals(msg.getFeature())
&& (msg.getEventType() == Notification.ADD || msg.getEventType() == Notification.REMOVE)) {
if (getModel().eContainer().eContainer() instanceof SystemDiagram) {
@@ -233,6 +244,9 @@
// ターゲットのポートのEditPartが存在しない時に走るときがある。
@Override
protected void addSourceConnection(ConnectionEditPart connection, int index) {
+ LOGGER.trace(
+ "addSourceConnection: this=<{}> connEditpart=<{}> index=<{}>",
+ getModel().getNameL(), connection, index);
// ターゲット側の設定も行う
PortConnector connectionModel = (PortConnector) connection.getModel();
PortEditPart targetPart = (PortEditPart) getViewer().getEditPartRegistry().get(connectionModel.getTarget());
@@ -263,6 +277,9 @@
@Override
protected void addTargetConnection(ConnectionEditPart connection, int index) {
+ LOGGER.trace(
+ "addTargetConnection: this=<{}> connEditpart=<{}> index=<{}>",
+ getModel().getNameL(), connection, index);
// ソース側の設定も行う
PortConnector connectionModel = (PortConnector) connection.getModel();
PortEditPart sourcePart = (PortEditPart) getViewer().getEditPartRegistry().get(connectionModel.getSource());
@@ -293,6 +310,8 @@
@Override
protected void refreshSourceConnections() {
+ // LOGGER.trace("refreshSourceConnections: this=<{}>",
+ // getModel().getNameL());
int i;
ConnectionEditPart editPart;
Object model;
@@ -330,6 +349,8 @@
@Override
protected void refreshTargetConnections() {
+ // LOGGER.trace("refreshTargetConnections: this=<{}>",
+ // getModel().getNameL());
int i;
ConnectionEditPart editPart;
Object model;
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ServicePortEditPart.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ServicePortEditPart.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpart/ServicePortEditPart.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -13,12 +13,17 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.PlatformUI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* ServicePortのEditPartクラス
*/
public class ServicePortEditPart extends PortEditPart {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ServicePortEditPart.class);
+
/**
* コンストラクタ
*
@@ -36,6 +41,8 @@
@Override
public void notifyChanged(Notification notification) {
+ LOGGER.trace("notifyChanged: this=<{}> notification=<{}>", getModel()
+ .getNameL(), notification);
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
Modified: branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/PortConnectorBendpointEditPolicy.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/PortConnectorBendpointEditPolicy.java 2016-12-14 08:37:12 UTC (rev 638)
+++ branches/FSM4RTC/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/editpolicy/PortConnectorBendpointEditPolicy.java 2017-01-22 06:09:03 UTC (rev 652)
@@ -11,6 +11,7 @@
import jp.go.aist.rtm.systemeditor.ui.editor.command.MoveLineCommand;
import jp.go.aist.rtm.systemeditor.ui.editor.editpart.router.LineMoveHandle;
import jp.go.aist.rtm.toolscommon.model.component.PortConnector;
+import jp.go.aist.rtm.toolscommon.model.component.SystemDiagram;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.geometry.Point;
@@ -21,6 +22,8 @@
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy;
import org.eclipse.gef.requests.BendpointRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* コネクタのベンドポイント編集のEditPolicyクラス
@@ -28,26 +31,61 @@
public class PortConnectorBendpointEditPolicy extends
SelectionHandlesEditPolicy implements PropertyChangeListener {
- private static final Map<Integer, Point> NULL_CONSTRAINT = Collections.emptyMap();
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(PortConnectorBendpointEditPolicy.class);
+ private static final Map<Integer, Point> NULL_CONSTRAINT = Collections
+ .emptyMap();
+
private Map<Integer, Point> originalConstraint;
private boolean isDeleting = false;
+ private SystemDiagram diagram;
+ private String connectorId;
+
/**
+ * 編集対象のダイアグラムを設定します。
+ *
+ * @param diagram
+ * 編集対象のダイアグラム
+ */
+ public void setDiagram(SystemDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ @Override
+ public void setHost(EditPart host) {
+ LOGGER.trace("setHost: host=<{}>", host);
+ super.setHost(host);
+ // コネクタの描画開始時にベンドポイントを初期設定
+ // (プロファイル読込によるベンドポイント初期値はダイアグラムに格納)
+ PortConnector conn = (PortConnector) getHost().getModel();
+ this.connectorId = conn.getConnectorProfile().getConnectorId();
+ conn.getRoutingConstraint().clear();
+ conn.getRoutingConstraint().putAll(
+ this.diagram
+ .getPortConnectorRoutingConstraint(this.connectorId));
+ }
+
+ /**
* {@inheritDoc}
*/
+ @Override
public void activate() {
+ LOGGER.trace("activate: this=<{}>", this.connectorId);
super.activate();
- getConnection().addPropertyChangeListener(Connection.PROPERTY_POINTS,
- this);
+ getConnectionFigure().addPropertyChangeListener(
+ Connection.PROPERTY_POINTS, this);
}
/**
* {@inheritDoc}
*/
+ @Override
public void deactivate() {
- getConnection().removePropertyChangeListener(
+ LOGGER.trace("deactivate: this=<{}>", this.connectorId);
+ getConnectionFigure().removePropertyChangeListener(
Connection.PROPERTY_POINTS, this);
super.deactivate();
}
@@ -55,145 +93,175 @@
/**
* {@inheritDoc}
*/
- protected void eraseConnectionFeedback(BendpointRequest request) {
- restoreOriginalConstraint();
- originalConstraint = null;
- }
-
- /**
- * {@inheritDoc}
- */
+ @Override
public void eraseSourceFeedback(Request request) {
if (REQ_MOVE_BENDPOINT.equals(request.getType())
- || REQ_CREATE_BENDPOINT.equals(request.getType()))
+ || REQ_CREATE_BENDPOINT.equals(request.getType())) {
eraseConnectionFeedback((BendpointRequest) request);
+ }
}
/**
* {@inheritDoc}
*/
+ @Override
public Command getCommand(Request request) {
if (REQ_MOVE_BENDPOINT.equals(request.getType())) {
- if (isDeleting)
+ if (isDeleting) {
return getDeleteBendpointCommand((BendpointRequest) request);
+ }
return getMoveBendpointCommand((BendpointRequest) request);
}
- if (REQ_CREATE_BENDPOINT.equals(request.getType()))
+ if (REQ_CREATE_BENDPOINT.equals(request.getType())) {
return getCreateBendpointCommand((BendpointRequest) request);
+ }
return null;
}
- protected Connection getConnection() {
- return (Connection) ((ConnectionEditPart) getHost()).getFigure();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void showSourceFeedback(Request request) {
+ if (REQ_MOVE_BENDPOINT.equals(request.getType())) {
+ showMoveBendpointFeedback((BendpointRequest) request);
+ } else if (REQ_CREATE_BENDPOINT.equals(request.getType())) {
+ showCreateBendpointFeedback((BendpointRequest) request);
+ }
}
/**
* {@inheritDoc}
*/
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
- if (getHost().getSelected() != EditPart.SELECTED_NONE)
+ // LOGGER.trace("propertyChange: this=<{}> host.selected=<{}> host.active=<{}> event=<{}>",this.connectorId,
+ // getHost().getSelected(),getHost().isActive(), evt);
+ if (getHost().isActive()
+ && getHost().getSelected() != EditPart.SELECTED_NONE) {
addSelectionHandles();
+ }
}
- /**
- * {@inheritDoc}
- */
- protected void restoreOriginalConstraint() {
- if (originalConstraint != null) {
- if (originalConstraint == NULL_CONSTRAINT)
- getConnection().setRoutingConstraint(null);
- else
- getConnection().setRoutingConstraint(originalConstraint);
+ @Override
+ protected void addSelectionHandles() {
+ // LOGGER.trace("addSelectionHandles: this=<{}> host.selected=<{}> host.active=<{}>",this.connectorId,
+ // getHost().getSelected(), getHost().isActive());
+ super.addSelectionHandles();
+ }
+
+ @Override
+ protected void removeSelectionHandles() {
+ // LOGGER.trace("removeSelectionHandles: this=<{}> host.selected=<{}> host.active=<{}>",this.connectorId,
+ // getHost().getSelected(), getHost().isActive());
+ super.removeSelectionHandles();
+ }
+
+ @Override
+ protected List<LineMoveHandle> createSelectionHandles() {
+ List<LineMoveHandle> result = new ArrayList<LineMoveHandle>();
+ ConnectionEditPart connEP = (ConnectionEditPart) getHost();
+ PointList points = getConnectionFigure().getPoints();
+ if (points.size() > 2) {
+ for (int i = 1; i < points.size() - 2; i++) {
+ result.add(new LineMoveHandle(connEP, i));
+ }
}
+ return result;
}
- /**
- * {@inheritDoc}
- */
+ protected Connection getConnectionFigure() {
+ return (Connection) ((ConnectionEditPart) getHost()).getFigure();
+ }
+
@SuppressWarnings("unchecked")
+ protected Map<Integer, Point> getRoutingConstraint() {
+ return (Map<Integer, Point>) getConnectionFigure()
+ .getRoutingConstraint();
+ }
+
+ protected void setRoutingConstraint(Map<Integer, Point> constraint) {
+ getConnectionFigure().setRoutingConstraint(constraint);
+ }
+
+ protected void eraseConnectionFeedback(BendpointRequest request) {
+ LOGGER.trace(
+ "eraseConnectionFeedback: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
+ if (this.originalConstraint != null) {
+ if (this.originalConstraint == NULL_CONSTRAINT) {
+ setRoutingConstraint(null);
+ } else {
+ setRoutingConstraint(this.originalConstraint);
+ }
+ }
+ this.originalConstraint = null;
+ }
+
protected void saveOriginalConstraint() {
- originalConstraint = (Map<Integer, Point>) getConnection().getRoutingConstraint();
- if (originalConstraint == null)
+ originalConstraint = getRoutingConstraint();
+ if (originalConstraint == null) {
originalConstraint = NULL_CONSTRAINT;
- getConnection().setRoutingConstraint(
- new TreeMap<Integer, Point>(originalConstraint));
+ }
+ setRoutingConstraint(new TreeMap<Integer, Point>(originalConstraint));
}
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
private void showCreateBendpointFeedback(BendpointRequest request) {
+ LOGGER.trace(
+ "showCreateBendpointFeedback: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
Point p = new Point(request.getLocation());
- getConnection().translateToRelative(p);
- if (originalConstraint == null) saveOriginalConstraint();
- ((Map<Integer, Point>) getConnection().getRoutingConstraint())
- .put(request.getIndex(), p);
+ getConnectionFigure().translateToRelative(p);
+ if (this.originalConstraint == null) {
+ saveOriginalConstraint();
+ }
+ getRoutingConstraint().put(request.getIndex(), p);
}
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
protected void showMoveBendpointFeedback(BendpointRequest request) {
+ LOGGER.trace(
+ "showMoveBendpointFeedback: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
Point p = new Point(request.getLocation());
- if (isDeleting) {
- isDeleting = false;
+ if (this.isDeleting) {
+ this.isDeleting = false;
eraseSourceFeedback(request);
}
- if (originalConstraint == null)
+ if (this.originalConstraint == null) {
saveOriginalConstraint();
- Map<Integer, Point> constraint = (Map<Integer, Point>) getConnection().getRoutingConstraint();
- getConnection().translateToRelative(p);
-
+ }
+ getConnectionFigure().translateToRelative(p);
+ Map<Integer, Point> constraint = getRoutingConstraint();
constraint.put(request.getIndex(), p);
- getConnection().setRoutingConstraint(constraint);
+ setRoutingConstraint(constraint);
}
- /**
- * {@inheritDoc}
- */
- public void showSourceFeedback(Request request) {
- if (REQ_MOVE_BENDPOINT.equals(request.getType()))
- showMoveBendpointFeedback((BendpointRequest) request);
- else if (REQ_CREATE_BENDPOINT.equals(request.getType()))
- showCreateBendpointFeedback((BendpointRequest) request);
- }
-
protected Command getCreateBendpointCommand(BendpointRequest request) {
+ LOGGER.trace(
+ "getCreateBendpointCommand: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
return null;
}
protected Command getDeleteBendpointCommand(BendpointRequest request) {
+ LOGGER.trace(
+ "getDeleteBendpointCommand: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
return null;
}
protected Command getMoveBendpointCommand(BendpointRequest request) {
+ LOGGER.trace(
+ "getMoveBendpointCommand: this=<{}> index=<{}> point=<{}>",
+ this.connectorId, request.getIndex(), request.getLocation());
MoveLineCommand result = new MoveLineCommand();
- result
- .setModel((PortConnector) getHost()
- .getModel());
+ result.setModel((PortConnector) getHost().getModel());
+ result.setDiagram(this.diagram);
Point location = request.getLocation();
- getConnection().translateToRelative(location);
-
+ getConnectionFigure().translateToRelative(location);
result.setLocation(location);
result.setIndex(request.getIndex());
-
return result;
}
- protected List<LineMoveHandle> createSelectionHandles() {
- List<LineMoveHandle> result = new ArrayList<LineMoveHandle>();
- ConnectionEditPart connEP = (ConnectionEditPart) getHost();
- PointList points = getConnection().getPoints();
-
- if (points.size() > 2) {
- for (int i = 1; i < points.size() - 2; i++) {
- result.add(new LineMoveHandle(connEP, i));
- }
- }
-
- return result;
- }
-
}
More information about the openrtm-commit
mailing list