Skip to content

Commit

Permalink
Merge pull request #36 from fantonangeli/sync-main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira committed Aug 27, 2024
2 parents 536e5f6 + 35458de commit 1b3ab5c
Show file tree
Hide file tree
Showing 477 changed files with 14,504 additions and 3,591 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ The Apache KIE Tools project contains several applications. To develop each one

1. After you've successfully built the project following the instructions above, open the `packages/kie-editors-dev-vscode-extension` folder on VS Code. Use a new VS Code window so that the `packages/kie-editors-dev-vscode-extension` folder shows up as root in the VS Code explorer.
2. From there, you can Run the extension or the end-to-end tests by using the `Debug` menu/section. You can also use the respective shortcuts (F5 to start debugging, for instance).
3. **NOTE:** To run the VS Code extension in development mode, you need `webpack` and `webpack-cli` to be globally installed on NPM. Normally you can do that with `npm install -g webpack@^5.88.2 webpack-cli@^4.10.0`, but `sudo` may be required depending on your installation.
3. **NOTE:** To run the VS Code extension in development mode, you need `webpack` and `webpack-cli` to be globally installed on NPM. Normally you can do that with `npm install -g webpack@^5.92.1 webpack-cli@^4.10.0`, but `sudo` may be required depending on your installation.
4. **Remember!** If you make changes to any package other than `packages/kie-editors-dev-vscode-extension`, you have to manually rebuild them before relaunching the extension on VS Code.

#### VS Code Extension (Serverless Workflow Editor)
Expand Down
2 changes: 1 addition & 1 deletion examples/base64png-editor-chrome-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"copy-webpack-plugin": "^11.0.0",
"rimraf": "^3.0.2",
"typescript": "^5.5.3",
"webpack": "^5.88.2",
"webpack": "^5.92.1",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/base64png-editor-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@vscode/vsce": "^2.22.0",
"rimraf": "^3.0.2",
"typescript": "^5.5.3",
"webpack": "^5.88.2",
"webpack": "^5.92.1",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0"
Expand Down
75 changes: 75 additions & 0 deletions examples/dmn-editor-standalone-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## DMN Editor Standalone Examples

A series of examples on how to use the DMN Editor Standalone in different applications.

### Examples

- [State Control]("src/stateControl/index.ts"): Shows how to leverage the Editor API to undo/redo changes to a decision, get its contents and download an SVG of the diagram.
- [Read Only]("src/readOnly/index.ts"): Loads the editor in "Read Only" mode, where a decision can be displayed and navigated but not changed.
- [With Included Models]("src/withIncludedModels/index.ts"): Displays how Decisions can be imported into other Decisions as "Included Models", using the `resources` parameter from the DMN Editor.

### Build

To build the examples, execute one of the following commands on the root folder of the project:

```shell script
KIE_TOOLS_BUILD__buildExamples=true pnpm -F @kie-tools-examples/dmn-editor-standalone-examples... build:dev
KIE_TOOLS_BUILD__buildExamples=true pnpm -F @kie-tools-examples/dmn-editor-standalone-examples... build:prod
```

### Run

To start the examples application, execute the following command on the root folder of the project:

```shell script
pnpm -F @kie-tools-examples/dmn-editor-standalone-examples start
```

Open http://localhost:9102 to see the list of files bundled by webpack, then choose an example:

- State Control: http://localhost:9102/state_control.html
- Read Only: http://localhost:9102/read_only.html
- With Included Models: http://localhost:9102/with_included_models.html

---

Apache KIE (incubating) is an effort undergoing incubation at The Apache Software
Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is
required of all newly accepted projects until a further review indicates that
the infrastructure, communications, and decision making process have stabilized
in a manner consistent with other successful ASF projects. While incubation
status is not necessarily a reflection of the completeness or stability of the
code, it does indicate that the project has yet to be fully endorsed by the ASF.

Some of the incubating project’s releases may not be fully compliant with ASF
policy. For example, releases may have incomplete or un-reviewed licensing
conditions. What follows is a list of known issues the project is currently
aware of (note that this list, by definition, is likely to be incomplete):

- Hibernate, an LGPL project, is being used. Hibernate is in the process of
relicensing to ASL v2
- Some files, particularly test files, and those not supporting comments, may
be missing the ASF Licensing Header

If you are planning to incorporate this work into your product/project, please
be aware that you will need to conduct a thorough licensing review to determine
the overall implications of including this work. For the current status of this
project through the Apache Incubator visit:
https://incubator.apache.org/projects/kie.html
31 changes: 31 additions & 0 deletions examples/dmn-editor-standalone-examples/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");

