diff options
author | Bob Brodt | 2014-04-21 18:32:15 +0000 |
---|---|---|
committer | Bob Brodt | 2014-04-21 18:32:15 +0000 |
commit | b3dbd61203d6b2e9f4ea54ff475839b6cd6af0b5 (patch) | |
tree | 8bcaee2ed16165690b292c29797708bf5206c79b | |
parent | 8cbd4662cbe9dfbf6934e4540c4ab99fdf666510 (diff) | |
download | org.eclipse.bpmn2-modeler-b3dbd61203d6b2e9f4ea54ff475839b6cd6af0b5.tar.gz org.eclipse.bpmn2-modeler-b3dbd61203d6b2e9f4ea54ff475839b6cd6af0b5.tar.xz org.eclipse.bpmn2-modeler-b3dbd61203d6b2e9f4ea54ff475839b6cd6af0b5.zip |
Finished Item Definition rework.
7 files changed, 189 insertions, 116 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java index 235721da..9fde9eba 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/activity/AbstractAddActivityFeature.java @@ -156,6 +156,7 @@ public abstract class AbstractAddActivityFeature<T extends Activity> Graphiti.getPeService().setPropertyValue(pe, ACTIVITY_DECORATOR, "true"); //$NON-NLS-1$ } + FeatureSupport.setToolTip(rect, "Tooltip"); splitConnection(context, containerShape); updatePictogramElement(context, containerShape); layoutPictogramElement(context, containerShape); diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/AbstractDetailComposite.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/AbstractDetailComposite.java index 37982c99..f36d8de1 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/AbstractDetailComposite.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/merrimac/clad/AbstractDetailComposite.java @@ -62,6 +62,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.IExpansionListener; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -275,6 +276,16 @@ public abstract class AbstractDetailComposite extends ListAndDetailCompositeBase return label; } + protected Text createText(Composite parent, String label, String value) { + createLabel(parent,label); + Text text = getToolkit().createText(parent, "", style | SWT.BORDER); //$NON-NLS-1$ + GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); + text.setLayoutData(data); + text.setText(value==null ? "" : value); + text.setEditable(false); + return text; + } + public Font getDescriptionFont() { if (descriptionFont==null) { Display display = Display.getCurrent(); diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/messages.properties b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/messages.properties index 1764eade..739a4756 100644 --- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/messages.properties +++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/messages.properties @@ -184,7 +184,7 @@ UI_DataOutput_description = Activities and Processes often required data in orde Data that is produced is captured using Data Outputs and Output Sets. UI_ItemDefinition_description = Specifies the nature and structure of data objects that can be manipulated, transferred, transformed and stored in a Process. \ Data Objects can be either physical in nature, such as the mechanical part of a vehicle, or informational, such as a catalog of the mechanical parts of a vehicle. \ - Informational items are typically represented as data structures, which are defined by the Type Language of the Process. + Informational items are typically represented as data structures, which are defined by the Type Language of the Process or in an Import file. UI_Message_description = A Message represents the content of a communication between two Participants. UI_Error_description = An Error represents the content of an Error Event or the Fault of a failed Operation. An ItemDefinition is \ diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/diagrams/ItemDefinitionDetailComposite.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/diagrams/ItemDefinitionDetailComposite.java index 45d4bf6e..ed9814e2 100644 --- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/diagrams/ItemDefinitionDetailComposite.java +++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/diagrams/ItemDefinitionDetailComposite.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.bpmn2.modeler.ui.property.diagrams; +import org.eclipse.bpmn2.Definitions; +import org.eclipse.bpmn2.Import; import org.eclipse.bpmn2.ItemDefinition; import org.eclipse.bpmn2.ItemKind; import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesProvider; @@ -20,11 +22,12 @@ import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.ComboObjectEditor; import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.ObjectEditor; import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.TextObjectEditor; import org.eclipse.bpmn2.modeler.core.utils.ModelUtil; -import org.eclipse.bpmn2.modeler.ui.property.editors.SchemaObjectEditor; -import org.eclipse.bpmn2.modeler.ui.property.editors.StructureObjectEditor; +import org.eclipse.bpmn2.modeler.core.utils.NamespaceUtil; +import org.eclipse.bpmn2.modeler.ui.property.editors.ItemDefinitionStructureEditor; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -62,9 +65,8 @@ public class ItemDefinitionDetailComposite extends DefaultDetailComposite { } return propertiesProvider; } - - protected void bindAttribute(Composite parent, EObject object, EAttribute attribute, String label) { + protected void bindAttribute(Composite parent, EObject object, EAttribute attribute, String label) { if ("itemKind".equals(attribute.getName())) { //$NON-NLS-1$ if (isModelObjectEnabled(object.eClass(), attribute)) { @@ -102,14 +104,16 @@ public class ItemDefinitionDetailComposite extends DefaultDetailComposite { if (parent==null) parent = getAttributesParent(); - final ItemDefinition def = (ItemDefinition)object; + final ItemDefinition itemDefinition = (ItemDefinition)object; String displayName = ExtendedPropertiesProvider.getLabel(object, reference); - if (def.getItemKind().equals(ItemKind.INFORMATION)) { - StructureObjectEditor editor = new StructureObjectEditor(this,object,reference); + if (itemDefinition.getItemKind().equals(ItemKind.INFORMATION)) { + // This is an Information item: enforce constraints on this thing + ItemDefinitionStructureEditor editor = new ItemDefinitionStructureEditor(this,itemDefinition); editor.createControl(parent,displayName); } else { + // This is a Physical item: anything goes ObjectEditor editor = new TextObjectEditor(this,object,reference) { @Override protected boolean setValue(Object result) { @@ -118,6 +122,35 @@ public class ItemDefinitionDetailComposite extends DefaultDetailComposite { }; editor.createControl(parent,displayName); } + + // create a Twistie Section for read-only information about this ItemDefinition + Composite container = createSectionComposite(this, "Defined In"); + Object structureRef = itemDefinition.getStructureRef(); + Import imp = itemDefinition.getImport(); + if (imp!=null) { + // the thing is defined in an Import: display Import location, type and namespace + createText(container, "Import", imp.getLocation()); + createText(container, "Type", imp.getImportType()); + createText(container, "Namespace", imp.getNamespace()); + } + else if (ModelUtil.isStringWrapper(structureRef)) { + // the thing is defined within the namespace of the type language, + // or some other namespace defined within the document: display + // the namespace information + String string = ModelUtil.getStringWrapperTextValue(structureRef); + String prefix = ""; + int index = string.indexOf(":"); + if (index>0) + prefix = string.substring(0,index); + Resource resource = ModelUtil.getResource(object); + String namespace = NamespaceUtil.getNamespaceForPrefix(resource, prefix); + if (namespace!=null) + createText(container, "Namespace", namespace); + else { + Definitions definitions = ModelUtil.getDefinitions(resource); + createText(container, "Type Language", definitions.getTypeLanguage()); + } + } } else super.bindReference(parent, object, reference); diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/ItemDefinitionStructureEditor.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/ItemDefinitionStructureEditor.java new file mode 100644 index 00000000..1750cb98 --- /dev/null +++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/ItemDefinitionStructureEditor.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 Red Hat, Inc. + * All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + * + * @author Bob Brodt + ******************************************************************************/ + +package org.eclipse.bpmn2.modeler.ui.property.editors; + +import org.eclipse.bpmn2.Bpmn2Package; +import org.eclipse.bpmn2.Definitions; +import org.eclipse.bpmn2.Import; +import org.eclipse.bpmn2.ItemDefinition; +import org.eclipse.bpmn2.ItemKind; +import org.eclipse.bpmn2.modeler.core.merrimac.clad.AbstractDetailComposite; +import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.TextAndButtonObjectEditor; +import org.eclipse.bpmn2.modeler.core.utils.ModelUtil; +import org.eclipse.bpmn2.modeler.core.validation.SyntaxCheckerUtils; +import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.window.Window; + +/** + * This class implements a Data Structure editor for ItemDefinitions. + * <p> + * The ItemDefinition which is the object of this + * {@link org.eclipse.bpmn2.modeler.core.merrimac.dialogs.ObjectEditor} will be + * populated with the structureRef. + */ +public class ItemDefinitionStructureEditor extends TextAndButtonObjectEditor { + + Definitions definitions = null; + ItemDefinition itemDefinition; + String prefix = null; + + /** + * @param parent + * @param object + */ + public ItemDefinitionStructureEditor(AbstractDetailComposite parent, ItemDefinition itemDefinition) { + super(parent, itemDefinition, Bpmn2Package.eINSTANCE.getItemDefinition_StructureRef()); + this.itemDefinition = itemDefinition; + definitions = ModelUtil.getDefinitions(itemDefinition); + } + + @Override + protected void buttonClicked(int buttonId) { + // Default button was clicked: open a text editor and allow editing of just the + // data structure name part (the localpart) if the original structureRef contained + // a namespace prefix. + String text = getText(); + int index = text.indexOf(":"); + prefix = null; + if (index>0) { + prefix = text.substring(0,index); + if (SyntaxCheckerUtils.isNCName(prefix)) { + // this is a valid namespace prefix + text = text.substring(index+1); + } + else + prefix = null; + } + final ItemKind thisItemKind = itemDefinition.getItemKind(); + final boolean thisIsCollection = itemDefinition.isIsCollection(); + final Import thisImport = itemDefinition.getImport(); + + IInputValidator validator = new IInputValidator() { + @Override + public String isValid(String newText) { + if (newText==null || newText.isEmpty()) + return "Data structure may not be empty"; + if (newText.contains(":") && prefix!=null) { + return "Data structure name may not contain ':'"; + } + String thisText = (prefix!=null) ? + prefix + ":" + newText : + newText; + for (ItemDefinition that : ModelUtil.getAllRootElements(definitions, ItemDefinition.class)) { + String thatText = ModelUtil.getStringWrapperTextValue(that.getStructureRef()); + if ( + thisText.equals(thatText) && + that.getItemKind() == thisItemKind && + that.isIsCollection() == thisIsCollection && + that.getImport() == thisImport + ) { + return "An Item Definition with this data structure name already exists"; + } + } + return null; + } + }; + + InputDialog dialog = new InputDialog( + parent.getShell(), + "Edit Structure", + "Enter data structure name:", + text, + validator); + + if (dialog.open()==Window.OK){ + text = dialog.getValue(); + if (prefix!=null) + text = prefix + ":" + text; + if (!text.equals( getText() )) { + setValue(text); + } + } + } +} diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/StructureObjectEditor.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/StructureObjectEditor.java deleted file mode 100644 index c90899c2..00000000 --- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/editors/StructureObjectEditor.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 Red Hat, Inc. - * All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - * - * @author Bob Brodt - ******************************************************************************/ - -package org.eclipse.bpmn2.modeler.ui.property.editors; - -import org.eclipse.bpmn2.Import; -import org.eclipse.bpmn2.ItemDefinition; -import org.eclipse.bpmn2.modeler.core.merrimac.clad.AbstractDetailComposite; -import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.ComboObjectEditor; -import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.ObjectEditor; -import org.eclipse.bpmn2.modeler.core.merrimac.dialogs.TextAndButtonObjectEditor; -import org.eclipse.bpmn2.modeler.ui.property.dialogs.SchemaSelectionDialog; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; - -/** - * This class implements a Data Structure editor which consists of an editable - * Combobox field and a "Browse" button. The button allows for selection of a BPMN2 - * Import and schema element defined in the Import. The button uses the - * {@link SchemaSelectionDialog} which can be used to either select an existing - * Import or add a new Import to the BPMN2 file. - * <p> - * The ItemDefinition which is the object of this {@link ObjectEditor} will be - * populated with the structureRef (the selected schema element) and the - * import selected in the {@link SchemaSelectionDialog} - */ -public class StructureObjectEditor extends TextAndButtonObjectEditor { - - /** - * @param parent - * @param object - * @param feature - */ - public StructureObjectEditor(AbstractDetailComposite parent, EObject object, EStructuralFeature feature) { - super(parent, object, feature); - } - - @Override - protected boolean canEdit() { - return true; - } - - @Override - protected boolean canCreateNew() { - return true; - } - - @Override - protected boolean canSetNull() { - return true; - } - - @Override - protected void buttonClicked(int buttonId) { -// if (buttonId==ID_CREATE_BUTTON) { -// Object[] result = SchemaObjectEditor.showSchemaSelectionDialog(parent, object); -// if (result.length==2) { -// setValue((String)result[0]); -// if (object instanceof ItemDefinition) { -// ((ItemDefinition)object).setImport((Import)result[1]); -// } -//// fillCombo(); -// } -// } -// else if (buttonId==ID_EDIT_BUTTON) { - IInputValidator validator = new IInputValidator() { - - @Override - public String isValid(String newText) { - if (newText==null || newText.isEmpty()) - return "Data Type may not be empty"; - return null; - } - - }; -// StructuredSelection sel = (StructuredSelection)comboViewer.getSelection(); -// String value = (String) sel.getFirstElement(); - - InputDialog dialog = new InputDialog( - parent.getShell(), - "Edit Data Type", - "Enter new data type:", - getText(), - validator); - if (dialog.open()==Window.OK){ - setValue(dialog.getValue()); - if (object instanceof ItemDefinition) { - ((ItemDefinition)object).setImport(null); - } -// fillCombo(); - } -// } - } -} diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/providers/JavaTreeContentProvider.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/providers/JavaTreeContentProvider.java index be5c6a60..f26abd3d 100644 --- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/providers/JavaTreeContentProvider.java +++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/providers/JavaTreeContentProvider.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.bpmn2.modeler.ui.property.providers; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import org.eclipse.bpmn2.modeler.ui.util.ListMap; @@ -56,6 +59,24 @@ public class JavaTreeContentProvider extends ModelTreeContentProvider { return (r == null ? ListMap.IGNORE : r ); } }; + Arrays.sort(elements, new Comparator<Object>() { + + @Override + public int compare(Object arg0, Object arg1) { + if (arg0 instanceof IType) { + IType t0 = (IType)arg0; + IType t1 = (IType)arg1; + return t0.getElementName().compareTo(t1.getElementName()); + } + else if (arg0 instanceof IMember) { + IMember m0 = (IMember)arg0; + IMember m1 = (IMember)arg1; + return m0.getElementName().compareTo(m1.getElementName()); + } + return 0; + } + + }); return (Object[]) ListMap.Map(elements, visitor, EMPTY_ARRAY); } |