Skip to content

Commit

Permalink
Merge branch 'main' of github.com:borkdominik/bigER
Browse files Browse the repository at this point in the history
  • Loading branch information
plglaser committed Aug 9, 2022
2 parents 6dd1993 + a0e68a6 commit 707894a
Show file tree
Hide file tree
Showing 20 changed files with 231 additions and 100 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# matrix build of server (Java) and client (Node)
name: Build

# run workflow on pushes/pull requests to main or manually
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
# builds the server using Gradle on ubuntu, macos, windows with java 11, 17
build-server:
strategy:
matrix:
java: [11, 17]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} with Java ${{ matrix.Java }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.Java }}
distribution: 'temurin'
- run: language-server/gradlew -p language-server/ clean
- run: language-server/gradlew -p language-server/ build
# builds the client using yarn on ubuntu, macos, windows with Node.js 16
build-client:
strategy:
matrix:
node: ['16']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: yarn --cwd webview
- run: yarn --cwd extension
2 changes: 1 addition & 1 deletion extension/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"operator-linebreak": ["error", "after"],
"no-multi-assign": "error",
"no-dupe-class-members": "error",
"function-paren-newline": ["error", "never"],
"function-paren-newline": ["error", "multiline"],
"@typescript-eslint/no-explicit-any": "off",
"no-duplicate-imports": "error",
"no-alert": "error",
Expand Down
25 changes: 19 additions & 6 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"activationEvents": [
"onLanguage:erdiagram",
"onCommand:erdiagram.diagram.open",
"onCommand:erdiagram.model.new"
"onCommand:erdiagram.model.newEmpty",
"onCommand:erdiagram.model.newSample"
],
"files": [
"dist",
Expand Down Expand Up @@ -98,8 +99,13 @@
"category": "bigER"
},
{
"command": "erdiagram.model.new",
"title": "New ER Model",
"command": "erdiagram.model.newEmpty",
"title": "New empty ER Model",
"category": "bigER"
},
{
"command": "erdiagram.model.newSample",
"title": "New sample ER Model",
"category": "bigER"
}
],
Expand Down Expand Up @@ -127,7 +133,11 @@
],
"file/newFile": [
{
"command": "erdiagram.model.new",
"command": "erdiagram.model.newEmpty",
"group": "file"
},
{
"command": "erdiagram.model.newSample",
"group": "file"
}
],
Expand All @@ -153,7 +163,10 @@
"when": "erdiagram-diagram-focused"
},
{
"command": "erdiagram.model.new"
"command": "erdiagram.model.newEmpty"
},
{
"command": "erdiagram.model.newSample"
}
]
},
Expand Down Expand Up @@ -207,7 +220,7 @@
"build": "webpack --mode=development",
"build:tests": "tsc -p . --outDir dist",
"clean": "rimraf dist",
"lint": "eslint './src/**'",
"lint": "eslint \"./src/**\"",
"watch": "webpack --mode=development --watch"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { commands, Selection, window, workspace } from 'vscode';
export const command = 'erdiagram.model.new';
export const command = 'erdiagram.model.newEmpty';

