本文整理汇总了Java中com.intellij.ide.IdeView.selectElement方法的典型用法代码示例。如果您正苦于以下问题:Java IdeView.selectElement方法的具体用法?Java IdeView.selectElement怎么用?Java IdeView.selectElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.IdeView
的用法示例。
在下文中一共展示了IdeView.selectElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFromTemplate
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
public static void createFromTemplate(@NotNull Project project,
@NotNull PsiDirectory taskDirectory,
@NotNull String name,
@Nullable IdeView view,
boolean open) {
FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate(name);
if (template == null) {
LOG.info("Template " + name + " wasn't found");
return;
}
try {
final PsiElement file = FileTemplateUtil.createFromTemplate(template, name, null, taskDirectory);
if (view != null && open) {
EditorHelper.openInEditor(file, false);
view.selectElement(file);
}
}
catch (Exception e) {
LOG.error(e);
}
}
示例2: createLessonContent
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
/**
* Creates content (including its directory or module) of new lesson in project
*
* @param project Parameter is used in Java and Kotlin plugins
* @param lesson Lesson to create content for. It's already properly initialized and added to course.
* @return PsiDirectory of created lesson
*/
default PsiDirectory createLessonContent(@NotNull Project project,
@NotNull Lesson lesson,
@Nullable IdeView view,
@NotNull PsiDirectory parentDirectory) {
final PsiDirectory[] lessonDirectory = new PsiDirectory[1];
ApplicationManager.getApplication().runWriteAction(() -> {
String lessonDirName = EduNames.LESSON + lesson.getIndex();
lessonDirectory[0] = DirectoryUtil.createSubdirectories(lessonDirName, parentDirectory, "\\/");
});
if (lessonDirectory[0] != null) {
if (view != null) {
view.selectElement(lessonDirectory[0]);
}
}
return lessonDirectory[0];
}
示例3: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(final AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getProject();
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例4: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
isDirectory ? "\\/" : ".");
Messages.showInputDialog(project, isDirectory
? IdeBundle.message("prompt.enter.new.directory.name")
: IdeBundle.message("prompt.enter.new.package.name"),
isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiElement result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
示例5: createItemDir
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
@Nullable
protected PsiDirectory createItemDir(@NotNull final Project project, @NotNull final StudyItem item,
@Nullable final IdeView view, @NotNull final PsiDirectory parentDirectory,
@NotNull final Course course) {
final PsiDirectory[] lessonDirectory = new PsiDirectory[1];
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
lessonDirectory[0] = DirectoryUtil.createSubdirectories(EduNames.LESSON + item.getIndex(), parentDirectory, "\\/");
}
});
if (lessonDirectory[0] != null) {
if (view != null) {
view.selectElement(lessonDirectory[0]);
}
}
return lessonDirectory[0];
}
示例6: createFromTemplateAndOpen
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
private static void createFromTemplateAndOpen(@NotNull final PsiDirectory taskDirectory,
@Nullable final FileTemplate template,
@Nullable IdeView view) {
if (template == null) {
return;
}
try {
final PsiElement file = FileTemplateUtil.createFromTemplate(template, template.getName(), null, taskDirectory);
if (view != null) {
EditorHelper.openInEditor(file, false);
view.selectElement(file);
}
}
catch (Exception e) {
LOG.error(e);
}
}
示例7: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
// This is where we differ from CreateElementActionBase:
// Rather than asking for a directory here, we just allow
// *any* directory
final PsiElement[] createdElements = invokeDialog(project, dataContext);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例8: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例9: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
Project project = e.getData(PlatformDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
isDirectory ? "\\/" : ".");
Messages.showInputDialog(project, isDirectory
? IdeBundle.message("prompt.enter.new.directory.name")
: IdeBundle.message("prompt.enter.new.package.name"),
isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiElement result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
示例10: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public final void actionPerformed(@Nonnull final AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getProject();
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例11: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null)
return;
String name = Messages.showInputDialog(project, CatberryBundle.message("new.cat.store.prompt"),
CatberryBundle.message("new.cat.store"), CatberryIcons.LOGO_16, "Store", null);
if (name == null)
return;
name = StringUtil.toCamelCase(name, "-");
final String path = directory.getVirtualFile().getPath();
if (!createCatberryStore(path, name, e.getProject()))
return;
LocalFileSystem.getInstance().refreshWithoutFileWatcher(false);
PsiFile storeFile = directory.findFile(name + ".js");
if (storeFile == null)
return;
view.selectElement(storeFile);
}
示例12: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(AnActionEvent e){
DataContext dataContext = e.getDataContext();
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
PsiDirectory dir = getTargetDirectory(dataContext, view);
if (dir == null) return;
Project project = dir.getProject();
FileTemplate selectedTemplate = getTemplate(project, dir);
if (selectedTemplate != null){
AnAction action = getReplacedAction(selectedTemplate);
if (action != null) {
action.actionPerformed(e);
}
else {
FileTemplateManager.getInstance(project).addRecentName(selectedTemplate.getName());
final AttributesDefaults defaults = getAttributesDefaults(dataContext);
final CreateFromTemplateDialog dialog = new CreateFromTemplateDialog(project, dir, selectedTemplate, defaults,
defaults != null ? defaults.getDefaultProperties() : null);
PsiElement createdElement = dialog.create();
if (createdElement != null) {
elementCreated(dialog, createdElement);
view.selectElement(createdElement);
if (selectedTemplate.isLiveTemplateEnabled() && createdElement instanceof PsiFile) {
startLiveTemplate((PsiFile)createdElement);
}
}
}
}
}
示例13: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, false, ".") {
@Override
protected void createDirectories(String subDirName) {
super.createDirectories(subDirName);
PsiFileSystemItem element = getCreatedElement();
if (element instanceof PsiDirectory) {
createInitPyInHierarchy((PsiDirectory)element, directory);
}
}
};
Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.package.name"),
IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiFileSystemItem result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
示例14: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(AnActionEvent e){
DataContext dataContext = e.getDataContext();
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
PsiDirectory dir = getTargetDirectory(dataContext, view);
if (dir == null) return;
FileTemplate selectedTemplate = getTemplate(project, dir);
if(selectedTemplate != null){
AnAction action = getReplacedAction(selectedTemplate);
if (action != null) {
action.actionPerformed(e);
}
else {
FileTemplateManager.getInstance().addRecentName(selectedTemplate.getName());
final AttributesDefaults defaults = getAttributesDefaults(dataContext);
final CreateFromTemplateDialog dialog = new CreateFromTemplateDialog(project, dir, selectedTemplate, defaults,
defaults != null ? defaults.getDefaultProperties() : null);
PsiElement createdElement = dialog.create();
if (createdElement != null) {
elementCreated(dialog, createdElement);
view.selectElement(createdElement);
}
}
}
}
示例15: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) {
return;
}
Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> info = getInfo(directory);
CreateDirectoryOrPackageHandler validator =
new CreateDirectoryOrPackageHandler(project, directory, info.getThird() == ChildType.Directory, info.getThird().getSeparator());
Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.name"), info.getThird().getName(), Messages.getQuestionIcon(), "",
validator);
PsiFileSystemItem result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}