Search in sources :

Example 6 with UIRepositoryDirectory

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

the class BrowseController method init.

// end PDI-3326 hack
@SuppressWarnings("deprecation")
public void init(Repository repository) throws ControllerInitializationException {
    try {
        this.repository = repository;
        mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController");
        RepositoryDirectoryInterface root;
        try {
            if (repository instanceof RepositoryExtended) {
                root = ((RepositoryExtended) repository).loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, BooleanUtils.isTrue(repository.getUserInfo().isAdmin()), true, true);
            } else {
                root = repository.loadRepositoryDirectoryTree();
            }
            this.repositoryDirectory = UIObjectRegistry.getInstance().constructUIRepositoryDirectory(root, null, repository);
        } catch (UIObjectCreationException uoe) {
            this.repositoryDirectory = new UIRepositoryDirectory(repository.loadRepositoryDirectoryTree(), null, repository);
        }
        dirMap = new HashMap<ObjectId, UIRepositoryDirectory>();
        populateDirMap(repositoryDirectory);
        bf = new SwtBindingFactory();
        bf.setDocument(this.getXulDomContainer().getDocumentRoot());
        messageBox = (XulMessageBox) document.createElement("messagebox");
        createBindings();
    } catch (Exception e) {
        throw new ControllerInitializationException(e);
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) SwtBindingFactory(org.pentaho.ui.xul.swt.SwtBindingFactory) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) ObjectId(org.pentaho.di.repository.ObjectId) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) 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) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)

Example 7 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory 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 8 with UIRepositoryDirectory

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

the class BrowseController method deleteContent.

public void deleteContent() throws Exception {
    for (Object object : fileTable.getSelectedItems()) {
        if (object instanceof UIRepositoryObject) {
            final UIRepositoryObject repoObject = (UIRepositoryObject) object;
            Callable<Void> deleteCallable = new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    deleteContent(repoObject);
                    return null;
                }
            };
            // otherwise we will end this method call
            if (repoObject instanceof UIRepositoryDirectory) {
                confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", deleteCallable);
            } else {
                confirm("BrowseController.DeleteFileWarningTitle", "BrowseController.DeleteFileWarningMessage", deleteCallable);
            }
        }
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) Callable(java.util.concurrent.Callable)

Example 9 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pdi-dataservice-server-plugin by pentaho.

the class DeleteRepositoryObjectExtensionPointPlugin method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    RepositoryExtension repositoryExtension = (RepositoryExtension) object;
    UIRepositoryObject repositoryObject = repositoryExtension.getRepositoryObject();
    // if a directory get all transformations recursively
    if (repositoryObject instanceof UIRepositoryDirectory) {
        List<UIRepositoryObject> transformationList = new ArrayList<UIRepositoryObject>();
        getAllTransformations((UIRepositoryDirectory) repositoryObject, transformationList);
        for (UIRepositoryObject uiRepositoryObject : transformationList) {
            Repository repository = uiRepositoryObject.getRepository();
            metaStoreUtil.clearReferences(repository.loadTransformation(uiRepositoryObject.getObjectId(), null));
        }
    } else if (repositoryObject.getRepositoryElementType().equals(RepositoryObjectType.TRANSFORMATION)) {
        Repository repository = repositoryObject.getRepository();
        metaStoreUtil.clearReferences(repository.loadTransformation(repositoryObject.getObjectId(), null));
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) Repository(org.pentaho.di.repository.Repository) RepositoryExtension(org.pentaho.di.ui.repository.RepositoryExtension) ArrayList(java.util.ArrayList)

Example 10 with UIRepositoryDirectory

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

the class BrowseControllerTest method setUp.

@Before
public void setUp() throws Exception {
    DocumentFactory.registerElementClass(ElementDom4J.class);
    controller = new BrowseController();
    controller.setRepositoryDirectory(mock(UIRepositoryDirectory.class));
    directoryMap = new HashMap<>(8);
    controller.setDirMap(directoryMap);
    document = mock(Document.class);
    XulDomContainer xulDomContainer = mock(XulDomContainer.class);
    when(xulDomContainer.getDocumentRoot()).thenReturn(document);
    controller.setXulDomContainer(xulDomContainer);
    UIRepositoryDirectory someDirectory = mock(UIRepositoryDirectory.class);
    selectedFolder = mock(UIRepositoryDirectory.class);
    when(selectedFolder.createFolder(FOLDER_NAME)).thenReturn(someDirectory);
    XulTree folderTree = mock(XulTree.class);
    when(folderTree.getSelectedItems()).thenReturn(Collections.<Object>singleton(selectedFolder));
    controller.setFolderTree(folderTree);
    directoryBinding = mock(Binding.class);
    controller.setDirectoryBinding(directoryBinding);
    selectedItemsBinding = mock(Binding.class);
    controller.setSelectedItemsBinding(selectedItemsBinding);
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) Binding(org.pentaho.ui.xul.binding.Binding) XulTree(org.pentaho.ui.xul.containers.XulTree) Document(org.pentaho.ui.xul.dom.Document) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Before(org.junit.Before)

Aggregations

UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)16 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)10 KettleException (org.pentaho.di.core.exception.KettleException)9 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 XulException (org.pentaho.ui.xul.XulException)7 ArrayList (java.util.ArrayList)5 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)5 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)5 List (java.util.List)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)2 Binding (org.pentaho.ui.xul.binding.Binding)2 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Callable (java.util.concurrent.Callable)1 Point (org.eclipse.swt.graphics.Point)1 Shell (org.eclipse.swt.widgets.Shell)1 Before (org.junit.Before)1 ObjectId (org.pentaho.di.repository.ObjectId)1