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


Java FileEditorManagerEx.getCurrentWindow方法代码示例

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


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

示例1: getEditorTabColor

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Nullable
@Override
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(project);
    FileColorManager fileColorManager = FileColorManager.getInstance(project);
    HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance(project);

    EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow();
    if (activeWindow != null) {
        final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor();

        if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) {
            return highlighterSettingsConfig.buildHighlightColor();
        }
    }

    return fileColorManager.getFileColor(virtualFile);
}
 
开发者ID:tobszarny,项目名称:ActiveTabHighlighterPlugin,代码行数:19,代码来源:CustomEditorTabColorProvider.java

示例2: actionPerformed

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
  EditorWindow window;
  final VirtualFile file = (VirtualFile)myTabInfo.getObject();
  if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) {
    window = myWindow;
  }
  else {
    window = mgr.getCurrentWindow();
  }

  if (window != null) {
    if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) {
      window.closeAllExcept(file);
    }
    else {
      if (window.findFileComposite(file) != null) {
        mgr.closeFile(file, window);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EditorTabbedContainer.java

示例3: update

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public void update(AnActionEvent event){
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  presentation.setEnabled(false);
  if (project == null) {
    return;
  }
  final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  if (windowManager.isEditorComponentActive()) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
    if (currentWindow == null){
      editorManager.getCurrentWindow ();
    }
    if (currentWindow != null) {
      final VirtualFile[] files = currentWindow.getFiles();
      presentation.setEnabled(files.length > 1);
    }
    return;
  }

  ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
  presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TabNavigationActionBase.java

示例4: actionPerformed

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
  EditorWindow window;
  final VirtualFile file = (VirtualFile)myTabInfo.getObject();
  if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) {
    window = myWindow;
  }
  else {
    window = mgr.getCurrentWindow();
  }

  if (window != null) {
    if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) {
      window.closeAllExcept(file);
    }
    else {
      if (window.findFileComposite(file) != null) {
        mgr.closeFile(file, window);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:EditorTabbedContainer.java

示例5: update

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public void update(AnActionEvent event){
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  presentation.setEnabled(false);
  if (project == null) {
    return;
  }
  final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  if (windowManager.isEditorComponentActive()) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
    if (currentWindow == null){
      editorManager.getCurrentWindow ();
    }
    if (currentWindow != null) {
      final VirtualFile[] files = currentWindow.getFiles();
      presentation.setEnabled(files.length > 1);
    }
    return;
  }

  ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
  presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:TabNavigationActionBase.java

示例6: actionPerformed

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(final AnActionEvent e) {
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
  consulo.fileEditor.impl.EditorWindow window;
  final VirtualFile file = (VirtualFile)myTabInfo.getObject();
  if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) {
    window = myWindow;
  }
  else {
    window = mgr.getCurrentWindow();
  }

  if (window != null) {
    if (BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK)) {
      window.closeAllExcept(file);
    }
    else {
      if (window.findFileComposite(file) != null) {
        mgr.closeFile(file, window);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:EditorTabbedContainer.java

示例7: update

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
public void update(@Nonnull AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  presentation.setEnabled(false);
  if (project == null) {
    return;
  }
  final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  if (windowManager.isEditorComponentActive()) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = event.getData(EditorWindow.DATA_KEY);
    if (currentWindow == null) {
      editorManager.getCurrentWindow();
    }
    if (currentWindow != null) {
      final VirtualFile[] files = currentWindow.getFiles();
      presentation.setEnabled(files.length > 1);
    }
    return;
  }

  ContentManager contentManager = event.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER);
  presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:TabNavigationActionBase.java

示例8: doNavigate

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
private void doNavigate(DataContext dataContext, Project project) {
  final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
  EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
  if (currentWindow == null){
    currentWindow = editorManager.getCurrentWindow ();
  }
  VirtualFile selectedFile = currentWindow.getSelectedFile();
  if (selectedFile == null) {
    selectedFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  }
  final VirtualFile[] files = currentWindow.getFiles();
  int index = ArrayUtil.find(files, selectedFile);
  LOG.assertTrue(index != -1);
  editorManager.openFile(files[(index + files.length + myDir) % files.length], true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TabNavigationActionBase.java

示例9: navigateImpl

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public static void navigateImpl(final DataContext dataContext, Project project, VirtualFile selectedFile, final int dir) {
  LOG.assertTrue (dir == 1 || dir == -1);
  final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
  EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
  if (currentWindow == null){
    currentWindow = editorManager.getCurrentWindow ();
  }
  final VirtualFile[] files = currentWindow.getFiles();
  int index = ArrayUtil.find(files, selectedFile);
  LOG.assertTrue(index != -1);
  editorManager.openFile(files[(index + files.length + dir) % files.length], true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:TabNavigationActionBase.java

示例10: getEditorWindow

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
private static EditorWindow getEditorWindow(DataContext dataContext) {
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
  EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
  if (editorWindow == null) {
    editorWindow = fileEditorManager.getCurrentWindow();
  }
  return editorWindow;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:PinActiveTabAction.java

示例11: navigateImpl

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public static void navigateImpl(final DataContext dataContext, Project project, VirtualFile selectedFile, final int dir) {
  LOG.assertTrue(dir == 1 || dir == -1);
  final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
  EditorWindow currentWindow = dataContext.getData(EditorWindow.DATA_KEY);
  if (currentWindow == null) {
    currentWindow = editorManager.getCurrentWindow();
  }
  final VirtualFile[] files = currentWindow.getFiles();
  int index = ArrayUtil.find(files, selectedFile);
  LOG.assertTrue(index != -1);
  editorManager.openFile(files[(index + files.length + dir) % files.length], true);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:TabNavigationActionBase.java

示例12: navigate

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public void navigate(int injectedOffset) {
  if (myAction.isShowInBalloon()) {
    Ref<Balloon> ref = Ref.create(null);
    final JComponent component = myAction.createBalloonComponent(myNewFile, ref);
    if (component != null) {
      final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component)
        .setShadow(true)
        .setAnimationCycle(0)
        .setHideOnClickOutside(true)
        .setHideOnKeyOutside(true)
        .setHideOnAction(false)
        .setFillColor(UIUtil.getControlColor())
        .createBalloon();
      ref.set(balloon);
      Disposer.register(myNewFile.getProject(), balloon);
      final Balloon.Position position = QuickEditAction.getBalloonPosition(myEditor);
      RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
      if (position == Balloon.Position.above) {
        final Point p = point.getPoint();
        point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - myEditor.getLineHeight()));
      }
      balloon.show(point, position);
    }
  }
  else {
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
    final FileEditor[] editors = fileEditorManager.getEditors(myNewVirtualFile);
    if (editors.length == 0) {
      final EditorWindow curWindow = fileEditorManager.getCurrentWindow();
      mySplittedWindow = curWindow.split(SwingConstants.HORIZONTAL, false, myNewVirtualFile, true);
    }
    Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(myProject, myNewVirtualFile, injectedOffset), true);
    // fold missing values
    if (editor != null) {
      editor.putUserData(QuickEditAction.QUICK_EDIT_HANDLER, this);
      final FoldingModel foldingModel = editor.getFoldingModel();
      foldingModel.runBatchFoldingOperation(new Runnable() {
        @Override
        public void run() {
          for (RangeMarker o : ContainerUtil.reverse(((DocumentEx)myNewDocument).getGuardedBlocks())) {
            String replacement = o.getUserData(REPLACEMENT_KEY);
            if (StringUtil.isEmpty(replacement)) continue;
            FoldRegion region = foldingModel.addFoldRegion(o.getStartOffset(), o.getEndOffset(), replacement);
            if (region != null) region.setExpanded(false);
          }
        }
      });
    }
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
      }
    });

  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:58,代码来源:QuickEditHandler.java

示例13: navigate

import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
public void navigate(int injectedOffset) {
  if (myAction.isShowInBalloon()) {
    final JComponent component = myAction.createBalloonComponent(myNewFile);
    if (component != null) {
      final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component)
              .setShadow(true)
              .setAnimationCycle(0)
              .setHideOnClickOutside(true)
              .setHideOnKeyOutside(true)
              .setHideOnAction(false)
              .setFillColor(UIUtil.getControlColor())
              .createBalloon();
      new AnAction() {
        @RequiredDispatchThread
        @Override
        public void actionPerformed(AnActionEvent e) {
          balloon.hide();
        }
      }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
      Disposer.register(myNewFile.getProject(), balloon);
      final Balloon.Position position = QuickEditAction.getBalloonPosition(myEditor);
      RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
      if (position == Balloon.Position.above) {
        final Point p = point.getPoint();
        point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - myEditor.getLineHeight()));
      }
      balloon.show(point, position);
    }
  }
  else {
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
    final FileEditor[] editors = fileEditorManager.getEditors(myNewVirtualFile);
    if (editors.length == 0) {
      final consulo.fileEditor.impl.EditorWindow curWindow = fileEditorManager.getCurrentWindow();
      mySplittedWindow = curWindow.split(SwingConstants.HORIZONTAL, false, myNewVirtualFile, true);
    }
    Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(myProject, myNewVirtualFile, injectedOffset), true);
    // fold missing values
    if (editor != null) {
      editor.putUserData(QuickEditAction.QUICK_EDIT_HANDLER, this);
      final FoldingModel foldingModel = editor.getFoldingModel();
      foldingModel.runBatchFoldingOperation(new Runnable() {
        @Override
        public void run() {
          for (RangeMarker o : ContainerUtil.reverse(((DocumentEx)myNewDocument).getGuardedBlocks())) {
            String replacement = o.getUserData(REPLACEMENT_KEY);
            if (StringUtil.isEmpty(replacement)) continue;
            FoldRegion region = foldingModel.addFoldRegion(o.getStartOffset(), o.getEndOffset(), replacement);
            if (region != null) region.setExpanded(false);
          }
        }
      });
    }
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
      }
    });

  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:63,代码来源:QuickEditHandler.java


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