Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a8d4ed106e16c3e929e6794a8e6ac6867ebc0394 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*****************************************************************************
 * Copyright (c) 2013 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.properties.constraints;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.constraints.constraints.JavaQuery;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.FeatureLabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ObjectLabelProviderConfiguration;
import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtils;

/**
 * Constraint to know if the table has an object row label configuration
 *
 * @author vl222926
 *
 */
public class HasRowObjectLabelConfigurationConstraint implements JavaQuery {

	/**
	 *
	 * @see org.eclipse.papyrus.infra.constraints.constraints.JavaQuery#match(java.lang.Object)
	 *
	 * @param selection
	 * @return
	 */
	@Override
	public boolean match(Object selection) {
		final EObject table = EMFHelper.getEObject(selection);
		final ObjectLabelProviderConfiguration objectConf = LabelConfigurationManagementUtils.getUsedRowObjectLabelConfiguration((Table) table);
		final FeatureLabelProviderConfiguration featureConf = LabelConfigurationManagementUtils.getUsedRowFeatureLabelConfiguration((Table) table);
		return objectConf != null && featureConf == null;
	}

}

Back to the top