Source Code Cross Referenced for ActionToolbar.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.common.DirtyableComposite;
020:        import org.drools.brms.client.common.FormStylePopup;
021:        import org.drools.brms.client.common.GenericCallback;
022:        import org.drools.brms.client.common.ImageButton;
023:        import org.drools.brms.client.common.RulePackageSelector;
024:        import org.drools.brms.client.common.StatusChangePopup;
025:        import org.drools.brms.client.rpc.MetaData;
026:        import org.drools.brms.client.rpc.RepositoryServiceFactory;
027:        import org.drools.brms.client.rpc.RuleAsset;
028:
029:        import com.google.gwt.user.client.Command;
030:        import com.google.gwt.user.client.Window;
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.Composite;
034:        import com.google.gwt.user.client.ui.FlexTable;
035:        import com.google.gwt.user.client.ui.HTML;
036:        import com.google.gwt.user.client.ui.HasHorizontalAlignment;
037:        import com.google.gwt.user.client.ui.HasVerticalAlignment;
038:        import com.google.gwt.user.client.ui.HorizontalPanel;
039:        import com.google.gwt.user.client.ui.Image;
040:        import com.google.gwt.user.client.ui.TextBox;
041:        import com.google.gwt.user.client.ui.Widget;
042:        import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
043:
044:        /**
045:         * This contains the widgets used to action a rule asset
046:         * (ie checkin, change state, close window)
047:         * @author Michael Neale
048:         */
049:        public class ActionToolbar extends Composite {
050:
051:            private FlexTable layout = new FlexTable();
052:            private Command closeCommand;
053:
054:            private MetaData metaData;
055:            private Command checkinAction;
056:            private Command archiveAction;
057:            private Command deleteAction;
058:            private String uuid;
059:            private HTML state;
060:
061:            public ActionToolbar(final RuleAsset asset,
062:
063:            final Command checkin, final Command archiv,
064:                    final Command minimiseMaximise, final Command delete,
065:                    boolean readOnly) {
066:
067:                this .metaData = asset.metaData;
068:                this .checkinAction = checkin;
069:                this .uuid = asset.uuid;
070:                this .archiveAction = archiv;
071:                this .deleteAction = delete;
072:                this .state = new HTML();
073:                String status = metaData.status;
074:
075:                FlexCellFormatter formatter = layout.getFlexCellFormatter();
076:                HorizontalPanel saveControls = new HorizontalPanel();
077:                setState(status);
078:
079:                saveControls.add(state);
080:
081:                if (!readOnly) {
082:                    controls(formatter, saveControls);
083:
084:                }
085:
086:                windowControls(minimiseMaximise, formatter);
087:
088:                initWidget(layout);
089:                setWidth("100%");
090:            }
091:
092:            /**
093:             * Sets the visible status display.
094:             */
095:            private void setState(String status) {
096:                state.setHTML("Status: <b>[" + status + "]</b>");
097:            }
098:
099:            private void controls(FlexCellFormatter formatter,
100:                    HorizontalPanel saveControls) {
101:                Image editState = new ImageButton("images/edit.gif");
102:                editState.setTitle("Change status.");
103:                editState.addClickListener(new ClickListener() {
104:                    public void onClick(Widget w) {
105:                        showStatusChanger(w);
106:                    }
107:
108:                });
109:                saveControls.add(editState);
110:
111:                layout.setWidget(0, 0, saveControls);
112:                formatter.setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT,
113:                        HasVerticalAlignment.ALIGN_MIDDLE);
114:
115:                //Image save = new Image("images/save_edit.gif");
116:                Button save = new Button("Save changes");
117:                save.setTitle("Check in changes.");
118:                save.addClickListener(new ClickListener() {
119:                    public void onClick(Widget w) {
120:                        doCheckinConfirm(w);
121:                    }
122:                });
123:
124:                saveControls.add(save);
125:
126:                Button copy = new Button("Copy");
127:                copy.addClickListener(new ClickListener() {
128:                    public void onClick(Widget w) {
129:                        doCopyDialog(w);
130:                    }
131:                });
132:
133:                saveControls.add(copy);
134:
135:                Button archive = new Button("Archive");
136:                archive.addClickListener(new ClickListener() {
137:                    public void onClick(Widget w) {
138:                        if (Window
139:                                .confirm("Are you sure you want to archive this item?")) {
140:                            metaData.checkinComment = "Archived Item on "
141:                                    + new java.util.Date().toString();
142:                            archiveAction.execute();
143:                        }
144:                    }
145:                });
146:                saveControls.add(archive);
147:
148:                if (this .metaData.versionNumber == 0) {
149:                    Button delete = new Button("Delete");
150:                    delete.addClickListener(new ClickListener() {
151:
152:                        public void onClick(Widget w) {
153:                            if (Window
154:                                    .confirm("Are you sure you want to permanently delete this (unversioned) item?")) {
155:                                deleteAction.execute();
156:                            }
157:                        }
158:                    });
159:                    saveControls.add(delete);
160:                }
161:
162:            }
163:
164:            private void windowControls(final Command minimiseMaximise,
165:                    FlexCellFormatter formatter) {
166:                HorizontalPanel windowControls = new HorizontalPanel();
167:
168:                Image maxMinImage = new ImageButton("images/max_min.gif");
169:                maxMinImage.addClickListener(new ClickListener() {
170:                    public void onClick(Widget w) {
171:                        minimiseMaximise.execute();
172:                    }
173:                });
174:
175:                windowControls.add(maxMinImage);
176:
177:                Image closeImg = new ImageButton("images/close.gif");
178:                closeImg.setTitle("Close.");
179:                closeImg.addClickListener(new ClickListener() {
180:                    public void onClick(Widget w) {
181:                        closeCommand.execute();
182:                    }
183:                });
184:
185:                windowControls.add(closeImg);
186:
187:                layout.setWidget(0, 1, windowControls);
188:                formatter.setAlignment(0, 1,
189:                        HasHorizontalAlignment.ALIGN_RIGHT,
190:                        HasVerticalAlignment.ALIGN_MIDDLE);
191:
192:            }
193:
194:            protected void doCopyDialog(Widget w) {
195:                final FormStylePopup form = new FormStylePopup(
196:                        "images/rule_asset.gif", "Copy this item");
197:                final TextBox newName = new TextBox();
198:                final RulePackageSelector newPackage = new RulePackageSelector();
199:                form.addAttribute("New name:", newName);
200:                form.addAttribute("New package:", newPackage);
201:
202:                Button ok = new Button("Create copy");
203:                ok.addClickListener(new ClickListener() {
204:                    public void onClick(Widget w) {
205:                        RepositoryServiceFactory.getService().copyAsset(uuid,
206:                                newPackage.getSelectedPackage(),
207:                                newName.getText(), new GenericCallback() {
208:                                    public void onSuccess(Object data) {
209:                                        completedCopying(newName.getText(),
210:                                                newPackage.getSelectedPackage());
211:                                        form.hide();
212:                                    }
213:
214:                                });
215:                    }
216:                });
217:                form.addAttribute("", ok);
218:
219:                form.setPopupPosition((DirtyableComposite.getWidth() - form
220:                        .getOffsetWidth()) / 2, 100);
221:                form.show();
222:
223:            }
224:
225:            private void completedCopying(String name, String pkg) {
226:                Window.alert("Created a new item called [" + name
227:                        + "] in package: [" + pkg + "] successfully.");
228:
229:            }
230:
231:            /**
232:             * Called when user wants to checkin.
233:             */
234:            protected void doCheckinConfirm(Widget w) {
235:
236:                final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft(),
237:                        w.getAbsoluteTop(), "Check in changes.");
238:                pop.setCommand(new Command() {
239:
240:                    public void execute() {
241:                        metaData.checkinComment = pop.getCheckinComment();
242:                        checkinAction.execute();
243:                    }
244:                });
245:                pop.show();
246:            }
247:
248:            /**
249:             * Show the stats change popup.
250:             */
251:            private void showStatusChanger(Widget w) {
252:                final StatusChangePopup pop = new StatusChangePopup(uuid, false);
253:                pop.setChangeStatusEvent(new Command() {
254:                    public void execute() {
255:                        setState(pop.getState());
256:                    }
257:                });
258:                pop.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
259:                pop.show();
260:            }
261:
262:            /**
263:             * This needs to be set to allow the current viewer to be closed.
264:             */
265:            public void setCloseCommand(Command c) {
266:                this.closeCommand = c;
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.