diff options
author | Vincent Lorenzo | 2020-04-29 13:56:47 +0000 |
---|---|---|
committer | Patrick Tessier | 2020-05-11 08:42:03 +0000 |
commit | 18768fb206d41d1f0d9c512f2c696e0ec18c1029 (patch) | |
tree | c798f89541f813f7eddef29badb435c345a96269 | |
parent | 51056dc1e2e9ef239d742d97a4be487cbeb76893 (diff) | |
download | org.eclipse.papyrus-18768fb206d41d1f0d9c512f2c696e0ec18c1029.tar.gz org.eclipse.papyrus-18768fb206d41d1f0d9c512f2c696e0ec18c1029.tar.xz org.eclipse.papyrus-18768fb206d41d1f0d9c512f2c696e0ec18c1029.zip |
Bug 562646: [Table][Performance] Poor performances when using/changing row filters
Change-Id: I3870c34af01ba5f4a0a1d895d72126927381ac6f
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
2 files changed, 57 insertions, 29 deletions
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 4339aaae6c9..86def26d544 100644 --- 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 @@ -14,7 +14,7 @@ * Nicolas Boulay (Esterel Technologies SAS) - Bug 497467 * Sebastien Bordes (Esterel Technologies SAS) - Bug 497738 * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 526146, 515737, 516314 - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 559973, 560318, 562619 + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 559973, 560318, 562619, 562646 *****************************************************************************/ package org.eclipse.papyrus.infra.nattable.manager.table; @@ -89,9 +89,6 @@ import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory; import org.eclipse.papyrus.infra.nattable.messages.Messages; import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EStructuralFeatureAxis; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.FeatureIdAxis; import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis; import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration; import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation; @@ -108,6 +105,8 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.I 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.NamedStyle; +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; @@ -1993,6 +1992,32 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen @Override public void run() { if (null != natTable && !natTable.isDisposed()) { + final Object notifier = notification.getNotifier(); + final Object feature = notification.getFeature(); + final Object newValue = notification.getNewValue(); + final Object oldValue = notification.getOldValue(); + final int type = notification.getEventType(); + + if (notifier instanceof IAxis && notification.getFeature() == NattablestylePackage.eINSTANCE.getStyledElement_Styles()) { + // the change is on a style of an IAxis + final String styleName; + if (newValue instanceof NamedStyle) { + styleName = ((NamedStyle) newValue).getName(); + } else if (oldValue instanceof NamedStyle) { + styleName = ((NamedStyle) oldValue).getName(); + } else { + styleName = null; + } + + // we are working with a filter + if (NamedStyleConstants.FILTER_SYSTEM_ID.equals(styleName) + || NamedStyleConstants.FILTER_VALUE_TO_MATCH.equals(styleName)) { + // nothing to do + return; + } + + } + // already created booleanValues and intValues if (notification.getNotifier() instanceof BooleanValueStyle) { // as the filter already prevented any nonBooleanValueStyle, and therefore any non EObject, it can be cast without verification @@ -2067,9 +2092,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen .or(NotificationFilter.createEventTypeFilter(Notification.REMOVE))) .and((NotificationFilter.createNotifierTypeFilter(BooleanValueStyle.class)) .or(NotificationFilter.createNotifierTypeFilter(IntValueStyle.class)) - .or(NotificationFilter.createNotifierTypeFilter(EObjectAxis.class)) - .or(NotificationFilter.createNotifierTypeFilter(FeatureIdAxis.class)) - .or(NotificationFilter.createNotifierTypeFilter(EStructuralFeatureAxis.class)) + .or(NotificationFilter.createNotifierTypeFilter(IAxis.class)) .or(NotificationFilter.createNotifierTypeFilter(LocalTableHeaderAxisConfiguration.class)) .or(NotificationFilter.createNotifierTypeFilter(Table.class))); // return NotificationFilter.createNotifierTypeFilter(EObject.class); diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/sort/PapyrusGlazedListsSortModel.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/sort/PapyrusGlazedListsSortModel.java index a94119d8c89..b23c588038e 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/sort/PapyrusGlazedListsSortModel.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/sort/PapyrusGlazedListsSortModel.java @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Original authors and others. + * Copyright (c) 2012, 2013, 2020 Original authors and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Original authors and others - initial API and implementation + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562646 ******************************************************************************/ package org.eclipse.papyrus.infra.nattable.sort; @@ -32,12 +33,12 @@ import ca.odell.glazedlists.SortedList; /** - * + * * @author Vincent Lorenzo * This class provides the sort model for an axis */ public class PapyrusGlazedListsSortModel extends AbstractGlazedListSortModel { - + /** * the column accessor */ @@ -73,33 +74,32 @@ public class PapyrusGlazedListsSortModel extends AbstractGlazedListSortModel { } - + protected PapyrusNatColumnTableFormat<Object> f; protected NatTableComparatorChooser<Object> getComparatorChooser() { if (comparatorChooser == null) { - f = new PapyrusNatColumnTableFormat<Object>(columnAccessor, getTableManager(), columnHeaderDataLayer); - comparatorChooser = - new PapyrusNatTableComparatorChooser(sortedList, f) { - - /** - * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#createSortingState() - * - * @return - */ - @Override - protected org.eclipse.papyrus.infra.nattable.glazedlists.copy.SortingState createSortingState() { - return new PapyrusSortingState(this, getTableManager()); - } - }; + f = new PapyrusNatColumnTableFormat<>(columnAccessor, getTableManager(), columnHeaderDataLayer); + comparatorChooser = new PapyrusNatTableComparatorChooser(sortedList, f) { + + /** + * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#createSortingState() + * + * @return + */ + @Override + protected org.eclipse.papyrus.infra.nattable.glazedlists.copy.SortingState createSortingState() { + return new PapyrusSortingState(this, getTableManager()); + } + }; } return comparatorChooser; } protected IConfigRegistry getConfigRegistry() { - NatTable nat = (NatTable) getTableManager().getAdapter(NatTable.class); + NatTable nat = getTableManager().getAdapter(NatTable.class); return nat.getConfigRegistry(); } @@ -142,6 +142,11 @@ public class PapyrusGlazedListsSortModel extends AbstractGlazedListSortModel { public void handleLayerEvent(ILayerEvent event) { if (event instanceof StructuralRefreshEvent && ((StructuralRefreshEvent) event).isHorizontalStructureChanged()) { String test = getComparatorChooser().toString(); + if (test.contains("-")) { //$NON-NLS-1$ + // avoid exception moving column where a filter is applied + // the - sign is for negative column index... + return; + } this.comparatorChooser = null; getComparatorChooser().fromString(test); } @@ -165,7 +170,7 @@ public class PapyrusGlazedListsSortModel extends AbstractGlazedListSortModel { */ // @Override public void updateSort() { - + } @@ -177,7 +182,7 @@ public class PapyrusGlazedListsSortModel extends AbstractGlazedListSortModel { */ @Override public Comparator<?> getColumnComparator(int columnIndex) { - + return null; } } |