Java 类com.intellij.openapi.actionSystem.DataProvider 实例源码

项目:intellij-ce-playground    文件:AnalysisScopeRule.java   
@Override
public Object getData(final DataProvider dataProvider) {
  final Object psiFile = dataProvider.getData(CommonDataKeys.PSI_FILE.getName());
  if (psiFile instanceof PsiJavaFile) {
    return new JavaAnalysisScope((PsiJavaFile)psiFile);
  }
  Object psiTarget = dataProvider.getData(CommonDataKeys.PSI_ELEMENT.getName());
  if (psiTarget instanceof PsiPackage) {
    PsiPackage pack = (PsiPackage)psiTarget;
    PsiManager manager = pack.getManager();
    if (!manager.isInProject(pack)) return null;
    PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject()));
    if (dirs.length == 0) return null;
    return new JavaAnalysisScope(pack, (Module)dataProvider.getData(LangDataKeys.MODULE.getName()));
  }
  return null;
}
项目:intellij-ce-playground    文件:DirDiffFrame.java   
public DirDiffFrame(Project project, DirDiffTableModel model) {
  super(project, "DirDiffDialog");
  setSize(JBUI.size(800, 600));
  setTitle(model.getTitle());
  myPanel = new DirDiffPanel(model, new DirDiffWindow(this));
  Disposer.register(this, myPanel);
  setComponent(myPanel.getPanel());
  if (project != null) {
    setProject(project);
  }
  closeOnEsc();
  DataManager.registerDataProvider(myPanel.getPanel(), new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      if (PlatformDataKeys.HELP_ID.is(dataId)) {
        return "reference.dialogs.diff.folder";
      }
      return null;
    }
  });
}
项目:intellij-ce-playground    文件:DiffPanelBase.java   
public DiffPanelBase(@Nullable Project project,
                     @NotNull DataProvider provider,
                     @NotNull DiffContext context) {
  super(new BorderLayout());
  myProject = project;
  myDataProvider = provider;
  myContext = context;

  myCardLayout = new CardLayout();
  myContentPanel = new JPanel(myCardLayout);

  myNotificationsPanel = new JPanel();
  myNotificationsPanel.setLayout(new BoxLayout(myNotificationsPanel, BoxLayout.Y_AXIS));

  myNorthPanel = new Wrapper();
  mySouthPanel = new Wrapper();

  add(myContentPanel, BorderLayout.CENTER);
  add(myNorthPanel, BorderLayout.NORTH);
  add(mySouthPanel, BorderLayout.SOUTH);
}
项目:intellij-ce-playground    文件:EditorComposite.java   
@Override
public final Object getData(String dataId){
  if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
    return getSelectedEditor();
  }
  else if(CommonDataKeys.VIRTUAL_FILE.is(dataId)){
    return myFile.isValid() ? myFile : null;
  }
  else if(CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)){
    return myFile.isValid() ? new VirtualFile[] {myFile} : null;
  }
  else{
    JComponent component = getPreferredFocusedComponent();
    if(component instanceof DataProvider && component != this){
      return ((DataProvider)component).getData(dataId);
    }
    else{
      return null;
    }
  }
}
项目:intellij-ce-playground    文件:ContentManagerImpl.java   
@Override
@Nullable
public Object getData(@NonNls String dataId) {
  if (PlatformDataKeys.CONTENT_MANAGER.is(dataId) || PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.is(dataId) && getContentCount() > 1) {
    return ContentManagerImpl.this;
  }

  for (DataProvider dataProvider : dataProviders) {
    Object data = dataProvider.getData(dataId);
    if (data != null) {
      return data;
    }
  }

  if (myUI instanceof DataProvider) {
    return ((DataProvider)myUI).getData(dataId);
  }

  DataProvider provider = DataManager.getDataProvider(this);
  return provider == null ? null : provider.getData(dataId);
}
项目:intellij-ce-playground    文件:ShowSettingsUtilImpl.java   
public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) {
  ConfigurableGroup[] group = getConfigurableGroups(project, true);

  group = filterEmptyGroups(group);
  final Configurable configurable2Select = id2Select == null ? null : new ConfigurableVisitor.ByID(id2Select).find(group);

  if (Registry.is("ide.new.settings.view")) {
    new SettingsDialog(getProject(project), group, configurable2Select, filter).show();
    return;
  }
  final DialogWrapper dialog = getDialog(project, group, configurable2Select);

  new UiNotifyConnector.Once(dialog.getContentPane(), new Activatable.Adapter() {
    @Override
    public void showNotify() {
      final OptionsEditor editor = (OptionsEditor)((DataProvider)dialog).getData(OptionsEditor.KEY.getName());
      LOG.assertTrue(editor != null);
      editor.select(configurable2Select, filter);
    }
  });
  dialog.show();
}
项目:intellij-ce-playground    文件:FileTextRule.java   
public Object getData(DataProvider dataProvider) {
  final VirtualFile virtualFile = (VirtualFile)dataProvider.getData(CommonDataKeys.VIRTUAL_FILE.getName());
  if (virtualFile == null) {
    return null;
  }

  final FileType fileType = virtualFile.getFileType();
  if (fileType.isBinary() || fileType.isReadOnly()) {
    return null;
  }

  final Project project = (Project)dataProvider.getData(CommonDataKeys.PROJECT.getName());
  if (project == null) {
    return null;
  }

  final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  if (document == null) {
    return null;
  }

  return document.getText();
}
项目:intellij-ce-playground    文件:XDebuggerFramesList.java   
public XDebuggerFramesList(@NotNull final Project project) {
  super(project);

  doInit();
  setTransferHandler(DEFAULT_TRANSFER_HANDLER);
  setDataProvider(new DataProvider() {
    @Nullable
    @Override
    public Object getData(@NonNls String dataId) {
      if (mySelectedFrame != null) {
        if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
          return getFile(mySelectedFrame);
        }
        else if (CommonDataKeys.PSI_FILE.is(dataId)) {
          VirtualFile file = getFile(mySelectedFrame);
          if (file != null && file.isValid()) {
            return PsiManager.getInstance(myProject).findFile(file);
          }
        }
      }
      return null;
    }
  });
}
项目:intellij-ce-playground    文件:VcsRevisionNumberArrayRule.java   
@Nullable
public List<VcsRevisionNumber> getRevisionNumbers(@NotNull DataProvider dataProvider) {
  VcsRevisionNumber revisionNumber = VcsDataKeys.VCS_REVISION_NUMBER.getData(dataProvider);
  if (revisionNumber != null) {
    return Collections.singletonList(revisionNumber);
  }

  ChangeList[] changeLists = VcsDataKeys.CHANGE_LISTS.getData(dataProvider);
  if (changeLists != null && changeLists.length > 0) {
    List<CommittedChangeList> committedChangeLists = ContainerUtil.findAll(changeLists, CommittedChangeList.class);

    if (!committedChangeLists.isEmpty()) {
      ContainerUtil.sort(committedChangeLists, CommittedChangeListByDateComparator.DESCENDING);

      return ContainerUtil.mapNotNull(committedChangeLists, CommittedChangeListToRevisionNumberFunction.INSTANCE);
    }
  }

  VcsFileRevision[] fileRevisions = VcsDataKeys.VCS_FILE_REVISIONS.getData(dataProvider);
  if (fileRevisions != null && fileRevisions.length > 0) {
    return ContainerUtil.mapNotNull(fileRevisions, FileRevisionToRevisionNumberFunction.INSTANCE);
  }

  return null;
}
项目:intellij-ce-playground    文件:NavigationItemListCellRenderer.java   
protected static Color getBackgroundColor(@Nullable Object value) {
  if (value instanceof PsiElement || value instanceof DataProvider) {
    final PsiElement psiElement = value instanceof PsiElement
                                  ? (PsiElement)value
                                  : CommonDataKeys.PSI_ELEMENT.getData((DataProvider) value);
    if (psiElement != null && psiElement.isValid()) {
      final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject());
      final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile());
      if (fileColor != null) {
        return fileColor;
      }
    }
  }

  return UIUtil.getListBackground();
}
项目:intellij-ce-playground    文件:NavigatableRule.java   
@Override
public Object getData(DataProvider dataProvider) {
  final Navigatable navigatable = CommonDataKeys.NAVIGATABLE.getData(dataProvider);
  if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
    final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;

    if (openFileDescriptor.getFile().isValid()) {
      return openFileDescriptor;
    }
  }
  final PsiElement element = CommonDataKeys.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;
}
项目:intellij-ce-playground    文件:PsiElementFromSelectionsRule.java   
@Override
public Object getData(DataProvider dataProvider) {
  final Object[] objects = (Object[])dataProvider.getData(PlatformDataKeys.SELECTED_ITEMS.getName());
  if (objects != null) {
    final PsiElement[] elements = new PsiElement[objects.length];
    for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
      Object object = objects[i];
      if (!(object instanceof PsiElement)) return null;
      if (!((PsiElement)object).isValid()) return null;
      elements[i] = (PsiElement)object;
    }

    return elements;
  }
  return null;
}
项目:intellij-ce-playground    文件:MavenDomTestCase.java   
protected List<PsiElement> search(VirtualFile file) throws IOException {
  final MapDataContext context = createDataContext(file);
  UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      return context.getData(dataId);
    }
  });
  PsiElement target = ((PsiElement2UsageTargetAdapter)targets[0]).getElement();
  List<PsiReference> result = new ArrayList<PsiReference>(ReferencesSearch.search(target).findAll());
  return ContainerUtil.map(result, new Function<PsiReference, PsiElement>() {
    @Override
    public PsiElement fun(PsiReference psiReference) {
      return psiReference.getElement();
    }
  });
}
项目:intellij-ce-playground    文件:AsmCodeGeneratorTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  myNestedFormLoader = new MyNestedFormLoader();

  final String swingPath = PathUtil.getJarPathForClass(AbstractButton.class);

  java.util.List<URL> cp = new ArrayList<URL>();
  appendPath(cp, JBTabbedPane.class);
  appendPath(cp, TIntObjectHashMap.class);
  appendPath(cp, UIUtil.class);
  appendPath(cp, SystemInfoRt.class);
  appendPath(cp, ApplicationManager.class);
  appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/messages/UIBundle.properties"));
  appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties"));
  appendPath(cp, GridLayoutManager.class); // forms_rt
  appendPath(cp, DataProvider.class);
  myClassFinder = new MyClassFinder(
    new URL[] {new File(swingPath).toURI().toURL()},
    cp.toArray(new URL[cp.size()])
  );
}
项目:tools-idea    文件:AnalysisScopeRule.java   
@Override
public Object getData(final DataProvider dataProvider) {
  final Object psiFile = dataProvider.getData(LangDataKeys.PSI_FILE.getName());
  if (psiFile instanceof PsiJavaFile) {
    return new JavaAnalysisScope((PsiJavaFile)psiFile);
  }
  Object psiTarget = dataProvider.getData(LangDataKeys.PSI_ELEMENT.getName());
  if (psiTarget instanceof PsiPackage) {
    PsiPackage pack = (PsiPackage)psiTarget;
    PsiManager manager = pack.getManager();
    if (!manager.isInProject(pack)) return null;
    PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject()));
    if (dirs.length == 0) return null;
    return new JavaAnalysisScope(pack, (Module)dataProvider.getData(LangDataKeys.MODULE.getName()));
  }
  return null;
}
项目:tools-idea    文件:EditorComposite.java   
public final Object getData(String dataId){
  if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
    return getSelectedEditor();
  }
  else if(PlatformDataKeys.VIRTUAL_FILE.is(dataId)){
    return myFile.isValid() ? myFile : null;
  }
  else if(PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)){
    return myFile.isValid() ? new VirtualFile[] {myFile} : null;
  }
  else{
    JComponent component = getPreferredFocusedComponent();
    if(component instanceof DataProvider && component != this){
      return ((DataProvider)component).getData(dataId);
    }
    else{
      return null;
    }
  }
}
项目:tools-idea    文件:ContentManagerImpl.java   
@Override
@Nullable
public Object getData(@NonNls final String dataId) {
  if (PlatformDataKeys.CONTENT_MANAGER.is(dataId)) return ContentManagerImpl.this;
  if (PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.is(dataId) && getContentCount() > 1) {
    return ContentManagerImpl.this;
  }

  for (DataProvider each : myProviders) {
    final Object data = each.getData(dataId);
    if (data != null) return data;
  }

  if (myUI instanceof DataProvider) {
    return ((DataProvider)myUI).getData(dataId);
  }

  return null;
}
项目:tools-idea    文件:FileTextRule.java   
public Object getData(DataProvider dataProvider) {
  final VirtualFile virtualFile = (VirtualFile)dataProvider.getData(PlatformDataKeys.VIRTUAL_FILE.getName());
  if (virtualFile == null) {
    return null;
  }

  final FileType fileType = virtualFile.getFileType();
  if (fileType.isBinary() || fileType.isReadOnly()) {
    return null;
  }

  final Project project = (Project)dataProvider.getData(PlatformDataKeys.PROJECT.getName());
  if (project == null) {
    return null;
  }

  final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  if (document == null) {
    return null;
  }

  return document.getText();
}
项目:tools-idea    文件:RunContentDescriptor.java   
public RunContentDescriptor(final ExecutionConsole executionConsole,
                            final ProcessHandler processHandler, final JComponent component, final String displayName, final Icon icon) {
  myExecutionConsole = executionConsole;
  myProcessHandler = processHandler;
  myComponent = component;
  myDisplayName = displayName;
  myIcon = icon;
  myHelpId = myExecutionConsole instanceof HelpIdProvider ? ((HelpIdProvider)myExecutionConsole).getHelpId() : null;
  DataManager.registerDataProvider(myComponent, new DataProvider() {

    @Override
    public Object getData(@NonNls final String dataId) {
      if (RunContentManager.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
        return RunContentDescriptor.this;
      }
      return null;
    }
  });
}
项目:tools-idea    文件:DirDiffFrame.java   
public DirDiffFrame(Project project, DirDiffTableModel model) {
  super(project, "DirDiffDialog");
  setSize(new Dimension(800, 600));
  setTitle(model.getTitle());
  myPanel = new DirDiffPanel(model, new DirDiffWindow(this));
  Disposer.register(this, myPanel);
  setComponent(myPanel.getPanel());
  if (project != null) {
    setProject(project);
  }
  closeOnEsc();
  DataManager.registerDataProvider(myPanel.getPanel(), new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      if (PlatformDataKeys.HELP_ID.is(dataId)) {
        return "reference.dialogs.diff.folder";
      }
      return null;
    }
  });
}
项目:tools-idea    文件:RunnerLayoutUiImpl.java   
@Override
public Object getData(@NonNls String dataId) {
  if (SwitchProvider.KEY.getName().equals(dataId)) {
    return myContentUI;
  }

  if (QuickActionProvider.KEY.getName().equals(dataId)) {
    return myContentUI;
  }

  if (RunnerContentUi.KEY.getName().equals(dataId)) {
    return myContentUI;
  }

  final DataProvider provider = DataManager.getDataProvider(this);
  return provider != null ? provider.getData(dataId) : null;
}
项目:tools-idea    文件:NavigationItemListCellRenderer.java   
protected static Color getBackgroundColor(@Nullable Object value) {
  if (value instanceof PsiElement || value instanceof DataProvider) {
    final PsiElement psiElement = value instanceof PsiElement
                                  ? (PsiElement)value
                                  : LangDataKeys.PSI_ELEMENT.getData((DataProvider) value);
    if (psiElement != null) {
      final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject());
      final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile());
      if (fileColor != null) {
        return fileColor;
      }
    }
  }

  return UIUtil.getListBackground();
}
项目:tools-idea    文件:NavigatableRule.java   
@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;
    }
  }
  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;
}
项目:tools-idea    文件:PsiElementFromSelectionsRule.java   
@Override
public Object getData(DataProvider dataProvider) {
  final Object[] objects = (Object[])dataProvider.getData(PlatformDataKeys.SELECTED_ITEMS.getName());
  if (objects != null) {
    final PsiElement[] elements = new PsiElement[objects.length];
    for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
      Object object = objects[i];
      if (!(object instanceof PsiElement)) return null;
      if (!((PsiElement)object).isValid()) return null;
      elements[i] = (PsiElement)object;
    }

    return elements;
  }
  return null;
}
项目:tools-idea    文件:MavenDomTestCase.java   
protected List<PsiElement> search(VirtualFile file) throws IOException {
  final MapDataContext context = createDataContext(file);
  UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      return context.getData(dataId);
    }
  });
  PsiElement target = ((PsiElement2UsageTargetAdapter)targets[0]).getElement();
  List<PsiReference> result = new ArrayList<PsiReference>(ReferencesSearch.search(target).findAll());
  return ContainerUtil.map(result, new Function<PsiReference, PsiElement>() {
    @Override
    public PsiElement fun(PsiReference psiReference) {
      return psiReference.getElement();
    }
  });
}
项目:consulo    文件:DirDiffFrame.java   
public DirDiffFrame(Project project, DirDiffTableModel model) {
  super(project, "DirDiffDialog");
  setSize(new Dimension(800, 600));
  setTitle(model.getTitle());
  myPanel = new DirDiffPanel(model, new DirDiffWindow(this));
  Disposer.register(this, myPanel);
  setComponent(myPanel.getPanel());
  if (project != null) {
    setProject(project);
  }
  closeOnEsc();
  DataManager.registerDataProvider(myPanel.getPanel(), new DataProvider() {
    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      if (PlatformDataKeys.HELP_ID == dataId) {
        return "reference.dialogs.diff.folder";
      }
      return null;
    }
  });
}
项目:consulo    文件:DiffPanelBase.java   
public DiffPanelBase(@Nullable Project project,
                     @Nonnull DataProvider provider,
                     @Nonnull DiffContext context) {
  super(new BorderLayout());
  myProject = project;
  myDataProvider = provider;
  myContext = context;

  myCardLayout = new CardLayout();
  myContentPanel = new JPanel(myCardLayout);

  myNotificationsPanel = new JPanel();
  myNotificationsPanel.setLayout(new BoxLayout(myNotificationsPanel, BoxLayout.Y_AXIS));

  myNorthPanel = new Wrapper();
  mySouthPanel = new Wrapper();

  add(myContentPanel, BorderLayout.CENTER);
  add(myNorthPanel, BorderLayout.NORTH);
  add(mySouthPanel, BorderLayout.SOUTH);
}
项目:consulo    文件:EditorComposite.java   
@Override
public final Object getData(@Nonnull Key<?> dataId){
  if (PlatformDataKeys.FILE_EDITOR == dataId) {
    return getSelectedEditor();
  }
  else if(CommonDataKeys.VIRTUAL_FILE == dataId){
    return myFile.isValid() ? myFile : null;
  }
  else if(CommonDataKeys.VIRTUAL_FILE_ARRAY == dataId){
    return myFile.isValid() ? new VirtualFile[] {myFile} : null;
  }
  else{
    JComponent component = getPreferredFocusedComponent();
    if(component instanceof DataProvider && component != this){
      return ((DataProvider)component).getData(dataId);
    }
    return null;
  }
}
项目:consulo    文件:DesktopContentManagerImpl.java   
@Override
@Nullable
public Object getData(@Nonnull @NonNls Key<?> dataId) {
  if (PlatformDataKeys.CONTENT_MANAGER == dataId || PlatformDataKeys.NONEMPTY_CONTENT_MANAGER == dataId && getContentCount() > 1) {
    return DesktopContentManagerImpl.this;
  }

  for (DataProvider dataProvider : myDataProviders) {
    Object data = dataProvider.getData(dataId);
    if (data != null) {
      return data;
    }
  }

  if (myUI instanceof DataProvider) {
    return ((DataProvider)myUI).getData(dataId);
  }

  DataProvider provider = DataManager.getDataProvider(this);
  return provider == null ? null : provider.getData(dataId);
}
项目:consulo    文件:FileTextRule.java   
@Override
public String getData(@Nonnull DataProvider dataProvider) {
  final VirtualFile virtualFile = dataProvider.getDataUnchecked(PlatformDataKeys.VIRTUAL_FILE);
  if (virtualFile == null) {
    return null;
  }

  final FileType fileType = virtualFile.getFileType();
  if (fileType.isBinary() || fileType.isReadOnly()) {
    return null;
  }

  final Project project = dataProvider.getDataUnchecked(CommonDataKeys.PROJECT);
  if (project == null) {
    return null;
  }

  final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  if (document == null) {
    return null;
  }

  return document.getText();
}
项目:consulo    文件:XDebuggerFramesList.java   
public XDebuggerFramesList(@Nonnull Project project) {
  myProject = project;

  doInit();
  setTransferHandler(DEFAULT_TRANSFER_HANDLER);
  setDataProvider(new DataProvider() {
    @Nullable
    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      if (mySelectedFrame != null) {
        if (CommonDataKeys.VIRTUAL_FILE == dataId) {
          return getFile(mySelectedFrame);
        }
        else if (CommonDataKeys.PSI_FILE == dataId) {
          VirtualFile file = getFile(mySelectedFrame);
          if (file != null && file.isValid()) {
            return PsiManager.getInstance(myProject).findFile(file);
          }
        }
      }
      return null;
    }
  });
}
项目:consulo    文件:VcsRevisionNumberArrayRule.java   
@Nullable
public List<VcsRevisionNumber> getRevisionNumbers(@Nonnull DataProvider dataProvider) {
  VcsRevisionNumber revisionNumber = dataProvider.getDataUnchecked(VcsDataKeys.VCS_REVISION_NUMBER);
  if (revisionNumber != null) {
    return Collections.singletonList(revisionNumber);
  }

  ChangeList[] changeLists = dataProvider.getDataUnchecked(VcsDataKeys.CHANGE_LISTS);
  if (changeLists != null && changeLists.length > 0) {
    List<CommittedChangeList> committedChangeLists = ContainerUtil.findAll(changeLists, CommittedChangeList.class);

    if (!committedChangeLists.isEmpty()) {
      ContainerUtil.sort(committedChangeLists, CommittedChangeListByDateComparator.DESCENDING);

      return ContainerUtil.mapNotNull(committedChangeLists, CommittedChangeListToRevisionNumberFunction.INSTANCE);
    }
  }

  VcsFileRevision[] fileRevisions = dataProvider.getDataUnchecked(VcsDataKeys.VCS_FILE_REVISIONS);
  if (fileRevisions != null && fileRevisions.length > 0) {
    return ContainerUtil.mapNotNull(fileRevisions, FileRevisionToRevisionNumberFunction.INSTANCE);
  }

  return null;
}
项目:consulo    文件:NavigatableRule.java   
@Override
public Navigatable getData(@Nonnull DataProvider dataProvider) {
  final Navigatable navigatable = dataProvider.getDataUnchecked(PlatformDataKeys.NAVIGATABLE);
  if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
    final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;

    if (openFileDescriptor.getFile().isValid()) {
      return openFileDescriptor;
    }
  }
  final PsiElement element = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
  if (element instanceof Navigatable) {
    return (Navigatable)element;
  }
  if (element != null) {
    return EditSourceUtil.getDescriptor(element);
  }

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

  return null;
}
项目:consulo    文件:PsiElementFromSelectionsRule.java   
@Override
public PsiElement[] getData(@Nonnull DataProvider dataProvider) {
  final Object[] objects = dataProvider.getDataUnchecked(PlatformDataKeys.SELECTED_ITEMS);
  if (objects != null) {
    final PsiElement[] elements = new PsiElement[objects.length];
    for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
      Object object = objects[i];
      if (!(object instanceof PsiElement)) return null;
      if (!((PsiElement)object).isValid()) return null;
      elements[i] = (PsiElement)object;
    }

    return elements;
  }
  return null;
}
项目:consulo-java    文件:AnalysisScopeRule.java   
@Override
public AnalysisScope getData(@NotNull final DataProvider dataProvider)
{
    final Object psiFile = dataProvider.getDataUnchecked(LangDataKeys.PSI_FILE);
    if(psiFile instanceof PsiJavaFile)
    {
        return new JavaAnalysisScope((PsiJavaFile) psiFile);
    }
    Object psiTarget = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
    if(psiTarget instanceof PsiJavaPackage)
    {
        PsiJavaPackage pack = (PsiJavaPackage) psiTarget;
        PsiManager manager = pack.getManager();
        if(!manager.isInProject(pack))
        {
            return null;
        }
        PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject()));
        if(dirs.length == 0)
        {
            return null;
        }
        return new JavaAnalysisScope(pack, dataProvider.getDataUnchecked(LangDataKeys.MODULE));
    }
    return null;
}
项目:intellij-ce-playground    文件:UnifiedDiffPanel.java   
public UnifiedDiffPanel(@Nullable Project project,
                        @NotNull UnifiedContentPanel content,
                        @NotNull DataProvider provider,
                        @NotNull DiffContext context) {
  super(project, provider, context);
  myBusyIcon = new AsyncProcessIcon.Big("UnifiedDiff");
  JPanel centerPanel = JBUI.Panels.simplePanel(content).addToTop(myNotificationsPanel);
  myContentPanel.add(centerPanel, GOOD_CONTENT);
  myContentPanel.add(myBusyIcon, LOADING_CONTENT);
  myContentPanel.add(createMessagePanel("Can not calculate diff. " + DiffTooBigException.MESSAGE), TOO_BIG_CONTENT);
  myContentPanel.add(createMessagePanel("Can not calculate diff. Operation canceled."), OPERATION_CANCELED_CONTENT);
  myContentPanel.add(createMessagePanel("Error"), ERROR_CONTENT);

  setCurrentCard(LOADING_CONTENT, false);
}
项目:intellij-ce-playground    文件:SimpleDiffPanel.java   
public SimpleDiffPanel(@NotNull JComponent editorPanel,
                       @NotNull DataProvider dataProvider,
                       @NotNull DiffContext context) {
  super(context.getProject(), dataProvider, context);
  JPanel centerPanel = JBUI.Panels.simplePanel(editorPanel).addToTop(myNotificationsPanel);

  myContentPanel.add(centerPanel, GOOD_CONTENT);
  myContentPanel.add(DiffUtil.createMessagePanel("Error"), ERROR_CONTENT);

  setCurrentCard(GOOD_CONTENT, false);
}
项目:intellij-ce-playground    文件:DockableEditorTabbedContainer.java   
@Override
public void add(@NotNull DockableContent content, RelativePoint dropTarget) {
  EditorWindow window = null;
  if (myCurrentOver != null) {
    final DataProvider provider = myCurrentOver.getDataProvider();
    if (provider != null) {
      window = EditorWindow.DATA_KEY.getData(provider);
    }
  }

  final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content;
  VirtualFile file = dockableEditor.getFile();


  if (window == null || window.isDisposed()) {
    window = mySplitters.getOrCreateCurrentWindow(file);
  }


  if (myCurrentOver != null) {
    int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex();
    file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index);
  }

  ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true);
  window.setFilePinned(file, dockableEditor.isPinned());
}
项目:intellij-ce-playground    文件:SettingsDialog.java   
public Object getData(@NonNls String dataId) {
  if (myEditor instanceof DataProvider) {
    DataProvider provider = (DataProvider)myEditor;
    return provider.getData(dataId);
  }
  return null;
}
项目:intellij-ce-playground    文件:GlassPaneDialogWrapperPeer.java   
@Override
public Object getData(@NonNls final String dataId) {
  final DialogWrapper wrapper = myDialogWrapper.get();
  if (wrapper instanceof DataProvider) {
    return ((DataProvider) wrapper).getData(dataId);
  } else if (wrapper instanceof TypeSafeDataProvider) {
    TypeSafeDataProviderAdapter adapter = new TypeSafeDataProviderAdapter((TypeSafeDataProvider) wrapper);
    return adapter.getData(dataId);
  }
  return null;
}