use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision in project pentaho-kettle by pentaho.
the class RevisionController method openRevision.
public void openRevision() {
Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
UIRepositoryContent contentToOpen = content.iterator().next();
Collection<UIRepositoryObjectRevision> revision = revisionTable.getSelectedItems();
// TODO: Is it a requirement to allow opening multiple revisions?
UIRepositoryObjectRevision revisionToOpen = revision.iterator().next();
if (mainController != null && mainController.getCallback() != null) {
try {
// TODO: fire request to close dialog
mainController.getCallback().open(contentToOpen, revisionToOpen.getName());
} catch (Exception e) {
if (mainController != null) {
mainController.handleLostRepository(e);
}
}
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision in project pentaho-kettle by pentaho.
the class RevisionController method restoreRevision.
public void restoreRevision() {
try {
final Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
final UIRepositoryContent contentToRestore = content.iterator().next();
Collection<UIRepositoryObjectRevision> versions = revisionTable.getSelectedItems();
final UIRepositoryObjectRevision versionToRestore = versions.iterator().next();
SwtConfirmBox confirmbox = promptCommitComment(document);
if (contentToRestore instanceof ILockObject && ((ILockObject) contentToRestore).isLocked()) {
// Cannot restore revision of locked content
// $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, "RevisionsController.RestoreLockedFileNotAllowed"));
messageBox.open();
return;
}
confirmbox.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (!status.equals(Status.CANCEL)) {
try {
if (contentToRestore instanceof IRevisionObject) {
((IRevisionObject) contentToRestore).restoreRevision(versionToRestore, value);
List<UIRepositoryObject> objects = new ArrayList<UIRepositoryObject>();
objects.add(contentToRestore);
browseController.setRepositoryObjects(objects);
} else {
throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
"RevisionsController.RevisionsNotSupported"));
}
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
}
public void onError(XulComponent component, Throwable err) {
if (mainController == null || !mainController.handleLostRepository(err)) {
throw new RuntimeException(err);
}
}
});
confirmbox.open();
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
throw new RuntimeException(new KettleException(e));
}
}
}
Aggregations