Search in sources :

Example 1 with UIRepositoryObjectRevision

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);
            }
        }
    }
}
Also used : UIRepositoryObjectRevision(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 2 with UIRepositoryObjectRevision

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));
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IRevisionObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) SwtConfirmBox(org.pentaho.ui.xul.swt.tags.SwtConfirmBox) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryObjectRevision(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision) ArrayList(java.util.ArrayList) List(java.util.List) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)2 UIRepositoryObjectRevision (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision)2 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)2 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)2 XulException (org.pentaho.ui.xul.XulException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)1 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)1 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 SwtConfirmBox (org.pentaho.ui.xul.swt.tags.SwtConfirmBox)1