Java Code Examples for org.eclipse.gmf.runtime.notation.View#eResource()

The following examples show how to use org.eclipse.gmf.runtime.notation.View#eResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidateAction.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private static void validate(DiagramEditPart diagramEditPart, View view) {
	IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null;
	if (target != null) {
		CrossflowMarkerNavigationProvider.deleteMarkers(target);
	}
	Diagnostic diagnostic = runEMFValidator(view);
	createMarkers(target, diagnostic, diagramEditPart);
	IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance()
			.newValidator(EvaluationMode.BATCH);
	validator.setIncludeLiveConstraints(true);
	if (view.isSetElement() && view.getElement() != null) {
		IStatus status = validator.validate(view.getElement());
		createMarkers(target, status, diagramEditPart);
	}
}
 
Example 2
Source File: AbstractPriorityDecorationProvider.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void refresh() {
	removeDecoration();
	boolean showLabels = DiagramActivator.getDefault().getPreferenceStore()
			.getBoolean(StatechartPreferenceConstants.PREF_PRIORITY_LABELS);
	if (!showLabels)
		return;
	View view = (View) getDecoratorTarget().getAdapter(View.class);
	if (view == null || view.eResource() == null) {
		return;
	}
	IGraphicalEditPart editPart = (IGraphicalEditPart) getDecoratorTarget().getAdapter(EditPart.class);
	if (editPart == null || editPart.getViewer() == null) {
		return;
	}
	if (needsDecoration(editPart))
		createDecorators(editPart);
}
 
Example 3
Source File: AbstractMarkerBasedDecorationProvider.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void refresh() {
	removeDecoration();
	View view = (View) getDecoratorTarget().getAdapter(View.class);
	if (view == null || view.eResource() == null) {
		return;
	}
	EditPart editPart = (EditPart) getDecoratorTarget().getAdapter(EditPart.class);
	if (editPart == null || editPart.getViewer() == null) {
		return;
	}

	IResource resource = WorkspaceSynchronizer.getFile(view.eResource());
	if (resource == null || !resource.exists()) {
		return;
	}
	List<IMarker> markers = new ArrayList<IMarker>();
	try {
		markers.addAll(Arrays.asList(resource.findMarkers(getMarkerType(), true, IResource.DEPTH_INFINITE)));
	} catch (CoreException e) {
		e.printStackTrace();
	}
	if (markers == null || markers.size() == 0) {
		return;
	}
	createDecorators(view, markers);
}
 
Example 4
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private static void validate(DiagramEditPart diagramEditPart, View view) {
	IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null;
	if (target != null) {
		ProcessMarkerNavigationProvider.deleteMarkers(target);
	}
	Diagnostic diagnostic = runEMFValidator(view);
	createMarkers(target, diagnostic, diagramEditPart);
	IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance()
			.newValidator(EvaluationMode.BATCH);
	validator.setIncludeLiveConstraints(true);
	if (view.isSetElement() && view.getElement() != null) {
		IStatus status = validator.validate(view.getElement());
		createMarkers(target, status, diagramEditPart);
	}
}
 
Example 5
Source File: StatechartValidationDecorationProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private Optional<View> getTargetView() {
	View view = (View) getDecoratorTarget().getAdapter(View.class);
	if (view == null || view.eResource() == null) {
		return Optional.empty();
	}
	return Optional.of(view);
}
 
Example 6
Source File: BatchValidationOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void validate(final DiagramEditPart diagramEditPart, final View view, final IProgressMonitor monitor) {
    final IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null;
    final Diagnostic diagnostic = validationMarkerProvider.runEMFValidator(view);
    validationMarkerProvider.createMarkers(target, diagnostic, diagramEditPart);
    final IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator(
            EvaluationMode.BATCH);
    validator.setIncludeLiveConstraints(true);
    if (view.isSetElement() && view.getElement() != null && view.getElement().eResource() != null) {
        final IStatus status = validator.validate(view.getElement(), monitor);
        validationMarkerProvider.createMarkers(target, status, diagramEditPart);
    }
}