Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src')
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/Activator.java64
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/celleditor/RefinedByMatrixCellEditorConfiguration.java104
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/cellmanager/RefinedByMatrixCellManager.java136
3 files changed, 304 insertions, 0 deletions
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/Activator.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/Activator.java
new file mode 100644
index 00000000000..4187070a22f
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/Activator.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/celleditor/RefinedByMatrixCellEditorConfiguration.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/celleditor/RefinedByMatrixCellEditorConfiguration.java
new file mode 100644
index 00000000000..65cada8593a
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/celleditor/RefinedByMatrixCellEditorConfiguration.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config.celleditor;
+
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.editor.CheckBoxCellEditor;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.painter.CustomCheckBoxPainter;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.requirements.sysml.common.I_SysMLStereotype;
+import org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config.Activator;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+public class RefinedByMatrixCellEditorConfiguration implements ICellAxisConfiguration {
+ /**
+ * the id of this editor
+ */
+ private static final String ID = Activator.PLUGIN_ID
+ + ".celleditor.RefinedByMatrixCellEditorConfiguration.CheckBox";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationId()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationId() {
+ return ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationDescription() {
+ return "This configuration provides a CheckBox editor for a single Boolean that is not necessarily a EStructuralFeature as in SingleBooleanCellEditorConfiguration";//$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#handles(org.eclipse.papyrus.infra.nattable.model.nattable.Table,
+ * java.lang.Object)
+ *
+ * @param table
+ * @param axisElement
+ * @return
+ */
+ @Override
+ public boolean handles(Table table, Object axisElement) {
+ if (table.getTableConfiguration().getName().equals("RefinedByMatrix")) {
+ Object repElement = AxisUtils.getRepresentedElement(axisElement);
+ Element colUMLElement = (Element) repElement;
+ if (UMLUtil.getStereotypeApplication(colUMLElement, Requirement.class) != null) {
+ Stereotype reqStereotype = colUMLElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
+ if (reqStereotype != null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#configureCellEditor(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry,
+ * java.lang.Object, java.lang.String)
+ *
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+
+ @Override
+ public void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CustomCheckBoxPainter(),
+ DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor(),
+ DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
+ new DefaultBooleanDisplayConverter(), DisplayMode.EDIT, configLabel);
+ }
+
+}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/cellmanager/RefinedByMatrixCellManager.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/cellmanager/RefinedByMatrixCellManager.java
new file mode 100644
index 00000000000..9c440e43844
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config/src/org/eclipse/papyrus/requirements/sysml/matrix/refinedBy/config/cellmanager/RefinedByMatrixCellManager.java
@@ -0,0 +1,136 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config.cellmanager;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.nattable.manager.cell.AbstractCellManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.requirements.sysml.common.I_SysMLStereotype;
+import org.eclipse.papyrus.requirements.sysml.matrix.common.helpers.Helper;
+import org.eclipse.papyrus.requirements.sysml.matrix.refinedBy.config.Activator;
+import org.eclipse.papyrus.requirements.sysml.traceability.commands.RefinementCreateCommand;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.uml2.uml.Abstraction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+public class RefinedByMatrixCellManager extends AbstractCellManager {
+ public static final String CELL_MANAGER_ID = Activator.PLUGIN_ID + ".cellmanager.RefinedByMatrixCellManager";
+
+ @Override
+ public boolean handles(Object columnElement, Object rowElement) {
+ // Supports Requirement x Element
+ Object column = AxisUtils.getRepresentedElement(columnElement);
+ Object row = AxisUtils.getRepresentedElement(rowElement);
+ if (rowElement instanceof ITreeItemAxis) {
+ ITreeItemAxis axis = (ITreeItemAxis) rowElement;
+ AxisManagerRepresentation manager = axis.getManager();
+ TableConfiguration conf = (TableConfiguration) manager.eContainer().eContainer();
+ String tableName = conf.getName();
+ if (!tableName.equals("RefinedByMatrix")) {
+ return false;
+ }
+ }
+
+ if (column instanceof Element) {
+ Element colUMLElement = (Element) column;
+ if (UMLUtil.getStereotypeApplication(colUMLElement, Requirement.class) != null) {
+ if (row instanceof Element) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected Object doGetValue(Object columnElement, Object rowElement, INattableModelManager tableManager) {
+ Object column = AxisUtils.getRepresentedElement(columnElement);
+ Object row = AxisUtils.getRepresentedElement(rowElement);
+ EObject eObjectInRow = (EObject) row;
+ if (column instanceof Element) {
+ Element colUMLElement = (Element) column;
+ if (UMLUtil.getStereotypeApplication(colUMLElement, Requirement.class) != null) {
+ Stereotype reqStereotype = colUMLElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
+ Object listOfObjectsThatSatisfyRequirement = colUMLElement.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_REFINEDBY_ATT);
+ if (listOfObjectsThatSatisfyRequirement instanceof EList<?>) {
+ @SuppressWarnings("unchecked")
+ EList<EObject> list = (EList<EObject>) listOfObjectsThatSatisfyRequirement;
+ // check the list of elements that satisfy the requirement
+ // to see if the element in the current row
+ for (EObject eObjectThatSatisfiesRequirement : list) {
+ if (eObjectInRow.equals(eObjectThatSatisfiesRequirement)) {
+ return true;
+ }
+ }
+ }
+
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void setValue(TransactionalEditingDomain domain, Object columnElement, Object rowElement, Object newValue,
+ INattableModelManager tableManager) {
+ Object column = AxisUtils.getRepresentedElement(columnElement);
+ Object row = AxisUtils.getRepresentedElement(rowElement);
+
+ if (column instanceof Element) {
+ Element colUMLElement = (Element) column;
+
+ if (Boolean.FALSE.equals(newValue)) {
+ if (UMLUtil.getStereotypeApplication(colUMLElement, Requirement.class) != null) {
+ Helper.deleteRelationshipInIntersection(domain, row, colUMLElement,
+ I_SysMLStereotype.REQUIREMENT_STEREOTYPE, I_SysMLStereotype.REQUIREMENT_REFINEDBY_ATT,
+ "StandardProfile::Refine");
+ }
+ } else if (Boolean.TRUE.equals(newValue)
+ || (newValue instanceof Abstraction && ((Abstraction) newValue).eContainer() == null)) {
+ if (row instanceof Element) {
+ RefinementCreateCommand refinementCreateCommand = new RefinementCreateCommand(domain,
+ (NamedElement) (EObject) row, (NamedElement) colUMLElement);
+ refinementCreateCommand.execute();
+ }
+ }
+ }
+ }
+
+ @Override
+ public Command getSetValueCommand(TransactionalEditingDomain domain, Object columnElement, Object rowElement,
+ Object newValue, INattableModelManager tableManager) {
+ return super.getSetValueCommand(domain, columnElement, rowElement, newValue, tableManager);
+ }
+
+ @Override
+ public boolean isCellEditable(Object columnElement, Object rowElement) {
+ Object column = AxisUtils.getRepresentedElement(columnElement);
+ Object row = AxisUtils.getRepresentedElement(rowElement);
+ if (row instanceof NamedElement && column instanceof Element) {
+ return UMLUtil.getStereotypeApplication((Element) column, Requirement.class) != null;
+ }
+ return false;
+ }
+}

Back to the top