Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b1216ccbceb0c45406b4d813cda64ff965718d46 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*****************************************************************************
 * Copyright (c) 2010 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.infra.constraints.constraints;


/**
 * A constraint applying an EMF Query on a selection. The Query should return
 * a Boolean.
 *
 * @author Camille Letavernier
 */
public class EMFQueryConstraint extends AbstractConstraint {

	@Override
	protected boolean equivalent(Constraint constraint) {
		
		return false;
	}

	@Override
	protected boolean match(Object selection) {
		
		return false;
	}

	// private OCLModelQuery query;
	//
	// @Override
	// protected void setDescriptor(SimpleConstraint descriptor) {
	//		ConfigProperty property = getProperty("query"); //$NON-NLS-1$
	// if(property instanceof ReferenceProperty) {
	//			query = (OCLModelQuery)getReferenceValue("query"); //$NON-NLS-1$
	// } else {
	// String queryExpression = ((ValueProperty)property).getValue();
	// query = QueryFactory.eINSTANCE.createOCLModelQuery();
	// query.setQuery(queryExpression);
	// query.setReturnType(EcorePackage.eINSTANCE.getEBoolean());
	// query.getScope().add(EcorePackage.eINSTANCE.getEObject());
	// throw new UnsupportedOperationException();
	// }
	// }
	//
	// public boolean match(Object selection) {
	// if(query == null) {
	// return false;
	// }
	//
	// EObject selectedItem = EMFHelper.getEObject(selection);
	//
	// if(selectedItem != null) {
	// try {
	// ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
	// AbstractModelQuery abstractQuery = catalog.getModelQueryImpl(query);
	// ModelQueryResult result = abstractQuery.evaluate(selectedItem);
	// Object value = result.getValue();
	// return value == null ? false : (Boolean)value;
	// } catch (Exception ex) {
	// Activator.log.error(ex);
	// }
	//
	// }
	// return false;
	// }
	//
	// @Override
	// protected boolean equivalent(Constraint constraint) {
	// if(constraint != null && constraint instanceof EMFQueryConstraint) {
	// EMFQueryConstraint other = (EMFQueryConstraint)constraint;
	// return other.query.equals(query);
	// }
	// return false;
	// }

}

Back to the top