Skip to content

Commit

Permalink
Apply PR feedback: Properly re-export fixed Sprotty classes
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-fleck-at committed Mar 10, 2024
1 parent e4033ca commit 002df84
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 94 deletions.
32 changes: 0 additions & 32 deletions packages/client/src/features/routing/glsp-bezier-edge-router.ts

This file was deleted.

Expand Up @@ -14,15 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import {
GConnectableElement,
GParentElement,
GRoutableElement,
ManhattanEdgeRouter,
Point,
ResolvedHandleMove,
almostEquals
} from '@eclipse-glsp/sprotty';
import { ManhattanEdgeRouter, ResolvedHandleMove, GRoutableElement, almostEquals } from '@eclipse-glsp/sprotty';

export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
protected override applyInnerHandleMoves(edge: GRoutableElement, moves: ResolvedHandleMove[]): void {
Expand Down Expand Up @@ -64,16 +56,4 @@ export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
}
});
}

override getTranslatedAnchor(
connectable: GConnectableElement,
refPoint: Point,
refContainer: GParentElement,
edge: GRoutableElement,
anchorCorrection?: number | undefined
): Point {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return Point.isValid(anchor) ? anchor : refPoint;
}
}
32 changes: 0 additions & 32 deletions packages/client/src/features/routing/glsp-polyline-edge-router.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/features/routing/index.ts
Expand Up @@ -14,5 +14,4 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
export * from './glsp-manhattan-edge-router';
export * from './glsp-polyline-edge-router';
export * from './routing-module';
8 changes: 4 additions & 4 deletions packages/client/src/features/routing/routing-module.ts
Expand Up @@ -17,6 +17,7 @@ import {
AddRemoveBezierSegmentCommand,
AnchorComputerRegistry,
BezierDiamondAnchor,
BezierEdgeRouter,
BezierEllipseAnchor,
BezierRectangleAnchor,
DiamondAnchor,
Expand All @@ -26,14 +27,13 @@ import {
ManhattanDiamondAnchor,
ManhattanEllipticAnchor,
ManhattanRectangularAnchor,
PolylineEdgeRouter,
RectangleAnchor,
TYPES,
bindAsService,
configureCommand
} from '@eclipse-glsp/sprotty';
import { GLSPManhattanEdgeRouter } from './glsp-manhattan-edge-router';
import { GLSPPolylineEdgeRouter } from './glsp-polyline-edge-router';
import { GLSPBezierEdgeRouter } from './glsp-bezier-edge-router';

export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) => {
const context = { bind, unbind, isBound, rebind };
Expand All @@ -45,12 +45,12 @@ export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) =
bindAsService(context, TYPES.IAnchorComputer, ManhattanRectangularAnchor);
bindAsService(context, TYPES.IAnchorComputer, ManhattanDiamondAnchor);

bindAsService(context, TYPES.IEdgeRouter, GLSPPolylineEdgeRouter);
bindAsService(context, TYPES.IEdgeRouter, PolylineEdgeRouter);
bindAsService(context, TYPES.IAnchorComputer, EllipseAnchor);
bindAsService(context, TYPES.IAnchorComputer, RectangleAnchor);
bindAsService(context, TYPES.IAnchorComputer, DiamondAnchor);

bindAsService(context, TYPES.IEdgeRouter, GLSPBezierEdgeRouter);
bindAsService(context, TYPES.IEdgeRouter, BezierEdgeRouter);
bindAsService(context, TYPES.IAnchorComputer, BezierEllipseAnchor);
bindAsService(context, TYPES.IAnchorComputer, BezierRectangleAnchor);
bindAsService(context, TYPES.IAnchorComputer, BezierDiamondAnchor);
Expand Down
1 change: 1 addition & 0 deletions packages/glsp-sprotty/src/index.ts
Expand Up @@ -16,4 +16,5 @@
export * from './action-override';
export * from './feature-modules';
export * from './re-exports';
export * from './routing-override';
export * from './types';
22 changes: 18 additions & 4 deletions packages/glsp-sprotty/src/re-exports.ts
Expand Up @@ -192,12 +192,26 @@ export * from 'sprotty/lib/features/open/open';
export * from 'sprotty/lib/features/projection/model';
export * from 'sprotty/lib/features/projection/views';

