Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
Issue imixs#246
  • Loading branch information
rsoika committed May 14, 2023
1 parent e9de24a commit a3525e9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@
flex-direction: row;
justify-content: space-between;
}
.bpmn-properties-body .control.text-file-editor>label .file-selector {
font-weight: bold;
color: var(--theia-focusBorder);
}
.bpmn-properties-body .control.text-file-editor>textarea {
min-height: 12em;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import merge from 'lodash/merge';
import React, { useState } from 'react';

/***********************
* This is a custom renderer for text which can be optional linked to a file.
* The optional file path can be provided in the option 'filePath'.
* This is a custom renderer for textare which can be optional linked to a file.
* The optional file path is identified if the content starts with 'file://'
* <p>
* This allows to edit the text content in a separate file within the same IDE.
* <p>
*/

/**
* A Custom Textarea linking ot a file
* A Custom Textarea linking to a file
* @param props
* @returns
*/
Expand All @@ -56,7 +56,6 @@ export const TextFileEditor = ({
handleChange
}: ControlProps & VanillaRendererProps & OwnPropsOfEnum) => {
const [isFocused, setFocus] = useState(false);
// const isValid = errors.length === 0;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
const showDescription = !isDescriptionHidden(
visible,
Expand All @@ -80,22 +79,7 @@ export const TextFileEditor = ({
)}
</span>
<span className={'file-selector'}>
<input type="checkbox" id="file-selector" name="file-selector" checked={data.startsWith('file://')}
value="file" onChange={ev => {
const a='file://';
const fTextarea = document.getElementById(id);
if (fTextarea) {
if (ev.target.checked) {
fTextarea.classList.add('fileInputMode');
} else {
fTextarea.classList.remove('fileInputMode');
}
} else {
// not found textarea!
}
handleChange(path, a);
}} />
<label> File Link</label>
<label>File Link: {(data.startsWith('file://'))?'ACTIVE':'NONE'}</label>
</span>
</label>

Expand All @@ -104,7 +88,24 @@ export const TextFileEditor = ({
disabled={!enabled}
autoFocus={uischema.options && uischema.options.focus}
value={data}
onChange={ev => handleChange(path, ev.target.value)}
className={(data.startsWith('file://'))?'fileInputMode':''}
onChange={ev => {
// change layout depending on input mode
const fileSelector = ev.target.closest('div')?.querySelector('span.file-selector');
if (ev.target.value.startsWith('file://')) {
ev.target.classList.add('fileInputMode');
if (fileSelector) {
fileSelector.textContent='File Link: ACTIVE';
}
} else {
ev.target.classList.remove('fileInputMode');
if (fileSelector) {
fileSelector.textContent='File Link: NONE';
}
}
handleChange(path, ev.target.value);
}
}
>{data}</textarea>
<div className={'input-description'}>
{showDescription ? description : undefined}
Expand Down
66 changes: 41 additions & 25 deletions open-bpmn.glsp-client/workspace/imixs-test.bpmn
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:BPMN2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn">
<bpmn2:process id="process_1" name="Default Process" processType="Public">
<bpmn2:documentation id="documentation_ZxNkOA"/>
<bpmn2:task id="task_CQoJ1A" imixs:processid="100" name="Task-1">
<bpmn2:documentation id="documentation_rYdYEw"/>
<bpmn2:outgoing>SequenceFlow_W02XQA</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:intermediateCatchEvent id="event_lzucQQ" name="Event-1">
<bpmn2:documentation id="documentation_JMyUqQ"/>
<bpmn2:incoming>SequenceFlow_W02XQA</bpmn2:incoming>
<bpmn2:signalEventDefinition id="signalEventDefinition_7FMuBw" signalRef="signal_1"/>
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="SequenceFlow_W02XQA" sourceRef="task_CQoJ1A" targetRef="event_lzucQQ">
<bpmn2:documentation id="documentation_29LNww"/>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn">
<bpmn2:collaboration id="collaboration_1" name="Default Collaboration">
<bpmn2:participant id="participant_dLmTNA" name="Default Process" processRef="process_1"/>
<bpmn2:participant id="participant_0laEIA" name="Pool-1" processRef="process_IP5ckA">
<bpmn2:documentation id="documentation_wo1IZw"/>
</bpmn2:participant>
</bpmn2:collaboration>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_1" name="Default Process" processType="Public">
<bpmn2:documentation id="documentation_20DpMw"/>
</bpmn2:process>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_IP5ckA" name="Pool-1" processType="Private">
<bpmn2:startEvent id="event_ZXMs0A" name="Event-1">
<bpmn2:documentation id="documentation_F7CNCw"/>
<bpmn2:outgoing>sequenceFlow_uKg7KA</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:scriptTask id="task_CYqqqA" name="Task-1" scriptFormat="">
<bpmn2:documentation id="documentation_KcpMQg"><![CDATA[abcccc]]></bpmn2:documentation>
<bpmn2:script id="script_VQHFSw" open-bpmn:file-link="file://imixs.script.js"><![CDATA[file://imixs.script.js]]></bpmn2:script>
<bpmn2:incoming>sequenceFlow_uKg7KA</bpmn2:incoming>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="sequenceFlow_uKg7KA" sourceRef="event_ZXMs0A" targetRef="task_CYqqqA">
<bpmn2:documentation id="documentation_mdTTiQ"/>
</bpmn2:sequenceFlow>
<bpmn2:task id="task_FqIHHg" name="Task-2">
<bpmn2:documentation id="documentation_sC05RQ"><![CDATA[HAAAAAAAAAAAAAAAAAALO]]></bpmn2:documentation>
</bpmn2:task>
</bpmn2:process>
<bpmn2:signal id="signal_1" name="Signal 1"/>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="process_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="task_CQoJ1A" id="BPMNShape_Sb48dQ">
<dc:Bounds height="50.0" width="110.0" x="49.0" y="49.0"/>
<bpmndi:BPMNPlane bpmnElement="collaboration_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="participant_0laEIA" id="BPMNShape_fOYZyg">
<dc:Bounds height="200.0" width="800.0" x="84.0" y="70.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_lzucQQ" id="BPMNShape_RkDKAQ">
<dc:Bounds height="36.0" width="36.0" x="216.0" y="56.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_HJLRuw">
<dc:Bounds height="16.0" width="100.0" x="184.0" y="95.0"/>
<bpmndi:BPMNShape bpmnElement="event_ZXMs0A" id="BPMNShape_ZFae2w">
<dc:Bounds height="36.0" width="36.0" x="176.0" y="135.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_CcGR9w">
<dc:Bounds height="16.0" width="100.0" x="144.0" y="174.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="SequenceFlow_W02XQA" id="BPMNEdge_aWWiLQ" sourceElement="BPMNShape_Sb48dQ" targetElement="BPMNShape_RkDKAQ">
<di:waypoint x="159.0" y="74.0"/>
<di:waypoint x="216.0" y="74.0"/>
<bpmndi:BPMNShape bpmnElement="task_CYqqqA" id="BPMNShape_5hn3Eg">
<dc:Bounds height="50.0" width="110.0" x="290.0" y="128.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_uKg7KA" id="BPMNEdge_Ox20pA" sourceElement="BPMNShape_ZFae2w" targetElement="BPMNShape_5hn3Eg">
<di:waypoint x="212.0" y="153.0"/>
<di:waypoint x="290.0" y="153.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="task_FqIHHg" id="BPMNShape_04O0sw">
<dc:Bounds height="50.0" width="110.0" x="445.0" y="128.0"/>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
2 changes: 2 additions & 0 deletions open-bpmn.glsp-client/workspace/imixs.script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var b=1;
var c=3;
4 changes: 4 additions & 0 deletions open-bpmn.glsp-client/workspace/imixs.script.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<input-section>

<data>Hello World</data>
</input-section>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openbpmn.glsp.jsonforms.SchemaBuilder;
import org.openbpmn.glsp.jsonforms.UISchemaBuilder;
import org.openbpmn.glsp.jsonforms.UISchemaBuilder.Layout;
import org.w3c.dom.Element;

/**
* This is the Default BPMNEvent extension providing the JSONForms schemata.
Expand Down Expand Up @@ -131,8 +132,16 @@ public void updatePropertiesData(final JsonObject json, final String category, f
if ("Script".equals(category)) {
Activity taskElement = (Activity) bpmnElement;
if (BPMNTypes.SCRIPT_TASK.equals(taskElement.getType())) {
String dataValue = json.getString("script", "");
bpmnElement.setAttribute("scriptFormat", json.getString("scriptformat", ""));
bpmnElement.setChildNodeContent(BPMNNS.BPMN2, "script", json.getString("script", ""), true);
Element childElement = bpmnElement.setChildNodeContent(BPMNNS.BPMN2, "script", dataValue, true);
// if we have a file:// link than we create an open-bpmn attribute
if (dataValue.startsWith("file://")) {
childElement.setAttribute("open-bpmn:file-link", dataValue);
} else {
childElement.removeAttribute("open-bpmn:file-link");
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion open-bpmn.metamodel/src/test/resources/out_blank.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL">
<bpmn2:definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://open-bpmn.org" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL">
<bpmn2:process id="process_1" name="Default Process" processType="Public"/>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="process_1" id="BPMNPlane_1"/>
Expand Down
2 changes: 1 addition & 1 deletion open-bpmn.metamodel/src/test/resources/prettify_test1.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn">
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://org.openbpmn">
<bpmn2:process id="process_1" processType="Public">
<bpmn2:manualTask id="task-dA-E3AaGA0Uoh7sc" name="Task-0"/>
</bpmn2:process>
Expand Down

0 comments on commit a3525e9

Please sign in to comment.