Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into e2etesting-17
Browse files Browse the repository at this point in the history
  • Loading branch information
sgraband committed Jan 16, 2020
2 parents bc7d215 + 2ac0473 commit 7d39316
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 13 deletions.
2 changes: 0 additions & 2 deletions client/sprotty-ecore/css/diagram.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
}

svg {
margin-top: 15px;
width: 100%;
height: 500px;
border-style: solid;
Expand Down Expand Up @@ -226,4 +225,3 @@ svg {
background-color: DodgerBlue !important;
color: #ffffff;
}

20 changes: 18 additions & 2 deletions client/sprotty-ecore/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,25 @@ import {
} from "@glsp/sprotty-client/lib";
import executeCommandModule from "@glsp/sprotty-client/lib/features/execute/di.config";
import { Container, ContainerModule } from "inversify";
import {EditLabelUIAutocomplete} from "./features/edit-label-autocomplete";
import { EditLabelUI } from "sprotty/lib";

import { EditLabelUIAutocomplete } from "./features/edit-label-autocomplete";
import { LabelSelectionFeedback } from "./feedback";
import {ArrowEdge, CompositionEdge, InheritanceEdge, LabeledNode, SEditableLabel, IconDataType, IconEnum, IconInterface, IconAbstract, IconClass, SLabelNodeAttribute, SLabelNodeLiteral} from "./model";
import {
ArrowEdge,
CompositionEdge,
IconAbstract,
IconClass,
IconDataType,
IconEnum,
IconInterface,
InheritanceEdge,
LabeledNode,
SEditableLabel,
SLabelNode,
SLabelNodeAttribute,
SLabelNodeLiteral
} from "./model";
import { ArrowEdgeView, ClassNodeView, CompositionEdgeView, IconView, InheritanceEdgeView, LabelNodeView } from "./views";

export default (containerId: string) => {
Expand All @@ -89,6 +104,7 @@ export default (containerId: string) => {
configureModelElement(context, 'label:name', SEditableLabel, SLabelView);
configureModelElement(context, 'label:edge-name', SEditableLabel, SLabelView);
configureModelElement(context, 'label:edge-multiplicity', SEditableLabel, SLabelView);
configureModelElement(context, 'label:instancename', SLabelNode, LabelNodeView);
configureModelElement(context, 'node:attribute', SLabelNodeAttribute, LabelNodeView);
configureModelElement(context, 'node:enumliteral', SLabelNodeLiteral, LabelNodeView);
configureModelElement(context, 'node:operation', SNode, RectangularNodeView);
Expand Down
9 changes: 6 additions & 3 deletions client/sprotty-ecore/src/views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,19 @@ export class AggregationEdgeView extends DiamondEdgeView {
@injectable()
export class LabelNodeView extends SLabelView {
render(labelNode: Readonly<SLabelNode>, context: RenderingContext): VNode {
const image = require("../images/" + labelNode.imageName);
let image;
if (labelNode.imageName) {
image = require("../images/" + labelNode.imageName);
}

const vnode = (
<g
class-selected={labelNode.selected}
class-mouseover={labelNode.hoverFeedback}
class-sprotty-label-node={true}
>
<image class-sprotty-icon={true} href={image} y={-4} width={13} height={8}></image>
<text class-sprotty-label={true} x={20}>{labelNode.text}</text>
{ !!image && <image class-sprotty-icon={true} href={image} y={-4} width={13} height={8}></image> }
<text class-sprotty-label={true} x={!!image ? 20 : 0}>{labelNode.text}</text>
</g>
);

Expand Down
2 changes: 1 addition & 1 deletion client/theia-ecore/src/node/ecore-file-generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class EcoreFileGenServer implements FileGenServer, BackendApplicationCont

generateEcore(name: string, prefix: string, uri: string, workspacePath: string): Promise<string> {
const jarPath = path.resolve(__dirname, '..', '..',
'src/server', 'ecore-backend-server-1.0-SNAPSHOT-jar-with-dependencies.jar');
'server', 'ecore-backend-server-1.0-SNAPSHOT-jar-with-dependencies.jar');
if (jarPath.length === 0) {
throw new Error('The EcoreGeneration.jar is not found. ');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public EdgeTypeHint createDefaultEdgeTypeHint(String elementId) {
public List<ShapeTypeHint> getNodeTypeHints() {
List<ShapeTypeHint> hints = new ArrayList<>();
hints.add(new ShapeTypeHint(DefaultTypes.GRAPH, false, false, false, false,
List.of(Types.ECLASS, Types.ABSTRACT, Types.INTERFACE, Types.ENUM)));
List.of(Types.ECLASS, Types.ABSTRACT, Types.INTERFACE, Types.ENUM, Types.DATATYPE)));
hints.add(new ShapeTypeHint(Types.ECLASS, true, true, false, false, List.of(Types.ATTRIBUTE, Types.OPERATION)));
hints.add(new ShapeTypeHint(Types.ENUM, true, true, false, false, List.of(Types.ENUMLITERAL)));
hints.add(new ShapeTypeHint(Types.DATATYPE, true, true, false, true));
Expand Down Expand Up @@ -120,6 +120,7 @@ public Map<String, EClass> getTypeMappings() {
mappings.put(Types.ATTRIBUTE, GraphPackage.Literals.GLABEL);
mappings.put(Types.OPERATION, GraphPackage.Literals.GLABEL);
mappings.put(Types.ENUMLITERAL, GraphPackage.Literals.GLABEL);
mappings.put(Types.LABEL_INSTANCE, GraphPackage.Literals.GLABEL);
return mappings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ public GNode create(EDataType eDataType) {
.hAlign(GConstants.HAlign.CENTER) //
.resizeContainer(true) //
.build()) //
.add(new GLabelBuilder(Types.LABEL_TEXT) //
.addCssClass(CSS.ITALIC).id(toId(eDataType) + "_typeLabel")//
.add(new GLabelBuilder(Types.LABEL_INSTANCE) //
.addCssClass(CSS.ITALIC)//
.id(toId(eDataType) + Types.LABEL_INSTANCE)//
.text(eDataType.getInstanceClassName()) //
.build())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void execute(AbstractOperationAction action, GraphicalModelState graphica
ApplyLabelEditOperationAction editLabelAction = (ApplyLabelEditOperationAction) action;
EcoreFacade facade = EcoreModelState.getEcoreFacade(graphicalModelState);
EcoreModelIndex index = EcoreModelState.getModelState(graphicalModelState).getIndex();

Optional<String> type = index.findElementByClass(editLabelAction.getLabelId(), GModelElement.class).map(e -> e.getType());
if (type.isPresent()) {
switch (type.get()) {
Expand All @@ -81,7 +80,16 @@ public void execute(AbstractOperationAction action, GraphicalModelState graphica
shape.setSemanticElement(facade.createProxy(node_semantic));
}
break;
case Types.LABEL_INSTANCE:
node = getOrThrow(index.findElementByClass(editLabelAction.getLabelId(), GNode.class),
"No parent Node for element with id " + editLabelAction.getLabelId() + " found");

node_semantic = getOrThrow(index.getSemantic(node),
"No semantic element for labelContainer with id " + node.getId() + " found");
if (node_semantic instanceof EClassifier) {
((EClassifier) node_semantic).setInstanceClassName(editLabelAction.getText().trim());
}
break;
case Types.ATTRIBUTE:
EAttribute attribute_semantic = (EAttribute) getOrThrow(index.getSemantic(editLabelAction.getLabelId()),
"No semantic element for label with id " + editLabelAction.getLabelId() + " found");
Expand Down Expand Up @@ -138,7 +146,6 @@ public void execute(AbstractOperationAction action, GraphicalModelState graphica
throw new GLSPServerException("Multiplicity of reference with id " + editLabelAction.getLabelId() + " has a wrong input format", new IllegalArgumentException());
}
break;

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static final class Types {
public static final String INHERITANCE = "edge:inheritance";
public static final String ABSTRACT = "node:class:abstract";
public static final String INTERFACE = "node:class:interface";
public static final String LABEL_INSTANCE = "label:instancename";

private Types() {
};
Expand Down

0 comments on commit 7d39316

Please sign in to comment.