harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r576185 [4/4] - in /harmony/enhanced/classlib/branches/java6/modules: archive/src/main/native/archive/shared/ auth/ auth/src/main/java/common/org/apache/harmony/auth/module/ auth/src/test/java/common/org/apache/harmony/auth/tests/module/ au...
Date Sun, 16 Sep 2007 21:56:47 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
Sun Sep 16 14:56:42 2007
@@ -19,7 +19,24 @@
 import java.io.InputStream;
 import java.io.Reader;
 import java.math.BigDecimal;
-import java.sql.*;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -29,10 +46,13 @@
 import javax.sql.RowSetEvent;
 import javax.sql.RowSetInternal;
 import javax.sql.RowSetMetaData;
+import javax.sql.RowSetWriter;
 import javax.sql.rowset.BaseRowSet;
 import javax.sql.rowset.CachedRowSet;
 import javax.sql.rowset.RowSetMetaDataImpl;
 import javax.sql.rowset.RowSetWarning;
+import javax.sql.rowset.spi.SyncFactory;
+import javax.sql.rowset.spi.SyncFactoryException;
 import javax.sql.rowset.spi.SyncProvider;
 import javax.sql.rowset.spi.SyncProviderException;
 
@@ -48,6 +68,7 @@
 
     private CachedRow currentRow;
 
+    // start from : 0 rather than 1.
     private int currentRowIndex;
 
     private int pageSize;
@@ -60,16 +81,40 @@
 
     private int columnCount;
 
+    private SyncProvider syncProvider;
+
+    private String dataBaseURL;
+
+    public CachedRowSetImpl(String providerID) throws SyncFactoryException {
+        syncProvider = SyncFactory.getInstance(providerID);
+    }
+
+    public CachedRowSetImpl() throws SyncFactoryException {
+        // this("org.apache.harmony.sql.rowset.HYOptimisticProvider");
+    }
+
     public void setRows(ArrayList<CachedRow> data, int cloumnCount) {
         this.rows = data;
         this.columnCount = cloumnCount;
     }
 
     public void acceptChanges() throws SyncProviderException {
-        throw new NotImplementedException();
+        // TODO:
+        // ?? 1. use the provider
+        // 2. use the connections defined in the resultset
+        try {
+            RowSetWriter rowSetWriter = syncProvider.getRowSetWriter();
+            rowSetWriter.writeData(this);
+            // acceptChanges(this.getConnection());
+        } catch (SQLException e) {
+            e.printStackTrace();
+            throw new SyncProviderException();
+        }
     }
 
     public void acceptChanges(Connection con) throws SyncProviderException {
+        if (currentRow == insertRow)
+            throw new SyncProviderException();
         throw new NotImplementedException();
     }
 
@@ -128,6 +173,9 @@
     }
 
     public ResultSet getOriginalRow() throws SQLException {
+        if (currentRow == null)
+            throw new SQLException();
+        // ResultSet originalRow.s
         throw new NotImplementedException();
     }
 
