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

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

Introduction

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

Prototype

public int size();

Source Link

Document

Returns the number of elements selected in this selection.

Usage

From source file:com.bdaum.zoom.ui.internal.views.CalendarView.java

License:Open Source License

@Override
public void collectionChanged(IWorkbenchPart part, IStructuredSelection sel) {
    if (sel.size() == 1) {
        Object firstElement = sel.getFirstElement();
        if (firstElement instanceof SmartCollection) {
            SmartCollectionImpl currentCollection = (SmartCollectionImpl) firstElement;
            if (currentCollection.getStringId().startsWith(IDbManager.DATETIMEKEY))
                setCurrentCal((Date) ((Range) currentCollection.getCriterion(0).getValue()).getFrom());
        }/*w  w w.j a va  2  s  . co  m*/
    }
}

From source file:com.bdaum.zoom.ui.internal.views.HierarchyView.java

License:Open Source License

private static AssetSelection nodeToAssetSelection(IStructuredSelection selection) {
    AssetSelection assetSelection = new AssetSelection(selection.size());
    Iterator<?> iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof Node) {
            Asset a = ((Node) object).getAsset();
            if (a != null)
                assetSelection.add(a);//from  w w  w . ja  va  2s  .  c  om
        }
    }
    return assetSelection;
}

From source file:com.bdaum.zoom.ui.internal.views.TableView.java

License:Open Source License

protected AssetSelection doGetAssetSelection() {
    IStructuredSelection s = gallery.getStructuredSelection();
    AssetSelection sel = new AssetSelection(s.size());
    for (Object item : s.toArray())
        sel.add((Asset) item);//from w  w w.  j  a v  a 2  s  . c  om
    return sel;
}

From source file:com.binge.workforce.widgets.internal.DrillDownAdapter.java

License:Open Source License

/**
 * Returns whether "go into" is possible for child tree.  This is only possible 
 * if the current selection in the client has one item and it has children.
 *
 * @return <code>true</code> if "go into" is possible; <code>false</code> otherwise
 *//*from  w  w  w.  j  a va2 s .com*/
public boolean canGoInto() {
    IStructuredSelection oSelection = (IStructuredSelection) fChildTree.getSelection();
    if (oSelection == null || oSelection.size() != 1) {
        return false;
    }
    Object anElement = oSelection.getFirstElement();
    return canExpand(anElement);
}

From source file:com.bluexml.side.Requirements.modeler.views.internal.Util.java

License:Open Source License

/**
 * Return whether or not the selection has one element that is concrete.
 * /*from   w  w  w .  j  av a  2s . co m*/
 * @param selection
 * @return <true>code</true> if the selection has one element that is
 *         concrete.
 */
static boolean isSingleConcreteSelection(IStructuredSelection selection) {
    if (selection != null && selection.size() == 1) {
        Object first = selection.getFirstElement();
        if (first instanceof MarkerNode) {
            return ((MarkerNode) first).isConcrete();
        }
    }
    return false;
}

From source file:com.bluexml.side.Requirements.modeler.views.internal.Util.java

License:Open Source License

/**
 * Return whether or not all of the elements in the selection are concrete.
 * //from  www  .j  a  v  a2s  .co  m
 * @param selection
 * @return <true>code</true> if all of the elements are concrete.
 */
public static boolean allConcreteSelection(IStructuredSelection selection) {
    if (selection != null && selection.size() > 0) {
        Iterator nodes = selection.iterator();
        while (nodes.hasNext()) {
            if (((MarkerNode) nodes.next()).isConcrete()) {
                continue;
            }
            return false;
        }
        return true;
    }
    return false;
}

From source file:com.bluexml.side.view.edit.ui.actions.CopyColConfAction.java

License:Open Source License

public boolean updateSelection(IStructuredSelection selection) {
    if (selection.size() == 1) {
        Iterator<?> objects = selection.iterator();
        Object object = objects.next();
        if (object instanceof Col) {
            selectedObject = (Col) object;
        }//  w w  w  .  jav a  2 s  .c  o m
    }
    return selectedObject != null;
}

From source file:com.bluexml.side.view.edit.ui.actions.PasteColConfAction.java

License:Open Source License

public boolean updateSelection(IStructuredSelection selection) {
    if (selection.size() == 1) {
        Iterator<?> objects = selection.iterator();
        Object object = objects.next();
        if (object instanceof Col) {
            selectedObject = (Col) object;
        }/*from   ww  w .j a v a2s.  co m*/
    }
    return (selectedObject != null && ColConfManager.getActualCopiedCol() != null);
}

From source file:com.bmw.spdxeditor.wizards.NewSPDXFileWizardPage.java

License:Apache License

/**
 * Tests if the current workbench selection is a suitable container to use.
 *//*w  w  w. j  a va 2s . com*/

private void initialize() {
    if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) {
        IStructuredSelection ssel = (IStructuredSelection) selection;
        if (ssel.size() > 1)
            return;
        Object obj = ssel.getFirstElement();
        if (obj instanceof IResource) {
            IContainer container;
            if (obj instanceof IContainer)
                container = (IContainer) obj;
            else
                container = ((IResource) obj).getParent();
            containerText.setText(container.getFullPath().toString());
        }
    }
    fileText.setText("new_file.spdx");
}

From source file:com.buildml.eclipse.actions.ActionsEditorDragSource.java

License:Open Source License

/** 
 * This method is called by the drag/drop framework to obtain the actual "transfer" data
 * for the tree node that was selected when the drag/drop started. For UIAction, we create
 * a corresponding BuildMLTransferType object. For other things, we abort.
 *//*from  ww  w.  jav a 2  s  . c o m*/
@Override
public void dragSetData(DragSourceEvent event) {
    if (BuildMLTransfer.getInstance().isSupportedType(event.dataType)) {

        /*
         * Identify the currently-selected tree node, and create a corresponding
         * BuildMLTransferType object for each selected element. We know how many
         * elements are in the selection, so create a BuildMLTransferType for each.
         */
        IStructuredSelection selection = ((IStructuredSelection) treeViewer.getSelection());
        BuildMLTransferType data[] = new BuildMLTransferType[selection.size()];

        /* populate the array */
        int elementNum = 0;
        @SuppressWarnings("unchecked")
        Iterator<Object> iter = selection.iterator();
        while (iter.hasNext()) {
            Object node = iter.next();
            int transferType;

            /* check the type of the tree node (must be a UIAction). */
            if (node instanceof UIAction) {
                transferType = BuildMLTransferType.TYPE_ACTION;
            } else {
                /* we can't proceed, not a recognized type */
                event.doit = false;
                return;
            }

            /*
             * The selected node is valid, create the data to pass to the drag/drop framework.
             */
            int id = ((UIInteger) node).getId();
            data[elementNum++] = new BuildMLTransferType(buildStore.toString(), transferType, id);
        }
        ;

        /* 
         * We now have a complete array of BuildMLTransferType[], each entry represents
         * a unique UIAction that was part of our selection.
         */
        event.data = data;
    }
}