use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject 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.di.ui.repository.repositoryexplorer.model.UIRepositoryObject in project pentaho-kettle by pentaho.
the class BrowseController method deleteContent.
public void deleteContent() throws Exception {
for (Object object : fileTable.getSelectedItems()) {
if (object instanceof UIRepositoryObject) {
final UIRepositoryObject repoObject = (UIRepositoryObject) object;
Callable<Void> deleteCallable = new Callable<Void>() {
@Override
public Void call() throws Exception {
deleteContent(repoObject);
return null;
}
};
// otherwise we will end this method call
if (repoObject instanceof UIRepositoryDirectory) {
confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", deleteCallable);
} else {
confirm("BrowseController.DeleteFileWarningTitle", "BrowseController.DeleteFileWarningMessage", deleteCallable);
}
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject in project pdi-dataservice-server-plugin by pentaho.
the class DeleteRepositoryObjectExtensionPointPlugin method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
RepositoryExtension repositoryExtension = (RepositoryExtension) object;
UIRepositoryObject repositoryObject = repositoryExtension.getRepositoryObject();
// if a directory get all transformations recursively
if (repositoryObject instanceof UIRepositoryDirectory) {
List<UIRepositoryObject> transformationList = new ArrayList<UIRepositoryObject>();
getAllTransformations((UIRepositoryDirectory) repositoryObject, transformationList);
for (UIRepositoryObject uiRepositoryObject : transformationList) {
Repository repository = uiRepositoryObject.getRepository();
metaStoreUtil.clearReferences(repository.loadTransformation(uiRepositoryObject.getObjectId(), null));
}
} else if (repositoryObject.getRepositoryElementType().equals(RepositoryObjectType.TRANSFORMATION)) {
Repository repository = repositoryObject.getRepository();
metaStoreUtil.clearReferences(repository.loadTransformation(repositoryObject.getObjectId(), null));
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject in project pentaho-kettle by pentaho.
the class RepositoryLockController method repositoryDirectoryHasLockedObject.
private boolean repositoryDirectoryHasLockedObject(DropEvent event, UIRepositoryDirectory dir) throws KettleException {
if (areAnyRepositoryObjectsLocked(event, dir.getRepositoryObjects())) {
return true;
}
for (UIRepositoryObject ro : dir.getChildren()) {
if (ro instanceof UIRepositoryDirectory) {
UIRepositoryDirectory directory = (UIRepositoryDirectory) ro;
repositoryDirectoryHasLockedObject(event, directory);
}
}
return false;
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject in project pentaho-kettle by pentaho.
the class RepositoryLockController method areAnyRepositoryObjectsLocked.
private boolean areAnyRepositoryObjectsLocked(DropEvent event, UIRepositoryObjects repositoryObjects) throws KettleException {
for (UIRepositoryObject ro : repositoryObjects) {
if (ro instanceof ILockObject) {
final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
if (((ILockObject) contentToLock).isLocked()) {
// Content is locked, move is not allowed.
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.FolderMoveNotAllowed"));
messageBox.open();
return true;
}
}
}
return false;
}
Aggregations