Java Code Examples for com.intellij.openapi.vcs.VcsDataKeys#CHANGES_SELECTION

The following examples show how to use com.intellij.openapi.vcs.VcsDataKeys#CHANGES_SELECTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangesBrowserBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void calcData(Key<?> 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);
  }
}
 
Example 2
Source File: VcsChangesSelectionRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ChangesSelection> getKey() {
  return VcsDataKeys.CHANGES_SELECTION;
}