1 | /* |
2 | *Copyright 2007, IPD, SDQ, University of Karlsruhe |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.repository.providers; |
5 | |
6 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
7 | import org.eclipse.gmf.runtime.notation.View; |
8 | |
9 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.RepositoryEditPart; |
10 | import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelRepositoryDiagramEditorPlugin; |
11 | import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelVisualIDRegistry; |
12 | |
13 | /** |
14 | * @generated |
15 | */ |
16 | public class PalladioComponentModelValidationProvider { |
17 | /** |
18 | * @generated |
19 | */ |
20 | private static boolean constraintsActive = false; |
21 | |
22 | /** |
23 | * @generated |
24 | */ |
25 | public static boolean shouldConstraintsBePrivate() { |
26 | return false; |
27 | } |
28 | |
29 | /** |
30 | * @generated |
31 | */ |
32 | public static void runWithConstraints( |
33 | TransactionalEditingDomain editingDomain, Runnable operation) { |
34 | final Runnable op = operation; |
35 | Runnable task = new Runnable() { |
36 | public void run() { |
37 | try { |
38 | constraintsActive = true; |
39 | op.run(); |
40 | } finally { |
41 | constraintsActive = false; |
42 | } |
43 | } |
44 | }; |
45 | if (editingDomain != null) { |
46 | try { |
47 | editingDomain.runExclusive(task); |
48 | } catch (Exception e) { |
49 | PalladioComponentModelRepositoryDiagramEditorPlugin |
50 | .getInstance().logError("Validation failed", e); //$NON-NLS-1$ |
51 | } |
52 | } else { |
53 | task.run(); |
54 | } |
55 | } |
56 | |
57 | /** |
58 | * @generated |
59 | */ |
60 | static boolean isInDefaultEditorContext(Object object) { |
61 | if (shouldConstraintsBePrivate() && !constraintsActive) { |
62 | return false; |
63 | } |
64 | if (object instanceof View) { |
65 | return constraintsActive |
66 | && RepositoryEditPart.MODEL_ID |
67 | .equals(PalladioComponentModelVisualIDRegistry |
68 | .getModelID((View) object)); |
69 | } |
70 | return true; |
71 | } |
72 | |
73 | } //PalladioComponentModelValidationProvider |