/*******************************************************************************
* Copyright (c) 2009, 2010 Ericsson
- *
+ *
* 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:
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
*******************************************************************************/
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model.EventImpl;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model.TraceImpl;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model.TraceModelImplFactory;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.ViewPart;
-@SuppressWarnings("nls")
+@SuppressWarnings({"javadoc", "nls"})
public class TsfTraceAnalysisView extends ViewPart implements
ITimeGraphSelectionListener, ITimeGraphTimeListener, ITimeGraphRangeListener {
*/
class TreeObject implements IAdaptable {
- private String name;
+ private final String name;
private TreeParent parent;
public TreeObject(String name) {
}
@Override
- @SuppressWarnings("rawtypes")
public Object getAdapter(Class key) {
return null;
}
}
class TreeParent extends TreeObject {
- private ArrayList<TreeObject> children;
+ private final ArrayList<TreeObject> children;
public TreeParent(String name) {
super(name);
}
}
- class ViewContentProvider implements IStructuredContentProvider,
- ITreeContentProvider {
+ class ViewContentProvider implements ITreeContentProvider {
private TreeParent invisibleRoot;
@Override
@Override
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- if (invisibleRoot == null)
- initialize();
+ if (invisibleRoot == null) {
+ initialize();
+ }
return getChildren(invisibleRoot);
}
return getChildren(parent);
@Override
public boolean hasChildren(Object parent) {
- if (parent instanceof TreeParent)
- return ((TreeParent) parent).hasChildren();
+ if (parent instanceof TreeParent) {
+ return ((TreeParent) parent).hasChildren();
+ }
return false;
}
@Override
public Image getImage(Object obj) {
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
- if (obj instanceof TreeParent)
- imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ if (obj instanceof TreeParent) {
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ }
return PlatformUI.getWorkbench().getSharedImages().getImage(
imageKey);
}
tsfviewer.setInput(traceArr);
tsfviewer.addSelectionListener(this);
tsfviewer.addRangeListener(this);
- tsfviewer.setTimeCalendarFormat(true);
+ tsfviewer.setTimeFormat(TimeFormat.CALENDAR);
tsfviewer2.setInput(traceArr);
tsfviewer2.addSelectionListener(this);
private TimeGraphViewer getActiveTsfCtrl() {
TimeGraphViewer inFocusViewer = null;
- if (tsfviewer.isInFocus())
- inFocusViewer = tsfviewer;
- else if (tsfviewer2.isInFocus())
- inFocusViewer = tsfviewer2;
+ if (tsfviewer.isInFocus()) {
+ inFocusViewer = tsfviewer;
+ } else if (tsfviewer2.isInFocus()) {
+ inFocusViewer = tsfviewer2;
+ }
return inFocusViewer;
}
public void run() {
TimeGraphViewer inFocusViewer = getActiveTsfCtrl();
if (inFocusViewer != null) {
- inFocusViewer.selectNextTrace();
+ inFocusViewer.selectNextItem();
}
}
};
public void run() {
TimeGraphViewer inFocusViewer = getActiveTsfCtrl();
if (inFocusViewer != null) {
- inFocusViewer.selectPrevTrace();
+ inFocusViewer.selectPrevItem();
}
}
};
+ "\nSelected Time: "
+ selTimens + " " + fDate + " " + ns);
- synchViewer.setSelectedTime(event.getTime(), true, event.getSource());
+ synchViewer.setSelectedTime(event.getTime(), true);
}
@Override
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
- if (event == null)
- return;
- Object source = event.getSource();
- if (source == null || !(source instanceof TimeGraphViewer)) {
- return;
- }
-
- if (event instanceof TimeGraphRangeUpdateEvent) {
- TimeGraphRangeUpdateEvent rEvent = (TimeGraphRangeUpdateEvent) event;
- TimeGraphViewer rViewer = (TimeGraphViewer) event
- .getSource();
- TimeGraphViewer synchViewer = null;
- // Synchronize viewer selections if Enabled,
- // make sure the selection does not go in loops
- if (tsfviewer == rViewer) {
- synchViewer = tsfviewer2;
- } else {
- synchViewer = tsfviewer;
- }
+ if (event == null) {
+ return;
+ }
+ Object source = event.getSource();
+ if (source == null || !(source instanceof TimeGraphViewer)) {
+ return;
+ }
+ TimeGraphRangeUpdateEvent rEvent = event;
+ TimeGraphViewer rViewer = (TimeGraphViewer) event
+ .getSource();
+ TimeGraphViewer synchViewer = null;
+ // Synchronize viewer selections if Enabled,
+ // make sure the selection does not go in loops
+ if (tsfviewer == rViewer) {
+ synchViewer = tsfviewer2;
+ } else {
+ synchViewer = tsfviewer;
+ }
- synchViewer.setSelectVisTimeWindow(rEvent.getStartTime(), rEvent
- .getEndTime(), source);
- }
- }
+ synchViewer.setSelectVisTimeWindow(rEvent.getStartTime(), rEvent
+ .getEndTime(), source);
+ }
/**
* Obtains the remainder fraction on unit Seconds of the entered value in
* nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds can
* be obtain by removing the last 9 digits: 1241207054 the fractional
* portion of seconds, expressed in ns is: 171080214
- *
+ *
* @param v
* @return
*/