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

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

Introduction

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

Prototype

DataKey SEARCH_INPUT_TEXT

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

Click Source Link

Usage

From source file:ru.list.search.AssistantSearchEverywhereAction.java

License:Apache License

private void registerDataProvider(JPanel panel, final Project project) {
    DataManager.registerDataProvider(panel, new DataProvider() {
        @Nullable// w ww  .  j a v a 2s.  co  m
        @Override
        public Object getData(@NonNls String dataId) {
            final Object value = myList.getSelectedValue();
            if (CommonDataKeys.PSI_ELEMENT.is(dataId) && value instanceof PsiElement) {
                return value;
            } else if (CommonDataKeys.VIRTUAL_FILE.is(dataId) && value instanceof VirtualFile) {
                return value;
            } else if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
                if (value instanceof Navigatable)
                    return value;
                if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) {
                    final Object config = ((ChooseRunConfigurationPopup.ItemWrapper) value).getValue();
                    if (config instanceof RunnerAndConfigurationSettings) {
                        return new Navigatable() {
                            @Override
                            public void navigate(boolean requestFocus) {
                                RunDialog.editConfiguration(project, (RunnerAndConfigurationSettings) config,
                                        "Edit Configuration", getExecutor());
                            }

                            @Override
                            public boolean canNavigate() {
                                return true;
                            }

                            @Override
                            public boolean canNavigateToSource() {
                                return true;
                            }
                        };
                    }
                }
            } else if (PlatformDataKeys.SEARCH_INPUT_TEXT.is(dataId)) {
                return myPopupField == null ? null : myPopupField.getText();
            }
            return null;
        }
    });
}