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();
}
}