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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*****************************************************************************
* Copyright (c) 2009 Atos Origin.
*
*
* 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:
* Atos Origin - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.providers;
import java.util.Arrays;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorUtil;
/**
* @generated
*/
public class UMLMarkerNavigationProvider extends AbstractModelMarkerNavigationProvider {
/**
* @generated
*/
public static final String MARKER_TYPE = UMLDiagramEditorPlugin.ID + ".diagnostic"; //$NON-NLS-1$
/**
* @generated
*/
@Override
protected void doGotoMarker(IMarker marker) {
String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
return;
}
DiagramEditor editor = (DiagramEditor) getEditor();
Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
if (targetView == null) {
return;
}
EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
if (targetEditPart != null) {
UMLDiagramEditorUtil.selectElementsInDiagram(
editor, Arrays.asList(new EditPart[] { targetEditPart }));
}
}
/**
* @generated
*/
public static void deleteMarkers(IResource resource) {
try {
resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO);
} catch (CoreException e) {
UMLDiagramEditorPlugin.getInstance().logError(
"Failed to delete validation markers", e); //$NON-NLS-1$
}
}
/**
* @generated
*/
public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) {
IMarker marker = null;
try {
marker = file.createMarker(MARKER_TYPE);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.LOCATION, location);
marker.setAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, elementId);
int markerSeverity = IMarker.SEVERITY_INFO;
if (statusSeverity == IStatus.WARNING) {
markerSeverity = IMarker.SEVERITY_WARNING;
} else if (statusSeverity == IStatus.ERROR ||
statusSeverity == IStatus.CANCEL) {
markerSeverity = IMarker.SEVERITY_ERROR;
}
marker.setAttribute(IMarker.SEVERITY, markerSeverity);
} catch (CoreException e) {
UMLDiagramEditorPlugin.getInstance().logError(
"Failed to create validation marker", e); //$NON-NLS-1$
}
return marker;
}
}
|