use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class DataHandler method traverseDomSetReadOnly.
private void traverseDomSetReadOnly(XulComponent component, boolean readonly) {
component.setDisabled(readonly);
List<XulComponent> children = component.getChildNodes();
if (children != null && children.size() > 0) {
for (XulComponent child : children) {
child.setDisabled(readonly);
traverseDomSetReadOnly(child, readonly);
}
}
}
use of org.pentaho.ui.xul.XulComponent 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.XulComponent in project pentaho-kettle by pentaho.
the class RepositoryLockController method lockContent.
public void lockContent() throws Exception {
List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
if (((ILockObject) contentToLock).isLocked()) {
// Unlock the item
((ILockObject) contentToLock).unlock();
browseController.getSelectedItemsBinding().fireSourceChanged();
} else {
// Lock the item
XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (!status.equals(Status.CANCEL)) {
try {
((ILockObject) contentToLock).lock(value);
browseController.getSelectedItemsBinding().fireSourceChanged();
} catch (Exception e) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
} else {
// $NON-NLS-1$
XulMenuitem lockMenuItem = (XulMenuitem) document.getElementById("lock-context-lock");
lockMenuItem.setSelected(false);
// $NON-NLS-1$
lockMenuItem = (XulMenuitem) document.getElementById("file-context-lock");
lockMenuItem.setSelected(false);
}
}
public void onError(XulComponent component, Throwable err) {
throw new RuntimeException(err);
}
});
lockNotePrompt.open();
}
}
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class StarModelerPerspective method setNameForTab.
public void setNameForTab(XulTab tab, String name) {
String tabName = name;
List<String> usedNames = new ArrayList<String>();
for (XulComponent c : tabs.getChildNodes()) {
if (c != tab) {
usedNames.add(((SwtTab) c).getLabel());
}
}
if (usedNames.contains(name)) {
int num = 2;
while (true) {
tabName = name + " (" + num + ")";
if (usedNames.contains(tabName) == false) {
break;
}
num++;
}
}
tab.setLabel(tabName);
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class BrowseController method createFolder.
public void createFolder() throws Exception {
try {
Collection<UIRepositoryDirectory> directories = folderTree.getSelectedItems();
if (directories == null || directories.size() == 0) {
return;
}
UIRepositoryDirectory selectedFolder = directories.iterator().next();
// First, ask for a name for the folder
XulPromptBox prompt = promptForName(null);
prompt.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (status == Status.ACCEPT) {
newName = value;
} else {
newName = null;
}
}
public void onError(XulComponent component, Throwable err) {
throw new RuntimeException(err);
}
});
prompt.open();
if (newName != null) {
if (selectedFolder == null) {
selectedFolder = repositoryDirectory;
}
// Do an explicit check here to see if the folder already exists in the ui
// This is to prevent a double message being sent in case the folder does
// not exist in the ui but does exist in the repo (PDI-5202)
boolean folderExistsInUI = selectedFolder.contains(newName);
if (folderExistsInUI) {
throw new Exception(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInUI", newName));
}
// PDI-5202
String newNameInRepo = selectedFolder.checkDirNameExistsInRepo(newName);
if (newNameInRepo != null) {
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Warning"));
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInRepository", newNameInRepo));
messageBox.open();
newName = newNameInRepo;
}
UIRepositoryDirectory newDir = selectedFolder.createFolder(newName);
dirMap.put(newDir.getObjectId(), newDir);
directoryBinding.fireSourceChanged();
selectedItemsBinding.fireSourceChanged();
this.folderTree.setSelectedItems(Collections.singletonList(selectedFolder));
}
newName = null;
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
confirm(BaseMessages.getString(PKG, "Dialog.Error"), e.getLocalizedMessage());
}
}
}
Aggregations