Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-02-27 11:08:22 -0500
committerMarc Khouzam2012-02-29 11:07:22 -0500
commitb00e6396b81bafa39ef5cae7ddc45a5dd4022adf (patch)
tree7085847193429659d15e20c423dcd77c1bc9b61f /visualizer
parent820844d7c2c03d2ec3a64791554f602833eea6a2 (diff)
downloadorg.eclipse.cdt-b00e6396b81bafa39ef5cae7ddc45a5dd4022adf.tar.gz
org.eclipse.cdt-b00e6396b81bafa39ef5cae7ddc45a5dd4022adf.tar.xz
org.eclipse.cdt-b00e6396b81bafa39ef5cae7ddc45a5dd4022adf.zip
Add decorations
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java4
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties7
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java60
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java2
4 files changed, 63 insertions, 10 deletions
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/Messages.java
index 11bc82633c..34bd6eb80f 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/Messages.java
@@ -19,7 +19,9 @@ class Messages extends NLS {
public static String ProblemCountVisualizer_Name;
public static String ProblemCountVisualizer_DisplayName;
public static String ProblemCountVisualizer_Description;
-
+ public static String ProblemCountVisualizer_Errors;
+ public static String ProblemCountVisualizer_Warnings;
+ public static String ProblemCountVisualizer_Infos;
static {
// initialize resource bundle
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/Messages.properties
index 666395673c..e8ad66d2a4 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/Messages.properties
@@ -10,5 +10,8 @@
###############################################################################
ProblemCountVisualizer_Name=ProblemCounter
-ProblemCountVisualizer_DisplayName=Problem Count Visualizer
-ProblemCountVisualizer_Description=Visualizer displaying the count of errors/warnings/info \ No newline at end of file
+ProblemCountVisualizer_DisplayName=Problem Count
+ProblemCountVisualizer_Description=Visualizer displaying the count of errors/warnings/info
+ProblemCountVisualizer_Errors=Errors:
+ProblemCountVisualizer_Warnings=Warnings:
+ProblemCountVisualizer_Infos=Infos:
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 659d8a51df..91d2a4bdfe 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
@@ -14,6 +14,7 @@ import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
import org.eclipse.cdt.visualizer.ui.canvas.GraphicObject;
import org.eclipse.cdt.visualizer.ui.util.Colors;
+import org.eclipse.cdt.visualizer.ui.util.GUIUtils;
import org.eclipse.cdt.visualizer.ui.util.SelectionManager;
import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
import org.eclipse.core.resources.IMarker;
@@ -52,11 +53,13 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
*/
private class BarGraphicObject extends GraphicObject {
private boolean m_outline;
+ private String m_label;
- public BarGraphicObject(Color color, int x, int y, int w, int h, boolean outline) {
+ public BarGraphicObject(int severity, int x, int y, int w, int h, boolean outline) {
super(x, y, w, h);
m_outline = outline;
+ Color color = getColor(severity);
if (m_outline) {
setForeground(color);
} else {
@@ -64,6 +67,10 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
}
+ public void setLabel(String label) {
+ m_label = label;
+ }
+
@Override
public void paintContent(GC gc) {
if (m_outline) {
@@ -72,6 +79,42 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
gc.fillRectangle(m_bounds);
}
}
+
+ @Override
+ public boolean hasDecorations() {
+ // Only the outline bar has a label decoration.
+ // We muse the the outline bar and not the inside one because
+ // the inside bar may be too small
+ return m_outline;
+ }
+
+ /** Invoked to allow element to paint decorations on top of anything drawn on it */
+ @Override
+ public void paintDecorations(GC gc) {
+ if (m_bounds.height > 20) {
+ gc.setForeground(Colors.BLACK);
+
+ int text_indent = 6;
+ int tx = m_bounds.x + m_bounds.width - text_indent;
+ int ty = m_bounds.y + m_bounds.height - text_indent;
+ GUIUtils.drawTextAligned(gc, m_label, tx, ty, false, false);
+ }
+ }
+
+ private Color getColor(int severity) {
+ switch (severity) {
+ case IMarker.SEVERITY_ERROR:
+ if (m_outline) return ERROR_OUTLINE_COLOR;
+ return ERROR_INSIDE_COLOR;
+ case IMarker.SEVERITY_WARNING:
+ if (m_outline) return WARNING_OUTLINE_COLOR;
+ return WARNING_INSIDE_COLOR;
+ case IMarker.SEVERITY_INFO:
+ if (m_outline) return INFO_OUTLINE_COLOR;
+ return INFO_INSIDE_COLOR;
+ }
+ return Colors.ORANGE;
+ }
}
private class ResizableGraphicCanvas extends GraphicCanvas {
@@ -178,13 +221,16 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
if (outline) {
// The bar outlines take the entire width of the view
- bars[0] = new BarGraphicObject(ERROR_OUTLINE_COLOR, x, y, maxWidth, height, outline);
+ bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, maxWidth, height, outline);
+ bars[0].setLabel(Messages.ProblemCountVisualizer_Errors + m_markerCount[IMarker.SEVERITY_ERROR]);
y = y + height + spacing;
- bars[1] = new BarGraphicObject(WARNING_OUTLINE_COLOR, x, y, maxWidth, height, outline);
+ bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, maxWidth, height, outline);
+ bars[1].setLabel(Messages.ProblemCountVisualizer_Warnings + m_markerCount[IMarker.SEVERITY_WARNING]);
y = y + height + spacing;
- bars[2] = new BarGraphicObject(INFO_OUTLINE_COLOR, x, y, maxWidth, height, outline);
+ bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, maxWidth, height, outline);
+ bars[2].setLabel(Messages.ProblemCountVisualizer_Infos + m_markerCount[IMarker.SEVERITY_INFO]);
} else {
// The inside of the bars use a proportional width with the maximum width and
@@ -196,15 +242,15 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
if (maxCount == 0) maxCount = 1; // Set to anything but 0. It will be multiplied by 0 and not matter.
int width = maxWidth * m_markerCount[IMarker.SEVERITY_ERROR] / maxCount;
- bars[0] = new BarGraphicObject(ERROR_INSIDE_COLOR, x, y, width, height, outline);
+ bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, width, height, outline);
y = y + height + spacing;
width = maxWidth * m_markerCount[IMarker.SEVERITY_WARNING] / maxCount;
- bars[1] = new BarGraphicObject(WARNING_INSIDE_COLOR, x, y, width, height, outline);
+ bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, width, height, outline);
y = y + height + spacing;
width = maxWidth * m_markerCount[IMarker.SEVERITY_INFO] / maxCount;
- bars[2] = new BarGraphicObject(INFO_INSIDE_COLOR, x, y, width, height, outline);
+ bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, width, height, outline);
}
return bars;
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
index 7793412a73..18463bca34 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
@@ -34,6 +34,7 @@ public class VisualizerExamplesPlugin extends AbstractUIPlugin {
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@@ -43,6 +44,7 @@ public class VisualizerExamplesPlugin extends AbstractUIPlugin {
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);

Back to the top