Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
Eugene Kudelevsky
2010-07-16 16:17:58 +04:00
9 changed files with 79 additions and 15 deletions
@@ -57,6 +57,7 @@ import com.intellij.problems.WolfTheProblemSolver;
import com.intellij.psi.*;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.PopupOwner;
import com.intellij.ui.popup.list.ListPopupImpl;
@@ -81,7 +82,7 @@ import java.util.Set;
* User: anna
* Date: 03-Nov-2005
*/
public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
public class NavBarPanel extends OpaquePanel.List implements DataProvider, PopupOwner {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.navigationToolbar.NavigationToolbarPanel");
/*private static final Icon LEFT_ICON = IconLoader.getIcon("/general/splitLeft.png");
private static final Icon RIGHT_ICON = IconLoader.getIcon("/general/splitRight.png");
@@ -107,8 +108,6 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
myProject = project;
myModel = new NavBarModel(myProject);
setBackground(UIUtil.getListBackground());
setOpaque(true);
PopupHandler.installPopupHandler(this, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.NAVIGATION_BAR);
@@ -482,7 +481,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
}
final Object object = myModel.getElement(index);
final List<Object> objects = myModel.calcElementChildren(object);
final java.util.List<Object> objects = myModel.calcElementChildren(object);
if (!objects.isEmpty()) {
final Object[] siblings = new Object[objects.size()];
@@ -895,7 +894,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
boolean selected = myModel.getSelectedIndex() == myIndex;
setPaintFocusBorder(selected);
setFocusBorderAroundIcon(selected);
setFocusBorderAroundIcon(true);
setBackground(selected && focused ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.impl.IdeRootPaneNorthExtension;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -47,9 +48,8 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
public JComponent getComponent() {
if (myPanel == null) {
myPanel = new JPanel(new BorderLayout());
myPanel = new OpaquePanel.List(new BorderLayout());
myPanel.setBackground(UIUtil.getListBackground());
myNavigationBar = new NavBarPanel(myProject);
JScrollPane scroller = ScrollPaneFactory.createScrollPane(myNavigationBar);
@@ -34,13 +34,16 @@ import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.FileColorManager;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.util.IconUtil;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
public class NavigationItemListCellRenderer extends JPanel implements ListCellRenderer {
public class NavigationItemListCellRenderer extends OpaquePanel implements ListCellRenderer {
public NavigationItemListCellRenderer() {
super(new BorderLayout());
}
@@ -64,6 +67,8 @@ public class NavigationItemListCellRenderer extends JPanel implements ListCellRe
final Color listBg = leftCellRendererComponent.getBackground();
add(leftCellRendererComponent, BorderLayout.WEST);
setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
if (hasRightRenderer){
final DefaultListCellRenderer moduleRenderer = factory.getModuleRenderer();
@@ -71,13 +76,13 @@ public class NavigationItemListCellRenderer extends JPanel implements ListCellRe
moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
rightCellRendererComponent.setBackground(listBg);
add(rightCellRendererComponent, BorderLayout.EAST);
final JPanel spacer = new JPanel();
final JPanel spacer = new NonOpaquePanel();
final Dimension size = rightCellRendererComponent.getSize();
spacer.setSize(new Dimension((int)(size.width * 0.015 + leftCellRendererComponent.getSize().width * 0.015), size.height));
spacer.setBackground(isSelected ? UIUtil.getListSelectionBackground() : listBg);
add(spacer, BorderLayout.CENTER);
}
setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
return this;
}
@@ -27,6 +27,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
public class PsiElementModuleRenderer extends DefaultListCellRenderer{
@@ -112,9 +113,14 @@ public class PsiElementModuleRenderer extends DefaultListCellRenderer{
setText(value == null ? "" : value.toString());
}*/
setText(myText);
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
//setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
setHorizontalTextPosition(SwingConstants.LEFT);
setBackground(selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
setForeground(selected ? UIUtil.getListSelectionForeground() : UIUtil.getInactiveTextColor());
if (UIUtil.isUnderNimbusLookAndFeel()) {
setOpaque(false);
}
}
}
@@ -15,11 +15,15 @@
*/
package com.intellij.ui.components.panels;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.*;
public class NonOpaquePanel extends Wrapper {
private static final Color TRANSPARENT = new Color(0, 0, 0, 0);
public NonOpaquePanel() {
setOpaque(false);
}
@@ -49,4 +53,21 @@ public class NonOpaquePanel extends Wrapper {
setOpaque(false);
}
@Override
public void setOpaque(boolean isOpaque) {
super.setOpaque(isOpaque);
if (!isOpaque && UIUtil.isUnderNimbusLookAndFeel()) {
if (UIUtil.isUnderNimbusLookAndFeel()) {
setBackground(TRANSPARENT);
}
}
}
public static void setTransparent(JComponent c) {
c.setOpaque(false);
if (UIUtil.isUnderNimbusLookAndFeel()) {
c.setBackground(TRANSPARENT);
}
}
}
@@ -25,6 +25,7 @@ public class OpaquePanel extends JPanel {
private boolean myOpaqueActive = true;
private String myKey;
public OpaquePanel() {
this(null, null);
@@ -43,9 +44,15 @@ public class OpaquePanel extends JPanel {
setBackground(color);
}
public OpaquePanel setKey(String key) {
myKey = key;
return this;
}
protected void paintComponent(Graphics g) {
if (myOpaqueActive) {
g.setColor(getBackground());
Color bg = myKey != null ? UIManager.getColor(myKey) : getBackground();
g.setColor(bg);
Dimension size = getSize();
g.fillRect(0, 0, size.width, size.height);
}
@@ -58,4 +65,25 @@ public class OpaquePanel extends JPanel {
public void setOpaqueActive(final boolean opaqueActive) {
myOpaqueActive = opaqueActive;
}
public static class List extends OpaquePanel {
public List() {
setKey("List.background");
}
public List(LayoutManager layout) {
super(layout);
setKey("List.background");
}
public List(Color color) {
super(color);
setKey("List.background");
}
public List(LayoutManager layoutManager, Color color) {
super(layoutManager, color);
setKey("List.background");
}
}
}
@@ -184,6 +184,10 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL
myText.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
myText.setOpaque(false);
if (UIUtil.isUnderNimbusLookAndFeel()) {
myText.setBackground(new Color(0, 0, 0, 0));
}
myText.setEditable(false);
myText.setEditorKit(UIUtil.getHTMLEditorKit());
@@ -711,7 +711,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
final JLabel label = new JLabel(text.getText());
final Dimension size = label.getPreferredSize();
text.setEditable(false);
text.setOpaque(false);
NonOpaquePanel.setTransparent(text);
text.setBorder(null);
text.setPreferredSize(size);
@@ -35,6 +35,7 @@ import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.ui.treeStructure.actions.CollapseAllAction;
import com.intellij.ui.treeStructure.actions.ExpandAllAction;
@@ -556,8 +557,8 @@ public abstract class ChangesTreeList<T> extends JPanel {
myCheckBox = new JCheckBox();
myTextRenderer = new ChangesBrowserNodeRenderer(myProject, false, myHighlightProblems);
myCheckBox.setBackground(null);
setBackground(null);
NonOpaquePanel.setTransparent(this);
NonOpaquePanel.setTransparent(myCheckBox);
if (myShowCheckboxes) {
add(myCheckBox, BorderLayout.WEST);