use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class PermissionsController method applyOnObjectOnly.
/**
* applyOnObjectOnly is called to save acl for a file object only
*
* @param roList
* @param hideDialog
*/
private void applyOnObjectOnly(List<UIRepositoryObject> roList, boolean hideDialog) {
try {
if (roList.get(0) instanceof UIRepositoryDirectory) {
UIRepositoryDirectory rd = (UIRepositoryDirectory) roList.get(0);
if (rd instanceof IAclObject) {
((IAclObject) rd).setAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
} else {
UIRepositoryContent rc = (UIRepositoryContent) roList.get(0);
if (rc instanceof ILockObject && ((ILockObject) rc).isLocked()) {
// $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, "PermissionsController.LockedObjectWarning"));
messageBox.open();
viewAclsModel.setModelDirty(false);
return;
} else if (rc instanceof IAclObject) {
((IAclObject) rc).setAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
}
/*
* if (hideDialog) { applyAclConfirmationDialog.hide(); }
*/
viewAclsModel.setModelDirty(false);
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.PermissionAppliedSuccessfully"));
messageBox.open();
} catch (AccessDeniedException ade) {
/*
* if (hideDialog) { applyAclConfirmationDialog.hide(); }
*/
if (mainController == null || !mainController.handleLostRepository(ade)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(ade.getLocalizedMessage());
messageBox.open();
}
} catch (KettleException kex) {
if (mainController == null || !mainController.handleLostRepository(kex)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(kex.getLocalizedMessage());
messageBox.open();
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class RepositoryLockController method onDragFromLocalTable.
// Object being dragged from the file listing table
public void onDragFromLocalTable(DropEvent event) {
try {
Collection<Object> selectedRepoObjects = fileTable.getSelectedItems();
if (selectedRepoObjects.size() > 0) {
for (Object ro : selectedRepoObjects) {
if (ro instanceof UIRepositoryObject && ro instanceof ILockObject) {
final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
if (((ILockObject) contentToLock).isLocked()) {
// Content is locked, not allowed to move
event.setAccepted(false);
// $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, "BrowseController.MoveNotAllowed"));
messageBox.open();
break;
} else {
// Content is not locked, check default permissions
browseController.onDragFromLocalTable(event);
}
} else if (ro instanceof UIRepositoryDirectory && repositoryDirectoryHasLockedObject(event, (UIRepositoryDirectory) ro)) {
// locked content nested in this directory. move not allowed.
event.setAccepted(false);
break;
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseController method renameFolder.
public void renameFolder() throws Exception {
try {
Collection<UIRepositoryDirectory> directory = folderTree.getSelectedItems();
final UIRepositoryDirectory toRename = directory.iterator().next();
renameRepositoryObject(toRename);
directoryBinding.fireSourceChanged();
selectedItemsBinding.fireSourceChanged();
} 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, th.getLocalizedMessage()));
messageBox.open();
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory 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());
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseController method deleteFolder.
public void deleteFolder() throws Exception {
UIRepositoryDirectory newSelectedItem = null;
for (Object object : folderTree.getSelectedItems()) {
if (object instanceof UIRepositoryDirectory) {
repoDir = (UIRepositoryDirectory) object;
newSelectedItem = repoDir.getParent();
confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", () -> {
deleteFolder(repoDir);
return null;
});
break;
} else {
deleteFolder(repoDir);
}
}
// since old selected item is the now deleted one, set the parent as the selected item
if (newSelectedItem != null) {
folderTree.setSelectedItems(Arrays.asList(newSelectedItem));
}
}
Aggregations