harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r812220 - in /harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing: RowSorter.java SortOrder.java event/RowSorterEvent.java event/RowSorterListener.java
Date Mon, 07 Sep 2009 16:33:26 GMT
Author: odeakin
Date: Mon Sep  7 16:33:26 2009
New Revision: 812220

URL: http://svn.apache.org/viewvc?rev=812220&view=rev
Log:
Add some more missing Java 6 swing classes.

Added:
    harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java
  (with props)

Added: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java?rev=812220&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java
Mon Sep  7 16:33:26 2009
@@ -0,0 +1,113 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.swing;
+
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.SortOrder;
+import javax.swing.event.RowSorterEvent;
+import javax.swing.event.RowSorterListener;
+
+public abstract class RowSorter<M> {
+
+    private Vector<RowSorterListener> listeners = new Vector<RowSorterListener>();
+
+    public static class SortKey {
+        private int column;
+        private SortOrder sortOrder;
+
+        public SortKey(int column, SortOrder sortOrder) {
+            if (sortOrder == null) {
+                throw new IllegalArgumentException("Sort order cannot be null");
+            }
+
+            this.column = column;
+            this.sortOrder = sortOrder;
+        }
+
+        public final int getColumn() {
+            return column;
+        }
+
+        public final SortOrder getSortOrder() {
+            return sortOrder;
+        }
+
+        public int hashCode() {
+            return column + sortOrder.hashCode();
+        }
+
+        public boolean equals(Object o) {
+            if ((o != null) && (o instanceof SortKey)) {
+                SortKey sortKey = (SortKey)o;
+                if ((column == sortKey.getColumn()) && (sortOrder.equals(sortKey.getSortOrder())))
{
+                    return true;
+                }
+            }            
+            return false;
+        }
+    }
+
+    public RowSorter() {
+        super();
+    }
+
+    public abstract M getModel();
+    public abstract void toggleSortOrder(int column);
+    public abstract int convertRowIndexToModel(int index);
+    public abstract int convertRowIndexToView(int index);
+    public abstract void setSortKeys(List<? extends RowSorter.SortKey> keys);
+    public abstract List<? extends RowSorter.SortKey> getSortKeys();
+    public abstract int getViewRowCount();
+    public abstract int getModelRowCount();
+    public abstract void modelStructureChanged();
+    public abstract void allRowsChanged();
+    public abstract void rowsInserted(int firstRow, int endRow);
+    public abstract void rowsDeleted(int firstRow, int endRow);
+    public abstract void rowsUpdated(int firstRow, int endRow);
+    public abstract void rowsUpdated(int firstRow, int endRow, int column);
+
+    public void addRowSorterListener(RowSorterListener l) {
+        if (l == null) return;
+        listeners.add(l);
+    }
+
+    public void removeRowSorterListener(RowSorterListener l) {
+        if (l == null) return;
+        listeners.remove(l);
+    }
+
+    protected void fireSortOrderChanged() {
+        RowSorterEvent event = new RowSorterEvent(this);
+
+        RowSorterListener[] listenerArray = (RowSorterListener[]) listeners.toArray();
+        for (int i=0; i<listenerArray.length; i++) {
+            listenerArray[i].sorterChanged(event);
+        }        
+    }
+
+    protected void fireRowSorterChanged(int[] lastRowIndexToModel) {
+        RowSorterEvent event = new RowSorterEvent(this, RowSorterEvent.Type.SORTED, lastRowIndexToModel);
+
+        RowSorterListener[] listenerArray = (RowSorterListener[]) listeners.toArray();
+        for (int i=0; i<listenerArray.length; i++) {
+            listenerArray[i].sorterChanged(event);
+        }   
+    }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/RowSorter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java?rev=812220&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java
Mon Sep  7 16:33:26 2009
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.swing;
+
+public enum SortOrder {
+    ASCENDING, DESCENDING, UNSORTED
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/SortOrder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java?rev=812220&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java
Mon Sep  7 16:33:26 2009
@@ -0,0 +1,70 @@
+ /*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.swing.event;
+
+import java.util.EventObject;
+import javax.swing.RowSorter;
+
+public class RowSorterEvent extends EventObject {
+    public static enum Type {
+        SORT_ORDER_CHANGED, SORTED
+    }
+
+    private RowSorter source;
+    private RowSorterEvent.Type eventType;
+    private int[] previousRowIndexToModel;
+
+    public RowSorterEvent(RowSorter source) {
+        this(source, Type.SORT_ORDER_CHANGED, null);
+    }
+
+    public RowSorterEvent(RowSorter source, RowSorterEvent.Type type, int[] previousRowIndexToModel)
{
+        super(source);
+
+        if (source == null) {
+            throw new IllegalArgumentException("Source row sorter cannot be null");
+        }
+        if (type == null) {
+            throw new IllegalArgumentException("Row sorter event type cannot be null");
+        }
+
+        this.source = source;
+        this.eventType = type;
+        this.previousRowIndexToModel = previousRowIndexToModel;
+    }
+
+    public RowSorter getSource() {
+        return source;
+    }
+
+    public RowSorterEvent.Type getType() {
+        return eventType;
+    }
+
+    public int convertPreviousRowIndexToModel(int index) {
+        if ((previousRowIndexToModel == null) || (index > previousRowIndexToModel.length
- 1)) {
+            return -1;
+        }
+
+        return previousRowIndexToModel[index];
+    }
+
+    public int getPreviousRowCount() {
+        return previousRowIndexToModel.length;
+    }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java?rev=812220&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java
Mon Sep  7 16:33:26 2009
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.swing.event;
+
+public interface RowSorterListener {
+    void sorterChanged(RowSorterEvent e);
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/event/RowSorterListener.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message