Browse Source

fix tree demo (missing icons)

master
Konstantin Bulenkov 11 years ago
parent
commit
0666c32eb0
  1. 2
      .idea/misc.xml
  2. 4
      src/com/bulenkov/darcula/DarculaLaf.java
  3. 36
      src/com/bulenkov/darcula/DarculaUIUtil.java
  4. 2
      src/com/bulenkov/darcula/darcula.properties
  5. BIN
      src/com/bulenkov/darcula/icons/treeNodeCollapsed.png
  6. BIN
      src/com/bulenkov/darcula/icons/treeNodeCollapsed@2x.png
  7. BIN
      src/com/bulenkov/darcula/icons/treeNodeExpanded.png
  8. BIN
      src/com/bulenkov/darcula/icons/treeNodeExpanded@2x.png
  9. 5
      src/com/bulenkov/darcula/ui/DarculaTreeUI.java
  10. 14
      swingset3/com/sun/swingset3/demos/DemoUtilities.java
  11. 4
      swingset3/com/sun/swingset3/demos/table/TableDemo.java
  12. 11
      swingset3/com/sun/swingset3/utilities/Utilities.java

2
.idea/misc.xml

@ -6,7 +6,7 @@
<component name="ProjectKey"> <component name="ProjectKey">
<option name="state" value="https://bulenkov@bitbucket.org/bulenkov/darcula.git" /> <option name="state" value="https://bulenkov@bitbucket.org/bulenkov/darcula.git" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Plugin SDK" project-jdk-type="IDEA JDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

4
src/com/bulenkov/darcula/DarculaLaf.java

