Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 139141
Collapse All | Expand All

(-)src/org/eclipse/wst/sse/ui/internal/StructuredMarkerAnnotation.java (-64 / +38 lines)
Lines 15-23 Link Here
15
15
16
import org.eclipse.core.resources.IMarker;
16
import org.eclipse.core.resources.IMarker;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.model.IBreakpoint;
19
import org.eclipse.debug.ui.DebugUITools;
20
import org.eclipse.debug.ui.IDebugModelPresentation;
21
import org.eclipse.jface.resource.JFaceResources;
18
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jface.text.source.IAnnotationPresentation;
19
import org.eclipse.jface.text.source.IAnnotationPresentation;
23
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWT;
Lines 26-32 Link Here
26
import org.eclipse.ui.ISharedImages;
23
import org.eclipse.ui.ISharedImages;
27
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.texteditor.MarkerAnnotation;
25
import org.eclipse.ui.texteditor.MarkerAnnotation;
29
import org.eclipse.ui.texteditor.MarkerUtilities;
30
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
26
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
31
27
32
28
Lines 37-151 Link Here
37
 * in the OverviewRuler
33
 * in the OverviewRuler
38
 */
34
 */
39
public class StructuredMarkerAnnotation extends MarkerAnnotation implements IAnnotationPresentation {
35
public class StructuredMarkerAnnotation extends MarkerAnnotation implements IAnnotationPresentation {
40
36
	// controls if icon should be painted gray
41
	private IDebugModelPresentation fPresentation;
42
	//controls if icon should be painted gray
43
	private boolean fIsGrayed = false;
37
	private boolean fIsGrayed = false;
44
	String fAnnotationType = null;
38
	String fAnnotationType = null;
45
39
46
	StructuredMarkerAnnotation(IMarker marker) {
40
	StructuredMarkerAnnotation(IMarker marker) {
47
		super(marker);
41
		super(marker);
48
		initAnnotationType();
49
	}
42
	}
50
	
43
51
	public final String getAnnotationType() {
44
	public final String getAnnotationType() {
52
		return fAnnotationType;
45
		return fAnnotationType;
53
	}
46
	}
54
	
47
55
	/**
48
	/**
56
	 * Eventually will have to use IAnnotationPresentation & IAnnotationExtension
49
	 * Eventually will have to use IAnnotationPresentation &
50
	 * IAnnotationExtension
51
	 * 
57
	 * @see org.eclipse.ui.texteditor.MarkerAnnotation#getImage(org.eclipse.swt.widgets.Display)
52
	 * @see org.eclipse.ui.texteditor.MarkerAnnotation#getImage(org.eclipse.swt.widgets.Display)
58
	 */
53
	 */
59
	protected Image getImage(Display display) {
54
	protected Image getImage(Display display) {
60
		Image image = null;
55
		Image image = null;
61
		if (fAnnotationType == TemporaryAnnotation.ANNOT_BREAKPOINT) {
56
		if (fAnnotationType == TemporaryAnnotation.ANNOT_ERROR) {
62
			image = super.getImage(display);
63
			if (image == null) {
64
				IMarker marker = getMarker();
65
				if (marker != null && marker.exists()) {
66
					image = fPresentation.getImage(getMarker());
67
				}
68
			}
69
		}
70
		else if(fAnnotationType == TemporaryAnnotation.ANNOT_ERROR) {
71
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
57
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
72
		}
58
		}
73
		else if(fAnnotationType == TemporaryAnnotation.ANNOT_WARNING) {
59
		else if (fAnnotationType == TemporaryAnnotation.ANNOT_WARNING) {
74
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
60
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
75
		}
61
		}
76
		else if(fAnnotationType == TemporaryAnnotation.ANNOT_INFO) {
62
		else if (fAnnotationType == TemporaryAnnotation.ANNOT_INFO) {
77
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
63
			image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
78
		}
64
		}
79
			
65
80
		if(image != null && isGrayed())
66
		if (image != null && isGrayed())
81
			setImage(getGrayImage(display, image));
67
			setImage(getGrayImage(display, image));
82
		else 
68
		else
83
			setImage(image);
69
			setImage(image);
84
		
70
85
		return super.getImage(display);
71
		return super.getImage(display);
86
	}
72
	}
87
73
88
	private Image getGrayImage(Display display, Image image) {
74
	private Image getGrayImage(Display display, Image image) {
89
		if (image != null) {
75
		if (image != null) {
90
			String key= Integer.toString(image.hashCode());
76
			String key = Integer.toString(image.hashCode());
91
			// make sure we cache the gray image
77
			// make sure we cache the gray image
92
			Image grayImage = JFaceResources.getImageRegistry().get(key);
78
			Image grayImage = JFaceResources.getImageRegistry().get(key);
93
			if (grayImage == null) {
79
			if (grayImage == null) {
94
				grayImage= new Image(display, image, SWT.IMAGE_GRAY);
80
				grayImage = new Image(display, image, SWT.IMAGE_GRAY);
95
				JFaceResources.getImageRegistry().put(key, grayImage);
81
				JFaceResources.getImageRegistry().put(key, grayImage);
96
			}
82
			}
97
			image= grayImage;
83
			image = grayImage;
98
		}
84
		}
99
		return image;
85
		return image;
100
	}
86
	}
101
	
87
102
	public final boolean isGrayed() {
88
	public final boolean isGrayed() {
103
		return fIsGrayed;
89
		return fIsGrayed;
104
	}
90
	}
105
	
91
106
	public final void setGrayed(boolean grayed) {
92
	public final void setGrayed(boolean grayed) {
107
		fIsGrayed = grayed;
93
		fIsGrayed = grayed;
108
	}
94
	}
109
	
95
110
	/**
96
	/**
111
	 * Initializes the annotation's icon representation and its drawing layer
97
	 * Initializes the annotation's icon representation and its drawing layer
112
	 * based upon the properties of the underlying marker.
98
	 * based upon the properties of the underlying marker.
113
	 */
99
	 */
114
	protected void initAnnotationType() {
100
	protected void initAnnotationType() {
115
		
116
		IMarker marker = getMarker();
117
		if (MarkerUtilities.isMarkerType(marker, IBreakpoint.BREAKPOINT_MARKER)) {
118
119
			if (fPresentation == null)
120
				fPresentation = DebugUITools.newDebugModelPresentation();
121
101
122
			setImage(null); // see bug 32469
102
		IMarker marker = getMarker();
123
			setLayer(4);
103
		fAnnotationType = TemporaryAnnotation.ANNOT_UNKNOWN;
124
			//fImageType = BREAKPOINT_IMAGE;
104
		try {
125
			fAnnotationType = TemporaryAnnotation.ANNOT_BREAKPOINT;
105
			if (marker.isSubtypeOf(IMarker.PROBLEM)) {
126
106
				int severity = marker.getAttribute(IMarker.SEVERITY, -1);
127
		} else {
107
				switch (severity) {
128
			
108
					case IMarker.SEVERITY_ERROR :
129
			fAnnotationType = TemporaryAnnotation.ANNOT_UNKNOWN;
109
						fAnnotationType = TemporaryAnnotation.ANNOT_ERROR;
130
			try {
110
						break;
131
				if (marker.isSubtypeOf(IMarker.PROBLEM)) {
111
					case IMarker.SEVERITY_WARNING :
132
					int severity = marker.getAttribute(IMarker.SEVERITY, -1);
112
						fAnnotationType = TemporaryAnnotation.ANNOT_WARNING;
133
					switch (severity) {
113
						break;
134
						case IMarker.SEVERITY_ERROR :
114
					case IMarker.SEVERITY_INFO :
135
							fAnnotationType = TemporaryAnnotation.ANNOT_ERROR;
115
						fAnnotationType = TemporaryAnnotation.ANNOT_INFO;
136
							break;
116
						break;
137
						case IMarker.SEVERITY_WARNING :
138
							fAnnotationType = TemporaryAnnotation.ANNOT_WARNING;
139
							break;
140
						case IMarker.SEVERITY_INFO :
141
							fAnnotationType = TemporaryAnnotation.ANNOT_INFO;
142
							break;
143
					}
144
				}
117
				}
145
146
			} catch (CoreException e) {
147
				Logger.logException(e);
148
			}
118
			}
119
120
		}
121
		catch (CoreException e) {
122
			Logger.logException(e);
149
		}
123
		}
150
	}
124
	}
151
}
125
}
(-)src/org/eclipse/wst/sse/ui/internal/StructuredResourceMarkerAnnotationModel.java (-2 / +1 lines)
Lines 15-21 Link Here
15
import org.eclipse.core.resources.IMarker;
15
import org.eclipse.core.resources.IMarker;
16
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.model.IBreakpoint;
19
import org.eclipse.jface.text.Position;
18
import org.eclipse.jface.text.Position;
20
import org.eclipse.ui.texteditor.MarkerAnnotation;
19
import org.eclipse.ui.texteditor.MarkerAnnotation;
21
import org.eclipse.ui.texteditor.MarkerUtilities;
20
import org.eclipse.ui.texteditor.MarkerUtilities;
Lines 59-65 Link Here
59
		 * a special marker annotation for those markers. Otherwise, use
