Search in sources :

Example 1 with AdaptableList

use of org.eclipse.ui.model.AdaptableList in project ecf by eclipse.

the class WizardContentProvider method getChildren.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
	 */
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof WizardCollectionElement) {
        ArrayList list = new ArrayList();
        WizardCollectionElement element = (WizardCollectionElement) parentElement;
        Object[] childCollections = element.getChildren();
        for (int i = 0; i < childCollections.length; i++) {
            handleChild(childCollections[i], list);
        }
        Object[] childWizards = element.getWizards();
        for (int i = 0; i < childWizards.length; i++) {
            handleChild(childWizards[i], list);
        }
        // flatten lists with only one category
        if (list.size() == 1 && list.get(0) instanceof WizardCollectionElement)
            return getChildren(list.get(0));
        return list.toArray();
    } else if (parentElement instanceof AdaptableList) {
        AdaptableList aList = (AdaptableList) parentElement;
        Object[] children = aList.getChildren();
        ArrayList list = new ArrayList(children.length);
        for (int i = 0; i < children.length; i++) {
            handleChild(children[i], list);
        }
        // (flatten list)
        if (list.size() == 1 && list.get(0) instanceof WizardCollectionElement)
            return getChildren(list.get(0));
        return list.toArray();
    } else
        return new Object[0];
}
Also used : AdaptableList(org.eclipse.ui.model.AdaptableList) ArrayList(java.util.ArrayList)

Example 2 with AdaptableList

use of org.eclipse.ui.model.AdaptableList in project tracecompass by tracecompass.

the class TraceFileSystemElement method getAllChildren.

/**
 * Get all the TraceFileSystemElements recursively.
 *
 * @param result
 *            the list accumulating the result
 */
public void getAllChildren(List<TraceFileSystemElement> result) {
    AdaptableList files = getFiles();
    for (Object file : files.getChildren()) {
        result.add((TraceFileSystemElement) file);
    }
    AdaptableList folders = getFolders();
    for (Object folder : folders.getChildren()) {
        TraceFileSystemElement traceElementFolder = (TraceFileSystemElement) folder;
        traceElementFolder.getAllChildren(result);
    }
}
Also used : AdaptableList(org.eclipse.ui.model.AdaptableList)

Aggregations

AdaptableList (org.eclipse.ui.model.AdaptableList)2 ArrayList (java.util.ArrayList)1