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


001:        package org.drools.brms.client.ruleeditor;
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.categorynav.CategoryExplorerWidget;
020:        import org.drools.brms.client.categorynav.CategorySelectHandler;
021:        import org.drools.brms.client.common.AssetFormats;
022:        import org.drools.brms.client.common.FormStylePopup;
023:        import org.drools.brms.client.common.GenericCallback;
024:        import org.drools.brms.client.common.ImageButton;
025:        import org.drools.brms.client.common.LoadingPopup;
026:        import org.drools.brms.client.common.RulePackageSelector;
027:        import org.drools.brms.client.common.WarningPopup;
028:        import org.drools.brms.client.rpc.RepositoryServiceFactory;
029:        import org.drools.brms.client.rulelist.EditItemEvent;
030:
031:        import com.google.gwt.user.client.ui.Button;
032:        import com.google.gwt.user.client.ui.ClickListener;
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.Label;
036:        import com.google.gwt.user.client.ui.ListBox;
037:        import com.google.gwt.user.client.ui.TextArea;
038:        import com.google.gwt.user.client.ui.TextBox;
039:        import com.google.gwt.user.client.ui.Widget;
040:
041:        /**
042:         * This provides a popup for creating a new rule/asset from scratch.
043:         * reuses a few other widgets.
044:         */
045:        public class NewAssetWizard extends FormStylePopup {
046:
047:            private TextBox name = new TextBox();
048:            private TextArea description = new TextArea();
049:            private String initialCategory;
050:
051:            private ListBox formatChooser = getFormatChooser();
052:
053:            private RulePackageSelector packageSelector = new RulePackageSelector();
054:            private EditItemEvent afterCreate;
055:            private boolean showCats;
056:            private String format;
057:
058:            /** This is used when creating a new rule. */
059:            public NewAssetWizard(EditItemEvent afterCreate, boolean showCats,
060:                    String format, String title) {
061:                super ("images/new_wiz.gif", title);
062:                this .showCats = showCats;
063:                this .format = format;
064:
065:                this .afterCreate = afterCreate;
066:
067:                addAttribute("Name:", name);
068:
069:                if (showCats) {
070:                    addAttribute("Initial category:", getCatChooser());
071:                }
072:
073:                if (format == null) {
074:                    addAttribute("Type (format) of rule:", this .formatChooser);
075:                }
076:
077:                addAttribute("Package:", packageSelector);
078:
079:                description.setVisibleLines(4);
080:                description.setWidth("100%");
081:                addAttribute("Initial description:", description);
082:
083:                Button ok = new Button("OK");
084:                ok.addClickListener(new ClickListener() {
085:                    public void onClick(Widget arg0) {
086:                        ok();
087:                    }
088:
089:                });
090:
091:                addAttribute("", ok);
092:
093:                setStyleName("ks-popups-Popup");
094:            }
095:
096:            /**
097:             * This will create a new asset wizard with the given preselected package.
098:             */
099:            public NewAssetWizard(EditItemEvent event, boolean showCategories,
100:                    String format2, String title,
101:                    String currentlySelectedPackage) {
102:                this (event, showCategories, format2, title);
103:                packageSelector.selectPackage(currentlySelectedPackage);
104:
105:            }
106:
107:            private Widget getCatChooser() {
108:                return new CategoryExplorerWidget(new CategorySelectHandler() {
109:                    public void selected(String selectedPath) {
110:                        initialCategory = selectedPath;
111:                    }
112:                });
113:            }
114:
115:            private ListBox getFormatChooser() {
116:
117:                ListBox box = new ListBox();
118:
119:                box.addItem("Business rule (using guided editor)",
120:                        AssetFormats.BUSINESS_RULE);
121:                box.addItem("DRL rule (technical rule - text editor)",
122:                        AssetFormats.DRL);
123:                box.addItem("Business rule using a DSL (text editor)",
124:                        AssetFormats.DSL_TEMPLATE_RULE);
125:                box.addItem("Decision table (spreadsheet)",
126:                        AssetFormats.DECISION_SPREADSHEET_XLS);
127:
128:                box.setSelectedIndex(0);
129:
130:                return box;
131:            }
132:
133:            /**
134:             * When OK is pressed, it will update the repository with the new rule.
135:             */
136:            void ok() {
137:
138:                if (this .showCats && this .initialCategory == null) {
139:                    WarningPopup.showMessage(
140:                            "You have to pick an initial category.", this 
141:                                    .getAbsoluteLeft(), this .getAbsoluteTop());
142:                    return;
143:                } else if (this .name.getText() == null
144:                        || "".equals(this .name.getText())) {
145:                    WarningPopup.showMessage("Rule must have a name", this 
146:                            .getAbsoluteLeft(), this .getAbsoluteTop());
147:                    return;
148:                }
149:
150:                GenericCallback cb = new GenericCallback() {
151:                    public void onSuccess(Object result) {
152:                        openEditor((String) result);
153:                        hide();
154:                    }
155:                };
156:
157:                LoadingPopup.showMessage("Please wait ...");
158:                RepositoryServiceFactory.getService().createNewRule(
159:                        name.getText(), description.getText(), initialCategory,
160:                        packageSelector.getSelectedPackage(), getFormat(), cb);
161:
162:            }
163:
164:            private String getFormat() {
165:                if (format != null)
166:                    return format;
167:                return formatChooser.getValue(formatChooser.getSelectedIndex());
168:            }
169:
170:            /**
171:             * After creating the item we open it in the editor.
172:             * @param uuid
173:             */
174:            protected void openEditor(String uuid) {
175:                afterCreate.open(uuid);
176:            }
177:
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.