Merge branch 'develop' into helios
diff --git a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
index b548ee0..b806096 100644
--- a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
+++ b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIImport.java
@@ -130,6 +130,9 @@
d.setPlane(plane);
modelHandler.getDefinitions().getDiagrams().add(d);
+
+ // don't forget to add the new Diagram to our list for processing
+ bpmnDiagrams.add(d);
}
featureProvider.link(diagram, bpmnDiagrams.get(0));
diff --git a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/DefaultDetailComposite.java b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/DefaultDetailComposite.java
index 15f60b3..d7a4d95 100644
--- a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/DefaultDetailComposite.java
+++ b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/DefaultDetailComposite.java
@@ -228,7 +228,7 @@
String displayName = ModelUtil.getLabel(object, reference);
- if (reference.getEType() == PACKAGE.getExpression()) {
+ if (reference.getEType() == PACKAGE.getExpression() || reference.getEType() == PACKAGE.getFormalExpression()) {
FormalExpression expression = (FormalExpression)object.eGet(reference);
if (expression==null) {
expression = FACTORY.createFormalExpression();
diff --git a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
index ae86d2e..b16a67e 100644
--- a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
+++ b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
@@ -60,10 +60,12 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -165,6 +167,11 @@
.node(PROJECT_PREFERENCES_ID);
if (projectPreferences instanceof ProjectPreferences)
((ProjectPreferences)projectPreferences).addPreferenceChangeListener(this);
+ try {
+ projectPreferences.sync();
+ }
+ catch (Exception e) {
+ }
}
globalPreferences = Activator.getDefault().getPreferenceStore();
globalPreferences.addPropertyChangeListener(this);
@@ -250,6 +257,7 @@
String rid = TargetRuntime.getFirstNonDefaultId();
globalPreferences.setDefault(PREF_TARGET_RUNTIME, rid);
globalPreferences.setDefault(PREF_SHOW_ADVANCED_PROPERTIES, false);
+ globalPreferences.setDefault(PREF_CHECK_PROJECT_NATURE, true);
globalPreferences.setDefault(PREF_SHOW_DESCRIPTIONS, true);
globalPreferences.setDefault(PREF_IS_HORIZONTAL, BPMNDIAttributeDefault.DEFAULT_TRUE.name());
globalPreferences.setDefault(PREF_IS_EXPANDED, BPMNDIAttributeDefault.ALWAYS_TRUE.name());
@@ -380,7 +388,7 @@
showAdvancedPropertiesTab = getBoolean(PREF_SHOW_ADVANCED_PROPERTIES, false);
showDescriptions = getBoolean(PREF_SHOW_DESCRIPTIONS, false);
showIdAttribute = getBoolean(PREF_SHOW_ID_ATTRIBUTE, false);
- checkProjectNature = getBoolean(PREF_CHECK_PROJECT_NATURE, true);
+ checkProjectNature = getBoolean(PREF_CHECK_PROJECT_NATURE, false);
isHorizontal = getBPMNDIAttributeDefault(PREF_IS_HORIZONTAL, BPMNDIAttributeDefault.USE_DI_VALUE);
isExpanded = getBPMNDIAttributeDefault(PREF_IS_EXPANDED, BPMNDIAttributeDefault.USE_DI_VALUE);
isMessageVisible = getBPMNDIAttributeDefault(PREF_IS_MESSAGE_VISIBLE, BPMNDIAttributeDefault.USE_DI_VALUE);
@@ -407,7 +415,7 @@
if (projectPreferences!=null)
projectPreferences.putBoolean(PREF_OVERRIDE_MODEL_ENABLEMENTS, overrideModelEnablements);
- setString(PREF_TARGET_RUNTIME,targetRuntime.getId());
+ setString(PREF_TARGET_RUNTIME,getRuntime().getId());
setBoolean(PREF_SHOW_ADVANCED_PROPERTIES, showAdvancedPropertiesTab);
setBoolean(PREF_SHOW_DESCRIPTIONS, showDescriptions);
setBoolean(PREF_SHOW_ID_ATTRIBUTE, showIdAttribute);
@@ -435,6 +443,7 @@
if (projectPreferences!=null)
projectPreferences.flush();
+
dirty = false;
}
@@ -510,6 +519,27 @@
public TargetRuntime getRuntime() {
load();
+ if (targetRuntime==null) {
+ targetRuntime = TargetRuntime.getDefaultRuntime();
+ Display.getDefault().asyncExec( new Runnable() {
+ @Override
+ public void run() {
+ String id = getString(PREF_TARGET_RUNTIME,TargetRuntime.getFirstNonDefaultId());
+ if (id==null || id.isEmpty())
+ id = TargetRuntime.getFirstNonDefaultId();
+
+ targetRuntime = TargetRuntime.getDefaultRuntime();
+ MessageDialog.openError(
+ Display.getDefault().getActiveShell(),
+ "Unsupported Target Runtime",
+ "The Target Runtime plugin for id '"+id+"'"+
+ "\ncould not be loaded, using "+targetRuntime.getDescription()+" instead."
+ );
+ }
+
+ });
+
+ }
return targetRuntime;
}
@@ -724,10 +754,9 @@
}
private void overrideGlobalBoolean(String key, boolean value) {
- if (value!=globalPreferences.getBoolean(key)) {
- projectPreferences.putBoolean(key, value);
- dirty = true;
- }
+ projectPreferences.putBoolean(key, value);
+ saveProjectPreferences();
+ dirty = true;
}
public int getInt(String key, int defaultValue) {
@@ -746,10 +775,9 @@
}
private void overrideGlobalInt(String key, int value) {
- if (value!=globalPreferences.getInt(key)) {
- projectPreferences.putInt(key, value);
- dirty = true;
- }
+ projectPreferences.putInt(key, value);
+ saveProjectPreferences();
+ dirty = true;
}
public String getString(String key, String defaultValue) {
@@ -768,10 +796,9 @@
}
private void overrideGlobalString(String key, String value) {
- if (value!=globalPreferences.getString(key)) {
- projectPreferences.put(key, value);
- dirty = true;
- }
+ projectPreferences.put(key, value);
+ saveProjectPreferences();
+ dirty = true;
}
public BPMNDIAttributeDefault getBPMNDIAttributeDefault(String key, BPMNDIAttributeDefault defaultValue) {
@@ -793,10 +820,9 @@
}
private void overrideGlobalBPMNDIAttributeDefault(String key, BPMNDIAttributeDefault value) {
- if (value!=BPMNDIAttributeDefault.valueOf(globalPreferences.getString(key))) {
- projectPreferences.put(key, value.name());
- dirty = true;
- }
+ projectPreferences.put(key, value.name());
+ saveProjectPreferences();
+ dirty = true;
}
public static String[] getBPMNDIAttributeDefaultChoices() {
@@ -1051,4 +1077,13 @@
if (type==IResourceChangeEvent.PRE_DELETE)
dispose();
}
+
+ private void saveProjectPreferences() {
+ try {
+ projectPreferences.flush();
+ } catch (BackingStoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
diff --git a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
index 6a62568..c1c5a6a 100644
--- a/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
+++ b/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
@@ -63,7 +63,7 @@
if (font==null || font.isEmpty())
font = DEFAULT_FONT_STRING;
textFont = stringToFont(font);
- defaultSize = true;
+ defaultSize = false;
}
protected ShapeStyle(String s) {
@@ -83,7 +83,7 @@
if (a.length>6)
defaultSize = stringToBoolean(a[6]);
else
- defaultSize = true;
+ defaultSize = false;
}
public void setDefaultColors(IColorConstant defaultColor) {
diff --git a/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java b/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java
index 1a65f10..9976b5d 100644
--- a/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java
+++ b/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java
@@ -41,6 +41,7 @@
import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WIDException;
import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WIDHandler;
import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WorkItemDefinition;
+import org.eclipse.bpmn2.modeler.ui.DefaultBpmn2RuntimeExtension.RootElementParser;
import org.eclipse.bpmn2.modeler.ui.wizards.FileService;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -65,11 +66,8 @@
@SuppressWarnings("restriction")
public class JBPM5RuntimeExtension implements IBpmn2RuntimeExtension {
- private static final String BPMN2_NAMESPACE = "http://www.omg.org/spec/BPMN/20100524/MODEL"; //$NON-NLS-1$
private static final String DROOLS_NAMESPACE = "http://www.jboss.org/drools";
- private static final String ROOT_ELEMENT = "definitions"; //$NON-NLS-1$
- private RootElementParser parser;
private List<WorkItemDefinition> workItemDefinitions;
/* (non-Javadoc)
@@ -79,18 +77,10 @@
*/
@Override
public boolean isContentForRuntime(IEditorInput input) {
- try {
- InputSource source = new InputSource( FileService.getInputContents(input) );
- parser = new RootElementParser();
- parser.parse(source);
- } catch (AcceptedException e) {
- return true;
- } catch (Exception e) {
- } finally {
- parser = null;
- }
-
- return false;
+ InputSource source = new InputSource( FileService.getInputContents(input) );
+ RootElementParser parser = new RootElementParser(DROOLS_NAMESPACE);
+ parser.parse(source);
+ return parser.getResult();
}
public String getTargetNamespace(Bpmn2DiagramType diagramType){
@@ -452,43 +442,6 @@
}
}
- private class RootElementParser extends SAXParser {
- @Override
- public void startElement(QName qName, XMLAttributes attributes, Augmentations augmentations)
- throws XNIException {
-
- super.startElement(qName, attributes, augmentations);
-
- // search the "definitions" for a drools namespace
- if (ROOT_ELEMENT.equals(qName.localpart)) {
- Enumeration<?> e = fNamespaceContext.getAllPrefixes();
- while (e.hasMoreElements()) {
- String prefix = (String)e.nextElement();
- String namespace = fNamespaceContext.getURI(prefix);
- if (DROOLS_NAMESPACE.equals(namespace))
- throw new AcceptedException(qName.localpart);
- }
- throw new RejectedException();
- } else {
- throw new RejectedException();
- }
- }
- }
-
- private class AcceptedException extends RuntimeException {
- public String acceptedRootElement;
-
- public AcceptedException(String acceptedRootElement) {
- this.acceptedRootElement = acceptedRootElement;
- }
-
- private static final long serialVersionUID = 1L;
- }
-
- private class RejectedException extends RuntimeException {
- private static final long serialVersionUID = 1L;
- }
-
@Override
public Composite getPreferencesComposite(Composite parent, Bpmn2Preferences preferences) {
return null;
diff --git a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/DefaultBpmn2RuntimeExtension.java b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/DefaultBpmn2RuntimeExtension.java
index b3d74ea..7de1b14 100644
--- a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/DefaultBpmn2RuntimeExtension.java
+++ b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/DefaultBpmn2RuntimeExtension.java
@@ -11,24 +11,29 @@
* @author Bob Brodt
******************************************************************************/
package org.eclipse.bpmn2.modeler.ui;
+import java.util.Enumeration;
+
+import org.apache.xerces.parsers.SAXParser;
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.XNIException;
import org.eclipse.bpmn2.modeler.core.IBpmn2RuntimeExtension;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil.Bpmn2DiagramType;
import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
+import org.xml.sax.InputSource;
public class DefaultBpmn2RuntimeExtension implements IBpmn2RuntimeExtension {
public DefaultBpmn2RuntimeExtension() {
- // TODO Auto-generated constructor stub
}
@Override
public boolean isContentForRuntime(IEditorInput input) {
- // TODO Auto-generated method stub
return false;
}
@@ -51,11 +56,83 @@
@Override
public void initialize(DiagramEditor editor) {
- // TODO Auto-generated method stub
}
@Override
public Composite getPreferencesComposite(Composite parent, Bpmn2Preferences preferences) {
return null;
}
+
+
+ /**
+ * A simple XML parser that checks if the root element of an xml document contains any
+ * namespace definitions matching the given namespace URI.
+ *
+ * @author bbrodt
+ */
+ public static class RootElementParser extends SAXParser {
+ private String namespace;
+ private boolean result = false;
+
+ /**
+ * @param namespace - the namespace URI to scan for.
+ */
+ public RootElementParser(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public boolean getResult() {
+ return result;
+ }
+
+ public void parse(InputSource source) {
+ result = false;
+ try {
+ super.parse(source);
+ } catch (AcceptedException e) {
+ result = true;
+ } catch (Exception e) {
+ }
+ }
+
+ @Override
+ public void startElement(QName qName, XMLAttributes attributes, Augmentations augmentations)
+ throws XNIException {
+
+ super.startElement(qName, attributes, augmentations);
+
+ try {
+ // search the "definitions" for a namespace that matches the required namespace
+ if ("definitions".equals(qName.localpart)) {
+ Enumeration<?> e = fNamespaceContext.getAllPrefixes();
+ while (e.hasMoreElements()) {
+ String prefix = (String)e.nextElement();
+ String namespace = fNamespaceContext.getURI(prefix);
+ if (this.namespace.equals(namespace))
+ throw new AcceptedException(qName.localpart);
+ }
+ throw new RejectedException();
+ } else {
+ throw new RejectedException();
+ }
+ }
+ catch (Exception e) {
+ throw new RejectedException();
+ }
+ }
+ }
+
+ public static class AcceptedException extends RuntimeException {
+ public String acceptedRootElement;
+
+ public AcceptedException(String acceptedRootElement) {
+ this.acceptedRootElement = acceptedRootElement;
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+
+ public static class RejectedException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+ }
}
diff --git a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
index b9e1323..f204ef8 100644
--- a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
+++ b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
@@ -456,6 +456,8 @@
}
}
}
+ if (targetRuntime==null)
+ targetRuntime = TargetRuntime.getDefaultRuntime();
}
return targetRuntime;
}
diff --git a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2HomePreferencePage.java b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2HomePreferencePage.java
index e249c52..98c3a9d 100644
--- a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2HomePreferencePage.java
+++ b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2HomePreferencePage.java
@@ -90,6 +90,12 @@
getFieldEditorParent());
addField(showIds);
+ BooleanFieldEditor checkProjectNature = new BooleanFieldEditor(
+ Bpmn2Preferences.PREF_CHECK_PROJECT_NATURE,
+ Bpmn2Preferences.PREF_CHECK_PROJECT_NATURE_LABEL,
+ getFieldEditorParent());
+ addField(checkProjectNature);
+
Group group = new Group(getFieldEditorParent(), SWT.BORDER);
group.setLayout(new GridLayout(3,false));
group.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
diff --git a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2PropertyPage.java b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2PropertyPage.java
index b0eaabb..31967b4 100644
--- a/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2PropertyPage.java
+++ b/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/Bpmn2PropertyPage.java
@@ -36,6 +36,7 @@
private Combo cboRuntimes;
private Button btnShowAdvancedProperties;
private Button btnShowDescriptions;
+ private Button btnShowIds;
private Button btnCheckProjectNature;
private BPMNDIAttributeDefaultCombo cboIsHorizontal;
private BPMNDIAttributeDefaultCombo cboIsExpanded;
@@ -70,6 +71,10 @@
btnShowDescriptions = new Button(container, SWT.CHECK);
btnShowDescriptions.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
btnShowDescriptions.setText(Bpmn2Preferences.PREF_SHOW_DESCRIPTIONS_LABEL);
+
+ btnShowIds = new Button(container, SWT.CHECK);
+ btnShowIds.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
+ btnShowIds.setText(Bpmn2Preferences.PREF_SHOW_ID_ATTRIBUTE_LABEL);
btnCheckProjectNature = new Button(container, SWT.CHECK);
btnCheckProjectNature.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
@@ -121,6 +126,7 @@
private void initData() {
btnShowAdvancedProperties.setSelection( prefs.getShowAdvancedPropertiesTab() );
btnShowDescriptions.setSelection( prefs.getShowDescriptions() );
+ btnShowIds.setSelection( prefs.getShowIdAttribute() );
btnCheckProjectNature.setSelection( prefs.getCheckProjectNature() );
cboIsHorizontal.setValue(prefs.getIsHorizontal());
cboIsExpanded.setValue( prefs.getIsExpanded() );
@@ -161,6 +167,7 @@
prefs.setShowAdvancedPropertiesTab(btnShowAdvancedProperties.getSelection());
prefs.setShowDescriptions(btnShowDescriptions.getSelection());
+ prefs.setShowIdAttribute(btnShowIds.getSelection());
prefs.setCheckProjectNature(btnCheckProjectNature.getSelection());
prefs.setIsHorizontal(cboIsHorizontal.getValue());
prefs.setIsExpanded(cboIsExpanded.getValue());