Example usage for org.eclipse.jface.viewers ITreeSelection iterator

List of usage examples for org.eclipse.jface.viewers ITreeSelection iterator

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ITreeSelection iterator.

Prototype

@Override
public Iterator iterator();

Source Link

Document

Returns an iterator over the elements of this selection.

Usage

From source file:com.android.ide.eclipse.adt.internal.editors.ui.tree.UiTreeBlock.java

License:Open Source License

/**
 * Filters an ITreeSelection to only keep the {@link UiElementNode}s (in case there's
 * something else in there)./* ww  w  . jav a  2 s .co m*/
 *
 * @return A new list of {@link UiElementNode} with at least one item or null.
 */
private ArrayList<UiElementNode> filterSelection(ITreeSelection selection) {
    ArrayList<UiElementNode> selected = new ArrayList<UiElementNode>();

    for (Iterator<Object> it = selection.iterator(); it.hasNext();) {
        Object selectedObj = it.next();

        if (selectedObj instanceof UiElementNode) {
            selected.add((UiElementNode) selectedObj);
        }
    }

    return selected.size() > 0 ? selected : null;
}

From source file:com.android.ide.eclipse.editors.ui.tree.UiTreeBlock.java

License:Open Source License

/**
 * Filters an ITreeSelection to only keep the {@link UiElementNode}s (in case there's
 * something else in there)./*from w  ww  . j a  v a  2 s  .  com*/
 * 
 * @return A new list of {@link UiElementNode} with at least one item or null.
 */
@SuppressWarnings("unchecked")
private ArrayList<UiElementNode> filterSelection(ITreeSelection selection) {
    ArrayList<UiElementNode> selected = new ArrayList<UiElementNode>();

    for (Iterator it = selection.iterator(); it.hasNext();) {
        Object selectedObj = it.next();

        if (selectedObj instanceof UiElementNode) {
            selected.add((UiElementNode) selectedObj);
        }
    }

    return selected.size() > 0 ? selected : null;
}

From source file:com.mercatis.lighthouse3.ui.operations.ui.editors.pages.InstalledOperationsEditorPage.java

License:Apache License

public void menuDetected(MenuDetectEvent e) {
    Tree tree = (Tree) e.widget;/*from  ww w. j  a  v a  2  s.c o m*/
    ITreeSelection sel = (ITreeSelection) operationsTree.getSelection();
    int selCnt = tree.getSelectionCount();
    if (selCnt == 0 || (selCnt == 1 && sel.iterator().next() instanceof Category<?>)) {
        MenuManager mm = new MenuManager();
        mm.add(new OpenInstallOperationWizardAction(getSite().getShell(), lighthouseDomain, deployment));
        Menu m = mm.createContextMenu(tree);
        m.setLocation(e.x, e.y);
        m.setVisible(true);
        return;
    }
}

From source file:com.metaaps.eoclipse.datasets.internal.NCE.ImportHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();

    if (obj instanceof IDataSets) {
        IDataSets datasets = (IDataSets) obj;
        ImportMethod importmethod = null;
        try {//from ww w  .  j a  v a2  s .  com
            String extension = event.getParameter("com.metaaps.eoclipse.datasets.importmethod");
            for (Object impobj : ImportFolder.getInstance().getChildren()) {
                if (impobj instanceof ImportMethod) {
                    if (((ImportMethod) impobj).getFullExtension().contentEquals(extension)) {
                        importmethod = (ImportMethod) impobj;
                        break;
                    }
                }
            }
            NewHandler.importData(importmethod, datasets);
        } catch (Exception e) {
            Util.errorMessage("Could not activate Import Method");
            e.printStackTrace();
        }
    }
    return null;
}

From source file:com.metaaps.eoclipse.datasets.internal.NCE.NewHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();
    if (obj instanceof IImportMethod) {
        IDataSets datasets = (IDataSets) Util.scanTreePath(currentSelection, IDataSets.class);
        IImportMethod importmethod = (IImportMethod) obj;
        importData(importmethod, datasets);
    }/*from w  ww  .  j  av a  2  s.com*/

    return null;
}

From source file:com.metaaps.eoclipse.export.NCE.AddHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();
    if (obj instanceof Method) {
        ExportFolder folder = (ExportFolder) Util.scanTreePath(currentSelection, ExportFolder.class);
        // just for demo
        // should instantiate a new Method object
        folder.addChild(obj);/*from  w  ww.  j  a v a 2  s .c o  m*/
        folder.fireChanged(obj, Model.ADDED);
    }

    return null;
}

From source file:com.metaaps.eoclipse.processing.NCE.Execute.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();
    if (obj instanceof Process) {
        // prepare parameters
        IDataContent data = (IDataContent) Util.scanTreePath(currentSelection, IDataContent.class);
        ((Process) obj).execute(data);
    }//from   ww w  . jav  a 2 s  . co  m

    return null;
}

From source file:com.metaaps.eoclipse.viewers.NCE.OpenHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();
    if (obj instanceof Viewer) {
        IWorkFlow workflow = (IWorkFlow) Util.scanTreePath(currentSelection, IWorkFlow.class);
        ((Viewer) obj).Open(workflow, null);
    }/* w  w  w. jav a2 s. c o  m*/

    return null;
}

From source file:com.metaaps.eoclipse.viewers.NCE.OpenMenuHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ITreeSelection currentSelection = (ITreeSelection) HandlerUtil.getCurrentSelection(event);
    Object obj = currentSelection.iterator().next();

    if (obj instanceof IDataSets) {
        Viewer viewer = null;//from   w  w w.jav a2s  .c  o m
        try {
            String extension = event.getParameter("com.metaaps.eoclipse.viewers");
            for (Object viewerobj : Viewers.getInstance().getChildren()) {
                if (viewerobj instanceof Viewer) {
                    if (((Viewer) viewerobj).getFullExtension().contentEquals(extension)) {
                        viewer = (Viewer) viewerobj;
                        break;
                    }
                }
            }
            IWorkFlow workflow = (IWorkFlow) Util.scanTreePath(currentSelection, IWorkFlow.class);
            viewer.Open(workflow, null);
        } catch (Exception e) {
            Util.errorMessage("Could not activate Import Method");
            e.printStackTrace();
        }
    }
    return null;
}

From source file:com.microsoft.tfs.client.eclipse.ui.egit.importwizard.GitImportWizardSelectFoldersPage.java

License:Open Source License

private ImportEclipseProject[] getSelectedFolders() {
    final List<ImportEclipseProject> projects = new ArrayList<ImportEclipseProject>();
    final ITreeSelection selectedElements = (ITreeSelection) treeViewer.getSelection();

    for (final Iterator<?> i = selectedElements.iterator(); i.hasNext();) {
        final ImportEclipseProject folder = (ImportEclipseProject) i.next();
        projects.add(folder);//  w  w  w .  j  av  a2s .c o m
    }

    return projects.toArray(new ImportEclipseProject[projects.size()]);
}