Skip to content

Commit

Permalink
Merge pull request #109 from eclipse-emfcloud/issues-105-106
Browse files Browse the repository at this point in the history
#106 Update dependencies to stabilize property-view
  • Loading branch information
CamilleLetavernier committed Oct 27, 2021
2 parents 0577356 + a9fcbd3 commit 0b62544
Show file tree
Hide file tree
Showing 51 changed files with 1,302 additions and 1,054 deletions.
3 changes: 1 addition & 2 deletions client/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"typescriptHero.imports.insertSemicolons": true,
"typescriptHero.imports.multiLineTrailingComma": false,
"typescriptHero.imports.ignoredFromRemoval": [
"react",
"snabbdom-jsx"
"react"
],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand Down
4 changes: 2 additions & 2 deletions client/configs/base.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaVersion": 8,
"ecmaFeatures": {
"jsx": true
}
Expand Down Expand Up @@ -34,7 +34,7 @@
"env": {
"browser": true,
"mocha": true,
"es6": true
"es2017": true
},
"ignorePatterns": [
"node_modules",
Expand Down
46 changes: 23 additions & 23 deletions client/configs/base.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"compilerOptions": {
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"noImplicitAny": true,
"noEmitOnError": false,
"noImplicitThis": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"lib": [
"es6",
"dom"
],
"sourceMap": true
}
"compilerOptions": {
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"noImplicitAny": true,
"noEmitOnError": false,
"noImplicitThis": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2017",
"jsx": "react",
"lib": [
"ES2017",
"dom"
],
"sourceMap": true
}
}
3 changes: 2 additions & 1 deletion client/configs/errors.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"import/export": "off", // we have multiple exports due to namespaces, enums and classes that share the same name
"import/no-deprecated": "error",
// eslint-plugin-no-null
"no-null/no-null": "error"
"no-null/no-null": "error",
"react/react-in-jsx-scope": "off"
}
}
2 changes: 1 addition & 1 deletion client/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.4.0",
"lerna": "2.11.0",
"version": "0.2.0",
"useWorkspaces": true,
"npmClient": "yarn",
Expand Down
30 changes: 28 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,40 @@
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-react": "^7.20.3",
"keytar": "^7.7.0",
"lerna": "^2.11.0",
"npm-run-all": "^4.1.5",
"testcafe": "^1.11.0",
"vscode-languageclient": "^6.1.3"
},
"resolutions": {
"**/sprotty": "0.10.0-next.0e06051",
"**/sprotty-theia": "0.10.0-next.a5ea006"
"**/@theia/core": "1.18.0",
"**/@theia/cli": "1.18.0",
"**/@theia/editor": "1.18.0",
"**/@theia/filesystem": "1.18.0",
"**/@theia/markers": "1.18.0",
"**/@theia/messages": "1.18.0",
"**/@theia/monaco": "1.18.0",
"**/@theia/navigator": "1.18.0",
"**/@theia/plugin-ext-vscode": "1.18.0",
"**/@theia/plugin-ext": "1.18.0",
"**/@theia/plugin": "1.18.0",
"**/@theia/preferences": "1.18.0",
"**/@theia/process": "1.18.0",
"**/@theia/property-view": "1.18.0",
"**/@theia/terminal": "1.18.0",
"**/@theia/workspace": "1.18.0",
"**/@eclipse-emfcloud/modelserver-theia": "0.8.0-next.6b3138d6",
"**/@eclipse-emfcloud/modelserver-jsonforms-property-view": "0.8.0-next.c8999361",
"**/@eclipse-emfcloud/jsonforms-property-view": "0.8.0-next.c8999361",
"**/@eclipse-emfcloud/theia-tree-editor": "0.7.0-next.0324b32",
"**/@eclipse-glsp/client": "0.9.0-next.ab8b59c9",
"**/@eclipse-glsp/protocol": "0.9.0-next.ab8b59c9",
"**/@eclipse-glsp/theia-integration": "0.9.0-next.f4750f16",
"**/snabbdom": "3.0.3",
"**/snabbdom-jsx": "^0.4.2",
"**/sprotty": "0.10.0-next.4039435",
"**/sprotty-theia": "0.10.0-next.fb0f9eb"
},
"workspaces": [
"browser-app",
Expand Down
25 changes: 12 additions & 13 deletions client/packages/common/src/browser/style/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
* SPDX-License-Identifier: EPL-2.0 OR MIT
********************************************************************************/

.p-Menu-itemIcon.fa.fa-project-diagram {
font-size: smaller;
}

.p-Menu-itemIcon.fa.fa-project-diagram:before {
font-family: "Font Awesome 5 Free";
}

.p-Menu-itemIcon.ecore-glsp-icon {
background-repeat: no-repeat;
background-position: center;
Expand All @@ -26,6 +18,9 @@
background-size: 16px 16px;
height: 16px;
width: 16px;
}

.ecore-tool-button .ecoreimg {
margin-right: 6px;
}

Expand Down Expand Up @@ -241,29 +236,33 @@
background-image: url(../../../resources/icons/EcoreModelFile.gif);
height: 16px;
width: 16px;
margin-left: -3px;
margin-right: 6px;
}

