Source Code Cross Referenced for SearchView.java in  » Portal » Open-Portal » components » 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 » Portal » Open Portal » components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *  NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *  Copyright (c) 1996 Netscape Communications Corporation.
006:         *  All Rights Reserved.
007:         *  Use of this Source Code is subject to the terms of the applicable
008:         *  license agreement from Netscape Communications Corporation.
009:         */
010:
011:        package components;
012:
013:        import soif.CSID;
014:        import soif.Results;
015:        import soif.SOIF;
016:        import soif.Search;
017:        import soif.Taxonomy;
018:        import soif.TaxonomyNode;
019:        import util.Key;
020:        import util.SysInfo;
021:
022:        import netscape.application.Button;
023:        import netscape.application.Color;
024:        import netscape.application.Rect;
025:        import netscape.application.Size;
026:        import netscape.application.Target;
027:        import netscape.application.TextField;
028:        import netscape.application.View;
029:
030:        import components.SearchPopupField;
031:        import components.SearchTextField;
032:
033:        /**
034:         Search panel w/ button and textfield.
035:         *
036:         */
037:        public class SearchView extends View implements  Target {
038:            public Button searchBtn;
039:            public SearchTextField searchTF;
040:            public SearchPopupField searchPF;
041:            private String CGILocation;
042:            private String CGITarget;
043:            private CSID csid;
044:            private Search search; // SGP: why private?  could
045:            // eliminate methods.
046:
047:            // SGP: i don't suppose these need to be private,
048:            // unless some kind of validation is going to happen.
049:            private String display;
050:            private String sort;
051:            private int count;
052:            private String ql;
053:
054:            private boolean m_showPopup = false;
055:            private boolean m_showText = true;
056:
057:            /**
058:             * Constructor.
059:             */
060:            public SearchView(int x, int y, int width, int height,
061:                    String CGILocation, String CGITarget, CSID csid,
062:                    String display, String sort, int count, String ql) {
063:                super (x, y, width, height);
064:
065:                this .CGILocation = CGILocation;
066:                this .CGITarget = CGITarget;
067:                this .csid = csid;
068:                this .display = display;
069:                this .sort = sort;
070:                this .count = count;
071:                this .ql = ql;
072:
073:                search = new Search();
074:
075:                searchBtn = new Button();
076:                searchBtn.setTitle(Messages.CMD_SEARCH);
077:                searchBtn.setCommand(Messages.CMD_SEARCH);
078:                searchBtn.setBounds(width - searchBtn.minSize().width
079:                // SGP: why 2?
080:                        - (graphical.Header.WIDGETHGAP ),
081:                        graphical.Header.WIDGETVGAP, searchBtn.minSize().width,
082:                        searchBtn.minSize().height);
083:                searchBtn.setTarget(this );
084:                searchBtn
085:                        .setHorizResizeInstruction(View.LEFT_MARGIN_CAN_CHANGE);
086:
087:                // Create text entry field (default), but do not add it to view until used.
088:                searchTF = new SearchTextField(graphical.Header.WIDGETHGAP,
089:                        graphical.Header.WIDGETVGAP, width
090:                                - (graphical.Header.WIDGETHGAP * 3)
091:                                - searchBtn.width(), searchBtn.height());
092:                searchTF.setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
093:                searchTF.setBackgroundColor(Color.lightGray);
094:                searchTF.setCommand(Messages.CMD_SEARCH);
095:                searchTF.setTarget(this );
096:
097:                // Create popup entry field but do not add it to view until used.
098:                Rect boundsRect = searchTF.bounds();
099:                searchPF = new SearchPopupField(boundsRect);
100:                searchPF.setHorizResizeInstruction(View.WIDTH_CAN_CHANGE);
101:
102:                addSubview(searchBtn);
103:            }
104:
105:            /**
106:             * Set the attributes to be retrieved.
107:             * @param display attribute list, e.g. "score,url,title"
108:             */
109:            public void setDisplay(String display) {
110:                this .display = display;
111:            }
112:
113:            /**
114:             * Set the attributes to sort by.
115:             * @param sort sort list, e.g. "-score,+title"
116:             */
117:            public void setSort(String sort) {
118:                this .sort = sort;
119:            }
120:
121:            /**
122:             * Set the attributes to sort by.
123:             * @param sort sort list, e.g. "-score,+title"
124:             */
125:            public void setCount(int count) {
126:                this .count = count;
127:            }
128:
129:            public int getStatus() {
130:                return search.getStatus();
131:            }
132:
133:            public SOIF getSOIFResult() {
134:                return search.getSOIFResult();
135:            }
136:
137:            public int resultCount() {
138:                return search.resultCount();
139:            }
140:
141:            public Size minSize() {
142:                return new Size(searchTF.width()
143:                        + (graphical.Header.WIDGETHGAP * 3)
144:                        + searchBtn.minSize().width, searchTF.minSize().height
145:                        + (graphical.Header.WIDGETVGAP * 2));
146:            }
147:
148:            /**
149:             * Enable/Disable SearchView data entry field.
150:             */
151:            public void enableTextField(boolean enable) {
152:                if (enable == true) {
153:                    searchTF.setEditable(true);
154:                    searchTF.setSelectable(true);
155:                    searchTF.startFocus();
156:                    searchTF.setTextColor(graphical.Header.TEXTCOLOR);
157:                } else {
158:                    searchTF.setEditable(false);
159:                    searchTF.setSelectable(false);
160:                    searchTF.stopFocus();
161:                    searchTF.setTextColor(graphical.Header.DISABLEDTEXTCOLOR);
162:                }
163:            }
164:
165:            /**
166:             * Show SearchView data entry field as a TextField.
167:             */
168:            public void showTextField(boolean show) {
169:                if (show == m_showText) {
170:                    return;
171:                }
172:
173:                if (show == true) {
174:                    Rect boundsRect = this .bounds(); // View bounds
175:                    // Reposition text fiels as window could have been resized since
176:                    // last displayed and we want field to fill window.
177:                    boundsRect = new Rect(graphical.Header.WIDGETHGAP,
178:                            graphical.Header.WIDGETVGAP, boundsRect.width
179:                                    - (graphical.Header.WIDGETHGAP * 3)
180:                                    - searchBtn.width(), searchBtn.height());
181:                    searchTF.setBounds(boundsRect);
182:                    addSubview(searchTF);
183:                    setDirty(true);
184:                } else {
185:                    searchTF.removeFromSuperview();
186:                    setDirty(true);
187:                }
188:
189:                m_showText = show;
190:            }
191:
192:            /**
193:             * Show SearchView data entry field as a Popup.
194:             */
195:            public void showPopupField(boolean show) {
196:                if (show == m_showPopup) {
197:                    return;
198:                }
199:
200:                if (show == true) {
201:                    setDirty(true);
202:                    Rect boundsRect = this .bounds(); // View bounds
203:                    // Reposition popup as window could have been resized since
204:                    // last displayed and we want field to fill window.
205:                    boundsRect = new Rect(graphical.Header.WIDGETHGAP,
206:                            graphical.Header.WIDGETVGAP, boundsRect.width
207:                                    - (graphical.Header.WIDGETHGAP * 3)
208:                                    - searchBtn.width(), searchBtn.height());
209:                    searchPF.setBounds(boundsRect);
210:                    addSubview(searchPF);
211:                } else {
212:                    searchPF.removeFromSuperview();
213:                    setDirty(true);
214:                }
215:
216:                m_showPopup = show;
217:            }
218:
219:            /**
220:             * Load SearchView data entry popup field.
221:             */
222:            public void loadPopupField(Taxonomy taxonomy) {
223:                //        System.out.println("taxonomy=======\n" + taxonomy + "\n=======");
224:                searchPF.removeAllItems();
225:                taxonomy.binaryTree.resetEnumeration();
226:
227:                while (taxonomy.binaryTree.hasMoreElements(true)) {
228:                    taxonomy.binaryTree.nextElement(true);
229:                    Object o = taxonomy.binaryTree.getValue();
230:
231:                    if (o instanceof  TaxonomyNode) {
232:                        searchPF.addItem(((TaxonomyNode) o).getId(),
233:                                ((TaxonomyNode) o).getId());
234:                    }
235:                }
236:            }
237:
238:            public void searchBtnPress() {
239:                searchTF.setEditable(false);
240:                searchBtn.setEnabled(false);
241:                draw();
242:
243:                search = new Search(searchTF.stringValue(), display, sort,
244:                        count, ql, csid, CGILocation);
245:
246:                search.doQuery();
247:
248:                searchTF.setEditable(true);
249:                searchBtn.setEnabled(true);
250:                draw();
251:
252:                // SGP: some sort of callback
253:            }
254:
255:            public void performCommand(String command, Object arg) {
256:                if (Messages.CMD_SEARCH.equals(command)) {
257:                    searchBtnPress();
258:                }
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.