package bdv.ui.sourcegrouptree;

import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellEditor;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 * @author Tobias Pietzsch
 */
class SourceGroupEditor extends DefaultTreeCellEditor
{
	private final SourceGroupTreeCellRenderer sourceGroupRenderer;

	public SourceGroupEditor( final JTree tree, final SourceGroupTreeCellRenderer sourceGroupRenderer )
	{
		// super class uses the DefaultTreeCellRenderer for font, icons, preferred size, etc
		super( tree, new DefaultTreeCellRenderer() );
		this.sourceGroupRenderer = sourceGroupRenderer;
	}

	// Overridden because we don't want to start the editing timer at all
	@Override
	protected void startEditingTimer()
	{
	}

	@Override
	protected void determineOffset( final JTree tree, final Object value, final boolean isSelected, final boolean expanded, final boolean leaf, final int row )
	{
		editingIcon = null;
		offset = sourceGroupRenderer.determineOffset( value );
	}
}

@@ -26,16 +26,94 @@
 ptree;%0A%0A
+import java.awt.Component;%0Aimport java.awt.Graphics;%0Aimport javax.swing.Icon;%0A
 import j
@@ -992,12 +992,17 @@
 n = 
-null
+emptyIcon
 ;%0A%09%09
@@ -1059,10 +1059,467 @@
 e );%0A%09%7D%0A
+%0A%09private final Icon emptyIcon = new Icon()%0A%09%7B%0A%09%09private int iconHeight = -1;%0A%0A%09%09@Override%0A%09%09public void paintIcon( final Component c, final Graphics g, final int x, final int y )%0A%09%09%7B%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public int getIconWidth()%0A%09%09%7B%0A%09%09%09return 1;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public int getIconHeight()%0A%09%09%7B%0A%09%09%09if ( iconHeight %3C 0 && renderer != null )%0A%09%09%09%09iconHeight = renderer.getDefaultLeafIcon().getIconHeight();%0A%09%09%09return iconHeight %3C 0 ? 1 : iconHeight;%0A%09%09%7D%0A%09%7D;%0A%0A
 %7D%0A

Fix bug in Linux when editing group name (#71)