use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class BrowseController method renameRepositoryObject.
protected void renameRepositoryObject(final UIRepositoryObject object) throws XulException {
XulPromptBox prompt = promptForName(object);
prompt.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (status == Status.ACCEPT) {
try {
object.setName(value);
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
throw new RuntimeException(e);
}
}
}
}
public void onError(XulComponent component, Throwable err) {
throw new RuntimeException(err);
}
});
prompt.open();
}
use of org.pentaho.ui.xul.XulComponent 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.XulComponent in project pentaho-kettle by pentaho.
the class AbstractGraph method dispose.
public void dispose() {
super.dispose();
List<XulComponent> pops = xulDomContainer.getDocumentRoot().getElementsByTagName("menupopup");
for (XulComponent pop : pops) {
((MenuManager) pop.getManagedObject()).dispose();
}
}
use of org.pentaho.ui.xul.XulComponent 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.XulComponent in project pentaho-kettle by pentaho.
the class Spoon method removeMenuItem.
public void removeMenuItem(String itemid, boolean removeTrailingSeparators) {
XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(itemid);
if (item != null) {
XulComponent menu = item.getParent();
item.getParent().removeChild(item);
if (removeTrailingSeparators) {
List<XulComponent> children = menu.getChildNodes();
if (children.size() > 0) {
XulComponent lastMenuItem = children.get(children.size() - 1);
if (lastMenuItem instanceof XulMenuseparator) {
menu.removeChild(lastMenuItem);
// the menu separators seem to not be modeled as individual objects in XUL
try {
Menu swtm = (Menu) menu.getManagedObject();
swtm.getItems()[swtm.getItemCount() - 1].dispose();
} catch (Throwable t) {
LogChannel.GENERAL.logError("Error removing XUL menu item", t);
}
}
}
}
} else {
log.logError("Could not find menu item with id " + itemid + " to remove from Spoon menu");
}
}
Aggregations