Source Code Cross Referenced for RowSorterEvent.java in  » 6.0-JDK-Core » swing » javax » swing » event » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025        package javax.swing.event;
026
027        import javax.swing.RowSorter;
028
029        /**
030         * <code>RowSorterEvent</code> provides notification of changes to
031         * a <code>RowSorter</code>.  Two types of notification are possible:
032         * <ul>
033         * <li><code>Type.SORT_ORDER_CHANGED</code>: indicates the sort order has
034         *     changed.  This is typically followed by a notification of:
035         * <li><code>Type.SORTED</code>: indicates the contents of the model have
036         *     been transformed in some way.  For example, the contents may have
037         *     been sorted or filtered.
038         * </ul>
039         *
040         * @version 1.9 05/05/07
041         * @see javax.swing.RowSorter
042         * @since 1.6
043         */
044        public class RowSorterEvent extends java.util.EventObject {
045            private Type type;
046            private int[] oldViewToModel;
047
048            /**
049             * Enumeration of the types of <code>RowSorterEvent</code>s.
050             *
051             * @since 1.6
052             */
053            public enum Type {
054                /**
055                 * Indicates the sort order has changed.
056                 */
057                SORT_ORDER_CHANGED,
058
059                /**
060                 * Indicates the contents have been newly sorted or
061                 * transformed in some way.
062                 */
063                SORTED
064            }
065
066            /**
067             * Creates a <code>RowSorterEvent</code> of type
068             * <code>SORT_ORDER_CHANGED</code>.
069             *
070             * @param source the source of the change
071             * @throws IllegalArgumentException if <code>source</code> is
072             *         <code>null</code>
073             */
074            public RowSorterEvent(RowSorter source) {
075                this (source, Type.SORT_ORDER_CHANGED, null);
076            }
077
078            /**
079             * Creates a <code>RowSorterEvent</code>.
080             *
081             * @param source the source of the change
082             * @param type the type of event
083             * @param previousRowIndexToModel the mapping from model indices to 
084             *        view indices prior to the sort, may be <code>null</code>
085             * @throws IllegalArgumentException if source or <code>type</code> is
086             *         <code>null</code>
087             */
088            public RowSorterEvent(RowSorter source, Type type,
089                    int[] previousRowIndexToModel) {
090                super (source);
091                if (type == null) {
092                    throw new IllegalArgumentException("type must be non-null");
093                }
094                this .type = type;
095                this .oldViewToModel = previousRowIndexToModel;
096            }
097
098            /**
099             * Returns the source of the event as a <code>RowSorter</code>.
100             *
101             * @return the source of the event as a <code>RowSorter</code>
102             */
103            public RowSorter getSource() {
104                return (RowSorter) super .getSource();
105            }
106
107            /**
108             * Returns the type of event.
109             *
110             * @return the type of event
111             */
112            public Type getType() {
113                return type;
114            }
115
116            /**
117             * Returns the location of <code>index</code> in terms of the
118             * model prior to the sort.  This method is only useful for events
119             * of type <code>SORTED</code>.  This method will return -1 if the
120             * index is not valid, or the locations prior to the sort have not
121             * been provided.
122             * 
123             * @param index the index in terms of the view
124             * @return the index in terms of the model prior to the sort, or -1 if
125             *         the location is not valid or the mapping was not provided.
126             */
127            public int convertPreviousRowIndexToModel(int index) {
128                if (oldViewToModel != null && index >= 0
129                        && index < oldViewToModel.length) {
130                    return oldViewToModel[index];
131                }
132                return -1;
133            }
134
135            /**
136             * Returns the number of rows before the sort.  This method is only
137             * useful for events of type <code>SORTED</code> and if the
138             * last locations have not been provided will return 0.
139             *
140             * @return the number of rows in terms of the view prior to the sort
141             */
142            public int getPreviousRowCount() {
143                return (oldViewToModel == null) ? 0 : oldViewToModel.length;
144            }
145        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.