58
		 * a special marker annotation for those markers. Otherwise, use
60
		 * default.
59
		 * default.
61
		 */
60
		 */
62
		if (MarkerUtilities.isMarkerType(marker, IBreakpoint.BREAKPOINT_MARKER) || (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM))) {
61
		if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
63
			return new StructuredMarkerAnnotation(marker);
62
			return new StructuredMarkerAnnotation(marker);
64
		}
63
		}
65
		return super.createMarkerAnnotation(marker);
64
		return super.createMarkerAnnotation(marker);
(-)src/org/eclipse/wst/sse/ui/internal/reconcile/TemporaryAnnotation.java (-2 lines)
Lines 44-51 Link Here
44
	public final static String ANNOT_UNKNOWN = Annotation.TYPE_UNKNOWN;
44
	public final static String ANNOT_UNKNOWN = Annotation.TYPE_UNKNOWN;
45
	public final static String ANNOT_WARNING = "org.eclipse.wst.sse.ui.temp.warning"; //$NON-NLS-1$
45
	public final static String ANNOT_WARNING = "org.eclipse.wst.sse.ui.temp.warning"; //$NON-NLS-1$
46
46
47
	public final static String ANNOT_BREAKPOINT = "org.eclipse.wst.sse.ui.breakpoint"; //$NON-NLS-1$
48
    
49
    // copied from CompilationUnitDocumentProvider.ProblemAnnotation
47
    // copied from CompilationUnitDocumentProvider.ProblemAnnotation
50
    //XXX: To be fully correct these constants should be non-static
48
    //XXX: To be fully correct these constants should be non-static
51
49

Return to bug 139141