From 9e39717c36e4f669f2b2995eb086cbec5b531f87 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 23 Jul 2012 17:45:58 +0200 Subject: [PATCH] tree wide selection --- .../intellij/ui/ColoredTreeCellRenderer.java | 10 ++-- .../ui/HighlightableCellRenderer.java | 6 +- .../ui/JBDefaultTreeCellRenderer.java | 6 +- .../com/intellij/ui/treeStructure/Tree.java | 6 +- .../util/EditSourceOnDoubleClickHandler.java | 4 +- .../intellij/ide/dnd/aware/DnDAwareTree.java | 6 +- .../openapi/keymap/impl/ui/ActionsTree.java | 6 +- .../ui/MultilineTreeCellRenderer.java | 6 +- .../ui/TreeExpandableItemsHandler.java | 6 +- .../src/com/intellij/util/ui/MacUIUtil.java | 8 +-- ...acTreeUI.java => WideSelectionTreeUI.java} | 59 ++++++++++++++----- 11 files changed, 76 insertions(+), 47 deletions(-) rename platform/util/src/com/intellij/util/ui/tree/{MacTreeUI.java => WideSelectionTreeUI.java} (84%) diff --git a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java index 92c1fe10ed5f..b2605435d345 100644 --- a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package com.intellij.ui; import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -64,7 +64,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp if (UIUtil.isFullRowSelectionLAF()) { setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); } - else if (UIUtil.isUnderAquaBasedLookAndFeel() && tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection()) { + else if (/*UIUtil.isUnderAquaBasedLookAndFeel() && */tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) { setPaintFocusBorder(false); //setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); } @@ -100,7 +100,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp super.setOpaque(false); // avoid erasing Nimbus focus frame super.setIconOpaque(false); } - else if (UIUtil.isUnderAquaBasedLookAndFeel() && tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection()) { + else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) { super.setOpaque(false); // avoid erasing Nimbus focus frame super.setIconOpaque(false); } @@ -108,7 +108,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree } - if (tree.getUI() instanceof MacTreeUI) { + if (tree.getUI() instanceof WideSelectionTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) { setMyBorder(null); setIpad(new Insets(0, 2, 0, 2)); } diff --git a/platform/platform-api/src/com/intellij/ui/HighlightableCellRenderer.java b/platform/platform-api/src/com/intellij/ui/HighlightableCellRenderer.java index 392dfcffff36..b35c9a8c9a4d 100644 --- a/platform/platform-api/src/com/intellij/ui/HighlightableCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/HighlightableCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.intellij.ui; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import javax.swing.*; import javax.swing.tree.TreeCellRenderer; @@ -36,7 +36,7 @@ public class HighlightableCellRenderer extends HighlightableComponent implements setFont(UIUtil.getTreeFont()); setIcon(null); - if (tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection()) { + if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) { setOpaque(false); myIsSelected = false; myHasFocus = false; diff --git a/platform/platform-api/src/com/intellij/ui/JBDefaultTreeCellRenderer.java b/platform/platform-api/src/com/intellij/ui/JBDefaultTreeCellRenderer.java index 1683ac5c36b3..75f368b0f8e2 100644 --- a/platform/platform-api/src/com/intellij/ui/JBDefaultTreeCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/JBDefaultTreeCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package com.intellij.ui; import com.intellij.util.ui.MacUIUtil; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -33,7 +33,7 @@ public class JBDefaultTreeCellRenderer extends DefaultTreeCellRenderer { public JBDefaultTreeCellRenderer(@NotNull final JTree tree) { MacUIUtil.doNotFillBackground(tree, this); - myMacTreeUI = tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection(); + myMacTreeUI = tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection(); } @Override diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index 70ece1ad94fd..b67783afd0a3 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -27,7 +27,7 @@ import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.ComponentWithEmptyText; import com.intellij.util.ui.StatusText; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,8 +96,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith public void setUI(final TreeUI ui) { TreeUI actualUI = ui; if (!isCustomUI()) { - if (!(ui instanceof MacTreeUI) && UIUtil.isUnderAquaBasedLookAndFeel()) { - actualUI = new MacTreeUI(isMacWideSelection(), !isFileColorsEnabled()); + if (!(ui instanceof WideSelectionTreeUI) /*&& UIUtil.isUnderAquaBasedLookAndFeel()*/) { + actualUI = new WideSelectionTreeUI(isMacWideSelection(), !isFileColorsEnabled()); } } super.setUI(actualUI); diff --git a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java index 34791ec8f524..6c0bc76a69ba 100644 --- a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java +++ b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java @@ -23,7 +23,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; import com.intellij.ui.DoubleClickListener; import com.intellij.ui.treeStructure.treetable.TreeTable; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -106,7 +106,7 @@ public class EditSourceOnDoubleClickHandler { @Override public boolean onDoubleClick(MouseEvent e) { - final TreePath path = myTree.getUI() instanceof MacTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) + final TreePath path = myTree.getUI() instanceof WideSelectionTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) : myTree.getPathForLocation(e.getX(), e.getY()); if (path == null) return false; diff --git a/platform/platform-impl/src/com/intellij/ide/dnd/aware/DnDAwareTree.java b/platform/platform-impl/src/com/intellij/ide/dnd/aware/DnDAwareTree.java index e996c91d73a3..16e25aff0b78 100644 --- a/platform/platform-impl/src/com/intellij/ide/dnd/aware/DnDAwareTree.java +++ b/platform/platform-impl/src/com/intellij/ide/dnd/aware/DnDAwareTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import com.intellij.ide.dnd.DnDAware; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NotNull; @@ -58,7 +58,7 @@ public class DnDAwareTree extends Tree implements DnDAware { public final boolean isOverSelection(final Point point) { final TreeUI ui = getUI(); - final TreePath path = ui instanceof MacTreeUI && ((MacTreeUI)ui).isWideSelection() + final TreePath path = ui instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)ui).isWideSelection() ? getClosestPathForLocation(point.x, point.y) : getPathForLocation(point.x, point.y); if (path == null) return false; return isPathSelected(path); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java index b2d944853456..5beb45732455 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import com.intellij.ui.treeStructure.Tree; import com.intellij.ui.treeStructure.treetable.TreeTableModel; import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -97,7 +97,7 @@ public class ActionsTree { myTree.setRootVisible(false); myTree.setShowsRootHandles(true); - myTree.putClientProperty(MacTreeUI.STRIPED_CLIENT_PROPERTY, Boolean.TRUE); + myTree.putClientProperty(WideSelectionTreeUI.STRIPED_CLIENT_PROPERTY, Boolean.TRUE); myTree.setCellRenderer(new KeymapsRenderer()); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); diff --git a/platform/platform-impl/src/com/intellij/ui/MultilineTreeCellRenderer.java b/platform/platform-impl/src/com/intellij/ui/MultilineTreeCellRenderer.java index 91ce8bbf4cd4..1c824224100e 100644 --- a/platform/platform-impl/src/com/intellij/ui/MultilineTreeCellRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/MultilineTreeCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ArrayUtil; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -131,7 +131,7 @@ public abstract class MultilineTreeCellRenderer extends JComponent implements Tr } // fill background - if (!(myTree.getUI() instanceof MacTreeUI) || !((MacTreeUI)myTree.getUI()).isWideSelection()) { + if (!(myTree.getUI() instanceof WideSelectionTreeUI) || !((WideSelectionTreeUI)myTree.getUI()).isWideSelection()) { g.setColor(bgColor); g.fillRect(borderX, borderY, borderW, borderH); diff --git a/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java index 6a33df2d5b03..f3f3d39674b5 100644 --- a/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java +++ b/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java @@ -18,7 +18,7 @@ package com.intellij.ui; import com.intellij.openapi.util.Pair; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.MacTreeUI; +import com.intellij.util.ui.tree.WideSelectionTreeUI; import javax.swing.*; import javax.swing.event.TreeModelEvent; @@ -133,13 +133,13 @@ public class TreeExpandableItemsHandler extends AbstractExpandableItemsHandler