Java Code Examples for org.eclipse.swt.widgets.Tree.getItemCount()

The following are Jave code examples for showing how to use getItemCount() of the org.eclipse.swt.widgets.Tree class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PDFReporter-Studio   File: JDReportOutlineView.java   Source Code and License Vote up 5 votes
public void setTreeSelection(ISelection s) {
	if (s != null && s instanceof StructuredSelection && outline instanceof Tree) {
		StructuredSelection sel = (StructuredSelection) s;
		List<?> sobj = sel.toList();
		List<TreeItem> toSelect = new ArrayList<TreeItem>();
		Tree tree = (Tree) outline;
		tree.getItemCount();
		checkItems(tree.getItems(), toSelect, sobj);
		if (!toSelect.isEmpty())
			tree.setSelection(toSelect.toArray(new TreeItem[toSelect.size()]));
	} else
		setSelection(s);
}
 
Example 2
Project: mytourbook   File: ProfileDropAdapter.java   Source Code and License Vote up 4 votes
private boolean reorderMapProvider(final TVIMapProvider droppedMP) {

		final Tree mpTree = fMpViewer.getTree();
		final TVIMapProviderRoot rootItem = fDialogMPProfile.getRootItem();

		// remove drop item before it is inserted
		fMpViewer.remove(droppedMP);

		int itemIndex;

		if (fTargetTreeItem == null) {

			// a tree item is not hovered

			fMpViewer.add(rootItem, droppedMP);
			itemIndex = mpTree.getItemCount() - 1;

		} else {

			// get index of the target in the table
			itemIndex = mpTree.indexOf((TreeItem) fTargetTreeItem);
			if (itemIndex == -1) {
				return false;
			}

			// insert into the tree
			final int location = getCurrentLocation();
			if (location == LOCATION_BEFORE) {
				fMpViewer.insert(rootItem, droppedMP, itemIndex);
			} else if (location == LOCATION_AFTER) {
				fMpViewer.insert(rootItem, droppedMP, ++itemIndex);
			}
		}

		// reselect filter item
		fMpViewer.setSelection(new StructuredSelection(droppedMP));

		// set focus and selection
		final TreeItem droppedTreeItem = mpTree.getItem(itemIndex);

		mpTree.select(droppedTreeItem);
		mpTree.setFocus();

		fDialogMPProfile.updateLiveView();

		return true;
	}
 
Example 3
Project: mytourbook   File: ProfileDropAdapter.java   Source Code and License Vote up 4 votes
private boolean reorderMapProvider(final TVIMapProvider droppedMP) {

		final Tree mpTree = fMpViewer.getTree();
		final TVIMapProviderRoot rootItem = fDialogMPProfile.getRootItem();

		// remove drop item before it is inserted
		fMpViewer.remove(droppedMP);

		int itemIndex;

		if (fTargetTreeItem == null) {

			// a tree item is not hovered

			fMpViewer.add(rootItem, droppedMP);
			itemIndex = mpTree.getItemCount() - 1;

		} else {

			// get index of the target in the table
			itemIndex = mpTree.indexOf((TreeItem) fTargetTreeItem);
			if (itemIndex == -1) {
				return false;
			}

			// insert into the tree
			final int location = getCurrentLocation();
			if (location == LOCATION_BEFORE) {
				fMpViewer.insert(rootItem, droppedMP, itemIndex);
			} else if (location == LOCATION_AFTER) {
				fMpViewer.insert(rootItem, droppedMP, ++itemIndex);
			}
		}

		// reselect filter item
		fMpViewer.setSelection(new StructuredSelection(droppedMP));

		// set focus and selection
		final TreeItem droppedTreeItem = mpTree.getItem(itemIndex);

		mpTree.select(droppedTreeItem);
		mpTree.setFocus();

		fDialogMPProfile.updateLiveView();

		return true;
	}