mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Cleanup with javadoc and such.
This commit is contained in:
parent
b2a621616a
commit
5117703634
4 changed files with 75 additions and 45 deletions
|
@ -1,13 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Ericsson and others.
|
* Copyright (c) 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.visualizer.examples;
|
package org.eclipse.cdt.visualizer.examples;
|
||||||
|
|
||||||
|
@ -17,9 +16,9 @@ import org.eclipse.osgi.util.NLS;
|
||||||
* Preference strings.
|
* Preference strings.
|
||||||
*/
|
*/
|
||||||
class Messages extends NLS {
|
class Messages extends NLS {
|
||||||
public static String CounterVisualizer_Name;
|
public static String ProblemCountVisualizer_Name;
|
||||||
public static String CounterVisualizer_DisplayName;
|
public static String ProblemCountVisualizer_DisplayName;
|
||||||
public static String CounterVisualizer_Description;
|
public static String ProblemCountVisualizer_Description;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
# Marc Khouzam (Ericsson) - initial API and implementation
|
# Marc Khouzam (Ericsson) - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
CounterVisualizer_Name=counter
|
ProblemCountVisualizer_Name=ProblemCounter
|
||||||
CounterVisualizer_DisplayName=Counter Visualizer
|
ProblemCountVisualizer_DisplayName=Problem Count Visualizer
|
||||||
CounterVisualizer_Description=Visualizer displaying the count of errors/warnings/info
|
ProblemCountVisualizer_Description=Visualizer displaying the count of errors/warnings/info
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Tilera Corporation and others.
|
* Copyright (c) 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -27,33 +27,41 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
|
|
||||||
|
/** The width of the side margins */
|
||||||
private static final int MARGIN_WIDTH = 10;
|
private static final int MARGIN_WIDTH = 10;
|
||||||
|
/** The height of the top and bottom margins */
|
||||||
private static final int MARGIN_HEIGHT = 10;
|
private static final int MARGIN_HEIGHT = 10;
|
||||||
|
/** The default space between bars in the chart */
|
||||||
private static final int SPACING_HEIGHT = 40;
|
private static final int SPACING_HEIGHT = 40;
|
||||||
|
/** The predefined number of severities */
|
||||||
private static final int NUM_SEVERITY = 3;
|
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 class BarGraphicObject extends GraphicObject {
|
||||||
private boolean m_outline;
|
private boolean m_outline;
|
||||||
|
|
||||||
public BarGraphicObject(int severity, int x, int y, int w, int h, boolean outline) {
|
public BarGraphicObject(Color color, int x, int y, int w, int h, boolean outline) {
|
||||||
super(x, y, w, h);
|
super(x, y, w, h);
|
||||||
m_outline = outline;
|
m_outline = outline;
|
||||||
|
|
||||||
Color color = Colors.BLACK;
|
if (m_outline) {
|
||||||
|
setForeground(color);
|
||||||
switch (severity) {
|
} else {
|
||||||
case IMarker.SEVERITY_ERROR:
|
setBackground(color);
|
||||||
color = Colors.DARK_RED;
|
|
||||||
break;
|
|
||||||
case IMarker.SEVERITY_WARNING:
|
|
||||||
color = Colors.DARK_YELLOW;
|
|
||||||
break;
|
|
||||||
case IMarker.SEVERITY_INFO:
|
|
||||||
color = Colors.DARK_BLUE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!m_outline) setBackground(color);
|
|
||||||
setForeground(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,9 +74,14 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The canvas on which we'll draw our bars */
|
||||||
private GraphicCanvas m_canvas;
|
private GraphicCanvas m_canvas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The model containing the data to be displayed.
|
||||||
|
* In this case, it is the number of the three
|
||||||
|
* different types of problem markers.
|
||||||
|
*/
|
||||||
private int[] m_markerCount = new int[NUM_SEVERITY];
|
private int[] m_markerCount = new int[NUM_SEVERITY];
|
||||||
|
|
||||||
public ProblemVisualizer() {
|
public ProblemVisualizer() {
|
||||||
|
@ -77,17 +90,17 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return Messages.CounterVisualizer_Name;
|
return Messages.ProblemCountVisualizer_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return Messages.CounterVisualizer_DisplayName;
|
return Messages.ProblemCountVisualizer_DisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return Messages.CounterVisualizer_Description;
|
return Messages.ProblemCountVisualizer_Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,8 +111,8 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeCanvas(GraphicCanvas canvas) {
|
protected void initializeCanvas(GraphicCanvas canvas) {
|
||||||
// TODO Auto-generated method stub
|
m_canvas.setBackground(MAIN_BACKGROUND_COLOR);
|
||||||
super.initializeCanvas(canvas);
|
m_canvas.setForeground(MAIN_FOREGROUND_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,16 +128,17 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visualizerDeselected() {
|
public void visualizerDeselected() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.visualizerDeselected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visualizerSelected() {
|
public void visualizerSelected() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.visualizerSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually create the graphics bars for the different severities.
|
||||||
|
* @param outline Should the bars be created, or the bar outline
|
||||||
|
* @return The bars to be drawn.
|
||||||
|
*/
|
||||||
private BarGraphicObject[] getBars(boolean outline) {
|
private BarGraphicObject[] getBars(boolean outline) {
|
||||||
BarGraphicObject[] bars = new BarGraphicObject[3];
|
BarGraphicObject[] bars = new BarGraphicObject[3];
|
||||||
|
|
||||||
|
@ -144,35 +158,43 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
int maxWidth = bounds.width - 2 * MARGIN_WIDTH;
|
int maxWidth = bounds.width - 2 * MARGIN_WIDTH;
|
||||||
|
|
||||||
if (outline) {
|
if (outline) {
|
||||||
bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, maxWidth, height, outline);
|
// The bar outlines take the entire width of the view
|
||||||
|
bars[0] = new BarGraphicObject(ERROR_OUTLINE_COLOR, x, y, maxWidth, height, outline);
|
||||||
|
|
||||||
y = y + height + spacing;
|
y = y + height + spacing;
|
||||||
bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, maxWidth, height, outline);
|
bars[1] = new BarGraphicObject(WARNING_OUTLINE_COLOR, x, y, maxWidth, height, outline);
|
||||||
|
|
||||||
y = y + height + spacing;
|
y = y + height + spacing;
|
||||||
bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, maxWidth, height, outline);
|
bars[2] = new BarGraphicObject(INFO_OUTLINE_COLOR, x, y, maxWidth, height, outline);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// The inside of the bars use a proportional width with the maximum width and
|
||||||
|
// the largest amount of markers for one severity.
|
||||||
|
|
||||||
// Find the maximum marker count to dictate the width
|
// Find the maximum marker count to dictate the width
|
||||||
int maxCount = Math.max(m_markerCount[0], m_markerCount[1]);
|
int maxCount = Math.max(m_markerCount[0], m_markerCount[1]);
|
||||||
maxCount = Math.max(maxCount, m_markerCount[2]);
|
maxCount = Math.max(maxCount, m_markerCount[2]);
|
||||||
if (maxCount == 0) maxCount = 1; // Set to anything but 0. It will be multiplied by 0 and not matter.
|
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;
|
int width = maxWidth * m_markerCount[IMarker.SEVERITY_ERROR] / maxCount;
|
||||||
bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, width, height, outline);
|
bars[0] = new BarGraphicObject(ERROR_INSIDE_COLOR, x, y, width, height, outline);
|
||||||
|
|
||||||
y = y + height + spacing;
|
y = y + height + spacing;
|
||||||
width = maxWidth * m_markerCount[IMarker.SEVERITY_WARNING] / maxCount;
|
width = maxWidth * m_markerCount[IMarker.SEVERITY_WARNING] / maxCount;
|
||||||
bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, width, height, outline);
|
bars[1] = new BarGraphicObject(WARNING_INSIDE_COLOR, x, y, width, height, outline);
|
||||||
|
|
||||||
y = y + height + spacing;
|
y = y + height + spacing;
|
||||||
width = maxWidth * m_markerCount[IMarker.SEVERITY_INFO] / maxCount;
|
width = maxWidth * m_markerCount[IMarker.SEVERITY_INFO] / maxCount;
|
||||||
bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, width, height, outline);
|
bars[2] = new BarGraphicObject(INFO_INSIDE_COLOR, x, y, width, height, outline);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bars;
|
return bars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the count of problem markers for each severity for the
|
||||||
|
* specified resource.
|
||||||
|
*/
|
||||||
private void setMarkerCount(IResource resource) {
|
private void setMarkerCount(IResource resource) {
|
||||||
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
|
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
|
||||||
m_markerCount[IMarker.SEVERITY_WARNING] = 0;
|
m_markerCount[IMarker.SEVERITY_WARNING] = 0;
|
||||||
|
@ -225,5 +247,4 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
|
||||||
public SelectionManager getSelectionManager() {
|
public SelectionManager getSelectionManager() {
|
||||||
return m_selectionManager;
|
return m_selectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
package org.eclipse.cdt.visualizer.examples;
|
||||||
|
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
|
Loading…
Add table
Reference in a new issue