Java 类org.eclipse.swt.widgets.Tree 实例源码

项目:n4js    文件:CustomElementSelectionForm.java   
/**
 * Create the composite.
 */
public CustomElementSelectionForm(Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout(2, false));

    treeViewer = new TreeViewer(this, SWT.BORDER);
    Tree tree = getTreeViewer().getTree();

    // Set a minimum height to prevent weird dialog dimensions
    tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).minSize(0, 200).create());

    elementLabel = new Label(this, SWT.NONE);
    elementLabel.setLayoutData(GridDataFactory.swtDefaults().create());
    elementLabel.setText("New Label");

    elementInput = new SuffixText(this, SWT.BORDER);// new Text(this, SWT.BORDER);
    elementInput.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
}
项目:n4js    文件:TreeViewerBuilder.java   
@Override
protected TreeViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout,
        final int style) {
    final TreeViewer viewer = new TreeViewer(parent, virual ? (style | VIRTUAL) : style);
    final Tree tree = viewer.getTree();
    tree.setLinesVisible(linesVisible);
    tree.setHeaderVisible(headerVisible);

    int columnIndex = 0;
    for (final String columnLabel : columnLabels) {

        final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, NONE);
        final TreeColumn column = viewerColumn.getColumn();
        columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
        column.setText(columnLabel);
        column.setMoveable(moveable);

        columnIndex++;
    }

    return viewer;
}
项目:n4js    文件:TestResultsView.java   
@Override
protected boolean shouldCreateToolTip(final Event e) {
    this.lastDescriptor = null;
    if (e.widget instanceof Tree) {
        final Tree tree = (Tree) e.widget;
        final TreeItem item = tree.getItem(new Point(e.x, e.y));

        if (null != item && item.getData() instanceof ResultNode) {
            final ResultNode node = (ResultNode) item.getData();
            if (node.getElement() instanceof TestCase) {
                final URI uri = ((TestCase) node.getElement()).getURI();
                if (null != uri) {
                    final StyledTextDescriptor descriptor = getDescriptor(uri);
                    if (null != descriptor) {
                        this.lastDescriptor = descriptor;
                    }
                }
            }
        }
    }

    return null != this.lastDescriptor;
}
项目:neoscada    文件:SecurityEditor.java   
protected void createColumns ( final Tree tree )
{
    final TreeColumn typeFilterColumn = new TreeColumn ( tree, SWT.NONE );
    typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
    typeFilterColumn.setResizable ( true );
    typeFilterColumn.setWidth ( 200 );

    final TreeColumn idFilterColumn = new TreeColumn ( tree, SWT.NONE );
    idFilterColumn.setText ( getString ( "_UI_IdFilterColumn_label" ) ); //$NON-NLS-1$
    idFilterColumn.setResizable ( true );
    idFilterColumn.setWidth ( 200 );

    final TreeColumn actionFilterColumn = new TreeColumn ( tree, SWT.NONE );
    actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
    actionFilterColumn.setResizable ( true );
    actionFilterColumn.setWidth ( 200 );
}
项目:iTrace-Archive    文件:GazeHandlerFactory.java   
/**
 * Creates and returns a new IGazeHandler object from the specified object
 * and partRef, or returns null if no handler object is defined for that object.
 */