.p-TabBar.theia-app-centers .p-TabBar-tabIcon.ecoremodelfileTabIcon {
background-image: url(../../../resources/icons/EcoreModelFile.gif);
.p-TabBar.theia-app-centers .p-TabBar-tabIcon {
height: 16px;
width: 16px;
background-size: 16px;
background-position-y: 0px;
background-color: transparent;
background-repeat: no-repeat;
}

.p-TabBar.theia-app-centers .p-TabBar-tabIcon.ecoremodelfileTabIcon {
background-image: url(../../../resources/icons/EcoreModelFile.gif);
}

.newecorefile {
background-image: url(../../../resources/icons/NewEcoreFile.gif);
height: 16px;
width: 16px;
margin-left: -3px;
}

.genmodelfile {
background-image: url(../../../resources/icons/GenModelModelFile.gif)!important;
height: 16px;
width: 16px;
margin-left: -3px;
margin-right: 6px;
background-repeat: no-repeat!important;
background-position: center!important;
}
10 changes: 5 additions & 5 deletions client/packages/ecore-property-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
],
"dependencies": {
"@eclipse-emfcloud/theia-ecore": "0.2.0",
"@eclipse-emfcloud/jsonforms-property-view": "0.8.0-next.3a48b86a",
"@eclipse-emfcloud/modelserver-jsonforms-property-view": "0.8.0-next.3a48b86a",
"@eclipse-emfcloud/modelserver-theia": "0.8.0-next.0817744e",
"@eclipse-glsp/client": "0.9.0-RC01",
"@eclipse-glsp/theia-integration": "0.9.0-RC01",
"@eclipse-emfcloud/jsonforms-property-view": "next",
"@eclipse-emfcloud/modelserver-jsonforms-property-view": "next",
"@eclipse-emfcloud/modelserver-theia": "next",
"@eclipse-glsp/client": "next",
"@eclipse-glsp/theia-integration": "next",
"@theia/core": "^1.0.0",
"@theia/property-view": "^1.0.0",
"@theia/workspace": "^1.0.0"
Expand Down
12 changes: 8 additions & 4 deletions client/packages/ecore-property-view/src/browser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
import { ModelServerClient } from "@eclipse-emfcloud/modelserver-theia";

export async function getElementFromModelServer(modelServerClient: ModelServerClient, modelUri: string, elementId: string): Promise<Object> {
return modelServerClient.getElementById(modelUri, elementId)
return modelServerClient.getElementById(modelUri, elementId, "json")
.then(response => {
const returnObject = response.body as any;
// add semanticUri to jsonforms data structure
returnObject["semanticUri"] = elementId;
return returnObject;
if (typeof returnObject === "object" && returnObject !== undefined) {
// add elementId to jsonforms data structure
returnObject["semanticUri"] = elementId;
return returnObject;
}
// in case error message occurs the return object is a string, we return an empty object
return {};
});
}
66 changes: 47 additions & 19 deletions client/packages/ecore-property-view/src/browser/widget-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { ModelserverAwareWidgetProvider } from "@eclipse-emfcloud/modelserver-jsonforms-property-view";
import {
CommandExecutionResult,
CommandExecutionType,
ModelServerCommand,
ModelServerMessage,
ModelServerObject,
Expand All @@ -25,29 +26,40 @@ import {
import { isGlspSelection } from "@eclipse-glsp/theia-integration/lib/browser/diagram";
import URI from "@theia/core/lib/common/uri";
import { injectable, postConstruct } from "inversify";
import { debounce, isEqual, isObject, transform } from "lodash";
import { isEqual, isObject, transform } from "lodash";

import { getElementFromModelServer } from "./utils";

@injectable()
export class EcoreGlspPropertyViewWidgetProvider extends ModelserverAwareWidgetProvider {

canHandle(selection: Object | undefined): number {
return isGlspSelection(selection) ? 100 : 0;
}

@postConstruct()
init(): void {
this.propertyDataServices = this.propertyDataServices.concat(this.contributions.getContributions());
this.currentPropertyData = {};
this.currentModelUri = "";
this.jsonFormsWidget.onChange(
debounce((jsonFormsData: any) => {
this.handleChanges(jsonFormsData);
}, 200)
);
this.jsonFormsWidget.onChange((jsonFormsData: Object) => this.handleChanges(jsonFormsData));

this.jsonFormsWidget.onAttach(() => this.doSubscribe());
this.jsonFormsWidget.onDetach(() => this.doUnsubscribe());

this.subscriptionService.onIncrementalUpdateListener(incrementalUpdate => this.updateWidgetData(incrementalUpdate));
}

canHandle(selection: Object | undefined): number {
return isGlspSelection(selection) ? 100 : 0;
protected doSubscribe(): void {
if (this.selectionService.selection && isGlspSelection(this.selectionService.selection) && this.selectionService.selection.sourceUri) {
this.currentModelUri = this.getRelativeModelUri(this.selectionService.selection.sourceUri);
this.modelServerClient.subscribe(this.currentModelUri);
}
}

protected doUnsubscribe(): void {
this.modelServerClient.unsubscribe(this.currentModelUri);
this.currentModelUri = "";
}

updateContentWidget(selection: any): void {
Expand All @@ -63,19 +75,12 @@ export class EcoreGlspPropertyViewWidgetProvider extends ModelserverAwareWidgetP
});
}

protected async updateWidgetData(message: ModelServerMessage): Promise<void> {
protected updateWidgetData(message: ModelServerMessage): void {
if (message.type !== "incrementalUpdate" && message.type !== "fullUpdate") {
return;
}
if (this.isCommandExecutionResult(message.data)) {
if (message.data.affectedObjects && message.data.affectedObjects.length > 0) {
const affectedObject = message.data.affectedObjects[0];
const relativeRefURI = new URI(this.getRelativeModelUri(affectedObject.$ref.replace("file:", "")));
if (this.isCurrentModelUri(relativeRefURI)) {
this.currentPropertyData = await getElementFromModelServer(this.modelServerClient, this.currentModelUri, this.currentPropertyData.semanticUri);
this.jsonFormsWidget.updatePropertyViewData(this.currentPropertyData);
}
}
this.updateViaCommand(message.data, this.currentPropertyData.semanticUri);
}
}

Expand All @@ -86,8 +91,31 @@ export class EcoreGlspPropertyViewWidgetProvider extends ModelserverAwareWidgetP
&& "affectedObjects" in object;
}

protected updateViaCommand(result: CommandExecutionResult, semanticUri: string): void {
// no-op
protected async updateViaCommand(commandResult: CommandExecutionResult, semanticUri: string): Promise<void> {
switch (commandResult.type) {
case CommandExecutionType.EXECCUTE: {
if (commandResult.source && commandResult.source.feature && commandResult.source.dataValues) {
this.currentPropertyData[commandResult.source.feature] = commandResult.source.dataValues[0];
this.jsonFormsWidget.updatePropertyViewData(this.currentPropertyData);
}
break;
}
case CommandExecutionType.UNDO:
case CommandExecutionType.REDO: {
if (commandResult.affectedObjects && commandResult.affectedObjects.length > 0) {
const changedObject = commandResult.affectedObjects[0];
const relativeRefURI = new URI(this.getRelativeModelUri(changedObject.$ref.replace("file:", "")));
if (this.isCurrentModelUri(relativeRefURI)) {
await new Promise(f => setTimeout(f, 250));
const response = await getElementFromModelServer(this.modelServerClient, this.currentModelUri, this.currentPropertyData.semanticUri);
this.currentPropertyData = {};
this.currentPropertyData = response;
this.jsonFormsWidget.updatePropertyViewData(this.currentPropertyData);
}
}
break;
}
}
}

protected isCurrentModelUri(uri: URI): boolean {
Expand Down
6 changes: 3 additions & 3 deletions client/packages/ecore-tree-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"src"
],
"dependencies": {
"@eclipse-emfcloud/modelserver-theia": "0.8.0-next.0817744e",
"@eclipse-emfcloud/ecore-glsp-common": "0.2.0",
"@eclipse-emfcloud/modelserver-theia": "next",
"@eclipse-emfcloud/theia-tree-editor": "next",
"@theia/core": "^1.0.0",
"@theia/editor": "^1.0.0",
"@theia/filesystem": "^1.0.0",
"@theia/workspace": "^1.0.0",
"uuid": "^3.3.2",
"@eclipse-emfcloud/theia-tree-editor": "0.7.0-next.8e8d607"
"uuid": "^3.3.2"
},
"devDependencies": {
"rimraf": "^2.6.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0 OR MIT
********************************************************************************/
import { TreeEditor } from "@eclipse-emfcloud/theia-tree-editor";
import { LabelProviderContribution } from "@theia/core/lib/browser";
import { codicon, LabelProviderContribution } from "@theia/core/lib/browser";
import URI from "@theia/core/lib/common/uri";
import { injectable } from "inversify";

Expand All @@ -33,7 +33,7 @@ const ICON_CLASSES: Map<string, string> = new Map([
]);

/* Icon for unknown types */
const UNKNOWN_ICON = "fa fa-question-circle";
const UNKNOWN_ICON = `${codicon("question")}`;

@injectable()
export class TreeLabelProvider implements LabelProviderContribution {
Expand Down
2 changes: 1 addition & 1 deletion client/packages/sprotty-ecore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@eclipse-emfcloud/ecore-glsp-common": "0.2.0",
"@eclipse-glsp/client": "0.9.0-RC01",
"@eclipse-glsp/client": "next",
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
Expand Down

0 comments on commit 0b62544

Please sign in to comment.