本文整理汇总了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);
}
示例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);
}
}
}
}
示例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());
}
示例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);
}
}
}
}
示例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());
}
示例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);
}
}
}
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
});
}
}
示例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);
}
});
}
}