public static IGazeHandler createHandler(Object target,
        IWorkbenchPartReference partRef) {

    // create gaze handler for a StyledText widget within an EditorPart
    if (target instanceof StyledText &&
            partRef instanceof IEditorReference) {
        return new StyledTextGazeHandler(target); //can go back to using partRef

    } else if (target instanceof Browser) {
        //create gaze handler for a Browser Stack overflow and Bug Report widget
        //cannot get associated partRef
        return new BrowserGazeHandler(target);

    } else if (target instanceof Tree &&
            partRef instanceof IViewReference &&
            partRef.getTitle().equals("Project Explorer")) {
        //create gaze handler for a Project Explorer Tree
        return new ProjectExplorerGazeHandler(target, partRef);
    }

    return null;
}
项目:bdf2    文件:SelectClassPage.java   
private void removeSelectedPackage(SelectionEvent e, TreeViewer treeViewer) {
    Tree tree = getTree(e);
    if (tree == null) {
        return;
    }
    TreeItem[] selection = tree.getSelection();
    if (selection != null && selection.length > 0) {
        for (TreeItem item : selection) {
            TreeItem parent = item.getParentItem();
            if (parent == null) {
                removePackage(item);
                updatePageComplete(tree);
            } else {
                alert("请选择要删除的包!");
            }
        }
    } else {
        alert("请选择要删除的包!");
    }
}
项目:avro-schema-editor    文件:CountTreeItemsHandler.java   
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);

}
项目:mytourbook    文件:TourCatalogView.java   
@Override
public void reloadViewer() {

    final Tree tree = _tourViewer.getTree();
    tree.setRedraw(false);
    {
        final Object[] expandedElements = _tourViewer.getExpandedElements();
        final ISelection selection = _tourViewer.getSelection();

        _tourViewer.setInput(_rootItem = new TVICatalogRootItem(this));

        _tourViewer.setExpandedElements(expandedElements);
        _tourViewer.setSelection(selection);
    }
    tree.setRedraw(true);
}
项目:JFaceUtils    文件:EnhancedPreferenceDialog.java   
@Override
protected void constrainShellSize() {
    super.constrainShellSize();
    if (Util.isCocoa()) {
        final Tree tree = getTreeViewer().getTree();
        final FontDescriptor treeFontDescriptor = FontDescriptor.createFrom(JFaceResources.getBannerFont()).setStyle(SWT.NORMAL);
        final Font treeFont = treeFontDescriptor.createFont(tree.getDisplay());
        updateTreeFont(treeFont);
        tree.addDisposeListener(new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent e) {
                treeFontDescriptor.destroyFont(treeFont);
            }
        });
    }
}
项目:logbook    文件:TreeToClipboardAdapter.java   
/**
 * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
 * 
 * @param header ヘッダー
 * @param tree ツリー
 */
