From a8267ec6cfd725cab1c2e0df5263d6bbfef0831f Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 3 Aug 2012 10:17:07 +0200 Subject: [PATCH 1/3] a bit more codecache for 64bit jvm (inspections build) --- build/scripts/utils.gant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 73c2b33efe52..d36c47181a3c 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -53,7 +53,7 @@ binding.setVariable("isEap", { }) binding.setVariable("mem32", "-Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing") -binding.setVariable("mem64", "-Xms128m -Xmx800m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing") +binding.setVariable("mem64", "-Xms128m -Xmx800m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=70m -XX:+UseCodeCacheFlushing") binding.setVariable("common_vmoptions", "-ea") binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() }) From e7bf345c7657b06ba07bd6d3e4b6d02a79c08786 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 3 Aug 2012 10:24:44 +0200 Subject: [PATCH 2/3] revert --- build/scripts/utils.gant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index d36c47181a3c..73c2b33efe52 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -53,7 +53,7 @@ binding.setVariable("isEap", { }) binding.setVariable("mem32", "-Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing") -binding.setVariable("mem64", "-Xms128m -Xmx800m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=70m -XX:+UseCodeCacheFlushing") +binding.setVariable("mem64", "-Xms128m -Xmx800m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing") binding.setVariable("common_vmoptions", "-ea") binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() }) From 5892569959064fe2f3a99f62b1e8a44ca1bb5a2e Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 3 Aug 2012 11:19:37 +0200 Subject: [PATCH 3/3] Property Table: rendered tuned for various LaFs --- .../designer/propertyTable/PropertyTable.java | 185 ++++++------------ .../ui/TreeExpandableItemsHandler.java | 2 +- .../com/intellij/util/ui/CenteredIcon.java | 31 ++- .../util/src/com/intellij/util/ui/UIUtil.java | 38 +++- .../util/ui/tree/WideSelectionTreeUI.java | 27 +-- 5 files changed, 123 insertions(+), 160 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java index 8f1ecdd258b9..18a8c04024d7 100644 --- a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -19,21 +19,20 @@ import com.intellij.designer.model.ErrorInfo; import com.intellij.designer.model.PropertiesContainer; import com.intellij.designer.model.Property; import com.intellij.designer.model.PropertyContext; -import com.intellij.icons.AllIcons; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy; -import com.intellij.ui.*; +import com.intellij.ui.ColoredTableCellRenderer; +import com.intellij.ui.SimpleColoredComponent; +import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.TableUtil; import com.intellij.ui.table.JBTable; import com.intellij.util.ThrowableRunnable; -import com.intellij.util.ui.EmptyIcon; -import com.intellij.util.ui.IndentedIcon; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -79,6 +78,10 @@ public abstract class PropertyTable extends JBTable { setModel(myModel); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); showColumns(false); + setShowGrid(false); + + setRowSelectionAllowed(true); + setColumnSelectionAllowed(false); addMouseListener(new MouseTableListener()); @@ -874,6 +877,14 @@ public abstract class PropertyTable extends JBTable { } } + private static int getDepth(@NotNull Property property) { + int result = 0; + for (Property each = property.getParent(); each != null; each = each.getParent(), result++) { + // empty + } + return result; + } + private class PropertyCellEditorListener implements PropertyEditorListener { @Override public void valueCommitted(PropertyEditor source, boolean continueEditing, boolean closeEditorOnError) { @@ -969,161 +980,89 @@ public abstract class PropertyTable extends JBTable { protected abstract TextAttributesKey getErrorAttributes(@NotNull HighlightSeverity severity); private class PropertyCellRenderer implements TableCellRenderer { - private final Map myRegularAttributes = new HashMap(); - private final Map myBoldAttributes = new HashMap(); - private final Map myItalicAttributes = new HashMap(); - private final ColoredTableCellRenderer myPropertyNameRenderer; - private final ColoredTableCellRenderer myErrorRenderer; - private final Icon myExpandIcon; - private final Icon myCollapseIcon; - private final Icon myIndentedExpandIcon; - private final Icon myIndentedCollapseIcon; - private final Icon[] myIndentIcons = new Icon[3]; + private final ColoredTableCellRenderer myRenderer; private PropertyCellRenderer() { - myPropertyNameRenderer = new ColoredTableCellRenderer() { - protected void customizeCellRenderer( - JTable table, - Object value, - boolean selected, - boolean hasFocus, - int row, - int column - ) { + myRenderer = new ColoredTableCellRenderer() { + protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { setPaintFocusBorder(false); setFocusBorderAroundIcon(true); } }; - - myErrorRenderer = new ColoredTableCellRenderer() { - protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { - setPaintFocusBorder(false); - } - }; - - myExpandIcon = AllIcons.Nodes.ExpandNode; - myCollapseIcon = AllIcons.Nodes.CollapseNode; - for (int i = 0; i < myIndentIcons.length; i++) { - myIndentIcons[i] = new EmptyIcon(9 + 11 * i, 9); - } - myIndentedExpandIcon = new IndentedIcon(myExpandIcon, 11); - myIndentedCollapseIcon = new IndentedIcon(myCollapseIcon, 11); } @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean selected, + boolean cellHasFocus, + int row, + int column) { column = table.convertColumnIndexToModel(column); Property property = (Property)value; Color background = table.getBackground(); boolean isDefault = true; + Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + boolean tableHasFocus = focusOwner != null && SwingUtilities.isDescendingFrom(focusOwner, table); + try { isDefault = isDefault(property); } - catch (Throwable e) { + catch (Exception e) { LOG.debug(e); } - if (isDefault) { - background = Gray._240; - } + myRenderer.clear(); if (column == 0) { - myPropertyNameRenderer.getTableCellRendererComponent(table, value, selected, hasFocus, row, column); + myRenderer.getTableCellRendererComponent(table, value, selected, cellHasFocus, row, column); - if (!selected) { - myPropertyNameRenderer.setBackground(background); + myRenderer.setBackground(selected ? UIUtil.getTreeSelectionBackground(tableHasFocus) : background); + + SimpleTextAttributes attr = SimpleTextAttributes.REGULAR_ATTRIBUTES; + + if (!selected && !isDefault) { + attr = attr.derive(-1, FileStatus.MODIFIED.getColor(), null, null); } - - SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES; if (property.isImportant()) { - attributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES; + attr = attr.derive(attr.getStyle() | SimpleTextAttributes.STYLE_BOLD, null, null, null); } - else if (property.isExpert()) { - attributes = SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES; + if (property.isExpert()) { + attr = attr.derive(attr.getStyle() | SimpleTextAttributes.STYLE_ITALIC, null, null, null); + } + if (property.isDeprecated()) { + attr = attr.derive(attr.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT, null, null, null); } ErrorInfo errorInfo = getErrorInfoForRow(row); if (errorInfo != null) { - Map cache = myRegularAttributes; - if (property.isImportant()) { - cache = myBoldAttributes; - } - else if (property.isExpert()) { - cache = myItalicAttributes; - } + SimpleTextAttributes template = SimpleTextAttributes.fromTextAttributes( + EditorColorsManager.getInstance().getGlobalScheme().getAttributes(getErrorAttributes(errorInfo.getLevel().getSeverity()))); - HighlightSeverity severity = errorInfo.getLevel().getSeverity(); - SimpleTextAttributes errorAttributes = cache.get(severity); - - if (errorAttributes == null) { - TextAttributesKey attributesKey = getErrorAttributes(severity); - TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); - - if (property.isImportant()) { - textAttributes = textAttributes.clone(); - textAttributes.setFontType(textAttributes.getFontType() | Font.BOLD); - } - else if (property.isExpert()) { - textAttributes = textAttributes.clone(); - textAttributes.setFontType(textAttributes.getFontType() | Font.ITALIC); - } - - errorAttributes = SimpleTextAttributes.fromTextAttributes(textAttributes); - cache.put(severity, errorAttributes); - } - - attributes = errorAttributes; + int style = ((template.getStyle() & SimpleTextAttributes.STYLE_WAVED) != 0 ? SimpleTextAttributes.STYLE_WAVED : 0) + | ((template.getStyle() & SimpleTextAttributes.STYLE_UNDERLINE) != 0 ? SimpleTextAttributes.STYLE_UNDERLINE : 0); + attr = attr.derive(attr.getStyle() | style, template.getFgColor(), template.getBgColor(), template.getWaveColor()); } - if (property.isDeprecated()) { - attributes = new SimpleTextAttributes(attributes.getBgColor(), attributes.getFgColor(), attributes.getWaveColor(), - attributes.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT); - } + myRenderer.append(property.getName(), attr); - myPropertyNameRenderer.append(property.getName(), attributes); + Icon icon = UIUtil.getTreeNodeIcon(isExpanded(property), selected, tableHasFocus); + boolean hasChildren = !getChildren(property).isEmpty(); - if (!getChildren(property).isEmpty()) { - if (property.getParent() == null) { - if (isExpanded(property)) { - myPropertyNameRenderer.setIcon(myCollapseIcon); - } - else { - myPropertyNameRenderer.setIcon(myExpandIcon); - } - } - else { - if (isExpanded(property)) { - myPropertyNameRenderer.setIcon(myIndentedCollapseIcon); - } - else { - myPropertyNameRenderer.setIcon(myIndentedExpandIcon); - } - } - } - else { - myPropertyNameRenderer.setIcon(myIndentIcons[property.getIndent()]); - } + myRenderer.setIcon(hasChildren ? icon : null); + int indent = (icon.getIconWidth() + myRenderer.getIconTextGap()) * (getDepth(property) + (hasChildren ? 0 : 1)); + myRenderer.setIpad(new Insets(0, indent, 0, 0)); - if (!selected) { - if (isDefault) { - myPropertyNameRenderer.setForeground(property.isExpert() ? Color.LIGHT_GRAY : table.getForeground()); - } - else { - myPropertyNameRenderer.setForeground(FileStatus.MODIFIED.getColor()); - } - } - return myPropertyNameRenderer; + return myRenderer; } else { try { PropertyRenderer renderer = property.getRenderer(); - JComponent component = renderer.getComponent(getCurrentComponent(), getPropertyContext(), getValue(property), selected, hasFocus); - - if (!selected) { - component.setBackground(background); - } + JComponent component = + renderer.getComponent(getCurrentComponent(), getPropertyContext(), getValue(property), selected, tableHasFocus); + component.setBackground(selected ? UIUtil.getTreeSelectionBackground(tableHasFocus) : background); component.setFont(table.getFont()); if (component instanceof JCheckBox) { @@ -1132,11 +1071,11 @@ public abstract class PropertyTable extends JBTable { return component; } - catch (Throwable e) { + catch (Exception e) { LOG.debug(e); - myErrorRenderer.clear(); - myErrorRenderer.append(formatErrorGettingValueMesage(e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES); - return myErrorRenderer; + myRenderer.getTableCellRendererComponent(table, value, selected, cellHasFocus, row, column); + myRenderer.append(formatErrorGettingValueMesage(e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES); + return myRenderer; } } } diff --git a/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java index f3f3d39674b5..5d459082546c 100644 --- a/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java +++ b/platform/platform-impl/src/com/intellij/ui/TreeExpandableItemsHandler.java @@ -154,7 +154,7 @@ public class TreeExpandableItemsHandler extends AbstractExpandableItemsHandler 0 ? hsl[2] - .08f : hsl[2])); @@ -668,6 +668,10 @@ public class UIUtil { return isUnderDarcula() ? Gray._52 : UNFOCUSED_SELECTION_COLOR; } + public static Color getTreeSelectionBackground(boolean focused) { + return focused ? getTreeSelectionBackground() : getTreeUnfocusedSelectionBackground(); + } + public static Color getTreeUnfocusedSelectionBackground() { Color background = getTreeTextBackground(); return ColorUtil.isDark(background) ? Gray._30 : UNFOCUSED_SELECTION_COLOR; @@ -811,6 +815,20 @@ public class UIUtil { return UIManager.getIcon("RadioButton.icon"); } + public static Icon getTreeNodeIcon(boolean expanded, boolean selected, boolean focused) { + boolean white = (selected && focused) || isUnderDarcula(); + + Icon selectedIcon = getTreeSelectedExpandedIcon(); + Icon notSelectedIcon = getTreeExpandedIcon(); + + int widht = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); + int height = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); + + return new CenteredIcon(expanded ? (white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon()) + : (white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon()), + widht, height, false); + } + public static Icon getTreeCollapsedIcon() { return UIManager.getIcon("Tree.collapsedIcon"); } @@ -819,6 +837,16 @@ public class UIUtil { return UIManager.getIcon("Tree.expandedIcon"); } + public static Icon getTreeSelectedCollapsedIcon() { + return isUnderAquaBasedLookAndFeel() || isUnderNimbusLookAndFeel() || isUnderGTKLookAndFeel() + ? AllIcons.Mac.Tree_white_right_arrow : getTreeCollapsedIcon(); + } + + public static Icon getTreeSelectedExpandedIcon() { + return isUnderAquaBasedLookAndFeel() || isUnderNimbusLookAndFeel() || isUnderGTKLookAndFeel() + ? AllIcons.Mac.Tree_white_down_arrow : getTreeExpandedIcon(); + } + public static Border getTableHeaderCellBorder() { return UIManager.getBorder("TableHeader.cellBorder"); } @@ -1362,7 +1390,7 @@ public class UIUtil { *

* The whole idea is that XRender-based pipeline doesn't support * {@link AlphaComposite#SRC} and we should use {@link AlphaComposite#SRC_OVER} instead. - * + * * @param g target graphics container */ public static void setupComposite(@NotNull Graphics2D g) { @@ -1671,7 +1699,7 @@ public class UIUtil { public static Color getBorderColor() { return BORDER_COLOR; } - + public static Font getTitledBorderFont() { Font defFont = getLabelFont(); return defFont.deriveFont(Math.max(defFont.getSize() - 2f, 11f)); @@ -2331,7 +2359,7 @@ public class UIUtil { public static JComponent mergeComponentsWithAnchor(PanelWithAnchor...panels) { return mergeComponentsWithAnchor(Arrays.asList(panels)); } - + @Nullable public static JComponent mergeComponentsWithAnchor(Collection panels) { JComponent maxWidthAnchor = null; @@ -2379,7 +2407,7 @@ public class UIUtil { component.setBorder(new EmptyBorder(insets)); } } - + public static Dimension addInsets(@NotNull Dimension dimension, @NotNull Insets insets) { Dimension ans = new Dimension(dimension); diff --git a/platform/util/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java b/platform/util/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java index 54ee6e81a4b1..70d3b69df176 100644 --- a/platform/util/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java +++ b/platform/util/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java @@ -15,7 +15,6 @@ */ package com.intellij.util.ui.tree; -import com.intellij.icons.AllIcons; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.containers.ComparatorUtil; import com.intellij.util.ui.UIUtil; @@ -40,16 +39,6 @@ public class WideSelectionTreeUI extends BasicTreeUI { @NonNls public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list"; @NonNls public static final String STRIPED_CLIENT_PROPERTY = "mac.ui.striped"; - private static Icon getTreeSelectedCollapsedIcon() { - return UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel() || UIUtil.isUnderGTKLookAndFeel() - ? AllIcons.Mac.Tree_white_right_arrow : UIUtil.getTreeCollapsedIcon(); - } - - private static Icon getTreeSelectedExpandedIcon() { - return UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel() || UIUtil.isUnderGTKLookAndFeel() - ? AllIcons.Mac.Tree_white_down_arrow : UIUtil.getTreeExpandedIcon(); - } - private static final Border LIST_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListBackgroundPainter"); private static final Border LIST_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListSelectionBackgroundPainter"); private static final Border LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListFocusedSelectionBackgroundPainter"); @@ -315,7 +304,7 @@ public class WideSelectionTreeUI extends BasicTreeUI { } else { if (UIUtil.isUnderAquaBasedLookAndFeel()) { - Color bg = tree.hasFocus() ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground(); + Color bg = UIUtil.getTreeSelectionBackground(tree.hasFocus()); if (!selected) { bg = background; } @@ -370,7 +359,7 @@ public class WideSelectionTreeUI extends BasicTreeUI { for (int row = firstVisibleRow; row <= lastVisibleRow; row++) { if (tr.getSelectionModel().isRowSelected(row)) { final Rectangle bounds = tr.getRowBounds(row); - Color color = tr.hasFocus() ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground(); + Color color = UIUtil.getTreeSelectionBackground(tr.hasFocus()); if (color != null) { g.setColor(color); g.fillRect(0, bounds.y, tr.getWidth(), bounds.height); @@ -404,17 +393,9 @@ public class WideSelectionTreeUI extends BasicTreeUI { boolean hasBeenExpanded, boolean isLeaf) { boolean isPathSelected = tree.getSelectionModel().isPathSelected(path); - boolean dark = UIUtil.isUnderDarcula(); - - Icon expandIcon = (isPathSelected && tree.hasFocus()) || dark ? getTreeSelectedExpandedIcon() - : UIUtil.getTreeExpandedIcon(); - Icon collapseIcon = (isPathSelected && tree.hasFocus()) || dark? getTreeSelectedCollapsedIcon() - : UIUtil.getTreeCollapsedIcon(); - - if (!isLeaf(row)) { - setExpandedIcon(expandIcon); - setCollapsedIcon(collapseIcon); + setExpandedIcon(UIUtil.getTreeNodeIcon(true, isPathSelected, tree.hasFocus())); + setCollapsedIcon(UIUtil.getTreeNodeIcon(false, isPathSelected, tree.hasFocus())); } super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);