当前位置: 首页>>代码示例>>Java>>正文


Java DataProvider.getData方法代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.DataProvider.getData方法的典型用法代码示例。如果您正苦于以下问题:Java DataProvider.getData方法的具体用法?Java DataProvider.getData怎么用?Java DataProvider.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.actionSystem.DataProvider的用法示例。


在下文中一共展示了DataProvider.getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AnalysisScopeRule.java

示例2: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ContentManagerImpl.java

示例3: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FileTextRule.java

示例4: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiElementFromSelectionsRule.java

示例5: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:AnalysisScopeRule.java

示例6: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ContentManagerImpl.java

示例7: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:FileTextRule.java

示例8: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:RunnerLayoutUiImpl.java

示例9: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:DesktopContentManagerImpl.java

示例10: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
public Object getData(@NonNls String dataId) {
  if (myEditor instanceof DataProvider) {
    DataProvider provider = (DataProvider)myEditor;
    return provider.getData(dataId);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:SettingsDialog.java

示例11: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Object getData(DataProvider dataProvider) {
  final Editor editor = (Editor)dataProvider.getData(CommonDataKeys.EDITOR.getName());
  if (editor == null || editor.isDisposed()) {
    return null;
  }

  final Boolean aBoolean = editor.getUserData(EditorTextField.SUPPLEMENTARY_KEY);
  if (aBoolean != null && aBoolean.booleanValue()) {
    return null;
  }

  return TextEditorProvider.getInstance().getTextEditor(editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:FileEditorRule.java

示例12: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Object getData(DataProvider dataProvider) {
  final Object element = dataProvider.getData(PlatformDataKeys.SELECTED_ITEM.getName());
  if (element instanceof PsiElement) {
    PsiElement psiElement = (PsiElement)element;
    if (psiElement.isValid()) {
      return element;
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PsiElementFromSelectionRule.java

示例13: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
@Nullable
public Object getData(final DataProvider dataProvider) {
  UsageInfo usageInfo = (UsageInfo)dataProvider.getData(UsageView.USAGE_INFO_KEY.getName());
  if (usageInfo != null) return Collections.singletonList(usageInfo);
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:UsageInfo2ListRule.java

示例14: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Object getData(DataProvider dataProvider) {
  final Editor editor = (Editor)dataProvider.getData(PlatformDataKeys.EDITOR.getName());
  if (editor == null || editor.isDisposed()) {
    return null;
  }

  final Boolean aBoolean = editor.getUserData(EditorTextField.SUPPLEMENTARY_KEY);
  if (aBoolean != null && aBoolean.booleanValue()) {
    return null;
  }

  return TextEditorProvider.getInstance().getTextEditor(editor);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:FileEditorRule.java

示例15: getData

import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Nullable
public Object getData(final DataProvider dataProvider) {
  return dataProvider.getData(CommonDataKeys.EDITOR.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:InactiveEditorRule.java


注:本文中的com.intellij.openapi.actionSystem.DataProvider.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。