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 package complex.toolkit.awtgrid;
23 
24 import com.sun.star.awt.grid.GridDataEvent;
25 import com.sun.star.awt.grid.XGridDataListener;
26 import com.sun.star.lang.EventObject;
27 import static org.junit.Assert.*;
28 
29 final public class GridDataListener implements XGridDataListener
30 {
GridDataListener()31     public GridDataListener()
32     {
33     }
34 
rowsInserted( GridDataEvent i_event )35     public void rowsInserted( GridDataEvent i_event )
36     {
37         assertNull( m_rowInsertionEvent );
38         m_rowInsertionEvent = i_event;
39     }
40 
rowsRemoved( GridDataEvent i_event )41     public void rowsRemoved( GridDataEvent i_event )
42     {
43         assertNull( m_rowRemovalEvent );
44         m_rowRemovalEvent = i_event;
45     }
46 
dataChanged( GridDataEvent i_event )47     public void dataChanged( GridDataEvent i_event )
48     {
49         assertNull( m_dataChangeEvent );
50         m_dataChangeEvent = i_event;
51     }
52 
rowHeadingChanged( GridDataEvent i_event )53     public void rowHeadingChanged( GridDataEvent i_event )
54     {
55         assertNull( m_rowHeadingChangeEvent );
56         m_rowHeadingChangeEvent = i_event;
57     }
58 
disposing( EventObject eo )59     public void disposing( EventObject eo )
60     {
61         m_disposed = true;
62     }
63 
assertSingleRowInsertionEvent()64     public final GridDataEvent assertSingleRowInsertionEvent()
65     {
66         assertNotNull( m_rowInsertionEvent );
67         assertNull( m_rowRemovalEvent );
68         assertNull( m_dataChangeEvent );
69         assertNull( m_rowHeadingChangeEvent );
70         assertFalse( m_disposed );
71         return m_rowInsertionEvent;
72     }
73 
assertSingleRowRemovalEvent()74     public final GridDataEvent assertSingleRowRemovalEvent()
75     {
76         assertNull( m_rowInsertionEvent );
77         assertNotNull( m_rowRemovalEvent );
78         assertNull( m_dataChangeEvent );
79         assertNull( m_rowHeadingChangeEvent );
80         assertFalse( m_disposed );
81         return m_rowRemovalEvent;
82     }
83 
assertSingleDataChangeEvent()84     public final GridDataEvent assertSingleDataChangeEvent()
85     {
86         assertNull( m_rowInsertionEvent );
87         assertNull( m_rowRemovalEvent );
88         assertNotNull( m_dataChangeEvent );
89         assertNull( m_rowHeadingChangeEvent );
90         assertFalse( m_disposed );
91         return m_dataChangeEvent;
92     }
93 
assertSingleRowHeadingChangeEvent()94     public final GridDataEvent assertSingleRowHeadingChangeEvent()
95     {
96         assertNull( m_rowInsertionEvent );
97         assertNull( m_rowRemovalEvent );
98         assertNull( m_dataChangeEvent );
99         assertNotNull( m_rowHeadingChangeEvent );
100         assertFalse( m_disposed );
101         return m_rowHeadingChangeEvent;
102     }
103 
isDisposed()104     public final boolean isDisposed()
105     {
106         return m_disposed;
107     }
108 
reset()109     public final void reset()
110     {
111         m_rowInsertionEvent = m_rowRemovalEvent = m_dataChangeEvent = m_rowHeadingChangeEvent = null;
112         // m_disposed is not reset intentionally
113     }
114     private GridDataEvent m_rowInsertionEvent = null;
115     private GridDataEvent m_rowRemovalEvent = null;
116     private GridDataEvent m_dataChangeEvent = null;
117     private GridDataEvent m_rowHeadingChangeEvent = null;
118     private boolean m_disposed = false;
119 }
120