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

The following are Jave code examples for showing how to use getItems() 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.
+ Save this method
Example 1
Project: avro-schema-editor   File: CountTreeItemsHandler.java   View Source Code Vote up 6 votes
protected void computeAndDisplayStats(AvroSchemaEditor editor) {
	
	SchemaViewer masterViewer = editor.getContentPart().getSchemaViewer(AvroContext.Kind.MASTER);
	TreeViewer treeViewer = masterViewer.getTreeViewer();
	AvroNode inputNode = (AvroNode) treeViewer.getInput();
	NodeType inputType = inputNode.getType();
	String name = AttributeUtil.getNameFromAttribute(inputNode);
	
	NodeStats stats = new NodeStats("Compute stats of " + inputType.toString().toLowerCase() 
			+ " " + name + " from editor " + editor.getName());
	stats.start();
	
	Tree tree = treeViewer.getTree();
	
	TreeItem[] items = tree.getItems();
	for (TreeItem item : items) {
		visitTreeItem(item, stats);
	}
	
	stats.finish();
	AvroSchemaLogger.logStats(stats, false);
	
}
 
Example 2
Project: AndroidRobot   File: RobotTreeUtil.java   View Source Code Vote up 6 votes
public static Vector<String> getSelections(Tree tree,String prj){
	Vector<String> vecFiles = new Vector<String>();
	TreeItem[] tiRoot = tree.getItems();
	for(int i = 0;i<tiRoot.length;i++){
		if(tiRoot[i].getText().equals(prj))
			if(tiRoot[i].getChecked() == true){
				//Scripts
				TreeItem tiScript = tiRoot[i].getItems()[2];
				TreeItem[] tiCases = tiScript.getItems();
				for(int j =0;j<tiCases.length;j++)
					if(tiCases[j].getChecked()){
						vecFiles.add(System.getProperty("user.dir") + 
								"/workspace/"+tiRoot[i].getText()+"/Scripts/"+tiCases[j].getText());
					}
			}else
				break;
		else
			continue;
	}
	return vecFiles;
}
 
Example 3
Project: bdf2   File: SelectClassPage.java   View Source Code Vote up 5 votes
private void updatePageComplete(Tree tree) {
	TreeItem[] rootItems = tree.getItems();
	nodeListManager.clearSelectedNodeList();
	getSelectedItems(rootItems, nodeListManager.getSelectedNodeList());
	if (nodeListManager.getSelectedNodeList().size() > 0) {
		setPageComplete(true);
	} else {
		setPageComplete(false);
	}
}
 
Example 4
Project: bts   File: TreeViewerNavigator.java   View Source Code Vote up 5 votes
private TreeItem[] getSiblings(TreeItem currentItem) {
	Tree tree = viewer.getTree();
	TreeItem parentItem = currentItem.getParentItem();
	if (parentItem != null)
		return parentItem.getItems();
	return tree.getItems();
}
 
Example 5
Project: bts   File: TreeViewerNavigator.java   View Source Code Vote up 5 votes
private TreeItem getCurrentItem(boolean forward) {
	Tree tree = viewer.getTree();
	TreeItem[] selection = tree.getSelection();
	if (selection.length == 0) {
		selection = tree.getItems();
	}

	TreeItem nextItem = null;
	if (selection.length > 0) {
		nextItem = forward ? selection[0] : selection[selection.length - 1];
	}
	return nextItem;
}
 
Example 6
Project: AndroidRobot   File: RobotTreeUtil.java   View Source Code Vote up 5 votes
public static TreeItem getNodeByName(Tree tree,String prj){
	if(tree == null)
		return null;
	
	TreeItem[] tiRoot = tree.getItems();
	for(int i = 0;i<tiRoot.length;i++){
		if(tiRoot[i].getText().equals(prj)){
			return tiRoot[i];
		}
	}
	return null;
}
 
Example 7
Project: AndroidRobot   File: RobotTreeUtil.java   View Source Code Vote up 5 votes
public static Vector<TreeItem> getSelectElements(Tree tree){
	Vector<TreeItem> vecTreeItem = new Vector(); 
	TreeItem[] tiRoot = tree.getItems();
	for(int i = 0;i<tiRoot.length;i++){
		getSelection(vecTreeItem,tiRoot[i]);
	}
	return vecTreeItem;
}
 
