use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent in project pentaho-kettle by pentaho.
the class Spoon method exploreRepository.
public void exploreRepository() {
if (rep != null) {
final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {
@Override
public boolean open(UIRepositoryContent element, String revision) throws Exception {
String objName = element.getName();
if (objName != null) {
RepositoryObjectType objectType = element.getRepositoryElementType();
RepositoryDirectory repDir = element.getRepositoryDirectory();
if (element.getObjectId() != null) {
// new way
loadObjectFromRepository(element.getObjectId(), objectType, revision);
} else {
// old way
loadObjectFromRepository(objName, objectType, repDir, revision);
}
}
// do not close explorer
return false;
}
@Override
public boolean error(String message) throws Exception {
closeRepository();
return true;
}
};
try {
final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
box.setIndeterminate(true);
box.setCanCancel(false);
box.setIcon("ui/images/kettle_logo_small.svg");
box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
box.setDialogParent(shell);
box.setRunnable(new WaitBoxRunnable(box) {
@Override
public void run() {
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
RepositoryExplorer explorer;
try {
try {
explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
} catch (final KettleRepositoryLostException krle) {
handleRepositoryLost(krle);
closeRepository();
return;
} finally {
box.stop();
}
if (explorer.isInitialized()) {
explorer.show();
} else {
return;
}
explorer.dispose();
} catch (final Throwable e) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
});
}
}
});
}
@Override
public void cancel() {
}
});
box.start();
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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.UIRepositoryContent in project pentaho-kettle by pentaho.
the class RepositoryLockController method viewLockNote.
public void viewLockNote() throws Exception {
List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
// $NON-NLS-1$
XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
// $NON-NLS-1$
msgBox.setTitle(BaseMessages.getString(PKG, "PurRepository.LockNote.Title"));
msgBox.setMessage(((ILockObject) contentToLock).getLockMessage());
msgBox.open();
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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.UIRepositoryContent 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();
}
}
}
Aggregations