@ -16,6 +16,7 @@
package com.bulenkov.darcula; package com.bulenkov.darcula;
import com.bulenkov.iconloader.IconLoader;
import com.bulenkov.iconloader.util.ColorUtil; import com.bulenkov.iconloader.util.ColorUtil;
import com.bulenkov.iconloader.util.StringUtil; import com.bulenkov.iconloader.util.StringUtil;
import com.bulenkov.iconloader.util.SystemInfo; import com.bulenkov.iconloader.util.SystemInfo;
@ -92,6 +93,9 @@ public final class DarculaLaf extends BasicLookAndFeel {
patchComboBox(metalDefaults, defaults); patchComboBox(metalDefaults, defaults);
defaults.remove("Spinner.arrowButtonBorder"); defaults.remove("Spinner.arrowButtonBorder");
defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5)); defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5));
defaults.put("Tree.collapsedIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/treeNodeCollapsed.png")));
defaults.put("Tree.expandedIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/treeNodeExpanded.png")));
return defaults; return defaults;
} }
catch (Exception ignore) { catch (Exception ignore) {

36
src/com/bulenkov/darcula/DarculaUIUtil.java

@ -15,11 +15,9 @@
*/ */
package com.bulenkov.darcula; package com.bulenkov.darcula;
import com.bulenkov.iconloader.util.ColorUtil; import com.bulenkov.iconloader.util.*;
import com.bulenkov.iconloader.util.DoubleColor;
import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.iconloader.util.UIUtil;
import javax.swing.*;
import java.awt.*; import java.awt.*;
/** /**
@ -140,5 +138,35 @@ public class DarculaUIUtil {
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
} }
public static Icon getTreeNodeIcon(boolean expanded, boolean selected, boolean focused) {
boolean white = (selected && focused) || UIUtil.isUnderDarcula();
Icon selectedIcon = getTreeSelectedExpandedIcon();
Icon notSelectedIcon = getTreeExpandedIcon();
int width = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth());
int height = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth());
return new CenteredIcon(expanded ? (white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon())
: (white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon()),
width, height, false
);
}
public static Icon getTreeCollapsedIcon() {
return UIManager.getIcon("Tree.collapsedIcon");
}
public static Icon getTreeExpandedIcon() {
return UIManager.getIcon("Tree.expandedIcon");
}
public static Icon getTreeSelectedCollapsedIcon() {
return getTreeCollapsedIcon();
}
public static Icon getTreeSelectedExpandedIcon() {
return getTreeExpandedIcon();
}
} }

2
src/com/bulenkov/darcula/darcula.properties

@ -159,7 +159,5 @@ Hyperlink.linkColor=589df6
#Table.background=45494A #Table.background=45494A
#Tree.background=45494A #Tree.background=45494A
Tree.collapsedIcon=AllIcons.Mac.Tree_white_right_arrow
Tree.expandedIcon=AllIcons.Mac.Tree_white_down_arrow
FileView.fileIcon=AllIcons.FileTypes.Unknown FileView.fileIcon=AllIcons.FileTypes.Unknown

BIN
src/com/bulenkov/darcula/icons/treeNodeCollapsed.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

BIN
src/com/bulenkov/darcula/icons/treeNodeCollapsed@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

BIN
src/com/bulenkov/darcula/icons/treeNodeExpanded.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

BIN
src/com/bulenkov/darcula/icons/treeNodeExpanded@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

5
src/com/bulenkov/darcula/ui/DarculaTreeUI.java

@ -16,6 +16,7 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.iconloader.util.SystemInfo; import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.iconloader.util.UIUtil; import com.bulenkov.iconloader.util.UIUtil;
@ -413,8 +414,8 @@ public class DarculaTreeUI extends BasicTreeUI {
boolean isLeaf) { boolean isLeaf) {
boolean isPathSelected = tree.getSelectionModel().isPathSelected(path); boolean isPathSelected = tree.getSelectionModel().isPathSelected(path);
if (!isLeaf(row)) { if (!isLeaf(row)) {
setExpandedIcon(UIUtil.getTreeNodeIcon(true, isPathSelected, tree.hasFocus())); setExpandedIcon(DarculaUIUtil.getTreeNodeIcon(true, isPathSelected, tree.hasFocus()));
setCollapsedIcon(UIUtil.getTreeNodeIcon(false, isPathSelected, tree.hasFocus())); setCollapsedIcon(DarculaUIUtil.getTreeNodeIcon(false, isPathSelected, tree.hasFocus()));
} }
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);

14
swingset3/com/sun/swingset3/demos/DemoUtilities.java

@ -30,11 +30,10 @@
*/ */
package com.sun.swingset3.demos; package com.sun.swingset3.demos;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.net.URI;
import java.io.IOException; import java.io.IOException;
import javax.swing.*; import java.net.URI;
import javax.jnlp.*;
/** /**
* @author Pavel Porvatov * @author Pavel Porvatov
@ -107,7 +106,7 @@ public class DemoUtilities {
toplevel.setLocation(x, y); toplevel.setLocation(x, y);
} }
public static boolean browse(URI uri) throws IOException, UnavailableServiceException { public static boolean browse(URI uri) throws IOException {
// Try using the Desktop api first // Try using the Desktop api first
try { try {
Desktop desktop = Desktop.getDesktop(); Desktop desktop = Desktop.getDesktop();
@ -115,13 +114,6 @@ public class DemoUtilities {
return true; return true;
} catch (SecurityException e) { } catch (SecurityException e) {
// Running in sandbox, try using WebStart service
BasicService basicService =
(BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
if (basicService.isWebBrowserSupported()) {
return basicService.showDocument(uri.toURL());
}
} }
return false; return false;

4
swingset3/com/sun/swingset3/demos/table/TableDemo.java

@ -399,8 +399,8 @@ public class TableDemo extends JPanel {
new ArrayList<RowFilter<OscarTableModel, Integer>>(2); new ArrayList<RowFilter<OscarTableModel, Integer>>(2);
filters.add(winnerFilter); filters.add(winnerFilter);
filters.add(searchFilter); filters.add(searchFilter);
RowFilter<Object, Object> comboFilter = RowFilter.andFilter((Iterable<? extends RowFilter<? super Object,? super Object>>) filters); // RowFilter<? super Object, ? super Object> comboFilter = RowFilter.andFilter((Iterable<? extends RowFilter<? super Object, ? super Object>>) filters);
sorter.setRowFilter(comboFilter); sorter.setRowFilter(RowFilter.andFilter(filters));
} else if (showOnlyWinners) { } else if (showOnlyWinners) {
sorter.setRowFilter(winnerFilter); sorter.setRowFilter(winnerFilter);
} else if (hasFilterString()) { } else if (hasFilterString()) {

11
swingset3/com/sun/swingset3/utilities/Utilities.java

@ -31,16 +31,11 @@
package com.sun.swingset3.utilities; package com.sun.swingset3.utilities;
import java.awt.Color; import javax.swing.*;
import java.awt.GradientPaint; import java.awt.*;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Transparency;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.net.URL; import java.net.URL;
import javax.jnlp.ServiceManager;
import javax.swing.SwingConstants;
/** /**
* *
@ -53,7 +48,7 @@ public class Utilities {
} }
public static boolean runningFromWebStart() { public static boolean runningFromWebStart() {
return ServiceManager.getServiceNames() != null; return false;
} }
public static String getURLFileName(URL url) { public static String getURLFileName(URL url) {

Loading…
Cancel
Save