Example usage for com.intellij.openapi.actionSystem PlatformDataKeys SELECTED_ITEMS

List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys SELECTED_ITEMS

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem PlatformDataKeys SELECTED_ITEMS.

Prototype

DataKey SELECTED_ITEMS

To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys SELECTED_ITEMS.

Click Source Link

Document

Returns multi selection items.

Usage

From source file:com.intellij.ide.impl.dataRules.PsiElementFromSelectionsRule.java

License:Apache License

@Override
public Object getData(DataProvider dataProvider) {
    final Object[] objects = (Object[]) dataProvider.getData(PlatformDataKeys.SELECTED_ITEMS.getName());
    if (objects != null) {
        final PsiElement[] elements = new PsiElement[objects.length];
        for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
            Object object = objects[i];
            if (!(object instanceof PsiElement))
                return null;
            if (!((PsiElement) object).isValid())
                return null;
            elements[i] = (PsiElement) object;
        }//  w ww.  ja v a2  s.com

        return elements;
    }
    return null;
}

From source file:com.intellij.ide.navigationToolbar.NavBarListWrapper.java

License:Apache License

@Override
@Nullable// w w  w .j a v a 2s. c  o  m
public Object getData(@NonNls String dataId) {
    if (PlatformDataKeys.SELECTED_ITEM.is(dataId)) {
        return myList.getSelectedValue();
    }
    if (PlatformDataKeys.SELECTED_ITEMS.is(dataId)) {
        return myList.getSelectedValues();
    }
    return null;
}