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

Rename internal model classes with 'Impl' suffix #355

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
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
25 changes: 14 additions & 11 deletions examples/circlegraph/src/di.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -14,19 +14,20 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { Container, ContainerModule, injectable, inject } from "inversify";
import { Container, ContainerModule, injectable, inject } from 'inversify';
import {
TYPES, configureViewerOptions, SGraphView, ConsoleLogger, LogLevel, loadDefaultModules,
LocalModelSource, CircularNode, configureModelElement, SGraph, SEdge, selectFeature, PolylineEdgeView, MouseListener, SModelElement
LocalModelSource, CircularNode, configureModelElement, SGraphImpl, SEdgeImpl, selectFeature,
PolylineEdgeView, MouseListener, SModelElementImpl
} from 'sprotty';
import { Action, Point } from "sprotty-protocol";
import { CircleNodeView } from "./views";
import { Action, Point } from 'sprotty-protocol';
import { CircleNodeView } from './views';

const NodeCreator = Symbol('NodeCreator');

export default (nodeCreator: (point?: Point)=>void) => {
require("sprotty/css/sprotty.css");
require("../css/diagram.css");
require('sprotty/css/sprotty.css');
require('../css/diagram.css');

const circlegraphModule = new ContainerModule((bind, unbind, isBound, rebind) => {
bind(TYPES.ModelSource).to(LocalModelSource).inSingletonScope();
Expand All @@ -36,11 +37,13 @@ export default (nodeCreator: (point?: Point)=>void) => {
bind(DroppableMouseListener).toSelf().inSingletonScope();
bind(TYPES.MouseListener).toService(DroppableMouseListener);
const context = { bind, unbind, isBound, rebind };
configureModelElement(context, 'graph', SGraph, SGraphView);

configureModelElement(context, 'graph', SGraphImpl, SGraphView);
configureModelElement(context, 'node:circle', CircularNode, CircleNodeView);
configureModelElement(context, 'edge:straight', SEdge, PolylineEdgeView, {
configureModelElement(context, 'edge:straight', SEdgeImpl, PolylineEdgeView, {
disable: [selectFeature]
});

configureViewerOptions(context, {
needsClientLayout: false
});
Expand All @@ -57,12 +60,12 @@ class DroppableMouseListener extends MouseListener {

@inject(NodeCreator) nodeCreator: (point?: Point)=>void;

override dragOver(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] {
override dragOver(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] {
event.preventDefault();
return [];
}

override drop(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] {
override drop(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] {
this.nodeCreator({ x: event.offsetX, y:event.offsetY })
return [];
}
Expand Down
8 changes: 4 additions & 4 deletions examples/circlegraph/src/standalone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -15,10 +15,10 @@
********************************************************************************/

import {
TYPES, IActionDispatcher, ElementMove, MoveAction, LocalModelSource, getBasicType
TYPES, IActionDispatcher, ElementMove, MoveAction, LocalModelSource
} from 'sprotty';
import { Bounds, Point, SEdge, SelectAction, SGraph, SNode } from 'sprotty-protocol';
import createContainer from "./di.config";
import { Bounds, Point, SEdge, SelectAction, SGraph, SNode, getBasicType } from 'sprotty-protocol';
import createContainer from './di.config';

const NODE_SIZE = 60;

Expand Down
10 changes: 5 additions & 5 deletions examples/circlegraph/src/views.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -17,15 +17,15 @@
/** @jsx svg */
import { svg } from 'sprotty/lib/lib/jsx';
import { injectable } from 'inversify';
import { VNode } from "snabbdom";
import { RenderingContext, SNode, ShapeView } from 'sprotty';
import { VNode } from 'snabbdom';
import { RenderingContext, SNodeImpl, ShapeView } from 'sprotty';

/**
* A very simple example node consisting of a plain circle.
*/
@injectable()
export class CircleNodeView extends ShapeView {
render(node: SNode, context: RenderingContext): VNode | undefined {
render(node: SNodeImpl, context: RenderingContext): VNode | undefined {
if (!this.isVisible(node, context)) {
return undefined;
}
Expand All @@ -40,7 +40,7 @@ export class CircleNodeView extends ShapeView {
</g>;
}

protected getRadius(node: SNode): number {
protected getRadius(node: SNodeImpl): number {
const d = Math.min(node.size.width, node.size.height);
return d > 0 ? d / 2 : 0;
}
Expand Down
54 changes: 27 additions & 27 deletions examples/classdiagram/src/di.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -14,29 +14,29 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import '@vscode/codicons/dist/codicon.css';
import { Container, ContainerModule } from "inversify";
import { Container, ContainerModule } from 'inversify';
import {
TYPES, configureViewerOptions, SGraphView, SLabelView, SCompartmentView, JumpingPolylineEdgeView,
ConsoleLogger, LogLevel, loadDefaultModules, HtmlRootView, PreRenderedView, ExpandButtonView,
SRoutingHandleView, PreRenderedElement, HtmlRoot, SGraph, configureModelElement, SLabel,
SCompartment, SEdge, SButton, SRoutingHandle, RevealNamedElementActionProvider,
SRoutingHandleView, PreRenderedElementImpl, HtmlRootImpl, SGraphImpl, configureModelElement, SLabelImpl,
SCompartmentImpl, SEdgeImpl, SButtonImpl, SRoutingHandleImpl, RevealNamedElementActionProvider,
CenterGridSnapper, expandFeature, nameFeature, withEditLabelFeature, editLabelFeature,
RectangularNode, BezierCurveEdgeView, SBezierCreateHandleView, SBezierControlHandleView
} from 'sprotty';
import edgeIntersectionModule from "sprotty/lib/features/edge-intersection/di.config";
import edgeIntersectionModule from 'sprotty/lib/features/edge-intersection/di.config';
import { BezierMouseListener } from 'sprotty/lib/features/routing/bezier-edge-router';
import { ClassDiagramLabelValidationDecorator, ClassDiagramLabelValidator } from './label-validation';
import { ClassContextMenuItemProvider, ClassContextMenuService } from './menu';
import { ClassLabel, ClassNode, Icon, PropertyLabel } from "./model";
import { ClassLabel, ClassNode, Icon, PropertyLabel } from './model';
import { ClassDiagramModelSource } from './model-source';
import { PopupModelProvider } from "./popup";
import { IconView, NodeView } from "./views";
import { PopupModelProvider } from './popup';
import { IconView, NodeView } from './views';

export default (containerId: string) => {
require("sprotty/css/sprotty.css");
require("sprotty/css/command-palette.css");
require("sprotty/css/edit-label.css");
require("../css/diagram.css");
require('sprotty/css/sprotty.css');
require('sprotty/css/command-palette.css');
require('sprotty/css/edit-label.css');
require('../css/diagram.css');

const classDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) => {
bind(TYPES.ModelSource).to(ClassDiagramModelSource).inSingletonScope();
Expand All @@ -54,7 +54,7 @@ export default (containerId: string) => {
bind(TYPES.IContextMenuItemProvider).to(ClassContextMenuItemProvider);

const context = { bind, unbind, isBound, rebind };
configureModelElement(context, 'graph', SGraph, SGraphView);
configureModelElement(context, 'graph', SGraphImpl, SGraphView);
configureModelElement(context, 'node:package', RectangularNode, NodeView);
configureModelElement(context, 'node:class', ClassNode, NodeView, {
enable: [expandFeature, nameFeature, withEditLabelFeature]
Expand All @@ -65,21 +65,21 @@ export default (containerId: string) => {
configureModelElement(context, 'label:text', PropertyLabel, SLabelView, {
enable: [editLabelFeature]
});
configureModelElement(context, 'comp:comp', SCompartment, SCompartmentView);
configureModelElement(context, 'comp:header', SCompartment, SCompartmentView);
configureModelElement(context, 'comp:pkgcontent', SCompartment, SCompartmentView);
configureModelElement(context, 'comp:comp', SCompartmentImpl, SCompartmentView);
configureModelElement(context, 'comp:header', SCompartmentImpl, SCompartmentView);
configureModelElement(context, 'comp:pkgcontent', SCompartmentImpl, SCompartmentView);
configureModelElement(context, 'icon', Icon, IconView);
configureModelElement(context, 'label:icon', SLabel, SLabelView);
configureModelElement(context, 'edge:straight', SEdge, JumpingPolylineEdgeView);
configureModelElement(context, 'edge:bezier', SEdge, BezierCurveEdgeView);
configureModelElement(context, 'html', HtmlRoot, HtmlRootView);
configureModelElement(context, 'pre-rendered', PreRenderedElement, PreRenderedView);
configureModelElement(context, 'button:expand', SButton, ExpandButtonView);
configureModelElement(context, 'routing-point', SRoutingHandle, SRoutingHandleView);
configureModelElement(context, 'volatile-routing-point', SRoutingHandle, SRoutingHandleView);
configureModelElement(context, 'bezier-create-routing-point', SRoutingHandle, SBezierCreateHandleView);
configureModelElement(context, 'bezier-remove-routing-point', SRoutingHandle, SBezierCreateHandleView);
configureModelElement(context, 'bezier-routing-point', SRoutingHandle, SBezierControlHandleView);
configureModelElement(context, 'label:icon', SLabelImpl, SLabelView);
configureModelElement(context, 'edge:straight', SEdgeImpl, JumpingPolylineEdgeView);
configureModelElement(context, 'edge:bezier', SEdgeImpl, BezierCurveEdgeView);
configureModelElement(context, 'html', HtmlRootImpl, HtmlRootView);
configureModelElement(context, 'pre-rendered', PreRenderedElementImpl, PreRenderedView);
configureModelElement(context, 'button:expand', SButtonImpl, ExpandButtonView);
configureModelElement(context, 'routing-point', SRoutingHandleImpl, SRoutingHandleView);
configureModelElement(context, 'volatile-routing-point', SRoutingHandleImpl, SRoutingHandleView);
configureModelElement(context, 'bezier-create-routing-point', SRoutingHandleImpl, SBezierCreateHandleView);
configureModelElement(context, 'bezier-remove-routing-point', SRoutingHandleImpl, SBezierCreateHandleView);
configureModelElement(context, 'bezier-routing-point', SRoutingHandleImpl, SBezierControlHandleView);


configureViewerOptions(context, {
Expand Down
9 changes: 5 additions & 4 deletions examples/classdiagram/src/label-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable } from 'inversify';
import {
IEditLabelValidator, EditableLabel, SModelElement, EditLabelValidationResult, Severity, IEditLabelValidationDecorator
IEditLabelValidator, EditableLabel, SModelElementImpl, EditLabelValidationResult, Severity, IEditLabelValidationDecorator
} from 'sprotty';
import { injectable } from "inversify";

@injectable()
export class ClassDiagramLabelValidator implements IEditLabelValidator {
async validate(value: string, label: EditableLabel & SModelElement): Promise<EditLabelValidationResult> {
async validate(value: string, label: EditableLabel & SModelElementImpl): Promise<EditLabelValidationResult> {
if (value.length < 1) {
return {
severity: <Severity>'error',
Expand Down Expand Up @@ -67,4 +68,4 @@ export class ClassDiagramLabelValidationDecorator implements IEditLabelValidatio
containerElement.classList.remove('validation-ok', 'validation-warning', 'validation-error');
}
}
}
}
12 changes: 8 additions & 4 deletions examples/classdiagram/src/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { inject, injectable } from "inversify";
import { Anchor, DeleteElementAction, EMPTY_ROOT, GetSelectionAction, IActionDispatcher, IContextMenuItemProvider, IContextMenuService, LabeledAction, MenuItem, RequestExportSvgAction, SelectionResult, SModelRoot, TYPES, ViewerOptions } from "sprotty";
import { CenterAction, FitToScreenAction, Point, SetPopupModelAction } from "sprotty-protocol";
import { inject, injectable } from 'inversify';
import {
Anchor, DeleteElementAction, EMPTY_ROOT, GetSelectionAction, IActionDispatcher,
IContextMenuItemProvider, IContextMenuService, LabeledAction, MenuItem,
RequestExportSvgAction, SelectionResult, SModelRootImpl, TYPES, ViewerOptions
} from 'sprotty';
import { CenterAction, FitToScreenAction, Point, SetPopupModelAction } from 'sprotty-protocol';

@injectable()
export class ClassContextMenuService implements IContextMenuService {
Expand Down Expand Up @@ -72,7 +76,7 @@ export class ClassContextMenuItemProvider implements IContextMenuItemProvider {

@inject(TYPES.IActionDispatcher) readonly actionDispatcher: IActionDispatcher;

async getItems(root: Readonly<SModelRoot>, lastMousePosition?: Point | undefined): Promise<LabeledAction[]> {
async getItems(root: Readonly<SModelRootImpl>, lastMousePosition?: Point | undefined): Promise<LabeledAction[]> {
const selectionResult = await this.actionDispatcher.request<SelectionResult>(GetSelectionAction.create())
return [
new LabeledAction('Fit Diagram to Screen', [FitToScreenAction.create(root.children.map(child => child.id))]),
Expand Down
10 changes: 5 additions & 5 deletions examples/classdiagram/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -15,7 +15,7 @@
********************************************************************************/

import {
SShapeElement, Expandable, RectangularNode, Nameable, SLabel, WithEditableLabel, isEditableLabel,
SShapeElementImpl, Expandable, RectangularNode, Nameable, SLabelImpl, WithEditableLabel, isEditableLabel,
boundsFeature, layoutContainerFeature, layoutableChildFeature, fadeFeature
} from 'sprotty';

Expand All @@ -41,10 +41,10 @@ export class ClassNode extends RectangularNode implements Expandable, Nameable,
}
}

export class ClassLabel extends SLabel { }
export class PropertyLabel extends SLabel { }
export class ClassLabel extends SLabelImpl { }
export class PropertyLabel extends SLabelImpl { }

export class Icon extends SShapeElement {
export class Icon extends SShapeElementImpl {
static readonly DEFAULT_FEATURES = [boundsFeature, layoutContainerFeature, layoutableChildFeature, fadeFeature];

override size = {
Expand Down
6 changes: 3 additions & 3 deletions examples/classdiagram/src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from "inversify";
import { injectable, inject } from 'inversify';
import {
TYPES, IModelFactory, IPopupModelProvider
} from 'sprotty';
import { PreRenderedElement, RequestPopupModelAction, SModelElement, SModelRoot } from "sprotty-protocol";
import { ClassNode } from "./model";
import { PreRenderedElement, RequestPopupModelAction, SModelElement, SModelRoot } from 'sprotty-protocol';
import { ClassNode } from './model';

@injectable()
export class PopupModelProvider implements IPopupModelProvider {
Expand Down
2 changes: 1 addition & 1 deletion examples/classdiagram/src/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import createContainer from "./di.config";
import createContainer from './di.config';
import { TYPES, LocalModelSource } from 'sprotty';

export default function runClassDiagram() {
Expand Down
10 changes: 5 additions & 5 deletions examples/classdiagram/src/views.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Copyright (c) 2017-2023 TypeFox 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
Expand All @@ -17,14 +17,14 @@
/** @jsx svg */
import { svg } from 'sprotty/lib/lib/jsx';

import { RenderingContext, IView, RectangularNodeView, SNode, IViewArgs } from 'sprotty';
import { VNode } from "snabbdom";
import { RenderingContext, IView, RectangularNodeView, SNodeImpl, IViewArgs } from 'sprotty';
import { VNode } from 'snabbdom';
import { Icon } from './model';
import { injectable } from 'inversify';

@injectable()
export class NodeView extends RectangularNodeView {
override render(node: Readonly<SNode>, context: RenderingContext, args?: IViewArgs): VNode | undefined {
override render(node: Readonly<SNodeImpl>, context: RenderingContext, args?: IViewArgs): VNode | undefined {
if (!this.isVisible(node, context)) {
return undefined;
}
Expand All @@ -33,7 +33,7 @@ export class NodeView extends RectangularNodeView {
class-node-package={node.type === 'node:package'}
class-node-class={node.type === 'node:class'}
class-mouseover={node.hoverFeedback} class-selected={node.selected}
x="0" y="0" width={Math.max(node.size.width, 0)} height={Math.max(node.size.height, 0)}></rect>
x='0' y='0' width={Math.max(node.size.width, 0)} height={Math.max(node.size.height, 0)}></rect>
{context.renderChildren(node)}
</g>;
}
Expand Down
Loading