~ubuntu-branches/ubuntu/trusty/libswingx-java/trusty

« back to all changes in this revision

Viewing changes to src/test/org/jdesktop/test/FocusEventReport.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-11-02 00:17:00 UTC
  • mfrom: (4.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091102001700-j5k1sy0wdtsp63re
Tags: 1:1.0-1
* New upstream release.
* New "libswingx-java-doc" package:
  - contains API javadoc documentation
* Bump Standards-Version to 3.8.3
  - Change section to "java"
  - Rename debian/README.Debian-source to debian/README.source
  - Describe quilt patch system in debian/README.source
* Bump debhelper version to >= 7
* Remove unused Depends on ${shlibs:Depends}
* Default JRE:
  - Build-Depends on default-jdk
  - Use /usr/lib/jvm/default-java as JAVA_HOME
* Add myself to Uploaders
* Use DEP5 format for debian/copyright
* Maven POMs:
  - Add a Build-Depends-Indep dependency on maven-repo-helper
  - Use mh_installpoms and mh_installjar to install the POM and the jar to the
    Maven repository
  - Remove unneeded dependencies in pom.diff patch
* Maven ant helper (build system):
  - Add a Build-Depends dependency on maven-ant-helper
  - Update debian/build.xml to use /usr/share/maven-ant-helper/maven-build.xml
  - Build classpath is now defined in debian/build.properties

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 16.04.2009
 
3
 *
 
4
 */
 
5
package org.jdesktop.test;
 
6
 
 
7
import java.awt.event.FocusEvent;
 
8
import java.awt.event.FocusListener;
 
9
import java.util.Collections;
 
10
import java.util.LinkedList;
 
11
import java.util.List;
 
12
 
 
13
public class FocusEventReport implements FocusListener {
 
14
 
 
15
    
 
16
    /**
 
17
     * Holds a list of all canceled events.
 
18
     */
 
19
    protected List<FocusEvent> canceledEvents = Collections.synchronizedList(new LinkedList<FocusEvent>());
 
20
    protected List<FocusEvent> stoppedEvents = Collections.synchronizedList(new LinkedList<FocusEvent>());
 
21
    protected List<FocusEvent> allEvents = Collections.synchronizedList(new LinkedList<FocusEvent>());
 
22
    
 
23
    
 
24
//------------------------ implement FocusListener
 
25
 
 
26
    
 
27
    public void focusGained(FocusEvent e) {
 
28
        canceledEvents.add(0, e);
 
29
        allEvents.add(0, e);
 
30
    }
 
31
    
 
32
    
 
33
    public void focusLost(FocusEvent e) {
 
34
        stoppedEvents.add(0, e);
 
35
        allEvents.add(0, e);
 
36
        
 
37
    }
 
38
    
 
39
//----------------------- utility methods to access all events    
 
40
    public void clear() {
 
41
        canceledEvents.clear();
 
42
        stoppedEvents.clear();
 
43
        allEvents.clear();
 
44
    }
 
45
 
 
46
    public int getEventCount() {
 
47
        return allEvents.size();
 
48
    }
 
49
     
 
50
    public boolean hasEvents() {
 
51
        return !allEvents.isEmpty();
 
52
    }
 
53
 
 
54
    public FocusEvent getLastEvent() {
 
55
        return allEvents.isEmpty()
 
56
            ? null
 
57
            : allEvents.get(0);
 
58
    }
 
59
 
 
60
//------------------ access canceled events
 
61
    public int getCanceledEventCount() {
 
62
        return canceledEvents.size();
 
63
    }
 
64
    
 
65
    public boolean hasCanceledEvents() {
 
66
        return !canceledEvents.isEmpty();
 
67
    }
 
68
    
 
69
    public FocusEvent getLastCanceledEvent() {
 
70
        return canceledEvents.isEmpty()
 
71
        ? null
 
72
                : canceledEvents.get(0);
 
73
    }
 
74
 
 
75
//----------------- access stopped events
 
76
    
 
77
    public int getStoppedEventCount() {
 
78
        return stoppedEvents.size();
 
79
    }
 
80
    
 
81
    public boolean hasStoppedEvents() {
 
82
        return !stoppedEvents.isEmpty();
 
83
    }
 
84
    
 
85
    public FocusEvent getLastStoppedEvent() {
 
86
        return stoppedEvents.isEmpty()
 
87
        ? null
 
88
                : stoppedEvents.get(0);
 
89
    }
 
90
 
 
91
}