@@ -140,7 +188,7 @@
     }
 
     public SyncProvider getSyncProvider() throws SQLException {
-        throw new NotImplementedException();
+        return this.syncProvider;
     }
 
     public String getTableName() throws SQLException {
@@ -158,6 +206,7 @@
     public void populate(ResultSet rs, int startRow) throws SQLException {
         new CachedRowSetReader(rs, startRow).readData(this);
         composeMetaData(rs.getMetaData());
+        dataBaseURL = rs.getStatement().getConnection().getMetaData().getURL();
     }
 
     private void composeMetaData(ResultSetMetaData metaData)
@@ -217,7 +266,10 @@
     }
 
     public void setSyncProvider(String provider) throws SQLException {
-        throw new NotImplementedException();
+        // If a different concurrency control mechanism is desired, a different
+        // implementation of SyncProvider can be plugged in using the method
+        // setSyncProvider
+        syncProvider = SyncFactory.getInstance(provider);
     }
 
     public void setTableName(String tabName) throws SQLException {
@@ -337,7 +389,11 @@
     }
 
     public boolean first() throws SQLException {
-        throw new NotImplementedException();
+        if (rows.size() == 0)
+            return false;
+        this.currentRowIndex = 0;
+        this.currentRow = (CachedRow) rows.get(0);
+        return true;
     }
 
     public Array getArray(int columnIndex) throws SQLException {
@@ -467,11 +523,11 @@
     }
 
     public int getInt(int columnIndex) throws SQLException {
-        throw new NotImplementedException();
+        return this.currentRow.getInt(columnIndex);
     }
 
     public int getInt(String columnName) throws SQLException {
-        throw new NotImplementedException();
+        return this.currentRow.getInt(getIndexByName(columnName));
     }
 
     public long getLong(int columnIndex) throws SQLException {
@@ -528,12 +584,13 @@
         throw new NotImplementedException();
     }
 
+    // columnIndex: from 1 rather than 0
     public String getString(int columnIndex) throws SQLException {
-        throw new NotImplementedException();
+        return currentRow.getString(columnIndex);
     }
 
     public String getString(String columnName) throws SQLException {
-        throw new NotImplementedException();
+        return currentRow.getString(getIndexByName(columnName));
     }
 
     public Time getTime(int columnIndex) throws SQLException {
@@ -593,11 +650,14 @@
     public void insertRow() throws SQLException {
         checkValidRow();
         if (currentRow != insertRow) {
-            throw new SQLException();
+            // rowset.4=Not an insert row
+            throw new SQLException(Messages.getString("rowset.4"));
         }
         currentRow.setInsert();
         rows.add(insertRow);
         currentRowIndex++;
+        // TODO insert the data into database
+        // insertRowToDB(rows);
     }
 
     public boolean isAfterLast() throws SQLException {
@@ -628,6 +688,7 @@
     public void moveToInsertRow() throws SQLException {
         insertRow = new CachedRow(new Object[columnCount]);
         this.currentRow = insertRow;
+        this.rememberedCursorPosition = this.currentRowIndex;
         this.currentRowIndex = rows.size();
     }
 
@@ -636,7 +697,7 @@
         if (rows.size() < currentRowIndex) {
             return false;
         }
-        currentRow = rows.get(currentRowIndex);
+        currentRow = rows.get(currentRowIndex - 1);
         return true;
     }
 
@@ -658,7 +719,10 @@
     }
 
     public boolean rowInserted() throws SQLException {
-        throw new NotImplementedException();
+        boolean sign = false;
+        for (int i = 0; i < meta.getColumnCount(); ++i)
+            sign = this.currentRow.getUpdateMask(i) | sign;
+        return sign;
     }
 
     public boolean rowUpdated() throws SQLException {
@@ -828,7 +892,10 @@
     }
 
     public void updateRow() throws SQLException {
-        throw new NotImplementedException();
+        if ((currentRow == insertRow)
+                || (this.getConcurrency() == (ResultSet.CONCUR_READ_ONLY)))
+            throw new SQLException();
+        rows.set(currentRowIndex, currentRow);
     }
 
     public void updateShort(int columnIndex, short x) throws SQLException {
@@ -874,7 +941,7 @@
     }
 
     public Connection getConnection() throws SQLException {
-        throw new NotImplementedException();
+        return DriverManager.getConnection(dataBaseURL);
     }
 
     public void updateNCharacterStream(String columnLabel, Reader reader){
@@ -1049,32 +1116,37 @@
         throw new NotImplementedException();
     }
     
