Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanh Liem PHAN2017-11-22 14:37:02 +0000
committervincent lorenzo2017-12-13 09:26:29 +0000
commitf6a57394b636e9b6bc34eb249f89b1120aeb4a43 (patch)
treeab2b407af90d73fb2eb6e67900fe6b2aa62be77c /plugins/infra
parent7fb9f19190aa37552eb00c26eaa5d9042e192bfc (diff)
downloadorg.eclipse.papyrus-f6a57394b636e9b6bc34eb249f89b1120aeb4a43.tar.gz
org.eclipse.papyrus-f6a57394b636e9b6bc34eb249f89b1120aeb4a43.tar.xz
org.eclipse.papyrus-f6a57394b636e9b6bc34eb249f89b1120aeb4a43.zip
Bug 527496 - [Table][TreeTable] Auto Resize cells heights make reappears
hidden categories https://bugs.eclipse.org/bugs/show_bug.cgi?id=527496 - Initialize wraptext and auto resize named style to true to enable - Delete wraptext and auto resize NS to disable Change-Id: Idb8cd98806a18829c55f5f8a2dc0ce4d53cf4f2f Signed-off-by: Thanh Liem PHAN <thanhliem.phan@all4tec.net>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetAutoResizeCellHeightHandler.java17
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetWrapTextHandler.java24
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NamedStyleConstants.java14
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java17
4 files changed, 43 insertions, 29 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetAutoResizeCellHeightHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetAutoResizeCellHeightHandler.java
index 964257ac004..b97507dea5f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetAutoResizeCellHeightHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetAutoResizeCellHeightHandler.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220
+ * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 527496
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -41,12 +41,17 @@ public class SetAutoResizeCellHeightHandler extends AbstractTableHandler {
// If the auto resize value exists
if (null != autoResizeValue) {
- // Inverse the auto resize cell boolean value and save it to the table
- StyleUtils.setBooleanNamedStyle(editingDomain, table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT, !autoResizeValue.isBooleanValue());
-
+ // If auto resize is currently enabled
+ if (autoResizeValue.isBooleanValue()) {
+ // Delete the auto resize cell boolean named style to disable it
+ StyleUtils.deleteBooleanNamedStyle(editingDomain, table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT);
+ } else {
+ // Otherwise, enable it
+ StyleUtils.setBooleanNamedStyle(editingDomain, table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT, NamedStyleConstants.ENABLE_AUTO_RESIZE_CELL_HEIGHT);
+ }
} else {
- // Otherwise, initialise the auto resize cell height named value in the disable mode by default
- StyleUtils.initBooleanNamedStyle(editingDomain, table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT, false);
+ // Otherwise, initialise the auto resize cell height named value to true to enable it
+ StyleUtils.initBooleanNamedStyle(editingDomain, table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT, NamedStyleConstants.ENABLE_AUTO_RESIZE_CELL_HEIGHT);
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetWrapTextHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetWrapTextHandler.java
index 98440aac517..9913840b400 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetWrapTextHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SetWrapTextHandler.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220
+ * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 527496
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -43,17 +43,15 @@ public class SetWrapTextHandler extends AbstractTableHandler {
// If the wrap text value exists
if (null != wrapTextValue) {
- boolean oldWrapTextValue = wrapTextValue.isBooleanValue();
+ // If wrap text is currently enabled
+ if (wrapTextValue.isBooleanValue()) {
- // Inverse the wrap text boolean value and save it to the table
- StyleUtils.setBooleanNamedStyle(editingDomain, table, NamedStyleConstants.WRAP_TEXT, !oldWrapTextValue);
-
- // If wrap text value is changing from enable to disable and if the set auto resize cell height is currently enabled,
- // the row's height must be reset to the default value
- if (oldWrapTextValue) {
// Get the auto resize cell height named style from the table
BooleanValueStyle autoResizeValue = (BooleanValueStyle) table.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT);
+ // As wrap text value is changing from enable to disable, if the set auto resize cell height is currently enabled,
+ // the row's height must be reset to the default value
+
// NB: Rows resizing must be done in NattableModelManager after the cell editors are reconfigured
// So, an auto resize rows config attribute flag is used here, which allows the rows resizing to be done later
if (null != autoResizeValue && autoResizeValue.isBooleanValue()) {
@@ -64,10 +62,16 @@ public class SetWrapTextHandler extends AbstractTableHandler {
natTable.getConfigRegistry().registerConfigAttribute(NattableConfigAttributes.REINITIALISE_ROW_HEIGHT, true);
}
}
+
+ // Now, delete the wraptext named style to disable it
+ StyleUtils.deleteBooleanNamedStyle(editingDomain, table, NamedStyleConstants.WRAP_TEXT);
+ } else {
+ // Otherwise, enable it
+ StyleUtils.setBooleanNamedStyle(editingDomain, table, NamedStyleConstants.WRAP_TEXT, NamedStyleConstants.ENABLE_WRAP_TEXT);
}
} else {
- // Otherwise, initialise the wrap text named value in the disable mode by default
- StyleUtils.initBooleanNamedStyle(editingDomain, table, NamedStyleConstants.WRAP_TEXT, false);
+ // Otherwise, initialise the wrap text named value to true to enable it
+ StyleUtils.initBooleanNamedStyle(editingDomain, table, NamedStyleConstants.WRAP_TEXT, NamedStyleConstants.ENABLE_WRAP_TEXT);
}
}
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 e21cf3abe80..200d1c73b97 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
@@ -147,6 +147,13 @@ public class NamedStyleConstants {
public static final String WRAP_TEXT = "wrapText"; //$NON-NLS-1$
/**
+ * A default value used to enable the wraptext function in the NatTable.
+ * It is enabled by default.
+ * @since 5.0
+ */
+ public static final boolean ENABLE_WRAP_TEXT = true;
+
+ /**
* A {@link BooleanValueStyle} used to enable auto-resize cell height in the NatTable.
*
* @since 3.0
@@ -154,6 +161,13 @@ public class NamedStyleConstants {
public static final String AUTO_RESIZE_CELL_HEIGHT = "autoResizeCellHeight"; //$NON-NLS-1$
/**
+ * A default value used to enable the auto resize cell height function in the NatTable.
+ * It is enabled by default.
+ * @since 5.0
+ */
+ public static final boolean ENABLE_AUTO_RESIZE_CELL_HEIGHT = true;
+
+ /**
* A {@link BooleanValueStyle} used to display list on separated rows in the NatTable.
*
* @since 4.0
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
index 6105c81a0d5..9b1ee420b24 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StyleUtils.java
@@ -8,17 +8,17 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 515737
+ * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 515737, 527496
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.utils;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
@@ -29,7 +29,6 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntListVa
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NamedStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestyleFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StyledElement;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
@@ -253,12 +252,8 @@ public class StyleUtils {
namedStyle.setName(namedStyleString);
namedStyle.setBooleanValue(defaultValue);
- // Add the new boolean style
- List<Style> styleList = new ArrayList<Style>(styledElement.getStyles());
- styleList.add(namedStyle);
-
IElementEditService editService = ElementEditServiceUtils.getCommandProvider(styledElement);
- SetRequest request = new SetRequest(editingDomain, styledElement, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), styleList);
+ SetRequest request = new SetRequest(editingDomain, styledElement, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), namedStyle);
if (editService.canEdit(request)) {
Command command = GMFtoEMFCommandWrapper.wrap(editService.getEditCommand(request));
editingDomain.getCommandStack().execute(command);
@@ -287,12 +282,8 @@ public class StyleUtils {
// If it does exist, remove it, otherwise do nothing
if (null != namedStyle) {
- // Delete the boolean style
- List<Style> styleList = new ArrayList<Style>(styledElement.getStyles());
- styleList.remove(namedStyle);
-
IElementEditService editService = ElementEditServiceUtils.getCommandProvider(styledElement);
- SetRequest request = new SetRequest(editingDomain, styledElement, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), styleList);
+ DestroyElementRequest request = new DestroyElementRequest(editingDomain, namedStyle, false);
if (editService.canEdit(request)) {
Command command = GMFtoEMFCommandWrapper.wrap(editService.getEditCommand(request));
editingDomain.getCommandStack().execute(command);

Back to the top