final String sessionId = ((Workbench)Registry.get(Workbench.ID)).getUser().getSessionId();
WPaloCubeViewServiceProvider.getInstance().runAsync(sessionId, 0, new Callback<Void>() {
public void onSuccess(Void arg0) {
final String oldPaths = widget.getHierarchy().getProperty("filterPaths");
final String oldAliasFormat = widget.getHierarchy().getProperty("aliasFormat");
final XAxisHierarchy hierarchy = widget.getHierarchy();
// get old settings:
final XAlias oldAlias = hierarchy.getActiveAlias();
final XSubset oldSubset = hierarchy.getActiveSubset();
final XElement oldSelectedElement = hierarchy.getSelectedElement();
hierarchy.setOldVisibleElements(hierarchy.getVisibleElements());
if (hierarchy.getVisibleElements() == null || hierarchy.getVisibleElements().length == 0) {
oldVisibles.remove(hierarchy.getId());
} else {
oldVisibles.put(hierarchy.getId(), hierarchy.getVisibleElements());
}
XElementNode [] newSelElems = dlg.getVisibleElements();
if (newSelElems == null || newSelElems.length == 0) {
visibles.remove(hierarchy.getId());
} else {
visibles.put(hierarchy.getId(), newSelElems);
}
// //apply changes:
hierarchy.setActiveAlias(dlg.getSelectedAlias());
hierarchy.setActiveSubset(dlg.getSelectedSubset());
hierarchy.setVisibleElements(newSelElems);
hierarchy.setSelectedElement(dlg.getSelectedElement());
final boolean containsSelected = contains(hierarchy.getVisibleElements(), oldSelectedElement);
if (isInRowOrColumn(hierarchy)) {
willUpdateHierarchy(widget, oldSubset, oldAlias, initialVisibleElements, oldPaths, oldAliasFormat, oldSelectedElement);
} else {
if (!containsSelected || (dlg.getOldSelectedElement() == null && hierarchy.getSelectedElement() != null)) {
willUpdateHierarchy(widget, oldSubset, oldAlias, initialVisibleElements, oldPaths, oldAliasFormat, dlg.getOldSelectedElement());
} else {
if (dlg.getSelectedSubset() != null) {
checkSubset(hierarchy, oldAlias, oldSubset, oldSelectedElement,
dlg.getSelectedSubset(), oldPaths, oldAliasFormat, initialVisibleElements, widget);
} else {
showWaitDialog(constants.applyingSelection());
adjustView();
WPaloCubeViewServiceProvider.getInstance().proceedUpdateViewWithoutTable(sessionId,
view,
new Callback<XViewModel>(messages.updatingViewFailed(ViewBrowserModel.modify(view.getName()))) {
public void onSuccess(XViewModel view) {
markDirty(true);
fastSetInput(view);
if (widget instanceof HierarchySelectionWidget) {
((HierarchySelectionWidget) widget).setSelectedElement(hierarchy.getSelectedElement());
}
widget.update();
hideWaitDialog();
}
});