01: package org.drools.brms.client.packages;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.util.Collections;
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import org.drools.brms.client.ruleeditor.EditorLauncher;
24: import org.drools.brms.client.rulelist.EditItemEvent;
25:
26: import com.google.gwt.user.client.ui.Composite;
27: import com.google.gwt.user.client.ui.TabPanel;
28:
29: /**
30: * This view is a tabbed browser for package management.
31: * The first tab always shows the list of packages in tree form,
32: * with a list/explorer like motif.
33: *
34: * This can also be specified to only show one package (ie when viewing a snapshot).
35: *
36: * Each editor that is opened is opened in a new tab.
37: *
38: * @author Michael Neale
39: */
40: public class PackageManagerView extends Composite {
41:
42: private final TabPanel tab;
43: private Map openedViewers = Collections.EMPTY_MAP;
44:
45: /**
46: * This will provide a explorer for all the packages in the system,
47: * not including snapshots.
48: */
49: public PackageManagerView() {
50: this (null, null);
51: }
52:
53: /**
54: * This is used when you only want to view one package.
55: * @param packageUUID The UUID of the package.
56: */
57: public PackageManagerView(String packageUUID,
58: final String snapshotName) {
59: tab = new TabPanel();
60: tab.setWidth("100%");
61: tab.setHeight("30%");
62:
63: EditItemEvent editEvent = new EditItemEvent() {
64: public void open(String key) {
65: EditorLauncher.showLoadEditor(openedViewers, tab, key,
66: (snapshotName != null));
67: }
68: };
69: PackageExplorerWidget explorer = null;
70:
71: if (packageUUID == null) {
72: explorer = new PackageExplorerWidget(editEvent);
73: } else {
74: explorer = new PackageExplorerWidget(editEvent,
75: packageUUID, snapshotName);
76: }
77:
78: tab.add(explorer, "<img src='images/explore.gif'/>Explore",
79: true);
80: tab.selectTab(0);
81:
82: initWidget(tab);
83: }
84:
85: public void setOpenedViewersContainer(Map openedViewers) {
86: this.openedViewers = openedViewers;
87: }
88:
89: }
|