Source Code Cross Referenced for EditorLauncher.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 java.util.HashMap;
020:        import java.util.Map;
021:
022:        import org.drools.brms.client.common.AssetFormats;
023:        import org.drools.brms.client.common.GenericCallback;
024:        import org.drools.brms.client.common.LoadingPopup;
025:        import org.drools.brms.client.decisiontable.DecisionTableXLSWidget;
026:        import org.drools.brms.client.modeldriven.ui.RuleModeller;
027:        import org.drools.brms.client.packages.ModelAttachmentFileWidget;
028:        import org.drools.brms.client.packages.PackageExplorerWidget;
029:        import org.drools.brms.client.packages.SuggestionCompletionCache;
030:        import org.drools.brms.client.rpc.RepositoryServiceFactory;
031:        import org.drools.brms.client.rpc.RuleAsset;
032:
033:        import com.google.gwt.user.client.Command;
034:        import com.google.gwt.user.client.Window;
035:        import com.google.gwt.user.client.ui.TabPanel;
036:        import com.google.gwt.user.client.ui.Widget;
037:
038:        /**
039:         * This launches the appropriate editor for the asset type.
040:         * This uses the format attribute to determine the appropriate editor, and
041:         * ALSO to unpackage the content payload from the generic asset RPC object.
042:         *
043:         * NOTE: when adding new editors for asset types, this will also need to be enhanced to load
044:         * it up/unpackage it correctly for the editor.
045:         * The editors will make changes to the rpc objects in place, and when checking in the whole RPC
046:         * objects will be sent back to the server.
047:         *
048:         * @author Michael Neale
049:         */
050:        public class EditorLauncher {
051:
052:            public static final Map TYPE_IMAGES = getTypeImages();
053:
054:            /**
055:             * This will return the appropriate viewer for the asset.
056:             */
057:            public static Widget getEditorViewer(RuleAsset asset,
058:                    RuleViewer viewer) {
059:                //depending on the format, load the appropriate editor
060:                if (asset.metaData.format.equals(AssetFormats.BUSINESS_RULE)) {
061:                    return new RuleValidatorWrapper(new RuleModeller(asset),
062:                            asset);
063:                } else if (asset.metaData.format
064:                        .equals(AssetFormats.DSL_TEMPLATE_RULE)) {
065:                    return new RuleValidatorWrapper(new DSLRuleEditor(asset),
066:                            asset);
067:                } else if (asset.metaData.format.equals(AssetFormats.MODEL)) {
068:                    return new ModelAttachmentFileWidget(asset, viewer);
069:                } else if (asset.metaData.format
070:                        .equals(AssetFormats.DECISION_SPREADSHEET_XLS)) {
071:                    return new RuleValidatorWrapper(new DecisionTableXLSWidget(
072:                            asset, viewer), asset);
073:                } else if (asset.metaData.format
074:                        .equals(AssetFormats.RULE_FLOW_RF)) {
075:                    return new RuleFlowUploadWidget(asset, viewer);
076:                } else if (asset.metaData.format.equals(AssetFormats.DRL)) {
077:                    return new RuleValidatorWrapper(
078:                            new DefaultRuleContentWidget(asset), asset);
079:                } else if (asset.metaData.format
080:                        .equals(AssetFormats.ENUMERATION)) {
081:                    return new RuleValidatorWrapper(
082:                            new DefaultRuleContentWidget(asset), asset);
083:                } else {
084:                    return new DefaultRuleContentWidget(asset);
085:                }
086:
087:            }
088:
089:            private static Map getTypeImages() {
090:                Map result = new HashMap();
091:
092:                result.put(AssetFormats.DRL, "technical_rule_assets.gif");
093:                result.put(AssetFormats.DSL, "dsl.gif");
094:                result.put(AssetFormats.FUNCTION, "function_assets.gif");
095:                result.put(AssetFormats.MODEL, "model_asset.gif");
096:                result.put(AssetFormats.DECISION_SPREADSHEET_XLS,
097:                        "spreadsheet_small.gif");
098:                result.put(AssetFormats.BUSINESS_RULE, "rule_asset.gif");
099:                result.put(AssetFormats.DSL_TEMPLATE_RULE, "rule_asset.gif");
100:                result.put(AssetFormats.RULE_FLOW_RF, "ruleflow_small.gif");
101:
102:                return result;
103:            }
104:
105:            /**
106:             * Get the icon name (not the path), including the extension, for the appropriate
107:             * asset format.
108:             */
109:            public static String getAssetFormatIcon(String format) {
110:                String result = (String) TYPE_IMAGES.get(format);
111:                if (result == null) {
112:                    return "rule_asset.gif";
113:                } else {
114:                    return result;
115:                }
116:            }
117:
118:            /**
119:             * This will show the rule viewer. If it was previously opened, it will show that dialog instead
120:             * of opening it again.
121:             */
122:            public static void showLoadEditor(final Map openedViewers,
123:                    final TabPanel tab, final String uuid,
124:                    final boolean readonly) {
125:
126:                if (openedViewers.containsKey(uuid)) {
127:                    if (tab.getWidgetIndex((Widget) openedViewers.get(uuid)) == -1) {
128:                        String featurename = tab.getWidget(0) instanceof  PackageExplorerWidget ? "Rule Viewer"
129:                                : "Package Manager";
130:                        Window.alert("Asset already opened in " + featurename);
131:                    } else {
132:                        tab.selectTab(tab.getWidgetIndex((Widget) openedViewers
133:                                .get(uuid)));
134:                    }
135:                    LoadingPopup.close();
136:                    return;
137:                }
138:
139:                RepositoryServiceFactory.getService().loadRuleAsset(uuid,
140:                        new GenericCallback() {
141:
142:                            public void onSuccess(Object o) {
143:                                final RuleAsset asset = (RuleAsset) o;
144:
145:                                SuggestionCompletionCache cache = SuggestionCompletionCache
146:                                        .getInstance();
147:                                cache.doAction(asset.metaData.packageName,
148:                                        new Command() {
149:                                            public void execute() {
150:                                                openRuleViewer(openedViewers,
151:                                                        tab, uuid, readonly,
152:                                                        asset);
153:                                            }
154:
155:                                        });
156:                            }
157:
158:                        });
159:
160:            }
161:
162:            /**
163:             * This will actually show the viewer once everything is loaded and ready.
164:             * @param openedViewers
165:             * @param tab
166:             * @param uuid
167:             * @param readonly
168:             * @param asset
169:             */
170:            private static void openRuleViewer(final Map openedViewers,
171:                    final TabPanel tab, final String uuid,
172:                    final boolean readonly, RuleAsset asset) {
173:                final RuleViewer view = new RuleViewer(asset, readonly);
174:
175:                String displayName = asset.metaData.name;
176:                if (displayName.length() > 10) {
177:                    displayName = displayName.substring(0, 7) + "...";
178:                }
179:                String icon = getAssetFormatIcon(asset.metaData.format);
180:
181:                tab.add(view, "<img src='images/" + icon + "'>" + displayName,
182:                        true);
183:
184:                openedViewers.put(uuid, view);
185:
186:                view.setCloseCommand(new Command() {
187:                    public void execute() {
188:                        tab.remove(tab.getWidgetIndex(view));
189:                        tab.selectTab(0);
190:                        openedViewers.remove(uuid);
191:
192:                    }
193:                });
194:                tab.selectTab(tab.getWidgetIndex(view));
195:            }
196:
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.