Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-02-27 10:27:48 -0500
committerMarc Khouzam2012-02-29 11:07:20 -0500
commit820844d7c2c03d2ec3a64791554f602833eea6a2 (patch)
tree084de1244dc817cce698e2223877060be8bf0d16
parent511770363448e9c3fe9622852984ee9276d15332 (diff)
downloadorg.eclipse.cdt-820844d7c2c03d2ec3a64791554f602833eea6a2.tar.gz
org.eclipse.cdt-820844d7c2c03d2ec3a64791554f602833eea6a2.tar.xz
org.eclipse.cdt-820844d7c2c03d2ec3a64791554f602833eea6a2.zip
Add support for resizing of view.
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java50
1 files changed, 38 insertions, 12 deletions
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.java
index f1fb950133..659d8a51df 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.java
@@ -74,6 +74,16 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
}
+ private class ResizableGraphicCanvas extends GraphicCanvas {
+ public ResizableGraphicCanvas(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ public void resized(Rectangle bounds) {
+ ProblemVisualizer.this.refresh();
+ }
+ }
/** The canvas on which we'll draw our bars */
private GraphicCanvas m_canvas;
@@ -105,7 +115,7 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
@Override
public GraphicCanvas createCanvas(Composite parent) {
- m_canvas = new GraphicCanvas(parent);
+ m_canvas = new ResizableGraphicCanvas(parent);
return m_canvas;
}
@@ -116,6 +126,15 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
@Override
+ public void disposeCanvas()
+ {
+ if (m_canvas != null) {
+ m_canvas.dispose();
+ m_canvas = null;
+ }
+ }
+
+ @Override
public int handlesSelection(ISelection selection) {
Object sel = SelectionUtils.getSelectedObject(selection);
@@ -133,7 +152,7 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
@Override
public void visualizerSelected() {
}
-
+
/**
* Actually create the graphics bars for the different severities.
* @param outline Should the bars be created, or the bar outline
@@ -219,8 +238,10 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
}
- @Override
- public void workbenchSelectionChanged(ISelection selection) {
+ /**
+ * Refresh the visualizer display based on the existing data.
+ */
+ public void refresh() {
m_canvas.clear();
// First create the outline bars
@@ -229,19 +250,24 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
m_canvas.add(bar);
}
+ // Now, create the inside bars
+ bars = getBars(false);
+ for (BarGraphicObject bar : bars) {
+ m_canvas.add(bar);
+ }
+
+ m_canvas.redraw();
+ }
+
+ @Override
+ public void workbenchSelectionChanged(ISelection selection) {
Object sel = SelectionUtils.getSelectedObject(selection);
if (sel instanceof IResource) {
- // Now, create the inside bars
-
+ // Update the data
setMarkerCount((IResource)sel);
-
- bars = getBars(false);
- for (BarGraphicObject bar : bars) {
- m_canvas.add(bar);
- }
}
- m_canvas.redraw();
+ refresh();
}
public SelectionManager getSelectionManager() {

Back to the top