/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* AquaTreeUI supports the client property "value-add" system of customization See MetalTreeUI
* This is heavily based on the 1.3.1 AquaTreeUI implementation.
*/
// Create PLAF
return new AquaTreeUI();
}
// Begin Line Stuff from Metal
// mouse tracking state
protected boolean fIsPressed = false;
protected boolean fIsInBounds = false;
protected final AquaPainter<AnimationFrameState> painter = AquaPainter.create(JRSUIStateFactory.getDisclosureTriangle());
public AquaTreeUI() {
}
super.installUI(c);
}
super.uninstallUI(c);
}
/**
* Creates the focus listener to repaint the focus ring
*/
return new AquaTreeUI.FocusHandler();
}
/**
* this function converts between the string passed into the client property and the internal representation
* (currently an int)
*/
return;
}
}
}
}
super.paint(g, c);
// Paint the lines
paintHorizontalSeparators(g, c);
}
}
final int endRow = getRowForPath(tree, getClosestPathForLocation(tree, 0, clipBounds.y + clipBounds.height - 1));
// Draw a line at the top
if (rowBounds != null) g.drawLine(clipBounds.x, rowBounds.y, clipBounds.x + clipBounds.width, rowBounds.y);
}
}
}
protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) {
if (lineStyle == LEG_LINE_STYLE) {
}
}
protected void paintHorizontalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final Rectangle bounds, final TreePath path, final int row, final boolean isExpanded, final boolean hasBeenExpanded, final boolean isLeaf) {
if (lineStyle == LEG_LINE_STYLE) {
super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
}
}
/** This class listens for changes in line style */
decodeLineStyle(e.getNewValue());
}
}
}
/**
* Paints the expand (toggle) part of a row. The reciever should NOT modify <code>clipBounds</code>, or
* <code>insets</code>.
*/
protected void paintExpandControl(final Graphics g, final Rectangle clipBounds, final Insets insets, final Rectangle bounds, final TreePath path, final int row, final boolean isExpanded, final boolean hasBeenExpanded, final boolean isLeaf) {
// Draw icons if not a leaf and either hasn't been loaded,
// or the model child count is > 0.
// if we are not animating, do the expected thing, and use the icon
// also, if there is a custom (non-LaF defined) icon - just use that instead
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
return;
}
// Both icons are the same size
if (!(icon instanceof UIResource)) {
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
return;
}
// if painting a right-to-left knob, we ensure that we are only painting when
// the clipbounds rect is set to the exact size of the knob, and positioned correctly
// (this code is not the same as metal)
int middleXOfKnob;
if (isLeftToRight) {
} else {
}
// Center vertically
final int height = icon.getIconHeight(); // use the icon height so we don't get drift we modify the bounds (by changing row height)
final int width = 20; // this is a hardcoded value from our default icon (since we are only at this point for animation)
}
}
if (fAnimationFrame == -1) {
} else {
}
} else {
}
}
}
if (fIsPressed) {
}
}
/**
* Misnamed - this is called on mousePressed Macs shouldn't react till mouseReleased
* We install a motion handler that gets removed after.
* See super.MouseInputHandler & super.startEditing for why
*/
}
/**
* Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.
*/
}
super.focusGained(e);
}
super.focusLost(e);
}
}
return new MacPropertyChangeHandler();
}
} else {
super.propertyChange(e);
}
}
}
/**
* TreeArrowMouseInputHandler handles passing all mouse events the way a Mac should - hilite/dehilite on enter/exit,
* only perform the action if released in arrow.
*
* Just like super.MouseInputHandler, this is removed once it's not needed, so they won't clash with each other
*/
// The Adapters take care of defining all the empties
// Values needed for paintOneControl
int fTrackingRow;
fIsPressed = true;
fIsInBounds = true;
tree.addMouseListener(this);
tree.addMouseMotionListener(this);
}
// Set up values needed to paint the triangle - see
// BasicTreeUI.paint
else {
}
}
}
}
if (fIsPressed) {
final boolean wasInBounds = fIsInBounds;
fIsPressed = false;
fIsInBounds = false;
if (wasInBounds) {
if (e.isAltDown()) {
if (fIsExpanded) {
expandNode(fTrackingRow, true);
} else {
collapseNode(fTrackingRow, true);
}
} else {
}
}
}
}
if (expanding) {
} else {
}
fAnimationFrame = -1;
}
}
// Utility to paint just one widget while it's being tracked
// Just doing "repaint" runs into problems if someone does "translate" on the graphics
// (ie, Sun's JTreeTable example, which is used by Moneydance - see Radar 2697837)
void paintOneControl() {
if (g == null) {
// i.e. source is not displayable
return;
}
try {
g.setClip(fVisibleRect);
// If we ever wanted a callback for drawing the arrow between
// transition stages
// the code between here and paintExpandControl would be it
g.setColor(fBackground);
// if there is no tracking path, we don't need to paint anything
if (fTrackingPath == null) return;
// draw the vertical line to the parent
if (parentPath != null) {
paintHorizontalPartOfLeg(g, fPathBounds, fInsets, fBounds, fTrackingPath, fTrackingRow, fIsExpanded, fHasBeenExpanded, fIsLeaf);
paintHorizontalPartOfLeg(g, fPathBounds, fInsets, fBounds, fTrackingPath, fTrackingRow, fIsExpanded, fHasBeenExpanded, fIsLeaf);
}
paintExpandControl(g, fPathBounds, fInsets, fBounds, fTrackingPath, fTrackingRow, fIsExpanded, fHasBeenExpanded, fIsLeaf);
} finally {
g.dispose();
}
}
protected void removeFromSource() {
tree.removeMouseListener(this);
tree.removeMouseMotionListener(this);
}
}
}
/**
* see isLocationInExpandControl for bounds calc
*/
final Rectangle bounds = getPathBounds(tree, path); // Gives us the y values, but x is adjusted for the contents
boxLeftX += (((path.getPathCount() + depthOffset - 2) * totalChildIndent) + getLeftChildIndent()) - bounds.width / 2;
} else {
boxLeftX += tree.getWidth() - 1 - ((path.getPathCount() - 2 + depthOffset) * totalChildIndent) - getLeftChildIndent() - bounds.width / 2;
}
return bounds;
}
protected void installKeyboardActions() {
super.installKeyboardActions();
}
/**
* Determines direction to traverse, 1 means expand, -1 means collapse.
*/
final boolean expand;
final boolean recursive;
/**
* True if the selection is reset, false means only the lead path changes.
*/
}
if (selectionPaths == null) return;
/*
* Try and expand the node, otherwise go to next node.
*/
if (expand) {
continue;
}
// else collapse
// in the special case where there is only one row selected,
// we want to do what the Cocoa does, and select the parent
}
continue;
}
}
}
public boolean isEnabled() {
}
}
if (!recursive) return;
}
for (int i = initialRow; true; i++) {
}
}
if (recursive) {
}
}
int lastRow = -1;
lastRow = i - 1;
}
}
for (int i = lastRow; i >= initialRow; i--) {
}
}
}