Skip to content

Commit

Permalink
[997] Disable EdgeReconnection since edge edition is enabled
Browse files Browse the repository at this point in the history
- Replace the sprotty reconnect command by an empty one. The empty
reconnect command will be removed as soon as we will support the edge
reconnection.
- An edge end can still be moved, but the move will never be taken
account.

Bug: #997
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
  • Loading branch information
gcoutable authored and sbegaudeau committed Oct 3, 2022
1 parent 01c8771 commit 63b6c43
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService;
import org.eclipse.sirius.components.diagrams.Diagram;
import org.eclipse.sirius.components.diagrams.Edge;
import org.eclipse.sirius.components.diagrams.FreeFormLayoutStrategy;
import org.eclipse.sirius.components.diagrams.Node;
import org.eclipse.sirius.components.diagrams.Position;
import org.eclipse.sirius.components.diagrams.description.DiagramDescription;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void testNodeMoveUpdatesEdgeRoutingPoints() {
Diagram diagram = TestLayoutDiagramBuilder.diagram("Root") //$NON-NLS-1$
.nodes()
.rectangleNode("Parent").at(100, 100).of(500, 500) //$NON-NLS-1$
.childNodes()
.childNodes(new FreeFormLayoutStrategy())
.rectangleNode("First Child").at(100, 100).of(100, 100).and() //$NON-NLS-1$
.rectangleNode("Second Child").at(300, 300).of(100, 100).and() //$NON-NLS-1$
.and()
Expand Down Expand Up @@ -107,10 +108,10 @@ public Optional<IRepresentationDescription> findById(IEditingContext editingCont
};

NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider, List.of());

LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()),
new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
new ELKLayoutedDiagramProvider(List.of()), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);

return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
* Obeo - initial API and implementation
*******************************************************************************/

import { ContainerModule } from 'inversify';
import { ContainerModule, decorate, inject } from 'inversify';
import {
Command,
CommandExecutionContext,
CommandReturn,
configureCommand,
configureModelElement,
DeleteElementCommand,
EmptyGroupView,
ReconnectCommand,
ReconnectAction,
SDanglingAnchor,
TYPES,
} from 'sprotty';
import { SiriusSwitchEditModeCommand } from './siriusSwitchEditModeCommand';

Expand All @@ -28,7 +32,30 @@ import { SiriusSwitchEditModeCommand } from './siriusSwitchEditModeCommand';
export const siriusEdgeEditModule = new ContainerModule((bind, unbind, isBound, rebind) => {
const context = { bind, isBound };
configureCommand(context, SiriusSwitchEditModeCommand);
configureCommand(context, ReconnectCommand);
configureCommand(context, EmptyReconnectCommand);
configureCommand(context, DeleteElementCommand);
configureModelElement(context, 'dangling-anchor', SDanglingAnchor, EmptyGroupView);
});

/**
* Prevent the reconnect to fail since we activate the edge edition.
* This class will be removed soon, when we will support the edge reconnection.
*/
class EmptyReconnectCommand extends Command {
static readonly KIND = ReconnectAction.KIND;

constructor(protected readonly action: ReconnectAction) {
super();
}

override execute(context: CommandExecutionContext): CommandReturn {
return context.root;
}
undo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
redo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
}
decorate(inject(TYPES.Action) as ParameterDecorator, EmptyReconnectCommand, 0);

0 comments on commit 63b6c43

Please sign in to comment.