Search in sources :

Example 6 with UIRepositoryContent

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

the class BrowseController method openContent.

public void openContent(Object[] items) {
    if ((items != null) && (items.length > 0)) {
        for (Object o : items) {
            if (o instanceof UIRepositoryDirectory) {
                ((UIRepositoryDirectory) o).toggleExpanded();
                List<Object> selectedFolder = new ArrayList<Object>();
                selectedFolder.add(o);
                folderTree.setSelectedItems(selectedFolder);
            } else if ((mainController != null && mainController.getCallback() != null) && (o instanceof UIRepositoryContent)) {
                try {
                    mainController.getCallback().open((UIRepositoryContent) o, null);
                } catch (Exception e) {
                    mainController.handleLostRepository(e);
                }
            // TODO: fire request to close dialog
            }
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) ArrayList(java.util.ArrayList) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 7 with UIRepositoryContent

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

the class ExplorerHarness method main.

/**
 * @param args
 */
@SuppressWarnings("nls")
public static void main(String[] args) {
    KettleDatabaseRepositoryMeta repositoryMeta;
    KettleDatabaseRepository repository;
    @SuppressWarnings("unused") UserInfo userInfo;
    repositoryMeta = new KettleDatabaseRepositoryMeta();
    repositoryMeta.setName("Kettle Database Repository");
    repositoryMeta.setDescription("Kettle database test repository");
    DatabaseMeta connection = new DatabaseMeta();
    connection.setDatabaseType("Hypersonic");
    connection.setHostname("localhost");
    connection.setDBName("kettle_repository_4x");
    connection.setDBPort("9002");
    connection.setUsername("sa");
    repositoryMeta.setConnection(connection);
    userInfo = new UserInfo("admin", "admin", "Administrator", "The system administrator", true);
    repository = new KettleDatabaseRepository();
    repository.init(repositoryMeta);
    @SuppressWarnings("unused") RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

        public boolean open(UIRepositoryContent element, String revision) throws Exception {
            System.out.println("Name: ".concat(element.getName()));
            System.out.println("Type: ".concat(element.getRepositoryElementType().name()));
            System.out.println("Directory: ".concat(element.getRepositoryDirectory().toString()));
            System.out.println("Revision: ".concat(revision == null ? "null" : revision));
            // do not close explorer
            return false;
        }

        @Override
        public boolean error(String message) throws Exception {
            System.out.println("Error message: ".concat(message));
            return true;
        }
    };
/*
     * try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new
     * RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) {
     * e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) {
     * e.printStackTrace(); }
     */
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) UserInfo(org.pentaho.di.repository.UserInfo) KettleDatabaseRepository(org.pentaho.di.repository.kdr.KettleDatabaseRepository) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 8 with UIRepositoryContent

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

the class RepositoryLockController method areAnyRepositoryObjectsLocked.

private boolean areAnyRepositoryObjectsLocked(DropEvent event, UIRepositoryObjects repositoryObjects) throws KettleException {
    for (UIRepositoryObject ro : repositoryObjects) {
        if (ro instanceof ILockObject) {
            final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
            if (((ILockObject) contentToLock).isLocked()) {
                // Content is locked, move is not allowed.
                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.FolderMoveNotAllowed"));
                messageBox.open();
                return true;
            }
        }
    }
    return false;
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)

Example 9 with UIRepositoryContent

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

the class RevisionController method createBindings.

private void createBindings() {
    // $NON-NLS-1$
    filePropertiesTabbox = (XulTabbox) document.getElementById("file-properties-tabs");
    // $NON-NLS-1$
    historyTab = (XulTab) document.getElementById("history");
    // $NON-NLS-1$
    revisionTable = (XulTree) document.getElementById("revision-table");
    // $NON-NLS-1$
    folderTree = (XulTree) document.getElementById("folder-tree");
    // $NON-NLS-1$
    fileTable = (XulTree) document.getElementById("file-table");
    // Hide the history tab if versioning is off
    historyTab.setVisible(false);
    bf.setBindingType(Binding.Type.ONE_WAY);
    BindingConvertor<int[], Boolean> forButtons = new BindingConvertor<int[], Boolean>() {

        @Override
        public Boolean sourceToTarget(int[] value) {
            return value != null && !(value.length <= 0);
        }

        @Override
        public int[] targetToSource(Boolean value) {
            return null;
        }
    };
    Binding openButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    bf.createBinding(revisionTable, "selectedRows", OPEN_REVISION_BUTTON, "!disabled", forButtons);
    Binding restoreButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    bf.createBinding(revisionTable, "selectedRows", RESTORE_REVISION_BUTTON, "!disabled", forButtons);
    bf.setBindingType(Binding.Type.ONE_WAY);
    // $NON-NLS-1$  //$NON-NLS-2$
    bf.createBinding(folderTree, "selectedItems", this, "historyTabVisibility");
    // $NON-NLS-1$ //$NON-NLS-2$
    revisionBinding = bf.createBinding(this, "revisionObjects", revisionTable, "elements");
    revisionBinding = // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(// $NON-NLS-1$ //$NON-NLS-2$
    browseController, // $NON-NLS-1$ //$NON-NLS-2$
    "repositoryItems", // $NON-NLS-1$ //$NON-NLS-2$
    this, // $NON-NLS-1$ //$NON-NLS-2$
    "revisionObjects", new BindingConvertor<List<UIRepositoryObject>, UIRepositoryObjectRevisions>() {

        private void disableButtons() {
            document.getElementById(OPEN_REVISION_BUTTON).setDisabled(true);
            document.getElementById(RESTORE_REVISION_BUTTON).setDisabled(true);
        }

        @Override
        public UIRepositoryObjectRevisions sourceToTarget(List<UIRepositoryObject> ro) {
            if (ro == null || ro.isEmpty() || !masterVersioningEnabled) {
                return new UIRepositoryObjectRevisions();
            }
            if (ro.get(0) instanceof UIRepositoryDirectory) {
                historyTab.setVisible(false);
                filePropertiesTabbox.setSelectedIndex(0);
                disableButtons();
                return null;
            }
            UIRepositoryObjectRevisions revisions = null;
            try {
                UIRepositoryContent rc = (UIRepositoryContent) ro.get(0);
                if (rc instanceof IRevisionObject) {
                    Boolean versioningEnabled = ((IRevisionObject) rc).getVersioningEnabled();
                    // Show/hide the Verison History tab
                    historyTab.setVisible(versioningEnabled);
                    if (!versioningEnabled) {
                        return new UIRepositoryObjectRevisions();
                    }
                    Boolean versionCommentEnabled = ((IRevisionObject) rc).getVersionCommentEnabled();
                    // Show/Hide the version comment column
                    setRevisionTableColumns(versionCommentEnabled);
                    revisions = ((IRevisionObject) rc).getRevisions();
                } else {
                    throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
                    "RevisionsController.RevisionsNotSupported"));
                }
            } catch (KettleException e) {
                if (mainController == null || !mainController.handleLostRepository(e)) {
                    // convert to runtime exception so it bubbles up through the UI
                    throw new RuntimeException(e);
                }
            }
            return revisions;
        }

        @Override
        public List<UIRepositoryObject> targetToSource(UIRepositoryObjectRevisions elements) {
            return null;
        }
    });
    try {
        openButtonBinding.fireSourceChanged();
        restoreButtonBinding.fireSourceChanged();
        revisionBinding.fireSourceChanged();
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            // convert to runtime exception so it bubbles up through the UI
            throw new RuntimeException(e);
        }
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) 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) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) 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) UIRepositoryObjectRevisions(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevisions) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with UIRepositoryContent

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

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