blob: 424facc1b677f9cbca1a0d64f53d011481262beb (
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
|
/*****************************************************************************
* Copyright (c) 2010, 2014 CEA LIST and others.
*
* 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
* Christian W. Damus (CEA) - bug 417409
*
*****************************************************************************/
package org.eclipse.papyrus.views.properties.runtime;
import java.util.Collection;
import java.util.Set;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
import org.eclipse.papyrus.infra.constraints.runtime.DefaultConstraintEngine;
import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.View;
/**
* The implementation for ViewConstraintEngine
*
* @author Camille Letavernier
*/
public class ViewConstraintEngineImpl extends DefaultConstraintEngine<View> implements ViewConstraintEngine {
public ViewConstraintEngineImpl() {
super(View.class);
}
@Override
public synchronized void refresh() {
constraints.clear();
Collection<Context> contexts = ConfigurationManager.getInstance().getEnabledContexts();
for (Context context : contexts) {
addContext(context);
}
fireConstraintsChanged();
}
@Override
public void addContext(final Context context) {
for (View view : context.getViews()) {
for (ConstraintDescriptor descriptor : view.getConstraints()) {
addConstraint(descriptor);
}
}
}
@Override
public Set<View> getViews(final ISelection forSelection) {
return getDisplayUnits(forSelection);
}
}
|