本文整理汇总了Java中com.intellij.openapi.actionSystem.impl.SimpleDataContext类的典型用法代码示例。如果您正苦于以下问题:Java SimpleDataContext类的具体用法?Java SimpleDataContext怎么用?Java SimpleDataContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleDataContext类属于com.intellij.openapi.actionSystem.impl包,在下文中一共展示了SimpleDataContext类的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: createActionGroupPopup
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor) {
final DefaultActionGroup group = new DefaultActionGroup();
for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
if (shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file)) {
group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
}
}
if (group.getChildrenCount() > 0) {
final DataContext context = SimpleDataContext.getProjectContext(null);
return JBPopupFactory.getInstance()
.createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
}
return null;
}
示例3: 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());
}
示例4: 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;
}
示例5: 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
);
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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));
}
}
示例9: BranchActionGroupPopup
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入依赖的package包/类
public BranchActionGroupPopup(@Nonnull String title, @Nonnull Project project, @Nonnull Condition<AnAction> preselectActionCondition, @Nonnull ActionGroup actions, @Nullable String dimensionKey) {
super(title, new DefaultActionGroup(actions, createBranchSpeedSearchActionGroup(actions)), SimpleDataContext.getProjectContext(project), preselectActionCondition, true);
myProject = project;
DataManager.registerDataProvider(getList(), dataId -> POPUP_MODEL == dataId ? getListModel() : null);
myKey = dimensionKey;
if (myKey != null) {
Dimension storedSize = WindowStateService.getInstance(myProject).getSizeFor(myProject, myKey);
if (storedSize != null) {
//set forced size before component is shown
setSize(storedSize);
myUserSizeChanged = true;
}
createTitlePanelToolbar(myKey);
}
myMeanRowHeight = getList().getCellBounds(0, 0).height + UIUtil.getListCellVPadding() * 2;
}
示例10: 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;
}
示例11: 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();
}
}
示例12: createActionGroupPopup
import com.intellij.openapi.actionSystem.impl.SimpleDataContext; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor)
{
final DefaultActionGroup group = new DefaultActionGroup();
for(final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions())
{
if(shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file))
{
group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
}
}
if(group.getChildrenCount() > 0)
{
final DataContext context = SimpleDataContext.getProjectContext(null);
return JBPopupFactory.getInstance().createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
}
return null;
}
示例13: 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);
}
示例14: 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);
}
示例15: 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)
));
}