mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-265158 Cannot dnd tab to pin when options 'One row' and 'Show pinned tabs in a separate row' are on
GitOrigin-RevId: fff8ce10a2401cdaa33c51eab14f70874fa9d0c8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e01f210867
commit
2f16298ef2
@@ -17,8 +17,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TableLayout extends TabLayout implements MorePopupAware {
|
||||
@@ -327,11 +326,18 @@ public class TableLayout extends TabLayout implements MorePopupAware {
|
||||
int result = -1;
|
||||
|
||||
Component c = myTabs.getComponentAt(point);
|
||||
Set<TabInfo> lastInRow = new HashSet<>();
|
||||
for (int i = 0; i < myLastTableLayout.table.size(); i++) {
|
||||
List<TabInfo> columns = myLastTableLayout.table.get(i).myColumns;
|
||||
lastInRow.add(columns.get(columns.size() - 1));
|
||||
}
|
||||
|
||||
if (c instanceof JBTabsImpl) {
|
||||
for (int i = 0; i < myLastTableLayout.myVisibleInfos.size() - 1; i++) {
|
||||
TabLabel first = myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i));
|
||||
TabLabel second = myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i + 1));
|
||||
TabInfo firstInfo = myLastTableLayout.myVisibleInfos.get(i);
|
||||
TabInfo secondInfo = myLastTableLayout.myVisibleInfos.get(i + 1);
|
||||
TabLabel first = myTabs.myInfo2Label.get(firstInfo);
|
||||
TabLabel second = myTabs.myInfo2Label.get(secondInfo);
|
||||
|
||||
Rectangle firstBounds = first.getBounds();
|
||||
Rectangle secondBounds = second.getBounds();
|
||||
@@ -345,6 +351,13 @@ public class TableLayout extends TabLayout implements MorePopupAware {
|
||||
c = first;
|
||||
break;
|
||||
}
|
||||
if (lastInRow.contains(firstInfo)
|
||||
&& firstBounds.y <= point.y
|
||||
&& firstBounds.getMaxY() >= point.y
|
||||
&& firstBounds.getMaxX() <= point.x) {
|
||||
c = second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+20
-5
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsCollectorImpl;
|
||||
import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsEventLogGroup;
|
||||
import com.intellij.internal.statistic.eventLog.events.ObjectEventData;
|
||||
@@ -17,10 +18,8 @@ import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.awt.RelativeRectangle;
|
||||
import com.intellij.ui.docking.DockContainer;
|
||||
import com.intellij.ui.docking.DockableContent;
|
||||
import com.intellij.ui.tabs.JBTabs;
|
||||
import com.intellij.ui.tabs.JBTabsEx;
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.TabsUtil;
|
||||
import com.intellij.ui.tabs.*;
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
@@ -160,8 +159,8 @@ public final class DockableEditorTabbedContainer implements DockContainer.Persis
|
||||
}
|
||||
|
||||
Boolean dropInBetweenPinnedTabs = null;
|
||||
Boolean dropInPinnedRow = false;
|
||||
if (myCurrentOver != null) {
|
||||
|
||||
int index = ((JBTabsEx)myCurrentOver).getDropInfoIndex();
|
||||
if (index >= 0 && index <= myCurrentOver.getTabCount()) {
|
||||
TabInfo tabInfo = index == myCurrentOver.getTabCount() ? null : myCurrentOver.getTabAt(index);
|
||||
@@ -171,6 +170,17 @@ public final class DockableEditorTabbedContainer implements DockContainer.Persis
|
||||
else {
|
||||
dropInBetweenPinnedTabs = tabInfo != null ? tabInfo.isPinned() : null;
|
||||
}
|
||||
if (tabInfo != null && index > 0 ) {
|
||||
Component previousLabel = myCurrentOver.getTabLabel(myCurrentOver.getTabAt(index - 1));
|
||||
Rectangle bounds = previousLabel.getBounds();
|
||||
Point dropPoint = dropTarget.getPoint(previousLabel);
|
||||
dropInPinnedRow =
|
||||
myCurrentOver instanceof JBTabsImpl
|
||||
&& UISettings.getInstance().getState().getShowPinnedTabsInASeparateRow()
|
||||
&& ((JBTabsImpl)myCurrentOver).getTabsPosition() == JBTabsPosition.top
|
||||
&& myCurrentOver.getTabAt(index - 1).isPinned()
|
||||
&& bounds.y < dropPoint.y && bounds.getMaxY() > dropPoint.y;
|
||||
}
|
||||
}
|
||||
file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index);
|
||||
Integer dragStartIndex = file.getUserData(EditorWindow.DRAG_START_INDEX_KEY);
|
||||
@@ -178,6 +188,11 @@ public final class DockableEditorTabbedContainer implements DockContainer.Persis
|
||||
if (!isDroppedToOriginalPlace) {
|
||||
file.putUserData(EditorWindow.DRAG_START_PINNED_KEY, dropInBetweenPinnedTabs);
|
||||
}
|
||||
if (dropInPinnedRow) {
|
||||
file.putUserData(EditorWindow.DRAG_START_INDEX_KEY, index + 1);
|
||||
file.putUserData(EditorWindow.DRAG_START_PINNED_KEY, Boolean.TRUE);
|
||||
dropInBetweenPinnedTabs = true;
|
||||
}
|
||||
}
|
||||
recordDragStats(dropIntoNewlyCreatedWindow? -1 : CENTER, sameWindow);
|
||||
((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true);
|
||||
|
||||
Reference in New Issue
Block a user