kirill-grouchnikov / substance

A modern and high-performant Swing look-and-feel library
164 stars 109 forks source link

Issue with the tree cell render which must be object of default cell render rather than the treecell. #69

Closed raikikon closed 6 years ago

raikikon commented 6 years ago

Version of Substance

Version of Java

Version of OS

The issue you're experiencing (expected vs actual, screenshot, stack trace etc)

SubstanceDefaultTreeCellRenderer.zip

fixed

kirill-grouchnikov commented 6 years ago

It's not clear what this is fixing. There is https://github.com/kirill-grouchnikov/substance/issues/66 which is tracking an enhancement to provide more generic way of rendering such content while still maintaining the animated highlights.

raikikon commented 6 years ago
Caused by: java.lang.ClassCastException: org.pushingpixels.substance.api.renderers.SubstanceDefaultTreeCellRenderer cannot be cast to javax.swing.tree.DefaultTreeCellRenderer
    at gis.filter.CheckTreeManager.<init>(CheckTreeManager.java:58)
    at gis.filter.IfPanel.postInit(IfPanel.java:50)
    at gis.filter.IfPanel.<init>(IfPanel.java:31)
    at gis.filter.EntityFilterDialog.<init>(EntityFilterDialog.java:36)
    at gis.filter.SpotLightFiltersManager$SpotLightCustomFilteringDialog.<init>(SpotLightFiltersManager.java:91)
    at com.bel.crl.gis.filter.SpotLightFiltersManager.<clinit>(SpotLightFiltersManager.java:40)

while checkTreemanager code is

public CheckTreeManager(FilterTree tree, IFilterHelper<?>... filterHelper){
        this.tree = tree;
        this.filterHelper = filterHelper;
        EditTreeCell cellEditor = new EditTreeCell(tree, (DefaultTreeCellRenderer) tree.getCellRenderer()); // error here

now EditTreeCell

public class EditTreeCell extends DefaultTreeCellEditor{

    private final int mHotSpot = new JCheckBox().getWidth();

    public EditTreeCell(JTree tree, DefaultTreeCellRenderer renderer) {
        super(tree, renderer);
    }

    @SuppressWarnings("serial")
    @Override
    protected TreeCellEditor createTreeCellEditor() {

        Border              aBorder = UIManager.getBorder("Tree.editorBorder");
        DefaultCellEditor   editor = new DefaultCellEditor (  new DefaultTextField(aBorder)) {
            @Override
            public boolean shouldSelectCell(EventObject event) {
                boolean retValue = super.shouldSelectCell(event);
                return retValue;
            }
        };

        // One click to edit.
        editor.setClickCountToStart(2);
        return editor;
    }

    @Override
    protected boolean inHitRegion(int x, int y) {
        return super.inHitRegion(x+mHotSpot, y);
    }

}

also can you give me http://today.java.net/today/2007/02/22/flexi-slider-src.zip flexi-slider-src.zip this code

kirill-grouchnikov commented 6 years ago

(DefaultTreeCellRenderer) tree.getCellRenderer()

This is not an assumption that a library can make. If you do not have access to change the source code of that library, you will need to change your app to use an extension of DefaultTreeCellRenderer. I've added a comment in SubstanceDefaultTreeCellRenderer explaining why it is not going to be switched to that super class.

kirill-grouchnikov commented 6 years ago

As for the flexislider, I don't have the original sources any more. However, some variant of it (don't know if this was the last one I've touched) is in http://www.java2s.com/Code/Jar/f/Downloadflamingo31sourcesjar.htm

Download that and you will have it in the flamingo/slider folder. Use together with https://web.archive.org/web/20080430123725/http://today.java.net/pub/a/today/2007/02/22/how-to-write-custom-swing-component.html. Fair warning - I haven't looked at that code in ten years, so probably I won't be able to answer questions on it.