xref: /AOO42X/main/dbaccess/qa/complex/dbaccess/RowSetEventListener.java (revision b0efeae40e43e6d4ccd561d22ec612d42773857b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.dbaccess;
25 
26 import com.sun.star.sdb.XRowSetApproveListener;
27 import com.sun.star.sdbc.XRowSetListener;
28 import com.sun.star.sdb.RowChangeEvent;
29 import com.sun.star.lang.EventObject;
30 import com.sun.star.beans.XPropertyChangeListener;
31 
32 public final class RowSetEventListener implements XRowSetApproveListener,XRowSetListener,XPropertyChangeListener
33 {
34     public static final int APPROVE_CURSOR_MOVE = 0;
35     public static final int APPROVE_ROW_CHANGE  = 1;
36     public static final int COLUMN_VALUE        = 2;
37     public static final int CURSOR_MOVED        = 3;
38     public static final int ROW_CHANGED         = 4;
39     public static final int IS_MODIFIED         = 5;
40     public static final int IS_NEW              = 6;
41     public static final int ROW_COUNT           = 7;
42     public static final int IS_ROW_COUNT_FINAL  = 8;
43 
44     int callPos = 1;
45     int calling [];
46 
RowSetEventListener()47     RowSetEventListener(){
48         calling = new int [9];
49         clearCalling();
50     }
getCalling()51     public int[] getCalling(){
52         return calling;
53     }
clearCalling()54     public void clearCalling(){
55         for(int i = 0 ; i < calling.length; ++i){
56             calling[i] = -1;
57         }
58         callPos = 1;
59     }
60     // XEventListener
disposing(com.sun.star.lang.EventObject event)61     public void disposing(com.sun.star.lang.EventObject event)
62     {
63     }
64     // XRowSetApproveBroadcaster
approveCursorMove(EventObject event)65     public boolean approveCursorMove(EventObject event)
66     {
67         calling[APPROVE_CURSOR_MOVE] = callPos++;
68         return true;
69     }
approveRowChange(RowChangeEvent event)70     public boolean approveRowChange(RowChangeEvent event)
71     {
72         calling[APPROVE_ROW_CHANGE] = callPos++;
73         return true;
74     }
approveRowSetChange(EventObject event)75     public boolean approveRowSetChange(EventObject event)
76     {
77         return true;
78     }
79 
80     // XRowSetListener
cursorMoved(com.sun.star.lang.EventObject event)81     public void cursorMoved(com.sun.star.lang.EventObject event)
82     {
83         calling[CURSOR_MOVED] = callPos++;
84     }
rowChanged(com.sun.star.lang.EventObject event)85     public void rowChanged(com.sun.star.lang.EventObject event)
86     {
87         calling[ROW_CHANGED] = callPos++;
88     }
rowSetChanged(com.sun.star.lang.EventObject event)89     public void rowSetChanged(com.sun.star.lang.EventObject event)
90     {
91     }
92 
propertyChange(com.sun.star.beans.PropertyChangeEvent propertyChangeEvent)93     public void propertyChange(com.sun.star.beans.PropertyChangeEvent propertyChangeEvent) {
94         if ( "Value".equals(propertyChangeEvent.PropertyName) ){
95             calling[COLUMN_VALUE] = callPos++;
96         } else if ( "IsModified".equals(propertyChangeEvent.PropertyName) ){
97             calling[IS_MODIFIED] = callPos++;
98         } else if ( "IsNew".equals(propertyChangeEvent.PropertyName) ){
99             calling[IS_NEW] = callPos++;
100         } else if ( "RowCount".equals(propertyChangeEvent.PropertyName) ){
101             calling[ROW_COUNT] = callPos++;
102         } else if ( "IsRowCountFinal".equals(propertyChangeEvent.PropertyName) ){
103             calling[IS_ROW_COUNT_FINAL] = callPos++;
104         }
105     }
106 
107 }
108