blob: b45654d5e0ff60d99f789feec51263e03a2adebc (
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
|
/*****************************************************************************
* Copyright (c) 2011 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:
*
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.constraint;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.gmf.runtime.notation.DescriptionStyle;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
//import org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecorator;
/**
* Constraint that test if selection can be decorated
*/
public class IsDecorableElementConstraint extends AbstractConstraint {
/**
* {@inheritDoc}
*/
public boolean match(Object selection) {
if(selection instanceof IAdaptable) {
View node = (View)((IAdaptable)selection).getAdapter(View.class);
if(node != null && !(node instanceof Diagram)) {
DescriptionStyle descStyle = (DescriptionStyle)node.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle());
if(descStyle != null) {
return true;
}
}
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
protected boolean equivalent(Constraint constraint) {
if(constraint == null) {
return false;
}
return constraint instanceof IsDecorableElementConstraint;
}
}
|