@ -42,13 +42,15 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseEvent ;
import java.awt.event.MouseEvent ;
import java.awt.event.MouseListener ;
import java.awt.event.MouseListener ;
import java.beans.PropertyChangeEvent ;
import java.beans.PropertyChangeListener ;
import java.util.Enumeration ;
import java.util.Enumeration ;
/ * *
/ * *
* @author Konstantin Bulenkov
* @author Konstantin Bulenkov
* @author Jannis Weis
* @author Jannis Weis
* /
* /
public class DarkTreeUI extends BasicTreeUI {
public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
public static final String TREE_TABLE_TREE_KEY = "JTree.treeTableTree" ;
public static final String TREE_TABLE_TREE_KEY = "JTree.treeTableTree" ;
public static final String STRIPED_CLIENT_PROPERTY = "JTree.alternateRowColor" ;
public static final String STRIPED_CLIENT_PROPERTY = "JTree.alternateRowColor" ;
@ -135,13 +137,9 @@ public class DarkTreeUI extends BasicTreeUI {
@Override
@Override
protected void completeUIInstall ( ) {
protected void completeUIInstall ( ) {
super . completeUIInstall ( ) ;
super . completeUIInstall ( ) ;
myOldRepaintAllRowValue = UIManager . getBoolean ( "Tree.repaintWholeRow" ) ;
myOldRepaintAllRowValue = UIManager . getBoolean ( "Tree.repaintWholeRow" ) ;
UIManager . put ( "Tree.repaintWholeRow" , true ) ;
UIManager . put ( "Tree.repaintWholeRow" , true ) ;
tree . putClientProperty ( "JTree.alternateRowColor" , UIManager . getBoolean ( "Tree.alternateRowColor" ) ) ;
tree . putClientProperty ( "JTree.alternateRowColor" , UIManager . getBoolean ( "Tree.alternateRowColor" ) ) ;
tree . setShowsRootHandles ( true ) ;
tree . addMouseListener ( mySelectionListener ) ;
}
}
@Override
@Override
@ -164,6 +162,15 @@ public class DarkTreeUI extends BasicTreeUI {
tree . putClientProperty ( "JTree.renderBooleanAsCheckBox" ,
tree . putClientProperty ( "JTree.renderBooleanAsCheckBox" ,
UIManager . getBoolean ( "Tree.renderBooleanAsCheckBox" ) ) ;
UIManager . getBoolean ( "Tree.renderBooleanAsCheckBox" ) ) ;
tree . putClientProperty ( "JTree.booleanRenderType" , UIManager . getString ( "Tree.booleanRenderType" ) ) ;
tree . putClientProperty ( "JTree.booleanRenderType" , UIManager . getString ( "Tree.booleanRenderType" ) ) ;
tree . setShowsRootHandles ( true ) ;
tree . putClientProperty ( "JTree.lineStyle" , "Line" ) ;
}
@Override
protected void installListeners ( ) {
super . installListeners ( ) ;
tree . addPropertyChangeListener ( this ) ;
tree . addMouseListener ( mySelectionListener ) ;
}
}
@Override
@Override
@ -320,11 +327,16 @@ public class DarkTreeUI extends BasicTreeUI {
}
}
@Override
@Override
public void uninstallUI ( final JComponent c ) {
protected void uninstallDefaults ( ) {
super . uninstallUI ( c ) ;
super . uninstallDefaults ( ) ;
UIManager . put ( "Tree.repaintWholeRow" , myOldRepaintAllRowValue ) ;
UIManager . put ( "Tree.repaintWholeRow" , myOldRepaintAllRowValue ) ;
c . removeMouseListener ( mySelectionListener ) ;
}
@Override
protected void uninstallListeners ( ) {
super . uninstallListeners ( ) ;
tree . removeMouseListener ( mySelectionListener ) ;
tree . removePropertyChangeListener ( this ) ;
}
}
@Override
@Override
@ -674,6 +686,20 @@ public class DarkTreeUI extends BasicTreeUI {
& & ( SystemInfo . isMac ? e . isMetaDown ( ) : e . isControlDown ( ) ) & & ! e . isPopupTrigger ( ) ;
& & ( SystemInfo . isMac ? e . isMetaDown ( ) : e . isControlDown ( ) ) & & ! e . isPopupTrigger ( ) ;
}
}
@Override
public void propertyChange ( final PropertyChangeEvent evt ) {
String key = evt . getPropertyName ( ) ;
if ( STRIPED_CLIENT_PROPERTY . equals ( key ) ) {
tree . repaint ( ) ;
} else if ( "JTree.renderBooleanAsCheckBox" . equals ( key ) ) {
tree . repaint ( ) ;
} else if ( "JTree.booleanRenderType" . equals ( key ) ) {
tree . repaint ( ) ;
} else if ( "JTree.lineStyle" . equals ( key ) ) {
tree . repaint ( ) ;
}
}
private abstract static class TreeUIAction extends AbstractAction implements UIResource {
private abstract static class TreeUIAction extends AbstractAction implements UIResource {
}
}
}
}