Search in sources :

Example 1 with SwtConfirmBox

use of org.pentaho.ui.xul.swt.tags.SwtConfirmBox in project pentaho-kettle by pentaho.

the class RevisionController method promptCommitComment.

private SwtConfirmBox promptCommitComment(org.pentaho.ui.xul.dom.Document document) throws XulException {
    SwtConfirmBox confirmbox = (SwtConfirmBox) document.createElement("confirmbox");
    // $NON-NLS-1$
    confirmbox.setTitle(BaseMessages.getString(PKG, "RepositoryExplorer.CommitTitle"));
    confirmbox.setButtons(new DialogConstant[] { DialogConstant.OK, DialogConstant.CANCEL });
    // $NON-NLS-1$//$NON-NLS-1$
    confirmbox.setMessage(BaseMessages.getString(PKG, "RepositoryExplorer.CommitLabel"));
    return confirmbox;
}
Also used : SwtConfirmBox(org.pentaho.ui.xul.swt.tags.SwtConfirmBox)

Example 2 with SwtConfirmBox

use of org.pentaho.ui.xul.swt.tags.SwtConfirmBox 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

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