mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reduce getInfo calls (pass info instead), invalidate cache on register/unregister
This commit is contained in:
@@ -81,10 +81,13 @@ public final class DesktopLayout {
|
||||
for (WindowInfoImpl otherInfo : layout.myIdToInfo.values()) {
|
||||
WindowInfoImpl oldInfo = old.get(otherInfo.getId());
|
||||
if (oldInfo == null) {
|
||||
myIdToInfo.put(otherInfo.getId(), otherInfo.copy());
|
||||
WindowInfoImpl newInfo = otherInfo.copy();
|
||||
newInfo.setRegistered(otherInfo.isRegistered());
|
||||
myIdToInfo.put(otherInfo.getId(), newInfo);
|
||||
}
|
||||
else {
|
||||
oldInfo.copyFrom(otherInfo);
|
||||
oldInfo.setRegistered(otherInfo.isRegistered());
|
||||
myIdToInfo.put(otherInfo.getId(), oldInfo);
|
||||
}
|
||||
}
|
||||
@@ -98,10 +101,6 @@ public final class DesktopLayout {
|
||||
normalizeOrder(getAllInfos(ToolWindowAnchor.BOTTOM));
|
||||
normalizeOrder(getAllInfos(ToolWindowAnchor.RIGHT));
|
||||
|
||||
invalidateCaches();
|
||||
}
|
||||
|
||||
private void invalidateCaches() {
|
||||
myRegisteredInfos.drop();
|
||||
}
|
||||
|
||||
@@ -120,16 +119,20 @@ public final class DesktopLayout {
|
||||
info.setAnchor(anchor);
|
||||
info.setSplit(splitMode);
|
||||
myIdToInfo.put(id, info);
|
||||
invalidateCaches();
|
||||
}
|
||||
info.setRegistered(true);
|
||||
if (!info.isRegistered()) {
|
||||
info.setRegistered(true);
|
||||
myRegisteredInfos.drop();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
final void unregister(@NotNull String id) {
|
||||
WindowInfoImpl info = myIdToInfo.get(id);
|
||||
info.setRegistered(false);
|
||||
invalidateCaches();
|
||||
if (info.isRegistered()) {
|
||||
info.setRegistered(false);
|
||||
myRegisteredInfos.drop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,8 +150,8 @@ public final class DesktopLayout {
|
||||
|
||||
@Nullable
|
||||
final String getActiveId() {
|
||||
for (WindowInfoImpl info : myIdToInfo.values()) {
|
||||
if (info.isRegistered() && info.isActive()) {
|
||||
for (WindowInfoImpl info : getInfos()) {
|
||||
if (info.isActive()) {
|
||||
return info.getId();
|
||||
}
|
||||
}
|
||||
@@ -253,7 +256,7 @@ public final class DesktopLayout {
|
||||
normalizeOrder(getAllInfos(newAnchor));
|
||||
}
|
||||
|
||||
invalidateCaches();
|
||||
myRegisteredInfos.drop();
|
||||
}
|
||||
|
||||
final void setSplitMode(@NotNull String id, boolean split) {
|
||||
@@ -318,7 +321,7 @@ public final class DesktopLayout {
|
||||
private final Map<String, WindowInfoImpl> myIdToInfo = new THashMap<>();
|
||||
|
||||
public MyStripeButtonComparator(@NotNull ToolWindowAnchor anchor) {
|
||||
for (WindowInfoImpl info : DesktopLayout.this.myIdToInfo.values()) {
|
||||
for (WindowInfoImpl info : getInfos()) {
|
||||
if (anchor == info.getAnchor()) {
|
||||
myIdToInfo.put(info.getId(), info.copy());
|
||||
}
|
||||
|
||||
@@ -287,7 +287,6 @@ final class Stripe extends JPanel implements UISettingsListener {
|
||||
tryDroppingOnGap(data, gap, -1);
|
||||
}
|
||||
|
||||
|
||||
if (isDroppingButton()) {
|
||||
final Dimension dragSize = myDragButton.getPreferredSize();
|
||||
if (getAnchor().isHorizontal() == myDragButton.getWindowInfo().getAnchor().isHorizontal()) {
|
||||
|
||||
+26
-32
@@ -197,8 +197,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
.handleDocked(toolWindowId -> {})
|
||||
.handleFloating(toolWindowId -> {})
|
||||
.handleFocusLostOnPinned(toolWindowId -> {
|
||||
ArrayList<FinalizableCommand> commands = new ArrayList<>();
|
||||
deactivateToolWindowImpl(toolWindowId, true, commands);
|
||||
List<FinalizableCommand> commands = new ArrayList<>();
|
||||
deactivateToolWindowImpl(getInfo(toolWindowId), true, commands);
|
||||
myCommandProcessor.execute(commands, myProject.getDisposed());
|
||||
})
|
||||
.handleWindowed(toolWindowId -> {})
|
||||
@@ -542,9 +542,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
if (myFrame == null) {
|
||||
return;
|
||||
}
|
||||
final String[] ids = getToolWindowIds();
|
||||
|
||||
// Remove ToolWindowsPane
|
||||
// remove ToolWindowsPane
|
||||
((IdeRootPane)myFrame.getRootPane()).setToolWindowsPane(null);
|
||||
myWindowManager.releaseFrame(myFrame);
|
||||
List<FinalizableCommand> commandsList = new ArrayList<>();
|
||||
@@ -552,8 +551,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
|
||||
// Hide all tool windows
|
||||
|
||||
for (final String id : ids) {
|
||||
deactivateToolWindowImpl(id, true, commandsList);
|
||||
for (WindowInfoImpl info : myLayout.getInfos()) {
|
||||
deactivateToolWindowImpl(info, true, commandsList);
|
||||
}
|
||||
|
||||
appendSetEditorComponentCmd(null, commandsList);
|
||||
@@ -603,12 +602,11 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
focusDefaultElementInSelectedEditor();
|
||||
}
|
||||
|
||||
private void deactivateWindows(@Nullable String idToIgnore, @NotNull List<FinalizableCommand> commandList) {
|
||||
for (final WindowInfoImpl info : myLayout.getInfos()) {
|
||||
if (idToIgnore != null && idToIgnore.equals(info.getId())) {
|
||||
continue;
|
||||
private void deactivateWindows(@NotNull String idToIgnore, @NotNull List<FinalizableCommand> commandList) {
|
||||
for (WindowInfoImpl info : myLayout.getInfos()) {
|
||||
if (!idToIgnore.equals(info.getId())) {
|
||||
deactivateToolWindowImpl(info, isToHideOnDeactivation(info), commandList);
|
||||
}
|
||||
deactivateToolWindowImpl(info.getId(), isToHideOnDeactivation(info), commandList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,18 +705,15 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
|
||||
/**
|
||||
* Helper method. It deactivates (and hides) window with specified {@code id}.
|
||||
*
|
||||
* @param id {@code id} of the tool window to be deactivated.
|
||||
* @param shouldHide if {@code true} then also hides specified tool window.
|
||||
*/
|
||||
private void deactivateToolWindowImpl(@NotNull String id, final boolean shouldHide, @NotNull List<FinalizableCommand> commandsList) {
|
||||
private void deactivateToolWindowImpl(@NotNull WindowInfoImpl info, final boolean shouldHide, @NotNull List<FinalizableCommand> commandsList) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("enter: deactivateToolWindowImpl(" + id + "," + shouldHide + ")");
|
||||
LOG.debug("enter: deactivateToolWindowImpl(" + info.getId() + "," + shouldHide + ")");
|
||||
}
|
||||
|
||||
WindowInfoImpl info = getInfo(id);
|
||||
if (shouldHide && info.isVisible()) {
|
||||
applyInfo(id, info, commandsList);
|
||||
//noinspection ConstantConditions
|
||||
applyInfo(info.getId(), info, commandsList);
|
||||
}
|
||||
info.setActive(false);
|
||||
appendApplyWindowInfoCmd(info, commandsList);
|
||||
@@ -832,15 +827,19 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
|
||||
public void hideToolWindow(@NotNull String id, final boolean hideSide, final boolean moveFocus) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
checkId(id);
|
||||
final WindowInfoImpl info = getInfo(id);
|
||||
if (!info.isVisible()) return;
|
||||
if (!info.isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<FinalizableCommand> commandList = new ArrayList<>();
|
||||
final boolean wasActive = info.isActive();
|
||||
|
||||
// hide and deactivate
|
||||
|
||||
deactivateToolWindowImpl(id, true, commandList);
|
||||
deactivateToolWindowImpl(info, true, commandList);
|
||||
|
||||
if (hideSide && !info.isFloating() && !info.isWindowed()) {
|
||||
final List<String> ids = myLayout.getVisibleIdsOn(info.getAnchor(), this);
|
||||
@@ -848,22 +847,18 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
myActiveStack.remove(each, true);
|
||||
}
|
||||
|
||||
|
||||
while (!mySideStack.isEmpty(info.getAnchor())) {
|
||||
mySideStack.pop(info.getAnchor());
|
||||
}
|
||||
|
||||
final String[] all = getToolWindowIds();
|
||||
for (String eachId : all) {
|
||||
final WindowInfoImpl eachInfo = getInfo(eachId);
|
||||
for (WindowInfoImpl eachInfo : myLayout.getInfos()) {
|
||||
if (eachInfo.isVisible() && eachInfo.getAnchor() == info.getAnchor()) {
|
||||
deactivateToolWindowImpl(eachId, true, commandList);
|
||||
deactivateToolWindowImpl(eachInfo, true, commandList);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isStackEnabled()) {
|
||||
// first of all we have to find tool window that was located at the same side and
|
||||
// was hidden.
|
||||
// first of all we have to find tool window that was located at the same side and was hidden
|
||||
|
||||
WindowInfoImpl info2 = null;
|
||||
while (!mySideStack.isEmpty(info.getAnchor())) {
|
||||
@@ -1207,7 +1202,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
for (final WindowInfoImpl currentInfo : currentInfos) {
|
||||
final WindowInfoImpl info = layout.getInfo(currentInfo.getId(), false);
|
||||
if (currentInfo.isVisible() && (info == null || !info.isVisible())) {
|
||||
deactivateToolWindowImpl(currentInfo.getId(), true, commandList);
|
||||
deactivateToolWindowImpl(currentInfo, true, commandList);
|
||||
}
|
||||
}
|
||||
// change anchor of tool windows
|
||||
@@ -1269,7 +1264,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
|
||||
@Override
|
||||
public boolean canShowNotification(@NotNull final String toolWindowId) {
|
||||
if (!Arrays.asList(getToolWindowIds()).contains(toolWindowId)) {
|
||||
if (getInfo(toolWindowId) == null) {
|
||||
return false;
|
||||
}
|
||||
final Stripe stripe = myToolWindowsPane.getStripeFor(toolWindowId);
|
||||
@@ -1744,10 +1739,9 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
// Update size of all open floating windows. See SCR #18439
|
||||
for (final String id : getToolWindowIds()) {
|
||||
final WindowInfoImpl info = getInfo(id);
|
||||
for (WindowInfoImpl info : myLayout.getInfos()) {
|
||||
if (info.isVisible()) {
|
||||
final InternalDecorator decorator = getInternalDecorator(id);
|
||||
final InternalDecorator decorator = getInternalDecorator(info.getId());
|
||||
LOG.assertTrue(decorator != null);
|
||||
decorator.fireResized();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user