Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-11-26 16:59:32 +0000
committervincent lorenzo2016-01-08 15:53:12 +0000
commit75831599d5aa8d3f8613671632145451df800df2 (patch)
treee520cb46e5e90567964739751713036d31756092 /plugins/infra
parent419ea81bf5c4267f18ef147cee01ebedbb4b7679 (diff)
downloadorg.eclipse.papyrus-75831599d5aa8d3f8613671632145451df800df2.tar.gz
org.eclipse.papyrus-75831599d5aa8d3f8613671632145451df800df2.tar.xz
org.eclipse.papyrus-75831599d5aa8d3f8613671632145451df800df2.zip
Bug 481018: [Table] Width of row header columns is not persisted for
column index >1 https://bugs.eclipse.org/bugs/show_bug.cgi?id=481018 Implement the NamedStyle for the row header position when the index is superior to 1. The name if the new style is : 'rowPositionXLabelWidth' when x is the position of the column of the row header to manage Add JUnit tests. Change-Id: I1583748187a1d559b400b14fc13118550131be31 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/infra')
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java103
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java188
2 files changed, 183 insertions, 108 deletions
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 e06a874fc02..df078ce0c46 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
@@ -943,6 +943,11 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
}
+
+ // If this index is not display, increment the resized header position to corresponding to the label
+ if(null != localColumnHeaderAxis && !localColumnHeaderAxis.isDisplayIndex()){
+ resizedHeaderPosition++;
+ }
// manipulate the index layer and as the variables are now fixed this part is common to both the inverted and not inverted case
@@ -1011,6 +1016,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof ColumnResizeEvent) {
+
+ // Calculate the width of the index column and of the label column (depending to its position)
int newHeaderIndexWidth = rowHeaderLayerStack.getRowIndexDataLayer().getColumnWidthByPosition(0);
int newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(0);
int resizedHeaderPosition = getRangeStart(event);
@@ -1027,34 +1034,50 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
if (!getTable().isInvertAxis()) {
if (getTable().getLocalRowHeaderAxisConfiguration() != null) {
localRowHeaderAxis = getTable().getLocalRowHeaderAxisConfiguration();
- } else if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
- TableHeaderAxisConfiguration rowHeaderAxis;
- EStructuralFeature localHeaderFeature = null;
- rowHeaderAxis = getTable().getTableConfiguration().getRowHeaderAxisConfiguration();
- localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
- localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
-
- IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
- IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
- resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
+ } else{
+ // Calculate the modified header row position (-1 because the index is displayed)
+ newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(resizedHeaderPosition-1);
+ if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
+ TableHeaderAxisConfiguration rowHeaderAxis;
+ EStructuralFeature localHeaderFeature = null;
+ rowHeaderAxis = getTable().getTableConfiguration().getRowHeaderAxisConfiguration();
+ localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
+ localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+
+ IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
+ IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
+ resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
+ }
}
} else {
if (getTable().getLocalColumnHeaderAxisConfiguration() != null) {
localRowHeaderAxis = getTable().getLocalColumnHeaderAxisConfiguration();
- } else if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
- TableHeaderAxisConfiguration rowHeaderAxis;
- EStructuralFeature localHeaderFeature = null;
- rowHeaderAxis = getTable().getTableConfiguration().getColumnHeaderAxisConfiguration();
- localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
- localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
-
- IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
- IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
- resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
+ } else{
+ // Calculate the modified header row position (-1 because the index is displayed)
+ newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(resizedHeaderPosition-1);
+ if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
+ TableHeaderAxisConfiguration rowHeaderAxis;
+ EStructuralFeature localHeaderFeature = null;
+ rowHeaderAxis = getTable().getTableConfiguration().getColumnHeaderAxisConfiguration();
+ localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
+ localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+
+ IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
+ IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
+ resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
+ }
}
}
+
+ // If this index is not display, increment the resized header position to corresponding to the label
+ if(null != localRowHeaderAxis && !localRowHeaderAxis.isDisplayIndex()){
+ resizedHeaderPosition++;
+ }
+
+ // Recalculate the initial label width to compare with the correct one
+ newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(resizedHeaderPosition-1);
if (resizedHeaderPosition == 0 && localRowHeaderAxis != null) {
IntValueStyle valueIndex = (IntValueStyle) localRowHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.ROW_INDEX_WIDTH);
@@ -1089,6 +1112,27 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
}
}
+
+ if(resizedHeaderPosition > 1 && null != localRowHeaderAxis){
+ final StringBuilder nameStyle = new StringBuilder(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH);
+ nameStyle.append(resizedHeaderPosition);
+ nameStyle.append(NamedStyleConstants.ROW_LABEL_POSITION_SUFFIX_WIDTH);
+
+ IntValueStyle valueLabel = (IntValueStyle) localRowHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), nameStyle.toString());
+ if (valueLabel != null && valueLabel.getIntValue() != newHeaderLabelWidth) {
+ SetRequest resizeRowHeaderLabel = new SetRequest(tableDomain, valueLabel, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderLabelWidth);
+ SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(resizeRowHeaderLabel);
+ resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
+ } else if (valueLabel == null && newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
+ valueLabel = NattablestyleFactory.eINSTANCE.createIntValueStyle();
+ valueLabel.setIntValue(newHeaderLabelWidth);
+ valueLabel.setName(nameStyle.toString());
+
+ SetRequest initRowHeaderLabelSizeRequest = new SetRequest(tableDomain, localRowHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueLabel);
+ SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(initRowHeaderLabelSizeRequest);
+ resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
+ }
+ }
if (resizeRowHeaderCommand.canExecute() && !resizeRowHeaderCommand.isEmpty()) {
@@ -1456,6 +1500,25 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
} else {
tableRowLabelHeaderLayer.setColumnWidthByPosition(0, DefaultSizeUtils.getDefaultRowHeaderWidth());
}
+
+ // Manage the style for the header with index > 1
+ for(final Style style : rowHeader.getStyles()){
+ if(style instanceof IntValueStyle){
+ final String styleName = ((IntValueStyle) style).getName();
+ if(styleName.startsWith(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH)){
+ //Calculate the position contained in the name of the style
+ String styleNameWithoutPrefix = styleName.replace(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH, "");
+ String styleNameWithoutSuffix = styleNameWithoutPrefix.replace(NamedStyleConstants.ROW_LABEL_POSITION_SUFFIX_WIDTH, "");
+ // Remove 1 because the column position start at 0
+ int position = Integer.parseInt(styleNameWithoutSuffix)-1;
+
+ // Don't try to set a width of a position which not existing
+ if(position < tableRowLabelHeaderLayer.getColumnCount()){
+ tableRowLabelHeaderLayer.setColumnWidthByPosition(position, ((IntValueStyle)style).getIntValue());
+ }
+ }
+ }
+ }
}
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 e9d6459b90b..bb241b7c91f 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
@@ -1,88 +1,100 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.nattable.utils;
-
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StringValueStyle;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
-
-public class NamedStyleConstants {
-
- private NamedStyleConstants() {
- // to prevent instantiation
- }
-
- /**
- *
- * The following constants are used during the initialization and retrieval of the Axis and Header dimensions in the tables
- */
-
- public static final String ROW_INDEX_WIDTH = "rowIndexWidth"; //$NON-NLS-1$1
-
- public static final String ROW_LABEL_WIDTH = "rowLabelWidth"; //$NON-NLS-1$
-
- public static final String COLUMN_INDEX_HEIGHT = "columnIndexHeight"; //$NON-NLS-1$
-
- public static final String COLUMN_LABEL_HEIGHT = "columnLabelHeight"; //$NON-NLS-1$
-
- public static final String AXIS_WIDTH = "axisWidth"; //$NON-NLS-1$
-
- public static final String AXIS_HEIGHT = "axisHeight"; //$NON-NLS-1$
-
- /**
- *
- * The following constants are used during the initialization and retrieval of the merge options in the tables
- */
-
- // public static final String TABLEMERGE = "tableMerge"; //$NON-NLS-1$
-
- public static final String MERGE_ROWS = "mergeRows"; //$NON-NLS-1$
-
- public static final String MERGE_COLUMNS = "mergeColumns"; //$NON-NLS-1$
-
- public static final String MERGE_SELECTED_ROWS = "mergeSelectedRows"; //$NON-NLS-1$
-
- public static final String MERGE_SELECTED_COLUMNS = "mergeSelectedColumns"; //$NON-NLS-1$
-
- public static final String MERGE_IN_SELECTED_ROWS = "mergeInSelectedRows"; //$NON-NLS-1$
-
- public static final String MERGE_IN_SELECTED_COLUMNS = "mergeInSelectedColumns"; //$NON-NLS-1$
-
- // the merge of all the elements in the table is not yet supported
- // public static final String MERGE_TABLE = "mergeTable"; //$NON-NLS-1$
-
-
- public static final String HIDDEN_CATEGORY_FOR_DEPTH = "hiddenCategoriesByDepth"; //$NON-NLS-1$
-
- /**
- * key used to save a filter configuration id state when the system use the default filter provided by the configuration
- * It is only used as name for a {@link StringValueStyle}
- */
- public static final String FILTER_SYSTEM_ID = "filterId"; //$NON-NLS-1$
-
- /**
- * key used to save filter state (the value typed by the user to filter the rows)
- * This key used as name for a {@link Style} without more precision
- */
- public static final String FILTER_VALUE_TO_MATCH = "filterValueToMatch"; //$NON-NLS-1$
-
- /**
- * 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
- *
- *
- */
- public static final String FILTER_FORCED_BY_USER_ID = "filterForcedByUserId"; //$NON-NLS-1$
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StringValueStyle;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
+
+public class NamedStyleConstants {
+
+ private NamedStyleConstants() {
+ // to prevent instantiation
+ }
+
+ /**
+ *
+ * The following constants are used during the initialization and retrieval of the Axis and Header dimensions in the tables
+ */
+
+ public static final String ROW_INDEX_WIDTH = "rowIndexWidth"; //$NON-NLS-1$1
+
+ public static final String ROW_LABEL_WIDTH = "rowLabelWidth"; //$NON-NLS-1$
+
+ /**
+ * The prefix of the name style to calculate the width of each row header.
+ * This prefix is followed by the position of the column to edit width.
+ */
+ public static final String ROW_LABEL_POSITION_PREFIX_WIDTH = "rowPosition"; //$NON-NLS-1$
+
+ /**
+ * The suffix of the name style to calculate the width of each row header
+ */
+ public static final String ROW_LABEL_POSITION_SUFFIX_WIDTH = "LabelWidth"; //$NON-NLS-1$
+
+
+ public static final String COLUMN_INDEX_HEIGHT = "columnIndexHeight"; //$NON-NLS-1$
+
+ public static final String COLUMN_LABEL_HEIGHT = "columnLabelHeight"; //$NON-NLS-1$
+
+ public static final String AXIS_WIDTH = "axisWidth"; //$NON-NLS-1$
+
+ public static final String AXIS_HEIGHT = "axisHeight"; //$NON-NLS-1$
+
+ /**
+ *
+ * The following constants are used during the initialization and retrieval of the merge options in the tables
+ */
+
+ // public static final String TABLEMERGE = "tableMerge"; //$NON-NLS-1$
+
+ public static final String MERGE_ROWS = "mergeRows"; //$NON-NLS-1$
+
+ public static final String MERGE_COLUMNS = "mergeColumns"; //$NON-NLS-1$
+
+ public static final String MERGE_SELECTED_ROWS = "mergeSelectedRows"; //$NON-NLS-1$
+
+ public static final String MERGE_SELECTED_COLUMNS = "mergeSelectedColumns"; //$NON-NLS-1$
+
+ public static final String MERGE_IN_SELECTED_ROWS = "mergeInSelectedRows"; //$NON-NLS-1$
+
+ public static final String MERGE_IN_SELECTED_COLUMNS = "mergeInSelectedColumns"; //$NON-NLS-1$
+
+ // the merge of all the elements in the table is not yet supported
+ // public static final String MERGE_TABLE = "mergeTable"; //$NON-NLS-1$
+
+
+ public static final String HIDDEN_CATEGORY_FOR_DEPTH = "hiddenCategoriesByDepth"; //$NON-NLS-1$
+
+ /**
+ * key used to save a filter configuration id state when the system use the default filter provided by the configuration
+ * It is only used as name for a {@link StringValueStyle}
+ */
+ public static final String FILTER_SYSTEM_ID = "filterId"; //$NON-NLS-1$
+
+ /**
+ * key used to save filter state (the value typed by the user to filter the rows)
+ * This key used as name for a {@link Style} without more precision
+ */
+ public static final String FILTER_VALUE_TO_MATCH = "filterValueToMatch"; //$NON-NLS-1$
+
+ /**
+ * 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
+ *
+ *
+ */
+ public static final String FILTER_FORCED_BY_USER_ID = "filterForcedByUserId"; //$NON-NLS-1$
+
+}

Back to the top