Skip to content
Snippets Groups Projects
Commit ce4458bd authored by David Trachtenherz's avatar David Trachtenherz
Browse files

Adjustments of label text and refresh adapter, now more similar to GraphicalEditPartBase:

- fullRefreshAdapter is now an EContentAdapter
- relationshipLabel text now determined by determineRelationshipLabelFigureText()
refs 336
parent 0e2babab
No related branches found
No related tags found
No related merge requests found
......@@ -39,8 +39,8 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
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.ecore.EObject;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.gef.editpolicies.BendpointEditPolicy;
......@@ -102,11 +102,12 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
* The adapter used to receive change notifications for the
* {@link #modelElement}.
*/
protected final Adapter fullRefreshAdapter = new AdapterImpl() {
// protected final Adapter fullRefreshAdapter = new AdapterImpl() {
protected final Adapter fullRefreshAdapter = new EContentAdapter() {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
// do not care what happens, just refresh everything
refresh();
}
......@@ -121,7 +122,8 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
setModel(modelElement);
this.modelElementHandler = (IModelElementHandler<T>) IModelElementHandlerService.INSTANCE
.getModelElementHandler(modelElement);
this.relationshipLabel = new Label(modelElement.getName()) {
this.relationshipLabel = new Label(
determineRelationshipLabelFigureText()) {
/** {@inheritDoc} */
@Override
public void setBounds(Rectangle rect) {
......@@ -224,13 +226,13 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
@Override
public void activate() {
super.activate();
modelElement.eAdapters().add(fullRefreshAdapter);
getModel().eAdapters().add(fullRefreshAdapter);
}
/** {@inheritDoc} */
@Override
public void deactivate() {
modelElement.eAdapters().remove(fullRefreshAdapter);
getModel().eAdapters().remove(fullRefreshAdapter);
super.deactivate();
}
......@@ -276,7 +278,7 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
// EObjectSelectionUtils requires us to adapt to EObject, since
// graphical edit parts can be provided as selection as well.
if (key == EObject.class) {
return modelElement;
return getModel();
}
return super.getAdapter(key);
}
......@@ -288,9 +290,17 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
return new Label();
}
/**
* Determines the text of the relationship label figure during a refresh.
* The default implementation returns the model element name.
*/
protected String determineRelationshipLabelFigureText() {
return getModel().getName();
}
/** Updates the bend points, based on the model. */
protected void refreshBendpoints() {
Points pts = getConnectionPoints(modelElement);
Points pts = getConnectionPoints(getModel());
List<AbsoluteBendpoint> figureConstraint = new ArrayList<AbsoluteBendpoint>();
int size = 0;
......@@ -308,7 +318,7 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
if (connection.getChildren().contains(relationshipLabel)) {
connection.remove(relationshipLabel);
}
relationshipLabel.setText(modelElement.getName());
relationshipLabel.setText(determineRelationshipLabelFigureText());
MidpointLocator mpl = new MidpointLocator(connection, size / 2) {
@Override
protected Point getReferencePoint() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment