@Override
 public void calcData(DataKey key, DataSink sink) {
   super.calcData(key, sink);
   if (key.equals(PlatformDataKeys.DELETE_ELEMENT_PROVIDER) && myDeleteProvider != null) {
     sink.put(key, myDeleteProvider);
   } else if (key.equals(CommonDataKeys.VIRTUAL_FILE_ARRAY)) {
     sink.put(key, ArrayUtil.toObjectArray(getSelectedChanges(), VirtualFile.class));
   }
 }
 @Override
 public void calcData(final DataKey key, final DataSink sink) {
   if (key == UsageView.USAGE_INFO_KEY) {
     sink.put(UsageView.USAGE_INFO_KEY, getUsageInfo());
   }
   if (key == UsageView.USAGE_INFO_LIST_KEY) {
     List<UsageInfo> list = Arrays.asList(getMergedInfos());
     sink.put(UsageView.USAGE_INFO_LIST_KEY, list);
   }
 }
 public void calcData(DataKey key, DataSink sink) {
   if (OpenFileDescriptor.NAVIGATE_IN_EDITOR == key) {
     sink.put(OpenFileDescriptor.NAVIGATE_IN_EDITOR, myConsoleEditor);
     return;
   } else if (getProject().isInitialized()) {
     FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
     final Object o =
         ((FileEditorManagerImpl) editorManager)
             .getData(key.getName(), myConsoleEditor, myVirtualFile);
     sink.put(key, o);
   }
 }
 @Override
 public void calcData(final DataKey key, final DataSink sink) {
   if (!isValid()) return;
   if (LangDataKeys.PSI_ELEMENT == key) {
     sink.put(LangDataKeys.PSI_ELEMENT, getPsiClass());
   }
   if (UsageView.USAGE_INFO_KEY == key) {
     PsiClass psiClass = getPsiClass();
     if (psiClass != null) {
       sink.put(UsageView.USAGE_INFO_KEY, new UsageInfo(psiClass));
     }
   }
 }
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (UsageView.USAGE_SCOPE.equals(key)) {
     SearchScope scope = getScopeFromModel(myProject, myFindModel);
     sink.put(UsageView.USAGE_SCOPE, scope);
   }
 }
    @Override
    public void calcData(final DataKey key, final DataSink sink) {
      Node node = getSelectedNode();

      if (key == PlatformDataKeys.PROJECT) {
        sink.put(PlatformDataKeys.PROJECT, myProject);
      } else if (key == USAGE_VIEW_KEY) {
        sink.put(USAGE_VIEW_KEY, UsageViewImpl.this);
      } else if (key == PlatformDataKeys.NAVIGATABLE_ARRAY) {
        sink.put(PlatformDataKeys.NAVIGATABLE_ARRAY, getNavigatablesForNodes(getSelectedNodes()));
      } else if (key == PlatformDataKeys.EXPORTER_TO_TEXT_FILE) {
        sink.put(PlatformDataKeys.EXPORTER_TO_TEXT_FILE, myTextFileExporter);
      } else if (key == USAGES_KEY) {
        final Set<Usage> selectedUsages = getSelectedUsages();
        sink.put(
            USAGES_KEY,
            selectedUsages != null
                ? selectedUsages.toArray(new Usage[selectedUsages.size()])
                : null);
      } else if (key == USAGE_TARGETS_KEY) {
        sink.put(USAGE_TARGETS_KEY, getSelectedUsageTargets());
      } else if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) {
        final Set<Usage> usages = getSelectedUsages();
        Usage[] ua = usages != null ? usages.toArray(new Usage[usages.size()]) : null;
        VirtualFile[] data = UsageDataUtil.provideVirtualFileArray(ua, getSelectedUsageTargets());
        sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, data);
      } else if (key == PlatformDataKeys.HELP_ID) {
        sink.put(PlatformDataKeys.HELP_ID, HELP_ID);
      } else if (key == PlatformDataKeys.COPY_PROVIDER) {
        sink.put(PlatformDataKeys.COPY_PROVIDER, this);
      } else if (node != null) {
        Object userObject = node.getUserObject();
        if (userObject instanceof TypeSafeDataProvider) {
          ((TypeSafeDataProvider) userObject).calcData(key, sink);
        } else if (userObject instanceof DataProvider) {
          DataProvider dataProvider = (DataProvider) userObject;
          Object data = dataProvider.getData(key.getName());
          if (data != null) {
            sink.put(key, data);
          }
        }
      }
    }
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (key == CommonDataKeys.NAVIGATABLE_ARRAY) {
     List<Navigatable> navigatables = getNavigatables();
     if (!navigatables.isEmpty()) {
       sink.put(
           CommonDataKeys.NAVIGATABLE_ARRAY,
           navigatables.toArray(new Navigatable[navigatables.size()]));
     }
   }
 }
 @Override
 public void calcData(final DataKey key, final DataSink sink) {
   if (key.equals(LangDataKeys.PSI_ELEMENT)) {
     if (mySelectedElements != null && !mySelectedElements.isEmpty()) {
       T selectedElement = mySelectedElements.iterator().next();
       if (selectedElement instanceof ClassMemberWithElement) {
         sink.put(
             LangDataKeys.PSI_ELEMENT, ((ClassMemberWithElement) selectedElement).getElement());
       }
     }
   }
 }
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.CHANGES) {
     sink.put(VcsDataKeys.CHANGES, getSelectedChanges());
   } else if (key == VcsDataKeys.CHANGE_LEAD_SELECTION) {
     sink.put(VcsDataKeys.CHANGE_LEAD_SELECTION, getLeadSelection());
   } else if (key == VcsDataKeys.CHANGE_LISTS) {
     sink.put(VcsDataKeys.CHANGE_LISTS, getSelectedChangeLists());
   } else if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) {
     sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, getSelectedFiles());
   } else if (key == PlatformDataKeys.NAVIGATABLE) {
     final VirtualFile[] files = getSelectedFiles();
     if (files.length == 1 && !files[0].isDirectory()) {
       sink.put(PlatformDataKeys.NAVIGATABLE, new OpenFileDescriptor(myProject, files[0], 0));
     }
   } else if (key == PlatformDataKeys.NAVIGATABLE_ARRAY) {
     sink.put(
         PlatformDataKeys.NAVIGATABLE_ARRAY,
         ChangesUtil.getNavigatableArray(myProject, getSelectedFiles()));
   } else if (key == PlatformDataKeys.DELETE_ELEMENT_PROVIDER) {
     final TreePath[] paths = getSelectionPaths();
     if (paths != null) {
       for (TreePath path : paths) {
         ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
         if (!(node.getUserObject() instanceof ChangeList)) {
           sink.put(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, new VirtualFileDeleteProvider());
           break;
         }
       }
     }
   } else if (key == PlatformDataKeys.COPY_PROVIDER) {
     sink.put(PlatformDataKeys.COPY_PROVIDER, myCopyProvider);
   } else if (key == UNVERSIONED_FILES_DATA_KEY) {
     sink.put(UNVERSIONED_FILES_DATA_KEY, getSelectedUnversionedFiles());
   } else if (key == VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY) {
     sink.put(VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY, getSelectedModifiedWithoutEditing());
   } else if (key == LOCALLY_DELETED_CHANGES) {
     sink.put(LOCALLY_DELETED_CHANGES, getSelectedLocallyDeletedChanges());
   } else if (key == MISSING_FILES_DATA_KEY) {
     sink.put(MISSING_FILES_DATA_KEY, getSelectedMissingFiles());
   } else if (VcsDataKeys.HAVE_LOCALLY_DELETED == key) {
     sink.put(VcsDataKeys.HAVE_LOCALLY_DELETED, haveLocallyDeleted());
   } else if (VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING == key) {
     sink.put(VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING, haveLocallyModified());
   } else if (VcsDataKeys.HAVE_SELECTED_CHANGES == key) {
     sink.put(VcsDataKeys.HAVE_SELECTED_CHANGES, haveSelectedChanges());
   } else if (key == HELP_ID_DATA_KEY) {
     sink.put(HELP_ID_DATA_KEY, ourHelpId);
   } else if (key == VcsDataKeys.CHANGES_IN_LIST_KEY) {
     final TreePath selectionPath = getSelectionPath();
     if (selectionPath != null && selectionPath.getPathCount() > 1) {
       ChangesBrowserNode<?> firstNode = (ChangesBrowserNode) selectionPath.getPathComponent(1);
       if (firstNode instanceof ChangesBrowserChangeListNode) {
         final List<Change> list = firstNode.getAllChangesUnder();
         sink.put(VcsDataKeys.CHANGES_IN_LIST_KEY, list);
       }
     }
   }
 }
Example #10
0
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (PlatformDataKeys.COPY_PROVIDER == key) {
     sink.put(key, this);
   }
 }
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.COMMIT_MESSAGE_CONTROL) {
     sink.put(VcsDataKeys.COMMIT_MESSAGE_CONTROL, myCommitMessagePanel);
   }
 }
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.CHANGES) {
     List<Change> list = getSelectedChanges();
     if (list.isEmpty()) list = getAllChanges();
     sink.put(VcsDataKeys.CHANGES, list.toArray(new Change[list.size()]));
   } else if (key == VcsDataKeys.CHANGES_SELECTION) {
     sink.put(VcsDataKeys.CHANGES_SELECTION, getChangesSelection());
   } else if (key == VcsDataKeys.CHANGE_LISTS) {
     sink.put(VcsDataKeys.CHANGE_LISTS, getSelectedChangeLists());
   } else if (key == VcsDataKeys.CHANGE_LEAD_SELECTION) {
     final Change highestSelection =
         ObjectUtils.tryCast(myViewer.getHighestLeadSelection(), Change.class);
     sink.put(
         VcsDataKeys.CHANGE_LEAD_SELECTION,
         (highestSelection == null) ? new Change[] {} : new Change[] {highestSelection});
   } else if (key == CommonDataKeys.VIRTUAL_FILE_ARRAY) {
     sink.put(CommonDataKeys.VIRTUAL_FILE_ARRAY, getSelectedFiles().toArray(VirtualFile[]::new));
   } else if (key == CommonDataKeys.NAVIGATABLE_ARRAY) {
     sink.put(
         CommonDataKeys.NAVIGATABLE_ARRAY, getNavigatableArray(myProject, getSelectedFiles()));
   } else if (VcsDataKeys.IO_FILE_ARRAY.equals(key)) {
     sink.put(VcsDataKeys.IO_FILE_ARRAY, getSelectedIoFiles());
   } else if (key == DATA_KEY) {
     sink.put(DATA_KEY, this);
   } else if (VcsDataKeys.SELECTED_CHANGES_IN_DETAILS.equals(key)) {
     final List<Change> selectedChanges = getSelectedChanges();
     sink.put(
         VcsDataKeys.SELECTED_CHANGES_IN_DETAILS,
         selectedChanges.toArray(new Change[selectedChanges.size()]));
   } else if (UNVERSIONED_FILES_DATA_KEY.equals(key)) {
     sink.put(
         UNVERSIONED_FILES_DATA_KEY,
         getVirtualFiles(myViewer.getSelectionPaths(), UNVERSIONED_FILES_TAG));
   } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.equals(key)) {
     sink.put(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider);
   }
 }