module.exports = composeEnv([require("@kie-tools/root-env/env")], {
vars: varsWithName({}),
get env() {
return {
dmnEditorStandaloneExamples: {
port: 9102,
},
};
},
});
45 changes: 45 additions & 0 deletions examples/dmn-editor-standalone-examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"private": true,
"name": "@kie-tools-examples/dmn-editor-standalone-examples",
"version": "0.0.0",
"description": "",
"license": "Apache-2.0",
"homepage": "https://github.com/apache/incubator-kie-tools",
"repository": {
"type": "git",
"url": "https://github.com/apache/incubator-kie-tools.git"
},
"bugs": {
"url": "https://github.com/apache/incubator-kie-tools/issues"
},
"scripts": {
"build:dev": "rimraf dist && webpack --env dev",
"build:prod": "rimraf dist && webpack --env prod",
"start": "webpack serve --host 0.0.0.0 --env dev"
},
"dependencies": {
"@kie-tools/dmn-editor-standalone": "workspace:*"
},
"devDependencies": {
"@kie-tools-core/webpack-base": "workspace:*",
"@kie-tools/root-env": "workspace:*",
"@kie-tools/tsconfig": "workspace:*",
"copy-webpack-plugin": "^11.0.0",
"html-webpack-plugin": "^5.3.2",
"process": "^0.11.10",
"raw-loader": "^4.0.2",
"rimraf": "^3.0.2",
"typescript": "^5.5.3",
"webpack": "^5.92.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0"
},
"kieTools": {
"requiredPreinstalledCliCommands": [
"java",
"mvn"
]
}
}
32 changes: 32 additions & 0 deletions examples/dmn-editor-standalone-examples/src/fileLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { DmnEditorStandaloneApi } from "@kie-tools/dmn-editor-standalone/dist";

export function loadFile(fileName: string) {
return fetch(`/static/models/${fileName}`).then((value) => value.text());
}

export function initFileLoader(files: Array<string>, editor: DmnEditorStandaloneApi) {
files.map((fileName) => {
document.getElementById(fileName)?.addEventListener("click", () => {
loadFile(fileName).then((fileContent) => editor.setContent(fileName, fileContent));
});
});
}
45 changes: 45 additions & 0 deletions examples/dmn-editor-standalone-examples/src/readOnly/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!-- This file is used for test purposes only -->

<!doctype html>
<html lang="en">
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#dmn-editor-container {
height: calc(100vh - 6px);
}
</style>

<title></title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
<div id="dmn-editor-container" />
</body>
</html>
43 changes: 43 additions & 0 deletions examples/dmn-editor-standalone-examples/src/readOnly/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as DmnEditor from "@kie-tools/dmn-editor-standalone/dist";
import { loadFile } from "../fileLoader";

document.addEventListener("DOMContentLoaded", function () {
loadEditor();
});

function loadEditor() {
// Loads the DMN Editor in the `<div id="dmn-editor-container" />` element.
// Initializes with an existing file called `loan-pre-qualification.dmn` on the root of the
// workspace.
// The `loadFile` function loads the file from the /static/models directory and returns
// a Promise that resolves into a string.
// The `readOnly` flag changes the editor, locking all changes to the model, making it
// useful for displaying diagrams without editing the Decision.
const editor = DmnEditor.open({
container: document.getElementById("dmn-editor-container")!,
initialFileNormalizedPosixPathRelativeToTheWorkspaceRoot: "loan-pre-qualification.dmn",
initialContent: loadFile("loan-pre-qualification.dmn"),
readOnly: true,
});

console.log({ editor });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!-- This file is used for test purposes only -->

<!doctype html>
<html lang="en">
<head>
<style>
* {
margin: 0;
}

#dmn-editor-container {
height: calc(100vh - 36px);
}

.toolbar {
height: 30px;
display: flex;
font-size: 16px;
border-bottom: 1px solid #d2d2d2;
box-sizing: border-box;
align-items: center;
}

.toolbar button {
font-size: 16px;
}

.toolbar .toolbar-items {
flex: 1 1;
}

.toolbar .load-files {
text-align: right;
}

.hidden {
display: none;
}
</style>

<title></title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
<div class="toolbar">
<div class="toolbar-items actions">
<button id="undo">Undo</button>
<button id="redo">Redo</button>
<button id="download">Download</button>
<button id="downloadSvg">Download SVG</button>
<span id="unsavedChanges" class="hidden">File contains unsaved changes.</span>
</div>
<br />
<div class="toolbar-items load-files">
Load DMN:
<button id="empty.dmn">Empty</button>
<button id="empty-drd.dmn">Empty DRD</button>
<button id="find-employees.dmn">Find Employees</button>
<button id="loan-pre-qualification.dmn">Loan Pre Qualification</button>
</div>
</div>
<div id="dmn-editor-container" />
</body>
</html>
Loading

0 comments on commit 1b3ab5c

Please sign in to comment.