diff options
author | Ansgar Radermacher | 2019-05-16 09:59:56 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2019-05-16 09:59:56 +0000 |
commit | a511343ffb8f5115d3d371eab4a75483a91d7135 (patch) | |
tree | 782caca8cc54a75ed022a8d005884a9e3b716296 | |
parent | b1cfbd2223d04923df05deac447718a559d14f6f (diff) | |
download | org.eclipse.papyrus-robotics-a511343ffb8f5115d3d371eab4a75483a91d7135.tar.gz org.eclipse.papyrus-robotics-a511343ffb8f5115d3d371eab4a75483a91d7135.tar.xz org.eclipse.papyrus-robotics-a511343ffb8f5115d3d371eab4a75483a91d7135.zip |
Bug 546986 - [Robotics] It should be easy to update parameter entry names and types
- Add a name and type columns to default value table
Change-Id: Id4dbc6b1b5d9520c451bb96df8137dc888c16de6
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
2 files changed, 66 insertions, 32 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.parameters/config/tables/defaultValue.nattableconfiguration b/plugins/customization/org.eclipse.papyrus.robotics.parameters/config/tables/defaultValue.nattableconfiguration index 66131d01..7d74e5f5 100644 --- a/plugins/customization/org.eclipse.papyrus.robotics.parameters/config/tables/defaultValue.nattableconfiguration +++ b/plugins/customization/org.eclipse.papyrus.robotics.parameters/config/tables/defaultValue.nattableconfiguration @@ -3,7 +3,7 @@ <styles xmi:type="nattablestyle:TableDisplayStyle" xmi:id="_hviMUUkqEeil4MD2OcSjtg" displayStyle="NORMAL"/> <styles xmi:type="nattablestyle:BooleanValueStyle" xmi:id="_hviMUkkqEeil4MD2OcSjtg" name="columnsWidthAsPercentage"/> <creationTester xmi:type="nattabletester:JavaTableTester" xmi:id="_hviMU0kqEeil4MD2OcSjtg" tester="org.eclipse.papyrus.robotics.parameters.defaultvalue.DefaultValueTableTester"/> - <rowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:TableHeaderAxisConfiguration" xmi:id="_hviMVEkqEeil4MD2OcSjtg" indexStyle="NUMERIC" displayLabel="true" displayFilter="false" displayIndex="false"> + <rowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:TableHeaderAxisConfiguration" xmi:id="_hviMVEkqEeil4MD2OcSjtg" indexStyle="NUMERIC" displayLabel="false" displayFilter="false" displayIndex="false"> <styles xmi:type="nattablestyle:IntValueStyle" xmi:id="_hviMVUkqEeil4MD2OcSjtg" name="rowLabelWidth" intValue="250"/> <ownedLabelConfigurations xmi:type="nattablelabelprovider:ObjectLabelProviderConfiguration" xmi:id="_hviMVkkqEeil4MD2OcSjtg" displayIcon="false" displayLabel="true"/> <axisManagers xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" xmi:id="_hviMV0kqEeil4MD2OcSjtg" axisManagerId="org.eclipse.papyrus.robotics.parameters.defaultvalue.DefaultValueTableRowAxisManager" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.labelprovider" headerLabelConfiguration="_hviMVkkqEeil4MD2OcSjtg"/> @@ -13,9 +13,15 @@ <axisManagers xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" xmi:id="_hviMWkkqEeil4MD2OcSjtg" axisManagerId="org.eclipse.papyrus.uml.nattable.feature.axis.manager" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.feature.labelprovider" headerLabelConfiguration="_hviMWUkqEeil4MD2OcSjtg"/> </columnHeaderAxisConfiguration> <columnAxisProviders xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_hviMW0kqEeil4MD2OcSjtg" description="Provides table default columns" name="Default Value Column Provider"> - <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_hviMXEkqEeil4MD2OcSjtg" manager="_hviMWkkqEeil4MD2OcSjtg" alias="Value"> + <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_hviMXEkqEeil4MD2OcSjth" manager="_hviMWkkqEeil4MD2OcSjtg" alias="Name"> + <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/> + </axis> + <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_hviMXEkqEeil4MD2OcSjti" manager="_hviMWkkqEeil4MD2OcSjtg" alias="Type"> + <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//TypedElement/type"/> + </axis> + <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_hviMXEkqEeil4MD2OcSjtg" manager="_hviMWkkqEeil4MD2OcSjtg" alias="Default value"> <styles xmi:type="nattablestyle:IntValueStyle" xmi:id="_hviMXUkqEeil4MD2OcSjtg" name="axisWidth" intValue="150"/> - <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//StructuredClassifier/ownedAttribute"/> + <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//Property/default"/> </axis> </columnAxisProviders> <rowAxisProviders xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_hvizYEkqEeil4MD2OcSjtg" description="The row provider stores the definition of default values" name="Default Value Row Provider" disconnectSlave="true"/> diff --git a/plugins/customization/org.eclipse.papyrus.robotics.parameters/src/org/eclipse/papyrus/robotics/parameters/defaultvalue/DefaultValueTableCellManager.java b/plugins/customization/org.eclipse.papyrus.robotics.parameters/src/org/eclipse/papyrus/robotics/parameters/defaultvalue/DefaultValueTableCellManager.java index 93c0cda5..11ee7513 100644 --- a/plugins/customization/org.eclipse.papyrus.robotics.parameters/src/org/eclipse/papyrus/robotics/parameters/defaultvalue/DefaultValueTableCellManager.java +++ b/plugins/customization/org.eclipse.papyrus.robotics.parameters/src/org/eclipse/papyrus/robotics/parameters/defaultvalue/DefaultValueTableCellManager.java @@ -35,11 +35,19 @@ import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.robotics.parameters.utils.ParameterTableUtils; import org.eclipse.uml2.uml.OpaqueExpression; import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; import org.eclipse.uml2.uml.ValueSpecification; public class DefaultValueTableCellManager extends AbstractCellManager { + /** + * Alias names as in table definitions + */ + private static final String DEFAULT_VALUE = "Default value"; //$NON-NLS-1$ + private static final String TYPE = "Type"; //$NON-NLS-1$ + private static final String NAME = "Name"; //$NON-NLS-1$ + // Table type handled by the cell manager public static final String DEFAULT_VALUE_TABLE = "DefaultValueTable"; //$NON-NLS-1$ @@ -86,10 +94,19 @@ public class DefaultValueTableCellManager extends AbstractCellManager { // an opaque expression. In this situation an literal string gets generated // and its value is the content of the first body of the opaque expression. Object value = ""; //$NON-NLS-1$ - if (rowElement instanceof Property) { + String alias = columnElement instanceof IAxis ? ((IAxis) columnElement).getAlias() : null; + + if (rowElement instanceof Property && alias != null) { Property p = (Property) rowElement; - if (p != null && p.getDefault() != null) { - return p.getDefault(); + + if (alias.equals(NAME)) { + return p.getName(); + } else if (alias.equals(TYPE)) { + return p.getType().getName(); + } else if (alias.equals(DEFAULT_VALUE)) { + if (p != null && p.getDefault() != null) { + return p.getDefault(); + } } } return value; @@ -101,36 +118,47 @@ public class DefaultValueTableCellManager extends AbstractCellManager { // The text provided by the cell editor in usage is retrieved. If the value associated // to the defining feature was an opaque expression then the first body of this opaque // expression is + String alias = columnElement instanceof IAxis ? ((IAxis) columnElement).getAlias() : null; + Property property = (Property) rowElement; + IElementEditService provider = ElementEditServiceUtils.getCommandProvider(property); + CompositeCommand editingCommand = new CompositeCommand(null); - if (newValue instanceof String) { + if (newValue instanceof Type) { + AbstractEditCommandRequest setTypeReq = new SetRequest(domain, property, UMLPackage.eINSTANCE.getTypedElement_Type(), (Type) newValue); + editingCommand.compose(provider.getEditCommand(setTypeReq)); + } + else if (newValue instanceof String) { String text = (String) newValue; if (text != null) { - text = text.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$ - Property property = (Property) rowElement; - if (property.getDefaultValue() instanceof OpaqueExpression) { - OpaqueExpression expression = (OpaqueExpression) property.getDefaultValue(); - IElementEditService provider = ElementEditServiceUtils.getCommandProvider(expression); - if (provider != null) { - List<String> bodies = expression.getBodies(); - Collection<String> newBodies = new ArrayList<String>(); - newBodies.add(text); - if (!bodies.isEmpty()) { - newBodies.addAll(bodies.subList(1, bodies.size())); - } else { - Collection<String> newLanguages = new ArrayList<String>(); - newLanguages.add("Matlab"); //$NON-NLS-1$ - AbstractEditCommandRequest languageRequest = new SetRequest(domain, expression, UMLPackage.eINSTANCE.getOpaqueExpression_Language(), newLanguages); - editingCommand.compose(provider.getEditCommand(languageRequest)); + if (alias.equals(NAME)) { + AbstractEditCommandRequest setNameReq = new SetRequest(domain, property, UMLPackage.eINSTANCE.getNamedElement_Name(), text); + editingCommand.compose(provider.getEditCommand(setNameReq)); + } else if (alias.equals(DEFAULT_VALUE)) { + text = text.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$ + + if (property.getDefaultValue() instanceof OpaqueExpression) { + OpaqueExpression expression = (OpaqueExpression) property.getDefaultValue(); + if (provider != null) { + List<String> bodies = expression.getBodies(); + Collection<String> newBodies = new ArrayList<String>(); + newBodies.add(text); + if (!bodies.isEmpty()) { + newBodies.addAll(bodies.subList(1, bodies.size())); + } else { + Collection<String> newLanguages = new ArrayList<String>(); + newLanguages.add("Matlab"); //$NON-NLS-1$ + AbstractEditCommandRequest languageRequest = new SetRequest(domain, expression, UMLPackage.eINSTANCE.getOpaqueExpression_Language(), newLanguages); + editingCommand.compose(provider.getEditCommand(languageRequest)); + } + AbstractEditCommandRequest bodiesRequest = new SetRequest(domain, expression, UMLPackage.eINSTANCE.getOpaqueExpression_Body(), newBodies); + editingCommand.compose(provider.getEditCommand(bodiesRequest)); + } + } else { + ValueSpecification specification = ParameterTableUtils.createValueSpecification(property, property.getType(), text); + if (specification != null && provider != null) { + AbstractEditCommandRequest request = new SetRequest(domain, property, UMLPackage.eINSTANCE.getProperty_DefaultValue(), specification); + editingCommand.compose(provider.getEditCommand(request)); } - AbstractEditCommandRequest bodiesRequest = new SetRequest(domain, expression, UMLPackage.eINSTANCE.getOpaqueExpression_Body(), newBodies); - editingCommand.compose(provider.getEditCommand(bodiesRequest)); - } - } else { - ValueSpecification specification = ParameterTableUtils.createValueSpecification(property, property.getType(), text); - IElementEditService provider = ElementEditServiceUtils.getCommandProvider(property); - if (specification != null && provider != null) { - AbstractEditCommandRequest request = new SetRequest(domain, property, UMLPackage.eINSTANCE.getProperty_DefaultValue(), specification); - editingCommand.compose(provider.getEditCommand(request)); } } } |