Search in sources :

Example 1 with RepositoryOpenSaveDialog

use of org.pentaho.repo.dialog.RepositoryOpenSaveDialog in project pentaho-kettle by pentaho.

the class RepositoryOpenSaveExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    FileDialogOperation fileDialogOperation = (FileDialogOperation) o;
    PropsUI propsUI = propsUISupplier.get();
    String startingDir = null;
    if (fileDialogOperation.getRepository() == null) {
        String username = getRepository().getUserInfo() != null ? getRepository().getUserInfo().getLogin() : "";
        String repoAndUser = getRepository().getName() + ":" + username;
        List<LastUsedFile> lastUsedFileList = propsUI.getLastUsedRepoFiles().getOrDefault(repoAndUser, Collections.emptyList());
        startingDir = getStartingDir(fileDialogOperation, lastUsedFileList);
    } else {
        startingDir = fileDialogOperation.getStartDir();
    }
    RepositoryOpenSaveDialog repositoryOpenSaveDialog = new RepositoryOpenSaveDialog(spoonSupplier.get().getShell(), WIDTH, HEIGHT);
    repositoryOpenSaveDialog.open(fileDialogOperation.getRepository(), startingDir, fileDialogOperation.getCommand(), fileDialogOperation.getTitle(), fileDialogOperation.getFilter(), fileDialogOperation.getOrigin(), fileDialogOperation.getFilename(), fileDialogOperation.getFileType());
    if (!Utils.isEmpty(repositoryOpenSaveDialog.getObjectName())) {
        RepositoryObject repositoryObject = new RepositoryObject();
        repositoryObject.setObjectId(repositoryOpenSaveDialog::getObjectId);
        repositoryObject.setName(repositoryOpenSaveDialog.getObjectName());
        repositoryObject.setRepositoryDirectory(getRepository().findDirectory(repositoryOpenSaveDialog.getObjectDirectory()));
        repositoryObject.setObjectType(repositoryOpenSaveDialog.getObjectType().equals(TRANSFORMATION) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB);
        fileDialogOperation.setRepositoryObject(repositoryObject);
    }
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryOpenSaveDialog(org.pentaho.repo.dialog.RepositoryOpenSaveDialog) LastUsedFile(org.pentaho.di.core.LastUsedFile) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

LastUsedFile (org.pentaho.di.core.LastUsedFile)1 RepositoryObject (org.pentaho.di.repository.RepositoryObject)1 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)1 PropsUI (org.pentaho.di.ui.core.PropsUI)1 RepositoryOpenSaveDialog (org.pentaho.repo.dialog.RepositoryOpenSaveDialog)1