@Nullable private JBTabs getTabsAt(DockableContent content, RelativePoint point) { if (content instanceof EditorTabbedContainer.DockableEditor) { JBTabs targetTabs = mySplitters.getTabsAt(point); if (targetTabs != null) { return targetTabs; } else { EditorWindow wnd = mySplitters.getCurrentWindow(); if (wnd != null) { EditorTabbedContainer tabs = wnd.getTabbedPane(); if (tabs != null) { return tabs.getTabs(); } } else { EditorWindow[] windows = mySplitters.getWindows(); for (EditorWindow each : windows) { if (each.getTabbedPane() != null && each.getTabbedPane().getTabs() != null) { return each.getTabbedPane().getTabs(); } } } } } return null; }
@Override public Image processDropOver(@NotNull DockableContent content, RelativePoint point) { JBTabs current = getTabsAt(content, point); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(content); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = content.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, point); } return myCurrentOverImg; }
@Nullable private JBTabs getTabsAt(DockableContent content, RelativePoint point) { if (content instanceof EditorTabbedContainer.DockableEditor) { JBTabs targetTabs = mySplitters.getTabsAt(point); if (targetTabs != null) { return targetTabs; } else { EditorWindow wnd = mySplitters.getCurrentWindow(); if (wnd != null) { EditorTabbedContainer tabs = ((DesktopEditorWindow)wnd).getTabbedPane(); if (tabs != null) { return tabs.getTabs(); } } else { DesktopEditorWindow[] windows = mySplitters.getWindows(); for (DesktopEditorWindow each : windows) { if (each.getTabbedPane() != null && each.getTabbedPane().getTabs() != null) { return each.getTabbedPane().getTabs(); } } } } } return null; }
@Override public Image processDropOver(@Nonnull DockableContent content, RelativePoint point) { JBTabs current = getTabsAt(content, point); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(content); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = content.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, point); } return myCurrentOverImg; }
@Override public void add(@NotNull DockableContent content, RelativePoint dropTarget) { EditorWindow window = null; if (myCurrentOver != null) { final DataProvider provider = myCurrentOver.getDataProvider(); if (provider != null) { window = EditorWindow.DATA_KEY.getData(provider); } } final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content; VirtualFile file = dockableEditor.getFile(); if (window == null || window.isDisposed()) { window = mySplitters.getOrCreateCurrentWindow(file); } if (myCurrentOver != null) { int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex(); file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index); } ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true); window.setFilePinned(file, dockableEditor.isPinned()); }
@Override public void resetDropOver(@NotNull DockableContent content) { if (myCurrentOver != null) { myCurrentOver.resetDropOver(myCurrentOverInfo); myCurrentOver = null; myCurrentOverInfo = null; myCurrentOverImg = null; } }
@NotNull @Override public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) { if (!(content instanceof DockableGrid)) { return ContentResponse.DENY; } final RunnerContentUi ui = ((DockableGrid)content).getOriginalRunnerUi(); return ui.getProject() == myProject && ui.mySessionName.equals(mySessionName) ? ContentResponse.ACCEPT_MOVE : ContentResponse.DENY; }
@Override public void add(@NotNull DockableContent dockable, RelativePoint dropTarget) { final DockableGrid dockableGrid = (DockableGrid)dockable; final RunnerContentUi prev = dockableGrid.getRunnerUi(); saveUiState(); final List<Content> contents = dockableGrid.getContents(); final boolean wasRestoring = myOriginal != null && myOriginal.isStateBeingRestored(); setStateIsBeingRestored(true, this); try { final Point point = dropTarget != null ? dropTarget.getPoint(myComponent) : null; boolean hadGrid = !myTabs.shouldAddToGlobal(point); for (Content content : contents) { final View view = getStateFor(content); if (view.isMinimizedInGrid()) continue; prev.myManager.removeContent(content, false); myManager.removeContent(content, false); if (hadGrid && !wasRestoring) { view.assignTab(getTabFor(getSelectedGrid())); view.setPlaceInGrid(calcPlaceInGrid(point, myComponent.getSize())); } else if (contents.size() == 1 && !wasRestoring) { view.assignTab(null); view.setPlaceInGrid(myLayoutSettings.getDefaultGridPlace(content)); } view.setWindow(myWindow); myManager.addContent(content); } } finally { setStateIsBeingRestored(false, this); } saveUiState(); updateTabsUI(true); }
@Override public Image processDropOver(@NotNull DockableContent dockable, RelativePoint dropTarget) { JBTabs current = getTabsAt(dockable, dropTarget); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(dockable); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = dockable.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentPainter == null) { myCurrentPainter = new MyDropAreaPainter(); IdeGlassPaneUtil.find(myComponent).addPainter(myComponent, myCurrentPainter, this); } myCurrentPainter.processDropOver(this, dockable, dropTarget); return myCurrentOverImg; }
@Nullable private JBTabs getTabsAt(DockableContent content, RelativePoint point) { if (content instanceof DockableGrid) { final Point p = point.getPoint(getComponent()); Component c = SwingUtilities.getDeepestComponentAt(getComponent(), p.x, p.y); while (c != null) { if (c instanceof JBRunnerTabs) { return (JBTabs)c; } c = c.getParent(); } } return null; }
@Override public void resetDropOver(@NotNull DockableContent content) { if (myCurrentOver != null) { myCurrentOver.resetDropOver(myCurrentOverInfo); myCurrentOver = null; myCurrentOverInfo = null; myCurrentOverImg = null; IdeGlassPaneUtil.find(myComponent).removePainter(myCurrentPainter); myCurrentPainter = null; } }
@NotNull @Override public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) { if (content.getKey() instanceof VirtualFile) { return ContentResponse.ACCEPT_COPY; } return ContentResponse.DENY; }
@Override public void add(@NotNull DockableContent content, RelativePoint dropTarget) { if (content.getKey() instanceof VirtualFile) { VirtualFile vFile = (VirtualFile)content.getKey(); final PsiFileSystemItem psiFile = vFile.isDirectory() ? PsiManager.getInstance(myProject).findDirectory(vFile) : PsiManager.getInstance(myProject).findFile(vFile); Point p = dropTarget.getScreenPoint(); SwingUtilities.convertPointFromScreen(p, myTree); FavoritesListNode node = findFavoritesListNode(p); if (node != null && psiFile != null) { dropPsiElements(myFavoritesManager, node, new PsiElement[]{psiFile}); } } }
@Nullable @Override public Image processDropOver(@NotNull DockableContent content, RelativePoint point) { Point p = point.getScreenPoint(); SwingUtilities.convertPointFromScreen(p, myTree); TreePath treePath = myTree.getClosestPathForLocation(p.x, p.y); FavoritesListNode node = getListNodeFromPath(treePath); treePath = node != null ? myTree.getPath(node) : null; if (treePath != null) { myTree.setSelectionPath(treePath); } return null; }
@Override public void add(@NotNull DockableContent content, RelativePoint dropTarget) { if (isTerminalSessionContent(content)) { TerminalSessionVirtualFileImpl terminalFile = (TerminalSessionVirtualFileImpl)content.getKey(); myTerminalWidget.addTab(terminalFile.getName(), terminalFile.getTerminal()); terminalFile.getTerminal().setNextProvider(myTerminalWidget); } }
@Override public void add(@NotNull DockableContent content, RelativePoint dropTarget) { if(isTerminalSessionContent(content)) { TerminalSessionVirtualFileImpl terminalFile = (TerminalSessionVirtualFileImpl) content.getKey(); myTerminalWidget.addTab(terminalFile.getName(), terminalFile.getTerminal()); terminalFile.getTerminal().setNextProvider(myTerminalWidget); } }
@Override public void add(@Nonnull DockableContent content, RelativePoint dropTarget) { EditorWindow window = null; if (myCurrentOver != null) { final DataProvider provider = myCurrentOver.getDataProvider(); if (provider != null) { window = provider.getDataUnchecked(EditorWindow.DATA_KEY); } } final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content; VirtualFile file = dockableEditor.getFile(); if (window == null || window.isDisposed()) { window = mySplitters.getOrCreateCurrentWindow(file); } if (myCurrentOver != null) { int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex(); file.putUserData(DesktopEditorWindow.INITIAL_INDEX_KEY, index); } ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true); window.setFilePinned(file, dockableEditor.isPinned()); }
@Override public void resetDropOver(@Nonnull DockableContent content) { if (myCurrentOver != null) { myCurrentOver.resetDropOver(myCurrentOverInfo); myCurrentOver = null; myCurrentOverInfo = null; myCurrentOverImg = null; } }
@Nonnull @Override public ContentResponse getContentResponse(@Nonnull DockableContent content, RelativePoint point) { if (!(content instanceof DockableGrid)) { return ContentResponse.DENY; } final RunnerContentUi ui = ((DockableGrid)content).getOriginalRunnerUi(); return ui.getProject() == myProject && ui.mySessionName.equals(mySessionName) ? ContentResponse.ACCEPT_MOVE : ContentResponse.DENY; }
@Override public void add(@Nonnull DockableContent dockable, RelativePoint dropTarget) { final DockableGrid dockableGrid = (DockableGrid)dockable; final RunnerContentUi prev = dockableGrid.getRunnerUi(); saveUiState(); final List<Content> contents = dockableGrid.getContents(); final boolean wasRestoring = myOriginal != null && myOriginal.isStateBeingRestored(); setStateIsBeingRestored(true, this); try { final Point point = dropTarget != null ? dropTarget.getPoint(myComponent) : null; boolean hadGrid = !myTabs.shouldAddToGlobal(point); for (Content content : contents) { final View view = getStateFor(content); if (view.isMinimizedInGrid()) continue; prev.myManager.removeContent(content, false); myManager.removeContent(content, false); if (hadGrid && !wasRestoring) { view.assignTab(getTabFor(getSelectedGrid())); view.setPlaceInGrid(calcPlaceInGrid(point, myComponent.getSize())); } else if (contents.size() == 1 && !wasRestoring) { view.assignTab(null); view.setPlaceInGrid(myLayoutSettings.getDefaultGridPlace(content)); } view.setWindow(myWindow); myManager.addContent(content); } } finally { setStateIsBeingRestored(false, this); } saveUiState(); updateTabsUI(true); }
@Override public Image processDropOver(@Nonnull DockableContent dockable, RelativePoint dropTarget) { JBTabs current = getTabsAt(dockable, dropTarget); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(dockable); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = dockable.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentPainter == null) { myCurrentPainter = new MyDropAreaPainter(); IdeGlassPaneUtil.find(myComponent).addPainter(myComponent, myCurrentPainter, this); } myCurrentPainter.processDropOver(this, dockable, dropTarget); return myCurrentOverImg; }
@Override public void resetDropOver(@Nonnull DockableContent content) { if (myCurrentOver != null) { myCurrentOver.resetDropOver(myCurrentOverInfo); myCurrentOver = null; myCurrentOverInfo = null; myCurrentOverImg = null; IdeGlassPaneUtil.find(myComponent).removePainter(myCurrentPainter); myCurrentPainter = null; } }
@Nonnull @Override public ContentResponse getContentResponse(@Nonnull DockableContent content, RelativePoint point) { if (content.getKey() instanceof VirtualFile) { return ContentResponse.ACCEPT_COPY; } return ContentResponse.DENY; }
@Override public void add(@Nonnull DockableContent content, RelativePoint dropTarget) { if (content.getKey() instanceof VirtualFile) { VirtualFile vFile = (VirtualFile)content.getKey(); final PsiFileSystemItem psiFile = vFile.isDirectory() ? PsiManager.getInstance(myProject).findDirectory(vFile) : PsiManager.getInstance(myProject).findFile(vFile); Point p = dropTarget.getScreenPoint(); SwingUtilities.convertPointFromScreen(p, myTree); FavoritesListNode node = findFavoritesListNode(p); if (node != null && psiFile != null) { dropPsiElements(myFavoritesManager, node, new PsiElement[]{psiFile}); } } }
@Nullable @Override public Image processDropOver(@Nonnull DockableContent content, RelativePoint point) { Point p = point.getScreenPoint(); SwingUtilities.convertPointFromScreen(p, myTree); TreePath treePath = myTree.getClosestPathForLocation(p.x, p.y); FavoritesListNode node = getListNodeFromPath(treePath); treePath = node != null ? myTree.getPath(node) : null; if (treePath != null) { myTree.setSelectionPath(treePath); } return null; }
@Override public DockContainer createContainer(DockableContent content) { return createContainer(false); }
@NotNull @Override public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) { return getTabsAt(content, point) != null ? ContentResponse.ACCEPT_MOVE : ContentResponse.DENY; }