/*
* 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.
*/
final boolean isMultiLineEditor;
final JTextComponent c;
boolean mFocused = false;
super();
c = inComponent;
}
return AquaHighlighter.getInstance();
}
/**
* Only show the flashing caret if the selection range is zero
*/
public void setVisible(boolean e) {
super.setVisible(e);
}
protected void fireStateChanged() {
// If we have focus the caret should only flash if the range length is zero
super.fireStateChanged();
}
} else {
setVisible(false);
}
}
}
// --- FocusListener methods --------------------------
private boolean shouldSelectAllOnFocus = true;
super.focusGained(e);
return;
}
mFocused = true;
if (!shouldSelectAllOnFocus) {
shouldSelectAllOnFocus = true;
super.focusGained(e);
return;
}
if (isMultiLineEditor) {
super.focusGained(e);
return;
}
if (dot == 0) {
}
}
super.focusGained(e);
}
mFocused = false;
shouldSelectAllOnFocus = true;
if (isMultiLineEditor) {
setVisible(false);
c.repaint();
} else {
super.focusLost(e);
}
}
// This fixes the problem where when on the mac you have to ctrl left click to
// get popup triggers the caret has code that only looks at button number.
// see radar # 3125390
if (!e.isPopupTrigger()) {
super.mousePressed(e);
shouldSelectAllOnFocus = false;
}
}
/**
* Damages the area surrounding the caret to cause
* it to be repainted in a new location. If paint()
* is reimplemented, this method should also be
* reimplemented. This method should update the
* caret bounds (x, y, width, and height).
*
* @param r the current location of the caret
* @see #paint
*/
x = r.x - 4;
y = r.y;
width = 10;
// Don't damage the border area. We can't paint a partial border, so get the
// intersection of the caret rectangle and the component less the border, if any.
}
x = caretRect.x;
y = caretRect.y;
repaint();
}
boolean fPainting = false;
// See <rdar://problem/3833837> 1.4.2_05-141.3: JTextField performance with Aqua L&F
// We are getting into a circular condition with the BasicCaret paint code since it doesn't know about the fact that our
// damage routine above elminates the border. Sadly we can't easily change either one, so we will
// add a painting flag and not damage during a repaint.
if (isVisible()) {
fPainting = true;
super.paint(g);
fPainting = false;
}
}
}