Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2013-05-31 19:18:52 +0000
committerPatrick Tasse2013-06-03 19:19:08 +0000
commiteb7aebfc1e3aa288072665a894511b1268d4151e (patch)
treec207b908a3a31f5667551841a8faae52be120483
parent87e97c54dda8a4c5212179a9eba480a7a37eaa29 (diff)
downloadorg.eclipse.linuxtools-eb7aebfc1e3aa288072665a894511b1268d4151e.tar.gz
org.eclipse.linuxtools-eb7aebfc1e3aa288072665a894511b1268d4151e.tar.xz
org.eclipse.linuxtools-eb7aebfc1e3aa288072665a894511b1268d4151e.zip
Fix Sonar warnings in callstack package
Cherry-pick of commit 24849371187a0595bd12e53b504b2f09fbef1cd7 Change-Id: I955f5a184bb6084a8a883f4670c7bf1d1a3776f7 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/13447 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackPresentationProvider.java15
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java138
2 files changed, 79 insertions, 74 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackPresentationProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackPresentationProvider.java
index 02c627d1d0..0d1c2c6b06 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackPresentationProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackPresentationProvider.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.tmf.ui.views.callstack;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
@@ -46,7 +47,7 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
MULTIPLE (new RGB(100, 100, 100)),
EXEC (new RGB(0, 200, 0));
- public final RGB rgb;
+ private final RGB rgb;
private State (RGB rgb) {
this.rgb = rgb;
@@ -66,10 +67,12 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
@Override
public StateItem[] getStateTable() {
+ final float saturation = 0.6f;
+ final float brightness = 0.6f;
StateItem[] stateTable = new StateItem[NUM_COLORS + 1];
stateTable[0] = new StateItem(State.MULTIPLE.rgb, State.MULTIPLE.toString());
for (int i = 0; i < NUM_COLORS; i++) {
- RGB rgb = new RGB((i), (float) 0.6, (float) 0.6);
+ RGB rgb = new RGB(i, saturation, brightness);
stateTable[i + 1] = new StateItem(rgb, State.EXEC.toString());
}
return stateTable;
@@ -98,9 +101,9 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
return state.toString();
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
/* Ignored */
}
@@ -127,9 +130,9 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
Utils.drawText(gc, state.toString(), bounds.x, bounds.y - 2, bounds.width, true, true);
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
/* Ignored */
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java
index 038fd723db..7495ad4004 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java
@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -105,7 +106,7 @@ public class CallStackView extends TmfView {
*/
private enum State { IDLE, BUSY, PENDING }
- private final String[] COLUMN_NAMES = new String[] {
+ private static final String[] COLUMN_NAMES = new String[] {
Messages.CallStackView_FunctionColumn,
Messages.CallStackView_DepthColumn,
Messages.CallStackView_EntryTimeColumn,
@@ -113,6 +114,17 @@ public class CallStackView extends TmfView {
Messages.CallStackView_DurationColumn
};
+ private static final int[] COLUMN_WIDTHS = new int[] {
+ 200,
+ 50,
+ 120,
+ 120,
+ 120
+ };
+
+ // Fraction of a function duration to be added as spacing
+ private static final double SPACING_RATIO = 0.01;
+
private static final Image THREAD_IMAGE = Activator.getDefault().getImageFromPath("icons/obj16/thread_obj.gif"); //$NON-NLS-1$
private static final Image STACKFRAME_IMAGE = Activator.getDefault().getImageFromPath("icons/obj16/stckframe_obj.gif"); //$NON-NLS-1$
@@ -121,22 +133,22 @@ public class CallStackView extends TmfView {
// ------------------------------------------------------------------------
// The time graph combo
- TimeGraphCombo fTimeGraphCombo;
+ private TimeGraphCombo fTimeGraphCombo;
// The selected trace
private ITmfTrace fTrace;
// The selected thread map
- final private HashMap<ITmfTrace, String> fSelectedThreadMap = new HashMap<ITmfTrace, String>();
+ private final Map<ITmfTrace, String> fSelectedThreadMap = new HashMap<ITmfTrace, String>();
// The time graph entry list
- private ArrayList<ThreadEntry> fEntryList;
+ private List<ThreadEntry> fEntryList;
// The trace to entry list hash map
- final private HashMap<ITmfTrace, ArrayList<ThreadEntry>> fEntryListMap = new HashMap<ITmfTrace, ArrayList<ThreadEntry>>();
+ private final Map<ITmfTrace, ArrayList<ThreadEntry>> fEntryListMap = new HashMap<ITmfTrace, ArrayList<ThreadEntry>>();
// The trace to build thread hash map
- final private HashMap<ITmfTrace, BuildThread> fBuildThreadMap = new HashMap<ITmfTrace, BuildThread>();
+ private final Map<ITmfTrace, BuildThread> fBuildThreadMap = new HashMap<ITmfTrace, BuildThread>();
// The start time
private long fStartTime;
@@ -166,7 +178,7 @@ public class CallStackView extends TmfView {
private State fRedrawState = State.IDLE;
// The redraw synchronization object
- final private Object fSyncObj = new Object();
+ private final Object fSyncObj = new Object();
// The saved time sync. signal used when switching off the pinning of a view
private TmfTimeSynchSignal fSavedTimeSyncSignal;
@@ -215,9 +227,9 @@ public class CallStackView extends TmfView {
ITmfStateInterval eventStackInterval = ss.querySingleState(ss.getStartTime(), eventStackQuark);
return ! eventStackInterval.getStateValue().isNull() || eventStackInterval.getEndTime() != ss.getCurrentEndTime();
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
/* Ignored */
}
@@ -353,26 +365,18 @@ public class CallStackView extends TmfView {
CallStackEntry entry = (CallStackEntry) element;
if (columnIndex == 0) {
return entry.getFunctionName();
- } else if (columnIndex == 1) {
- if (entry.getFunctionName().length() > 0) {
- int depth = entry.getStackLevel();
- return Integer.toString(depth);
- }
- } else if (columnIndex == 2) {
- if (entry.getFunctionName().length() > 0) {
- ITmfTimestamp ts = new TmfTimestamp(entry.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
- return ts.toString();
- }
- } else if (columnIndex == 3) {
- if (entry.getFunctionName().length() > 0) {
- ITmfTimestamp ts = new TmfTimestamp(entry.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE);
- return ts.toString();
- }
- } else if (columnIndex == 4) {
- if (entry.getFunctionName().length() > 0) {
- ITmfTimestamp ts = new TmfTimestampDelta(entry.getEndTime() - entry.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
- return ts.toString();
- }
+ } else if (columnIndex == 1 && entry.getFunctionName().length() > 0) {
+ int depth = entry.getStackLevel();
+ return Integer.toString(depth);
+ } else if (columnIndex == 2 && entry.getFunctionName().length() > 0) {
+ ITmfTimestamp ts = new TmfTimestamp(entry.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ return ts.toString();
+ } else if (columnIndex == 3 && entry.getFunctionName().length() > 0) {
+ ITmfTimestamp ts = new TmfTimestamp(entry.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ return ts.toString();
+ } else if (columnIndex == 4 && entry.getFunctionName().length() > 0) {
+ ITmfTimestamp ts = new TmfTimestampDelta(entry.getEndTime() - entry.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ return ts.toString();
}
}
return ""; //$NON-NLS-1$
@@ -404,12 +408,12 @@ public class CallStackView extends TmfView {
}
private class ZoomThread extends Thread {
- private final ArrayList<ThreadEntry> fZoomEntryList;
+ private final List<ThreadEntry> fZoomEntryList;
private final long fZoomStartTime;
private final long fZoomEndTime;
private final IProgressMonitor fMonitor;
- public ZoomThread(ArrayList<ThreadEntry> entryList, long startTime, long endTime) {
+ public ZoomThread(List<ThreadEntry> entryList, long startTime, long endTime) {
super("ResourcesView zoom"); //$NON-NLS-1$
fZoomEntryList = entryList;
fZoomStartTime = startTime;
@@ -477,11 +481,11 @@ public class CallStackView extends TmfView {
fTimeGraphCombo.setTreeColumns(COLUMN_NAMES);
- fTimeGraphCombo.getTreeViewer().getTree().getColumn(0).setWidth(200);
- fTimeGraphCombo.getTreeViewer().getTree().getColumn(1).setWidth(50);
- fTimeGraphCombo.getTreeViewer().getTree().getColumn(2).setWidth(120);
- fTimeGraphCombo.getTreeViewer().getTree().getColumn(3).setWidth(120);
- fTimeGraphCombo.getTreeViewer().getTree().getColumn(4).setWidth(120);
+ fTimeGraphCombo.getTreeViewer().getTree().getColumn(0).setWidth(COLUMN_WIDTHS[0]);
+ fTimeGraphCombo.getTreeViewer().getTree().getColumn(1).setWidth(COLUMN_WIDTHS[1]);
+ fTimeGraphCombo.getTreeViewer().getTree().getColumn(2).setWidth(COLUMN_WIDTHS[2]);
+ fTimeGraphCombo.getTreeViewer().getTree().getColumn(3).setWidth(COLUMN_WIDTHS[3]);
+ fTimeGraphCombo.getTreeViewer().getTree().getColumn(4).setWidth(COLUMN_WIDTHS[4]);
fTimeGraphCombo.setTimeGraphProvider(new CallStackPresentationProvider());
fTimeGraphCombo.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
@@ -526,7 +530,7 @@ public class CallStackView extends TmfView {
if (entry.getFunctionName().length() > 0) {
long startTime = entry.getStartTime();
long endTime = entry.getEndTime();
- long spacingTime = (long) ((endTime - startTime) * 0.01);
+ long spacingTime = (long) ((endTime - startTime) * SPACING_RATIO);
startTime -= spacingTime;
endTime += spacingTime;
TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
@@ -550,7 +554,7 @@ public class CallStackView extends TmfView {
CallStackEvent event = (CallStackEvent) o;
long startTime = event.getTime();
long endTime = startTime + event.getDuration();
- long spacingTime = (long) ((endTime - startTime) * 0.01);
+ long spacingTime = (long) ((endTime - startTime) * SPACING_RATIO);
startTime -= spacingTime;
endTime += spacingTime;
TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
@@ -679,13 +683,13 @@ public class CallStackView extends TmfView {
break;
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateValueTypeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
}
}
}
@@ -795,7 +799,7 @@ public class CallStackView extends TmfView {
threadEntry.addChild(callStackEntry);
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
}
}
}
@@ -852,8 +856,8 @@ public class CallStackView extends TmfView {
long time = statusInterval.getStartTime();
long duration = statusInterval.getEndTime() - time + 1;
if (!statusInterval.getStateValue().isNull()) {
- final int MODULO = CallStackPresentationProvider.NUM_COLORS / 2;
- int value = statusInterval.getStateValue().toString().hashCode() % MODULO + MODULO;
+ final int modulo = CallStackPresentationProvider.NUM_COLORS / 2;
+ int value = statusInterval.getStateValue().toString().hashCode() % modulo + modulo;
eventList.add(new CallStackEvent(entry, time, duration, value));
lastIsNull = false;
} else {
@@ -866,9 +870,9 @@ public class CallStackView extends TmfView {
lastEndTime = time + duration;
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
/* Ignored */
}
@@ -907,11 +911,11 @@ public class CallStackView extends TmfView {
callStackEntry.setEndTime(stackLevelInterval.getEndTime() + 1);
}
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
}
}
}
@@ -1004,17 +1008,15 @@ public class CallStackView extends TmfView {
fPinAction.addPropertyChangeListener(new IPropertyChangeListener(){
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (IAction.CHECKED.equals(event.getProperty())) {
- if (!isPinned()) {
- if (fSavedRangeSyncSignal != null) {
- synchToRange(fSavedRangeSyncSignal);
- fSavedRangeSyncSignal = null;
- }
+ if (IAction.CHECKED.equals(event.getProperty()) && !isPinned()) {
+ if (fSavedRangeSyncSignal != null) {
+ synchToRange(fSavedRangeSyncSignal);
+ fSavedRangeSyncSignal = null;
+ }
- if (fSavedTimeSyncSignal != null) {
- synchToTime(fSavedTimeSyncSignal);
- fSavedTimeSyncSignal = null;
- }
+ if (fSavedTimeSyncSignal != null) {
+ synchToTime(fSavedTimeSyncSignal);
+ fSavedTimeSyncSignal = null;
}
}
}
@@ -1062,13 +1064,13 @@ public class CallStackView extends TmfView {
viewer.getTimeGraphControl().fireSelectionChanged();
startZoomThread(viewer.getTime0(), viewer.getTime1());
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateValueTypeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
}
}
}
@@ -1113,13 +1115,13 @@ public class CallStackView extends TmfView {
viewer.getTimeGraphControl().fireSelectionChanged();
startZoomThread(viewer.getTime0(), viewer.getTime1());
} catch (AttributeNotFoundException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (TimeRangeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
} catch (StateValueTypeException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
}
}
}

Back to the top