diff options
Diffstat (limited to 'plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java')
-rw-r--r-- | plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java index b2fd7bebbdc..c94a8b7aec2 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsTreeTableConstraint.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2015 CEA LIST and others. + * Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,15 +8,16 @@ * * Contributors: * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * Christian W. Damus - bug 485220 * *****************************************************************************/ package org.eclipse.papyrus.infra.nattable.properties.constraints; +import java.util.Collection; import java.util.Iterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint; import org.eclipse.papyrus.infra.constraints.constraints.Constraint; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; @@ -35,23 +36,23 @@ public class IsTreeTableConstraint extends AbstractConstraint { * each object of the selection. */ @Override - public boolean match(final IStructuredSelection selection) { + public boolean match(final Collection<?> selection) { boolean result = false; - + if (!selection.isEmpty()) { final int elementMultiplicity = display.getElementMultiplicity(); - + final int selectionSize = selection.size(); if (elementMultiplicity == 1) { if (selectionSize == 1) { - if (match(selection.getFirstElement())) { + if (match(selection.iterator().next())) { result = true; } } // Manage the multiple elements only if the selection is multiple too } else if ((elementMultiplicity == selectionSize) || (elementMultiplicity < 0 && selection.size() > 1)) { result = true; - + final Iterator<?> selectionIterator = selection.iterator(); while (selectionIterator.hasNext() && result) { final Object selectedItem = selectionIterator.next(); @@ -64,7 +65,7 @@ public class IsTreeTableConstraint extends AbstractConstraint { return result; } - + /** * {@inheritDoc} * |