Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-11-28 13:31:19 +0000
committerGerrit Code Review @ Eclipse.org2016-11-30 14:55:00 +0000
commit6e9101fcda37f09fcc0d98289dc44360b9f4d63a (patch)
tree9ebebfedfd96a4a734ee47e0f262b8cefe47a793
parent9a1f912107c70ed3504f2ed6a877e8b322f68026 (diff)
downloadorg.eclipse.papyrus-6e9101fcda37f09fcc0d98289dc44360b9f4d63a.tar.gz
org.eclipse.papyrus-6e9101fcda37f09fcc0d98289dc44360b9f4d63a.tar.xz
org.eclipse.papyrus-6e9101fcda37f09fcc0d98289dc44360b9f4d63a.zip
Bug 504077: [Table] Papyrus table to support percentage sizing offered
by NatTable https://bugs.eclipse.org/bugs/show_bug.cgi?id=504077 Add the named styles: - 'columnsWidthAsPercentage' to manage axis width with percentage. If this named style is managed as true, the 'axisWidth' are managed as percentage too. - 'saveColumnsWidth' to determinate if the 'axisWidth' must be used for the table columns width initialization - Modify the 'stereotype.nattableconfiguration' to manage axisWidth as percentage instead of pixels Change-Id: Idf748fc7014202fdeb4c7c57ce8a8a93eb6feea3 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSpanningDataLayer.java217
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java157
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java10
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java22
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/config/stereotype.nattableconfiguration10
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java19
6 files changed, 305 insertions, 130 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSpanningDataLayer.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSpanningDataLayer.java
index 6c35102a9d5..a3293119ccb 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSpanningDataLayer.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSpanningDataLayer.java
@@ -1,101 +1,116 @@
-/*****************************************************************************
- * Copyright (c) 2014-2015 CEA LIST and others.
- *
- * 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:
- * CEA LIST - Initial API and implementation
- * Camille Letavernier - CEA LIST - Bug 464168 - Use the Context's EditingDomain
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.nattable.layer;
-
-import java.util.List;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.nebula.widgets.nattable.coordinate.Range;
-import org.eclipse.nebula.widgets.nattable.data.ISpanningDataProvider;
-import org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer;
-import org.eclipse.nebula.widgets.nattable.util.ArrayUtil;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-
-/**
- *
- * @author QL238289
- * @see org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer
- *
- *
- */
-public class PapyrusSpanningDataLayer extends SpanningDataLayer {
-
- private TransactionalEditingDomain contextDomain;
-
- private INattableModelManager manager;
-
- /**
- * Constructor.
- *
- * @param dataProvider
- * @param defaultColumnWidth
- * @param defaultRowHeight
- */
- public PapyrusSpanningDataLayer(final TransactionalEditingDomain contextDomain, ISpanningDataProvider dataProvider, int defaultColumnWidth, int defaultRowHeight) {
- super(dataProvider, defaultColumnWidth, defaultRowHeight);
- this.contextDomain = contextDomain;
-
- }
-
- /**
- * Constructor.
- *
- * @param dataProvider
- */
- public PapyrusSpanningDataLayer(final TransactionalEditingDomain contextDomain, ISpanningDataProvider dataProvider) {
- super(dataProvider);
- this.contextDomain = contextDomain;
- }
-
-
- /**
- * Constructor.
- *
- * @param contextEditingDomain
- * @param manager
- * @param spanProvider
- * @param defaultCellWidth
- * @param defaultCellHeight
- */
- public PapyrusSpanningDataLayer(TransactionalEditingDomain contextEditingDomain, INattableModelManager manager,
- ISpanningDataProvider spanProvider, int defaultCellWidth, int defaultCellHeight) {
- super(spanProvider, defaultCellWidth, defaultCellHeight);
- this.contextDomain = contextEditingDomain;
- this.manager = manager;
- }
-
- /**
- * @see org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer#setDataValue(int, int, java.lang.Object)
- *
- * @param columnIndex
- * @param rowIndex
- * @param newValue
- */
- @Override
- public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
- RecordingCommand recordUpdate = new RecordingCommand(this.contextDomain) {
-
- @Override
- protected void doExecute() {
- // AbstractCellManager's setValue() takes care of the compatibility between the cell and the edit types
- // 469109: [Tree Table] set value problem when categories are hidden
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=469109
- PapyrusSpanningDataLayer.super.setDataValue(columnIndex, rowIndex, newValue);
- }
- };
- this.contextDomain.getCommandStack().execute(recordUpdate);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2014-2015 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ * Camille Letavernier - CEA LIST - Bug 464168 - Use the Context's EditingDomain
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.layer;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.nebula.widgets.nattable.data.ISpanningDataProvider;
+import org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer;
+import org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * @author QL238289
+ * @see org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer
+ *
+ *
+ */
+public class PapyrusSpanningDataLayer extends SpanningDataLayer {
+
+ private TransactionalEditingDomain contextDomain;
+
+ private INattableModelManager manager;
+
+ /**
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param defaultColumnWidth
+ * @param defaultRowHeight
+ */
+ public PapyrusSpanningDataLayer(final TransactionalEditingDomain contextDomain, ISpanningDataProvider dataProvider, int defaultColumnWidth, int defaultRowHeight) {
+ super(dataProvider, defaultColumnWidth, defaultRowHeight);
+ this.contextDomain = contextDomain;
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param dataProvider
+ */
+ public PapyrusSpanningDataLayer(final TransactionalEditingDomain contextDomain, ISpanningDataProvider dataProvider) {
+ super(dataProvider);
+ this.contextDomain = contextDomain;
+ }
+
+
+ /**
+ * Constructor.
+ *
+ * @param contextEditingDomain
+ * @param manager
+ * @param spanProvider
+ * @param defaultCellWidth
+ * @param defaultCellHeight
+ */
+ public PapyrusSpanningDataLayer(TransactionalEditingDomain contextEditingDomain, INattableModelManager manager,
+ ISpanningDataProvider spanProvider, int defaultCellWidth, int defaultCellHeight) {
+ super(spanProvider, defaultCellWidth, defaultCellHeight);
+ this.contextDomain = contextEditingDomain;
+ this.manager = manager;
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer#setDataValue(int, int, java.lang.Object)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @param newValue
+ */
+ @Override
+ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ RecordingCommand recordUpdate = new RecordingCommand(this.contextDomain) {
+
+ @Override
+ protected void doExecute() {
+ // AbstractCellManager's setValue() takes care of the compatibility between the cell and the edit types
+ // 469109: [Tree Table] set value problem when categories are hidden
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=469109
+ PapyrusSpanningDataLayer.super.setDataValue(columnIndex, rowIndex, newValue);
+ }
+ };
+ this.contextDomain.getCommandStack().execute(recordUpdate);
+ }
+
+ /**
+ * This allows to set the column width with a percentage.
+ *
+ * @param columnPosition
+ * The column position to modify.
+ * @param width
+ * The width as percentage.
+ * @param fireEvent
+ * Boolean to determinate if layer event must be fire.
+ */
+ public void setColumnWidthPercentageByPosition(int columnPosition, int width, boolean fireEvent) {
+ this.columnWidthConfig.setPercentage(columnPosition, width);
+ if (fireEvent){
+ fireLayerEvent(new ColumnResizeEvent(this, columnPosition));
+ }
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index 4184b9bc0f9..fc7288e0e6c 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -12,6 +12,7 @@
* Christian W. Damus (CEA) - bug 402525
* Christian W. Damus (CEA) - bug 430880
* Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
+ * Nicolas FAUVERGUE(ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077
*
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
@@ -19,8 +20,10 @@ package org.eclipse.papyrus.infra.nattable.manager.table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.command.Command;
@@ -236,7 +239,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
private BodyLayerStack bodyLayerStack;
- private ILayerListener resizeAxisListener;
+ protected ILayerListener resizeAxisListener;
private ILayerListener resizeRowHeaderListener;
@@ -768,7 +771,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* @param bodyLayerStack
* the table's body layer
*/
- private void addAxisResizeListener(final BodyLayerStack bodyLayerStack) {
+ protected void addAxisResizeListener(final BodyLayerStack bodyLayerStack) {
resizeAxisListener = new ILayerListener() {
@Override
@@ -782,16 +785,41 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
if (event instanceof ColumnResizeEvent) {
+
// get the index of the first column modified by the user
// the assumption is that the user changes only one column at a time in order to resize to its liking
int resizedColumnPosition = getRangeStart(event);
// get the resized value from this column
- int newColumnSize = columnHeaderLayerStack.getColumnWidthByPosition(resizedColumnPosition);
- ICommand cmd = createSetColumnSizeCommand(resizedColumnPosition, newColumnSize);
- if (cmd != null && cmd.canExecute()) {
- resizeCommand.add(cmd);
- }
+ int newColumnSize = getBodyLayerStack().getBodyDataLayer().getColumnWidthByPosition(resizedColumnPosition);
+
+ // If the columns width are managed as percentage, transform the width to the percentage
+ if (isColumnWidthAsPercentage()) {
+ int columnSizePercentage = getInitialColumnWidthPercentage();
+
+ final Composite parent = natTable.getParent();
+ if (null != parent && !parent.isDisposed()) {
+ final int parentSize = parent.getSize().x;
+
+ // Get the columns size without header
+ final int columnsSize = parentSize - PapyrusTableSizeCalculation.getRowHeaderWidth(AbstractNattableWidgetManager.this);
+ // Calculate the current percentage of the new width
+ int currentPercentage = Math.round(newColumnSize * 100.0f / columnsSize);
+
+ // If the current percentage is not equals to the initial percentage, set the named style with the percentage, else do nothing
+ if (currentPercentage != columnSizePercentage) {
+ final ICommand cmd = createSetColumnSizeCommand(resizedColumnPosition, currentPercentage);
+ if (cmd != null && cmd.canExecute()) {
+ resizeCommand.add(cmd);
+ }
+ }
+ }
+ } else {
+ ICommand cmd = createSetColumnSizeCommand(resizedColumnPosition, newColumnSize);
+ if (cmd != null && cmd.canExecute()) {
+ resizeCommand.add(cmd);
+ }
+ }
}
// the process is the same for this event
@@ -817,6 +845,45 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
/**
+ * This allows to calculate the initial width percentage for a column without 'axisWidth' named style.
+ *
+ * @return The percentage for a column without 'axisWidth' named style.
+ * @since 3.0
+ */
+ protected int getInitialColumnWidthPercentage() {
+ int remainingPercentage = 100;
+ int numberColumnWithoutDefinedWidth = 0;
+
+ // Get the boolean value style to determinate if we need to use the columns width
+ BooleanValueStyle saveColumnsWidth = (BooleanValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.SAVE_COLUMNS_WIDTH);
+ if (null == saveColumnsWidth) {
+ final TableConfiguration config = getTable().getTableConfiguration();
+ saveColumnsWidth = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.SAVE_COLUMNS_WIDTH);
+ }
+
+ List<IAxis> notationColumnsAxisList = getTable().getCurrentColumnAxisProvider().getAxis();
+ // we go through all the elements to find those which have been modified
+ for (int index = 0; index < notationColumnsAxisList.size(); index++) {
+ IAxis currentColumnAxis = notationColumnsAxisList.get(index);
+ // we need both to detect and use the correct value, width or height, of the handled element as the user could have modified the table when the axis was inverted
+ if (!getTable().isInvertAxis()) {
+ int axisWidth = getBodyLayerStack().getBodyDataLayer().getColumnWidthByPosition(index);
+ IntValueStyle value = (IntValueStyle) currentColumnAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
+ if (value != null && (null == saveColumnsWidth || (null != saveColumnsWidth && saveColumnsWidth.isBooleanValue()))) {
+ remainingPercentage -= axisWidth;
+ } else {
+ numberColumnWithoutDefinedWidth++;
+ }
+ }
+ }
+
+ if (0 == numberColumnWithoutDefinedWidth) {
+ numberColumnWithoutDefinedWidth = 1;
+ }
+ return Math.round(remainingPercentage / numberColumnWithoutDefinedWidth);
+ }
+
+ /**
* Create the set column size command for the column resizing.
*
* @param columnIndex
@@ -1468,6 +1535,24 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
// value, width or height, of the resized column or row
IntValueStyle value = null;
+ // Get the boolean value style to determinate if the width in named style is managed as percentage or as pixels
+ boolean isUsedPercentage = isColumnWidthAsPercentage();
+ if (isUsedPercentage) {
+ // Notify the column percentage management to the body layer
+ tableBodyLayer.setColumnPercentageSizing(true);
+ }
+
+ // Get the boolean value style to determinate if we need to use the columns width
+ BooleanValueStyle saveColumnsWidth = (BooleanValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.SAVE_COLUMNS_WIDTH);
+ if (null == saveColumnsWidth) {
+ final TableConfiguration config = getTable().getTableConfiguration();
+ saveColumnsWidth = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.SAVE_COLUMNS_WIDTH);
+ }
+
+ // Get the axis with non 'axisWidth' named style (to set the correct percentage)
+ final Set<Integer> notManagedIndexAxisWidth = new HashSet<Integer>();
+ int remainingPercentage = 100;
+
// we go through all the elements to find those which have been modified
for (int index = 0; index < notationColumnsAxisList.size(); index++) {
IAxis currentColumnAxis = notationColumnsAxisList.get(index);
@@ -1475,12 +1560,21 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
if (!getTable().isInvertAxis()) {
int axisWidth = tableBodyLayer.getColumnWidthByPosition(index);
value = (IntValueStyle) currentColumnAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
- if (value != null) {
- // we set the size of the axis in the graphical representation
- tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
- } else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth()) {
+ if (value != null && (null == saveColumnsWidth || (null != saveColumnsWidth && !saveColumnsWidth.isBooleanValue()))) {
+ if (isUsedPercentage) {
+ // Set the percentage with the correct function
+ tableBodyLayer.setColumnWidthPercentageByPosition(index, value.getIntValue());
+ remainingPercentage -= value.getIntValue();
+ } else {
+ // we set the size of the axis in the graphical representation
+ tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
+ }
+ } else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth() && !isUsedPercentage) {
// resets the size in case of an undo to the default table
tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
+ } else if (isUsedPercentage) {
+ // If the columns width are managed with percentage, we need to recalculate it
+ notManagedIndexAxisWidth.add(index);
}
} else {
int axisHeight = tableBodyLayer.getRowHeightByPosition(index);
@@ -1506,19 +1600,36 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
} else {
int axisWidth = tableBodyLayer.getColumnWidthByPosition(index);
value = (IntValueStyle) currentRowAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
- if (value != null) {
- tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
- } else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth()) {
+ if (value != null && (null == saveColumnsWidth || (null != saveColumnsWidth && !saveColumnsWidth.isBooleanValue()))) {
+ if (isUsedPercentage) {
+ tableBodyLayer.setColumnWidthPercentageByPosition(index, value.getIntValue());
+ remainingPercentage -= value.getIntValue();
+ } else {
+ tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
+ }
+ } else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth() && !isUsedPercentage) {
tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
+ } else if (isUsedPercentage) {
+ // If the columns width are managed with percentage, we need to recalculate it
+ notManagedIndexAxisWidth.add(index);
}
}
}
+ // For the axis without 'axisWidth' named style and with the columns width percentage management, set the correct percentage
+ for (int index : notManagedIndexAxisWidth) {
+ tableBodyLayer.setColumnWidthPercentageByPosition(index, Math.round(remainingPercentage / notManagedIndexAxisWidth.size()));
+ }
+
// this method is used to resize by default. In the actual state, only the rows, representing the table's core elements, are missing from the notation file
if (notationRowsAxisList.size() == 0) {
if (getTable().isInvertAxis()) {
for (int index = 0; index < actualColumnAxisElements; index++) {
- tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
+ if (isUsedPercentage) {
+ tableBodyLayer.setColumnWidthPercentageByPosition(index, 100 / actualColumnAxisElements);
+ } else {
+ tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
+ }
}
} else if (!getTable().isInvertAxis()) {
@@ -1564,6 +1675,22 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
/**
+ * Get the column width as percentage management value.
+ *
+ * @return <code>true</code> if columns width are managed as percentage, <code>false</code> otherwise.
+ * @since 3.0
+ */
+ protected boolean isColumnWidthAsPercentage() {
+ BooleanValueStyle columnsWidthAsPercentage = (BooleanValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.COLUMNS_WIDTH_AS_PERCENTAGE);
+ if (null == columnsWidthAsPercentage) {
+ final TableConfiguration config = getTable().getTableConfiguration();
+ columnsWidthAsPercentage = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.COLUMNS_WIDTH_AS_PERCENTAGE);
+ }
+
+ return null != columnsWidthAsPercentage && columnsWidthAsPercentage.isBooleanValue();
+ }
+
+ /**
*
* Handles the initialization of the table's headers resize styles, on opening, based on the previous changes made by the user.
*
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index 93aaf46a555..3499c719545 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -9,7 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618, 504077
* Nicolas Boulay (Esterel Technologies SAS) - Bug 497467
* Sebastien Bordes (Esterel Technologies SAS) - Bug 497738
*
@@ -97,11 +97,13 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.Na
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecell.Cell;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.CellEditorDeclaration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.FeatureLabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ObjectLabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.BooleanValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntValueStyle;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
import org.eclipse.papyrus.infra.nattable.selection.ISelectionExtractor;
import org.eclipse.papyrus.infra.nattable.selection.ObjectsSelectionExtractor;
@@ -110,6 +112,7 @@ import org.eclipse.papyrus.infra.nattable.sort.PapyrusCompositeGlazedListSortMod
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.CellMapKey;
import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.StringComparator;
import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
@@ -771,7 +774,10 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
public void resizeAxis() {
- initTableAxis();
+ // If the columns width is managed by percentage, the table axis don't have to be recalculated
+ if (!isColumnWidthAsPercentage()) {
+ initTableAxis();
+ }
refreshNatTable();
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java
index e0339984245..591f82c06f9 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE(ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077
*
*****************************************************************************/
@@ -97,7 +98,7 @@ public class NamedStyleConstants {
/**
* key used to save a filter configuration id state when the system use a filter choosen by the user
- * It is only used as name for a {@link StringValueStyle}, we use a specific key in order to not destroyed it when we unapply filter on a column where filter has been definied by the user
+ * It is only used as name for a {@link StringValueStyle}, we use a specific key in order to not destroyed it when we unapply filter on a column where filter has been defined by the user
*
*
*/
@@ -110,6 +111,25 @@ public class NamedStyleConstants {
/**
* This allows to manage the fill columns size to take all the container space.
+ *
+ * @deprecated since 3.0
*/
+ @Deprecated
public static final String FILL_COLUMNS_SIZE = "fillColumnsSize"; //$NON-NLS-1$
+
+ /**
+ * This allows to determinate if the columns width must be managed as percentage.
+ * This named style is not compatible with 'fillColumnsSize'.
+ *
+ * @since 3.0
+ */
+ public static final String COLUMNS_WIDTH_AS_PERCENTAGE = "columnsWidthAsPercentage"; //$NON-NLS-1$
+
+ /**
+ * This allows to determinate if the columns width must be saved or not.
+ * This named style is not compatible with 'fillColumnsSize'.
+ *
+ * @since 3.0
+ */
+ public static final String SAVE_COLUMNS_WIDTH = "saveColumnsWidth"; //$NON-NLS-1$
}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/config/stereotype.nattableconfiguration b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/config/stereotype.nattableconfiguration
index 4db16e6b505..dd9636706cd 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/config/stereotype.nattableconfiguration
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/config/stereotype.nattableconfiguration
@@ -36,19 +36,19 @@
</columnHeaderAxisConfiguration>
<columnAxisProviders xsi:type="nattableaxisprovider:SlaveObjectAxisProvider" description="This axis provider provides available columns according to the columns of the table ( features of the object displayed on the other axis)" name="Stereotype display properties axis provider">
<axis xsi:type="nattableaxis:FeatureIdAxis" manager="//@columnHeaderAxisConfiguration/@axisManagers.0" alias="Name Depth" element="stereotype_display_properties:/nameDepth">
- <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="100"/>
+ <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="17"/>
</axis>
<axis xsi:type="nattableaxis:FeatureIdAxis" manager="//@columnHeaderAxisConfiguration/@axisManagers.0" alias="Visible" element="stereotype_display_properties:/isDisplayed">
- <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="100"/>
+ <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="17"/>
</axis>
<axis xsi:type="nattableaxis:FeatureIdAxis" manager="//@columnHeaderAxisConfiguration/@axisManagers.0" alias="In Braces" element="stereotype_display_properties:/isDisplayedInBraces">
- <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="120"/>
+ <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="22"/>
</axis>
<axis xsi:type="nattableaxis:FeatureIdAxis" manager="//@columnHeaderAxisConfiguration/@axisManagers.0" alias="In Comment" element="stereotype_display_properties:/isDisplayedInComment">
- <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="120"/>
+ <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="22"/>
</axis>
<axis xsi:type="nattableaxis:FeatureIdAxis" manager="//@columnHeaderAxisConfiguration/@axisManagers.0" alias="In Compartment" element="stereotype_display_properties:/isDisplayedInCompartment">
- <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="120"/>
+ <styles xsi:type="nattablestyle:IntValueStyle" name="axisWidth" intValue="22"/>
</axis>
</columnAxisProviders>
<rowAxisProviders xsi:type="nattableaxisprovider:MasterObjectAxisProvider" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowAxisManager" disconnectSlave="true"/>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
index 736746bce58..94ed97cd45b 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
@@ -10,6 +10,7 @@
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
* Christian W. Damus - bugs 493858, 493853
* Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr - bugs 494537, 504745
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -793,13 +794,19 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
// for the table displayed in property view, we want to use all the available place, so we add a specific named style each time
- BooleanValueStyle fillStyle = (BooleanValueStyle) table.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE);
+ // We manage it with percentage named style
+ BooleanValueStyle columnsWidthAsPercentage = (BooleanValueStyle) table.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.COLUMNS_WIDTH_AS_PERCENTAGE);
// if the name style already exists we do nothing
- if (null == fillStyle) {
- fillStyle = NattablestyleFactory.eINSTANCE.createBooleanValueStyle();
- fillStyle.setName(NamedStyleConstants.FILL_COLUMNS_SIZE);
- fillStyle.setBooleanValue(true);
- table.getStyles().add(fillStyle);
+ if (null == columnsWidthAsPercentage) {
+ // for the table displayed in property view, we want to use all the available place, so we add a specific named style each time
+ BooleanValueStyle fillStyle = (BooleanValueStyle) table.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE);
+ // if the name style already exists we do nothing
+ if (null == fillStyle) {
+ columnsWidthAsPercentage = NattablestyleFactory.eINSTANCE.createBooleanValueStyle();
+ columnsWidthAsPercentage.setName(NamedStyleConstants.COLUMNS_WIDTH_AS_PERCENTAGE);
+ columnsWidthAsPercentage.setBooleanValue(true);
+ table.getStyles().add(columnsWidthAsPercentage);
+ }
}
// for the table displayed in property view, we expand all directly

Back to the top