public void set(final TreeNode input) {
if (input == null || input.getXObject() == null) {
return;
}
if (input.getXObject() instanceof XReport) {
final XReport report = (XReport) input.getXObject();
if (report.getReceiverType().equals(XConstants.TYPE_FOLDER_ELEMENT_SHEET)) {
ViewModeWorkbench wb = (ViewModeWorkbench)Registry.get(
ViewModeWorkbench.ID);
final XUser user = wb.getUser();
WPaloServiceProvider.getInstance().loadWorksheet(report, user,
new Callback<XWorksheet>(){
public void onSuccess(final XWorksheet ws) {
WPaloServiceProvider.getInstance().getVariables(
report, user, new Callback<XVariableDescriptor>(){
public void onSuccess(
XVariableDescriptor desc) {
XWorkbook wb = ws.getWorkbook();
XAccount acc = wb.getAccount();
XConnection con = acc.getConnection();
HashMap <XObject, String> mapping = desc.getVariableMapping();
String host = con.getHost();
String service = con.getService();
if (service.indexOf(":") != -1) {
service = service.split(":")[1];
}
String url = host + ":" + service + "/cc/auto_login.php?user=";
url += acc.getLogin() + "&pass=" + acc.getPassword();
url += "&app=" + wb.getAppName() + "&wb=" + wb.getName();
url += "&ws=" + ws.getName() + "&lang=en_US&w=1024&h=768";
// for (XElement xe: report.getElements()) {
// for (XObject match: mapping.keySet()) {
// if (match instanceof XHierarchy) {
// if (xe.getHierarchy().equals(match)) {
// url += "&var_" + mapping.get(match) + "=" + xe.getName();
// break;
// }
// } else if (match instanceof XSubset) {
// if (xe.getHierarchy().equals(((XSubset) match).getHierarchy())) {
// url += "&var_" + mapping.get(match) + "=" + xe.getName();
// break;
// }
// }
// }
// }
for (TabItem ti: tabFolder.getItems()) {
ReportTab rt = (ReportTab) ti;
if (rt.id.equals(url + report.getName())) {
rt.getTabPanel().scrollToTab(rt, true);
tabFolder.setSelection(rt);
return;
}
}
Frame frame = new Frame();
frame.setHeight("100%");
frame.setWidth("100%");
WidgetComponent component = new WidgetComponent(frame);
frame.setUrl(url);
ReportTab tab = new ReportTab(url + report.getName(), report.getName());
tab.setClosable(true);
tab.add(component);
tabFolder.add(tab);
tabFolder.setSelection(tab);