diff options
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java')
-rw-r--r-- | systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java | 252 |
1 files changed, 126 insertions, 126 deletions
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java index fc6526a7d9..c9814f484e 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java @@ -21,130 +21,130 @@ import org.eclipse.jface.viewers.Viewer; public class ListTreeContentProvider implements ITreeContentProvider { - @Override - public Object[] getChildren(Object parentElement) { - - ArrayList<Object> output = new ArrayList<>(); - - if (parentElement instanceof ICContainer) { - try { - Object[] list =((ICContainer) parentElement).getChildren(); - for (Object item : list) { - if (item instanceof ICContainer) { - if (checkForValidChildren((ICContainer) item)) - output.add(item); - } else if (item instanceof ICElement) { - ICElement el = (ICElement) item; - if (SystemTapLaunchShortcut.validElement(el)) - output.add(el); - } - - - } - - return output.toArray(); - } catch (CModelException e) { - e.printStackTrace(); - } - } - return null; - } - - /** - * A container is valid if any of its children are valid c/cpp elements - * or if it contains another container for which the above holds - * @param cont - * @return - */ - private boolean checkForValidChildren(ICContainer cont) { - try { - for (ICElement child : cont.getChildren()) { - - if ((child != null) - && SystemTapLaunchShortcut.validElement(child)) - return true; - if ((child instanceof ICContainer) - && checkForValidChildren((ICContainer) child)) { - return true; - } - } - } catch (CModelException e) { - e.printStackTrace(); - } - - return false; - - } - - @Override - public Object getParent(Object element) { - if (element instanceof ICElement) { - return ((ICElement)element).getAncestor(ICElement.C_CCONTAINER); - } - return null; - } - - @Override - public boolean hasChildren(Object element) { - if (element instanceof ICContainer) { - try { - if (((ICContainer) element).getChildren().length > 0) - return true; - } catch (CModelException e) { - e.printStackTrace(); - } - } - return false; - } - - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof List) { - for (Object element : (List<?>) inputElement) - if (element instanceof ICContainer) - try { - ICElement[] array = ((ICContainer) element).getChildren(); - ArrayList<ICElement> output = new ArrayList<>(); - - for (ICElement item : array) { - if ((item instanceof ICContainer) - && checkForValidChildren((ICContainer) item)) { - output.add(item); - } - - if (SystemTapLaunchShortcut.validElement(item)) { - output.add(item); - } - } - return output.toArray(); - } catch (CModelException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public void dispose() { - - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - - public Object[] findElements(Object inputElement) { - ArrayList<Object> output = new ArrayList<>(); - - if (inputElement instanceof List) { - for (Object element : (List<?>) inputElement) { - Object[] list = (getChildren(element)); - for (Object o : list) { - output.add(o); - } - } - } - return output.toArray(); - } + @Override + public Object[] getChildren(Object parentElement) { + + ArrayList<Object> output = new ArrayList<>(); + + if (parentElement instanceof ICContainer) { + try { + Object[] list =((ICContainer) parentElement).getChildren(); + for (Object item : list) { + if (item instanceof ICContainer) { + if (checkForValidChildren((ICContainer) item)) + output.add(item); + } else if (item instanceof ICElement) { + ICElement el = (ICElement) item; + if (SystemTapLaunchShortcut.validElement(el)) + output.add(el); + } + + + } + + return output.toArray(); + } catch (CModelException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * A container is valid if any of its children are valid c/cpp elements + * or if it contains another container for which the above holds + * @param cont + * @return + */ + private boolean checkForValidChildren(ICContainer cont) { + try { + for (ICElement child : cont.getChildren()) { + + if ((child != null) + && SystemTapLaunchShortcut.validElement(child)) + return true; + if ((child instanceof ICContainer) + && checkForValidChildren((ICContainer) child)) { + return true; + } + } + } catch (CModelException e) { + e.printStackTrace(); + } + + return false; + + } + + @Override + public Object getParent(Object element) { + if (element instanceof ICElement) { + return ((ICElement)element).getAncestor(ICElement.C_CCONTAINER); + } + return null; + } + + @Override + public boolean hasChildren(Object element) { + if (element instanceof ICContainer) { + try { + if (((ICContainer) element).getChildren().length > 0) + return true; + } catch (CModelException e) { + e.printStackTrace(); + } + } + return false; + } + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof List) { + for (Object element : (List<?>) inputElement) + if (element instanceof ICContainer) + try { + ICElement[] array = ((ICContainer) element).getChildren(); + ArrayList<ICElement> output = new ArrayList<>(); + + for (ICElement item : array) { + if ((item instanceof ICContainer) + && checkForValidChildren((ICContainer) item)) { + output.add(item); + } + + if (SystemTapLaunchShortcut.validElement(item)) { + output.add(item); + } + } + return output.toArray(); + } catch (CModelException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override + public void dispose() { + + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + + public Object[] findElements(Object inputElement) { + ArrayList<Object> output = new ArrayList<>(); + + if (inputElement instanceof List) { + for (Object element : (List<?>) inputElement) { + Object[] list = (getChildren(element)); + for (Object o : list) { + output.add(o); + } + } + } + return output.toArray(); + } } |