You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/25 21:05:24 UTC
svn commit: r479184 -
/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/
Author: ndbeyer
Date: Sat Nov 25 12:05:22 2006
New Revision: 479184
URL: http://svn.apache.org/viewvc?view=rev&rev=479184
Log:
Cleanup
* add missing annotations
* add serialVersionUID fields and comments
* format code
Modified:
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/CellRendererPane.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ComponentInputMap.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultBoundedRangeModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultCellEditor.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultComboBoxModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultDesktopManager.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListCellRenderer.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenu.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSpinner.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTabbedPane.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTable.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTree.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ProgressMonitor.java
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java Sat Nov 25 12:05:22 2006
@@ -58,7 +58,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public abstract class AbstractButton extends JComponent implements ItemSelectable,
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/CellRendererPane.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/CellRendererPane.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/CellRendererPane.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/CellRendererPane.java Sat Nov 25 12:05:22 2006
@@ -32,7 +32,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class CellRendererPane extends Container implements Accessible {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ComponentInputMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ComponentInputMap.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ComponentInputMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ComponentInputMap.java Sat Nov 25 12:05:22 2006
@@ -24,7 +24,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class ComponentInputMap extends InputMap {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DebugGraphics.java Sat Nov 25 12:05:22 2006
@@ -43,7 +43,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class DebugGraphics extends Graphics {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultBoundedRangeModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultBoundedRangeModel.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultBoundedRangeModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultBoundedRangeModel.java Sat Nov 25 12:05:22 2006
@@ -29,7 +29,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java Sat Nov 25 12:05:22 2006
@@ -34,7 +34,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class DefaultButtonModel implements ButtonModel, Serializable {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultCellEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultCellEditor.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultCellEditor.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultCellEditor.java Sat Nov 25 12:05:22 2006
@@ -15,10 +15,6 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
package javax.swing;
import java.awt.Component;
@@ -29,37 +25,49 @@
import java.awt.event.MouseEvent;
import java.io.Serializable;
import java.util.EventObject;
-
import javax.swing.table.TableCellEditor;
import javax.swing.tree.TreeCellEditor;
-
import org.apache.harmony.x.swing.StringConstants;
-public class DefaultCellEditor extends AbstractCellEditor implements TableCellEditor, TreeCellEditor {
+/**
+ * <p>
+ * <i>DefaultCellEditor</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
+public class DefaultCellEditor extends AbstractCellEditor implements TableCellEditor,
+ TreeCellEditor {
+ private static final long serialVersionUID = 3564035141373880027L;
+
protected class EditorDelegate implements ActionListener, ItemListener, Serializable {
+ private static final long serialVersionUID = -1953114537286696317L;
+
protected Object value;
public Object getCellEditorValue() {
return value;
}
- public void setValue(final Object value) {
+ public void setValue(Object value) {
this.value = value;
}
- public boolean isCellEditable(final EventObject event) {
+ public boolean isCellEditable(EventObject event) {
if (event instanceof MouseEvent) {
- return ((MouseEvent)event).getClickCount() >= clickCountToStart;
+ return ((MouseEvent) event).getClickCount() >= clickCountToStart;
}
-
return true;
}
- public boolean shouldSelectCell(final EventObject event) {
+ public boolean shouldSelectCell(EventObject event) {
return true;
}
- public boolean startCellEditing(final EventObject event) {
+ public boolean startCellEditing(EventObject event) {
return true;
}
@@ -72,28 +80,33 @@
fireEditingCanceled();
}
- public void actionPerformed(final ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
DefaultCellEditor.this.stopCellEditing();
}
- public void itemStateChanged(final ItemEvent e) {
+ public void itemStateChanged(ItemEvent e) {
DefaultCellEditor.this.stopCellEditing();
}
}
protected JComponent editorComponent;
+
protected EditorDelegate delegate;
- protected int clickCountToStart;
+ protected int clickCountToStart;
public DefaultCellEditor(final JTextField textField) {
editorComponent = textField;
delegate = new EditorDelegate() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public Object getCellEditorValue() {
return textField.getText();
}
- public void setValue(final Object value) {
+ @Override
+ public void setValue(Object value) {
textField.setText(value != null ? value.toString() : null);
}
};
@@ -104,12 +117,17 @@
public DefaultCellEditor(final JCheckBox checkBox) {
editorComponent = checkBox;
delegate = new EditorDelegate() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public Object getCellEditorValue() {
return Boolean.valueOf(checkBox.isSelected());
}
- public void setValue(final Object value) {
- checkBox.setSelected(value != null ? Boolean.valueOf(value.toString()).booleanValue() : false);
+ @Override
+ public void setValue(Object value) {
+ checkBox.setSelected(value != null ? Boolean.parseBoolean(value.toString())
+ : false);
}
};
checkBox.setFocusable(false);
@@ -120,17 +138,20 @@
public DefaultCellEditor(final JComboBox comboBox) {
editorComponent = comboBox;
delegate = new EditorDelegate() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public Object getCellEditorValue() {
return comboBox.getSelectedItem();
}
- public void setValue(final Object value) {
+ @Override
+ public void setValue(Object value) {
comboBox.setSelectedItem(value);
}
};
comboBox.addActionListener(delegate);
setClickCountToStart(1);
-
comboBox.putClientProperty(StringConstants.IS_TABLE_EDITOR, Boolean.TRUE);
}
@@ -138,7 +159,7 @@
return editorComponent;
}
- public void setClickCountToStart(final int count) {
+ public void setClickCountToStart(int count) {
clickCountToStart = count;
}
@@ -150,39 +171,34 @@
return delegate.getCellEditorValue();
}
- public boolean isCellEditable(final EventObject event) {
+ @Override
+ public boolean isCellEditable(EventObject event) {
return delegate.isCellEditable(event);
}
- public boolean shouldSelectCell(final EventObject event) {
+ @Override
+ public boolean shouldSelectCell(EventObject event) {
return delegate.shouldSelectCell(event);
}
+ @Override
public boolean stopCellEditing() {
return delegate.stopCellEditing();
}
+ @Override
public void cancelCellEditing() {
delegate.cancelCellEditing();
}
- public Component getTreeCellEditorComponent(final JTree tree,
- final Object value,
- final boolean isSelected,
- final boolean expanded,
- final boolean leaf,
- final int row) {
-
+ public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected,
+ boolean expanded, boolean leaf, int row) {
delegate.setValue(value);
return getComponent();
}
- public Component getTableCellEditorComponent(final JTable table,
- final Object value,
- final boolean isSelected,
- final int row,
- final int column) {
-
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row, int column) {
delegate.setValue(value);
return getComponent();
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultComboBoxModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultComboBoxModel.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultComboBoxModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultComboBoxModel.java Sat Nov 25 12:05:22 2006
@@ -15,26 +15,26 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
-
package javax.swing;
import java.util.Arrays;
import java.util.Vector;
+@SuppressWarnings("unchecked")
public class DefaultComboBoxModel extends AbstractListModel implements MutableComboBoxModel {
private static final long serialVersionUID = 3906372640380892983L;
+
private Vector listData;
+
private Object selection;
public DefaultComboBoxModel() {
+ super();
listData = new Vector();
}
- public DefaultComboBoxModel(final Object[] items) {
+ public DefaultComboBoxModel(Object[] items) {
+ super();
listData = new Vector();
listData.addAll(Arrays.asList(items));
if (items.length > 0) {
@@ -42,14 +42,14 @@
}
}
- public DefaultComboBoxModel(final Vector<?> items) {
+ public DefaultComboBoxModel(Vector items) {
listData = items;
if (items.size() > 0) {
selection = items.get(0);
}
}
- public void addElement(final Object element) {
+ public void addElement(Object element) {
listData.add(element);
fireIntervalAdded(this, listData.size() - 1, listData.size() - 1);
if (getSelectedItem() == null) {
@@ -57,11 +57,11 @@
}
}
- public Object getElementAt(final int index) {
+ public Object getElementAt(int index) {
return index < getSize() ? listData.get(index) : null;
}
- public int getIndexOf(final Object element) {
+ public int getIndexOf(Object element) {
return listData.indexOf(element);
}
@@ -69,7 +69,7 @@
return listData.size();
}
- public void insertElementAt(final Object element, final int index) {
+ public void insertElementAt(Object element, int index) {
listData.insertElementAt(element, index);
fireIntervalAdded(this, index, index);
}
@@ -83,20 +83,18 @@
selection = null;
}
- public void removeElement(final Object element) {
+ public void removeElement(Object element) {
int index = getIndexOf(element);
if (index != -1) {
removeElementAt(index);
}
}
- public void removeElementAt(final int index) {
+ public void removeElementAt(int index) {
Object removingElement = getElementAt(index);
listData.remove(index);
-
- if (selection == removingElement
- || selection != null && selection.equals(removingElement)) {
-
+ if (selection == removingElement || selection != null
+ && selection.equals(removingElement)) {
if (index == 0 && getSize() > 0) {
setSelectedItem(getElementAt(0));
} else if (index > 0) {
@@ -105,19 +103,16 @@
setSelectedItem(null);
}
}
-
fireIntervalRemoved(this, index, index);
}
-
public Object getSelectedItem() {
- return selection;
+ return selection;
}
- public void setSelectedItem(final Object element) {
- if (element != null && !element.equals(selection)
- || element == null && selection != null) {
-
+ public void setSelectedItem(Object element) {
+ if (element != null && !element.equals(selection) || element == null
+ && selection != null) {
selection = element;
fireContentsChanged(this, -1, -1);
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultDesktopManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultDesktopManager.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultDesktopManager.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultDesktopManager.java Sat Nov 25 12:05:22 2006
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
- * @author Vadim L. Bogdanov
- * @version $Revision$
- */
-
package javax.swing;
import java.awt.Color;
@@ -35,82 +30,89 @@
import org.apache.harmony.x.swing.Utilities;
-
+/**
+ * <p>
+ * <i>DefaultDesktopManager</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class DefaultDesktopManager implements DesktopManager, Serializable {
+ private static final long serialVersionUID = 3138850139820361176L;
+
private static final String WAS_ICON_PROPERTY = "wasIcon";
private transient boolean isOutlineDragging;
+
private transient Rectangle prevOutlineBounds;
+
// is true if we have begun to drag/resize but didn't move the mouse
private transient boolean shouldClearOutline = true;
- public void minimizeFrame(final JInternalFrame f) {
+ public void minimizeFrame(JInternalFrame f) {
Rectangle bounds = getPreviousBounds(f);
setBoundsForFrame(f, bounds.x, bounds.y, bounds.width, bounds.height);
}
- public void maximizeFrame(final JInternalFrame f) {
+ public void maximizeFrame(JInternalFrame f) {
Container desktop = f.getParent();
if (desktop == null) {
return;
}
-
setPreviousBounds(f, f.getBounds());
Rectangle innerBounds = getInnerBounds(desktop);
- setBoundsForFrame(f, innerBounds.x, innerBounds.y,
- innerBounds.width, innerBounds.height);
-
+ setBoundsForFrame(f, innerBounds.x, innerBounds.y, innerBounds.width,
+ innerBounds.height);
try {
f.setSelected(true);
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
}
- public void iconifyFrame(final JInternalFrame f) {
+ public void iconifyFrame(JInternalFrame f) {
Container desktop = f.getParent();
if (desktop == null) {
return;
}
-
if (!wasIcon(f)) {
f.getDesktopIcon().setBounds(getBoundsForIconOf(f));
}
JLayeredPane.putLayer(f.getDesktopIcon(), f.getLayer());
try {
f.setSelected(false);
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
desktop.remove(f);
desktop.add(f.getDesktopIcon());
setWasIcon(f, Boolean.TRUE);
moveSelectionToNextFrame(desktop);
-
repaint(desktop, f.getBounds());
}
- public void deiconifyFrame(final JInternalFrame f) {
+ public void deiconifyFrame(JInternalFrame f) {
addFrame(f, true);
}
- public void openFrame(final JInternalFrame f) {
+ public void openFrame(JInternalFrame f) {
addFrame(f, false);
}
- public void deactivateFrame(final JInternalFrame f) {
+ public void deactivateFrame(JInternalFrame f) {
JDesktopPane desktop = f.getDesktopPane();
if (desktop != null) {
desktop.setSelectedFrame(null);
}
}
- public void closeFrame(final JInternalFrame f) {
+ public void closeFrame(JInternalFrame f) {
try {
f.setSelected(false);
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
-
removeIconFor(f);
-
Container desktop = f.getParent();
if (desktop == null) {
return;
@@ -120,33 +122,30 @@
moveSelectionToNextFrame(desktop);
}
- public void activateFrame(final JInternalFrame f) {
+ public void activateFrame(JInternalFrame f) {
JDesktopPane desktop = f.getDesktopPane();
if (desktop == null || desktop.getSelectedFrame() == f) {
return;
}
-
if (desktop.getSelectedFrame() != null) {
try {
desktop.getSelectedFrame().setSelected(false);
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
}
desktop.moveToFront(f);
desktop.setSelectedFrame(f);
}
- public void setBoundsForFrame(final JComponent f, final int x, final int y,
- final int width, final int height) {
+ public void setBoundsForFrame(JComponent f, int x, int y, int width, int height) {
f.setBounds(x, y, width, height);
}
- public void beginResizingFrame(final JComponent f, final int direction) {
+ public void beginResizingFrame(JComponent f, int direction) {
beginDragFrameOperation(f);
}
- public void resizeFrame(final JComponent f, final int x, final int y,
- final int width, final int height) {
+ public void resizeFrame(JComponent f, int x, int y, int width, int height) {
if (isOutlineDragging) {
moveFrameOutline(f, x, y, width, height);
} else {
@@ -154,71 +153,62 @@
}
}
- public void endResizingFrame(final JComponent f) {
+ public void endResizingFrame(JComponent f) {
endDragFrameOperation(f);
}
- public void beginDraggingFrame(final JComponent f) {
+ public void beginDraggingFrame(JComponent f) {
beginDragFrameOperation(f);
}
- public void dragFrame(final JComponent f, final int x, final int y) {
+ public void dragFrame(JComponent f, int x, int y) {
if (isOutlineDragging) {
- moveFrameOutline(f, x, y,
- prevOutlineBounds.width, prevOutlineBounds.height);
+ moveFrameOutline(f, x, y, prevOutlineBounds.width, prevOutlineBounds.height);
} else {
setBoundsForFrame(f, x, y, f.getWidth(), f.getHeight());
}
}
- public void endDraggingFrame(final JComponent f) {
+ public void endDraggingFrame(JComponent f) {
endDragFrameOperation(f);
}
- protected void setWasIcon(final JInternalFrame f, final Boolean value) {
+ protected void setWasIcon(JInternalFrame f, Boolean value) {
f.putClientProperty(WAS_ICON_PROPERTY, value);
}
- protected boolean wasIcon(final JInternalFrame f) {
+ protected boolean wasIcon(JInternalFrame f) {
Object value = f.getClientProperty(WAS_ICON_PROPERTY);
- return value instanceof Boolean ? ((Boolean)value).booleanValue() : false;
+ return value instanceof Boolean ? ((Boolean) value).booleanValue() : false;
}
- protected void setPreviousBounds(final JInternalFrame f,
- final Rectangle bounds) {
+ protected void setPreviousBounds(JInternalFrame f, Rectangle bounds) {
f.setNormalBounds(bounds);
}
- protected Rectangle getPreviousBounds(final JInternalFrame f) {
+ protected Rectangle getPreviousBounds(JInternalFrame f) {
return f.getNormalBounds();
}
- protected Rectangle getBoundsForIconOf(final JInternalFrame f) {
+ protected Rectangle getBoundsForIconOf(JInternalFrame f) {
if (wasIcon(f)) {
return f.getDesktopIcon().getBounds();
}
-
Dimension iconSize = f.getDesktopIcon().getSize();
Rectangle result = new Rectangle(0, 0, iconSize.width, iconSize.height);
-
Container desktop = f.getParent();
if (desktop == null) {
return result;
}
-
Rectangle innerBounds = getInnerBounds(desktop);
// maximum x position
int totalWidth = innerBounds.width - iconSize.width;
if (totalWidth < 0) {
totalWidth = 0;
}
-
- result.y = (int)innerBounds.getMaxY() - iconSize.height;
+ result.y = (int) innerBounds.getMaxY() - iconSize.height;
while (true) {
- for (result.x = innerBounds.x;
- result.x <= totalWidth;
- result.x += iconSize.width) {
-
+ for (result.x = innerBounds.x; result.x <= totalWidth; result.x += iconSize.width) {
if (isFreeDesktopIconPosition(desktop, result)) {
return result;
}
@@ -227,21 +217,18 @@
}
}
- protected void removeIconFor(final JInternalFrame f) {
+ protected void removeIconFor(JInternalFrame f) {
Container desktop = f.getDesktopIcon().getParent();
if (desktop == null) {
return;
}
-
desktop.remove(f.getDesktopIcon());
repaint(desktop, f.getDesktopIcon().getBounds());
}
- private boolean isFreeDesktopIconPosition(final Container desktop,
- final Rectangle bounds) {
+ private boolean isFreeDesktopIconPosition(Container desktop, Rectangle bounds) {
for (int i = 0; i < desktop.getComponentCount(); i++) {
Component c = desktop.getComponent(i);
-
Rectangle occupiedBouds = null;
if (c instanceof JInternalFrame.JDesktopIcon) {
occupiedBouds = c.getBounds();
@@ -251,7 +238,6 @@
occupiedBouds = f.getDesktopIcon().getBounds();
}
}
-
if (occupiedBouds != null && bounds.intersects(occupiedBouds)) {
return false;
}
@@ -259,26 +245,25 @@
return true;
}
- private void moveSelectionToNextFrame(final Container desktop) {
+ private void moveSelectionToNextFrame(Container desktop) {
for (int i = 0; i < desktop.getComponentCount(); i++) {
if (desktop.getComponent(i) instanceof JInternalFrame) {
try {
- ((JInternalFrame)desktop.getComponent(i)).setSelected(true);
+ ((JInternalFrame) desktop.getComponent(i)).setSelected(true);
break;
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
}
}
}
- private void paintOutline(final JComponent f, final int x, final int y,
- final int width, final int height) {
+ private void paintOutline(JComponent f, int x, int y, int width, int height) {
Graphics g = f.getParent().getGraphics();
g = g.create();
g.setXORMode(Color.WHITE);
if (shouldClearOutline) {
- g.drawRect(prevOutlineBounds.x, prevOutlineBounds.y,
- prevOutlineBounds.width - 1, prevOutlineBounds.height - 1);
+ g.drawRect(prevOutlineBounds.x, prevOutlineBounds.y, prevOutlineBounds.width - 1,
+ prevOutlineBounds.height - 1);
} else {
shouldClearOutline = true;
}
@@ -286,17 +271,15 @@
g.dispose();
}
- private void repaint(final Container desktop, final Rectangle clipRect) {
- desktop.repaint(clipRect.x, clipRect.y,
- clipRect.width, clipRect.height);
+ private void repaint(Container desktop, Rectangle clipRect) {
+ desktop.repaint(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
}
- private void addFrame(final JInternalFrame f, final boolean select) {
+ private void addFrame(JInternalFrame f, boolean select) {
Container desktop = f.getDesktopIcon().getParent();
if (desktop == null) {
return;
}
-
removeIconFor(f);
if (!select) {
desktop.add(f);
@@ -304,18 +287,17 @@
desktop.add(f, 0);
try {
f.setSelected(true);
- } catch (final PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
}
}
}
- private void beginDragFrameOperation(final JComponent f) {
+ private void beginDragFrameOperation(JComponent f) {
isOutlineDragging = false;
if (!(f.getParent() instanceof JDesktopPane)) {
return;
}
-
- JDesktopPane desktop = (JDesktopPane)f.getParent();
+ JDesktopPane desktop = (JDesktopPane) f.getParent();
if (desktop.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE) {
isOutlineDragging = true;
prevOutlineBounds = f.getBounds(prevOutlineBounds);
@@ -323,23 +305,21 @@
}
}
- private void endDragFrameOperation(final JComponent f) {
+ private void endDragFrameOperation(JComponent f) {
if (isOutlineDragging) {
setBoundsForFrame(f, prevOutlineBounds.x, prevOutlineBounds.y,
- prevOutlineBounds.width, prevOutlineBounds.height);
+ prevOutlineBounds.width, prevOutlineBounds.height);
isOutlineDragging = false;
}
}
- private void moveFrameOutline(final JComponent f, final int x, final int y,
- final int width, final int height) {
+ private void moveFrameOutline(JComponent f, int x, int y, int width, int height) {
paintOutline(f, x, y, width, height);
prevOutlineBounds.setBounds(x, y, width, height);
}
- private Rectangle getInnerBounds(final Container parent) {
- Rectangle innerBounds = new Rectangle(0, 0, parent.getWidth(),
- parent.getHeight());
+ private Rectangle getInnerBounds(Container parent) {
+ Rectangle innerBounds = new Rectangle(0, 0, parent.getWidth(), parent.getHeight());
return Utilities.subtractInsets(innerBounds, parent.getInsets());
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListCellRenderer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListCellRenderer.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListCellRenderer.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListCellRenderer.java Sat Nov 25 12:05:22 2006
@@ -15,31 +15,39 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
-
package javax.swing;
import java.awt.Component;
import java.io.Serializable;
-
import javax.swing.border.Border;
+/**
+ * <p>
+ * <i>DefaultListCellRenderer</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class DefaultListCellRenderer extends JLabel implements ListCellRenderer, Serializable {
+ private static final long serialVersionUID = -4095659446023979489L;
- public static class UIResource extends DefaultListCellRenderer implements javax.swing.plaf.UIResource {
+ public static class UIResource extends DefaultListCellRenderer implements
+ javax.swing.plaf.UIResource {
+ private static final long serialVersionUID = 5748603813962368116L;
}
protected static Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
public DefaultListCellRenderer() {
setBorder(noFocusBorder);
- setHorizontalAlignment(JLabel.LEADING);
+ setHorizontalAlignment(SwingConstants.LEADING);
}
- public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
+ public Component getListCellRendererComponent(JList list, Object value, int index,
+ boolean isSelected, boolean cellHasFocus) {
setText(value != null ? value.toString() : null);
if (isSelected) {
setForeground(list.getSelectionForeground());
@@ -48,40 +56,48 @@
setForeground(list.getForeground());
setBackground(list.getBackground());
}
-
setOpaque(true);
setFont(list.getFont());
setEnabled(list.isEnabled());
- setBorder(cellHasFocus ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
+ setBorder(cellHasFocus ? UIManager.getBorder("List.focusCellHighlightBorder")
+ : noFocusBorder);
setComponentOrientation(list.getComponentOrientation());
-
return this;
}
- public void firePropertyChange(final String propertyName, final boolean oldValue, final boolean newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
}
- public void firePropertyChange(final String propertyName, final byte oldValue, final byte newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {
}
- public void firePropertyChange(final String propertyName, final char oldValue, final char newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, char oldValue, char newValue) {
}
- public void firePropertyChange(final String propertyName, final double oldValue, final double newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, double oldValue, double newValue) {
}
- public void firePropertyChange(final String propertyName, final float oldValue, final float newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, float oldValue, float newValue) {
}
- public void firePropertyChange(final String propertyName, final int oldValue, final int newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, int oldValue, int newValue) {
}
- public void firePropertyChange(final String propertyName, final long oldValue, final long newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, long oldValue, long newValue) {
}
- public void firePropertyChange(final String propertyName, final short oldValue, final short newValue) {
+ @Override
+ public void firePropertyChange(String propertyName, short oldValue, short newValue) {
}
- protected void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
+ @Override
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListModel.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListModel.java Sat Nov 25 12:05:22 2006
@@ -15,25 +15,32 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
-
package javax.swing;
import java.util.Enumeration;
import java.util.Vector;
+/**
+ * <p>
+ * <i>DefaultListModel</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class DefaultListModel extends AbstractListModel {
- private Vector internalStorage = new Vector();
+ private static final long serialVersionUID = 7987079759213724557L;
- public void add(final int index, final Object element) {
+ private Vector<Object> internalStorage = new Vector<Object>();
+
+ public void add(int index, Object element) {
internalStorage.add(index, element);
fireIntervalAdded(this, index, index);
}
- public void addElement(final Object element) {
+ public void addElement(Object element) {
internalStorage.addElement(element);
fireIntervalAdded(this, internalStorage.size() - 1, internalStorage.size() - 1);
}
@@ -50,15 +57,15 @@
}
}
- public boolean contains(final Object element) {
+ public boolean contains(Object element) {
return internalStorage.contains(element);
}
- public void copyInto(final Object[] array) {
+ public void copyInto(Object[] array) {
internalStorage.copyInto(array);
}
- public Object elementAt(final int index) {
+ public Object elementAt(int index) {
return internalStorage.elementAt(index);
}
@@ -66,7 +73,7 @@
return internalStorage.elements();
}
- public void ensureCapacity(final int minCapacity) {
+ public void ensureCapacity(int minCapacity) {
internalStorage.ensureCapacity(minCapacity);
}
@@ -74,11 +81,11 @@
return internalStorage.firstElement();
}
- public Object get(final int index) {
+ public Object get(int index) {
return internalStorage.get(index);
}
- public Object getElementAt(final int index) {
+ public Object getElementAt(int index) {
return get(index);
}
@@ -86,15 +93,15 @@
return internalStorage.size();
}
- public int indexOf(final Object element) {
+ public int indexOf(Object element) {
return internalStorage.indexOf(element);
}
- public int indexOf(final Object element, final int index) {
+ public int indexOf(Object element, int index) {
return internalStorage.indexOf(element, index);
}
- public void insertElementAt(final Object element, final int index) {
+ public void insertElementAt(Object element, int index) {
internalStorage.insertElementAt(element, index);
fireIntervalAdded(this, index, index);
}
@@ -107,15 +114,15 @@
return internalStorage.lastElement();
}
- public int lastIndexOf(final Object element) {
+ public int lastIndexOf(Object element) {
return internalStorage.lastIndexOf(element);
}
- public int lastIndexOf(final Object element, final int index) {
+ public int lastIndexOf(Object element, int index) {
return internalStorage.lastIndexOf(element, index);
}
- public Object remove(final int index) {
+ public Object remove(int index) {
Object result = internalStorage.remove(index);
fireIntervalRemoved(this, index, index);
return result;
@@ -125,40 +132,37 @@
clear();
}
- public boolean removeElement(final Object element) {
+ public boolean removeElement(Object element) {
int index = internalStorage.indexOf(element);
boolean result = internalStorage.removeElement(element);
-
if (index != -1) {
fireIntervalRemoved(this, index, index);
}
-
return result;
}
- public void removeElementAt(final int index) {
+ public void removeElementAt(int index) {
remove(index);
}
- public void removeRange(final int fromIndex, final int toIndex) {
+ public void removeRange(int fromIndex, int toIndex) {
for (int i = 0; i < toIndex - fromIndex + 1; i++) {
internalStorage.remove(fromIndex);
}
fireIntervalRemoved(this, fromIndex, toIndex);
}
- public Object set(final int index, final Object element) {
+ public Object set(int index, Object element) {
Object result = internalStorage.set(index, element);
fireContentsChanged(this, index, index);
-
return result;
}
- public void setElementAt(final Object element, final int index) {
+ public void setElementAt(Object element, int index) {
set(index, element);
}
- public void setSize(final int size) {
+ public void setSize(int size) {
internalStorage.setSize(size);
}
@@ -170,6 +174,7 @@
return internalStorage.toArray();
}
+ @Override
public String toString() {
return internalStorage.toString();
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java Sat Nov 25 12:05:22 2006
@@ -14,32 +14,39 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
+
package javax.swing;
import java.awt.Rectangle;
import java.io.Serializable;
-import java.util.EventListener;
-
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-
import org.apache.harmony.awt.gl.MultiRectArea;
-
+/**
+ * <p>
+ * <i>DefaultListSelectionModel</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, Serializable {
+ private static final long serialVersionUID = -3207109908101807625L;
+
private static final int NOT_SET = -1;
private static class Segment extends Rectangle {
- public Segment(final int begin, final int end) {
+ private static final long serialVersionUID = 1L;
+
+ public Segment(int begin, int end) {
super(Math.min(begin, end), 0, Math.abs(end - begin) + 1, 1);
}
- public void add(final Segment s) {
+ public void add(Segment s) {
if (s == null || s.isEmpty()) {
return;
} else if (isEmpty()) {
@@ -66,9 +73,10 @@
private static final Rectangle EMPTY_RECTANGLE = new Rectangle();
public Selection() {
+ super();
}
- private Selection(final Selection s) {
+ private Selection(Selection s) {
super(s);
}
@@ -76,15 +84,15 @@
intersect(EMPTY_RECTANGLE);
}
- public boolean contains(final int index) {
+ public boolean contains(int index) {
return contains(index, 0);
}
- public void insertIndices(final int index, final int length, final boolean multiSelectionAllowed) {
+ public void insertIndices(int index, int length, boolean multiSelectionAllowed) {
MultiRectArea modified = new MultiRectArea();
Rectangle[] rects = getRectangles();
for (int i = 0; i < rects.length; i++) {
- Rectangle rect = (Rectangle)rects[i].clone();
+ Rectangle rect = (Rectangle) rects[i].clone();
if (index < rect.x) {
rect.x += length;
} else if (rect.x <= index && index < rect.x + rect.width) {
@@ -100,7 +108,7 @@
add(modified);
}
- public void removeIndices(final int index, final int length) {
+ public void removeIndices(int index, int length) {
MultiRectArea modified = new MultiRectArea();
Rectangle[] rects = getRectangles();
for (int i = 0; i < rects.length; i++) {
@@ -117,14 +125,14 @@
}
modified.add(new Segment(rect.x, rectEnd));
} else {
- modified.add((Rectangle)rect.clone());
+ modified.add((Rectangle) rect.clone());
}
}
clear();
add(modified);
}
- public Segment getDifferenceBounds(final Selection anotherSelection) {
+ public Segment getDifferenceBounds(Selection anotherSelection) {
MultiRectArea thisFromAnother = MultiRectArea.subtract(this, anotherSelection);
MultiRectArea anotherFromThis = MultiRectArea.subtract(anotherSelection, this);
MultiRectArea diff = MultiRectArea.union(thisFromAnother, anotherFromThis);
@@ -144,73 +152,70 @@
return bounds.x + bounds.width - 1;
}
-
+ @Override
public Object clone() {
return new Selection(this);
}
}
protected boolean leadAnchorNotificationEnabled = true;
+
protected EventListenerList listenerList = new EventListenerList();
private Selection selection = new Selection();
+
private int anchorSelectionIndex = NOT_SET;
+
private int leadSelectionIndex = NOT_SET;
+
private Segment adjustingInterval;
+
private int selectionMode = MULTIPLE_INTERVAL_SELECTION;
+
private boolean valueIsAdjusting;
- public void setSelectionInterval(final int intervalEnd1, final int intervalEnd2) {
+ public void setSelectionInterval(int intervalEnd1, int intervalEnd2) {
if (!isValidInterval(intervalEnd1, intervalEnd2)) {
return;
}
-
- Selection oldSelection = (Selection)selection.clone();
+ Selection oldSelection = (Selection) selection.clone();
selection.clear();
-
setSelectionAndUpdateLeadAnchor(intervalEnd1, intervalEnd2, oldSelection);
}
- public void addSelectionInterval(final int intervalEnd1, final int intervalEnd2) {
+ public void addSelectionInterval(int intervalEnd1, int intervalEnd2) {
if (!isValidInterval(intervalEnd1, intervalEnd2)) {
return;
}
-
- Selection oldSelection = (Selection)selection.clone();
+ Selection oldSelection = (Selection) selection.clone();
if (selectionMode == SINGLE_SELECTION || selectionMode == SINGLE_INTERVAL_SELECTION) {
selection.clear();
}
-
setSelectionAndUpdateLeadAnchor(intervalEnd1, intervalEnd2, oldSelection);
}
- public void removeSelectionInterval(final int intervalEnd1, final int intervalEnd2) {
+ public void removeSelectionInterval(int intervalEnd1, int intervalEnd2) {
if (!isValidInterval(intervalEnd1, intervalEnd2)) {
return;
}
-
Segment interval = new Segment(intervalEnd1, intervalEnd2);
- Selection oldSelection = (Selection)selection.clone();
-
+ Selection oldSelection = (Selection) selection.clone();
selection.substract(interval);
-
int oldAnchor = anchorSelectionIndex;
int oldLead = leadSelectionIndex;
-
anchorSelectionIndex = intervalEnd1;
leadSelectionIndex = intervalEnd2;
-
doNotification(selection.getDifferenceBounds(oldSelection), oldAnchor, oldLead);
}
public void clearSelection() {
- Selection oldSelection = (Selection)selection.clone();
+ Selection oldSelection = (Selection) selection.clone();
selection.clear();
-
- doNotification(selection.getDifferenceBounds(oldSelection), anchorSelectionIndex, leadSelectionIndex);
+ doNotification(selection.getDifferenceBounds(oldSelection), anchorSelectionIndex,
+ leadSelectionIndex);
}
- public boolean isSelectedIndex(final int index) {
+ public boolean isSelectedIndex(int index) {
return selection.contains(index);
}
@@ -226,53 +231,43 @@
return isSelectionEmpty() ? NOT_SET : selection.getBeginIndex();
}
-
- public void insertIndexInterval(final int index, final int length, final boolean before) {
+ public void insertIndexInterval(int index, int length, boolean before) {
if (!isValidInterval(index, length)) {
return;
}
-
- Selection oldSelection = (Selection)selection.clone();
+ Selection oldSelection = (Selection) selection.clone();
int insertionIndex = before ? index : index + 1;
selection.insertIndices(index, length, selectionMode != SINGLE_SELECTION);
-
int oldAnchor = anchorSelectionIndex;
int oldLead = leadSelectionIndex;
-
if (anchorSelectionIndex >= insertionIndex) {
anchorSelectionIndex += length;
}
if (leadSelectionIndex >= insertionIndex) {
leadSelectionIndex += length;
}
-
doNotification(selection.getDifferenceBounds(oldSelection), oldAnchor, oldLead);
}
- public void removeIndexInterval(final int intervalEnd1, final int intervalEnd2) {
+ public void removeIndexInterval(int intervalEnd1, int intervalEnd2) {
if (!isValidInterval(intervalEnd1, intervalEnd2)) {
return;
}
-
- Selection oldSelection = (Selection)selection.clone();
-
+ Selection oldSelection = (Selection) selection.clone();
Segment removalInterval = new Segment(intervalEnd1, intervalEnd2);
selection.removeIndices(removalInterval.getBeginIndex(), removalInterval.getLength());
-
int oldAnchor = anchorSelectionIndex;
int oldLead = leadSelectionIndex;
-
- anchorSelectionIndex = adjustLeadAnchorIndexForIndicesRemoval(anchorSelectionIndex, removalInterval);
- leadSelectionIndex = adjustLeadAnchorIndexForIndicesRemoval(leadSelectionIndex, removalInterval);
-
+ anchorSelectionIndex = adjustLeadAnchorIndexForIndicesRemoval(anchorSelectionIndex,
+ removalInterval);
+ leadSelectionIndex = adjustLeadAnchorIndexForIndicesRemoval(leadSelectionIndex,
+ removalInterval);
doNotification(selection.getDifferenceBounds(oldSelection), oldAnchor, oldLead);
}
- public void setAnchorSelectionIndex(final int anchorIndex) {
+ public void setAnchorSelectionIndex(int anchorIndex) {
int oldAnchor = anchorSelectionIndex;
-
anchorSelectionIndex = anchorIndex;
-
doNotification(null, oldAnchor, leadSelectionIndex);
}
@@ -280,18 +275,16 @@
return anchorSelectionIndex;
}
- public void setLeadSelectionIndex(final int leadIndex) {
+ public void setLeadSelectionIndex(int leadIndex) {
if (leadIndex < 0 && anchorSelectionIndex < 0) {
leadSelectionIndex = leadIndex;
}
if (leadIndex < 0 || anchorSelectionIndex < 0) {
return;
}
-
- Selection oldSelection = (Selection)selection.clone();
+ Selection oldSelection = (Selection) selection.clone();
int oldLead = leadSelectionIndex;
leadSelectionIndex = leadIndex;
-
Segment oldSegment = new Segment(anchorSelectionIndex, oldLead);
Segment newSegment = new Segment(anchorSelectionIndex, leadSelectionIndex);
if (selection.contains(anchorSelectionIndex)) {
@@ -301,15 +294,14 @@
selection.add(oldSegment);
selection.substract(newSegment);
}
-
- doNotification(selection.getDifferenceBounds(oldSelection), anchorSelectionIndex, oldLead);
+ doNotification(selection.getDifferenceBounds(oldSelection), anchorSelectionIndex,
+ oldLead);
}
- public void moveLeadSelectionIndex(final int leadIndex) {
+ public void moveLeadSelectionIndex(int leadIndex) {
if (leadIndex < 0 || leadSelectionIndex == leadIndex) {
return;
}
-
int oldIndex = leadSelectionIndex;
leadSelectionIndex = leadIndex;
doNotification(null, anchorSelectionIndex, oldIndex);
@@ -319,7 +311,7 @@
return leadSelectionIndex;
}
- public void setLeadAnchorNotificationEnabled(final boolean enabled) {
+ public void setLeadAnchorNotificationEnabled(boolean enabled) {
leadAnchorNotificationEnabled = enabled;
}
@@ -331,18 +323,15 @@
return selectionMode;
}
- public void setSelectionMode(final int selectionMode) {
- if (selectionMode != SINGLE_SELECTION
- && selectionMode != SINGLE_INTERVAL_SELECTION
- && selectionMode != MULTIPLE_INTERVAL_SELECTION) {
-
+ public void setSelectionMode(int selectionMode) {
+ if (selectionMode != SINGLE_SELECTION && selectionMode != SINGLE_INTERVAL_SELECTION
+ && selectionMode != MULTIPLE_INTERVAL_SELECTION) {
throw new IllegalArgumentException("Incorrect selection mode is specified");
}
-
this.selectionMode = selectionMode;
}
- public void setValueIsAdjusting(final boolean isAdjusting) {
+ public void setValueIsAdjusting(boolean isAdjusting) {
valueIsAdjusting = isAdjusting;
if (!isAdjusting) {
fireValueChanged(isAdjusting);
@@ -353,118 +342,109 @@
return valueIsAdjusting;
}
- public void addListSelectionListener(final ListSelectionListener l) {
+ public void addListSelectionListener(ListSelectionListener l) {
listenerList.add(ListSelectionListener.class, l);
}
- public void removeListSelectionListener(final ListSelectionListener l) {
+ public void removeListSelectionListener(ListSelectionListener l) {
listenerList.remove(ListSelectionListener.class, l);
}
public ListSelectionListener[] getListSelectionListeners() {
- return (ListSelectionListener[])getListeners(ListSelectionListener.class);
+ return getListeners(ListSelectionListener.class);
}
- public <T extends java.util.EventListener> T[] getListeners(final Class<T> listenerType) {
+ public <T extends java.util.EventListener> T[] getListeners(Class<T> listenerType) {
return listenerList.getListeners(listenerType);
}
+ @Override
public Object clone() throws CloneNotSupportedException {
DefaultListSelectionModel result = new DefaultListSelectionModel();
-
result.anchorSelectionIndex = anchorSelectionIndex;
result.leadSelectionIndex = leadSelectionIndex;
result.leadAnchorNotificationEnabled = leadAnchorNotificationEnabled;
result.valueIsAdjusting = valueIsAdjusting;
result.selectionMode = selectionMode;
-
- result.selection = (Selection)selection.clone();
-
+ result.selection = (Selection) selection.clone();
return result;
}
+ @Override
public String toString() {
- return getClass().toString() + ": leadIndex=" + leadSelectionIndex
- + ", anchorIndex=" + anchorSelectionIndex
- + ", isEmpty=" + isSelectionEmpty();
+ return getClass().toString() + ": leadIndex=" + leadSelectionIndex + ", anchorIndex="
+ + anchorSelectionIndex + ", isEmpty=" + isSelectionEmpty();
}
- protected void fireValueChanged(final boolean isAdjusting) {
+ protected void fireValueChanged(boolean isAdjusting) {
if (adjustingInterval != null) {
- fireValueChanged(adjustingInterval.getBeginIndex(), adjustingInterval.getEndIndex(), isAdjusting);
+ fireValueChanged(adjustingInterval.getBeginIndex(),
+ adjustingInterval.getEndIndex(), isAdjusting);
adjustingInterval = null;
}
}
- protected void fireValueChanged(final int firstIndex, final int lastIndex) {
+ protected void fireValueChanged(int firstIndex, int lastIndex) {
fireValueChanged(firstIndex, lastIndex, getValueIsAdjusting());
}
- protected void fireValueChanged(final int firstIndex, final int lastIndex, final boolean isAdjusting) {
+ protected void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) {
fireListSelectionEvent(new ListSelectionEvent(this, firstIndex, lastIndex, isAdjusting));
}
-
- private void fireListSelectionEvent(final ListSelectionEvent event) {
+ private void fireListSelectionEvent(ListSelectionEvent event) {
ListSelectionListener[] listeners = getListSelectionListeners();
for (int i = 0; i < listeners.length; i++) {
listeners[i].valueChanged(event);
}
}
- private void doNotification(final Segment changedInterval, final int oldAnchorIndex, final int oldLeadIndex) {
+ private void doNotification(Segment changedInterval, int oldAnchorIndex, int oldLeadIndex) {
Segment fireInterval = changedInterval;
-
if (leadAnchorNotificationEnabled) {
Segment anchorLeadInterval = getLeadAnchorInterval(oldAnchorIndex, oldLeadIndex);
fireInterval = mergeIntervals(fireInterval, anchorLeadInterval);
}
-
if (fireInterval == null) {
return;
}
-
if (valueIsAdjusting) {
adjustingInterval = mergeIntervals(adjustingInterval, fireInterval);
}
fireValueChanged(fireInterval.getBeginIndex(), fireInterval.getEndIndex());
}
- private Segment mergeIntervals(final Segment interval1, final Segment interval2) {
+ private Segment mergeIntervals(Segment interval1, Segment interval2) {
Segment result = interval1;
-
if (result != null) {
result.add(interval2);
} else {
result = interval2;
}
-
return result;
}
- private Segment getLeadAnchorInterval(final int oldAnchorIndex, final int oldLeadIndex) {
+ private Segment getLeadAnchorInterval(int oldAnchorIndex, int oldLeadIndex) {
Segment anchorInterval = createInterval(oldAnchorIndex, anchorSelectionIndex);
Segment leadInterval = createInterval(oldLeadIndex, leadSelectionIndex);
-
return mergeIntervals(anchorInterval, leadInterval);
}
- private Segment createInterval(final int oldLeadAnchorIndex, final int newLeadAnchorIndex) {
+ private Segment createInterval(int oldLeadAnchorIndex, int newLeadAnchorIndex) {
if (oldLeadAnchorIndex == newLeadAnchorIndex) {
return null;
}
if (oldLeadAnchorIndex == NOT_SET) {
return new Segment(newLeadAnchorIndex, newLeadAnchorIndex);
- } else {
- if (newLeadAnchorIndex == NOT_SET) {
- return new Segment(oldLeadAnchorIndex, oldLeadAnchorIndex);
- } else {
- return new Segment(oldLeadAnchorIndex, newLeadAnchorIndex);
- }
}
+ if (newLeadAnchorIndex == NOT_SET) {
+ return new Segment(oldLeadAnchorIndex, oldLeadAnchorIndex);
+ }
+ return new Segment(oldLeadAnchorIndex, newLeadAnchorIndex);
}
- private int adjustLeadAnchorIndexForIndicesRemoval(final int leadAnchorIndex, final Segment removalInterval) {
+ private int adjustLeadAnchorIndexForIndicesRemoval(int leadAnchorIndex,
+ Segment removalInterval) {
int result = leadAnchorIndex;
if (result >= removalInterval.getBeginIndex()) {
if (result < removalInterval.getEndIndex()) {
@@ -473,15 +453,13 @@
result -= removalInterval.getLength();
}
}
-
return result;
}
- private void setSelectionAndUpdateLeadAnchor(final int intervalEnd1, final int intervalEnd2,
- final Selection oldSelection) {
+ private void setSelectionAndUpdateLeadAnchor(int intervalEnd1, int intervalEnd2,
+ Selection oldSelection) {
int oldAnchor = anchorSelectionIndex;
int oldLead = leadSelectionIndex;
-
if (selectionMode == SINGLE_SELECTION) {
anchorSelectionIndex = intervalEnd2;
} else {
@@ -489,19 +467,17 @@
}
leadSelectionIndex = intervalEnd2;
selection.add(new Segment(anchorSelectionIndex, leadSelectionIndex));
-
doNotification(selection.getDifferenceBounds(oldSelection), oldAnchor, oldLead);
}
- private boolean isValidInterval(final int n1, final int n2) {
+ private boolean isValidInterval(int n1, int n2) {
if (n1 == -1 || n2 == -1) {
return false;
}
-
if (n1 < -1 || n2 < -1) {
- throw new IndexOutOfBoundsException(); // According to the API specification
+ // According to the API specification
+ throw new IndexOutOfBoundsException();
}
-
return true;
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java Sat Nov 25 12:05:22 2006
@@ -49,7 +49,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JComboBox extends JComponent implements ItemSelectable, ListDataListener,
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenu.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenu.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenu.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenu.java Sat Nov 25 12:05:22 2006
@@ -41,7 +41,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JMenu extends JMenuItem implements Accessible, MenuElement {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java Sat Nov 25 12:05:22 2006
@@ -39,7 +39,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSpinner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSpinner.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSpinner.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSpinner.java Sat Nov 25 12:05:22 2006
@@ -59,7 +59,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JSpinner extends JComponent implements Accessible {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTabbedPane.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTabbedPane.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTabbedPane.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTabbedPane.java Sat Nov 25 12:05:22 2006
@@ -43,7 +43,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JTabbedPane extends JComponent implements Serializable, Accessible, SwingConstants {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTable.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTable.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTable.java Sat Nov 25 12:05:22 2006
@@ -85,7 +85,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
@SuppressWarnings("unchecked")
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTree.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTree.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTree.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JTree.java Sat Nov 25 12:05:22 2006
@@ -80,7 +80,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class JTree extends JComponent implements Scrollable, Accessible {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ProgressMonitor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ProgressMonitor.java?view=diff&rev=479184&r1=479183&r2=479184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ProgressMonitor.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ProgressMonitor.java Sat Nov 25 12:05:22 2006
@@ -46,7 +46,7 @@
* <h3>Implementation Notes:</h3>
* <ul>
* <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
- * optimization, not as guarantee of serialization compatibility.</li>
+ * optimization, not as a guarantee of serialization compatibility.</li>
* </ul>
*/
public class ProgressMonitor implements Accessible {