本文整理汇总了Java中com.intellij.openapi.actionSystem.impl.SimpleDataContext.getSimpleContext方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleDataContext.getSimpleContext方法的具体用法?Java SimpleDataContext.getSimpleContext怎么用?Java SimpleDataContext.getSimpleContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.actionSystem.impl.SimpleDataContext
的用法示例。
在下文中一共展示了SimpleDataContext.getSimpleContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveClass
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
DataManager dataManager = DataManager.getInstance();
DataContext dataContext = dataManager.getDataContext();
final String fqName = aClass.getQualifiedName();
LOG.assertTrue(fqName != null);
PsiDirectory directory = PackageUtil
.findOrCreateDirectoryForPackage(myCurrentModule, StringUtil.getPackageName(fqName), mySourceRoot, true);
DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory, dataContext);
moveHandler.invoke(project, new PsiElement[]{aClass}, context);
PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.moduleScope(myCurrentModule));
if (reference != null && newClass != null) {
final QuestionAction action = new AddImportAction(project, reference, editor, newClass);
action.execute();
}
}
示例2: checkMove
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
private void checkMove(File jar, VirtualFile vFile, final PsiFile file) {
VirtualFile jarRoot;
File libDir = new File(jar.getParent(), "lib");
assertTrue(libDir.mkdir());
final VirtualFile vLibDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libDir);
assertNotNull(vLibDir);
jarRoot = findByPath(vFile.getPath() + JarFileSystem.JAR_SEPARATOR);
assertTrue(jarRoot.isValid());
PsiDirectory directory = getPsiManager().findDirectory(vLibDir);
final DataContext
psiDataContext = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory);
new WriteCommandAction.Simple(myProject) {
@Override
protected void run() throws Throwable {
new MoveHandler().invoke(myProject, new PsiElement[] {file}, psiDataContext);
}
}.execute();
assertFalse(jarRoot.isValid());
jarRoot = findByPath(vFile.getPath() + JarFileSystem.JAR_SEPARATOR);
assertTrue(jarRoot.isValid());
rename(directory, "lib2");
assertFalse(jarRoot.isValid());
}
示例3: isAvailableFor
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@Override
public boolean isAvailableFor(@NotNull UsageView usageView) {
UsageTarget[] targets = ((UsageViewImpl)usageView).getTargets();
if (targets.length == 0) return false;
UsageTarget target = targets[0];
if (!(target instanceof PsiElementUsageTarget)) return false;
PsiElement element = ((PsiElementUsageTarget)target).getElement();
if (element == null || !element.isValid()) return false;
Project project = element.getProject();
DataContext context = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), element,
SimpleDataContext.getProjectContext(project));
HierarchyProvider provider = BrowseHierarchyActionBase.findBestHierarchyProvider(LanguageCallHierarchy.INSTANCE, element, context);
if (provider == null) return false;
PsiElement providerTarget = provider.getTarget(context);
return providerTarget != null;
}
示例4: execute
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@Override
protected void execute(@NotNull Project project, @NotNull DataContext dataContext, final ProgressHandler progressHandler) {
DataContext wrappedDataContext = SimpleDataContext.getSimpleContext(VERIFY_CONTENT_WITH_WARNINGS, true, dataContext);
boolean verificationSuccessful = doVerify(project, wrappedDataContext, progressHandler);
// Notification are added
if(ApplicationManager.getApplication().isDispatchThread()) {
getMessageManager(project).showAlertWithArguments(
NotificationType.INFORMATION,
verificationSuccessful ?
"server.configuration.verification.successful" :
"server.configuration.verification.failed"
);
} else {
getMessageManager(project).sendNotification(
verificationSuccessful ?
"server.configuration.verification.successful" :
"server.configuration.verification.failed"
,
NotificationType.INFORMATION
);
}
}
示例5: isAvailableFor
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@Override
public boolean isAvailableFor(@NotNull UsageView usageView) {
UsageTarget[] targets = ((UsageViewImpl)usageView).getTargets();
if (targets.length == 0) return false;
UsageTarget target = targets[0];
if (!(target instanceof PsiElementUsageTarget)) return false;
PsiElement element = ((PsiElementUsageTarget)target).getElement();
if (element == null || !element.isValid()) return false;
Project project = element.getProject();
DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.PSI_ELEMENT.getName(), element,
SimpleDataContext.getProjectContext(project));
HierarchyProvider provider = BrowseHierarchyActionBase.findBestHierarchyProvider(LanguageCallHierarchy.INSTANCE, element, context);
if (provider == null) return false;
PsiElement providerTarget = provider.getTarget(context);
return providerTarget != null;
}
示例6: createCallHierarchyPanel
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@Nullable
private static HierarchyBrowser createCallHierarchyPanel(@NotNull PsiElement element) {
DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.PSI_ELEMENT.getName(), element, SimpleDataContext.getProjectContext(element.getProject()));
HierarchyProvider provider = BrowseHierarchyActionBase.findBestHierarchyProvider(LanguageCallHierarchy.INSTANCE, element, context);
if (provider == null) return null;
PsiElement providerTarget = provider.getTarget(context);
if (providerTarget == null) return null;
HierarchyBrowser browser = provider.createHierarchyBrowser(providerTarget);
if (browser instanceof HierarchyBrowserBaseEx) {
HierarchyBrowserBaseEx browserEx = (HierarchyBrowserBaseEx)browser;
browserEx.changeView(CallHierarchyBrowserBase.CALLER_TYPE);
final ProgressIndicatorBase indicator = new ProgressIndicatorBase();
Disposer.register(browserEx, new Disposable() {
@Override
public void dispose() {
indicator.cancel();
}
});
browserEx.setProgressIndicator(indicator);
}
return browser;
}
示例7: doAction
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
protected void doAction(MouseEvent e) {
final DefaultActionGroup group = createActionGroup();
final DataContext parent = DataManager.getInstance().getDataContext(myPanel.getParent());
final DataContext dataContext = SimpleDataContext.getSimpleContext(PlatformDataKeys.PROJECT.getName(), myProject, parent);
final JBPopup popup = JBPopupFactory.getInstance()
.createActionGroupPopup(null, group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true,
new Runnable() {
@Override
public void run() {
// todo ?
}
}, 20);
if (e != null) {
popup.show(new RelativePoint(e));
} else {
final Dimension dimension = popup.getContent().getPreferredSize();
final Point at = new Point(-dimension.width / 2, -dimension.height);
popup.show(new RelativePoint(myLabel, at));
}
}
示例8: isAvailableFor
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@Override
public boolean isAvailableFor(@Nonnull UsageView usageView) {
UsageTarget[] targets = ((UsageViewImpl)usageView).getTargets();
if (targets.length == 0) return false;
UsageTarget target = targets[0];
if (!(target instanceof PsiElementUsageTarget)) return false;
PsiElement element = ((PsiElementUsageTarget)target).getElement();
if (element == null || !element.isValid()) return false;
Project project = element.getProject();
DataContext context = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT, element,
SimpleDataContext.getProjectContext(project));
HierarchyProvider provider = BrowseHierarchyActionBase.findBestHierarchyProvider(LanguageCallHierarchy.INSTANCE, element, context);
if (provider == null) return false;
PsiElement providerTarget = provider.getTarget(context);
return providerTarget != null;
}
示例9: moveClass
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
DataManager dataManager = DataManager.getInstance();
DataContext dataContext = dataManager.getDataContext();
final String fqName = aClass.getQualifiedName();
LOG.assertTrue(fqName != null);
PsiDirectory directory = PackageUtil
.findOrCreateDirectoryForPackage(myCurrentModule, StringUtil.getPackageName(fqName), mySourceRoot, true);
DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT, directory, dataContext);
moveHandler.invoke(project, new PsiElement[]{aClass}, context);
PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.moduleScope(myCurrentModule));
if (reference != null && newClass != null) {
final QuestionAction action = new AddImportAction(project, reference, editor, newClass);
action.execute();
}
}
示例10: dataContext
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@SuppressWarnings("SameParameterValue")
private static DataContext dataContext(@Nullable DataContext parent, boolean autoTriggered) {
HashMap<String, Object> dataMap = new HashMap<>();
//dataMap.put(CommonDataKeys.PROJECT.getName(), project);
//if (editor != null) dataMap.put(CommonDataKeys.EDITOR.getName(), editor);
dataMap.put(AUTO_TRIGGERED_ACTION.getName(), autoTriggered);
return SimpleDataContext.getSimpleContext(dataMap, parent);
}
示例11: createEditorContext
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@NotNull
private static DataContext createEditorContext(@NotNull Editor editor) {
Object e = editor;
Object hostEditor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
Map<String, Object> map = ContainerUtil.newHashMap(Pair.create(CommonDataKeys.HOST_EDITOR.getName(), hostEditor),
Pair.createNonNull(CommonDataKeys.EDITOR.getName(), e));
DataContext parent = DataManager.getInstance().getDataContext(editor.getContentComponent());
return SimpleDataContext.getSimpleContext(map, parent);
}
示例12: getContext
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@NotNull
private DataContext getContext() {
Editor editor = getEditor();
DataContext parent = DataManager.getInstance().getDataContext((Component)myStatusBar);
return SimpleDataContext.getSimpleContext(
CommonDataKeys.VIRTUAL_FILE_ARRAY.getName(),
new VirtualFile[] {getSelectedFile()},
SimpleDataContext.getSimpleContext(CommonDataKeys.PROJECT.getName(),
getProject(),
SimpleDataContext.getSimpleContext(PlatformDataKeys.CONTEXT_COMPONENT.getName(),
editor == null ? null : editor.getComponent(), parent)
));
}
示例13: getContext
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
@NotNull
private DataContext getContext() {
Editor editor = getEditor();
DataContext parent = DataManager.getInstance().getDataContext((Component)myStatusBar);
return SimpleDataContext.getSimpleContext(CommonDataKeys.VIRTUAL_FILE.getName(), getSelectedFile(),
SimpleDataContext.getSimpleContext(CommonDataKeys.PROJECT.getName(), getProject(),
SimpleDataContext.getSimpleContext(PlatformDataKeys.CONTEXT_COMPONENT.getName(), editor == null ? null : editor.getComponent(), parent)
));
}
示例14: rename
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
private static void rename(final PsiNamedElement file, final String newName) {
final DataContext psiDataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), file);
final RenameHandler renameHandler =
RenameHandlerRegistry.getInstance().getRenameHandler(psiDataContext);
assertNotNull(renameHandler);
new WriteCommandAction.Simple(file.getProject()) {
@Override
public void run() {
PsiElementRenameHandler.rename(file, file.getProject(), file, null, newName);
}
}.execute();
}
示例15: getContext
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入方法依赖的package包/类
public DataContext getContext(VirtualFile file) {
Project project = myFixture.getProject();
Map<String, Object> dataId2data = new THashMap<String, Object>();
dataId2data.put(CommonDataKeys.PROJECT.getName(), project);
dataId2data.put(CommonDataKeys.VIRTUAL_FILE.getName(), file);
dataId2data.put(PlatformDataKeys.PROJECT_FILE_DIRECTORY.getName(), project.getBaseDir());
return SimpleDataContext.getSimpleContext(dataId2data, null);
}