public static void copyTree(String[] header, Tree tree) {
    TreeItem[] treeItems = tree.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TreeItem column : treeItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
项目:typescript.java    文件:AbstractInformationControl.java   
/**
 * Creates tree viewer to manage content
 * 
 * @param parent
 *            parent control
 */
private void createTreeViewer(Composite parent) {
    int style = SWT.H_SCROLL | SWT.V_SCROLL;
    // Create the tree
    Tree widget = new Tree(parent, style);
    // Configure the layout
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = widget.getItemHeight() * 12;
    widget.setLayoutData(data);

    treeViewer = new TreeViewer(widget);
    namePatternFilter = new QuickOutlineNamePatternFilter();
    treeViewer.addFilter(namePatternFilter);
    treeContentProvider = getContentProvider();
    treeViewer.setContentProvider(treeContentProvider);
    treeLabelProvider = getLabelProvider();
    treeViewer.setLabelProvider(treeLabelProvider);
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.setUseHashlookup(true);
    treeViewer.setInput(getInitialInput());
}
项目:PDFReporter-Studio    文件:JavaExpressionEditorComposite.java   
private void createObjectsNavigator(Composite parent) {
    objectsNavigator = new TreeViewer(parent, SWT.BORDER);
    Tree tree = objectsNavigator.getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    objectsNavigator
            .setContentProvider(new ObjectsNavigatorContentProvider());
    objectsNavigator.setLabelProvider(new ObjectsNavigatorLabelProvider());

    objectsNavigator
            .addSelectionChangedListener(new ISelectionChangedListener() {

                public void selectionChanged(SelectionChangedEvent event) {
                    Object selItem = ((IStructuredSelection) event
                            .getSelection()).getFirstElement();
                    if (selItem instanceof ObjectCategoryItem) {
                        updateDetailsPanel((ObjectCategoryItem) selItem);
                    }
                }
            });
}
项目:NEXCORE-UML-Modeler    文件:TreeItemUtil.java   
/**
 * getExpandTreePaths
 *  
 * @param tree
 * @param selectedItem
 * @return TreePath[]
 */
public static TreePath[] getExpandTreePaths(Tree tree, TreeItem selectedItem) {
    ArrayList<Object> items = new ArrayList<Object>();
    internalCollectTreeItems(items, tree);
    ArrayList<Object> result = new ArrayList<Object>();

    for (Iterator<Object> it = items.iterator(); it.hasNext();) {
        Item item = (Item) it.next();
        // if (item == selectedItem) {
        TreePath treePath = getTreePathFromItem(item);
        if (treePath != null) {
            result.add(treePath);
        }
        // }
    }

    return (TreePath[]) result.toArray(new TreePath[items.size()]);
}
项目:triquetrum    文件:PaletteTreeViewer.java   
/**
 * @see org.eclipse.gef.EditPartViewer#findObjectAtExcluding(Point, Collection, EditPartViewer.Conditional)
 */
@Override
public EditPart findObjectAtExcluding(Point pt, Collection exclude, Conditional condition) {
  if (getControl() == null)
    return null;

  final Tree tree = getTreeControl();
  Rectangle area = tree.getClientArea();
  if (pt.x < area.x || pt.y < area.y || pt.x >= area.x + area.width || pt.y >= area.y + area.height)
    return null;

  EditPart result = null;
  TreeItem tie = tree.getItem(new org.eclipse.swt.graphics.Point(pt.x, pt.y));

  if (tie != null) {
    result = (EditPart) tie.getData();
  } else if (tree.getData() instanceof EditPart) {
    result = (EditPart) tree.getData();
  }
  while (result != null) {
    if ((condition == null || condition.evaluate(result)) && !exclude.contains(result))
      return result;
    result = result.getParent();
  }
  return null;
}
项目:APICloud-Studio    文件:ControlThemerFactory.java   
private IControlThemer createThemer(Control control, int fontStyle, int alpha, Color defaultBg)
{
    // No themer exists, create a new one
    if (control instanceof Tree)
    {
        return new TreeThemer((Tree) control);
    }
    if (control instanceof Table)
    {
        return new TableThemer((Table) control);
    }
    if (fontStyle != SWT.NONE)
    {
        return new StyledFontThemer(control, fontStyle, defaultBg);
    }
    if (alpha > -1)
    {
        return new AlphaBlendThemer(control, alpha, defaultBg);
    }

    return new ControlThemer(control, defaultBg);
}
项目:traceability-assistant-eclipse-plugins    文件:ADOSelectionPage.java   
/**
 * Create contents of the wizard.
 *
 * @param parent the parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));

    treeViewer = new WorkbenchTreeViewer(container, SWT.SINGLE, CarchaWizard.EXTENSIONS_ADO);
    Tree tree = treeViewer.getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            setPageComplete(validatePage());
        }
    });
    StructuredSelection selection = getSelection();
    if(selection != null)
        treeViewer.setSelection(selection);

    setControl(container);

    setPageComplete(validatePage());
}
项目:mytourbook    文件:CollatedToursView.java   
@Override
public void reloadViewer() {

    if (_isInReload) {
        return;
    }

    final Tree tree = _tourViewer.getTree();
    tree.setRedraw(false);
    _isInReload = true;
    {
        final Object[] expandedElements = _tourViewer.getExpandedElements();
        final ISelection selection = _tourViewer.getSelection();

        _tourViewer.setInput(_rootItem = new TVICollatedTour_Root(this));

        _tourViewer.setExpandedElements(expandedElements);
        _tourViewer.setSelection(selection, true);
    }
    _isInReload = false;
    tree.setRedraw(true);
}
项目:traceability-assistant-eclipse-plugins    文件:REASelectionPage.java   
/**
 * Create contents of the wizard.
 *
 * @param parent the parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));

    treeViewer = new WorkbenchTreeViewer(container, SWT.SINGLE, CarchaWizard.EXTENSIONS_REA);
    Tree tree = treeViewer.getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            setPageComplete(validatePage());
        }
    });
    StructuredSelection selection = getSelection();
    if(selection != null)
        treeViewer.setSelection(selection);

    setControl(container);

    setPageComplete(validatePage());
}
项目:mipa    文件:LatticeTabUI.java   
private LatticeTabUI(TabFolder tabFolderMIPA) 
{
    TabItem tabItemLattice = new TabItem(tabFolderMIPA, SWT.NONE);
    tabItemLattice.setToolTipText("representation of lattice");
    tabItemLattice.setText("Lattice");

    SashForm sashLattice = new SashForm(tabFolderMIPA, SWT.NONE);
    tabItemLattice.setControl(sashLattice);

    StyledText styledTextLattice = new StyledText(sashLattice, SWT.BORDER
            | SWT.READ_ONLY);
    styledTextLattice.setText("Information for lattice are given here \n.");
    styledTextLattice.setToolTipText("Information for lattice.");

    Group grpLatticeTree = new Group(sashLattice, SWT.NONE);
    grpLatticeTree.setToolTipText("tree view of lattice");
    grpLatticeTree.setText("Lattice Tree View");

    latticeTreeViewer = new TreeViewer(grpLatticeTree, SWT.BORDER);
    Tree latticeTree = latticeTreeViewer.getTree();
    latticeTree.setBounds(10, 29, 444, 526);
    //latticeTreeViewer.setLabelProvider(new LatticeTreeLabelProvider());
    //latticeTreeViewer.setContentProvider(new LatticeTreeContentProvider());
    sashLattice.setWeights(new int[] { 1, 1 });
}
项目:SMVHunter    文件:DeviceContentProvider.java   
@Override
public void setChildren(final FileEntry entry, FileEntry[] children) {
    final Tree t = mViewer.getTree();
    if (t != null && t.isDisposed() == false) {
        Display display = t.getDisplay();
        if (display.isDisposed() == false) {
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    if (t.isDisposed() == false) {
                        // refresh the entry.
                        mViewer.refresh(entry);

                        // force it open, since on linux and windows
                        // when getChildren() returns null, the node is
                        // not considered expanded.
                        mViewer.setExpandedState(entry, true);
                    }
                }
            });
        }
    }
}
项目:mytourbook    文件:ActionCollapseOthers.java   
@Override
public void run() {

    if (fTourViewer != null) {

        final ColumnViewer viewer = fTourViewer.getViewer();
        if (viewer instanceof TreeViewer) {

            final TreeViewer treeViewer = (TreeViewer) viewer;
            final Object firstElement = ((StructuredSelection) treeViewer.getSelection()).getFirstElement();

            if (firstElement != null) {

                final Tree tree = treeViewer.getTree();
                tree.setRedraw(false);
                {
                    treeViewer.collapseAll();
                    treeViewer.setExpandedElements(new Object[] { firstElement });
                    treeViewer.setSelection(new StructuredSelection(firstElement), true);
                }
                tree.setRedraw(true);
            }
        }
    }
}
项目:mytourbook    文件:TourCompareResultView.java   
@Override
public void reloadViewer() {

    final Tree tree = _tourViewer.getTree();
    tree.setRedraw(false);
    {
        final Object[] expandedElements = _tourViewer.getExpandedElements();
        final ISelection selection = _tourViewer.getSelection();

        _tourViewer.setInput(_rootItem = new TVICompareResultRootItem());

        _tourViewer.setExpandedElements(expandedElements);
        _tourViewer.setSelection(selection);
    }
    tree.setRedraw(true);
}
项目:sophie    文件:SystemTree.java   
/**
 * Create a new tree listing Solr system information.
 * 
 * @param composite
 *            Parent composite.
 */
public SystemTree(Composite composite) throws SophieException {
    // Instantiate Tree.
    tree = new Tree(composite, SWT.BORDER);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Create name/value columns.
    columnName = new TreeColumn(tree, SWT.LEFT);
    columnName.setText("Name");
    columnValue = new TreeColumn(tree, SWT.LEFT);
    columnValue.setText("Value");

    // Populate tree with data from Solr.
    populate();

    // Pack columns.
    columnName.pack();
    columnValue.pack();
}
项目:scouter    文件:MainProcessor.java   
public TreeItem getSelectedRootItemFromMainTree(){
    Tree tree = this.getMainTree();
    if(tree == null){
        return null;
    }

    TreeItem [] items = tree.getSelection();
    if(items == null || items.length == 0){
        return null;
    }

    if(items[0].getData() instanceof StackAnalyzedInfo){
        return items[0].getParentItem();
    }
    return items[0];
}
项目:mytourbook    文件:PrefPageMap3Color.java   
/**
     * create the views context menu
     */
    private void createContextMenu() {

        final MenuManager menuMgr = new MenuManager();

        menuMgr.setRemoveAllWhenShown(true);

        menuMgr.addMenuListener(new IMenuListener() {
            @Override
            public void menuAboutToShow(final IMenuManager menuMgr2) {
//              fillContextMenu(menuMgr2);
            }
        });

        final Tree tree = _colorProfileViewer.getTree();
        final Menu treeContextMenu = menuMgr.createContextMenu(tree);

        tree.setMenu(treeContextMenu);

        _columnManager.createHeaderContextMenu(tree, treeContextMenu);
    }
项目:AndroidRobot    文件:ProjectUtil.java   
public static TreeItem importProject(String path,Tree tree,Display display) throws Exception{
    String project = readProjectName(path);
    Vector <IDeviceObject>vecDevices = readDevices(path);

    TreeItem root = new TreeItem(tree, SWT.NONE);
    root.setText(project);
    root.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/project.png")));

    TreeItem devices = new TreeItem(root, SWT.NONE);
    devices.setText("Devices");
    devices.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/devices.png")));

    for(int i =0;i<vecDevices.size();i++){
        TreeItem column = new TreeItem(devices, SWT.NONE);
        column.setText(vecDevices.get(i).name);
        column.setData("index",vecDevices.get(i).index);
        column.setData("sn",vecDevices.get(i).sn);
        column.setData("pixel",vecDevices.get(i).pixel);
        column.setData("name",vecDevices.get(i).name);
        column.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/disconn.png")));
    }
    return root;
}
项目:AndroidRobot    文件:RobotTreeUtil.java   
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;
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Returns true if the specified project can be found in the 'Package Explorer' or 'Project View',
 * otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer'
 * or 'Project Explorer' view cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to be found.
 * @return if the project exists
 */
public static boolean doesProjectExist(final SWTWorkbenchBot bot, String projectName) {
  SWTBotView explorer = getPackageExplorer(bot);
  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  SWTBotTreeItem[] allItems = new SWTBotTree(explorerTree).getAllItems();
  for (int i = 0; i < allItems.length; i++) {
    if (allItems[i].getText().equals(projectName)) {
      return true;
    }
  }
  return false;
}
项目:PDFReporter-Studio    文件:DataAdapterDragSourceListener.java   
private List<MDataAdapter> getDragSelection(DragSourceEvent event){
    if(event.getSource() instanceof DragSource){
        List<MDataAdapter> dataAdapters = new ArrayList<MDataAdapter>();
        Control control = ((DragSource)event.getSource()).getControl();
        if(control instanceof Tree && 
                ((Tree) control).getSelection().length>0){
            for(TreeItem tItem : ((Tree) control).getSelection()){
                Object data = tItem.getData();
                if(data instanceof MDataAdapter){
                    dataAdapters.add((MDataAdapter) data);
                }
            }
            return dataAdapters;                
        }
    }
    return new ArrayList<MDataAdapter>(0);
}
项目:n4js    文件:SelectAllProjectExplorerHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == activeWorkbenchWindow) {
        return null;
    }
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    if (null == activePage) {
        return null;
    }
    IWorkbenchPart activePart = activePage.getActivePart();
    if (!(activePart instanceof CommonNavigator)) {
        return null;
    }

    CommonNavigator navigator = (CommonNavigator) activePart;
    CommonViewer commonViewer = navigator.getCommonViewer();

    Tree navigatorTree = commonViewer.getTree();
    List<TreeItem> visibleItems = new ArrayList<>();
    collectChildren(navigatorTree.getItems(), visibleItems);

    List<Object> visibleData = visibleItems.stream().map(i -> i.getData()).collect(Collectors.toList());

    commonViewer.setSelection(new StructuredSelection(visibleData), false);

    return null;
}
项目:eclipse-batch-editor    文件:AbstractFilterableTreeQuickDialog.java   
@Override
public void keyPressed(KeyEvent event) {
    if (event.keyCode == SWT.ARROW_DOWN) {
        Tree tree = treeViewer.getTree();
        if (tree.isDisposed()) {
            return;
        }
        if (tree.isFocusControl()) {
            return;
        }
        tree.setFocus();
        return;
    }
    if (event.character == '\r') {
        ISelection selection = treeViewer.getSelection();
        openSelectionAndCloseDialog(selection);
        return;
    }
    boolean allowedChar = false;
    allowedChar = allowedChar || event.character == '*';
    allowedChar = allowedChar || event.character == '(';
    allowedChar = allowedChar || event.character == ')';
    allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
    allowedChar = allowedChar || Character.isWhitespace(event.character);
    if (!allowedChar) {
        event.doit = false;
        return;
    }
    if (treeViewer == null) {
        return;
    }

}
项目:convertigo-eclipse    文件:ProjectSchemaWizardPage.java   
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    Label label = new Label(container, SWT.NULL);
    label.setText("&Project:");

    tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
    tree.setHeaderVisible(false);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.verticalSpan = 20;
    gridData.horizontalSpan = 2;
    tree.setLayoutData(gridData);       
    tree.addListener(SWT.Selection, new Listener() {
        public void handleEvent(final Event event) {
            TreeItem item = (TreeItem) event.item;
            projectName = item.getText();
            dialogChanged();
        }
    });
    tree.setVisible(false);

    initialize();
    setControl(container);
    dialogChanged();
}
项目:convertigo-eclipse    文件:TwsDomTree.java   
/**
 * Fills an SWT Tree object with a parsed XML document
 * 
 * @param document      the parsed XML document
 */
