Mercurial > projects > dwt-addons
diff dwtx/jface/viewers/TreeViewer.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 7ffeace6c47f |
children |
line wrap: on
line diff
--- a/dwtx/jface/viewers/TreeViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TreeViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -33,9 +33,6 @@ import dwtx.jface.viewers.TreeExpansionEvent; import dwtx.jface.viewers.ViewerCell; -import tango.util.collection.LinkSeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.DWT; import dwt.events.DisposeEvent; @@ -54,6 +51,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -360,7 +358,7 @@ /* * (non-Javadoc) Method declared in AbstractTreeViewer. */ - protected override void setSelection(SeqView!(Item) items) { + protected override void setSelection(List items) { Item[] current = getSelection(getTree()); @@ -369,7 +367,7 @@ return; } - getTree().setSelection( cast(TreeItem[]) items.toArray()); + getTree().setSelection( arraycast!(TreeItem)( items.toArray())); } /* @@ -440,25 +438,17 @@ public void setChildCount(Object elementOrTreePath, int count) { if (checkBusy()) return; - preservingSelection(new class(elementOrTreePath,count) Runnable { - Object elementOrTreePath_; - int count_; - this(Object a,int b){ - elementOrTreePath_=a; - count_=b; + preservingSelection( dgRunnable((Object elementOrTreePath_, int count_) { + if (internalIsInputOrEmptyPath(elementOrTreePath_)) { + getTree().setItemCount(count_); + return; } - public void run() { - if (internalIsInputOrEmptyPath(elementOrTreePath_)) { - getTree().setItemCount(count_); - return; - } - Widget[] items = internalFindItems(elementOrTreePath_); - for (int i = 0; i < items.length; i++) { - TreeItem treeItem = cast(TreeItem) items[i]; - treeItem.setItemCount(count_); - } + Widget[] items = internalFindItems(elementOrTreePath_); + for (int i = 0; i < items.length; i++) { + TreeItem treeItem = cast(TreeItem) items[i]; + treeItem.setItemCount(count_); } - }); + }, elementOrTreePath,count )); } /** @@ -885,16 +875,13 @@ if (checkBusy()) return; preservingSelection(new class((cast(TreeSelection) getSelection()).getPaths(),parentOrTreePath_,index_) Runnable { - Seq!(TreePath) oldSelection; + List oldSelection; Object parentOrTreePath; int index; this(TreePath[] a,Object b,int c){ parentOrTreePath=b; index=c; - oldSelection = new LinkSeq!(TreePath); - foreach( p; a){ - oldSelection.append( p ); - } + oldSelection = new LinkedList(Arrays.asList(a)); } public void run() { TreePath removedPath = null; @@ -926,20 +913,21 @@ } if (removedPath !is null) { bool removed = false; - int delIdx = 0; - foreach ( path; oldSelection.dup ) { + for (Iterator it = oldSelection.iterator(); it + .hasNext();) { + TreePath path = cast(TreePath) it.next(); if (path.startsWith(removedPath, getComparer())) { - oldSelection.removeAt(delIdx); + it.remove(); removed = true; } - delIdx++; } if (removed) { setSelection(new TreeSelection( - oldSelection.toArray(), getComparer()), + arraycast!(TreePath)( oldSelection + .toArray(new TreePath[oldSelection + .size()])), getComparer()), false); } - } } });