redraw();\r
}\r
\r
- public void refreshData(ITimeGraphEntry traces[]) {\r
+ public void refreshData(ITimeGraphEntry[] traces) {\r
_data.refreshData(traces);\r
adjustScrolls();\r
redraw();\r
boolean changed = false;\r
if (idx < 0) {\r
for (idx = 0; idx < _data._expandedItems.length; idx++) {\r
- if (((TimeGraphItem) _data._expandedItems[idx])._selected)\r
+ if (((Item) _data._expandedItems[idx])._selected)\r
break;\r
}\r
}\r
}\r
\r
public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {\r
- TimeGraphItem item = _data.findItem(entry);\r
+ Item item = _data.findItem(entry);\r
if (item != null && item._expanded != expanded) {\r
item._expanded = expanded;\r
_data.updateExpandedItems();\r
boolean changed = false;\r
int lastSelection = -1;\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[i];\r
+ Item item = (Item) _data._expandedItems[i];\r
if (item._selected) {\r
lastSelection = i;\r
if ((1 == n) && (i < _data._expandedItems.length - 1)) {\r
item._selected = false;\r
- item = (TimeGraphItem) _data._expandedItems[i + 1];\r
+ item = (Item) _data._expandedItems[i + 1];\r
item._selected = true;\r
changed = true;\r
} else if ((-1 == n) && (i > 0)) {\r
item._selected = false;\r
- item = (TimeGraphItem) _data._expandedItems[i - 1];\r
+ item = (Item) _data._expandedItems[i - 1];\r
item._selected = true;\r
changed = true;\r
}\r
}\r
\r
if (lastSelection < 0 && _data._expandedItems.length > 0) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[0];\r
+ Item item = (Item) _data._expandedItems[0];\r
item._selected = true;\r
changed = true;\r
}\r
public int getSelectedIndex() {\r
int idx = -1;\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[i];\r
+ Item item = (Item) _data._expandedItems[i];\r
if (item._selected) {\r
idx = i;\r
break;\r
boolean toggle(int idx) {\r
boolean toggled = false;\r
if (idx >= 0 && idx < _data._expandedItems.length) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[idx];\r
+ Item item = (Item) _data._expandedItems[idx];\r
if (item._hasChildren) {\r
item._expanded = !item._expanded;\r
_data.updateExpandedItems();\r
}\r
}\r
\r
- TimeGraphItem getItem(Point pt) {\r
+ ITimeGraphEntry getEntry(Point pt) {\r
int idx = getItemIndexAtY(pt.y);\r
- return idx >= 0 ? (TimeGraphItem) _data._expandedItems[idx] : null;\r
+ return idx >= 0 ? _data._expandedItems[idx]._trace : null;\r
}\r
\r
long getTimeAtX(int x) {\r
boolean changed = false;\r
if (addSelection) {\r
if (idx >= 0 && idx < _data._expandedItems.length) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[idx];\r
+ Item item = (Item) _data._expandedItems[idx];\r
changed = (item._selected == false);\r
item._selected = true;\r
}\r
} else {\r
for (int i = 0; i < _data._expandedItems.length; i++) {\r
- TimeGraphItem item = (TimeGraphItem) _data._expandedItems[i];\r
+ Item item = (Item) _data._expandedItems[i];\r
if ((i == idx && !item._selected) || (idx == -1 && item._selected)) {\r
changed = true;\r
}\r
\r
public ITimeGraphEntry[] getExpandedElements() {\r
ArrayList<ITimeGraphEntry> elements = new ArrayList<ITimeGraphEntry>();\r
- for (TimeGraphItem item : _data._expandedItems) {\r
+ for (Item item : _data._expandedItems) {\r
elements.add(item._trace);\r
}\r
return elements.toArray(new ITimeGraphEntry[0]);\r
}\r
}\r
\r
- public void drawItems(Rectangle bounds, ITimeDataProvider timeProvider, TimeGraphItem[] items, int topIndex, int nameSpace, GC gc) {\r
+ public void drawItems(Rectangle bounds, ITimeDataProvider timeProvider, Item[] items, int topIndex, int nameSpace, GC gc) {\r
for (int i = topIndex; i < items.length; i++) {\r
- TimeGraphItem item = (TimeGraphItem) items[i];\r
+ Item item = (Item) items[i];\r
drawItem(item, bounds, timeProvider, i, nameSpace, gc);\r
}\r
fTimeGraphProvider.postDrawControl(bounds, gc);\r
* @param nameSpace the name space\r
* @param gc\r
*/\r
- protected void drawItem(TimeGraphItem item, Rectangle bounds, ITimeDataProvider timeProvider, int i, int nameSpace, GC gc) {\r
+ protected void drawItem(Item item, Rectangle bounds, ITimeDataProvider timeProvider, int i, int nameSpace, GC gc) {\r
ITimeGraphEntry entry = item._trace;\r
long time0 = timeProvider.getTime0();\r
long time1 = timeProvider.getTime1();\r
fTimeGraphProvider.postDrawEntry(entry, rect, gc);\r
}\r
\r
- protected void drawName(TimeGraphItem item, Rectangle bounds, GC gc) {\r
+ protected void drawName(Item item, Rectangle bounds, GC gc) {\r
boolean hasTimeEvents = item._trace.hasTimeEvents();\r
if (! hasTimeEvents) {\r
gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus));\r
\r
idx = getItemIndexAtY(e.y);\r
if (idx >= 0) {\r
- TimeGraphItem item = _data._expandedItems[idx];\r
+ Item item = _data._expandedItems[idx];\r
if (item._hasChildren && e.x < nameSpace && e.x < MARGIN + (item.level + 1) * EXPAND_SIZE) {\r
toggle(idx);\r
} else {\r
\r
}\r
\r
-}\r
-\r
-class ItemData {\r
- public TimeGraphItem[] _expandedItems = new TimeGraphItem[0];\r
- public TimeGraphItem[] _items = new TimeGraphItem[0];\r
- private ITimeGraphEntry _traces[] = new ITimeGraphEntry[0];\r
- private boolean traceFilter[] = new boolean[0];\r
- private Vector<ITimeGraphEntry> filteredOut = new Vector<ITimeGraphEntry>();\r
- public ITimeGraphPresentationProvider provider;\r
+ private class ItemData {\r
+ public Item[] _expandedItems = new Item[0];\r
+ public Item[] _items = new Item[0];\r
+ private ITimeGraphEntry _traces[] = new ITimeGraphEntry[0];\r
+ private boolean traceFilter[] = new boolean[0];\r
+ private Vector<ITimeGraphEntry> filteredOut = new Vector<ITimeGraphEntry>();\r
+ public ITimeGraphPresentationProvider provider;\r
\r
- public ItemData() {\r
- }\r
+ public ItemData() {\r
+ }\r
\r
- TimeGraphItem findItem(ITimeGraphEntry entry) {\r
- if (entry == null)\r
- return null;\r
+ Item findItem(ITimeGraphEntry entry) {\r
+ if (entry == null)\r
+ return null;\r
\r
- for (int i = 0; i < _items.length; i++) {\r
- TimeGraphItem item = _items[i];\r
- if (item._trace == entry) {\r
- return item;\r
+ for (int i = 0; i < _items.length; i++) {\r
+ Item item = _items[i];\r
+ if (item._trace == entry) {\r
+ return item;\r
+ }\r
}\r
+\r
+ return null;\r
}\r
\r
- return null;\r
- }\r
+ int findItemIndex(ITimeGraphEntry trace) {\r
+ if (trace == null)\r
+ return -1;\r
+\r
+ for (int i = 0; i < _expandedItems.length; i++) {\r
+ Item item = _expandedItems[i];\r
+ if (item._trace == trace) {\r
+ return i;\r
+ }\r
+ }\r
\r
- int findItemIndex(ITimeGraphEntry trace) {\r
- if (trace == null)\r
return -1;\r
+ }\r
\r
- for (int i = 0; i < _expandedItems.length; i++) {\r
- TimeGraphItem item = _expandedItems[i];\r
- if (item._trace == trace) {\r
- return i;\r
+ public void refreshData() {\r
+ List<Item> itemList = new ArrayList<Item>();\r
+ filteredOut.clear();\r
+ for (int i = 0; i < _traces.length; i++) {\r
+ ITimeGraphEntry entry = _traces[i];\r
+ refreshData(itemList, null, 0, entry);\r
}\r
+ _items = itemList.toArray(new Item[0]);\r
+ updateExpandedItems();\r
}\r
\r
- return -1;\r
- }\r
+ private void refreshData(List<Item> itemList, Item parent, int level, ITimeGraphEntry entry) {\r
+ Item item = new Item(entry, entry.getName(), level);\r
+ if (parent != null) {\r
+ parent.children.add(item);\r
+ }\r
+ item.itemHeight = provider.getItemHeight(entry);\r
+ itemList.add(item);\r
+ if (entry.hasChildren()) {\r
+ item._expanded = true;\r
+ item._hasChildren = true;\r
+ for (ITimeGraphEntry child : entry.getChildren()) {\r
+ refreshData(itemList, item, level + 1, child);\r
+ }\r
+ }\r
+ }\r
\r
- public void refreshData() {\r
- List<TimeGraphItem> itemList = new ArrayList<TimeGraphItem>();\r
- filteredOut.clear();\r
- for (int i = 0; i < _traces.length; i++) {\r
- ITimeGraphEntry entry = _traces[i];\r
- refreshData(itemList, null, 0, entry);\r
- }\r
- _items = itemList.toArray(new TimeGraphItem[0]);\r
- updateExpandedItems();\r
- }\r
-\r
- private void refreshData(List<TimeGraphItem> itemList, TimeGraphItem parent, int level, ITimeGraphEntry entry) {\r
- TimeGraphItem item = new TimeGraphItem(entry, entry.getName(), level);\r
- if (parent != null) {\r
- parent.children.add(item);\r
- }\r
- item.itemHeight = provider.getItemHeight(entry);\r
- itemList.add(item);\r
- if (entry.hasChildren()) {\r
- item._expanded = true;\r
- item._hasChildren = true;\r
- for (ITimeGraphEntry child : entry.getChildren()) {\r
- refreshData(itemList, item, level + 1, child);\r
+ public void updateExpandedItems() {\r
+ List<Item> expandedItemList = new ArrayList<Item>();\r
+ for (int i = 0; i < _traces.length; i++) {\r
+ ITimeGraphEntry entry = _traces[i];\r
+ Item item = findItem(entry);\r
+ refreshExpanded(expandedItemList, item);\r
}\r
+ _expandedItems = expandedItemList.toArray(new Item[0]);\r
}\r
- }\r
\r
- public void updateExpandedItems() {\r
- List<TimeGraphItem> expandedItemList = new ArrayList<TimeGraphItem>();\r
- for (int i = 0; i < _traces.length; i++) {\r
- ITimeGraphEntry entry = _traces[i];\r
- TimeGraphItem item = findItem(entry);\r
- refreshExpanded(expandedItemList, item);\r
+ private void refreshExpanded(List<Item> expandedItemList, Item item) {\r
+ expandedItemList.add(item);\r
+ if (item._hasChildren && item._expanded) {\r
+ for (Item child : item.children) {\r
+ refreshExpanded(expandedItemList, child);\r
+ }\r
+ }\r
}\r
- _expandedItems = expandedItemList.toArray(new TimeGraphItem[0]);\r
- }\r
\r
- private void refreshExpanded(List<TimeGraphItem> expandedItemList, TimeGraphItem item) {\r
- expandedItemList.add(item);\r
- if (item._hasChildren && item._expanded) {\r
- for (TimeGraphItem child : item.children) {\r
- refreshExpanded(expandedItemList, child);\r
+ public void expandItem(int idx) {\r
+ if (idx < 0 || idx >= _expandedItems.length)\r
+ return;\r
+ Item item = (Item) _expandedItems[idx];\r
+ if (item._hasChildren && !item._expanded) {\r
+ item._expanded = true;\r
+ updateExpandedItems();\r
}\r
}\r
- }\r
\r
- public void expandItem(int idx) {\r
- if (idx < 0 || idx >= _expandedItems.length)\r
- return;\r
- TimeGraphItem item = (TimeGraphItem) _expandedItems[idx];\r
- if (item._hasChildren && !item._expanded) {\r
- item._expanded = true;\r
- updateExpandedItems();\r
+ public void refreshData(ITimeGraphEntry traces[]) {\r
+ if (traces == null || traces.length == 0) {\r
+ traceFilter = null;\r
+ } else if (traceFilter == null || traces.length != traceFilter.length) {\r
+ traceFilter = new boolean[traces.length];\r
+ java.util.Arrays.fill(traceFilter, true);\r
+ }\r
+\r
+ _traces = traces;\r
+ refreshData();\r
}\r
- }\r
\r
- public void refreshData(ITimeGraphEntry traces[]) {\r
- if (traces == null || traces.length == 0) {\r
- traceFilter = null;\r
- } else if (traceFilter == null || traces.length != traceFilter.length) {\r
- traceFilter = new boolean[traces.length];\r
- java.util.Arrays.fill(traceFilter, true);\r
+ public ITimeGraphEntry[] getTraces() {\r
+ return _traces;\r
}\r
\r
- _traces = traces;\r
- refreshData();\r
- }\r
+ public boolean[] getTraceFilter() {\r
+ return traceFilter;\r
+ }\r
\r
- public ITimeGraphEntry[] getTraces() {\r
- return _traces;\r
+ public Vector<ITimeGraphEntry> getFilteredOut() {\r
+ return filteredOut;\r
+ }\r
}\r
\r
- public boolean[] getTraceFilter() {\r
- return traceFilter;\r
- }\r
+ private class Item {\r
+ public boolean _expanded;\r
+ public boolean _selected;\r
+ public boolean _hasChildren;\r
+ public int itemHeight;\r
+ public int level;\r
+ public List<Item> children;\r
+ public String _name;\r
+ public ITimeGraphEntry _trace;\r
\r
- public Vector<ITimeGraphEntry> getFilteredOut() {\r
- return filteredOut;\r
+ public Item(ITimeGraphEntry trace, String name, int level) {\r
+ this._trace = trace;\r
+ this._name = name;\r
+ this.level = level;\r
+ this.children = new ArrayList<Item>();\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return _name;\r
+ }\r
}\r
+\r
}\r
+\r