export * from 'sprotty/lib/features/routing/abstract-edge-router';
export {
DefaultAnchors,
LinearRouteOptions,
Side,
AbstractEdgeRouter as SprottyAbstractEdgeRouter
} from 'sprotty/lib/features/routing/abstract-edge-router';
export * from 'sprotty/lib/features/routing/anchor';
export * from 'sprotty/lib/features/routing/bezier-anchors';
export * from 'sprotty/lib/features/routing/bezier-edge-router';
export {
AddRemoveBezierSegmentAction,
AddRemoveBezierSegmentCommand,
BezierMouseListener,
BezierEdgeRouter as SprottyBezierEdgeRouter
} from 'sprotty/lib/features/routing/bezier-edge-router';
export * from 'sprotty/lib/features/routing/manhattan-anchors';
export * from 'sprotty/lib/features/routing/manhattan-edge-router';
export {
ManhattanRouterOptions,
ManhattanEdgeRouter as SprottyManhattanEdgeRouter
} from 'sprotty/lib/features/routing/manhattan-edge-router';

// Alias SModel types
export {
Connectable,
Expand All @@ -214,7 +228,7 @@ export {
isConnectable
} from 'sprotty/lib/features/routing/model';
export * from 'sprotty/lib/features/routing/polyline-anchors';
export * from 'sprotty/lib/features/routing/polyline-edge-router';
export { PolylineRouteOptions, PolylineEdgeRouter as SprottyPolylineEdgeRouter } from 'sprotty/lib/features/routing/polyline-edge-router';
export * from 'sprotty/lib/features/routing/routing';
export * from 'sprotty/lib/features/routing/views';

Expand Down
88 changes: 88 additions & 0 deletions packages/glsp-sprotty/src/routing-override.ts
@@ -0,0 +1,88 @@
/********************************************************************************
* Copyright (c) 2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { Point } from '@eclipse-glsp/protocol';
import { injectable } from 'inversify';
import {
SConnectableElementImpl,
SParentElementImpl,
SRoutableElementImpl,
AbstractEdgeRouter as SprottyAbstractEdgeRouter,
BezierEdgeRouter as SprottyBezierEdgeRouter,
ManhattanEdgeRouter as SprottyManhattanEdgeRouter,
PolylineEdgeRouter as SprottyPolylineEdgeRouter
} from 'sprotty';
import { GConnectableElement, GParentElement, GRoutableElement } from './re-exports';

@injectable()
export abstract class AbstractEdgeRouter extends SprottyAbstractEdgeRouter {
override getTranslatedAnchor(
connectable: SConnectableElementImpl,
refPoint: Point,
refContainer: SParentElementImpl,
edge: SRoutableElementImpl,
anchorCorrection?: number | undefined
): Point {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return Point.isValid(anchor) ? anchor : refPoint;
}
}

@injectable()
export class PolylineEdgeRouter extends SprottyPolylineEdgeRouter {
override getTranslatedAnchor(
connectable: GConnectableElement,
refPoint: Point,
refContainer: GParentElement,
edge: GRoutableElement,
anchorCorrection?: number | undefined
): Point {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return Point.isValid(anchor) ? anchor : refPoint;
}
}

@injectable()
export class ManhattanEdgeRouter extends SprottyManhattanEdgeRouter {
override getTranslatedAnchor(
connectable: GConnectableElement,
refPoint: Point,
refContainer: GParentElement,
edge: GRoutableElement,
anchorCorrection?: number | undefined
): Point {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return Point.isValid(anchor) ? anchor : refPoint;
}
}

@injectable()
export class BezierEdgeRouter extends SprottyBezierEdgeRouter {
override getTranslatedAnchor(
connectable: GConnectableElement,
refPoint: Point,
refContainer: GParentElement,
edge: GRoutableElement,
anchorCorrection?: number | undefined
): Point {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return Point.isValid(anchor) ? anchor : refPoint;
}
}

0 comments on commit 002df84

Please sign in to comment.