Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #457: edition of messages with scrolled diagrams #458

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

import org.eclipse.draw2d.ConnectionLayer;
import org.eclipse.draw2d.ConnectionRouter;
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.ViewportUtilities;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.ecore.EClass;
Expand Down Expand Up @@ -474,13 +476,17 @@ protected Command getReconnectSourceCommand(ReconnectRequest request) {

// This is known to exist because we're manipulating an existing message in the diagram
MMessage message = getInteraction().getMessage(_message.get()).get();
int y = request.getLocation().y();

Point location = request.getLocation();

fixScroll(location);
int y = location.y();
OptionalInt yPosition = OptionalInt.of(y);

org.eclipse.emf.common.command.Command result = null;

// Check for semantic re-ordering if we're not connecting to an execution
if (!getExecutionFinish(lifeline.get(), request.getLocation()).isPresent()) {
if (!getExecutionFinish(lifeline.get(), location).isPresent()) {
// should ensure the execution start is nudged
result = getNudgeObstacleCommand(request, message.getSend().get(), y);
}
Expand Down Expand Up @@ -562,7 +568,11 @@ protected Command getReconnectTargetCommand(ReconnectRequest request) {

// This is known to exist because we're manipulating an existing message in the diagram
MMessage message = getInteraction().getMessage(_message.get()).get();
int y = request.getLocation().y();

Point location = request.getLocation();

fixScroll(location);
int y = location.y();
if (!isForce(request) && MessageUtil.isSynchronous(message.getElement().getMessageSort())
// Synchronous message that is not a self-message
&& message.getSender().isPresent()
Expand All @@ -574,7 +584,7 @@ protected Command getReconnectTargetCommand(ReconnectRequest request) {

org.eclipse.emf.common.command.Command result = null;
// Check for semantic re-ordering if we're not connecting to an execution
if (!getExecutionStart(lifeline.get(), request.getLocation()).isPresent()
if (!getExecutionStart(lifeline.get(), location).isPresent()
// Or if we're moving both ends and the other is not connecting to an execution
&& !(isForce(request) && message.getSender()
.flatMap(sndr -> getExecutionFinish(sndr, getUpdatedSourceLocation(request)))
Expand Down Expand Up @@ -624,6 +634,22 @@ protected Command getReconnectTargetCommand(ReconnectRequest request) {
return wrap(result);
}

private void fixScroll(Point location) {
Viewport enclosingViewport = ViewportUtilities.getRootViewport(getHostFigure());
if (enclosingViewport != null) {
location.performTranslate(enclosingViewport.getHorizontalRangeModel().getValue(),
enclosingViewport.getVerticalRangeModel().getValue());
}
}

private void unfixScroll(Point location) {
Viewport enclosingViewport = ViewportUtilities.getRootViewport(getHostFigure());
if (enclosingViewport != null) {
location.performTranslate(-enclosingViewport.getHorizontalRangeModel().getValue(),
-enclosingViewport.getVerticalRangeModel().getValue());
}
}

protected boolean shouldCreateExecution() {
return Activator.getDefault().getPreferences().isAutoCreateExecutionForSyncMessage();
}
Expand Down