private Widget packageExplorer(final ExplorerViewCenterPanel tabPanel) {
TreeNode root = new TreeNode(constants.Packages());
root.setAttribute("icon", "images/silk/chart_organisation.gif"); //NON-NLS
final TreePanel panel = genericExplorerWidget(root);
loadPackages(root);
TreePanelListener treePanelListener = new TreePanelListenerAdapter() {
public void onClick(TreeNode node, EventObject e) {
if (node.getUserObject() instanceof PackageConfigData) {
PackageConfigData pc = (PackageConfigData) node.getUserObject();
currentPackage = 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();
currentPackage = pc.name;
String key = key(fmts, pc);
if (!centertabbedPanel.showIfOpen(key)) {
AssetItemGrid list = new AssetItemGrid(new EditItemEvent() {
public void open(String uuid) {
centertabbedPanel.openAsset(uuid);
}
},
AssetItemGrid.PACKAGEVIEW_LIST_TABLE_ID,
new AssetItemGridDataLoader() {
public void loadData(int skip, int numRows, GenericCallback cb) {
RepositoryServiceFactory.getService().listAssets(pc.uuid, fmts, skip, numRows, AssetItemGrid.PACKAGEVIEW_LIST_TABLE_ID, cb);
}
}
, GWT.getModuleBaseURL() + "feed/package?name=" + pc.name + "&viewUrl=" + Window.Location.getHref() + "&status=*");
tabPanel.addTab(uo[1] + " [" + pc.name + "]", true, list, key);
}
}
}
@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);
ScrollPanel scp = new ScrollPanel(panel);
scp.setHeight("500px"); //NON-NLS