export default async function newModel() {
export default async function newEmptyModel() {
const fileUri = await window.showSaveDialog({
saveLabel: 'Save as',
filters: {
Expand All @@ -13,10 +13,7 @@ export default async function newModel() {
await workspace.fs.writeFile(fileUri, writeData);
const document = await workspace.openTextDocument(fileUri);
const editor = await window.showTextDocument(fileUri);
editor.selection = new Selection(document.positionAt(10),
document.positionAt(17));
editor.selection = new Selection(document.positionAt(10), document.positionAt(16));
commands.executeCommand('erdiagram.diagram.open');
}


}
33 changes: 33 additions & 0 deletions extension/src/commands/new-sample-model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { commands, Selection, window, workspace } from 'vscode';
export const command = 'erdiagram.model.newSample';

export default async function newSampleModel() {
const fileUri = await window.showSaveDialog({
saveLabel: 'Save as',
filters: {
"ER Diagram file": ["erd"]
}
});
if (fileUri) {
const sampleModel = [
"erdiagram Model\n",
"notation=default",
"generate=off\n",
"entity A {",
" id key",
"}\n",
"entity B {",
" id key",
"}\n",
"relationship Rel {",
" A -> B",
"}"
].join("\n");
const writeData = Buffer.from(sampleModel, 'utf8');
await workspace.fs.writeFile(fileUri, writeData);
const document = await workspace.openTextDocument(fileUri);
const editor = await window.showTextDocument(fileUri);
editor.selection = new Selection(document.positionAt(10), document.positionAt(16));
commands.executeCommand('erdiagram.diagram.open');
}
}
12 changes: 8 additions & 4 deletions extension/src/erdiagram-lsp-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { LanguageClient, ServerOptions, LanguageClientOptions } from "vscode-lan
import { SprottyWebview } from "sprotty-vscode/lib/sprotty-webview";
import { SprottyDiagramIdentifier, SprottyLspWebview } from "sprotty-vscode/lib/lsp";
import { ERDiagramWebview } from './erdiagram-webview';
import newModel from './commands/new-model';
import newEmptyModel from './commands/new-empty-model';
import newSampleModel from './commands/new-sample-model';

export class ERDiagramLspVscodeExtension extends SprottyLspEditVscodeExtension {

Expand All @@ -15,9 +16,12 @@ export class ERDiagramLspVscodeExtension extends SprottyLspEditVscodeExtension {

protected registerCommands() {
super.registerCommands();
this.context.subscriptions.push(vscode.commands.registerCommand('erdiagram.model.new', (...commandArgs: any[]) => {
newModel();
}));
this.context.subscriptions.push(vscode.commands.registerCommand('erdiagram.model.newEmpty', (...commandArgs: any[]) => {
newEmptyModel();
}));
this.context.subscriptions.push(vscode.commands.registerCommand('erdiagram.model.newSample', (...commandArgs: any[]) => {
newSampleModel();
}));
}

protected getDiagramType(commandArgs: any[]): string | undefined {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* generated by Xtext 2.27.0
*/
package org.big.erd.ide;

import org.big.erd.ide.codeActions.ERDCodeActionService;
import org.big.erd.ide.hover.ERDHoverService;
import org.big.erd.ide.symbol.ErDocumentSymbolKindProvider;
import org.big.erd.ide.symbol.ErDocumentSymbolNameProvider;
import org.eclipse.xtext.ide.server.codeActions.ICodeActionService2;
import org.eclipse.xtext.ide.server.hover.HoverService;
import org.eclipse.xtext.ide.server.symbol.DocumentSymbolMapper.DocumentSymbolKindProvider;
import org.eclipse.xtext.ide.server.symbol.DocumentSymbolMapper.DocumentSymbolNameProvider;

/**
* Use this class to register ide components.
*/
public class EntityRelationshipIdeModule extends AbstractEntityRelationshipIdeModule {

public Class<? extends ICodeActionService2> bindICodeActionService2() {
return ERDCodeActionService.class;
}

public Class<? extends HoverService> bindHoverService() {
return ERDHoverService.class;
}

public Class<? extends DocumentSymbolNameProvider> bindDocumentSymbolNameProvider() {
return ErDocumentSymbolNameProvider.class;
}

public Class<? extends DocumentSymbolKindProvider> bindDocumentSymbolKindProvider() {
return ErDocumentSymbolKindProvider.class;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* generated by Xtext 2.27.0
*/
package org.big.erd.ide;

import com.google.inject.Guice;
import com.google.inject.Injector;
import org.big.erd.EntityRelationshipRuntimeModule;
import org.big.erd.EntityRelationshipStandaloneSetup;
import org.big.erd.ide.diagram.DiagramModule;
import org.eclipse.xtext.util.Modules2;

/**
* Initialization support for running Xtext languages as language servers.
*/
public class EntityRelationshipIdeSetup extends EntityRelationshipStandaloneSetup {

@Override
public Injector createInjector() {
return Guice.createInjector(
Modules2.mixin(
new EntityRelationshipRuntimeModule(),
new EntityRelationshipIdeModule(),
new DiagramModule()
));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ERDiagramGenerator implements IDiagramGenerator {
this.state = context.state
val contentHead = context.resource.contents.head
if (contentHead instanceof Model) {
LOG.info("Generating diagram for model with URI '" + context.resource.URI.lastSegment + "'")
LOG.debug("Generating diagram for model with URI '" + context.resource.URI.lastSegment + "'")
model = contentHead
toSGraph(model, context)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ class ERDiagramGenerator implements IDiagramGenerator {
}
]

LOG.info("Generated Graph: " + graph)
LOG.debug("Generated Graph: " + graph)
}

def RelationshipNode relationshipNodes(Relationship relationship, extension Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ERDiagramLayoutEngine extends ElkLayoutEngine {
override layout(SModelRoot root, Action cause) {

if (root instanceof ERModel) {
LOG.info("Applying macro layout for model with id: '" + root.id + "'")
LOG.debug("Applying macro layout for model with id: '" + root.id + "'")
val configurator = new SprottyLayoutConfigurator

configurator.configureByType('graph')
Expand Down Expand Up @@ -46,7 +46,7 @@ class ERDiagramLayoutEngine extends ElkLayoutEngine {
.setProperty(CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_SIDE)

layout(root, configurator, cause)
LOG.info("Finished computing macro layout.")
LOG.debug("Finished computing macro layout.")
}
}

Expand Down
Loading

0 comments on commit 707894a

Please sign in to comment.