Example usage for org.eclipse.jface.viewers IStructuredSelection toList

List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection toList.

Prototype

public List toList();

Source Link

Document

Returns the elements in this selection as a List.

Usage

From source file:com.ibm.research.tagging.core.ui.tags.TagTableSelectionChangedListener.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    // Get the selection
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();

    if (TagUIPlugin.getDefault().getTagView().isLinkedWithWaypointView()) {
        List<ITag> tagList = selection.toList();

        // Convert to array 
        ITag[] tags = new ITag[0];
        tags = tagList.toArray(tags);//from   w  ww  .j  a  v a 2  s . co  m

        // Fire the selection event
        TagUIPlugin.getDefault().getTagUI().tagSelectionChanged(tags);
    }

    if (selection.size() == 1) {
        TagUIPlugin.getDefault().getTagView().getRenameTagAction().setEnabled(true);
    } else {
        TagUIPlugin.getDefault().getTagView().getRenameTagAction().setEnabled(false);
    }
}

From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointTableContentProvider.java

License:Open Source License

public Object[] getElements(Object inputElement) {
    TagView view = TagUIPlugin.getDefault().getTagView();

    if (view != null) {
        TableViewer viewer = view.getTagTableViewer();
        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        Set<IWaypoint> result = new HashSet<IWaypoint>();
        List tagSelection = selection.toList();

        if (tagSelection.size() == 0)
            return getAllWaypoints();

        for (Object o : tagSelection) {
            ITag tag = (ITag) o;//from   ww w.j a  v  a2  s.  c  o  m
            IWaypoint[] waypoints = tag.getWaypoints();

            for (IWaypoint waypoint : waypoints)
                result.add(waypoint);
        }

        return result.toArray();
    } else
        return getAllWaypoints();
}

From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointTableDoubleClickListener.java

License:Open Source License

public void doubleClick(DoubleClickEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();

    for (Object o : selection.toList()) {
        IWaypoint waypoint = (IWaypoint) o;
        waypoint.navigate();//from w  w w. j  a v a 2 s .co  m
    }
}

From source file:com.ibm.research.tours.editors.PaletteDoubleClickListener.java

License:Open Source License

public void doubleClick(DoubleClickEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();

    for (Object o : selection.toList()) {

    }//from   www . j  av a 2  s  .c  o m
}

From source file:com.inepex.classtemplater.plugin.popup.actions.Generator.java

License:Eclipse Public License

private void processSelection(IStructuredSelection selection) throws Exception {
    classModels.clear();/*from ww  w  .j a  va  2s  . co  m*/
    if (ICompilationUnit.class.isInstance(selection.getFirstElement())) {
        for (Object o : selection.toList()) {
            ICompilationUnit compunit = ((ICompilationUnit) o);
            classModels.add(new Class(compunit));
        }
        if (selection.size() == 1)
            mode = "One class";
        else
            mode = "Multiple class";
    } else if (IField.class.isInstance(selection.getFirstElement())) {
        classModels.add(new Class(selection.toList()));
        mode = "Attribute list";
    } else if (IMethod.class.isInstance(selection.getFirstElement())) {
        classModels.add(new Class(selection.toList(), true));
        mode = "Method list";
    }
}

From source file:com.itsolut.mantis.ui.action.MantisDeleteAttachmentAction.java

License:Open Source License

public void selectionChanged(IAction action, ISelection selection) {

    attachments.clear();// ww w.  j  a va  2s.  c  o m
    action.setEnabled(false);

    IStructuredSelection structuredSelection = null;

    if (selection instanceof IStructuredSelection)
        structuredSelection = (IStructuredSelection) selection;

    if (structuredSelection == null || structuredSelection.isEmpty())
        return;

    for (Object selectionItem : structuredSelection.toList()) {
        if (selectionItem instanceof ITaskAttachment) {
            attachments.add((ITaskAttachment) selectionItem);
        }
    }

    action.setEnabled(attachments.size() > 0);
}

From source file:com.iw.plugins.spindle.editorjwc.beans.ChooseBeanInitializerDialog.java

License:Mozilla Public License

protected void okPressed() {
    if (viewer != null) {

        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        if (!selection.isEmpty()) {

            chosenProperties = new ArrayList();

            for (Iterator iter = selection.toList().iterator(); iter.hasNext();) {
                PropertyDescriptor element = (PropertyDescriptor) iter.next();
                chosenProperties.add(element.getName());
            }/*www .j  a  v  a 2 s  .  c  o m*/

        }
    }
    super.okPressed();
}

From source file:com.iw.plugins.spindle.editorjwc.components.ChooseBindingTypeDialog.java

License:Mozilla Public License

protected void okPressed() {
    if (viewer != null) {
        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        if (!selection.isEmpty()) {
            chosenParameters = selection.toList();
        }/*from ww  w . j  a  v a2s  . c om*/
    }
    super.okPressed();
}

From source file:com.iw.plugins.spindle.ui.wizards.source.MoveImplicitAttributesPage.java

License:Mozilla Public License

private void handleLeftRightChange(Viewer fromViewer, Object changeObject) {

    IStructuredSelection selection = null;
    if (changeObject instanceof ISelection) {

        selection = (IStructuredSelection) changeObject;
    } else {// www .  j  a  v a  2s  .  com

        selection = new StructuredSelection(changeObject);
    }

    List fromList = null;
    List toList = null;
    TableViewer toViewer = null;
    if (fromViewer == fAttributesThatStayViewer) {

        fromList = fAttributesThatStay;
        toList = fAttributesThatMove;
        toViewer = fAttributesThatMoveViewer;
    } else {

        fromList = fAttributesThatMove;
        toList = fAttributesThatStay;
        toViewer = fAttributesThatStayViewer;
    }

    if (!selection.isEmpty()) {

        List selectedObjects = selection.toList();
        fromList.removeAll(selectedObjects);
        toList.addAll(selectedObjects);
        fromViewer.setInput(fromList);
        toViewer.setInput(toViewer);
        toViewer.getControl().setFocus();
        toViewer.setSelection(selection);
    }
    updateButtonsEnabled();
    updateStatus();
}

From source file:com.iw.plugins.spindle.wizards.migrate.DefinePagesComponentsPage.java

License:Mozilla Public License

private void handleChange(Viewer fromViewer, Object changeObject) {

    IStructuredSelection selection = null;
    if (changeObject instanceof ISelection) {

        selection = (IStructuredSelection) changeObject;
    } else {/*from   w ww  .  j  a v a  2  s .  co  m*/

        selection = new StructuredSelection(changeObject);
    }

    List fromList = null;
    List toList = null;
    TableViewer toViewer = null;
    if (fromViewer == componentViewer) {

        fromList = componentList;
        toList = pageList;
        toViewer = pageViewer;
    } else {

        fromList = pageList;
        toList = componentList;
        toViewer = componentViewer;
    }

    if (!selection.isEmpty()) {

        List selectedObjects = selection.toList();
        fromList.removeAll(selectedObjects);
        toList.addAll(selectedObjects);
        fromViewer.setInput(fromList);
        toViewer.setInput(toViewer);
        toViewer.getControl().setFocus();
        toViewer.setSelection(selection);
        updateButtonsEnabled();
    }
}