1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package complex.dbaccess; 29 30 import com.sun.star.sdb.XRowSetApproveListener; 31 import com.sun.star.sdbc.XRowSetListener; 32 import com.sun.star.sdb.RowChangeEvent; 33 import com.sun.star.lang.EventObject; 34 import com.sun.star.beans.XPropertyChangeListener; 35 36 public final class RowSetEventListener implements XRowSetApproveListener,XRowSetListener,XPropertyChangeListener 37 { 38 public static final int APPROVE_CURSOR_MOVE = 0; 39 public static final int APPROVE_ROW_CHANGE = 1; 40 public static final int COLUMN_VALUE = 2; 41 public static final int CURSOR_MOVED = 3; 42 public static final int ROW_CHANGED = 4; 43 public static final int IS_MODIFIED = 5; 44 public static final int IS_NEW = 6; 45 public static final int ROW_COUNT = 7; 46 public static final int IS_ROW_COUNT_FINAL = 8; 47 48 int callPos = 1; 49 int calling []; 50 51 RowSetEventListener(){ 52 calling = new int [9]; 53 clearCalling(); 54 } 55 public int[] getCalling(){ 56 return calling; 57 } 58 public void clearCalling(){ 59 for(int i = 0 ; i < calling.length; ++i){ 60 calling[i] = -1; 61 } 62 callPos = 1; 63 } 64 // XEventListener 65 public void disposing(com.sun.star.lang.EventObject event) 66 { 67 } 68 // XRowSetApproveBroadcaster 69 public boolean approveCursorMove(EventObject event) 70 { 71 calling[APPROVE_CURSOR_MOVE] = callPos++; 72 return true; 73 } 74 public boolean approveRowChange(RowChangeEvent event) 75 { 76 calling[APPROVE_ROW_CHANGE] = callPos++; 77 return true; 78 } 79 public boolean approveRowSetChange(EventObject event) 80 { 81 return true; 82 } 83 84 // XRowSetListener 85 public void cursorMoved(com.sun.star.lang.EventObject event) 86 { 87 calling[CURSOR_MOVED] = callPos++; 88 } 89 public void rowChanged(com.sun.star.lang.EventObject event) 90 { 91 calling[ROW_CHANGED] = callPos++; 92 } 93 public void rowSetChanged(com.sun.star.lang.EventObject event) 94 { 95 } 96 97 public void propertyChange(com.sun.star.beans.PropertyChangeEvent propertyChangeEvent) { 98 if ( "Value".equals(propertyChangeEvent.PropertyName) ){ 99 calling[COLUMN_VALUE] = callPos++; 100 } else if ( "IsModified".equals(propertyChangeEvent.PropertyName) ){ 101 calling[IS_MODIFIED] = callPos++; 102 } else if ( "IsNew".equals(propertyChangeEvent.PropertyName) ){ 103 calling[IS_NEW] = callPos++; 104 } else if ( "RowCount".equals(propertyChangeEvent.PropertyName) ){ 105 calling[ROW_COUNT] = callPos++; 106 } else if ( "IsRowCountFinal".equals(propertyChangeEvent.PropertyName) ){ 107 calling[IS_ROW_COUNT_FINAL] = callPos++; 108 } 109 } 110 111 } 112