/* | |
* | |
*/ | |
package comrel.diagram.providers; | |
import org.eclipse.emf.transaction.TransactionalEditingDomain; | |
import org.eclipse.gmf.runtime.notation.View; | |
import comrel.diagram.edit.parts.CompositeRefactoringEditPart; | |
import comrel.diagram.part.ComrelDiagramEditorPlugin; | |
import comrel.diagram.part.ComrelVisualIDRegistry; | |
/** | |
* @generated | |
*/ | |
public class ComrelValidationProvider { | |
/** | |
* @generated | |
*/ | |
private static boolean constraintsActive = false; | |
/** | |
* @generated | |
*/ | |
public static boolean shouldConstraintsBePrivate() { | |
return false; | |
} | |
/** | |
* @generated | |
*/ | |
public static void runWithConstraints( | |
TransactionalEditingDomain editingDomain, Runnable operation) { | |
final Runnable op = operation; | |
Runnable task = new Runnable() { | |
public void run() { | |
try { | |
constraintsActive = true; | |
op.run(); | |
} finally { | |
constraintsActive = false; | |
} | |
} | |
}; | |
if (editingDomain != null) { | |
try { | |
editingDomain.runExclusive(task); | |
} catch (Exception e) { | |
ComrelDiagramEditorPlugin.getInstance().logError( | |
"Validation failed", e); //$NON-NLS-1$ | |
} | |
} else { | |
task.run(); | |
} | |
} | |
/** | |
* @generated | |
*/ | |
static boolean isInDefaultEditorContext(Object object) { | |
if (shouldConstraintsBePrivate() && !constraintsActive) { | |
return false; | |
} | |
if (object instanceof View) { | |
return constraintsActive | |
&& CompositeRefactoringEditPart.MODEL_ID | |
.equals(ComrelVisualIDRegistry | |
.getModelID((View) object)); | |
} | |
return true; | |
} | |
} |