public void loaderLoad(LoadEvent le) {
((Workbench)Registry.get(Workbench.ID)).hideWaitCursor();
}
});
final ToolBar toolbar = new ToolBar();
TextToolItem addFolder = new TextToolItem("", "icon-create-folder");
addFolder.setToolTip(constants.createNewViewFolder());
addFolder.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
createNewFolder();
}
});
toolbar.add(addFolder);
toolbar.add(new SeparatorToolItem());
TextToolItem createViews = new TextToolItem("", "icon-create-view");
createViews.setToolTip(constants.createNewViews());
createViews
.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
TreeNode node = getSelectedNode();
createViews(node);
}
});
toolbar.add(createViews);
TextToolItem importViews = new TextToolItem("", "icon-import-view");
importViews.setToolTip(constants.importViews());
importViews
.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
TreeNode node = getSelectedNode();
importViews(node);
}
});
toolbar.add(importViews);
toolbar.add(new SeparatorToolItem());
renameItem = new TextToolItem("", "icon-rename");
renameItem.setToolTip(constants.renameSelectedItem());
renameItem.setEnabled(true);
renameItem.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
handleAction(RENAME);
}
});
toolbar.add(renameItem);
deleteItem = new TextToolItem("", "icon-delete-off");
deleteItem.setToolTip(constants.deleteSelectedItem());
deleteItem.setEnabled(false);
deleteItem
.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
handleAction(DELETE);
}
});
toolbar.add(deleteItem);
navigator.setTopComponent(toolbar);
navigator.add(viewsTree);
Workbench wb = (Workbench) Registry.get(Workbench.ID);
wb.addToViewPanel(navigator);
ComponentHelper.doAttach(viewsTree);
navigator.addListener(Events.OnKeyUp, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
viewsTree.fireEvent(Events.OnKeyUp, be);
}
});
toolbar.add(new SeparatorToolItem());
// SplitToolItem about = new SplitToolItem("");
// about.setIconStyle("icon-about");
TextToolItem about = new TextToolItem("", "icon-about");
about.setToolTip(constants.extras());
// about.addSelectionListener(new SelectionListener<ComponentEvent>() {
// public void componentSelected(ComponentEvent ce) {
// WPaloPropertyServiceProvider.getInstance().getBuildNumber(new AsyncCallback<String>() {
// public void onFailure(Throwable arg0) {
// displayAboutDialog("<Unknown>");
// }
//
// public void onSuccess(String result) {
// displayAboutDialog(result);
// }
// });
// }
// });
Menu menu = new Menu();
editViewProperties = new MenuItem(constants.editViewProperties());
editViewProperties.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
XUser user = ((Workbench)Registry.get(Workbench.ID)).getUser();
final String sessionId = user.getSessionId();
XView targetView = null;
XObject xObj = null;
TreeItem item = null;
TreeNode node = null;
if (treeBinder != null && treeBinder.getTree() != null) {
TreeItem selection = treeBinder.getTree().getSelectedItem();
if (selection != null) {
item = selection;
node = (TreeNode) selection.getModel();
xObj = browserModel.getWrappedXObject(node);
if (xObj instanceof XFolderElement) {
XObject source = ((XFolderElement) xObj).getSourceObject();
if (source != null && source instanceof XView) {
targetView = (XView) source;
}
}
}
}
if (targetView != null) {
final XView viewToModify = targetView;
final XObject xObject = xObj;
final TreeItem selectedItem = item;
final TreeNode nodeOfView = node;
// int permission = user.getId().equals(targetView.getOwnerId()) ? 2 : 16;
int permission = user.isAdmin() ? 0 : (user.getId().equals(targetView.getOwnerId()) ? 16 : 22);
WPaloCubeViewServiceProvider.getInstance().checkPermission(sessionId, permission, new Callback <Boolean>(){
public void onSuccess(Boolean result) {
if (result) {
final EditViewPropertiesDialog dlg =
new EditViewPropertiesDialog(viewToModify);
dlg.addButtonListener(EditViewPropertiesDialog.BUTTON_OK,
new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
boolean pub = dlg.isPublic();
boolean edi = dlg.isEditable();
String ownerId = dlg.getOwner();
String accId = dlg.getAccountId();
String dbId = dlg.getDatabaseId();
String cubeId = dlg.getCubeId();
WPaloCubeViewServiceProvider.getInstance().setVisibility(
sessionId, (XFolderElement) xObject, pub, edi, ownerId, accId, dbId, cubeId, new Callback <XView>(){
public void onSuccess(XView view) {
XFolderElement xObj = (XFolderElement) browserModel.getWrappedXObject(nodeOfView);
xObj.setSourceObject(view);
selectedItem.setIconStyle(getIconStyle(view));
treeBinder.getStore().update(nodeOfView);
}});
}
});
dlg.show();
} else {
MessageBox.alert(constants.notEnoughRights(), constants.notEnoughRightsToModifyVisibility(), null);
}
}
});
}
}
});
menu.add(editViewProperties);
createDirectLink = new MenuItem(constants.createDirectLink());
createDirectLink.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
if (treeBinder != null && treeBinder.getTree() != null) {
TreeItem selection = treeBinder.getTree().getSelectedItem();
if (selection != null) {
TreeNode node = (TreeNode) selection.getModel();
final XObject xObj = browserModel.getWrappedXObject(node);
if (xObj instanceof XFolderElement) {
final XObject source = ((XFolderElement) xObj).getSourceObject();
if (source != null && source instanceof XView) {
final CreateDirectLinkDialog cdl = new CreateDirectLinkDialog((XView) source);
cdl.show();
}
}
}
}
}
});
menu.add(createDirectLink);
MenuItem abi = new MenuItem(constants.about());
abi.addSelectionListener(new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
WPaloPropertyServiceProvider.getInstance().getBuildNumber(new AsyncCallback<String>() {
public void onFailure(Throwable arg0) {
displayAboutDialog("<" + constants.unknown() + ">", null);
}
public void onSuccess(final String result) {
WPaloPropertyServiceProvider.getInstance().getCurrentBuildNumber(new AsyncCallback<String []>(){
public void onFailure(Throwable arg0) {
displayAboutDialog(result, null);
}
public void onSuccess(String [] buildInformation) {
displayAboutDialog(result, buildInformation);
}
});
}
});
}
});
menu.add(abi);
// MenuItem tti = new MenuItem("Test Tree");
// tti.addSelectionListener(new SelectionListener<ComponentEvent>() {
// public void componentSelected(ComponentEvent ce) {
// final TestFastTreeDialog tftd = new TestFastTreeDialog();
// tftd.show();
// }
// });
// menu.add(tti);
about.setMenu(menu);
toolbar.add(about);
return toolbar;
}