xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_XRangeSelection.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir package ifc.sheet;
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole;
30*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
31*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent;
32*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext;
33*cdf0e10cSrcweir import com.sun.star.awt.Point;
34*cdf0e10cSrcweir import com.sun.star.awt.PosSize;
35*cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
36*cdf0e10cSrcweir import com.sun.star.awt.XExtendedToolkit;
37*cdf0e10cSrcweir import com.sun.star.awt.XTopWindow;
38*cdf0e10cSrcweir import com.sun.star.awt.XWindow;
39*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
40*cdf0e10cSrcweir import com.sun.star.frame.XModel;
41*cdf0e10cSrcweir import com.sun.star.lang.EventObject;
42*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
43*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
44*cdf0e10cSrcweir import com.sun.star.sheet.RangeSelectionEvent;
45*cdf0e10cSrcweir import com.sun.star.sheet.XRangeSelection;
46*cdf0e10cSrcweir import com.sun.star.sheet.XRangeSelectionChangeListener;
47*cdf0e10cSrcweir import com.sun.star.sheet.XRangeSelectionListener;
48*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
49*cdf0e10cSrcweir import java.awt.Robot;
50*cdf0e10cSrcweir import java.awt.event.InputEvent;
51*cdf0e10cSrcweir import java.io.PrintWriter;
52*cdf0e10cSrcweir import lib.MultiMethodTest;
53*cdf0e10cSrcweir import lib.Status;
54*cdf0e10cSrcweir import lib.StatusException;
55*cdf0e10cSrcweir import util.AccessibilityTools;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /**
58*cdf0e10cSrcweir  * Check the XRangeSelection interface.
59*cdf0e10cSrcweir  */
60*cdf0e10cSrcweir public class _XRangeSelection extends MultiMethodTest {
61*cdf0e10cSrcweir     public XRangeSelection oObj = null;
62*cdf0e10cSrcweir     MyRangeSelectionListener aListener = null;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     public void before() {
65*cdf0e10cSrcweir         aListener = new _XRangeSelection.MyRangeSelectionListener(log);
66*cdf0e10cSrcweir         // workaround for i34499
67*cdf0e10cSrcweir         XModel xModel = (XModel)tEnv.getObjRelation("FirstModel");
68*cdf0e10cSrcweir         if (xModel == null)
69*cdf0e10cSrcweir             throw new StatusException(Status.failed("Object relation FirstModel' not set."));
70*cdf0e10cSrcweir         XWindow xWindow = xModel.getCurrentController().getFrame().getContainerWindow();
71*cdf0e10cSrcweir         XTopWindow xTopWindow = (XTopWindow)UnoRuntime.queryInterface(XTopWindow.class, xWindow);
72*cdf0e10cSrcweir         xTopWindow.toFront();
73*cdf0e10cSrcweir         util.utils.shortWait(500);
74*cdf0e10cSrcweir     }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     public void _abortRangeSelection() {
78*cdf0e10cSrcweir         requiredMethod("removeRangeSelectionChangeListener()");
79*cdf0e10cSrcweir         requiredMethod("removeRangeSelectionListener()");
80*cdf0e10cSrcweir         oObj.abortRangeSelection();
81*cdf0e10cSrcweir         tRes.tested("abortRangeSelection()", true);
82*cdf0e10cSrcweir     }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     public void _addRangeSelectionChangeListener() {
85*cdf0e10cSrcweir         oObj.addRangeSelectionChangeListener(aListener);
86*cdf0e10cSrcweir         tRes.tested("addRangeSelectionChangeListener()", true);
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     public void _addRangeSelectionListener() {
90*cdf0e10cSrcweir         oObj.addRangeSelectionListener(aListener);
91*cdf0e10cSrcweir         tRes.tested("addRangeSelectionListener()", true);
92*cdf0e10cSrcweir     }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     public void _removeRangeSelectionChangeListener() {
95*cdf0e10cSrcweir         oObj.removeRangeSelectionChangeListener(aListener);
96*cdf0e10cSrcweir         tRes.tested("removeRangeSelectionChangeListener()", true);
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     public void _removeRangeSelectionListener() {
100*cdf0e10cSrcweir         oObj.removeRangeSelectionListener(aListener);
101*cdf0e10cSrcweir         tRes.tested("removeRangeSelectionListener()", true);
102*cdf0e10cSrcweir     }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     public void _startRangeSelection() {
105*cdf0e10cSrcweir         requiredMethod("addRangeSelectionChangeListener()");
106*cdf0e10cSrcweir         requiredMethod("addRangeSelectionListener()");
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         // get the sheet center
109*cdf0e10cSrcweir         Point center = getSheetCenter();;
110*cdf0e10cSrcweir         if (center == null)
111*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't get the sheet center."));
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir         PropertyValue[] props = new PropertyValue[3];
114*cdf0e10cSrcweir         props[0] = new PropertyValue();
115*cdf0e10cSrcweir         props[0].Name = "InitialValue";
116*cdf0e10cSrcweir         props[0].Value = "B3:D5";
117*cdf0e10cSrcweir         props[1] = new PropertyValue();
118*cdf0e10cSrcweir         props[1].Name = "Title";
119*cdf0e10cSrcweir         props[1].Value = "the title";
120*cdf0e10cSrcweir         props[2] = new PropertyValue();
121*cdf0e10cSrcweir         props[2].Name = "CloseOnMouseRelease";
122*cdf0e10cSrcweir         props[2].Value = Boolean.FALSE;
123*cdf0e10cSrcweir         oObj.startRangeSelection(props);
124*cdf0e10cSrcweir         // wait for listeners
125*cdf0e10cSrcweir         util.utils.shortWait(1000);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir         // get closer button: move if window cobvers the sheet center
128*cdf0e10cSrcweir         Point closer = getCloser(center);
129*cdf0e10cSrcweir         if (closer == null)
130*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't get the close Button."));
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         // do something to trigger the listeners
133*cdf0e10cSrcweir         clickOnSheet(center);
134*cdf0e10cSrcweir         util.utils.shortWait(5000);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         // click on closer
137*cdf0e10cSrcweir         clickOnSheet(closer);
138*cdf0e10cSrcweir         util.utils.shortWait(5000);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir //        System.out.println("X: " + closer.X + "    Y: " + closer.Y);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         // just check that we do not have the page instead of the range descriptor
143*cdf0e10cSrcweir /*        int childCount = xRoot.getAccessibleContext().getAccessibleChildCount();
144*cdf0e10cSrcweir         if (childCount > 3) {// too many children: wrong type
145*cdf0e10cSrcweir             throw new StatusException(Status.failed("Could not get the Range Descriptor"));
146*cdf0e10cSrcweir         }
147*cdf0e10cSrcweir         XAccessible xAcc = null;
148*cdf0e10cSrcweir         try {
149*cdf0e10cSrcweir             xAcc = xRoot.getAccessibleContext().getAccessibleChild(1);
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir         catch(com.sun.star.lang.IndexOutOfBoundsException e) {
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir         }
154*cdf0e10cSrcweir         accTools.printAccessibleTree(log, xAcc);
155*cdf0e10cSrcweir */
156*cdf0e10cSrcweir         // open a new range selection
157*cdf0e10cSrcweir         props[0].Value = "C4:E6";
158*cdf0e10cSrcweir         oObj.startRangeSelection(props);
159*cdf0e10cSrcweir         util.utils.shortWait(1000);
160*cdf0e10cSrcweir         props[0].Value = "C2:E3";
161*cdf0e10cSrcweir         oObj.startRangeSelection(props);
162*cdf0e10cSrcweir         util.utils.shortWait(1000);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         oObj.startRangeSelection(props);
165*cdf0e10cSrcweir         util.utils.shortWait(1000);
166*cdf0e10cSrcweir         oObj.abortRangeSelection();
167*cdf0e10cSrcweir         aListener.reset();
168*cdf0e10cSrcweir         System.out.println("Listener called: " + aListener.bAbortCalled);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         tRes.tested("startRangeSelection()", aListener.listenerCalled());
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     /**
174*cdf0e10cSrcweir      * Determine the current top window center and return this as a point.
175*cdf0e10cSrcweir      * @ return a point representing the sheet center.
176*cdf0e10cSrcweir      */
177*cdf0e10cSrcweir     protected Point getSheetCenter() {
178*cdf0e10cSrcweir         log.println("Trying to get AccessibleSpreadsheet");
179*cdf0e10cSrcweir         AccessibilityTools at = new AccessibilityTools();
180*cdf0e10cSrcweir         XComponent xSheetDoc = (XComponent) tEnv.getObjRelation("DOCUMENT");
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir         XModel xModel = (XModel)
183*cdf0e10cSrcweir             UnoRuntime.queryInterface(XModel.class, xSheetDoc);
184*cdf0e10cSrcweir         System.out.println("Name: " + xModel.getCurrentController().getFrame().getName());
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)tParam.getMSF(), xModel);
187*cdf0e10cSrcweir         XAccessible xRoot = at.getAccessibleObject(xWindow);
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         at.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE  );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         XAccessibleComponent AccessibleSpreadsheet = (XAccessibleComponent) UnoRuntime.queryInterface(XAccessibleComponent.class,AccessibilityTools.SearchedContext);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         log.println("Got " + util.utils.getImplName(AccessibleSpreadsheet));
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         Object toolkit = null;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir         try {
198*cdf0e10cSrcweir             toolkit = ((XMultiServiceFactory)tParam.getMSF()).createInstance("com.sun.star.awt.Toolkit");
199*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
200*cdf0e10cSrcweir             log.println("Couldn't get toolkit");
201*cdf0e10cSrcweir             e.printStackTrace(log);
202*cdf0e10cSrcweir             throw new StatusException("Couldn't get toolkit", e);
203*cdf0e10cSrcweir         }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir         XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
206*cdf0e10cSrcweir                                       XExtendedToolkit.class, toolkit);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir         XTopWindow tw = null;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir         int k = tk.getTopWindowCount();
211*cdf0e10cSrcweir         for (int i=0;i<k;i++) {
212*cdf0e10cSrcweir             try {
213*cdf0e10cSrcweir                 XTopWindow tw_temp = tk.getTopWindow(i);
214*cdf0e10cSrcweir                 XAccessible xacc = (XAccessible) UnoRuntime.queryInterface(XAccessible.class,  tw_temp);
215*cdf0e10cSrcweir                 if (xacc != null) {
216*cdf0e10cSrcweir                     if (xacc.getAccessibleContext().getAccessibleName().indexOf("d2")>0) {
217*cdf0e10cSrcweir                         tw=tw_temp;
218*cdf0e10cSrcweir                     };
219*cdf0e10cSrcweir                 } else {
220*cdf0e10cSrcweir                     log.println("\t unknown window");
221*cdf0e10cSrcweir                 }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
224*cdf0e10cSrcweir             }
225*cdf0e10cSrcweir         }
226*cdf0e10cSrcweir         if (tw == null) {
227*cdf0e10cSrcweir             System.out.println("No TopWindow :-(");
228*cdf0e10cSrcweir             return null;
229*cdf0e10cSrcweir         }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         Point point = AccessibleSpreadsheet.getLocationOnScreen();
232*cdf0e10cSrcweir         Rectangle rect = AccessibleSpreadsheet.getBounds();
233*cdf0e10cSrcweir         Point retPoint = new Point();
234*cdf0e10cSrcweir         retPoint.X = point.X + (rect.Width / 2);
235*cdf0e10cSrcweir         retPoint.Y = point.Y + (rect.Height / 2);
236*cdf0e10cSrcweir         return retPoint;
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     /**
240*cdf0e10cSrcweir      * Get the closer button on the right top of the current window.
241*cdf0e10cSrcweir      * @return A point representing the closer button.
242*cdf0e10cSrcweir      */
243*cdf0e10cSrcweir     private Point getCloser(Point center) {
244*cdf0e10cSrcweir         XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
245*cdf0e10cSrcweir         Object aToolkit = null;
246*cdf0e10cSrcweir         try {
247*cdf0e10cSrcweir             aToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit");
248*cdf0e10cSrcweir         }
249*cdf0e10cSrcweir         catch(com.sun.star.uno.Exception e) {
250*cdf0e10cSrcweir             throw new StatusException("Could not create 'com.sun.star.awt.Toolkit'.", e);
251*cdf0e10cSrcweir         }
252*cdf0e10cSrcweir         XExtendedToolkit xExtendedToolkit = (XExtendedToolkit)UnoRuntime.queryInterface(XExtendedToolkit.class, aToolkit);
253*cdf0e10cSrcweir         XTopWindow tw = null;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         XAccessibleComponent xAccessibleComponent = null;
256*cdf0e10cSrcweir         int k = xExtendedToolkit.getTopWindowCount();
257*cdf0e10cSrcweir         for (int i=0;i<k;i++) {
258*cdf0e10cSrcweir             try {
259*cdf0e10cSrcweir                 XTopWindow tw_temp = xExtendedToolkit.getTopWindow(i);
260*cdf0e10cSrcweir                 XAccessible xacc = (XAccessible)UnoRuntime.queryInterface(XAccessible.class,  tw_temp);
261*cdf0e10cSrcweir                 if (xacc != null) {
262*cdf0e10cSrcweir                     System.out.println("Name: " + xacc.getAccessibleContext().getAccessibleName());
263*cdf0e10cSrcweir                     if (xacc.getAccessibleContext().getAccessibleName().startsWith("the title")) {
264*cdf0e10cSrcweir                         tw = tw_temp;
265*cdf0e10cSrcweir                         XAccessibleContext xContext = xacc.getAccessibleContext();
266*cdf0e10cSrcweir                         xAccessibleComponent = (XAccessibleComponent)UnoRuntime.queryInterface(XAccessibleComponent.class, xContext);
267*cdf0e10cSrcweir                         if (xAccessibleComponent == null)
268*cdf0e10cSrcweir                             System.out.println("!!!! MIST !!!!");
269*cdf0e10cSrcweir                         else
270*cdf0e10cSrcweir                             System.out.println("########## KLAPPT ########## ");
271*cdf0e10cSrcweir                     }
272*cdf0e10cSrcweir                 }
273*cdf0e10cSrcweir                 else {
274*cdf0e10cSrcweir                     log.println("\t unknown window");
275*cdf0e10cSrcweir                 }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
278*cdf0e10cSrcweir             }
279*cdf0e10cSrcweir         }
280*cdf0e10cSrcweir         if (tw == null) {
281*cdf0e10cSrcweir             System.out.println("No TopWindow :-(");
282*cdf0e10cSrcweir             return null;
283*cdf0e10cSrcweir         }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         XWindow xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, tw);
286*cdf0e10cSrcweir         Rectangle posSize = xWindow.getPosSize();
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir         // compare the center point with the dimensions of the current top window
289*cdf0e10cSrcweir         boolean windowOK = false;
290*cdf0e10cSrcweir         while(!windowOK) {
291*cdf0e10cSrcweir             if (posSize.X <= center.X && center.X <= posSize.X + posSize.Width) {
292*cdf0e10cSrcweir                 if (posSize.Y <= center.Y && center.Y <= posSize.Y +posSize.Height) {
293*cdf0e10cSrcweir                     // move window out of the way
294*cdf0e10cSrcweir                     posSize.X = posSize.X + 10;
295*cdf0e10cSrcweir                     posSize.Y = posSize.Y +10;
296*cdf0e10cSrcweir                     xWindow.setPosSize(posSize.X, posSize.Y, posSize.Width, posSize.Height, PosSize.POS);
297*cdf0e10cSrcweir                 }
298*cdf0e10cSrcweir                 else {
299*cdf0e10cSrcweir                     windowOK = true;
300*cdf0e10cSrcweir                 }
301*cdf0e10cSrcweir             }
302*cdf0e10cSrcweir             else {
303*cdf0e10cSrcweir                 windowOK = true;
304*cdf0e10cSrcweir             }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         Point p = xAccessibleComponent.getLocationOnScreen();
309*cdf0e10cSrcweir //        System.out.println("ScreenPoint: " + p.X + "   " + p.Y );
310*cdf0e10cSrcweir //        System.out.println("WindowPoint: " + posSize.X + "   " + posSize.Y + "   " + posSize.Width + "   " + posSize.Height);
311*cdf0e10cSrcweir         Point closer = new Point();
312*cdf0e10cSrcweir         closer.X = p.X + posSize.Width - 2;
313*cdf0e10cSrcweir         closer.Y = p.Y + 5;
314*cdf0e10cSrcweir         System.out.println("Closer: " + closer.X + "   " + closer.Y);
315*cdf0e10cSrcweir         return closer;
316*cdf0e10cSrcweir     }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     protected boolean clickOnSheet(Point point) {
319*cdf0e10cSrcweir         log.println("Clicking in the center of the AccessibleSpreadsheet");
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir         try {
322*cdf0e10cSrcweir             Robot rob = new Robot();
323*cdf0e10cSrcweir             rob.mouseMove(point.X, point.Y);
324*cdf0e10cSrcweir             rob.mousePress(InputEvent.BUTTON1_MASK);
325*cdf0e10cSrcweir             util.utils.shortWait(1000);
326*cdf0e10cSrcweir             rob.mouseRelease(InputEvent.BUTTON1_MASK);
327*cdf0e10cSrcweir             util.utils.shortWait(1000);
328*cdf0e10cSrcweir         } catch (java.awt.AWTException e) {
329*cdf0e10cSrcweir             log.println("couldn't press mouse button");
330*cdf0e10cSrcweir         }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir         return true;
333*cdf0e10cSrcweir     }
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     /**
336*cdf0e10cSrcweir      *
337*cdf0e10cSrcweir      */
338*cdf0e10cSrcweir     public static class MyRangeSelectionListener implements XRangeSelectionListener, XRangeSelectionChangeListener {
339*cdf0e10cSrcweir         boolean bAbortCalled = false;
340*cdf0e10cSrcweir         boolean bChangeCalled = false;
341*cdf0e10cSrcweir         boolean bDoneCalled = false;
342*cdf0e10cSrcweir         PrintWriter log = null;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir         public MyRangeSelectionListener(PrintWriter log) {
345*cdf0e10cSrcweir             this.log = log;
346*cdf0e10cSrcweir         }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         public void aborted(RangeSelectionEvent rangeSelectionEvent) {
349*cdf0e10cSrcweir             log.println("Called 'aborted' with: " + rangeSelectionEvent.RangeDescriptor);
350*cdf0e10cSrcweir             bAbortCalled = true;
351*cdf0e10cSrcweir         }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         public void descriptorChanged(RangeSelectionEvent rangeSelectionEvent) {
354*cdf0e10cSrcweir             log.println("Called 'descriptorChanged' with: " + rangeSelectionEvent.RangeDescriptor);
355*cdf0e10cSrcweir             bChangeCalled = true;
356*cdf0e10cSrcweir         }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         public void done(RangeSelectionEvent rangeSelectionEvent) {
359*cdf0e10cSrcweir             log.println("Called 'done' with: " + rangeSelectionEvent.RangeDescriptor);
360*cdf0e10cSrcweir             bDoneCalled = true;
361*cdf0e10cSrcweir         }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         public boolean listenerCalled() {
364*cdf0e10cSrcweir             return bAbortCalled & bChangeCalled & bDoneCalled;
365*cdf0e10cSrcweir         }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir         public void reset() {
368*cdf0e10cSrcweir             bAbortCalled = false;
369*cdf0e10cSrcweir             bChangeCalled = false;
370*cdf0e10cSrcweir             bDoneCalled = false;
371*cdf0e10cSrcweir         }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir         /**
374*cdf0e10cSrcweir          * ignore disposing
375*cdf0e10cSrcweir          * @param eventObject The event.
376*cdf0e10cSrcweir          */
377*cdf0e10cSrcweir         public void disposing(EventObject eventObject) {
378*cdf0e10cSrcweir         }
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir }
381