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


001:        package org.drools.brms.client.packages;
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.FormStyleLayout;
021:        import org.drools.brms.client.common.FormStylePopup;
022:        import org.drools.brms.client.common.GenericCallback;
023:        import org.drools.brms.client.common.ImageButton;
024:        import org.drools.brms.client.common.LoadingPopup;
025:        import org.drools.brms.client.rpc.PackageConfigData;
026:        import org.drools.brms.client.rpc.RepositoryServiceAsync;
027:        import org.drools.brms.client.rpc.RepositoryServiceFactory;
028:        import org.drools.brms.client.rpc.SnapshotInfo;
029:        import org.drools.brms.client.table.SortableTable;
030:
031:        import com.google.gwt.user.client.Command;
032:        import com.google.gwt.user.client.DeferredCommand;
033:        import com.google.gwt.user.client.Window;
034:        import com.google.gwt.user.client.ui.Button;
035:        import com.google.gwt.user.client.ui.ClickListener;
036:        import com.google.gwt.user.client.ui.Composite;
037:        import com.google.gwt.user.client.ui.FlexTable;
038:        import com.google.gwt.user.client.ui.HTML;
039:        import com.google.gwt.user.client.ui.HasHorizontalAlignment;
040:        import com.google.gwt.user.client.ui.HasVerticalAlignment;
041:        import com.google.gwt.user.client.ui.HorizontalPanel;
042:        import com.google.gwt.user.client.ui.Image;
043:        import com.google.gwt.user.client.ui.Label;
044:        import com.google.gwt.user.client.ui.TabPanel;
045:        import com.google.gwt.user.client.ui.TextBox;
046:        import com.google.gwt.user.client.ui.Tree;
047:        import com.google.gwt.user.client.ui.TreeItem;
048:        import com.google.gwt.user.client.ui.TreeListener;
049:        import com.google.gwt.user.client.ui.VerticalPanel;
050:        import com.google.gwt.user.client.ui.Widget;
051:        import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
052:
053:        /**
054:         * This contains a list of packages and their deployment snapshots.
055:         * 
056:         * @author Michael Neale
057:         */
058:        public class PackageSnapshotView extends Composite {
059:
060:            private RepositoryServiceAsync service;
061:            private TabPanel tab;
062:            private FlexTable layout;
063:
064:            public static final String LATEST_SNAPSHOT = "LATEST";
065:
066:            public PackageSnapshotView() {
067:
068:                layout = new FlexTable();
069:                tab = new TabPanel();
070:                tab.setWidth("100%");
071:                tab.setHeight("100%");
072:
073:                tab.add(layout,
074:                        "<img src='images/package_snapshot.gif'>Snapshots</a>",
075:                        true);
076:                layout.getCellFormatter().setWidth(0, 0, "28%");
077:
078:                service = RepositoryServiceFactory.getService();
079:
080:                refreshPackageList();
081:
082:                layout.setWidth("100%");
083:
084:                initWidget(tab);
085:
086:                tab.selectTab(0);
087:
088:            }
089:
090:            private void refreshPackageList() {
091:                LoadingPopup.showMessage("Loading package list...");
092:                service.listPackages(new GenericCallback() {
093:                    public void onSuccess(Object data) {
094:                        PackageConfigData[] list = (PackageConfigData[]) data;
095:                        addPackages(list);
096:                        LoadingPopup.close();
097:                    }
098:                });
099:            }
100:
101:            private void addPackages(final PackageConfigData[] list) {
102:
103:                Tree snapTree = new Tree();
104:
105:                VerticalPanel packages = new VerticalPanel();
106:                for (int i = 0; i < list.length; i++) {
107:                    final String pkgName = list[i].name;
108:                    TreeItem item = makeItem(pkgName,
109:                            "images/package_snapshot.gif", new Command() {
110:                                public void execute() {
111:                                    showPackage(pkgName);
112:                                }
113:                            });
114:
115:                    snapTree.addItem(item);
116:
117:                }
118:
119:                packages.add(snapTree);
120:
121:                HTML refresh = new HTML(
122:                        "Refresh list:&nbsp;<img src='images/refresh.gif'/>");
123:
124:                //Image refresh = new Image("images/refresh.gif");
125:                refresh.addClickListener(new ClickListener() {
126:                    public void onClick(Widget w) {
127:                        refreshPackageList();
128:                    }
129:                });
130:
131:                snapTree.addTreeListener(new TreeListener() {
132:                    public void onTreeItemSelected(TreeItem item) {
133:                        DeferredCommand.add((Command) item.getUserObject());
134:                    }
135:
136:                    public void onTreeItemStateChanged(TreeItem a) {
137:                    }
138:                });
139:                packages.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
140:                packages
141:                        .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
142:                packages.add(refresh);
143:                packages.setStyleName("snapshot-List");
144:                layout.setWidget(0, 0, packages);
145:                layout.getCellFormatter().setVerticalAlignment(0, 0,
146:                        HasVerticalAlignment.ALIGN_TOP);
147:            }
148:
149:            /**
150:             * This will load up the list of snapshots for a package.
151:             */
152:            private void showPackage(final String pkgName) {
153:                LoadingPopup.showMessage("Loading snapshots...");
154:                service.listSnapshots(pkgName, new GenericCallback() {
155:                    public void onSuccess(Object data) {
156:                        SnapshotInfo[] list = (SnapshotInfo[]) data;
157:
158:                        renderListOfSnapshots(pkgName, list);
159:                        LoadingPopup.close();
160:                    }
161:                });
162:            }
163:
164:            /**
165:             * This will render the snapshot list.
166:             */
167:            protected void renderListOfSnapshots(String pkgName,
168:                    SnapshotInfo[] list) {
169:
170:                FormStyleLayout right = new FormStyleLayout(
171:                        "images/snapshot.png",
172:                        "Labelled snapshots for package: " + pkgName);
173:
174:                FlexTable table = new FlexTable();
175:                table.setText(0, 1, "Name");
176:                table.setText(0, 2, "Comment");
177:                table.getRowFormatter().setStyleName(0,
178:                        SortableTable.styleListHeader);
179:
180:                for (int i = 0; i < list.length; i++) {
181:                    int row = i + 1;
182:                    Label name = new Label(list[i].name);
183:                    table.setWidget(row, 0, new Image(
184:                            "images/package_snapshot_item.gif"));
185:                    table.setWidget(row, 1, name);
186:                    table.setWidget(row, 2, new Label(list[i].comment));
187:                    table.setWidget(row, 3, getOpenSnapshotButton(pkgName, name
188:                            .getText(), list[i].uuid));
189:                    table.setWidget(row, 4, getCopyButton(pkgName, name
190:                            .getText()));
191:                    table.setWidget(row, 5, getDeleteButton(name.getText(),
192:                            pkgName));
193:
194:                    if (i % 2 == 0) {
195:                        table.getRowFormatter().setStyleName(i + 1,
196:                                SortableTable.styleEvenRow);
197:                    }
198:                }
199:
200:                right.setWidth("100%");
201:                //right.setHeight( "100%" );
202:                right.addRow(table);
203:                table.setWidth("100%");
204:                right.setStyleName(SortableTable.styleList);
205:
206:                layout.setWidget(0, 1, right);
207:                layout.getFlexCellFormatter().setVerticalAlignment(0, 1,
208:                        HasVerticalAlignment.ALIGN_TOP);
209:
210:            }
211:
212:            private Button getCopyButton(final String packageName,
213:                    final String snapshotName) {
214:                final FormStylePopup copy = new FormStylePopup(
215:                        "images/snapshot.png", "Copy snapshot " + snapshotName);
216:                final TextBox box = new TextBox();
217:                copy.addAttribute("New label:", box);
218:                Button ok = new Button("OK");
219:                copy.addAttribute("", ok);
220:
221:                ok.addClickListener(new ClickListener() {
222:                    public void onClick(Widget w) {
223:                        service.copyOrRemoveSnapshot(packageName, snapshotName,
224:                                false, box.getText(), new GenericCallback() {
225:                                    public void onSuccess(Object data) {
226:                                        showPackage(packageName);
227:                                        copy.hide();
228:                                    }
229:                                });
230:                    }
231:                });
232:
233:                Button btn = new Button("Copy");
234:                btn.addClickListener(new ClickListener() {
235:                    public void onClick(Widget w) {
236:                        copy.setPopupPosition(
237:                                (DirtyableComposite.getWidth() - copy
238:                                        .getOffsetWidth()) / 2, 100);
239:                        copy.show();
240:                    }
241:                });
242:
243:                return btn;
244:            }
245:
246:            private Button getOpenSnapshotButton(final String pkgName,
247:                    final String snapshotName, final String uuid) {
248:
249:                Button but = new Button("Open");
250:                but.addClickListener(new ClickListener() {
251:                    public void onClick(Widget w) {
252:
253:                        openPackageSnapshot(pkgName, snapshotName, uuid);
254:                    }
255:                });
256:
257:                return but;
258:            }
259:
260:            private Button getDeleteButton(final String snapshotName,
261:                    final String pkgName) {
262:                Button btn = new Button("Delete");
263:                btn.addClickListener(new ClickListener() {
264:
265:                    public void onClick(Widget w) {
266:                        boolean confirm = Window
267:                                .confirm("Are you sure you want to delete the snapshot labelled ["
268:                                        + snapshotName
269:                                        + "] from the package ["
270:                                        + pkgName + "] ?");
271:
272:                        if (!confirm) {
273:                            return;
274:                        } else {
275:                            service.copyOrRemoveSnapshot(pkgName, snapshotName,
276:                                    true, null, new GenericCallback() {
277:                                        public void onSuccess(Object data) {
278:                                            showPackage(pkgName);
279:                                        }
280:                                    });
281:                        }
282:                    }
283:
284:                });
285:                return btn;
286:            }
287:
288:            private TreeItem makeItem(String name, String icon, Object command) {
289:                TreeItem item = new TreeItem();
290:                item.setHTML("<img src=\"" + icon + "\">" + name + "</a>");
291:                item.setUserObject(command);
292:                return item;
293:            }
294:
295:            /**
296:             * This opens the package viewer, showing the contents of that snapshot.
297:             */
298:            private void openPackageSnapshot(final String pkgName,
299:                    final String snapshotName, final String uuid) {
300:                FlexTable viewLayout = new FlexTable();
301:                String msg = "<b>Viewing snapshot labelled: </b>"
302:                        + snapshotName + " for package " + pkgName
303:                        + ". This should not be edited.";
304:                HorizontalPanel horiz = new HorizontalPanel();
305:                horiz.add(new HTML(msg));
306:                Image close = new ImageButton("images/close.gif");
307:                close.setTitle("Close this view");
308:                close.addClickListener(new ClickListener() {
309:                    public void onClick(Widget w) {
310:                        tab.remove(1);
311:                        tab.selectTab(0);
312:                    }
313:                });
314:                horiz.add(close);
315:                viewLayout.setWidget(0, 0, horiz);
316:                FlexCellFormatter formatter = viewLayout.getFlexCellFormatter();
317:                formatter.setStyleName(0, 0, "editable-Surface");
318:
319:                viewLayout.setWidget(1, 0, new PackageManagerView(uuid,
320:                        snapshotName));
321:
322:                viewLayout.setWidth("100%");
323:                viewLayout.setHeight("100%");
324:
325:                if (tab.getWidgetCount() > 1) {
326:                    tab.remove(1);
327:                }
328:                tab.add(viewLayout,
329:                        "<img src='images/package_snapshot_item.gif'> "
330:                                + pkgName + " [" + snapshotName + "]", true);
331:                tab.selectTab(1);
332:            }
333:
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.