use of org.pentaho.ui.xul.components.XulConfirmBox in project pentaho-kettle by pentaho.
the class AbstractPermissionsController method onContextChange.
public TYPE onContextChange() {
try {
if (viewAclsModel.isModelDirty()) {
if (!hasManageAclAccess()) {
// if the user does not have permission to modify the acls,
// ignore any changes, although this code shouldn't be executed
// because all buttons should be disabled.
viewAclsModel.clear();
// Clear the ACL from the backing repo object
clearSelectedObjAcl();
viewAclsModel.setModelDirty(false);
return TYPE.OK;
}
XulConfirmBox confirmBox = null;
try {
// $NON-NLS-1$
confirmBox = (XulConfirmBox) document.createElement("confirmbox");
} catch (Exception e) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
// $NON-NLS-1$
confirmBox.setTitle(BaseMessages.getString(PKG, "PermissionsController.ContextChangeWarning"));
// $NON-NLS-1$
confirmBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.ContextChangeWarningText"));
// $NON-NLS-1$
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Yes"));
// $NON-NLS-1$
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.No"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
returnType = TYPE.OK;
viewAclsModel.clear();
// Clear the ACL from the backing repo object
clearSelectedObjAcl();
viewAclsModel.setModelDirty(false);
} else {
returnType = TYPE.CANCEL;
}
}
public void onError(XulComponent sender, Throwable t) {
returnType = TYPE.NO_OP;
}
});
confirmBox.open();
} else {
returnType = TYPE.NO_OP;
}
return returnType;
} catch (Exception e) {
if (KettleRepositoryLostException.lookupStackStrace(e) != null) {
return TYPE.NO_OP;
} else {
throw new RuntimeException(e);
}
}
}
use of org.pentaho.ui.xul.components.XulConfirmBox in project pentaho-kettle by pentaho.
the class StarModelerPerspective method onTabClose.
public boolean onTabClose(final int pos) throws XulException {
if (models.get(pos).hasChanged()) {
XulConfirmBox confirm = (XulConfirmBox) document.createElement("confirmbox");
confirm.setTitle(BaseMessages.getString(this.getClass(), "StarModelerPerspective.unsavedChangesTitle"));
confirm.setMessage(BaseMessages.getString(this.getClass(), "StarModelerPerspective.unsavedChangesMessage"));
CloseConfirmXulDialogCallback callback = new CloseConfirmXulDialogCallback();
confirm.addDialogCallback(callback);
confirm.open();
if (callback.closeIt) {
models.remove(pos);
metas.remove(tabbox.getTabs().getChildNodes().get(pos));
return true;
} else {
return false;
}
} else {
models.remove(pos);
metas.remove(pos);
}
return true;
}
use of org.pentaho.ui.xul.components.XulConfirmBox in project pentaho-kettle by pentaho.
the class SecurityController method removeUser.
/**
* removeUser method is called when user has click on a remove button in a user deck. It first displays a confirmation
* message to the user and once the user selects ok, it remove the user
*
* @throws Exception
*/
public void removeUser() throws Exception {
XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveUserConfirmDialog.Message"));
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
if (service != null) {
if (security != null && security.getSelectedUser() != null) {
try {
service.delUser(security.getSelectedUser().getName());
security.removeUser(security.getSelectedUser().getName());
} catch (Throwable th) {
if (mainController == null || !mainController.handleLostRepository(th)) {
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", th.getLocalizedMessage()));
messageBox.open();
}
}
} else {
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.NoUserSelected"));
messageBox.open();
}
}
}
}
public void onError(XulComponent sender, Throwable t) {
if (mainController == null || !mainController.handleLostRepository(t)) {
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", t.getLocalizedMessage()));
messageBox.open();
}
}
});
confirmBox.open();
}
use of org.pentaho.ui.xul.components.XulConfirmBox in project pentaho-kettle by pentaho.
the class RepositoriesHelper method deleteRepository.
public void deleteRepository() {
try {
XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
final RepositoryMeta repositoryMeta = input.searchRepository(model.getSelectedRepository().getName());
if (repositoryMeta != null) {
confirmBox.setTitle(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Title"));
confirmBox.setMessage(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Message"));
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
int idx = input.indexOfRepository(repositoryMeta);
input.removeRepository(idx);
fillRepositories();
writeData();
}
}
public void onError(XulComponent sender, Throwable t) {
log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()));
new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()), t);
}
});
confirmBox.open();
}
} catch (Exception e) {
log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()));
new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()), e);
}
}
use of org.pentaho.ui.xul.components.XulConfirmBox in project pentaho-kettle by pentaho.
the class EESecurityController method removeRole.
/**
* removeRole method is called when user has click on a remove button in a role deck. It first displays a confirmation
* message to the user and once the user selects ok, it remove the role
*
* @throws Exception
*/
public void removeRole() throws Exception {
// $NON-NLS-1$
XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
// $NON-NLS-1$
confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
// $NON-NLS-1$
confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveRoleConfirmDialog.Message"));
// $NON-NLS-1$
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
if (service != null) {
if (eeSecurity != null && eeSecurity.getSelectedRole() != null) {
try {
((IRoleSupportSecurityManager) service).deleteRole(eeSecurity.getSelectedRole().getName());
eeSecurity.removeRole(eeSecurity.getSelectedRole().getName());
} catch (Throwable th) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", // $NON-NLS-1$
th.getLocalizedMessage()));
messageBox.open();
}
} else {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.NoRoleSelected"));
messageBox.open();
}
}
}
}
public void onError(XulComponent sender, Throwable t) {
if (mainController == null || !mainController.handleLostRepository(t)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(// $NON-NLS-1$
BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", t.getLocalizedMessage()));
messageBox.open();
}
}
});
confirmBox.open();
}
Aggregations