Example 8
Project: PDFReporter-Studio   File: JDReportOutlineView.java   View Source Code Vote up 5 votes
/**
 * Sets the contents.
 * 
 * @param contents
 *          the new contents
 */
public void setContents(Object contents) {
	if (getViewer().getEditPartFactory() != null){
		getViewer().setContents(contents);
	}
	if (outline instanceof Tree) {
		Tree tree = (Tree) outline;
		if (!tree.isDisposed() && tree.getItems() != null && tree.getItems().length > 0)
			tree.getItem(0).setExpanded(true);
	}
}
 
Example 9
Project: erflute   File: ERDiagramOutlinePage.java   View Source Code Vote up 5 votes
public void setFilterText(String filterText) {
    editPartFactory.setFilterText(filterText);
    viewer.setContents(diagram);
    final Tree tree = (Tree) viewer.getControl();
    final TreeItem[] items = tree.getItems();
    expand(items);
    final TreeItem[] tableItems = items[0].getItems();
    if (tableItems.length >= 1) {
        tree.setSelection(tableItems[0]);
    }
}
 
Example 10
Project: erflute   File: ERDiagramOutlinePage.java   View Source Code Vote up 4 votes
public void selectSelection() {
    final IStructuredSelection sel = (IStructuredSelection) getViewer().getSelection();
    Object firstElement = sel.getFirstElement();
    if (firstElement instanceof ERDiagramOutlineEditPart) {
        final Tree tree = (Tree) viewer.getControl();
        final TreeItem[] items = tree.getItems();
        expand(items);
        final TreeItem[] tableItems = items[0].getItems();
        if (tableItems.length >= 1) {
            final Object data = tableItems[0].getData();
            firstElement = data;
        }
    }
    if (firstElement instanceof TableOutlineEditPart) {
        final Object model = ((TableOutlineEditPart) firstElement).getModel();
        final ERTable table = (ERTable) model;

        final MainDiagramEditor editor = ((MainDiagramEditor) diagram.getEditor().getActiveEditor());
        if (!diagram.isVirtual()) {
            editor.reveal(table);
            return;
        }

        final ERVirtualDiagram erModel = table.getDiagram().findModelByTable(table);
        if (erModel != null) {
            final OpenERModelCommand command = new OpenERModelCommand(diagram, erModel);
            command.setTable(table.toMaterialize());
            command.execute(); // コマンドスタックには積まないで実行する。ファイル編集中にしないため。

            // TODO ymd アウトラインツリー上の仮想ダイアグラムを選択するためにのみある。
            // この処理があることで、クイックアウトライン検索→テーブル選択がバグるのでコメントにした。不要なことを確信したら、削除する。
            //                final ERDiagramOutlineEditPart contents =
            //                        (ERDiagramOutlineEditPart) diagram.getEditor().getOutlinePage().getViewer().getContents();
            //                if (contents != null) {
            //                    final ERVirtualDiagramSetOutlineEditPart virtualDiagramSetOutlineEditPart =
            //                            (ERVirtualDiagramSetOutlineEditPart) contents.getChildren().get(0);
            //                    @SuppressWarnings("unchecked")
            //                    final List<ERVirtualDiagramOutlineEditPart> parts = virtualDiagramSetOutlineEditPart.getChildren();
            //                    for (final ERVirtualDiagramOutlineEditPart part : parts) {
            //                        if (part.getModel().equals(erModel)) {
            //                            final ISelection selection = new StructuredSelection(part);
            //                            diagram.getEditor().getOutlinePage().setSelection(selection);
            //                        }
            //                    }
            //                }
        } else {
            // ここでrevealしないと、メインダイアグラムでtableが選択不可状態になる。理由は分からない。
            editor.reveal(table);
            Activator.showMessageDialog("\"" + table.getPhysicalName() + "\"does not exist on the virtual diagram.");
        }
    }
}