Index: make/properties.xml
===================================================================
--- make/properties.xml (revision 588163)
+++ make/properties.xml (working copy)
@@ -265,7 +265,7 @@
-
+
Index: modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java
===================================================================
--- modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java (revision 588163)
+++ modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java (working copy)
@@ -51,7 +51,6 @@ import java.util.Calendar;
import java.util.Date;
import javax.swing.BoundedRangeModel;
-import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JFormattedTextField;
import javax.swing.SwingConstants;
@@ -996,23 +995,6 @@ public class TextUtils {
return retVal;
}
- public static Rectangle getEditorRect(final JComponent component) {
- if (component == null) {
- return null;
- }
- Insets insets = component.getInsets();
- int left = 0;
- int top = 0;
- if (insets != null) {
- left = insets.left;
- top = insets.top;
- }
- Dimension r = component.getSize();
- return r.width == 0 || r.height == 0 ? null
- : new Rectangle(left, top, r.width - getHrzInsets(insets),
- r.height - getVrtInsets(insets));
- }
-
public static int getHrzInsets(final Insets insets) {
return (insets != null) ? insets.left + insets.right : 0;
}
Index: modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/TextUtils.java
===================================================================
--- modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/TextUtils.java (revision 0)
+++ modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/TextUtils.java (revision 0)
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.x.swing.text;
+
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.Rectangle;
+
+import javax.swing.text.JTextComponent;
+
+public class TextUtils {
+
+ /**
+ * Returns, component getSize, excluding insets.
+ */
+ public static Rectangle getEditorRect(JTextComponent component) {
+ if (component == null) {
+ return null;
+ }
+ Insets insets = component.getInsets();
+ int left = 0;
+ int top = 0;
+ if (insets != null) {
+ left = insets.left;
+ top = insets.top;
+ }
+ Dimension r = component.getSize();
+ return r.width == 0 || r.height == 0 ? null : new Rectangle(left, top,
+ r.width
+ - org.apache.harmony.awt.text.TextUtils
+ .getHrzInsets(insets), r.height
+ - org.apache.harmony.awt.text.TextUtils
+ .getVrtInsets(insets));
+ }
+}
Index: modules/swing/src/main/java/common/javax/swing/text/DefaultHighlighter.java
===================================================================
--- modules/swing/src/main/java/common/javax/swing/text/DefaultHighlighter.java (revision 588163)
+++ modules/swing/src/main/java/common/javax/swing/text/DefaultHighlighter.java (working copy)
@@ -25,22 +25,20 @@ import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
import java.util.ArrayList;
+
import javax.swing.plaf.TextUI;
import org.apache.harmony.awt.text.TextKit;
import org.apache.harmony.awt.text.TextUtils;
-
import org.apache.harmony.x.swing.internal.nls.Messages;
-
-
public class DefaultHighlighter extends LayeredHighlighter {
// This vector contains all highlights
- private final HighlightList highlights = new HighlightList();;
+ private final ArrayList highlights = new ArrayList();
// Defines paint procedure
- private boolean drawsLayeredHighlights;
+ private boolean drawsLayeredHighlights;
// JTextComponent bound to the highlighter
private JTextComponent component;
@@ -48,23 +46,8 @@ public class DefaultHighlighter extends
private TextKit textKit;
/**
- * Provides more convinient interface for DefaultHighlighter
- */
- private class HighlightList extends ArrayList {
-
- public HighlightImpl getElem(final Object obj) {
- int index = indexOf(obj);
- return index >= 0 ? (HighlightImpl)get(index) : null;
- }
-
- public HighlightImpl getElem(final int index) {
- return (HighlightImpl)get(index);
- }
- }
-
- /**
* Stores all Highlights information.
- *
+ *
*/
private class HighlightImpl implements Highlight {
// highlight start position
@@ -92,7 +75,7 @@ public class DefaultHighlighter extends
* position, p1 - end position, pnt - painter, r - bounds
*/
HighlightImpl(final Position start, final Position end,
- final HighlightPainter pnt) {
+ final HighlightPainter pnt) {
startPosition = start;
endPosition = end;
painter = pnt;
@@ -103,8 +86,7 @@ public class DefaultHighlighter extends
/**
* Changes highlight. Changes startPosition, endPosition, bounds.
*/
- public void changeHighlight(final Position start,
- final Position end) {
+ public void changeHighlight(final Position start, final Position end) {
startPosition = start;
endPosition = end;
}
@@ -135,8 +117,7 @@ public class DefaultHighlighter extends
}
}
- public static class DefaultHighlightPainter extends
- LayerPainter {
+ public static class DefaultHighlightPainter extends LayerPainter {
private final Color color;
public DefaultHighlightPainter(final Color c) {
@@ -154,10 +135,10 @@ public class DefaultHighlighter extends
* It supposes, that p0 and p1 have Position.Bias.Forward bias.
* Calculates appropriate rectangles by call TextUI.modelToView. If some
* rectangles equals null, do nothing.
- *
+ *
*/
public void paint(final Graphics g, final int p0, final int p1,
- final Shape shape, final JTextComponent jtc) {
+ final Shape shape, final JTextComponent jtc) {
TextUI textUI = jtc.getUI();
if (textUI == null) {
return;
@@ -171,7 +152,7 @@ public class DefaultHighlighter extends
try {
startRect = textUI.modelToView(jtc, start,
- Position.Bias.Forward);
+ Position.Bias.Forward);
endRect = textUI.modelToView(jtc, end, Position.Bias.Backward);
} catch (final BadLocationException e) {
}
@@ -183,27 +164,24 @@ public class DefaultHighlighter extends
boolean isLineGap = (startRectMaxY < endRect.y);
boolean isDifferentLine = (startRectMaxY <= endRect.y);
g.setColor(getRealColor(jtc));
- //It need to add 1 to width and height as that requires fillRect
+ // It need to add 1 to width and height as that requires fillRect
if (isLineGap) {
- g.fillRect(shapeBounds.x,
- startRectMaxY,
- shapeBounds.width + 1,
- endRect.y - startRectMaxY + 1);
+ g.fillRect(shapeBounds.x, startRectMaxY, shapeBounds.width + 1,
+ endRect.y - startRectMaxY + 1);
}
if (isDifferentLine) {
- g.fillRect(startRect.x,
- startRect.y,
- shapeBounds.width - startRect.x + 1 + shapeBounds.x,
- startRect.height + 1);
- g.fillRect(shapeBounds.x, endRect.y,
- endRect.x - shapeBounds.x + 1,
- endRect.height + 1);
+ g
+ .fillRect(startRect.x, startRect.y, shapeBounds.width
+ - startRect.x + 1 + shapeBounds.x,
+ startRect.height + 1);
+ g.fillRect(shapeBounds.x, endRect.y, endRect.x - shapeBounds.x
+ + 1, endRect.height + 1);
} else {
- g.fillRect(Math.min(startRect.x, endRect.x),
- startRect.y,
- Math.abs(endRect.x - startRect.x + 1),
- startRect.height + 1);
+ g
+ .fillRect(Math.min(startRect.x, endRect.x),
+ startRect.y, Math.abs(endRect.x - startRect.x
+ + 1), startRect.height + 1);
}
}
@@ -217,11 +195,10 @@ public class DefaultHighlighter extends
* drawsLayered of the current Highlight equals true.
*/
public Shape paintLayer(final Graphics g, final int start,
- final int end,
- final Shape shape, final JTextComponent jtc,
- final View view) {
- return TextUtils.paintLayer(g, start, end, shape, getRealColor(jtc),
- view, true);
+ final int end, final Shape shape, final JTextComponent jtc,
+ final View view) {
+ return TextUtils.paintLayer(g, start, end, shape,
+ getRealColor(jtc), view, true);
}
private Color getRealColor(final JTextComponent c) {
@@ -232,8 +209,8 @@ public class DefaultHighlighter extends
/**
* DefaultHighlighter.DefaultHighlighterPainter with color equal to null
*/
- public static final LayerPainter DefaultPainter =
- new DefaultHighlightPainter(null);
+ public static final LayerPainter DefaultPainter = new DefaultHighlightPainter(
+ null);
/**
* Calls setDrawLayeredHighlights(true). Initializes internal vector
@@ -244,22 +221,25 @@ public class DefaultHighlighter extends
}
public Object addHighlight(final int start, final int end,
- final Highlighter.HighlightPainter pnt)
- throws BadLocationException {
+ final Highlighter.HighlightPainter pnt) throws BadLocationException {
checkBoundaries(start, end);
- Highlight h = new HighlightImpl(createPosition(start),
- createPosition(end), pnt);
+ HighlightImpl h = new HighlightImpl(createPosition(start),
+ createPosition(end), pnt);
highlights.add(h);
repaintComponent(getBoundsByOffsets(start, end));
return h;
}
- public void changeHighlight(final Object obj, final int start,
- final int end)
+ private HighlightImpl updateHighlight(Object obj) {
+ int index = highlights.indexOf(obj);
+ return index >= 0 ? (HighlightImpl) highlights.get(index) : null;
+ }
+
+ public void changeHighlight(final Object obj, final int start, final int end)
throws BadLocationException {
checkBoundaries(start, end);
- HighlightImpl h = highlights.getElem(obj);
+ HighlightImpl h = updateHighlight(obj);
if (h == null) {
return;
}
@@ -278,7 +258,7 @@ public class DefaultHighlighter extends
}
public Highlighter.Highlight[] getHighlights() {
- return (Highlighter.Highlight[])highlights
+ return (Highlighter.Highlight[]) highlights
.toArray(new Highlighter.Highlight[highlights.size()]);
}
@@ -296,9 +276,10 @@ public class DefaultHighlighter extends
*/
public void paint(final Graphics g) {
- Rectangle r = TextUtils.getEditorRect(component);
+ Rectangle r = org.apache.harmony.x.swing.text.TextUtils
+ .getEditorRect(component);
for (int i = 0; i < highlights.size(); i++) {
- HighlightImpl hElem = highlights.getElem(i);
+ HighlightImpl hElem = highlights.get(i);
int start = hElem.getStartOffset();
int end = hElem.getEndOffset();
if (hElem.needSimplePaint()) {
@@ -313,28 +294,26 @@ public class DefaultHighlighter extends
* getStartOffet() and getEndOffset() of the Highlight corresponds to view,
* painter is instance of LayeredHighlight.LayeredHightPainter, and the
* Highlight is added at getDrawsLayeredHighlights() equals true.
- *
+ *
*/
public void paintLayeredHighlights(final Graphics g, final int p0,
- final int p1, final Shape viewBounds,
- final JTextComponent editor,
- final View view) {
+ final int p1, final Shape viewBounds, final JTextComponent editor,
+ final View view) {
Document doc = editor.getDocument();
int length = doc.getLength();
for (int i = highlights.size() - 1; i >= 0; i--) {
- HighlightImpl hElem = highlights.getElem(i);
+ HighlightImpl hElem = highlights.get(i);
int start = hElem.getStartOffset();
int end = hElem.getEndOffset();
- if (hElem.needSimplePaint()
- || end > length || start > p1 || end < p0) {
+ if (hElem.needSimplePaint() || end > length || start > p1
+ || end < p0) {
continue;
}
- ((LayerPainter)(hElem.getPainter()))
- .paintLayer(g, Math.max(p0, start), Math.min(p1, end),
- viewBounds, editor, view);
+ ((LayerPainter) (hElem.getPainter())).paintLayer(g, Math.max(p0,
+ start), Math.min(p1, end), viewBounds, editor, view);
}
}
@@ -344,7 +323,7 @@ public class DefaultHighlighter extends
*/
public void removeAllHighlights() {
while (!highlights.isEmpty()) {
- HighlightImpl hElem = highlights.getElem(0);
+ HighlightImpl hElem = highlights.get(0);
Rectangle highlightBounds = getBoundsByHighlight(hElem);
highlights.remove(0);
repaintComponent(highlightBounds);
@@ -354,10 +333,10 @@ public class DefaultHighlighter extends
/**
* Calls repaint of component with parameters corresponding to bounds of
* deleted highlight.
- *
+ *
*/
public void removeHighlight(final Object obj) {
- Highlight highlight = highlights.getElem(obj);
+ Highlight highlight = updateHighlight(obj);
if (highlight != null) {
Rectangle highlightBounds = getBoundsByHighlight(highlight);
highlights.remove(highlight);
@@ -371,7 +350,7 @@ public class DefaultHighlighter extends
* highlight painter. Otherwise, if added highlighter is instance of
* LayeredHighlighter.LayeredHighlightPainter, method paintLayer of
* HighlightPainter will be used.
- *
+ *
* @param b
*/
public void setDrawsLayeredHighlights(final boolean b) {
@@ -379,12 +358,14 @@ public class DefaultHighlighter extends
}
private void checkBoundaries(final int start, final int end)
- throws BadLocationException {
+ throws BadLocationException {
if (start < 0) {
- throw new BadLocationException(Messages.getString("swing.89", start), end); //$NON-NLS-1$
+ throw new BadLocationException(Messages
+ .getString("swing.89", start), end); //$NON-NLS-1$
}
if (end < start) {
- throw new BadLocationException(Messages.getString("swing.89", start), end); //$NON-NLS-1$
+ throw new BadLocationException(Messages
+ .getString("swing.89", start), end); //$NON-NLS-1$
}
}
@@ -394,24 +375,23 @@ public class DefaultHighlighter extends
*/
private Position createPosition(final int offset)
- throws BadLocationException {
+ throws BadLocationException {
return component.getDocument().createPosition(offset);
}
private void updateHighlights(final int oldStart, final int oldEnd,
- final int newStart, final int newEnd) {
+ final int newStart, final int newEnd) {
if (oldEnd < newStart || oldStart > oldEnd) {
- repaintComponent(oldStart, oldEnd, newStart, newEnd);
+ repaintComponent(oldStart, oldEnd, newStart, newEnd);
} else {
- repaintComponent(Math.min(oldStart, newStart),
- Math.max(oldStart, newStart),
- Math.min(oldEnd, newEnd),
- Math.max(oldEnd, newEnd));
+ repaintComponent(Math.min(oldStart, newStart), Math.max(oldStart,
+ newStart), Math.min(oldEnd, newEnd), Math.max(oldEnd,
+ newEnd));
}
}
- private void repaintComponent(final int p0, final int p1,
- final int p2, final int p3) {
+ private void repaintComponent(final int p0, final int p1, final int p2,
+ final int p3) {
repaintComponent(getBoundsByOffsets(p0, p1));
repaintComponent(getBoundsByOffsets(p2, p3));
}
@@ -424,8 +404,7 @@ public class DefaultHighlighter extends
private Rectangle getBoundsByHighlight(final Highlight highlight) {
return TextUtils.getBoundsByOffsets(textKit,
- highlight.getStartOffset(),
- highlight.getEndOffset());
+ highlight.getStartOffset(), highlight.getEndOffset());
}
private Rectangle getBoundsByOffsets(final int p0, final int p1) {
@@ -433,5 +412,3 @@ public class DefaultHighlighter extends
}
}
-
-
Index: modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
===================================================================
--- modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java (revision 588163)
+++ modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java (working copy)
@@ -20,7 +20,6 @@
*/
package javax.swing.plaf.basic;
-
import java.awt.AWTKeyStroke;
import java.awt.Color;
import java.awt.Dimension;
@@ -89,7 +88,6 @@ import org.apache.harmony.x.swing.String
import org.apache.harmony.x.swing.Utilities;
import org.apache.harmony.x.swing.internal.nls.Messages;
-
public abstract class BasicTextUI extends TextUI implements ViewFactory {
public static class BasicCaret extends DefaultCaret implements UIResource {
@@ -106,7 +104,7 @@ public abstract class BasicTextUI extend
}
// Text Component, concerned with this BasicTextUI
- private JTextComponent component;
+ private JTextComponent component;
// Editor Kit for all components excluding JTextPane and JEditorPane
private static final EditorKit EDITOR_KIT = new DefaultEditorKit();
@@ -114,46 +112,45 @@ public abstract class BasicTextUI extend
// The Parent of all view Hierarchy. In never changes. When document
// changes,
// a child of rootView will be replaced only.
- private RootViewContext rootViewContext;
+ private RootViewContext rootViewContext;
// PropertyChangeListener, DocumentListener
- private Listener listener = new Listener();
+ private Listener listener = new Listener();
// Document, concerned with this BasicTextUI (component.getDocument)
- private Document document;
+ private Document document;
// Simple TransferHandler to support cut, copy, paste operations
private static TransferHandler transferHandler;
// This flag is used in paintSafely, modelToView, viewToModel methods.
- private boolean isActive = false;
+ private boolean isActive = false;
// This flag is used in Listener.InsertUpdate method. It need not to lock
// document in DocumentListener. Then modelChanged method defines, it need
// to lock document or not
- private boolean needLock = true;
+ private boolean needLock = true;
// if document i18n property changes, then ViewHierarchy must be rebuild.
- private boolean i18nProperty = false;
+ private boolean i18nProperty = false;
// Action to request focus on Text Component (support FocusAcceleratorKey
- //on JTextComponent).
- private final Action focusAction = new RequestFocusAction();
+ // on JTextComponent).
+ private final Action focusAction = new RequestFocusAction();
// Key for FOCUS_ACTION in ActionMap
- private static final String FOCUS_ACTION_NAME = "request-focus";
+ private static final String FOCUS_ACTION_NAME = "request-focus";
// Flag is used in UpdateFocus AcceleratorKey method
- private char lastFocusAccelerator = '\0';
+ private char lastFocusAccelerator = '\0';
- //Listener for drop target
- private DropListener dropListener;
+ // Listener for drop target
+ private DropListener dropListener;
- //Initiator for DnD
- private GestureRecognizer gestureRecognizer;
+ // Initiator for DnD
+ private GestureRecognizer gestureRecognizer;
- private final RootViewContext.ViewFactoryGetter viewFactoryGetter =
- new RootViewContext.ViewFactoryGetter() {
+ private final RootViewContext.ViewFactoryGetter viewFactoryGetter = new RootViewContext.ViewFactoryGetter() {
public ViewFactory getViewFactory() {
ViewFactory viewFactory = getEditorKit(component).getViewFactory();
@@ -173,7 +170,7 @@ public abstract class BasicTextUI extend
public void actionPerformed(final ActionEvent e) {
JTextComponent jtc = null;
if (e != null && e.getSource() != null) {
- jtc = (JTextComponent)e.getSource();
+ jtc = (JTextComponent) e.getSource();
}
if (jtc != null) {
jtc.requestFocusInWindow();
@@ -186,18 +183,18 @@ public abstract class BasicTextUI extend
* javax.swing.TransferHandler because it doesn't support required
* operations. See java.beans (Introspector, BeanInfo,...)
*/
- private static class TextTransferHandler extends TransferHandler
- implements UIResource {
+ private static class TextTransferHandler extends TransferHandler implements
+ UIResource {
boolean isDrag = false;
public boolean canImport(final JComponent comp,
- final DataFlavor[] dataFlavor) {
- //Note: temporary solution
- return true; //super.canImport(arg0, arg1);
+ final DataFlavor[] dataFlavor) {
+ // Note: temporary solution
+ return true; // super.canImport(arg0, arg1);
}
public void exportToClipboard(final JComponent c, final Clipboard clip,
- final int action) {
+ final int action) {
TextUtils.exportToClipboard(TextUtils.getTextKit(c), clip, action);
}
@@ -209,7 +206,7 @@ public abstract class BasicTextUI extend
}
protected void exportDone(final JComponent c, final Transferable data,
- final int action) {
+ final int action) {
isDrag = false;
TextUtils.exportDone(TextUtils.getTextKit(c), data, action);
}
@@ -223,7 +220,7 @@ public abstract class BasicTextUI extend
}
public void exportAsDrag(final JComponent comp, final InputEvent ie,
- final int action) {
+ final int action) {
isDrag = true;
super.exportAsDrag(comp, ie, action);
}
@@ -235,7 +232,7 @@ public abstract class BasicTextUI extend
*/
public void changedUpdate(final DocumentEvent e) {
getRootView().changedUpdate(e, getVisibleEditorRect(),
- getRootView().getViewFactory());
+ getRootView().getViewFactory());
}
/**
@@ -243,7 +240,7 @@ public abstract class BasicTextUI extend
* Otherwise, call rooView.insertUpdate
*/
public void insertUpdate(final DocumentEvent e) {
- boolean currentI18nProperty = ((Boolean)document
+ boolean currentI18nProperty = ((Boolean) document
.getProperty(StringConstants.BIDI_PROPERTY)).booleanValue();
if (currentI18nProperty && !i18nProperty) {
needLock = false;
@@ -252,7 +249,7 @@ public abstract class BasicTextUI extend
i18nProperty = true;
} else {
getRootView().insertUpdate(e, getVisibleEditorRect(),
- getRootView().getViewFactory());
+ getRootView().getViewFactory());
}
}
@@ -260,8 +257,8 @@ public abstract class BasicTextUI extend
* Call rootView.removeUpdate
*/
public void removeUpdate(final DocumentEvent e) {
- getRootView().removeUpdate(e, getVisibleEditorRect(), getRootView()
- .getViewFactory());
+ getRootView().removeUpdate(e, getVisibleEditorRect(),
+ getRootView().getViewFactory());
}
/**
@@ -282,16 +279,16 @@ public abstract class BasicTextUI extend
}
Object doc = e.getNewValue();
if (doc != null) {
- setDocument((Document)doc);
+ setDocument((Document) doc);
document.addDocumentListener(listener);
modelChanged();
}
} else if (StringConstants.COMPONENT_ORIENTATION.equals(name)) {
- modelChanged();
-
+ modelChanged();
- } else if (JTextComponent.FOCUS_ACCELERATOR_KEY.equals(name)) {
- lastFocusAccelerator = ((Character)e.getOldValue()).charValue();
+ } else if (JTextComponent.FOCUS_ACCELERATOR_KEY.equals(name)) {
+ lastFocusAccelerator = ((Character) e.getOldValue())
+ .charValue();
updateFocusAcceleratorBinding(true);
}
propertyChangeImpl(e);
@@ -304,11 +301,11 @@ public abstract class BasicTextUI extend
* component.getDropTarget()
*/
final class DropListener implements DropTargetListener {
- String str = null;
+ String str = null;
- int start = 0;
+ int start = 0;
- int end = 0;
+ int end = 0;
JTextComponent textComponent;
@@ -326,8 +323,7 @@ public abstract class BasicTextUI extend
* e.getTransferable(); start = textComponent.getSelectionStart();
* end = textComponent.getSelectionEnd(); try { str = (String) t
* .getTransferData(DataFlavor.stringFlavor); } catch (final
- * UnsupportedFlavorException ufe) { } catch (final IOException
- * ioe) {}
+ * UnsupportedFlavorException ufe) { } catch (final IOException ioe) {}
*/
}
@@ -347,7 +343,7 @@ public abstract class BasicTextUI extend
}
}
textComponent.getDocument().insertString(insertPosition, str,
- null);
+ null);
textComponent.replaceSelection("");
textComponent.setCaretPosition(insertPosition + length);
@@ -366,7 +362,7 @@ public abstract class BasicTextUI extend
public void mousePressed(final MouseEvent arg0) {
String selectedText = component.getSelectedText();
if (selectedText != null && selectedText != ""
- && component.getDragEnabled()) {
+ && component.getDragEnabled()) {
wasMousePressed = true;
}
}
@@ -374,8 +370,8 @@ public abstract class BasicTextUI extend
public void mouseDragged(final MouseEvent me) {
if (wasMousePressed) {
wasMousePressed = false;
- component.getTransferHandler()
- .exportAsDrag(component, me, TransferHandler.MOVE);
+ component.getTransferHandler().exportAsDrag(component, me,
+ TransferHandler.MOVE);
}
}
}
@@ -415,14 +411,13 @@ public abstract class BasicTextUI extend
Object bindings = UIManager.get(addPrefix(".keyBindings"));
if (bindings != null) {
JTextComponent.loadKeymap(keymap,
- (JTextComponent.KeyBinding[])bindings,
- component.getActions());
+ (JTextComponent.KeyBinding[]) bindings, component
+ .getActions());
}
return keymap;
}
- public void damageRange(final JTextComponent c, final int p0,
- final int p1) {
+ public void damageRange(final JTextComponent c, final int p0, final int p1) {
damageRange(c, p0, p1, Position.Bias.Forward, Position.Bias.Forward);
}
@@ -431,11 +426,11 @@ public abstract class BasicTextUI extend
* biases. Then call component.repaint(r.x, r.y, r.width, r.height)
*/
public void damageRange(final JTextComponent c, final int p0, final int p1,
- final Position.Bias b1, final Position.Bias b2) {
+ final Position.Bias b1, final Position.Bias b2) {
Shape shape = null;
try {
- shape = getRootView()
- .modelToView(p0, b1, p1, b2, getVisibleEditorRect());
+ shape = getRootView().modelToView(p0, b1, p1, b2,
+ getVisibleEditorRect());
} catch (final BadLocationException e) {
}
Rectangle rect;
@@ -463,7 +458,7 @@ public abstract class BasicTextUI extend
}
public Dimension getMaximumSize(final JComponent c) {
- //See description for getRootView().getMaximumSpan
+ // See description for getRootView().getMaximumSpan
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
@@ -473,26 +468,22 @@ public abstract class BasicTextUI extend
public Dimension getMinimumSize(final JComponent c) {
Insets insets = c.getInsets();
int minX = TextUtils.getHrzInsets(insets)
- + (int)getRootView().getMinimumSpan(View.X_AXIS);
+ + (int) getRootView().getMinimumSpan(View.X_AXIS);
int minY = TextUtils.getVrtInsets(insets)
- + (int)getRootView().getMinimumSpan(View.Y_AXIS);
+ + (int) getRootView().getMinimumSpan(View.Y_AXIS);
return new Dimension(minX, minY);
}
-
/**
* Calls getNextVisualPosition on root view. If root view returns -1, then
* this method will return p0 and biasRet[0] will be the same as bias
*/
public int getNextVisualPositionFrom(final JTextComponent c, final int p0,
- final Position.Bias bias,
- final int p1,
- final Position.Bias[] biasRet)
- throws BadLocationException {
+ final Position.Bias bias, final int p1,
+ final Position.Bias[] biasRet) throws BadLocationException {
int pos = getRootView().getNextVisualPositionFrom(p0, bias,
- getVisibleEditorRect(),
- p1, biasRet);
+ getVisibleEditorRect(), p1, biasRet);
if (pos == -1) {
pos = p0;
biasRet[0] = bias;
@@ -506,9 +497,9 @@ public abstract class BasicTextUI extend
public Dimension getPreferredSize(final JComponent c) {
Insets insets = c.getInsets();
int prefX = TextUtils.getHrzInsets(insets)
- + (int)getRootView().getPreferredSpan(View.X_AXIS);
+ + (int) getRootView().getPreferredSpan(View.X_AXIS);
int prefY = TextUtils.getVrtInsets(insets)
- + (int)getRootView().getPreferredSpan(View.Y_AXIS);
+ + (int) getRootView().getPreferredSpan(View.Y_AXIS);
return new Dimension(prefX, prefY);
}
@@ -534,7 +525,8 @@ public abstract class BasicTextUI extend
* Returns, component getSize, excluding insets.
*/
protected Rectangle getVisibleEditorRect() {
- return TextUtils.getEditorRect(component);
+ return org.apache.harmony.x.swing.text.TextUtils
+ .getEditorRect(component);
}
final String addPrefix(final String property) {
@@ -543,23 +535,22 @@ public abstract class BasicTextUI extend
protected void installDefaults() {
LookAndFeel.installColorsAndFont(component, addPrefix(".background"),
- addPrefix(".foreground"),
- addPrefix(".font"));
+ addPrefix(".foreground"), addPrefix(".font"));
if (Utilities.isUIResource(component.getBorder())) {
component.setBorder(UIManager.getBorder(addPrefix(".border")));
}
if (Utilities.isUIResource(component.getMargin())) {
component.setMargin(UIManager.getInsets(addPrefix(".margin")));
}
- //RI 6251901. Documentation error
+ // RI 6251901. Documentation error
if (Utilities.isUIResource(component.getCaretColor())) {
- component.setCaretColor(UIManager.getColor(addPrefix(
- ".caretForeground")));
+ component.setCaretColor(UIManager
+ .getColor(addPrefix(".caretForeground")));
}
if (Utilities.isUIResource(component.getSelectionColor())) {
- component.setSelectionColor(UIManager.getColor(addPrefix(
- ".selectionBackground")));
+ component.setSelectionColor(UIManager
+ .getColor(addPrefix(".selectionBackground")));
}
if (Utilities.isUIResource(component.getSelectedTextColor())) {
@@ -568,74 +559,70 @@ public abstract class BasicTextUI extend
}
if (Utilities.isUIResource(component.getDisabledTextColor())) {
- component.setDisabledTextColor(UIManager.getColor(addPrefix(
- ".inactiveForeground")));
+ component.setDisabledTextColor(UIManager
+ .getColor(addPrefix(".inactiveForeground")));
}
}
final Set getDefaultFocusTraversalKeys(final int mode) {
- Set result = component.getFocusTraversalKeys(mode);
-
- if (result == null) {
- result = new LinkedHashSet();
- if (mode == KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS) {
- result.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
- InputEvent.CTRL_DOWN_MASK));
- } else {
- result.add(KeyStroke
- .getKeyStroke(KeyEvent.VK_TAB,
- InputEvent.CTRL_DOWN_MASK
- | InputEvent.SHIFT_DOWN_MASK));
- }
- } else {
- result = new LinkedHashSet(result);
- }
-
- return result;
- }
+ Set result = component.getFocusTraversalKeys(mode);
+
+ if (result == null) {
+ result = new LinkedHashSet();
+ if (mode == KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS) {
+ result.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
+ InputEvent.CTRL_DOWN_MASK));
+ } else {
+ result
+ .add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
+ InputEvent.CTRL_DOWN_MASK
+ | InputEvent.SHIFT_DOWN_MASK));
+ }
+ } else {
+ result = new LinkedHashSet(result);
+ }
+
+ return result;
+ }
void updateFocusTraversalKeys() {
if (component == null) {
return;
}
- Set forwardFocusTraversalKeys =
- getDefaultFocusTraversalKeys(KeyboardFocusManager
- .FORWARD_TRAVERSAL_KEYS);
- Set backwardFocusTraversalKeys =
- getDefaultFocusTraversalKeys(KeyboardFocusManager
- .BACKWARD_TRAVERSAL_KEYS);
+ Set forwardFocusTraversalKeys = getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ Set backwardFocusTraversalKeys = getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
KeyStroke tabPressed = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
- KeyStroke shiftTabPressed = KeyStroke
- .getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK);
-
+ KeyStroke shiftTabPressed = KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
+ InputEvent.SHIFT_DOWN_MASK);
+
if (component.isEditable()) {
forwardFocusTraversalKeys.remove(tabPressed);
backwardFocusTraversalKeys.remove(shiftTabPressed);
} else {
if (!forwardFocusTraversalKeys.contains(tabPressed)) {
- forwardFocusTraversalKeys.add(tabPressed);
+ forwardFocusTraversalKeys.add(tabPressed);
}
if (!forwardFocusTraversalKeys.contains(shiftTabPressed)) {
- backwardFocusTraversalKeys.add(shiftTabPressed);
+ backwardFocusTraversalKeys.add(shiftTabPressed);
}
}
- component.setFocusTraversalKeys(KeyboardFocusManager
- .FORWARD_TRAVERSAL_KEYS,
- forwardFocusTraversalKeys);
- component.setFocusTraversalKeys(KeyboardFocusManager
- .BACKWARD_TRAVERSAL_KEYS,
- backwardFocusTraversalKeys);
- }
+ component.setFocusTraversalKeys(
+ KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
+ forwardFocusTraversalKeys);
+ component.setFocusTraversalKeys(
+ KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
+ backwardFocusTraversalKeys);
+ }
final void installUIInputMap() {
String propertyName = addPrefix(".focusInputMap");
InputMapUIResource inputMap1 = new InputMapUIResource();
- InputMapUIResource inputMap2 = (InputMapUIResource)UIManager
+ InputMapUIResource inputMap2 = (InputMapUIResource) UIManager
.get(propertyName);
inputMap1.setParent(inputMap2);
SwingUtilities.replaceUIInputMap(component, JComponent.WHEN_FOCUSED,
- inputMap1);
+ inputMap1);
}
final void putActionToActionMap(final Action a, final ActionMap map) {
@@ -664,14 +651,14 @@ public abstract class BasicTextUI extend
uiDefaults.put(propertyName, map);
}
}
- actionMap1.setParent((ActionMap)actionMap2);
+ actionMap1.setParent((ActionMap) actionMap2);
SwingUtilities.replaceUIActionMap(component, actionMap1);
}
/**
* Sets InputMap(JComponent.WHEN_FOCUSED), ActionMap, Keymap on
* TextComponent.
- *
+ *
*/
protected void installKeyboardActions() {
installUIActionMap();
@@ -687,20 +674,20 @@ public abstract class BasicTextUI extend
if (!(c instanceof JTextComponent)) {
throw new Error(Messages.getString("swing.B1")); //$NON-NLS-1$
}
-
+
super.installUI(c);
- setComponent((JTextComponent)c);
+ setComponent((JTextComponent) c);
installDefaults();
LookAndFeel.installProperty(component, StringConstants.OPAQUE_PROPERTY,
- Boolean.TRUE);
+ Boolean.TRUE);
if (Utilities.isUIResource(component.getCaret())) {
Caret caret = createCaret();
component.setCaret(caret);
caret.setBlinkRate(UIManager.getInt(getPropertyPrefix()
- + ".caretBlinkRate"));
+ + ".caretBlinkRate"));
}
if (Utilities.isUIResource(component.getHighlighter())) {
@@ -720,7 +707,7 @@ public abstract class BasicTextUI extend
modelChanged();
- ((AbstractDocument)component.getDocument())
+ ((AbstractDocument) component.getDocument())
.addDocumentListener(listener);
component.addPropertyChangeListener(listener);
JTextComponent.addKeymap(getKeymapName(), JTextComponent
@@ -734,11 +721,11 @@ public abstract class BasicTextUI extend
component.setAutoscrolls(true);
updateFocusAcceleratorBinding(true);
- //DnD support
+ // DnD support
// java.awt.Component doesn't support DnD
/*
- * try { component.getDropTarget().addDropTargetListener(dropListener);
- * } catch (final TooManyListenersException e){}
+ * try { component.getDropTarget().addDropTargetListener(dropListener); }
+ * catch (final TooManyListenersException e){}
*/
component.addMouseListener(gestureRecognizer);
component.addMouseMotionListener(gestureRecognizer);
@@ -747,7 +734,7 @@ public abstract class BasicTextUI extend
/**
* Rebuilts view hierarchy.
- *
+ *
*/
protected void modelChanged() {
final Document doc = document;
@@ -757,8 +744,8 @@ public abstract class BasicTextUI extend
}
try {
setDocument(document);
- View view = getRootView().getViewFactory()
- .create(document.getDefaultRootElement());
+ View view = getRootView().getViewFactory().create(
+ document.getDefaultRootElement());
setView(view);
setViewSize();
} finally {
@@ -777,10 +764,9 @@ public abstract class BasicTextUI extend
}
public Rectangle modelToView(final JTextComponent comp, final int p,
- final Position.Bias b)
- throws BadLocationException {
+ final Position.Bias b) throws BadLocationException {
final Document doc = document;
-
+
readLock(doc);
try {
Rectangle r = null;
@@ -793,15 +779,15 @@ public abstract class BasicTextUI extend
r = shape.getBounds();
}
}
- }
- return r;
+ }
+ return r;
} finally {
readUnlock(doc);
}
}
public final void paint(final Graphics g, final JComponent c) {
- //super.paint(g, c);//???
+ // super.paint(g, c);//???
paintSafely(g);
}
@@ -820,9 +806,9 @@ public abstract class BasicTextUI extend
if (!isActive) {
return;
}
-
+
final Document doc = document;
-
+
readLock(doc);
try {
Highlighter highlighter = component.getHighlighter();
@@ -908,7 +894,7 @@ public abstract class BasicTextUI extend
/**
* Sets ActionMap and Keymap of TextComponent to null.
- *
+ *
*/
protected void uninstallKeyboardActions() {
component.setKeymap(null);
@@ -940,8 +926,8 @@ public abstract class BasicTextUI extend
.removeDocumentListener(listener);
component.removePropertyChangeListener(listener);
- //DnD support
- //java.awt.Component doesn't support DnD
+ // DnD support
+ // java.awt.Component doesn't support DnD
/*
* component.getDropTarget().removeDropTargetListener(dropListener);
*/
@@ -961,28 +947,27 @@ public abstract class BasicTextUI extend
}
char accelerator = component.getFocusAccelerator();
InputMap im = SwingUtilities.getUIInputMap(component,
- JComponent.WHEN_IN_FOCUSED_WINDOW);
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
boolean wasInputMap = (im != null);
boolean needToRemove = (lastFocusAccelerator != '\0');
boolean needToAdd = (accelerator != '\0');
if (needToAdd) {
if (needToRemove && wasInputMap) {
im.remove(KeyStroke.getKeyStroke(lastFocusAccelerator,
- InputEvent.ALT_DOWN_MASK));
+ InputEvent.ALT_DOWN_MASK));
} else if (!wasInputMap) {
im = new ComponentInputMapUIResource(component);
im.put(KeyStroke.getKeyStroke(accelerator,
- InputEvent.ALT_DOWN_MASK),
- FOCUS_ACTION_NAME);
+ InputEvent.ALT_DOWN_MASK), FOCUS_ACTION_NAME);
if (!wasInputMap) {
SwingUtilities.replaceUIInputMap(component,
- JComponent.WHEN_IN_FOCUSED_WINDOW, im);
+ JComponent.WHEN_IN_FOCUSED_WINDOW, im);
}
- } else if (wasInputMap) {
- im.remove(KeyStroke.getKeyStroke(lastFocusAccelerator,
- InputEvent.ALT_DOWN_MASK));
- }
+ } else if (wasInputMap) {
+ im.remove(KeyStroke.getKeyStroke(lastFocusAccelerator,
+ InputEvent.ALT_DOWN_MASK));
+ }
}
}
@@ -991,7 +976,7 @@ public abstract class BasicTextUI extend
}
public int viewToModel(final JTextComponent c, final Point p,
- final Position.Bias[] b) {
+ final Position.Bias[] b) {
return getRootView().viewToModel(p.x, p.y, getVisibleEditorRect(), b);
}
@@ -1004,21 +989,19 @@ public abstract class BasicTextUI extend
private void readLock(final Document doc) {
if (doc instanceof AbstractDocument) {
- ((AbstractDocument)doc).readLock();
+ ((AbstractDocument) doc).readLock();
}
}
private void readUnlock(final Document doc) {
if (doc instanceof AbstractDocument) {
- ((AbstractDocument)doc).readUnlock();
+ ((AbstractDocument) doc).readUnlock();
}
}
final boolean getI18nProperty() {
- return document == null
- ? false
- : ((Boolean)document.getProperty(StringConstants.BIDI_PROPERTY))
- .booleanValue();
+ return document == null ? false : ((Boolean) document
+ .getProperty(StringConstants.BIDI_PROPERTY)).booleanValue();
}
private View getRootView() {
@@ -1042,5 +1025,3 @@ public abstract class BasicTextUI extend
setDocument(document);
}
}
-
-