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

The following examples show how to use org.eclipse.swt.widgets.Tree#getItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RobotTreeUtil.java    From AndroidRobot with Apache License 2.0 6 votes vote down vote up
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 2
Source File: TreeUtil.java    From hop with Apache License 2.0 5 votes vote down vote up
public static final TreeItem findTreeItem( Tree tree, String[] path ) {
  TreeItem[] items = tree.getItems();
  for ( int i = 0; i < items.length; i++ ) {
    TreeItem treeItem = findTreeItem( items[ i ], path, 0 );
    if ( treeItem != null ) {
      return treeItem;
    }
  }
  return null;
}
 
Example 3
Source File: ERDiagramOutlinePage.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public void setFilterText(String filterText) {
		editPartFactory.setFilterText(filterText);
		viewer.setContents(diagram);
		Tree tree = (Tree)viewer.getControl();
		TreeItem[] items = tree.getItems();
		expand(items);
		TreeItem[] tableItems = items[0].getItems();
		if (tableItems.length >= 1) {
			tree.setSelection(tableItems[0]);
		}
//		viewer.getContents().getChildren();



//		viewer.flush();
//		viewer.getEditPartFactory()
//		if (filterText == null) {
//			filterText = "";
//		}
//		this.filterText = filterText;
//		getTreeViewer().refresh();
//		getTreeViewer().expandAll();
//		JavaScriptElement element = getFirstElement(model, filterText);
//		if(element != null){
//			getViewer().setSelection(new StructuredSelection(element), true);
//		}
	}
 
Example 4
Source File: TreeUtil.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static final TreeItem findTreeItem( Tree tree, String[] path ) {
  TreeItem[] items = tree.getItems();
  for ( int i = 0; i < items.length; i++ ) {
    TreeItem treeItem = findTreeItem( items[i], path, 0 );
    if ( treeItem != null ) {
      return treeItem;
    }
  }
  return null;
}
 
Example 5
Source File: TreeMemory.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Expand of collapse all TreeItems in the complete tree based on the values stored in memory.
 *
 * @param tree
 *          The tree to format.
 */
public static void setExpandedFromMemory( Tree tree, String treeName ) {
  TreeItem[] items = tree.getItems();
  for ( int i = 0; i < items.length; i++ ) {
    setExpandedFromMemory( tree, treeName, items[i] );
  }
}
 
Example 6
Source File: SpoonSlave.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public TreeItem getTreeItem( Tree tree ) {
  TreeItem[] items = tree.getItems();
  for ( TreeItem item : items ) {
    TreeItem treeItem = findTreeItem( item, 0 );
    if ( treeItem != null ) {
      return treeItem;
    }
  }
  return null;
}
 
Example 7
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateSelectionIfNothingSelected(Tree tree) {
    TreeItem[] sel = tree.getSelection();
    if (sel == null || sel.length == 0) {
        TreeItem[] items = tree.getItems();
        if (items != null && items.length > 0) {
            tree.setSelection(items[0]);
        }
    }
}
 
Example 8
Source File: ColumnChooserDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the tree contains an item with the given label return it
 */
private TreeItem getTreeItem(Tree tree, String label) {
	for (TreeItem treeItem : tree.getItems()) {
		if (treeItem.getText().equals(label)) {
			return treeItem;
		}
	}
	return null;
}
 
Example 9
Source File: ColumnChooserDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the tree contains an item with the given label return it
 */
private TreeItem getTreeItem(Tree tree, String label) {
	for (TreeItem treeItem : tree.getItems()) {
		if (treeItem.getText().equals(label)) {
			return treeItem;
		}
	}
	return null;
}
 
Example 10
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Object[] getRootElements(TreeViewer viewer) {
	Tree t= viewer.getTree();
	Item[] roots= t.getItems();
	Object[] elements= new Object[roots.length];
	for (int i = 0; i < elements.length; i++) {
		elements[i]= roots[i].getData();
	}
	return elements;
}
 
Example 11
Source File: ERDiagramOutlinePage.java    From erflute with Apache License 2.0 5 votes vote down vote up
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 12
Source File: RobotTreeUtil.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
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 13
Source File: RobotTreeUtil.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
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 14
Source File: TreeViewerNavigator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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 15
Source File: TreeViewerNavigator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private TreeItem[] getSiblings(TreeItem currentItem) {
	Tree tree = viewer.getTree();
	TreeItem parentItem = currentItem.getParentItem();
	if (parentItem != null)
		return parentItem.getItems();
	return tree.getItems();
}
 
Example 16
Source File: TreeMemory.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Expand of collapse all TreeItems in the complete tree based on the values stored in memory.
 *
 * @param tree The tree to format.
 */
public static void setExpandedFromMemory( Tree tree, String treeName ) {
  TreeItem[] items = tree.getItems();
  for ( int i = 0; i < items.length; i++ ) {
    setExpandedFromMemory( tree, treeName, items[ i ] );
  }
}
 
Example 17
Source File: ERDiagramOutlinePage.java    From erflute with Apache License 2.0 4 votes vote down vote up
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.");
        }
    }
}
 
Example 18
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public static void maybeSetSelection(Tree tt, int itemIndex) {
  TreeItem[] items = tt.getItems();
  if (itemIndex >= 0 && itemIndex < items.length) {
    tt.setSelection(items[itemIndex]);
  }
}
 
Example 19
Source File: LaborResultsComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private void getAllItems(Tree tree, List<TreeItem> allItems){
	for (TreeItem item : tree.getItems()) {
		getAllItems(item, allItems);
	}
}
 
Example 20
Source File: ERDiagramOutlinePage.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
public void selectSelection() {
	IStructuredSelection sel = (IStructuredSelection) getViewer().getSelection();
	Object firstElement = sel.getFirstElement();
	if (firstElement instanceof ERDiagramOutlineEditPart) {
		Tree tree = (Tree)viewer.getControl();
		TreeItem[] items = tree.getItems();
		expand(items);
		TreeItem[] tableItems = items[0].getItems();
		if (tableItems.length >= 1) {
			Object data = tableItems[0].getData();
			firstElement = data;
		}
	}
	if (firstElement instanceof TableOutlineEditPart) {
		Object model = ((TableOutlineEditPart)firstElement).getModel();
		ERTable table = (ERTable) model;

		if (diagram.getCurrentErmodel() == null) {
			// �S�̃r���[
			ERDiagramEditor editor = ((ERDiagramEditor) diagram.getEditor().getActiveEditor());
			editor.reveal(table);
			return;
		}

		ERModel erModel = table.getDiagram().findModelByTable(table);
		if (erModel != null) {

			OpenERModelCommand command = new OpenERModelCommand(diagram, erModel);
			command.setTable(table);
			this.getViewer().getEditDomain().getCommandStack().execute(command);

			// �A�E�g���C���r���[�̗v�f��I��
			ERDiagramOutlineEditPart contents = (ERDiagramOutlineEditPart) diagram.getEditor().getOutlinePage().getViewer().getContents();
			if (contents != null) {
				List<ERModelOutlineEditPart> parts = ((ERModelSetOutlineEditPart) contents.getChildren().get(0)).getChildren();
				for (ERModelOutlineEditPart part : parts) {
					if (part.getModel().equals(erModel)) {
						ISelection selection = new StructuredSelection(part);
						diagram.getEditor().getOutlinePage().setSelection(selection);
					}
				}
			}

		} else {
			Activator.showMessageDialog(table.getPhysicalName() + " �e�[�u���͂��̃_�C�A�O�����ɂ��z�u����Ă��܂���B");
		}

	}
}