Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
JBPM-6794 - Invalid content was found starting with element caused by…
Browse files Browse the repository at this point in the history
… 'documentation' ordering (#740)
  • Loading branch information
Tihomir Surdilovic committed Feb 7, 2018
1 parent 2866fde commit d78aadb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates.
*
* Licensed 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.
*/
package org.jbpm.designer.bpmn2.util;

import java.util.List;

import org.eclipse.bpmn2.Bpmn2Factory;
import org.eclipse.bpmn2.Documentation;
import org.eclipse.bpmn2.ScriptTask;
import org.eclipse.bpmn2.impl.BaseElementImpl;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class BaseElementFeaturesTest {

@Test
public void testBaseElementDocumentationFeature() {
try {
Documentation testDocumentation = Bpmn2Factory.eINSTANCE.createDocumentation();
testDocumentation.setText("test docs");

// using script task but any base element will do
ScriptTask scriptTask = Bpmn2Factory.eINSTANCE.createScriptTask();
scriptTask.getDocumentation().add(testDocumentation);

BaseElementImpl baseElement = (BaseElementImpl) scriptTask;

// for base elements the first ("0") feature should
// always be documentation
Object eGetFeatureObj = baseElement.eGet(0,
false,
true);

assertNotNull(eGetFeatureObj);
assertTrue(eGetFeatureObj instanceof List);

List<Documentation> baseElementDocs = (List<Documentation>) eGetFeatureObj;
assertEquals("test docs",
baseElementDocs.get(0).getText());
} catch (Throwable t) {
fail("Error getting base element feature: " + t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,19 @@ ORYX.Plugins.PropertyWindow = {
editorGrid = new Ext.Editor(cf);
break;

case ORYX.CONFIG.TYPE_DOCS_EXPRESSION:
var cf = new Ext.form.ConditionExpressionEditorDocumentationField({
allowBlank: pair.optional(),
dataSource: this.dataSource,
grid: this.grid,
row: index,
facade: this.facade
});

cf.on('dialogClosed', this.dialogClosed, {scope: this, row: index, col: 1, field: cf});
editorGrid = new Ext.Editor(cf);
break;

case ORYX.CONFIG.TYPE_CALLEDELEMENT:
var cf = new Ext.form.ComplexCalledElementField({
allowBlank: pair.optional(),
Expand Down Expand Up @@ -5507,6 +5520,7 @@ Ext.form.ConditionExpressionEditorField = Ext.extend(Ext.form.TriggerField, {
doLineWrapping: true,
doMatchBrackets: true,
editorTitle: ORYX.I18N.ConditionExpressionEditorField.simpleTitle,
isForDocumentation: false,

onTriggerClick: function () {
if (this.disabled) {
Expand Down Expand Up @@ -5566,11 +5580,13 @@ Ext.form.ConditionExpressionEditorField = Ext.extend(Ext.form.TriggerField, {

var isJavaCondition = false;

Ext.each(this.dataSource.data.items, function (item) {
if (item.data.gridProperties.propId == "oryx-conditionexpressionlanguage" && item.data['value'] == "java") {
isJavaCondition = true;
}
});
if(!this.isForDocumentation) {
Ext.each(this.dataSource.data.items, function (item) {
if (item.data.gridProperties.propId == "oryx-conditionexpressionlanguage" && item.data['value'] == "java") {
isJavaCondition = true;
}
});
}

var input = this;
var isSimpleEditor = true;
Expand Down Expand Up @@ -6289,6 +6305,16 @@ Ext.form.ConditionExpressionEditorTextField = Ext.extend(Ext.form.ConditionExpre
doLineWrapping: false,
doMatchBrackets: false,
editorTitle: ORYX.I18N.PropertyWindow.text,
isForDocumentation: false
});

Ext.form.ConditionExpressionEditorDocumentationField = Ext.extend(Ext.form.ConditionExpressionEditorField, {
typemode: "text",
showLineNumbers: false,
doLineWrapping: false,
doMatchBrackets: false,
editorTitle: ORYX.I18N.PropertyWindow.text,
isForDocumentation: true
});

Ext.form.ComplexRuleflowGroupElementField = Ext.extend(Ext.form.TriggerField, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ ORYX.CONFIG.TYPE_ENCODED_TEXT = "encodedtext";
ORYX.CONFIG.TYPE_VARDEF = "vardef";
ORYX.CONFIG.TYPE_EXPRESSION = "expression";
ORYX.CONFIG.TYPE_TEXT_EXPRESSION = "textexpression";
ORYX.CONFIG.TYPE_DOCS_EXPRESSION = "docsexpression";
ORYX.CONFIG.TYPE_ACTION = "action";
ORYX.CONFIG.TYPE_GLOBAL = "global";
ORYX.CONFIG.TYPE_IMPORT = "import";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
{
"id":"documentation",
"type":"TextExpression",
"type":"DocsExpression",
"title":"Documentation",
"value":"",
"description":"This attribute is used to annotate the BPMN element, such as descriptions and other documentation.",
Expand Down Expand Up @@ -79,7 +79,7 @@
"properties": [
{
"id":"documentation",
"type":"TextExpression",
"type":"DocsExpression",
"title":"Documentation",
"value":"",
"description":"This attribute is used to annotate the BPMN element, such as descriptions and other documentation.",
Expand Down Expand Up @@ -2359,7 +2359,7 @@
},
{
"id":"documentation",
"type":"TextExpression",
"type":"DocsExpression",
"title":"Documentation",
"value":"",
"description":"This attribute is used to annotate the BPMN element, such as descriptions and other documentation.",
Expand Down Expand Up @@ -3622,7 +3622,7 @@
$bclose$,
$bopen$
"id":"documentation",
"type":"TextExpression",
"type":"DocsExpression",
"title":"Documentation",
"value":"$workitemDefs.(k).documentation$",
"description":"This attribute is used to annotate the BPMN element, such as descriptions and other documentation.",
Expand Down

0 comments on commit d78aadb

Please sign in to comment.