@Nullable @Override public Object getData(@NonNls String dataId) { Object data; DataProvider contentProvider = DataManagerImpl.getDataProviderEx(myContentPanel.getTargetComponent()); if (contentProvider != null) { data = contentProvider.getData(dataId); if (data != null) return data; } if (CommonDataKeys.PROJECT.is(dataId)) { return myProject; } else if (PlatformDataKeys.HELP_ID.is(dataId)) { if (myRequest.getUserData(DiffUserDataKeys.HELP_ID) != null) { return myRequest.getUserData(DiffUserDataKeys.HELP_ID); } else { return "procedures.vcWithIDEA.commonVcsOps.integrateDiffs.resolveConflict"; } } DataProvider requestProvider = myRequest.getUserData(DiffUserDataKeys.DATA_PROVIDER); if (requestProvider != null) { data = requestProvider.getData(dataId); if (data != null) return data; } DataProvider contextProvider = myContext.getUserData(DiffUserDataKeys.DATA_PROVIDER); if (contextProvider != null) { data = contextProvider.getData(dataId); if (data != null) return data; } return null; }
@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); } } } }