Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-03-02 10:47:06 -0500
committerMarc Khouzam2012-03-02 10:47:06 -0500
commita4153db426af3de6fe53669c27637c23ad3349f9 (patch)
tree5fa4d06eda0a813598dc60f69a5950344d31d3ce /visualizer
parentf85b0e8f4cebc4f5ca7d4bb42bf77b8a73deb28d (diff)
downloadorg.eclipse.cdt-a4153db426af3de6fe53669c27637c23ad3349f9.tar.gz
org.eclipse.cdt-a4153db426af3de6fe53669c27637c23ad3349f9.tar.xz
org.eclipse.cdt-a4153db426af3de6fe53669c27637c23ad3349f9.zip
Bug 372797: Update based on comments.
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/META-INF/MANIFEST.MF2
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml2
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java96
-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/ProblemVisualizer/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/ProblemVisualizer/Messages.properties)0
-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/ProblemVisualizer.java)113
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ResizableGraphicCanvas.java29
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java5
8 files changed, 139 insertions, 110 deletions
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/META-INF/MANIFEST.MF b/visualizer/org.eclipse.cdt.visualizer.examples/META-INF/MANIFEST.MF
index 0a14b0d7f2..128d1797ef 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/META-INF/MANIFEST.MF
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/META-INF/MANIFEST.MF
@@ -11,3 +11,5 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.cdt.visualizer.examples,
+ org.eclipse.cdt.visualizer.examples.problemvisualizer
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml b/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
index 55d329cf0b..b5635af2c8 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/plugin.xml
@@ -4,7 +4,7 @@
<extension
point="org.eclipse.cdt.visualizer.ui.visualizer">
<visualizer
- class="org.eclipse.cdt.visualizer.examples.ProblemVisualizer.ProblemVisualizer"
+ 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/problemvisualizer/BarGraphicObject.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java
new file mode 100644
index 0000000000..5013b849ae
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc Khouzam (Ericsson) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.visualizer.examples.problemvisualizer;
+
+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.core.resources.IMarker;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+
+/**
+ * A class that draws a bar or a bar outline in the specified color.
+ */
+public class BarGraphicObject extends GraphicObject {
+
+ /* The different colors to use for the different severities */
+ private static final Color ERROR_OUTLINE_COLOR = Colors.DARK_RED;
+ private static final Color ERROR_INSIDE_COLOR = Colors.DARK_RED;
+ private static final Color WARNING_OUTLINE_COLOR = Colors.DARK_YELLOW;
+ private static final Color WARNING_INSIDE_COLOR = Colors.DARK_YELLOW;
+ private static final Color INFO_OUTLINE_COLOR = Colors.DARK_BLUE;
+ private static final Color INFO_INSIDE_COLOR = Colors.DARK_BLUE;
+
+ private boolean m_outline;
+ private String m_label;
+
+ 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 {
+ setBackground(color);
+ }
+ }
+
+ public void setLabel(String label) {
+ m_label = label;
+ }
+
+ @Override
+ public void paintContent(GC gc) {
+ if (m_outline) {
+ gc.drawRectangle(m_bounds);
+ } else {
+ 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;
+ }
+} \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/Messages.java
index d4932dd748..bec2c034d8 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/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.ProblemVisualizer;
+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/ProblemVisualizer/Messages.properties b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/Messages.properties
index 0f4271ed21..0f4271ed21 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/Messages.properties
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/Messages.properties
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/ProblemVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ProblemVisualizer.java
index 47a2a69e6e..e5989c28cd 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer/ProblemVisualizer.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ProblemVisualizer.java
@@ -8,15 +8,13 @@
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.visualizer.examples.ProblemVisualizer;
+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;
-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;
@@ -24,7 +22,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
@@ -38,97 +35,10 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
private static final int SPACING_HEIGHT = 40;
/** The predefined number of severities */
private static final int NUM_SEVERITY = 3;
-
- /* The different colors to use for the different severities */
- private static final Color ERROR_OUTLINE_COLOR = Colors.DARK_RED;
- private static final Color ERROR_INSIDE_COLOR = Colors.DARK_RED;
- private static final Color WARNING_OUTLINE_COLOR = Colors.DARK_YELLOW;
- private static final Color WARNING_INSIDE_COLOR = Colors.DARK_YELLOW;
- private static final Color INFO_OUTLINE_COLOR = Colors.DARK_BLUE;
- private static final Color INFO_INSIDE_COLOR = Colors.DARK_BLUE;
private static final Color MAIN_BACKGROUND_COLOR = Colors.WHITE;
private static final Color MAIN_FOREGROUND_COLOR = Colors.BLACK;
- /**
- * A class that draws a bar or a bar outline in the specified color.
- */
- private class BarGraphicObject extends GraphicObject {
- private boolean m_outline;
- private String m_label;
-
- 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 {
- setBackground(color);
- }
- }
-
- public void setLabel(String label) {
- m_label = label;
- }
-
- @Override
- public void paintContent(GC gc) {
- if (m_outline) {
- gc.drawRectangle(m_bounds);
- } else {
- 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 {
- 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;
@@ -140,27 +50,14 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
private int[] m_markerCount = new int[NUM_SEVERITY];
public ProblemVisualizer() {
- super();
+ super(Messages.ProblemCountVisualizer_Name,
+ Messages.ProblemCountVisualizer_DisplayName,
+ Messages.ProblemCountVisualizer_Description);
}
@Override
- public String getName() {
- return Messages.ProblemCountVisualizer_Name;
- }
-
- @Override
- public String getDisplayName() {
- return Messages.ProblemCountVisualizer_DisplayName;
- }
-
- @Override
- public String getDescription() {
- return Messages.ProblemCountVisualizer_Description;
- }
-
- @Override
public GraphicCanvas createCanvas(Composite parent) {
- m_canvas = new ResizableGraphicCanvas(parent);
+ m_canvas = new ResizableGraphicCanvas(this, parent);
return m_canvas;
}
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ResizableGraphicCanvas.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ResizableGraphicCanvas.java
new file mode 100644
index 0000000000..860bd079ec
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/ResizableGraphicCanvas.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc Khouzam (Ericsson) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.visualizer.examples.problemvisualizer;
+
+import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+
+public class ResizableGraphicCanvas extends GraphicCanvas {
+ private final ProblemVisualizer m_problemVisualizer;
+
+ public ResizableGraphicCanvas(ProblemVisualizer problemVisualizer, Composite parent) {
+ super(parent);
+ m_problemVisualizer = problemVisualizer;
+ }
+
+ @Override
+ public void resized(Rectangle bounds) {
+ m_problemVisualizer.refresh();
+ }
+} \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java
index 5fcef0d92d..d960d3fa67 100644
--- a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java
@@ -44,6 +44,11 @@ public class GraphicCanvasVisualizer extends Visualizer
super("canvas", "Canvas Visualizer", "Displays graphic representation of selection.");
}
+ /** Constructor specifying name and such information. */
+ public GraphicCanvasVisualizer(String name, String displayName, String description) {
+ super(name, displayName, description);
+ }
+
/** Dispose method. */
public void dispose() {
super.dispose();

Back to the top