home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.ComponentListener;
- import java.awt.event.FocusListener;
- import java.awt.event.InputEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.beans.PropertyChangeListener;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import javax.swing.ActionMap;
- import javax.swing.CellRendererPane;
- import javax.swing.Icon;
- import javax.swing.InputMap;
- import javax.swing.JComponent;
- import javax.swing.JTree;
- import javax.swing.SwingUtilities;
- import javax.swing.UIManager;
- import javax.swing.event.CellEditorListener;
- import javax.swing.event.TreeExpansionListener;
- import javax.swing.event.TreeModelListener;
- import javax.swing.event.TreeSelectionListener;
- import javax.swing.plaf.ActionMapUIResource;
- import javax.swing.plaf.ComponentUI;
- import javax.swing.plaf.TreeUI;
- import javax.swing.plaf.UIResource;
- import javax.swing.tree.AbstractLayoutCache;
- import javax.swing.tree.DefaultTreeCellEditor;
- import javax.swing.tree.DefaultTreeCellRenderer;
- import javax.swing.tree.FixedHeightLayoutCache;
- import javax.swing.tree.TreeCellEditor;
- import javax.swing.tree.TreeCellRenderer;
- import javax.swing.tree.TreeModel;
- import javax.swing.tree.TreePath;
- import javax.swing.tree.TreeSelectionModel;
- import javax.swing.tree.VariableHeightLayoutCache;
-
- public class BasicTreeUI extends TreeUI {
- private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
- protected transient Icon collapsedIcon;
- protected transient Icon expandedIcon;
- private Color hashColor;
- protected int leftChildIndent;
- protected int rightChildIndent;
- protected int totalChildIndent;
- protected Dimension preferredMinSize;
- protected int lastSelectedRow;
- protected JTree tree;
- protected transient TreeCellRenderer currentCellRenderer;
- protected boolean createdRenderer;
- protected transient TreeCellEditor cellEditor;
- protected boolean createdCellEditor;
- protected boolean stopEditingInCompleteEditing;
- protected CellRendererPane rendererPane;
- protected Dimension preferredSize;
- protected boolean validCachedPreferredSize;
- protected AbstractLayoutCache treeState;
- protected Hashtable drawingCache;
- protected boolean largeModel;
- protected AbstractLayoutCache.NodeDimensions nodeDimensions;
- protected TreeModel treeModel;
- protected TreeSelectionModel treeSelectionModel;
- protected int depthOffset;
- private int lastWidth;
- protected Component editingComponent;
- protected TreePath editingPath;
- protected int editingRow;
- protected boolean editorHasDifferentSize;
- private int leadRow;
- private boolean ignoreLAChange;
- private boolean leftToRight;
- private PropertyChangeListener propertyChangeListener;
- private PropertyChangeListener selectionModelPropertyChangeListener;
- private MouseListener mouseListener;
- private FocusListener focusListener;
- private KeyListener keyListener;
- private ComponentListener componentListener;
- private CellEditorListener cellEditorListener;
- private TreeSelectionListener treeSelectionListener;
- private TreeModelListener treeModelListener;
- private TreeExpansionListener treeExpansionListener;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicTreeUI();
- }
-
- protected Color getHashColor() {
- return this.hashColor;
- }
-
- protected void setHashColor(Color var1) {
- this.hashColor = var1;
- }
-
- public void setLeftChildIndent(int var1) {
- this.leftChildIndent = var1;
- this.totalChildIndent = this.leftChildIndent + this.rightChildIndent;
- if (this.treeState != null) {
- this.treeState.invalidateSizes();
- }
-
- this.updateSize();
- }
-
- public int getLeftChildIndent() {
- return this.leftChildIndent;
- }
-
- public void setRightChildIndent(int var1) {
- this.rightChildIndent = var1;
- this.totalChildIndent = this.leftChildIndent + this.rightChildIndent;
- if (this.treeState != null) {
- this.treeState.invalidateSizes();
- }
-
- this.updateSize();
- }
-
- public int getRightChildIndent() {
- return this.rightChildIndent;
- }
-
- public void setExpandedIcon(Icon var1) {
- this.expandedIcon = var1;
- }
-
- public Icon getExpandedIcon() {
- return this.expandedIcon;
- }
-
- public void setCollapsedIcon(Icon var1) {
- this.collapsedIcon = var1;
- }
-
- public Icon getCollapsedIcon() {
- return this.collapsedIcon;
- }
-
- protected void setLargeModel(boolean var1) {
- if (this.getRowHeight() < 1) {
- var1 = false;
- }
-
- if (this.largeModel != var1) {
- this.completeEditing();
- this.largeModel = var1;
- this.treeState = this.createLayoutCache();
- this.configureLayoutCache();
- this.updateLayoutCacheExpandedNodes();
- this.updateSize();
- }
-
- }
-
- protected boolean isLargeModel() {
- return this.largeModel;
- }
-
- protected void setRowHeight(int var1) {
- this.completeEditing();
- if (this.treeState != null) {
- this.setLargeModel(this.tree.isLargeModel());
- this.treeState.setRowHeight(var1);
- this.updateSize();
- }
-
- }
-
- protected int getRowHeight() {
- return this.tree == null ? -1 : this.tree.getRowHeight();
- }
-
- protected void setCellRenderer(TreeCellRenderer var1) {
- this.completeEditing();
- this.updateRenderer();
- if (this.treeState != null) {
- this.treeState.invalidateSizes();
- this.updateSize();
- }
-
- }
-
- protected TreeCellRenderer getCellRenderer() {
- return this.currentCellRenderer;
- }
-
- protected void setModel(TreeModel var1) {
- this.completeEditing();
- if (this.treeModel != null && this.treeModelListener != null) {
- this.treeModel.removeTreeModelListener(this.treeModelListener);
- }
-
- this.treeModel = var1;
- if (this.treeModel != null && this.treeModelListener != null) {
- this.treeModel.addTreeModelListener(this.treeModelListener);
- }
-
- if (this.treeState != null) {
- this.treeState.setModel(var1);
- this.updateLayoutCacheExpandedNodes();
- this.updateSize();
- }
-
- }
-
- protected TreeModel getModel() {
- return this.treeModel;
- }
-
- protected void setRootVisible(boolean var1) {
- this.completeEditing();
- this.updateDepthOffset();
- if (this.treeState != null) {
- this.treeState.setRootVisible(var1);
- this.treeState.invalidateSizes();
- this.updateSize();
- }
-
- }
-
- protected boolean isRootVisible() {
- return this.tree != null ? this.tree.isRootVisible() : false;
- }
-
- protected void setShowsRootHandles(boolean var1) {
- this.completeEditing();
- this.updateDepthOffset();
- if (this.treeState != null) {
- this.treeState.invalidateSizes();
- this.updateSize();
- }
-
- }
-
- protected boolean getShowsRootHandles() {
- return this.tree != null ? this.tree.getShowsRootHandles() : false;
- }
-
- protected void setCellEditor(TreeCellEditor var1) {
- this.updateCellEditor();
- }
-
- protected TreeCellEditor getCellEditor() {
- return this.tree != null ? this.tree.getCellEditor() : null;
- }
-
- protected void setEditable(boolean var1) {
- this.updateCellEditor();
- }
-
- protected boolean isEditable() {
- return this.tree != null ? this.tree.isEditable() : false;
- }
-
- protected void setSelectionModel(TreeSelectionModel var1) {
- this.completeEditing();
- if (this.selectionModelPropertyChangeListener != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.removePropertyChangeListener(this.selectionModelPropertyChangeListener);
- }
-
- if (this.treeSelectionListener != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.removeTreeSelectionListener(this.treeSelectionListener);
- }
-
- this.treeSelectionModel = var1;
- if (this.treeSelectionModel != null) {
- if (this.selectionModelPropertyChangeListener != null) {
- this.treeSelectionModel.addPropertyChangeListener(this.selectionModelPropertyChangeListener);
- }
-
- if (this.treeSelectionListener != null) {
- this.treeSelectionModel.addTreeSelectionListener(this.treeSelectionListener);
- }
-
- if (this.treeState != null) {
- this.treeState.setSelectionModel(this.treeSelectionModel);
- }
- } else if (this.treeState != null) {
- this.treeState.setSelectionModel((TreeSelectionModel)null);
- }
-
- if (this.tree != null) {
- this.tree.repaint();
- }
-
- }
-
- protected TreeSelectionModel getSelectionModel() {
- return this.treeSelectionModel;
- }
-
- public Rectangle getPathBounds(JTree var1, TreePath var2) {
- if (var1 != null && this.treeState != null) {
- Insets var3 = ((JComponent)var1).getInsets();
- Rectangle var4 = this.treeState.getBounds(var2, (Rectangle)null);
- if (var4 != null && var3 != null) {
- var4.x += var3.left;
- var4.y += var3.top;
- }
-
- return var4;
- } else {
- return null;
- }
- }
-
- public TreePath getPathForRow(JTree var1, int var2) {
- return this.treeState != null ? this.treeState.getPathForRow(var2) : null;
- }
-
- public int getRowForPath(JTree var1, TreePath var2) {
- return this.treeState != null ? this.treeState.getRowForPath(var2) : -1;
- }
-
- public int getRowCount(JTree var1) {
- return this.treeState != null ? this.treeState.getRowCount() : 0;
- }
-
- public TreePath getClosestPathForLocation(JTree var1, int var2, int var3) {
- if (var1 != null && this.treeState != null) {
- Insets var4 = ((JComponent)var1).getInsets();
- if (var4 == null) {
- var4 = EMPTY_INSETS;
- }
-
- return this.treeState.getPathClosestTo(var2 - var4.left, var3 - var4.top);
- } else {
- return null;
- }
- }
-
- public boolean isEditing(JTree var1) {
- return this.editingComponent != null;
- }
-
- public boolean stopEditing(JTree var1) {
- if (this.editingComponent != null && this.cellEditor.stopCellEditing()) {
- this.completeEditing(false, false, true);
- return true;
- } else {
- return false;
- }
- }
-
- public void cancelEditing(JTree var1) {
- if (this.editingComponent != null) {
- this.completeEditing(false, true, false);
- }
-
- }
-
- public void startEditingAtPath(JTree var1, TreePath var2) {
- var1.scrollPathToVisible(var2);
- if (var2 != null && var1.isVisible(var2)) {
- this.startEditing(var2, (MouseEvent)null);
- }
-
- }
-
- public TreePath getEditingPath(JTree var1) {
- return this.editingPath;
- }
-
- public void installUI(JComponent var1) {
- if (var1 == null) {
- throw new NullPointerException("null component passed to BasicTreeUI.installUI()");
- } else {
- this.tree = (JTree)var1;
- this.prepareForUIInstall();
- this.installDefaults();
- this.installListeners();
- this.installKeyboardActions();
- this.installComponents();
- this.completeUIInstall();
- }
- }
-
- protected void prepareForUIInstall() {
- this.drawingCache = new Hashtable(7);
- this.leftToRight = BasicGraphicsUtils.isLeftToRight(this.tree);
- this.lastWidth = this.tree.getWidth();
- this.stopEditingInCompleteEditing = true;
- this.lastSelectedRow = -1;
- this.leadRow = -1;
- this.preferredSize = new Dimension();
- this.tree.setRowHeight(UIManager.getInt("Tree.rowHeight"));
- Object var1 = UIManager.get("Tree.scrollsOnExpand");
- if (var1 != null) {
- this.tree.setScrollsOnExpand((Boolean)var1);
- }
-
- this.largeModel = this.tree.isLargeModel();
- if (this.getRowHeight() <= 0) {
- this.largeModel = false;
- }
-
- this.setModel(this.tree.getModel());
- }
-
- protected void completeUIInstall() {
- this.setShowsRootHandles(this.tree.getShowsRootHandles());
- this.updateRenderer();
- this.updateDepthOffset();
- this.setSelectionModel(this.tree.getSelectionModel());
- this.treeState = this.createLayoutCache();
- this.configureLayoutCache();
- this.updateSize();
- }
-
- protected void installDefaults() {
- if (this.tree.getBackground() == null || this.tree.getBackground() instanceof UIResource) {
- this.tree.setBackground(UIManager.getColor("Tree.background"));
- }
-
- if (this.getHashColor() == null || this.getHashColor() instanceof UIResource) {
- this.setHashColor(UIManager.getColor("Tree.hash"));
- }
-
- if (this.tree.getFont() == null || this.tree.getFont() instanceof UIResource) {
- this.tree.setFont(UIManager.getFont("Tree.font"));
- }
-
- this.setExpandedIcon((Icon)UIManager.get("Tree.expandedIcon"));
- this.setCollapsedIcon((Icon)UIManager.get("Tree.collapsedIcon"));
- this.setLeftChildIndent((Integer)UIManager.get("Tree.leftChildIndent"));
- this.setRightChildIndent((Integer)UIManager.get("Tree.rightChildIndent"));
- }
-
- protected void installListeners() {
- if ((this.propertyChangeListener = this.createPropertyChangeListener()) != null) {
- this.tree.addPropertyChangeListener(this.propertyChangeListener);
- }
-
- if ((this.mouseListener = this.createMouseListener()) != null) {
- this.tree.addMouseListener(this.mouseListener);
- }
-
- if ((this.focusListener = this.createFocusListener()) != null) {
- this.tree.addFocusListener(this.focusListener);
- }
-
- if ((this.keyListener = this.createKeyListener()) != null) {
- this.tree.addKeyListener(this.keyListener);
- }
-
- if ((this.treeExpansionListener = this.createTreeExpansionListener()) != null) {
- this.tree.addTreeExpansionListener(this.treeExpansionListener);
- }
-
- if ((this.treeModelListener = this.createTreeModelListener()) != null && this.treeModel != null) {
- this.treeModel.addTreeModelListener(this.treeModelListener);
- }
-
- if ((this.selectionModelPropertyChangeListener = this.createSelectionModelPropertyChangeListener()) != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.addPropertyChangeListener(this.selectionModelPropertyChangeListener);
- }
-
- if ((this.treeSelectionListener = this.createTreeSelectionListener()) != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.addTreeSelectionListener(this.treeSelectionListener);
- }
-
- }
-
- protected void installKeyboardActions() {
- InputMap var1 = this.getInputMap(1);
- SwingUtilities.replaceUIInputMap(this.tree, 1, var1);
- var1 = this.getInputMap(0);
- SwingUtilities.replaceUIInputMap(this.tree, 0, var1);
- ActionMap var2 = this.getActionMap();
- SwingUtilities.replaceUIActionMap(this.tree, var2);
- }
-
- InputMap getInputMap(int var1) {
- if (var1 == 1) {
- return (InputMap)UIManager.get("Tree.ancestorInputMap");
- } else {
- return var1 == 0 ? (InputMap)UIManager.get("Tree.focusInputMap") : null;
- }
- }
-
- ActionMap getActionMap() {
- return this.createActionMap();
- }
-
- ActionMap createActionMap() {
- ActionMapUIResource var1 = new ActionMapUIResource();
- ((ActionMap)var1).put("selectPrevious", new TreeIncrementAction(this, -1, "selectPrevious", false, true, (1)null));
- ((ActionMap)var1).put("selectPreviousChangeLead", new TreeIncrementAction(this, -1, "selectPreviousLead", false, false, (1)null));
- ((ActionMap)var1).put("selectPreviousExtendSelection", new TreeIncrementAction(this, -1, "selectPreviousExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("selectNext", new TreeIncrementAction(this, 1, "selectNext", false, true, (1)null));
- ((ActionMap)var1).put("selectNextChangeLead", new TreeIncrementAction(this, 1, "selectNextLead", false, false, (1)null));
- ((ActionMap)var1).put("selectNextExtendSelection", new TreeIncrementAction(this, 1, "selectNextExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("selectChild", new TreeTraverseAction(this, 1, "selectChild", true, (1)null));
- ((ActionMap)var1).put("selectChildChangeLead", new TreeTraverseAction(this, 1, "selectChildLead", false, (1)null));
- ((ActionMap)var1).put("selectParent", new TreeTraverseAction(this, -1, "selectParent", true, (1)null));
- ((ActionMap)var1).put("selectParentChangeLead", new TreeTraverseAction(this, -1, "selectParentLead", false, (1)null));
- ((ActionMap)var1).put("scrollUpChangeSelection", new TreePageAction(this, -1, "scrollUpChangeSelection", false, true, (1)null));
- ((ActionMap)var1).put("scrollUpChangeLead", new TreePageAction(this, -1, "scrollUpChangeLead", false, false, (1)null));
- ((ActionMap)var1).put("scrollUpExtendSelection", new TreePageAction(this, -1, "scrollUpExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("scrollDownChangeSelection", new TreePageAction(this, 1, "scrollDownChangeSelection", false, true, (1)null));
- ((ActionMap)var1).put("scrollDownExtendSelection", new TreePageAction(this, 1, "scrollDownExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("scrollDownChangeLead", new TreePageAction(this, 1, "scrollDownChangeLead", false, false, (1)null));
- ((ActionMap)var1).put("selectFirst", new TreeHomeAction(this, -1, "selectFirst", false, true, (1)null));
- ((ActionMap)var1).put("selectFirstChangeLead", new TreeHomeAction(this, -1, "selectFirst", false, false, (1)null));
- ((ActionMap)var1).put("selectFirstExtendSelection", new TreeHomeAction(this, -1, "selectFirstExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("selectLast", new TreeHomeAction(this, 1, "selectLast", false, true, (1)null));
- ((ActionMap)var1).put("selectLastChangeLead", new TreeHomeAction(this, 1, "selectLast", false, false, (1)null));
- ((ActionMap)var1).put("selectLastExtendSelection", new TreeHomeAction(this, 1, "selectLastExtendSelection", true, true, (1)null));
- ((ActionMap)var1).put("toggle", new TreeToggleAction(this, "toggle"));
- ((ActionMap)var1).put("cancel", new TreeCancelEditingAction(this, "cancel"));
- ((ActionMap)var1).put("startEditing", new TreeEditAction(this, "startEditing"));
- ((ActionMap)var1).put("selectAll", new TreeSelectAllAction(this, "selectAll", true));
- ((ActionMap)var1).put("clearSelection", new TreeSelectAllAction(this, "clearSelection", false));
- ((ActionMap)var1).put("toggleSelectionPreserveAnchor", new TreeAddSelectionAction(this, "toggleSelectionPreserveAnchor", false));
- ((ActionMap)var1).put("toggleSelection", new TreeAddSelectionAction(this, "toggleSelection", true));
- ((ActionMap)var1).put("extendSelection", new TreeExtendSelectionAction(this, "extendSelection"));
- ((ActionMap)var1).put("scrollLeft", new ScrollAction(this.tree, 0, -10));
- ((ActionMap)var1).put("scrollLeftExtendSelection", new TreeScrollLRAction(this, -1, "scrollLeftExtendSelection", true, true));
- ((ActionMap)var1).put("scrollRight", new ScrollAction(this.tree, 0, 10));
- ((ActionMap)var1).put("scrollRightExtendSelection", new TreeScrollLRAction(this, 1, "scrollRightExtendSelection", true, true));
- ((ActionMap)var1).put("scrollRightChangeLead", new TreeScrollLRAction(this, 1, "scrollRightChangeLead", false, false));
- ((ActionMap)var1).put("scrollLeftChangeLead", new TreeScrollLRAction(this, -1, "scrollLeftChangeLead", false, false));
- return var1;
- }
-
- protected void installComponents() {
- if ((this.rendererPane = this.createCellRendererPane()) != null) {
- this.tree.add(this.rendererPane);
- }
-
- }
-
- protected AbstractLayoutCache.NodeDimensions createNodeDimensions() {
- return new NodeDimensionsHandler(this);
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return new PropertyChangeHandler(this);
- }
-
- protected MouseListener createMouseListener() {
- return new MouseHandler(this);
- }
-
- protected FocusListener createFocusListener() {
- return new FocusHandler(this);
- }
-
- protected KeyListener createKeyListener() {
- return new KeyHandler(this);
- }
-
- protected PropertyChangeListener createSelectionModelPropertyChangeListener() {
- return new SelectionModelPropertyChangeHandler(this);
- }
-
- protected TreeSelectionListener createTreeSelectionListener() {
- return new TreeSelectionHandler(this);
- }
-
- protected CellEditorListener createCellEditorListener() {
- return new CellEditorHandler(this);
- }
-
- protected ComponentListener createComponentListener() {
- return new ComponentHandler(this);
- }
-
- protected TreeExpansionListener createTreeExpansionListener() {
- return new TreeExpansionHandler(this);
- }
-
- protected AbstractLayoutCache createLayoutCache() {
- return (AbstractLayoutCache)(this.isLargeModel() && this.getRowHeight() > 0 ? new FixedHeightLayoutCache() : new VariableHeightLayoutCache());
- }
-
- protected CellRendererPane createCellRendererPane() {
- return new CellRendererPane();
- }
-
- protected TreeCellEditor createDefaultCellEditor() {
- if (this.currentCellRenderer != null && this.currentCellRenderer instanceof DefaultTreeCellRenderer) {
- DefaultTreeCellEditor var1 = new DefaultTreeCellEditor(this.tree, (DefaultTreeCellRenderer)this.currentCellRenderer);
- return var1;
- } else {
- return new DefaultTreeCellEditor(this.tree, (DefaultTreeCellRenderer)null);
- }
- }
-
- protected TreeCellRenderer createDefaultCellRenderer() {
- return new DefaultTreeCellRenderer();
- }
-
- protected TreeModelListener createTreeModelListener() {
- return new TreeModelHandler(this);
- }
-
- public void uninstallUI(JComponent var1) {
- this.completeEditing();
- this.prepareForUIUninstall();
- this.uninstallDefaults();
- this.uninstallListeners();
- this.uninstallKeyboardActions();
- this.uninstallComponents();
- this.completeUIUninstall();
- }
-
- protected void prepareForUIUninstall() {
- }
-
- protected void completeUIUninstall() {
- if (this.createdRenderer) {
- this.tree.setCellRenderer((TreeCellRenderer)null);
- }
-
- if (this.createdCellEditor) {
- this.tree.setCellEditor((TreeCellEditor)null);
- }
-
- this.cellEditor = null;
- this.currentCellRenderer = null;
- this.rendererPane = null;
- this.componentListener = null;
- this.propertyChangeListener = null;
- this.mouseListener = null;
- this.focusListener = null;
- this.keyListener = null;
- this.setSelectionModel((TreeSelectionModel)null);
- this.treeState = null;
- this.drawingCache = null;
- this.selectionModelPropertyChangeListener = null;
- this.tree = null;
- this.treeModel = null;
- this.treeSelectionModel = null;
- this.treeSelectionListener = null;
- this.treeExpansionListener = null;
- }
-
- protected void uninstallDefaults() {
- }
-
- protected void uninstallListeners() {
- if (this.componentListener != null) {
- this.tree.removeComponentListener(this.componentListener);
- }
-
- if (this.propertyChangeListener != null) {
- this.tree.removePropertyChangeListener(this.propertyChangeListener);
- }
-
- if (this.mouseListener != null) {
- this.tree.removeMouseListener(this.mouseListener);
- }
-
- if (this.focusListener != null) {
- this.tree.removeFocusListener(this.focusListener);
- }
-
- if (this.keyListener != null) {
- this.tree.removeKeyListener(this.keyListener);
- }
-
- if (this.treeExpansionListener != null) {
- this.tree.removeTreeExpansionListener(this.treeExpansionListener);
- }
-
- if (this.treeModel != null && this.treeModelListener != null) {
- this.treeModel.removeTreeModelListener(this.treeModelListener);
- }
-
- if (this.selectionModelPropertyChangeListener != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.removePropertyChangeListener(this.selectionModelPropertyChangeListener);
- }
-
- if (this.treeSelectionListener != null && this.treeSelectionModel != null) {
- this.treeSelectionModel.removeTreeSelectionListener(this.treeSelectionListener);
- }
-
- }
-
- protected void uninstallKeyboardActions() {
- SwingUtilities.replaceUIActionMap(this.tree, (ActionMap)null);
- SwingUtilities.replaceUIInputMap(this.tree, 1, (InputMap)null);
- SwingUtilities.replaceUIInputMap(this.tree, 0, (InputMap)null);
- }
-
- protected void uninstallComponents() {
- if (this.rendererPane != null) {
- this.tree.remove(this.rendererPane);
- }
-
- }
-
- private void redoTheLayout() {
- if (this.treeState != null) {
- this.treeState.invalidateSizes();
- }
-
- }
-
- public void paint(Graphics var1, JComponent var2) {
- if (this.tree != var2) {
- throw new InternalError("incorrect component");
- } else if (this.treeState != null) {
- int var3 = this.tree.getWidth();
- if (var3 != this.lastWidth) {
- this.lastWidth = var3;
- if (!this.leftToRight) {
- this.redoTheLayout();
- this.updateSize();
- }
- }
-
- Rectangle var4 = var1.getClipBounds();
- Insets var5 = this.tree.getInsets();
- if (var5 == null) {
- var5 = EMPTY_INSETS;
- }
-
- TreePath var6 = this.getClosestPathForLocation(this.tree, 0, var4.y);
- Enumeration var7 = this.treeState.getVisiblePathsFrom(var6);
- int var8 = this.treeState.getRowForPath(var6);
- int var9 = var4.y + var4.height;
- this.drawingCache.clear();
- if (var6 != null && var7 != null) {
- for(TreePath var10 = var6.getParentPath(); var10 != null; var10 = var10.getParentPath()) {
- this.paintVerticalPartOfLeg(var1, var4, var5, var10);
- this.drawingCache.put(var10, Boolean.TRUE);
- }
-
- boolean var11 = false;
- Rectangle var15 = new Rectangle();
-
- for(boolean var18 = this.isRootVisible(); !var11 && var7.hasMoreElements(); ++var8) {
- TreePath var17 = (TreePath)var7.nextElement();
- if (var17 != null) {
- boolean var14 = this.treeModel.isLeaf(var17.getLastPathComponent());
- boolean var12;
- boolean var13;
- if (var14) {
- var13 = false;
- var12 = false;
- } else {
- var12 = this.treeState.getExpandedState(var17);
- var13 = this.tree.hasBeenExpanded(var17);
- }
-
- Rectangle var16 = this.treeState.getBounds(var17, var15);
- if (var16 == null) {
- return;
- }
-
- var16.x += var5.left;
- var16.y += var5.top;
- TreePath var19 = var17.getParentPath();
- if (var19 != null) {
- if (this.drawingCache.get(var19) == null) {
- this.paintVerticalPartOfLeg(var1, var4, var5, var19);
- this.drawingCache.put(var19, Boolean.TRUE);
- }
-
- this.paintHorizontalPartOfLeg(var1, var4, var5, var16, var17, var8, var12, var13, var14);
- } else if (var18 && var8 == 0) {
- this.paintHorizontalPartOfLeg(var1, var4, var5, var16, var17, var8, var12, var13, var14);
- }
-
- if (this.shouldPaintExpandControl(var17, var8, var12, var13, var14)) {
- this.paintExpandControl(var1, var4, var5, var16, var17, var8, var12, var13, var14);
- }
-
- if (!this.leftToRight) {
- var16.x += 4;
- }
-
- this.paintRow(var1, var4, var5, var16, var17, var8, var12, var13, var14);
- if (var16.y + var16.height >= var9) {
- var11 = true;
- }
- } else {
- var11 = true;
- }
- }
- }
-
- this.rendererPane.removeAll();
- }
- }
-
- protected void paintHorizontalPartOfLeg(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
- int var10 = var2.x;
- int var11 = var2.x + (var2.width - 1);
- int var12 = var2.y;
- int var13 = var2.y + (var2.height - 1);
- int var14 = var4.y + var4.height / 2;
- if (this.leftToRight) {
- int var15 = var4.x - this.getRightChildIndent();
- int var16 = var4.x - this.getHorizontalLegBuffer();
- if (var14 > var12 && var14 < var13 && var16 > var10 && var15 < var11) {
- var15 = Math.max(var15, var10);
- var16 = Math.min(var16, var11);
- var1.setColor(this.getHashColor());
- this.paintHorizontalLine(var1, this.tree, var14, var15, var16);
- }
- } else {
- int var18 = var4.x + var4.width + this.getRightChildIndent();
- int var21 = var4.x + var4.width + this.getHorizontalLegBuffer() - 1;
- if (var14 > var12 && var14 < var13 && var18 > var10 && var21 < var11) {
- var18 = Math.min(var18, var11);
- var21 = Math.max(var21, var10);
- var1.setColor(this.getHashColor());
- this.paintHorizontalLine(var1, this.tree, var14, var21, var18);
- }
- }
-
- }
-
- protected void paintVerticalPartOfLeg(Graphics var1, Rectangle var2, Insets var3, TreePath var4) {
- int var5;
- if (this.leftToRight) {
- var5 = (var4.getPathCount() + this.depthOffset) * this.totalChildIndent - this.getRightChildIndent() + var3.left;
- } else {
- var5 = this.lastWidth - (var4.getPathCount() - 1 + this.depthOffset) * this.totalChildIndent - 9;
- }
-
- int var6 = var2.x;
- int var7 = var2.x + (var2.width - 1);
- if (var5 > var6 && var5 < var7) {
- int var8 = var2.y;
- int var9 = var2.y + var2.height;
- Rectangle var10 = this.getPathBounds(this.tree, var4);
- Rectangle var11 = this.getPathBounds(this.tree, this.getLastChildPath(var4));
- if (var11 == null) {
- return;
- }
-
- int var12;
- if (var10 == null) {
- var12 = Math.max(var3.top + this.getVerticalLegBuffer(), var8);
- } else {
- var12 = Math.max(var10.y + var10.height + this.getVerticalLegBuffer(), var8);
- }
-
- if (var4.getPathCount() == 1 && !this.isRootVisible()) {
- TreeModel var13 = this.getModel();
- if (var13 != null) {
- Object var14 = var13.getRoot();
- if (var13.getChildCount(var14) > 0) {
- var10 = this.getPathBounds(this.tree, var4.pathByAddingChild(var13.getChild(var14, 0)));
- if (var10 != null) {
- var12 = Math.max(var3.top + this.getVerticalLegBuffer(), var10.y + var10.height / 2);
- }
- }
- }
- }
-
- int var16 = Math.min(var11.y + var11.height / 2, var9);
- var1.setColor(this.getHashColor());
- this.paintVerticalLine(var1, this.tree, var5, var12, var16);
- }
-
- }
-
- protected void paintExpandControl(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
- Object var10 = var5.getLastPathComponent();
- if (!var9 && (!var8 || this.treeModel.getChildCount(var10) > 0)) {
- int var11;
- if (this.leftToRight) {
- var11 = var4.x - (this.getRightChildIndent() - 1);
- } else {
- var11 = var4.x + var4.width + this.getRightChildIndent();
- }
-
- int var12 = var4.y + var4.height / 2;
- if (var7) {
- Icon var13 = this.getExpandedIcon();
- if (var13 != null) {
- this.drawCentered(this.tree, var1, var13, var11, var12);
- }
- } else {
- Icon var14 = this.getCollapsedIcon();
- if (var14 != null) {
- this.drawCentered(this.tree, var1, var14, var11, var12);
- }
- }
- }
-
- }
-
- protected void paintRow(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
- if (this.editingComponent == null || this.editingRow != var6) {
- int var10;
- if (this.tree.hasFocus()) {
- var10 = this.getLeadSelectionRow();
- } else {
- var10 = -1;
- }
-
- Component var11 = this.currentCellRenderer.getTreeCellRendererComponent(this.tree, var5.getLastPathComponent(), this.tree.isRowSelected(var6), var7, var9, var6, var10 == var6);
- this.rendererPane.paintComponent(var1, var11, this.tree, var4.x, var4.y, var4.width, var4.height, true);
- }
- }
-
- protected boolean shouldPaintExpandControl(TreePath var1, int var2, boolean var3, boolean var4, boolean var5) {
- if (var5) {
- return false;
- } else {
- int var6 = var1.getPathCount() - 1;
- return var6 != 0 && (var6 != 1 || this.isRootVisible()) || this.getShowsRootHandles();
- }
- }
-
- protected void paintVerticalLine(Graphics var1, JComponent var2, int var3, int var4, int var5) {
- var1.drawLine(var3, var4, var3, var5);
- }
-
- protected void paintHorizontalLine(Graphics var1, JComponent var2, int var3, int var4, int var5) {
- var1.drawLine(var4, var3, var5, var3);
- }
-
- protected int getVerticalLegBuffer() {
- return 0;
- }
-
- protected int getHorizontalLegBuffer() {
- return 0;
- }
-
- protected void drawCentered(Component var1, Graphics var2, Icon var3, int var4, int var5) {
- var3.paintIcon(var1, var2, var4 - var3.getIconWidth() / 2, var5 - var3.getIconHeight() / 2);
- }
-
- protected void drawDashedHorizontalLine(Graphics var1, int var2, int var3, int var4) {
- var3 += var3 % 2;
-
- for(int var5 = var3; var5 <= var4; var5 += 2) {
- var1.drawLine(var5, var2, var5, var2);
- }
-
- }
-
- protected void drawDashedVerticalLine(Graphics var1, int var2, int var3, int var4) {
- var3 += var3 % 2;
-
- for(int var5 = var3; var5 <= var4; var5 += 2) {
- var1.drawLine(var2, var5, var2, var5);
- }
-
- }
-
- protected void updateLayoutCacheExpandedNodes() {
- if (this.treeModel != null) {
- this.updateExpandedDescendants(new TreePath(this.treeModel.getRoot()));
- }
-
- }
-
- protected void updateExpandedDescendants(TreePath var1) {
- this.completeEditing();
- if (this.treeState != null) {
- this.treeState.setExpandedState(var1, true);
- Enumeration var2 = this.tree.getExpandedDescendants(var1);
- if (var2 != null) {
- while(var2.hasMoreElements()) {
- var1 = (TreePath)var2.nextElement();
- this.treeState.setExpandedState(var1, true);
- }
- }
-
- this.updateLeadRow();
- this.updateSize();
- }
-
- }
-
- protected TreePath getLastChildPath(TreePath var1) {
- if (this.treeModel != null) {
- int var2 = this.treeModel.getChildCount(var1.getLastPathComponent());
- if (var2 > 0) {
- return var1.pathByAddingChild(this.treeModel.getChild(var1.getLastPathComponent(), var2 - 1));
- }
- }
-
- return null;
- }
-
- protected void updateDepthOffset() {
- if (this.isRootVisible()) {
- if (this.getShowsRootHandles()) {
- this.depthOffset = 1;
- } else {
- this.depthOffset = 0;
- }
- } else if (!this.getShowsRootHandles()) {
- this.depthOffset = -1;
- } else {
- this.depthOffset = 0;
- }
-
- }
-
- protected void updateCellEditor() {
- this.completeEditing();
- TreeCellEditor var1;
- if (this.tree == null) {
- var1 = null;
- } else if (this.tree.isEditable()) {
- var1 = this.tree.getCellEditor();
- if (var1 == null) {
- var1 = this.createDefaultCellEditor();
- if (var1 != null) {
- this.tree.setCellEditor(var1);
- this.createdCellEditor = true;
- }
- }
- } else {
- var1 = null;
- }
-
- if (var1 != this.cellEditor) {
- if (this.cellEditor != null && this.cellEditorListener != null) {
- this.cellEditor.removeCellEditorListener(this.cellEditorListener);
- }
-
- this.cellEditor = var1;
- if (this.cellEditorListener == null) {
- this.cellEditorListener = this.createCellEditorListener();
- }
-
- if (var1 != null && this.cellEditorListener != null) {
- var1.addCellEditorListener(this.cellEditorListener);
- }
-
- this.createdCellEditor = false;
- }
-
- }
-
- protected void updateRenderer() {
- if (this.tree != null) {
- TreeCellRenderer var1 = this.tree.getCellRenderer();
- if (var1 == null) {
- this.tree.setCellRenderer(this.createDefaultCellRenderer());
- this.createdRenderer = true;
- } else {
- this.createdRenderer = false;
- this.currentCellRenderer = var1;
- if (this.createdCellEditor) {
- this.tree.setCellEditor((TreeCellEditor)null);
- }
- }
- } else {
- this.createdRenderer = false;
- this.currentCellRenderer = null;
- }
-
- this.updateCellEditor();
- }
-
- protected void configureLayoutCache() {
- if (this.treeState != null && this.tree != null) {
- if (this.nodeDimensions == null) {
- this.nodeDimensions = this.createNodeDimensions();
- }
-
- this.treeState.setNodeDimensions(this.nodeDimensions);
- this.treeState.setRootVisible(this.tree.isRootVisible());
- this.treeState.setRowHeight(this.tree.getRowHeight());
- this.treeState.setSelectionModel(this.getSelectionModel());
- if (this.treeState.getModel() != this.tree.getModel()) {
- this.treeState.setModel(this.tree.getModel());
- }
-
- this.updateLayoutCacheExpandedNodes();
- if (this.isLargeModel()) {
- if (this.componentListener == null) {
- this.componentListener = this.createComponentListener();
- if (this.componentListener != null) {
- this.tree.addComponentListener(this.componentListener);
- }
- }
- } else if (this.componentListener != null) {
- this.tree.removeComponentListener(this.componentListener);
- this.componentListener = null;
- }
- } else if (this.componentListener != null) {
- this.tree.removeComponentListener(this.componentListener);
- this.componentListener = null;
- }
-
- }
-
- protected void updateSize() {
- this.validCachedPreferredSize = false;
- this.tree.treeDidChange();
- }
-
- protected void updateCachedPreferredSize() {
- if (this.treeState != null) {
- Insets var1 = this.tree.getInsets();
- if (this.isLargeModel()) {
- Rectangle var6 = this.tree.getVisibleRect();
- if (var1 != null) {
- var6.x -= var1.left;
- var6.y -= var1.top;
- }
-
- if (this.leftToRight) {
- this.preferredSize.width = this.treeState.getPreferredWidth(var6);
- } else if (this.getRowCount(this.tree) == 0) {
- this.preferredSize.width = 0;
- } else {
- this.preferredSize.width = this.lastWidth - this.getMinX(var6);
- }
- } else if (this.leftToRight) {
- this.preferredSize.width = this.treeState.getPreferredWidth((Rectangle)null);
- } else {
- Rectangle var2 = null;
- int var3 = this.tree.getRowCount();
- int var4 = 0;
-
- for(int var5 = 0; var5 < var3; ++var5) {
- var2 = this.treeState.getBounds(this.treeState.getPathForRow(var5), var2);
- if (var2 != null) {
- var4 = Math.max(this.lastWidth - var2.x, var4);
- }
- }
-
- this.preferredSize.width = var4;
- }
-
- this.preferredSize.height = this.treeState.getPreferredHeight();
- if (var1 != null) {
- Dimension var10000 = this.preferredSize;
- var10000.width += var1.left + var1.right;
- var10000 = this.preferredSize;
- var10000.height += var1.top + var1.bottom;
- }
- }
-
- this.validCachedPreferredSize = true;
- }
-
- private int getMinX(Rectangle var1) {
- TreePath var2;
- int var3;
- if (var1 == null) {
- var2 = this.getPathForRow(this.tree, 0);
- var3 = Integer.MAX_VALUE;
- } else {
- var2 = this.treeState.getPathClosestTo(var1.x, var1.y);
- var3 = var1.height + var1.y;
- }
-
- Enumeration var4 = this.treeState.getVisiblePathsFrom(var2);
- int var5 = 0;
- if (var4 != null && var4.hasMoreElements()) {
- Rectangle var6 = this.treeState.getBounds((TreePath)var4.nextElement(), (Rectangle)null);
- if (var6 != null) {
- var5 = var6.x + var6.width;
- if (var6.y >= var3) {
- return var5;
- }
- }
-
- while(var6 != null && var4.hasMoreElements()) {
- var6 = this.treeState.getBounds((TreePath)var4.nextElement(), var6);
- if (var6 != null && var6.y < var3) {
- var5 = Math.min(var5, var6.x);
- } else {
- var6 = null;
- }
- }
-
- return var5;
- } else {
- return var5;
- }
- }
-
- protected void pathWasExpanded(TreePath var1) {
- if (this.tree != null) {
- this.tree.fireTreeExpanded(var1);
- }
-
- }
-
- protected void pathWasCollapsed(TreePath var1) {
- if (this.tree != null) {
- this.tree.fireTreeCollapsed(var1);
- }
-
- }
-
- protected void ensureRowsAreVisible(int var1, int var2) {
- if (this.tree != null && var1 >= 0 && var2 < this.getRowCount(this.tree)) {
- if (var1 == var2) {
- Rectangle var3 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var1));
- if (var3 != null) {
- this.tree.scrollRectToVisible(var3);
- }
- } else {
- Rectangle var9 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var1));
- Rectangle var4 = this.tree.getVisibleRect();
- Rectangle var5 = var9;
- int var6 = var9.y;
- int var7 = var6 + var4.height;
-
- for(int var8 = var1 + 1; var8 <= var2; ++var8) {
- var5 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var8));
- if (var5.y + var5.height > var7) {
- var8 = var2;
- }
- }
-
- this.tree.scrollRectToVisible(new Rectangle(var4.x, var6, 1, var5.y + var5.height - var6));
- }
- }
-
- }
-
- public void setPreferredMinSize(Dimension var1) {
- this.preferredMinSize = var1;
- }
-
- public Dimension getPreferredMinSize() {
- return this.preferredMinSize == null ? null : new Dimension(this.preferredMinSize);
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- return this.getPreferredSize(var1, true);
- }
-
- public Dimension getPreferredSize(JComponent var1, boolean var2) {
- Dimension var3 = this.getPreferredMinSize();
- if (!this.validCachedPreferredSize) {
- this.updateCachedPreferredSize();
- }
-
- if (this.tree != null) {
- return var3 != null ? new Dimension(Math.max(var3.width, this.preferredSize.width), Math.max(var3.height, this.preferredSize.height)) : new Dimension(this.preferredSize.width, this.preferredSize.height);
- } else {
- return var3 != null ? var3 : new Dimension(0, 0);
- }
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- return this.getPreferredMinSize() != null ? this.getPreferredMinSize() : new Dimension(0, 0);
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- if (this.tree != null) {
- return this.getPreferredSize(this.tree);
- } else {
- return this.getPreferredMinSize() != null ? this.getPreferredMinSize() : new Dimension(0, 0);
- }
- }
-
- protected void completeEditing() {
- if (this.tree.getInvokesStopCellEditing() && this.stopEditingInCompleteEditing && this.editingComponent != null) {
- this.cellEditor.stopCellEditing();
- }
-
- this.completeEditing(false, true, false);
- }
-
- protected void completeEditing(boolean var1, boolean var2, boolean var3) {
- if (this.stopEditingInCompleteEditing && this.editingComponent != null) {
- Component var4 = this.editingComponent;
- TreePath var5 = this.editingPath;
- TreeCellEditor var6 = this.cellEditor;
- Object var7 = var6.getCellEditorValue();
- Rectangle var8 = this.getPathBounds(this.tree, this.editingPath);
- boolean var9 = this.tree != null && (this.tree.hasFocus() || SwingUtilities.findFocusOwner(this.editingComponent) != null);
- this.editingComponent = null;
- this.editingPath = null;
- if (var1) {
- var6.stopCellEditing();
- } else if (var2) {
- var6.cancelCellEditing();
- }
-
- this.tree.remove(var4);
- if (this.editorHasDifferentSize) {
- this.treeState.invalidatePathBounds(var5);
- this.updateSize();
- } else {
- var8.x = 0;
- var8.width = this.tree.getSize().width;
- this.tree.repaint(var8);
- }
-
- if (var9) {
- this.tree.requestFocus();
- }
-
- if (var3) {
- this.treeModel.valueForPathChanged(var5, var7);
- }
- }
-
- }
-
- protected boolean startEditing(TreePath var1, MouseEvent var2) {
- this.completeEditing();
- if (this.cellEditor != null && this.tree.isPathEditable(var1)) {
- int var3 = this.getRowForPath(this.tree, var1);
- this.editingComponent = this.cellEditor.getTreeCellEditorComponent(this.tree, var1.getLastPathComponent(), this.tree.isPathSelected(var1), this.tree.isExpanded(var1), this.treeModel.isLeaf(var1.getLastPathComponent()), var3);
- if (this.cellEditor.isCellEditable(var2)) {
- Rectangle var4 = this.getPathBounds(this.tree, var1);
- this.editingRow = var3;
- Dimension var5 = this.editingComponent.getPreferredSize();
- if (var5.height != var4.height && this.getRowHeight() > 0) {
- var5.height = this.getRowHeight();
- }
-
- if (var5.width == var4.width && var5.height == var4.height) {
- this.editorHasDifferentSize = false;
- } else {
- this.editorHasDifferentSize = true;
- this.treeState.invalidatePathBounds(var1);
- this.updateSize();
- }
-
- this.tree.add(this.editingComponent);
- this.editingComponent.setBounds(var4.x, var4.y, var5.width, var5.height);
- this.editingPath = var1;
- this.editingComponent.validate();
- Rectangle var6 = this.tree.getVisibleRect();
- this.tree.paintImmediately(var4.x, var4.y, var6.width + var6.x - var4.x, var5.height);
- if (this.cellEditor.shouldSelectCell(var2)) {
- this.stopEditingInCompleteEditing = false;
-
- try {
- this.tree.setSelectionRow(var3);
- } catch (Exception var9) {
- System.err.println("Editing exception: " + var9);
- }
-
- this.stopEditingInCompleteEditing = true;
- }
-
- if (var2 != null && var2 instanceof MouseEvent) {
- Point var7 = SwingUtilities.convertPoint(this.tree, new Point(var2.getX(), var2.getY()), this.editingComponent);
- Component var8 = SwingUtilities.getDeepestComponentAt(this.editingComponent, var7.x, var7.y);
- if (var8 != null) {
- new MouseInputHandler(this, this.tree, var8, var2);
- }
- }
-
- return true;
- }
-
- this.editingComponent = null;
- }
-
- return false;
- }
-
- protected void checkForClickInExpandControl(TreePath var1, int var2, int var3) {
- if (this.isLocationInExpandControl(var1, var2, var3)) {
- this.handleExpandControlClick(var1, var2, var3);
- }
-
- }
-
- protected boolean isLocationInExpandControl(TreePath var1, int var2, int var3) {
- if (var1 != null && !this.treeModel.isLeaf(var1.getLastPathComponent())) {
- Insets var5 = this.tree.getInsets();
- int var4;
- if (this.getExpandedIcon() != null) {
- var4 = this.getExpandedIcon().getIconWidth();
- } else {
- var4 = 8;
- }
-
- int var6 = var5 != null ? var5.left : 0;
- if (this.leftToRight) {
- var6 += (var1.getPathCount() + this.depthOffset - 2) * this.totalChildIndent + this.getLeftChildIndent() - var4 / 2;
- } else {
- var6 += this.lastWidth - 1 - (var1.getPathCount() - 2 + this.depthOffset) * this.totalChildIndent - this.getLeftChildIndent() - var4 / 2;
- }
-
- int var7 = var6 + var4;
- return var2 >= var6 && var2 <= var7;
- } else {
- return false;
- }
- }
-
- protected void handleExpandControlClick(TreePath var1, int var2, int var3) {
- this.toggleExpandState(var1);
- }
-
- protected void toggleExpandState(TreePath var1) {
- if (!this.tree.isExpanded(var1)) {
- int var2 = this.getRowForPath(this.tree, var1);
- this.tree.expandPath(var1);
- this.updateSize();
- if (var2 != -1) {
- if (this.tree.getScrollsOnExpand()) {
- this.ensureRowsAreVisible(var2, var2 + this.treeState.getVisibleChildCount(var1));
- } else {
- this.ensureRowsAreVisible(var2, var2);
- }
- }
- } else {
- this.tree.collapsePath(var1);
- this.updateSize();
- }
-
- }
-
- protected boolean isToggleSelectionEvent(MouseEvent var1) {
- return SwingUtilities.isLeftMouseButton(var1) && ((InputEvent)var1).isControlDown();
- }
-
- protected boolean isMultiSelectEvent(MouseEvent var1) {
- return SwingUtilities.isLeftMouseButton(var1) && ((InputEvent)var1).isShiftDown();
- }
-
- protected boolean isToggleEvent(MouseEvent var1) {
- if (!SwingUtilities.isLeftMouseButton(var1)) {
- return false;
- } else {
- int var2 = this.tree.getToggleClickCount();
- if (var2 <= 0) {
- return false;
- } else {
- return var1.getClickCount() == var2;
- }
- }
- }
-
- protected void selectPathForEvent(TreePath var1, MouseEvent var2) {
- if (this.isToggleSelectionEvent(var2)) {
- if (this.tree.isPathSelected(var1)) {
- this.tree.removeSelectionPath(var1);
- } else {
- this.tree.addSelectionPath(var1);
- }
-
- this.lastSelectedRow = this.getRowForPath(this.tree, var1);
- this.setAnchorSelectionPath(var1);
- this.setLeadSelectionPath(var1);
- } else if (this.isMultiSelectEvent(var2)) {
- TreePath var3 = this.getAnchorSelectionPath();
- int var4 = var3 == null ? -1 : this.getRowForPath(this.tree, var3);
- if (var4 == -1) {
- this.tree.setSelectionPath(var1);
- } else {
- int var5 = this.getRowForPath(this.tree, var1);
- if (var5 < var4) {
- this.tree.setSelectionInterval(var5, var4);
- } else {
- this.tree.setSelectionInterval(var4, var5);
- }
-
- this.lastSelectedRow = var5;
- this.setAnchorSelectionPath(var3);
- this.setLeadSelectionPath(var1);
- }
- } else if (SwingUtilities.isLeftMouseButton(var2)) {
- this.tree.setSelectionPath(var1);
- if (this.isToggleEvent(var2)) {
- this.toggleExpandState(var1);
- }
- }
-
- }
-
- protected boolean isLeaf(int var1) {
- TreePath var2 = this.getPathForRow(this.tree, var1);
- return var2 != null ? this.treeModel.isLeaf(var2.getLastPathComponent()) : true;
- }
-
- private void setAnchorSelectionPath(TreePath var1) {
- this.ignoreLAChange = true;
-
- try {
- this.tree.setAnchorSelectionPath(var1);
- } finally {
- this.ignoreLAChange = false;
- }
-
- }
-
- private TreePath getAnchorSelectionPath() {
- return this.tree.getAnchorSelectionPath();
- }
-
- private void setLeadSelectionPath(TreePath var1) {
- this.setLeadSelectionPath(var1, false);
- }
-
- private void setLeadSelectionPath(TreePath var1, boolean var2) {
- Rectangle var3 = var2 ? this.getPathBounds(this.tree, this.getLeadSelectionPath()) : null;
- this.ignoreLAChange = true;
-
- try {
- this.tree.setLeadSelectionPath(var1);
- } finally {
- this.ignoreLAChange = false;
- }
-
- this.leadRow = this.getRowForPath(this.tree, var1);
- if (var2) {
- if (var3 != null) {
- this.tree.repaint(var3);
- }
-
- var3 = this.getPathBounds(this.tree, var1);
- if (var3 != null) {
- this.tree.repaint(var3);
- }
- }
-
- }
-
- private TreePath getLeadSelectionPath() {
- return this.tree.getLeadSelectionPath();
- }
-
- private void updateLeadRow() {
- this.leadRow = this.getRowForPath(this.tree, this.getLeadSelectionPath());
- }
-
- private int getLeadSelectionRow() {
- return this.leadRow;
- }
-
- private void extendSelection(TreePath var1) {
- TreePath var2 = this.getAnchorSelectionPath();
- int var3 = var2 == null ? -1 : this.getRowForPath(this.tree, var2);
- int var4 = this.getRowForPath(this.tree, var1);
- if (var3 == -1) {
- this.tree.setSelectionRow(var4);
- } else {
- if (var3 < var4) {
- this.tree.setSelectionInterval(var3, var4);
- } else {
- this.tree.setSelectionInterval(var4, var3);
- }
-
- this.setAnchorSelectionPath(var2);
- this.setLeadSelectionPath(var1);
- }
-
- }
-
- private void repaintPath(TreePath var1) {
- if (var1 != null) {
- Rectangle var2 = this.getPathBounds(this.tree, var1);
- if (var2 != null) {
- this.tree.repaint(var2.x, var2.y, var2.width, var2.height);
- }
- }
-
- }
-
- // $FF: synthetic method
- static void access$400(BasicTreeUI var0) {
- var0.updateLeadRow();
- }
-
- // $FF: synthetic method
- static TreePath access$500(BasicTreeUI var0) {
- return var0.getLeadSelectionPath();
- }
-
- // $FF: synthetic method
- static void access$600(BasicTreeUI var0, TreePath var1) {
- var0.setAnchorSelectionPath(var1);
- }
-
- // $FF: synthetic method
- static void access$700(BasicTreeUI var0, TreePath var1) {
- var0.setLeadSelectionPath(var1);
- }
-
- // $FF: synthetic method
- static boolean access$800(BasicTreeUI var0) {
- return var0.leftToRight;
- }
-
- // $FF: synthetic method
- static int access$900(BasicTreeUI var0) {
- return var0.lastWidth;
- }
-
- // $FF: synthetic method
- static boolean access$1000(BasicTreeUI var0) {
- return var0.ignoreLAChange;
- }
-
- // $FF: synthetic method
- static void access$1100(BasicTreeUI var0, TreePath var1) {
- var0.repaintPath(var1);
- }
-
- // $FF: synthetic method
- static void access$1200(BasicTreeUI var0) {
- var0.redoTheLayout();
- }
-
- // $FF: synthetic method
- static boolean access$802(BasicTreeUI var0, boolean var1) {
- return var0.leftToRight = var1;
- }
-
- // $FF: synthetic method
- static int access$1300(BasicTreeUI var0) {
- return var0.getLeadSelectionRow();
- }
-
- // $FF: synthetic method
- static void access$1400(BasicTreeUI var0, TreePath var1, boolean var2) {
- var0.setLeadSelectionPath(var1, var2);
- }
-
- // $FF: synthetic method
- static void access$1500(BasicTreeUI var0, TreePath var1) {
- var0.extendSelection(var1);
- }
-
- // $FF: synthetic method
- static TreePath access$1600(BasicTreeUI var0) {
- return var0.getAnchorSelectionPath();
- }
- }
-