-    public NClob getNClob(int columnIndex){
+    public <T> T unwrap(Class<T> iface){
         throw new NotImplementedException();
     }
     
-    public NClob getNClob(String columnLabel){
+    public int getHoldability(){
         throw new NotImplementedException();
     }
-    
-    public boolean isClosed(){
-        throw new NotImplementedException();
+
+    public NClob getNClob(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
     }
-    
-    public SQLXML getSQLXML(int columnIndex){
-        throw new NotImplementedException();
+
+    public NClob getNClob(String columnLabel) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
     }
-    
-    public SQLXML getSQLXML(String columnLabel){
-        throw new NotImplementedException();
+
+    public SQLXML getSQLXML(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
     }
-    
-    public <T> T unwrap(Class<T> iface){
-        throw new NotImplementedException();
+
+    public SQLXML getSQLXML(String columnLabel) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
     }
-    
-    public int getHoldability(){
-        throw new NotImplementedException();
+
+    public boolean isClosed() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetWriter.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetWriter.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetWriter.java
Sun Sep 16 14:56:42 2007
@@ -22,10 +22,18 @@
 import javax.sql.RowSetWriter;
 
 import org.apache.harmony.luni.util.NotImplementedException;
+import org.apache.harmony.sql.internal.nls.Messages;
 
 public class CachedRowSetWriter implements RowSetWriter {
 
     public boolean writeData(RowSetInternal theRowSet) throws SQLException {
+        // use an optimistic concurrency control mechanism
+        if (checkConflict())
+            throw new SQLException(Messages.getString("rowset.4"));
+        return true;
+    }
+
+    private boolean checkConflict() {
         throw new NotImplementedException();
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/FilteredRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/FilteredRowSetImpl.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/FilteredRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/FilteredRowSetImpl.java
Sun Sep 16 14:56:42 2007
@@ -20,11 +20,17 @@
 
 import javax.sql.rowset.FilteredRowSet;
 import javax.sql.rowset.Predicate;
+import javax.sql.rowset.spi.SyncFactoryException;
 
 import org.apache.harmony.luni.util.NotImplementedException;
 
 public class FilteredRowSetImpl extends WebRowSetImpl implements FilteredRowSet {
 
+    public FilteredRowSetImpl(String providerID) throws SyncFactoryException {
+        super(providerID);
+        // TODO Auto-generated constructor stub
+    }
+
     public Predicate getFilter() {
         throw new NotImplementedException();
     }
@@ -32,6 +38,5 @@
     public void setFilter(Predicate p) throws SQLException {
         throw new NotImplementedException();
     }
-
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/JoinRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/JoinRowSetImpl.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/JoinRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/JoinRowSetImpl.java
Sun Sep 16 14:56:42 2007
@@ -23,10 +23,16 @@
 import javax.sql.rowset.CachedRowSet;
 import javax.sql.rowset.JoinRowSet;
 import javax.sql.rowset.Joinable;
+import javax.sql.rowset.spi.SyncFactoryException;
 
 import org.apache.harmony.luni.util.NotImplementedException;
 
 public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
+
+    public JoinRowSetImpl(String providerID) throws SyncFactoryException {
+        super(providerID);
+        // TODO Auto-generated constructor stub
+    }
 
     public void addRowSet(Joinable rowset) throws SQLException {
         throw new NotImplementedException();

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/WebRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/WebRowSetImpl.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/WebRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/WebRowSetImpl.java
Sun Sep 16 14:56:42 2007
@@ -25,10 +25,15 @@
 import java.sql.SQLException;
 
 import javax.sql.rowset.WebRowSet;
+import javax.sql.rowset.spi.SyncFactoryException;
 
 import org.apache.harmony.luni.util.NotImplementedException;
 
 public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet {
+
+    public WebRowSetImpl(String providerID) throws SyncFactoryException {
+        super(providerID);
+    }
 
     public void readXml(Reader reader) throws SQLException {
         throw new NotImplementedException();

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
Sun Sep 16 14:56:42 2007
@@ -22,7 +22,11 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
+import javax.sql.RowSetReader;
+import javax.sql.RowSetWriter;
 import javax.sql.rowset.CachedRowSet;
+import javax.sql.rowset.spi.SyncProvider;
+import javax.sql.rowset.spi.SyncProviderException;
 
 import junit.framework.TestCase;
 
@@ -55,9 +59,11 @@
         try {
             crset = (CachedRowSet) Class.forName(
                     "com.sun.rowset.CachedRowSetImpl").newInstance();
+            System.setProperty("CachedRowSetImpl_Test_Signal", "Testing RI");
             System.out.println("Testing RI");
         } catch (ClassNotFoundException e) {
-            System.out.println("Testing Harmony");
+            System.setProperty("CachedRowSetImpl_Test_Signal",
+                    "Testing Harmony");
             crset = (CachedRowSet) Class.forName(
                     "org.apache.harmony.sql.internal.rowset.CachedRowSetImpl")
                     .newInstance();
@@ -72,6 +78,18 @@
         }
     }
 
+    public void testCachedRowSetVersion() {
+        assertEquals(System.getProperty("CachedRowSetImpl_Test_Signal"),
+                "Testing Harmony");
+    }
+
+    public void testSetSyncProvider() throws Exception {
+        // String mySyncProvider = "org.apache.internal.SyncProviderImpl";
+        // crset.setSyncProvider(mySyncProvider);
+        // assertEquals(crset.getSyncProvider().getClass().getCanonicalName(),
+        // mySyncProvider);
+    }
+
     public void testColumnUpdatedInt() throws SQLException {
         try {
             assertFalse(crset.columnUpdated(1));
@@ -162,8 +180,8 @@
         assertEquals(2, crset.size());
         assertTrue(crset.rowDeleted());
     }
-    
-    public void testRowDeleted() throws SQLException{
+
+    public void testRowDeleted() throws SQLException {
         try {
             crset.rowDeleted();
             fail("should throw SQLException");
@@ -171,8 +189,8 @@
             // expected;
         }
     }
-    
-    public void testInsertRow() throws SQLException{
+
+    public void testInsertRow() throws SQLException {
         try {
             crset.insertRow();
             fail("should throw SQLException");
@@ -190,17 +208,20 @@
         crset.updateString("Name", "TonyWu");
         crset.updateInt("ID", 3);
         crset.insertRow();
-//        crset.moveToCurrentRow();
-//        assertTrue(crset.rowInserted());
+        assertEquals("TonyWu", crset.getString(2));
+        assertEquals("TonyWu", crset.getString("Name"));
+        assertEquals(3, crset.getInt(1));
+        assertEquals(3, crset.getInt("ID"));
+        assertTrue(crset.rowInserted());
     }
 
     public void testAcceptChanges() throws SQLException {
-        // rs.next();
-        // assertEquals(1, rs.getInt(1));
-        // crset.next();
-        // assertEquals(1, crset.getInt(1));
-        // crset.updateInt(1, 3);
-        // assertEquals(3, crset.getInt(1));
+        rs.next();
+        assertEquals(1, rs.getInt(1));
+        crset.next();
+        assertEquals(1, crset.getInt(1));
+        crset.updateInt(1, 3);
+        assertEquals(3, crset.getInt(1));
         // try {
         // crset.acceptChanges();
         // fail("should throw SyncProviderException");
@@ -210,13 +231,15 @@
     }
 
     public void testAcceptChangesConnection() throws SQLException {
-        // rs.next();
-        // assertEquals(1, rs.getInt(1));
-        // crset.first();
-        // assertEquals(1, crset.getInt(1));
-        // crset.updateInt(1, 3);
-        // assertEquals(3, crset.getInt(1));
-        // crset.updateRow();
+        rs.next();
+        assertEquals(1, rs.getInt(1));
+        crset.first();
+        assertEquals(1, crset.getInt(1));
+        crset.updateInt(1, 3);
+        assertEquals(3, crset.getInt(1));
+        crset.updateRow();
+        crset.moveToCurrentRow();
+        assertEquals(3, crset.getInt(1));
         // crset.acceptChanges(conn);
         // rs = st.executeQuery("select * from USER_INFO");
         // rs.next();

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/AbstractButton.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
Sun Sep 16 14:56:42 2007
@@ -45,6 +45,8 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.InsetsUIResource;
+import javax.swing.plaf.UIResource;
 import javax.swing.text.AttributeSet;
 
 import org.apache.harmony.x.swing.ButtonCommons;
@@ -367,6 +369,8 @@
     private int mnemonicIndex = -1;
 
     private long multiClickThreshhold;
+    
+    private InsetsUIResource defaultMargin;
 
     protected void init(String text, Icon icon) {
         if (text != null) {
@@ -707,6 +711,17 @@
     }
 
     public void setMargin(Insets margin) {
+
+        /* default values are obtained from UI (Harmony-4655) */
+        if (margin instanceof InsetsUIResource) {
+            defaultMargin = (InsetsUIResource) margin;
+        } else if (margin == null) {
+            /*
+             * According to spec if margin == null default value sets
+             * (Harmony-4655)
+             */
+            margin = defaultMargin;
+        }
         Insets oldValue = this.margin;
         this.margin = margin;
         firePropertyChange(MARGIN_CHANGED_PROPERTY, oldValue, margin);

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/DefaultButtonModel.java
Sun Sep 16 14:56:42 2007
@@ -220,8 +220,10 @@
             listeners[i].actionPerformed(event);
         }
     }
-
-    private void toggleState(int stateFlag) {
+    
+    void toggleState(int stateFlag) {
+        // visibility is changed from private to default because according to
+        // HARMONY-4658 patch the method is needed by ToggleButtonModel
         stateMask ^= stateFlag;
         fireStateChanged();
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JTable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JTable.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JTable.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JTable.java
Sun Sep 16 14:56:42 2007
@@ -1264,7 +1264,11 @@
     }
 
     public int columnAtPoint(Point p) {
-        return getTableHeader().columnAtPoint(p);
+        int x = p.x;
+        if( !getComponentOrientation().isLeftToRight() ) {
+          x = getWidth() - x;
+        }
+        return getColumnModel().getColumnIndexAtX(x);
     }
 
     public int rowAtPoint(Point p) {
@@ -1645,7 +1649,7 @@
         if (getAutoResizeMode() == AUTO_RESIZE_OFF) {
             return;
         }
-        TableColumn resizingColumn = getTableHeader().getResizingColumn();
+        TableColumn resizingColumn = (getTableHeader() == null) ? null : getTableHeader().getResizingColumn();
         if (resizingColumn == null) {
             ResizableElements resizable = new ResizableElements() {
                 public int getElementsCount() {

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JToggleButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JToggleButton.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JToggleButton.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JToggleButton.java
Sun Sep 16 14:56:42 2007
@@ -46,6 +46,8 @@
     };
 
     public static class ToggleButtonModel extends DefaultButtonModel {
+        
+        @Override
         public void setPressed(final boolean pressed) {
             boolean oldPressed = isPressed();
             if (oldPressed != pressed && !pressed && isArmed()) {
@@ -54,13 +56,30 @@
             super.setPressed(pressed);
         }
 
-        public void setSelected(final boolean selected) {
-            if (group != null && group.getSelection() == this) {
-                return;
-            }
-            super.setSelected(selected);
-            if (selected && group != null) {
-                group.setSelected(this, true);
+        @Override
+        public void setSelected(boolean selected) {
+            // The method changed according to HARMONY-4658.
+            // Now super.setSelected(selected) divided if group!=null
+            if (group != null) {
+            
+                if (group.getSelection() == this) {
+                    return;
+                }
+                
+                toggleState(SELECTED);
+                
+                if (selected) {
+                    group.setSelected(this, true);
+                }
+                
+                int state = selected ? ItemEvent.SELECTED
+                        : ItemEvent.DESELECTED;
+                ItemEvent event = new ItemEvent(this,
+                        ItemEvent.ITEM_STATE_CHANGED, this, state);
+                fireItemStateChanged(event);
+                
+            } else {
+                super.setSelected(selected);
             }
         }
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RepaintManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RepaintManager.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RepaintManager.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RepaintManager.java
Sun Sep 16 14:56:42 2007
@@ -188,6 +188,9 @@
         }
     }
 
+    // According to Spec as a offscreen buffer we can use offscreen image of any type,
+    // which can keep own content. Our implementation of VolatileImage based on GDI Bitmap
and
+    // can't lost content. For performance reason as a offscreen buffer we use VolatileImage.
     public Image getOffscreenBuffer(final Component c, final int proposedWidth, final int
proposedHeight) {
         int adjustedWidth = Math.min(proposedWidth, maximumSize.width);
         int adjustedHeight = Math.min(proposedHeight, maximumSize.height);
@@ -202,7 +205,7 @@
                 offscreenImage.flush();
             }
 
-            offscreenImage = c.createImage(adjustedWidth, adjustedHeight);
+            offscreenImage = c.createVolatileImage(adjustedWidth, adjustedHeight);
         }
 
         return offscreenImage;

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
Sun Sep 16 14:56:42 2007
@@ -46,7 +46,24 @@
     private SwatchPanel recentPanel;
     private SwatchPanel swatchPanel;
 
-    private static class SwatchPanel extends JPanel {
+    private final class SwatchPanelMouseInputAdapter extends MouseInputAdapter {
+    	private SwatchPanel panel;
+
+    	SwatchPanelMouseInputAdapter(final SwatchPanel panel) {
+    		this.panel = panel;
+    	}
+
+		public void mouseClicked(final MouseEvent e) {
+		    getColorSelectionModel().setSelectedColor(panel.getColorAtLocation(e.getX(), e.getY(),
true));
+		}
+
+		public void mouseMoved(final MouseEvent e) {
+		    Color color = panel.getColorAtLocation(e.getX(), e.getY(), false);
+		    panel.setToolTipText(color.getRed() + ", " + color.getGreen() + ", " + color.getBlue());
+		}
+	}
+
+	private static class SwatchPanel extends JPanel {
         int oneColorWidth;
         int oneColorHeight;
 
@@ -135,20 +152,15 @@
 
         JPanel right = new JPanel(new BorderLayout());
         recentPanel = new SwatchPanel(createRecentColors(), null, recentSwatchSize);
-        
+        MouseInputAdapter swatchMouseAdapter = new SwatchPanelMouseInputAdapter(recentPanel);
+        recentPanel.addMouseListener(swatchMouseAdapter);
+        recentPanel.addMouseMotionListener(swatchMouseAdapter);
+
         right.add(BorderLayout.CENTER, new JLabel(UIManager.getString("ColorChooser.swatchesRecentText")));
         right.add(BorderLayout.SOUTH, recentPanel);
 
         swatchPanel = new SwatchPanel(MAIN_SWATCH_COLORS, recentPanel, swatchSize);
-        MouseInputAdapter swatchMouseAdapter = new MouseInputAdapter() {
-            public void mouseClicked(MouseEvent e) {
-                getColorSelectionModel().setSelectedColor(swatchPanel.getColorAtLocation(e.getX(),
e.getY(), true));
-            }
-            public void mouseMoved(MouseEvent e) {
-                Color color = swatchPanel.getColorAtLocation(e.getX(), e.getY(), false);
-                swatchPanel.setToolTipText(color.getRed() + ", " + color.getGreen() + ",
" + color.getBlue());
-            }
-        };
+        swatchMouseAdapter = new SwatchPanelMouseInputAdapter(swatchPanel);
         swatchPanel.addMouseListener(swatchMouseAdapter);
         swatchPanel.addMouseMotionListener(swatchMouseAdapter);
 

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxUI.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxUI.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxUI.java
Sun Sep 16 14:56:42 2007
@@ -172,18 +172,24 @@
     public class PropertyChangeHandler implements PropertyChangeListener {
         public void propertyChange(final PropertyChangeEvent event) {
             if (StringConstants.ENABLED_PROPERTY_CHANGED.equals(event.getPropertyName()))
{
+                if (arrowButton != null) {
                 arrowButton.setEnabled(((Boolean)event.getNewValue()).booleanValue());
-                if (comboBox.isEditable()) {
+                }
+                if (comboBox.isEditable() && (editor != null)) {
                     editor.setEnabled(((Boolean)event.getNewValue()).booleanValue());
                 }
             } else if (StringConstants.TOOLTIP_PROPERTY_CHANGED.equals(event.getPropertyName()))
{
+                if (arrowButton != null) {
                 arrowButton.setToolTipText((String)event.getNewValue());
+                }
                 if (comboBox.isEditable() && (editor instanceof JComponent)) {
                     ((JComponent)editor).setToolTipText((String)event.getNewValue());
                 }
             } else if (StringConstants.FONT_PROPERTY_CHANGED.equals(event.getPropertyName()))
{
+                if (arrowButton != null) {
                 arrowButton.setFont((Font)event.getNewValue());
-                if (comboBox.isEditable()) {
+                }
+                if (comboBox.isEditable() && (editor != null)) {
                     editor.setFont((Font)event.getNewValue());
                 }
             } else if (StringConstants.EDITABLE_PROPERTY_CHANGED.equals(event.getPropertyName()))
{

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
Sun Sep 16 14:56:42 2007
@@ -833,81 +833,103 @@
     }
 
     private static class ReadWriteLock {
-        private List<Thread> readers = new ArrayList<Thread>();
-        private Thread writer;
-        private int writerCount;
-        private boolean callingListeners;
+        private boolean            callingListeners;
+        private int                writeAcquestCounter;
+        private int                waitingWritersCounter;
+        private Thread             activeWriter;
+        private final List<Thread> activeReaders = new ArrayList<Thread>();
+        private final Object       lock          = new Object();
 
-        public ReadWriteLock() {
-            super();
+        public final Thread getCurrentWriter() {
+            return activeWriter;
         }
 
-        public final synchronized Thread getCurrentWriter() {
-            return writer;
-        }
-
-        public final synchronized void readLock() {
+        public final void readLock() {
             final Thread thread = Thread.currentThread();
 
-            if (writer != thread) {
-                while (writerCount > 0) {
+            if (thread == activeWriter) {
+                return;
+            }
+
+            synchronized (lock) {
+                while ((activeWriter != null) || (waitingWritersCounter > 0)) {
                     try {
-                        wait();
-                    } catch (final InterruptedException e) { }
+                        lock.wait();
+                    } catch (final InterruptedException e) {
+                        return;
+                    }
                 }
-            }
 
-            readers.add(thread);
+                activeReaders.add(thread);
+            }
         }
 
-        public final synchronized void readUnlock() {
-            final Thread currentThread = Thread.currentThread();
-            final int index = readers.indexOf(currentThread);
+        public final void readUnlock() {
+            final Thread thread = Thread.currentThread();
 
-            if (index == -1) {
-                throw new Error(Messages.getString("swing.err.10")); //$NON-NLS-1$
+            if (thread == activeWriter) {
+                return;
             }
 
-            readers.remove(index);
-            if (readers.size() == 0) {
-                notify();
+            synchronized (lock) {
+                if (!activeReaders.remove(thread)) {
+                    throw new Error(Messages.getString("swing.err.10")); //$NON-NLS-1$
+                }
+
+                lock.notifyAll();
             }
         }
 
-        public final synchronized void setCallingListeners(final boolean flag) {
+        public final void setCallingListeners(final boolean flag) {
             callingListeners = flag;
         }
 
-        public final synchronized void writeLock() {
+        public final void writeLock() {
             if (callingListeners) {
                 throw new IllegalStateException(Messages.getString("swing.7E")); //$NON-NLS-1$
             }
 
             final Thread thread = Thread.currentThread();
 
-            while (readers.size() > 0
-                   || writer != null && writer != thread) {
-                try {
-                    wait();
-                } catch (final InterruptedException e) { }
-            }
+            if (thread == activeWriter) {
+                writeAcquestCounter++;
+                return;
+            }
+
+            synchronized (lock) {
+                if ((activeReaders.size() > 0) || (activeWriter != null)) {
+
+                    waitingWritersCounter++;
+
+                    while ((activeReaders.size() > 0) || (activeWriter != null)) {
+                        try {
+                            lock.wait();
+                        } catch (final InterruptedException e) {
+                            waitingWritersCounter--;
+                            return;
+                        }
+                    }
+
+                    waitingWritersCounter--;
+                }
 
-            if (writerCount++ == 0) {
-                writer = thread;
+                writeAcquestCounter++;
+                activeWriter = thread;
             }
         }
 
-        public final synchronized void writeUnlock() {
-            if (writer != Thread.currentThread()) {
+        public final void writeUnlock() {
+            if (activeWriter != Thread.currentThread()) {
                 throw new Error(Messages.getString("swing.err.11")); //$NON-NLS-1$      
     }
             }
-            if (--writerCount == 0) {
-                writer = null;
-                readers.clear();
-                notifyAll();
+
+            if (--writeAcquestCounter == 0) {
+                synchronized (lock) {
+                    activeWriter = null;
+                    lock.notifyAll();
+                }
             }
         }
-
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
Sun Sep 16 14:56:42 2007
@@ -2067,6 +2067,23 @@
             assertEquals(name, listener.eventHappened.getActionCommand());
         }
     }
+    
+    /**
+     * Regression test for H4655: setMargin(null) causes to default margin
+     * */
+    public void testH4655() {
+
+        JRadioButton rb = new JRadioButton();
+        Insets newInsets = new Insets(10, 10, 10, 10);
+        Insets defaultInsets = rb.getMargin();
+
+        rb.setMargin(null);
+        assertEquals(defaultInsets, rb.getMargin());
+        rb.setMargin(newInsets);
+        assertEquals(newInsets, rb.getMargin());
+        rb.setMargin(null);
+        assertEquals(defaultInsets, rb.getMargin());
+    }
 
     protected int find(final Object[] array, final Object value) {
         int found = 0;

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
Sun Sep 16 14:56:42 2007
@@ -223,7 +223,9 @@
         assertNull(item.getForeground());
         assertNull(item.getFont());
         assertNull(item.getBorder());
-        assertNull(item.getMargin());
+        // Assertion below has been deleted because now we are compartible with
+        // RI in this point. For details see HARMONY-4655
+        // assertNull(item.getMargin());
         assertEquals(4, menuItemUI.defaultTextIconGap);
         if (isHarmony()) {
             assertFalse(menuItemUI.oldBorderPainted);

Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java?rev=576185&r1=576184&r2=576185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
Sun Sep 16 14:56:42 2007
@@ -160,7 +160,9 @@
         assertNull(menu.getForeground());
         assertNull(menu.getFont());
         assertNull(menu.getBorder());
-        assertNull(menu.getMargin());
+        // Assertion below has been deleted because now we are compartible with
+        // RI in this point. For details see HARMONY-4655
+        // assertNull(menu.getMargin());
         assertEquals(4, menuUI.defaultTextIconGap);
         assertTrue(menuUI.oldBorderPainted);
         assertEquals(Color.cyan, menuUI.acceleratorForeground);



Mime
View raw message