loadGlobal(rootNode);
rootNode.appendChild(packageRootNode);
// rootNode.appendChild(globalRootNode);
final TreePanel panel = genericExplorerWidget(rootNode);
panel.setRootVisible(false);
TreePanelListener treePanelListener = new TreePanelListenerAdapter() {
public void onClick(TreeNode node, EventObject e) {
if (node.getUserObject() instanceof PackageConfigData
&& !"global".equals(((PackageConfigData) node.getUserObject()).name)) {
PackageConfigData pc = (PackageConfigData) node.getUserObject();
RulePackageSelector.currentlySelectedPackage = pc.name;
String uuid = pc.uuid;
centertabbedPanel.openPackageEditor(uuid, new Command() {
public void execute() {
// refresh the package tree.
refreshPackageTree();
}
});
} else if (node.getUserObject() instanceof Object[]) {
Object[] uo = (Object[]) node.getUserObject();
final String[] fmts = (String[]) uo[0];
final PackageConfigData pc = (PackageConfigData) node.getParentNode().getUserObject();
RulePackageSelector.currentlySelectedPackage = pc.name;
String key = key(fmts, pc);
if (!centertabbedPanel.showIfOpen(key)) {
final AssetItemGrid list = new AssetItemGrid(new EditItemEvent() {
public void open(String uuid) {
centertabbedPanel.openAsset(uuid);
}
public void open(MultiViewRow[] rows) {
centertabbedPanel.openAssets(rows);
}
}, AssetItemGrid.PACKAGEVIEW_LIST_TABLE_ID, new AssetItemGridDataLoader() {
public void loadData(int startRow, int numberOfRows, GenericCallback<TableDataResult> cb) {
RepositoryServiceFactory.getService().listAssets(pc.uuid, fmts, startRow, numberOfRows,
AssetItemGrid.PACKAGEVIEW_LIST_TABLE_ID, cb);
}
}, GWT.getModuleBaseURL() + "feed/package?name=" + pc.name + "&viewUrl="
+ CategoriesPanel.getSelfURL() + "&status=*");
tabPanel.addTab(uo[1] + " [" + pc.name + "]", true, list, key);
final ServerPushNotification sub = new ServerPushNotification() {
public void messageReceived(PushResponse response) {
if (response.messageType.equals("packageChange") && response.message.equals(pc.name)) {
list.refreshGrid();
}
}
};
PushClient.instance().subscribe(sub);
list.addUnloadListener(new Command() {
public void execute() {
PushClient.instance().unsubscribe(sub);
}
});
}
}
}
@Override
public void onCollapseNode(final TreeNode node) {
if (node.getText().equals(constants.Packages())) {
Node[] children = node.getChildNodes();
for (Node child : children) {
node.removeChild(child);
}
loadPackages(node);
}
}
};
// register listener
panel.addListener(treePanelListener);
final ScrollPanel scp = wrapScroll(panel);
return scp;