Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-02-28 15:13:15 -0500
committerMarc Khouzam2012-02-29 11:07:25 -0500
commit57ef7fb85105bbd1a2735dacd014a995e19e8f49 (patch)
treed2297cfd2269ebf120eeb2f9b4d10ed0154c9882 /visualizer
parentb00e6396b81bafa39ef5cae7ddc45a5dd4022adf (diff)
downloadorg.eclipse.cdt-57ef7fb85105bbd1a2735dacd014a995e19e8f49.tar.gz
org.eclipse.cdt-57ef7fb85105bbd1a2735dacd014a995e19e8f49.tar.xz
org.eclipse.cdt-57ef7fb85105bbd1a2735dacd014a995e19e8f49.zip
Support for multiple selections. Factored into a ProblemVisualizer package.
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml4
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.java (renamed from visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java)2
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.properties (renamed from visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties)1
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/ProblemVisualizer.java (renamed from visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java)56
4 files changed, 39 insertions, 24 deletions
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml b/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
index f4e51561dd..55d329cf0b 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
@@ -4,8 +4,8 @@
<extension
point="org.eclipse.cdt.visualizer.ui.visualizer">
<visualizer
- class="org.eclipse.cdt.visualizer.examples.ProblemVisualizer"
- id="org.eclipse.cdt.visualizer.examples.counterVisualizer">
+ class="org.eclipse.cdt.visualizer.examples.ProblemVisualizer.ProblemVisualizer"
+ id="org.eclipse.cdt.visualizer.examples.ProblemVisualizer">
</visualizer>
</extension>
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.java
index 34bd6eb80f..d4932dd748 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.java
@@ -8,7 +8,7 @@
* Contributors:
* 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;
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.properties
index e8ad66d2a4..0f4271ed21 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.properties
@@ -7,7 +7,6 @@
#
# Contributors:
# Marc Khouzam (Ericsson) - initial API and implementation
-###############################################################################
ProblemCountVisualizer_Name=ProblemCounter
ProblemCountVisualizer_DisplayName=Problem Count
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/ProblemVisualizer.java
index 91d2a4bdfe..47a2a69e6e 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/ProblemVisualizer.java
@@ -8,7 +8,9 @@
* Contributors:
* 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.GraphicCanvasVisualizer;
@@ -176,17 +178,6 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
m_canvas = null;
}
}
-
- @Override
- public int handlesSelection(ISelection selection) {
- Object sel = SelectionUtils.getSelectedObject(selection);
-
- if (sel instanceof IResource) {
- return 2;
- }
-
- return 0;
- }
@Override
public void visualizerDeselected() {
@@ -257,14 +248,19 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
/**
- * Get the count of problem markers for each severity for the
- * specified resource.
+ * Clear the marker count array.
*/
- private void setMarkerCount(IResource resource) {
+ private void clearMarkerCount() {
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
m_markerCount[IMarker.SEVERITY_WARNING] = 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;
try {
problems = resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
@@ -306,11 +302,31 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
@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
public void workbenchSelectionChanged(ISelection selection) {
- Object sel = SelectionUtils.getSelectedObject(selection);
- if (sel instanceof IResource) {
- // Update the data
- setMarkerCount((IResource)sel);
+ clearMarkerCount();
+
+ List<Object> selections = SelectionUtils.getSelectedObjects(selection);
+
+ for (Object sel : selections) {
+ if (sel instanceof IResource) {
+ // Update the data
+ addToMarkerCount((IResource)sel);
+ }
}
refresh();

Back to the top