tmf: Make ITmfGraphEntry.getChildren() return a List
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 3 Oct 2012 16:29:39 +0000 (12:29 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 4 Oct 2012 15:55:12 +0000 (11:55 -0400)
instead of a static array.

Because of the upcoming AbstractTimeGraphEntry and its subclasses,
we will now need to specify the exact class in each view's
.getChildren(). This is not possible to do with an array if we use
a generic type (e.g. E[]), we have to use a Collection like List<E>.

Change-Id: Icf858b471a95ea7d68e6b6b2169afdc35922545a
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/7747
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowEntry.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesEntry.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java

index 97b6ef03e753d8bf3be419e1a86aeabc100e7f08..3e1fe97e443e243a265c2ea533bc0889caf01e03 100644 (file)
@@ -81,8 +81,8 @@ public class ControlFlowEntry implements ITimeGraphEntry {
     }
 
     @Override
-    public ControlFlowEntry[] getChildren() {
-        return fChildren.toArray(new ControlFlowEntry[0]);
+    public List<ControlFlowEntry> getChildren() {
+        return fChildren;
     }
 
     @Override
index 30105c25cb40c28ac7d6e1a28e147b0a7195effa..91ba7a34fe6b24b4149a0f7f3f2eb8f99ca96e77 100644 (file)
@@ -171,7 +171,8 @@ public class ControlFlowView extends TmfView {
         @Override
         public Object[] getChildren(Object parentElement) {
             ITimeGraphEntry entry = (ITimeGraphEntry) parentElement;
-            return entry.getChildren();
+            List<? extends ITimeGraphEntry> children = entry.getChildren();
+            return children.toArray(new ITimeGraphEntry[children.size()]);
         }
 
         @Override
index 585c2e8953efcb77e3dc7a0ffccab9d5543d0775..a51c418148b0083e0face98055c136e07799f0b4 100644 (file)
@@ -42,7 +42,7 @@ public class ResourcesEntry implements ITimeGraphEntry {
     private final int fQuark;
     private final CtfKernelTrace fTrace;
     private ITimeGraphEntry fParent = null;
-    private final ITimeGraphEntry[] children = null;
+    private final List<ITimeGraphEntry> children = null;
     private final String fName;
     private final Type fType;
     private final int fId;
@@ -79,11 +79,11 @@ public class ResourcesEntry implements ITimeGraphEntry {
 
     @Override
     public boolean hasChildren() {
-        return children != null && children.length > 0;
+        return children != null && children.size() > 0;
     }
 
     @Override
-    public ITimeGraphEntry[] getChildren() {
+    public List<ITimeGraphEntry> getChildren() {
         return children;
     }
 
index e878f8bcd984bdb69831e4a7e6bc7c15aaef9573..81e71306d99f6b718d16e7ae9196f850a748fa48 100644 (file)
@@ -154,8 +154,8 @@ public class ResourcesView extends TmfView {
         }
 
         @Override
-        public ResourcesEntry[] getChildren() {
-            return fChildren.toArray(new ResourcesEntry[0]);
+        public List<ResourcesEntry> getChildren() {
+            return fChildren;
         }
 
         @Override
index 210c5b0c8ce71dd670234c77346e3444ddf4aa8f..d78ec332493e3d7529715a38a0f466abdead4024 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
@@ -98,7 +99,7 @@ public class TraceImpl implements ITimeGraphEntry {
     }
 
     @Override
-    public ITimeGraphEntry[] getChildren() {
+    public List<ITimeGraphEntry> getChildren() {
         return null;
     }
 
index 35089c7e2e3b9b8740c7c2d4a2c99875a14b2310..ccd3d68a715a0277eee56e7230fbe5470cf4836e 100644 (file)
@@ -13,6 +13,7 @@
 package org.eclipse.linuxtools.tmf.ui.views.timechart;
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Vector;
 
@@ -41,8 +42,11 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry {
         fTraceEvents = new Vector<TimeChartEvent>(modelSize);
     }
 
+    /**
+     * @since 2.0
+     */
     @Override
-    public ITimeGraphEntry[] getChildren() {
+    public List<ITimeGraphEntry> getChildren() {
         return null;
     }
 
index f31d7c2a7ef914f089599fcbd18c471bb566b68c..d067ea9f9ea43a59d1bc46ee46e411e76ca1bbac 100644 (file)
@@ -14,6 +14,7 @@
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;
 
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Interface for an entry (row) in the time graph view
@@ -43,8 +44,9 @@ public interface ITimeGraphEntry {
      * Returns the child elements of this entry.
      *
      * @return an array of child elements
+     * @since 2.0
      */
-    public ITimeGraphEntry[] getChildren();
+    public List<? extends ITimeGraphEntry> getChildren();
 
     /**
      * Returns the name of this entry.
This page took 0.03554 seconds and 5 git commands to generate.