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

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

Introduction

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

Prototype

DataKey SELECTED_ITEM

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

Click Source Link

Document

Returns single selection item.

Usage

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

License:Apache License

@Override
public Object getData(DataProvider dataProvider) {
    final Navigatable navigatable = PlatformDataKeys.NAVIGATABLE.getData(dataProvider);
    if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
        final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor) navigatable;

        if (openFileDescriptor.getFile().isValid()) {
            return openFileDescriptor;
        }//ww  w  .  j a  v a2s.  c  om
    }
    final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
    if (element instanceof Navigatable) {
        return element;
    }
    if (element != null) {
        return EditSourceUtil.getDescriptor(element);
    }

    final Object selection = PlatformDataKeys.SELECTED_ITEM.getData(dataProvider);
    if (selection instanceof Navigatable) {
        return selection;
    }

    return null;
}

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

License:Apache License

@Override
public Object getData(DataProvider dataProvider) {
    final Object element = dataProvider.getData(PlatformDataKeys.SELECTED_ITEM.getName());
    if (element instanceof PsiElement) {
        PsiElement psiElement = (PsiElement) element;
        if (psiElement.isValid()) {
            return element;
        }/*from  w w w.ja va  2s  . com*/
    }

    return null;
}

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

License:Apache License

@Override
@Nullable/*from   www .  j ava 2  s  .  com*/
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;
}