mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Support for multiple selections. Factored into a ProblemVisualizer package.
This commit is contained in:
parent
b00e6396b8
commit
57ef7fb851
4 changed files with 39 additions and 24 deletions
|
@ -4,8 +4,8 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.visualizer.ui.visualizer">
|
point="org.eclipse.cdt.visualizer.ui.visualizer">
|
||||||
<visualizer
|
<visualizer
|
||||||
class="org.eclipse.cdt.visualizer.examples.ProblemVisualizer"
|
class="org.eclipse.cdt.visualizer.examples.ProblemVisualizer.ProblemVisualizer"
|
||||||
id="org.eclipse.cdt.visualizer.examples.counterVisualizer">
|
id="org.eclipse.cdt.visualizer.examples.ProblemVisualizer">
|
||||||
</visualizer>
|
</visualizer>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Marc Khouzam (Ericsson) - initial API and implementation
|
* Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.visualizer.examples;
|
package org.eclipse.cdt.visualizer.examples.ProblemVisualizer;
|
||||||
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Marc Khouzam (Ericsson) - initial API and implementation
|
# Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
ProblemCountVisualizer_Name=ProblemCounter
|
ProblemCountVisualizer_Name=ProblemCounter
|
||||||
ProblemCountVisualizer_DisplayName=Problem Count
|
ProblemCountVisualizer_DisplayName=Problem Count
|
|
@ -8,7 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Marc Khouzam (Ericsson) - initial API and implementation
|
* Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.visualizer.examples;
|
package org.eclipse.cdt.visualizer.examples.ProblemVisualizer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
|
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
|
||||||
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
|
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
|
||||||
|
@ -177,17 +179,6 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int handlesSelection(ISelection selection) {
|
|
||||||
Object sel = SelectionUtils.getSelectedObject(selection);
|
|
||||||
|
|
||||||
if (sel instanceof IResource) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visualizerDeselected() {
|
public void visualizerDeselected() {
|
||||||
}
|
}
|
||||||
|
@ -257,14 +248,19 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the count of problem markers for each severity for the
|
* Clear the marker count array.
|
||||||
* specified resource.
|
|
||||||
*/
|
*/
|
||||||
private void setMarkerCount(IResource resource) {
|
private void clearMarkerCount() {
|
||||||
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
|
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
|
||||||
m_markerCount[IMarker.SEVERITY_WARNING] = 0;
|
m_markerCount[IMarker.SEVERITY_WARNING] = 0;
|
||||||
m_markerCount[IMarker.SEVERITY_INFO] = 0;
|
m_markerCount[IMarker.SEVERITY_INFO] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the count of problem markers for each severity for the
|
||||||
|
* specified resource.
|
||||||
|
*/
|
||||||
|
private void addToMarkerCount(IResource resource) {
|
||||||
IMarker[] problems = null;
|
IMarker[] problems = null;
|
||||||
try {
|
try {
|
||||||
problems = resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
|
problems = resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
|
||||||
|
@ -305,12 +301,32 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
m_canvas.redraw();
|
m_canvas.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int handlesSelection(ISelection selection) {
|
||||||
|
List<Object> selections = SelectionUtils.getSelectedObjects(selection);
|
||||||
|
|
||||||
|
// As long as we support at least one element of the selection
|
||||||
|
// that is good enough
|
||||||
|
for (Object sel : selections) {
|
||||||
|
if (sel instanceof IResource) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void workbenchSelectionChanged(ISelection selection) {
|
public void workbenchSelectionChanged(ISelection selection) {
|
||||||
Object sel = SelectionUtils.getSelectedObject(selection);
|
clearMarkerCount();
|
||||||
|
|
||||||
|
List<Object> selections = SelectionUtils.getSelectedObjects(selection);
|
||||||
|
|
||||||
|
for (Object sel : selections) {
|
||||||
if (sel instanceof IResource) {
|
if (sel instanceof IResource) {
|
||||||
// Update the data
|
// Update the data
|
||||||
setMarkerCount((IResource)sel);
|
addToMarkerCount((IResource)sel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
Loading…
Add table
Reference in a new issue