public void fillDomTree(final Document document) {
    selectedTreeItem = null;

    removeAll();
    if (document != null) {
        Tree t = getTree();
        Node[] childs = XMLUtils.toNodeArray(document.getChildNodes());
        t.setData(document);
        t.setData("childs", childs);
        t.setItemCount(childs.length);
    }
}
项目:convertigo-eclipse    文件:ConvertigoPlugin.java   
/**
 * Gets the property descriptor of the selected property for this databaseObjectBeanInfo 
 * @param databaseObjectBeanInfo : BeanInfo of the selected databaseObject in the TreeExplorerView
 * @return PropertyDescriptor
 */
public PropertyDescriptor getSelectedPropertyDescriptor(BeanInfo databaseObjectBeanInfo) {
    PropertyDescriptor propertyDescriptor = null;

    // gets the properties editor
    PropertySheet view = ConvertigoPlugin.getDefault().getPropertiesView();
    Tree tree = (Tree) view.getCurrentPage().getControl();
    // gets the property selected in the property editor if one is selected
    TreeItem[] items = tree.getSelection();
    if (items.length > 0) {
        TreeItem selectedItem = items[0];

        // gets the local name of the selected property
        String text = selectedItem.getText();

        // gets the PropertyDescriptors of this databaseObject
        PropertyDescriptor[] descriptors = databaseObjectBeanInfo.getPropertyDescriptors();

        String displayName = null;
        int i = 0;

        // gets the PropertyDescriptor of the selected property 
        while (i < descriptors.length && propertyDescriptor == null) {
            displayName = descriptors[i].getDisplayName();
            if (displayName.equals(text))
                propertyDescriptor = descriptors[i];
            i++;
        }
    }   
    return propertyDescriptor;
}
项目:eclipse-bash-editor    文件:AbstractFilterableTreeQuickDialog.java   
@Override
public void keyPressed(KeyEvent event) {
    if (event.keyCode == SWT.ARROW_DOWN) {
        Tree tree = treeViewer.getTree();
        if (tree.isDisposed()) {
            return;
        }
        if (tree.isFocusControl()) {
            return;
        }
        tree.setFocus();
        return;
    }
    if (event.character == '\r') {
        ISelection selection = treeViewer.getSelection();
        openSelectionAndCloseDialog(selection);
        return;
    }
    boolean allowedChar = false;
    allowedChar = allowedChar || event.character == '*';
    allowedChar = allowedChar || event.character == '(';
    allowedChar = allowedChar || event.character == ')';
    allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
    allowedChar = allowedChar || Character.isWhitespace(event.character);
    if (!allowedChar) {
        event.doit = false;
        return;
    }
    if (treeViewer == null) {
        return;
    }

}
项目:bdf2    文件:SelectClassPage.java   
private void setCheckedItem(SelectionEvent e) {
    if (e.detail == SWT.CHECK) {
        TreeItem selectedTreeItem = (TreeItem) e.item;
        // 如果有父节点,选择父节点
        selectAllParentItems(selectedTreeItem);
        // 如果有子节点,全选子节点
        selectAllSubItems(selectedTreeItem);

        updatePageComplete((Tree) e.getSource());
    }
}
项目:bdf2    文件:SelectClassPage.java   
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);
    }
}
项目:bdf2    文件:SelectClassPage.java   
private Tree getTree(SelectionEvent e) {
    Control[] controls = ((Button) e.getSource()).getParent().getChildren();
    for (Object control : controls) {
        if (control instanceof Tree) {
            return (Tree) control;
        }
    }
    return null;
}
项目:egradle    文件:AbstractFilterableTreeQuickDialog.java   
@Override
public void keyPressed(KeyEvent event) {
    if (event.keyCode == SWT.ARROW_DOWN) {
        Tree tree = treeViewer.getTree();
        if (tree.isDisposed()) {
            return;
        }
        if (tree.isFocusControl()) {
            return;
        }
        tree.setFocus();
        return;
    }
    if (event.character == '\r') {
        ISelection selection = treeViewer.getSelection();
        openSelectionAndCloseDialog(selection);
        return;
    }
    boolean allowedChar = false;
    allowedChar = allowedChar || event.character == '*';
    allowedChar = allowedChar || event.character == '(';
    allowedChar = allowedChar || event.character == ')';
    allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
    allowedChar = allowedChar || Character.isWhitespace(event.character);
    if (!allowedChar) {
        event.doit = false;
        return;
    }
    if (treeViewer == null) {
        return;
    }

}
项目:team-explorer-everywhere    文件:QueryResultsTreeControl.java   
private void setupTree(final Tree tree) {
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayout(new TreeLayout());

    /* Pad table height by four pixels to increase readability */
    tree.addListener(/* SWT.MeasureItem */41, new MeasureItemHeightListener(4));
    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(final MouseEvent e) {
        }
    });
}