Search in sources :

Example 11 with UIRepositoryContent

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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)

Example 12 with UIRepositoryContent

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent in project pentaho-kettle by pentaho.

the class BrowseController method renameContent.

public void renameContent() throws Exception {
    try {
        Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
        UIRepositoryObject contentToRename = content.iterator().next();
        renameRepositoryObject(contentToRename);
        if (contentToRename instanceof UIRepositoryDirectory) {
            directoryBinding.fireSourceChanged();
        }
        selectedItemsBinding.fireSourceChanged();
    } catch (Throwable th) {
        if (mainController == null || !mainController.handleLostRepository(th)) {
            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            messageBox.setMessage(BaseMessages.getString(PKG, th.getLocalizedMessage()));
            messageBox.open();
        }
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)

Aggregations

UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)12 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)8 KettleException (org.pentaho.di.core.exception.KettleException)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)6 XulException (org.pentaho.ui.xul.XulException)6 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)5 UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)2 UIRepositoryObjectRevision (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision)2 RepositoryExplorerCallback (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)1 UserInfo (org.pentaho.di.repository.UserInfo)1 KettleDatabaseRepository (org.pentaho.di.repository.kdr.KettleDatabaseRepository)1