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


Java EditorHelper类代码示例

本文整理汇总了Java中com.intellij.ide.util.EditorHelper的典型用法代码示例。如果您正苦于以下问题:Java EditorHelper类的具体用法?Java EditorHelper怎么用?Java EditorHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createFromTemplate

import com.intellij.ide.util.EditorHelper; //导入依赖的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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:22,代码来源:StudyUtils.java

示例2: configure

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/domain");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createPomFile(project, projectId, muleVersion, root);
        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:20,代码来源:MuleDomainMavenProjectBuilderHelper.java

示例3: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(final PsiElement element) {
  final boolean isDirectory = element instanceof PsiDirectory;
  if (!isDirectory) {
    EditorHelper.openInEditor(element);
  }
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      myBuilder.selectElement(element, PsiUtilCore.getVirtualFile(element));
      if (!isDirectory) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            if (myMoveFocus) {
              ToolWindowManager.getInstance(myProject).activateEditorComponent();
            }
          }
        });
      }
    }
  }, ModalityState.NON_MODAL);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CommanderPanel.java

示例4: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(final PsiElement element) {
  if (element != null) {
    selectPsiElement(element, false);
    boolean requestFocus = true;
    final boolean isDirectory = element instanceof PsiDirectory;
    if (!isDirectory) {
      Editor editor = EditorHelper.openInEditor(element);
      if (editor != null) {
        ToolWindowManager.getInstance(myProject).activateEditorComponent();
        requestFocus = false;
      }
    }
    if (requestFocus) {
      selectPsiElement(element, true);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FavoritesTreeViewPanel.java

示例5: startLiveTemplate

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
public static void startLiveTemplate(PsiFile file) {
  Project project = file.getProject();
  final Editor editor = EditorHelper.openInEditor(file);
  if (editor == null) return;

  final TemplateImpl template = new TemplateImpl("", file.getText(), "");
  template.setInline(true);
  int count = template.getSegmentsCount();
  if (count == 0) return;

  Set<String> variables = new HashSet<String>();
  for (int i = 0; i < count; i++) {
    variables.add(template.getSegmentName(i));
  }
  variables.removeAll(TemplateImpl.INTERNAL_VARS_SET);
  for (String variable : variables) {
    template.addVariable(variable, null, "\"" + variable + "\"", true);
  }
  WriteCommandAction.runWriteCommandAction(project, new Runnable() {
    @Override
    public void run() {
      editor.getDocument().setText(template.getTemplateText());
    }
  });
  TemplateManager.getInstance(project).startTemplate(editor, template);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CreateFromTemplateActionBase.java

示例6: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(PsiElement element) {
  selectPsiElement(element, false);
  boolean requestFocus = true;
  if (element != null) {
    final boolean isDirectory = element instanceof PsiDirectory;
    if (!isDirectory) {
      FileEditor editor = EditorHelper.openInEditor(element, false);
      if (editor != null) {
        ToolWindowManager.getInstance(myProject).activateEditorComponent();
        requestFocus = false;
      }
    }
  }

  if (requestFocus) {
    selectPsiElement(element, true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ProjectViewImpl.java

示例7: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(final PsiElement element) {
  if (element != null) {
    final PackageSet packageSet = getCurrentScope().getValue();
    final PsiFile psiFile = element.getContainingFile();
    if (packageSet == null) return;
    final VirtualFile virtualFile = psiFile != null ? psiFile.getVirtualFile() :
                                    (element instanceof PsiDirectory ? ((PsiDirectory)element).getVirtualFile() : null);
    if (virtualFile != null) {
      final ProjectView projectView = ProjectView.getInstance(myProject);
      final NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, CURRENT_SCOPE_NAME, myDependencyValidationManager);
      if (packageSet instanceof PackageSetBase && !((PackageSetBase)packageSet).contains(virtualFile, myProject, holder) ||
          psiFile != null && !packageSet.contains(psiFile, holder)) {
        projectView.changeView(ProjectViewPane.ID);
      }
      projectView.select(element, virtualFile, false);
    }
    Editor editor = EditorHelper.openInEditor(element);
    if (editor != null) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ScopeTreeViewPanel.java

示例8: createFromTemplateAndOpen

import com.intellij.ide.util.EditorHelper; //导入依赖的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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CCCreateTask.java

示例9: startLiveTemplate

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
public static void startLiveTemplate(@Nonnull PsiFile file, @Nonnull Map<String, String> defaultValues) {
  Editor editor = EditorHelper.openInEditor(file);
  if (editor == null) return;

  TemplateImpl template = new TemplateImpl("", file.getText(), "");
  template.setInline(true);
  int count = template.getSegmentsCount();
  if (count == 0) return;

  Set<String> variables = new HashSet<>();
  for (int i = 0; i < count; i++) {
    variables.add(template.getSegmentName(i));
  }
  variables.removeAll(TemplateImpl.INTERNAL_VARS_SET);
  for (String variable : variables) {
    String defaultValue = defaultValues.getOrDefault(variable, variable);
    template.addVariable(variable, null, '"' + defaultValue + '"', true);
  }

  Project project = file.getProject();
  WriteCommandAction.runWriteCommandAction(project, () -> editor.getDocument().setText(template.getTemplateText()));

  editor.getCaretModel().moveToOffset(0);  // ensures caret at the start of the template
  TemplateManager.getInstance(project).startTemplate(editor, template);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:CreateFromTemplateActionBase.java

示例10: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(final PsiElement element) {
  if (element != null) {
    final PackageSet packageSet = getCurrentScope().getValue();
    final PsiFile psiFile = element.getContainingFile();
    if (packageSet == null) return;
    final VirtualFile virtualFile = psiFile != null ? psiFile.getVirtualFile() :
                                    (element instanceof PsiDirectory ? ((PsiDirectory)element).getVirtualFile() : null);
    if (virtualFile != null) {
      final ProjectView projectView = ProjectView.getInstance(myProject);
      final NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, CURRENT_SCOPE_NAME, myDependencyValidationManager);
      if (packageSet instanceof PackageSetBase && !((PackageSetBase)packageSet).contains(virtualFile, holder) ||
          psiFile != null && !packageSet.contains(psiFile, holder)) {
        projectView.changeView(ProjectViewPane.ID);
      }
      projectView.select(element, virtualFile, false);
    }
    Editor editor = EditorHelper.openInEditor(element);
    if (editor != null) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:ScopeTreeViewPanel.java

示例11: configure

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root, @Nullable MavenId parentId)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/app");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        createLog4J(project, projectId, resources);
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createMuleAppPropertiesFiles(project, appDirectory);
        VfsUtil.createDirectories(root.getPath() + "/src/main/api");
        //MUnit support
        VfsUtil.createDirectories(root.getPath() + "/src/test/munit");
        final VirtualFile testResources = VfsUtil.createDirectories(root.getPath() + "/src/test/resources");
        createLog4JTest(project, projectId, testResources);

        if (parentId == null)
            createPomFile(project, projectId, muleVersion, root);
        else
            createModulePomFile(project, projectId, root, parentId);

        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:32,代码来源:MuleMavenProjectBuilderHelper.java

示例12: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
@Override
public void selectElement(PsiElement element) {
  PsiFileSystemItem psiFile;
  if (element instanceof PsiFileSystemItem) {
    psiFile = (PsiFileSystemItem)element;
  }
  else {
    psiFile = element.getContainingFile();
    if (psiFile == null) {
      return;
    }
  }

  VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) {
    return;
  }

  selectFile(virtualFile, false);

  boolean requestFocus = true;

  if (psiFile instanceof PsiFile) {
    Editor editor = EditorHelper.openInEditor(element);
    if (editor != null) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
      requestFocus = false;
    }
  }

  if (requestFocus) {
    selectFile(virtualFile, true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:MvcProjectViewPane.java

示例13: selectElement

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
public void selectElement(PsiElement element) {
  PsiFileSystemItem psiFile;

  if (!(element instanceof PsiFileSystemItem)) {
    psiFile = element.getContainingFile();
  }
  else {
    psiFile = (PsiFileSystemItem)element;
  }

  if (psiFile == null) return;

  VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) return;

  selectFile(virtualFile, false);

  boolean requestFocus = true;

  if (psiFile instanceof PsiFile) {
    Editor editor = EditorHelper.openInEditor(element);
    if (editor != null) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
      requestFocus = false;
    }
  }

  if (requestFocus) {
    selectFile(virtualFile, true);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:MvcProjectViewPane.java

示例14: doRefactoring

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
private void doRefactoring(UsageInfo[] usages) throws IncorrectOperationException {
  myTypeParameterReplacements = buildTypeParameterReplacements();
  List<PsiClass> inheritors = new ArrayList<PsiClass>();

  CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);

  // Process usages
  for (final UsageInfo usage : usages) {
    if (usage instanceof MethodCallUsageInfo) {
      processMethodCall((MethodCallUsageInfo)usage);
    }
    else if (usage instanceof ParameterUsageInfo) {
      processParameterUsage((ParameterUsageInfo)usage);
    }
    else if (usage instanceof ImplementingClassUsageInfo) {
      inheritors.add(((ImplementingClassUsageInfo)usage).getPsiClass());
    }
  }

  prepareTypeParameterReplacement();
  myTargetParameter.delete();
  ChangeContextUtil.encodeContextInfo(myMethod, true);
  if (!myTargetClass.isInterface()) {
    PsiMethod method = addMethodToClass(myTargetClass);
    fixVisibility(method, usages);
    EditorHelper.openInEditor(method);
  }
  else {
    final PsiMethod interfaceMethod = addMethodToClass(myTargetClass);
    final PsiModifierList modifierList = interfaceMethod.getModifierList();
    modifierList.setModifierProperty(PsiModifier.PRIVATE, false);
    modifierList.setModifierProperty(PsiModifier.PUBLIC, false);
    modifierList.setModifierProperty(PsiModifier.PROTECTED, false);
    RefactoringUtil.makeMethodAbstract(myTargetClass, interfaceMethod);

    EditorHelper.openInEditor(interfaceMethod);

    for (final PsiClass psiClass : inheritors) {
      final PsiMethod newMethod = addMethodToClass(psiClass);
      PsiUtil.setModifierProperty(newMethod, myNewVisibility != null && !myNewVisibility.equals(VisibilityUtil.ESCALATE_VISIBILITY) ? myNewVisibility
                                                                                                                                    : PsiModifier.PUBLIC, true);
    }
  }
  myMethod.delete();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:ConvertToInstanceMethodProcessor.java

示例15: performRefactoring

import com.intellij.ide.util.EditorHelper; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, myTargetClass)) return;

  PsiMethod patternMethod = createMethodToAdd();
  final List<PsiReference> docRefs = new ArrayList<PsiReference>();
  for (UsageInfo usage : usages) {
    if (usage instanceof InheritorUsageInfo) {
      final PsiClass inheritor = ((InheritorUsageInfo)usage).getInheritor();
      addMethodToClass(inheritor, patternMethod, true);
    }
    else if (usage instanceof MethodCallUsageInfo && !((MethodCallUsageInfo)usage).isInternal()) {
      final PsiElement expression = ((MethodCallUsageInfo)usage).getMethodCallExpression();
      if (expression instanceof PsiMethodCallExpression) {
        correctMethodCall((PsiMethodCallExpression)expression, false);
      } else if (expression instanceof PsiMethodReferenceExpression) {
        PsiExpression newQualifier = JavaPsiFacade.getInstance(myProject).getElementFactory().createExpressionFromText(myTargetVariable.getType().getCanonicalText(), null);
        ((PsiMethodReferenceExpression)expression).setQualifierExpression(newQualifier);
      }
    }
    else if (usage instanceof JavadocUsageInfo) {
      docRefs.add(usage.getElement().getReference());
    }
  }

  try {
    if (myTargetClass.isInterface()) patternMethod.getBody().delete();

    final PsiMethod method = addMethodToClass(myTargetClass, patternMethod, false);
    myMethod.delete();
    for (PsiReference reference : docRefs) {
      reference.bindToElement(method);
    }
    VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usages), method, myNewVisibility);

    if (myOpenInEditor) {
      EditorHelper.openInEditor(method);
    }
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:MoveInstanceMethodProcessor.java


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