Source Code Cross Referenced for QuickFindWidget.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » brms » client » rulelist » 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 » Rule Engine » drolls Rule Engine » org.drools.brms.client.rulelist 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.brms.client.rulelist;
002:
003:        /*
004:         * Copyright 2005 JBoss Inc
005:         * 
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *      http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import org.drools.brms.client.common.AutoCompleteTextBoxAsync;
020:        import org.drools.brms.client.common.CompletionItemsAsync;
021:        import org.drools.brms.client.common.CompletionItemsAsyncReturn;
022:        import org.drools.brms.client.common.FormStyleLayout;
023:        import org.drools.brms.client.common.GenericCallback;
024:        import org.drools.brms.client.common.LoadingPopup;
025:        import org.drools.brms.client.rpc.RepositoryServiceFactory;
026:        import org.drools.brms.client.rpc.TableDataResult;
027:        import org.drools.brms.client.rpc.TableDataRow;
028:
029:        import com.google.gwt.user.client.ui.Button;
030:        import com.google.gwt.user.client.ui.CheckBox;
031:        import com.google.gwt.user.client.ui.ClickListener;
032:        import com.google.gwt.user.client.ui.Composite;
033:        import com.google.gwt.user.client.ui.FlexTable;
034:        import com.google.gwt.user.client.ui.HTML;
035:        import com.google.gwt.user.client.ui.HorizontalPanel;
036:        import com.google.gwt.user.client.ui.KeyboardListener;
037:        import com.google.gwt.user.client.ui.Label;
038:        import com.google.gwt.user.client.ui.TextBox;
039:        import com.google.gwt.user.client.ui.Widget;
040:
041:        /**
042:         * This is for quickly finding an asset by name. Partial completion is allowed.
043:         * This also uses some auto completion magic.
044:         * @author Michael Neale
045:         */
046:        public class QuickFindWidget extends Composite {
047:
048:            private final FormStyleLayout layout;
049:            private final FlexTable listPanel;
050:            private final TextBox searchBox;
051:            private CheckBox archiveBox;
052:            private EditItemEvent editEvent;
053:            private String[] shortListItems;
054:
055:            public QuickFindWidget(EditItemEvent editEvent) {
056:                layout = new FormStyleLayout("images/system_search.png", "");
057:
058:                searchBox = new AutoCompleteTextBoxAsync(
059:                        new CompletionItemsAsync() {
060:
061:                            public void getCompletionItems(String match,
062:                                    CompletionItemsAsyncReturn asyncReturn) {
063:                                loadShortList(match, asyncReturn);
064:
065:                            }
066:
067:                        });
068:                searchBox.setStyleName("gwt-TextBox");
069:
070:                this .editEvent = editEvent;
071:                HorizontalPanel srch = new HorizontalPanel();
072:                Button go = new Button("Go");
073:                go.addClickListener(new ClickListener() {
074:                    public void onClick(Widget w) {
075:                        updateList();
076:                    }
077:                });
078:
079:                srch.add(searchBox);
080:                srch.add(go);
081:
082:                archiveBox = new CheckBox("Include archived items in list");
083:                archiveBox.setStyleName("small-Text");
084:                archiveBox.setChecked(false);
085:
086:                layout.addAttribute("Find items with a name matching:", srch);
087:                layout.addRow(archiveBox);
088:                layout.addRow(new HTML("<hr/>"));
089:
090:                listPanel = new FlexTable();
091:                listPanel
092:                        .setWidget(
093:                                0,
094:                                0,
095:                                new HTML(
096:                                        "<img src='images/information.gif'/>&nbsp;Enter the name or part of a name. Alternatively, use the categories to browse."));
097:                layout.addRow(listPanel);
098:
099:                listPanel.setStyleName("editable-Surface");
100:
101:                searchBox.addKeyboardListener(getKeyboardListener());
102:
103:                layout.setStyleName("quick-find");
104:
105:                initWidget(layout);
106:            }
107:
108:            /**
109:             * This will load a list of items as they are typing.
110:             */
111:            protected String[] loadShortList(String match,
112:                    final CompletionItemsAsyncReturn returnItems) {
113:                RepositoryServiceFactory.getService().quickFindAsset(match, 5,
114:                        archiveBox.isChecked(), new GenericCallback() {
115:
116:                            public void onSuccess(Object data) {
117:                                TableDataResult result = (TableDataResult) data;
118:                                String[] items = new String[result.data.length];
119:                                for (int i = 0; i < result.data.length; i++) {
120:                                    if (!result.data[i].id.equals("MORE")) {
121:                                        items[i] = result.data[i].values[0];
122:                                    }
123:                                }
124:                                returnItems.itemReturn(items);
125:                            }
126:
127:                        });
128:                return shortListItems;
129:            }
130:
131:            private KeyboardListener getKeyboardListener() {
132:                return new KeyboardListener() {
133:                    public void onKeyDown(Widget arg0, char arg1, int arg2) {
134:                    }
135:
136:                    public void onKeyPress(Widget arg0, char arg1, int arg2) {
137:                    }
138:
139:                    public void onKeyUp(Widget arg0, char arg1, int arg2) {
140:                        if (arg1 == KEY_ENTER) {
141:
142:                            updateList();
143:                        }
144:                    }
145:
146:                };
147:            }
148:
149:            protected void updateList() {
150:
151:                LoadingPopup.showMessage("Searching...");
152:                RepositoryServiceFactory.getService().quickFindAsset(
153:                        searchBox.getText(), 15, archiveBox.isChecked(),
154:                        new GenericCallback() {
155:                            public void onSuccess(Object data) {
156:                                TableDataResult result = (TableDataResult) data;
157:                                populateList(result);
158:
159:                            }
160:                        });
161:
162:            }
163:
164:            protected void populateList(TableDataResult result) {
165:
166:                FlexTable data = new FlexTable();
167:
168:                //if its only one, just open it...
169:                if (result.data.length == 1) {
170:                    editEvent.open(result.data[0].id);
171:                }
172:
173:                for (int i = 0; i < result.data.length; i++) {
174:
175:                    final TableDataRow row = result.data[i];
176:                    if (row.id.equals("MORE")) {
177:                        data
178:                                .setWidget(
179:                                        i,
180:                                        0,
181:                                        new HTML(
182:                                                "<i>There are more items... try narrowing the search terms..</i>"));
183:                        data.getFlexCellFormatter().setColSpan(i, 0, 3);
184:                    } else {
185:                        data.setWidget(i, 0, new Label(row.values[0]));
186:                        data.setWidget(i, 1, new Label(row.values[1]));
187:                        Button open = new Button("Open");
188:                        open.addClickListener(new ClickListener() {
189:                            public void onClick(Widget w) {
190:                                editEvent.open(row.id);
191:                            }
192:                        });
193:
194:                        data.setWidget(i, 2, open);
195:                    }
196:
197:                }
198:
199:                data.setWidth("100%");
200:                listPanel.setWidget(0, 0, data);
201:
202:                LoadingPopup.close();
203:
204:            }
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.