Source Code Cross Referenced for SearchQueryBinding.java in  » Database-Client » prefuse » prefuse » data » query » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » prefuse » prefuse.data.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.data.query;
002:
003:        import javax.swing.JComponent;
004:
005:        import prefuse.data.Tuple;
006:        import prefuse.data.event.TupleSetListener;
007:        import prefuse.data.expression.AbstractPredicate;
008:        import prefuse.data.search.PrefixSearchTupleSet;
009:        import prefuse.data.search.SearchTupleSet;
010:        import prefuse.data.tuple.TupleSet;
011:        import prefuse.util.ui.JSearchPanel;
012:        import prefuse.visual.VisualTupleSet;
013:
014:        /**
015:         * DynamicQueryBinding supporting text search over data values. Implementations
016:         * of the {@link prefuse.data.search.SearchTupleSet} class from the
017:         * {@link prefuse.data.search} package can be used to control the type of
018:         * search index used.
019:         * 
020:         * @author <a href="http://jheer.org">jeffrey heer</a>
021:         * @see prefuse.data.search.SearchTupleSet
022:         */
023:        public class SearchQueryBinding extends DynamicQueryBinding {
024:
025:            private SearchTupleSet m_set;
026:            private Listener m_lstnr;
027:            private Object m_lock;
028:
029:            /**
030:             * Create a new SearchQueryBinding over the given set and data field.
031:             * @param ts the TupleSet to query
032:             * @param field the data field (Table column) to query
033:             */
034:            public SearchQueryBinding(TupleSet ts, String field) {
035:                this (ts, field, new PrefixSearchTupleSet());
036:            }
037:
038:            /**
039:             * Create a new SearchQueryBinding over the given set and data field,
040:             * using the specified SearchTupleSet instance. Use this constructor to
041:             * choose the type of search engine used, and to potentially reuse the
042:             * same search set over multiple dynamic query bindings.
043:             * @param ts the TupleSet to query
044:             * @param field the data field (Table column) to query
045:             * @param set the {@link prefuse.data.search.SearchTupleSet} to use.
046:             */
047:            public SearchQueryBinding(TupleSet ts, String field,
048:                    SearchTupleSet set) {
049:                super (ts, field);
050:                m_lstnr = new Listener();
051:                setPredicate(new SearchBindingPredicate());
052:
053:                m_set = set;
054:                m_set.index(ts.tuples(), field);
055:                m_set.addTupleSetListener(m_lstnr);
056:
057:                if (ts instanceof  VisualTupleSet)
058:                    m_lock = ((VisualTupleSet) ts).getVisualization();
059:            }
060:
061:            /**
062:             * Return the SearchTupleSet used for conducting searches.
063:             * @return the {@link prefuse.data.search.SearchTupleSet} used by this
064:             * dynamic query binding.
065:             */
066:            public SearchTupleSet getSearchSet() {
067:                return m_set;
068:            }
069:
070:            // ------------------------------------------------------------------------
071:
072:            /**
073:             * Create a new search text panel for searching over the data.
074:             * @return a {@link prefuse.util.ui.JSearchPanel} bound to this
075:             * dynamic query.
076:             * @see prefuse.data.query.DynamicQueryBinding#createComponent()
077:             */
078:            public JComponent createComponent() {
079:                return createSearchPanel();
080:            }
081:
082:            /**
083:             * Create a new search text panel for searching over the data.
084:             * @return a {@link prefuse.util.ui.JSearchPanel} bound to this
085:             * dynamic query.
086:             */
087:            public JSearchPanel createSearchPanel() {
088:                return createSearchPanel(m_set instanceof  PrefixSearchTupleSet);
089:            }
090:
091:            /**
092:             * Create a new search text panel for searching over the data.
093:             * @param monitorKeystrokes if true, each keystroke will cause the
094:             * search to be re-run (this is the default for prefix searches);
095:             * if false, searches will only re-run when the enter key is typed
096:             * (this is the default for the other search engine types).
097:             * @return a {@link prefuse.util.ui.JSearchPanel} bound to this
098:             * dynamic query.
099:             */
100:            public JSearchPanel createSearchPanel(boolean monitorKeystrokes) {
101:                JSearchPanel jsp = new JSearchPanel(m_set, m_field,
102:                        monitorKeystrokes);
103:                if (m_lock != null) {
104:                    jsp.setLock(m_lock);
105:                }
106:                return jsp;
107:            }
108:
109:            // ------------------------------------------------------------------------
110:
111:            private class SearchBindingPredicate extends AbstractPredicate {
112:                public boolean getBoolean(Tuple t) {
113:                    String q = m_set.getQuery();
114:                    return (q == null || q.length() == 0 || m_set
115:                            .containsTuple(t));
116:                }
117:
118:                public void touch() {
119:                    this .fireExpressionChange();
120:                }
121:            }
122:
123:            private class Listener implements  TupleSetListener {
124:                public void tupleSetChanged(TupleSet tset, Tuple[] added,
125:                        Tuple[] removed) {
126:                    ((SearchBindingPredicate) getPredicate()).touch();
127:                }
128:            }
129:
130:        } // end of class SearchQueryBinding
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.