Search in sources :

Example 6 with LastUsedFile

use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.

the class PropsUI method setLastUsedRepoFiles.

public void setLastUsedRepoFiles() {
    int lastRepoFiles = 0;
    for (String repoName : lastUsedRepoFiles.keySet()) {
        lastRepoFiles += lastUsedRepoFiles.get(repoName).size();
    }
    properties.setProperty("lastrepofiles", "" + lastRepoFiles);
    int i = 0;
    for (String repoName : lastUsedRepoFiles.keySet()) {
        for (LastUsedFile lastUsedFile : lastUsedRepoFiles.get(repoName)) {
            properties.setProperty("repofiletype" + (i + 1), Const.NVL(lastUsedFile.getFileType(), LastUsedFile.FILE_TYPE_TRANSFORMATION));
            properties.setProperty("repolastfile" + (i + 1), Const.NVL(lastUsedFile.getFilename(), ""));
            properties.setProperty("repolastdir" + (i + 1), Const.NVL(lastUsedFile.getDirectory(), ""));
            properties.setProperty("repolasttype" + (i + 1), lastUsedFile.isSourceRepository() ? YES : NO);
            properties.setProperty("repolastrepo" + (i + 1), Const.NVL(lastUsedFile.getRepositoryName(), ""));
            properties.setProperty("repolastuser" + (i + 1), Const.NVL(lastUsedFile.getUsername(), ""));
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            properties.setProperty("repolastdate" + (i + 1), Const.NVL(simpleDateFormat.format(lastUsedFile.getLastOpened()), ""));
            i++;
        }
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Point(org.pentaho.di.core.gui.Point) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 7 with LastUsedFile

use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.

the class PropsUI method getLastDirs.

public String[] getLastDirs() {
    String[] retval = new String[lastUsedFiles.size()];
    for (int i = 0; i < retval.length; i++) {
        LastUsedFile lastUsedFile = lastUsedFiles.get(i);
        retval[i] = lastUsedFile.getDirectory();
    }
    return retval;
}
Also used : Point(org.pentaho.di.core.gui.Point) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 8 with LastUsedFile

use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.

the class PropsUI method getLastRepositories.

public String[] getLastRepositories() {
    String[] retval = new String[lastUsedFiles.size()];
    for (int i = 0; i < retval.length; i++) {
        LastUsedFile lastUsedFile = lastUsedFiles.get(i);
        retval[i] = lastUsedFile.getRepositoryName();
    }
    return retval;
}
Also used : Point(org.pentaho.di.core.gui.Point) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 9 with LastUsedFile

use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.

the class RepositoryOpenRecentFileExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (!(object instanceof LastUsedFile)) {
        return;
    }
    LastUsedFile recentFile = (LastUsedFile) object;
    if (recentFile.isSourceRepository() && !repositoryConnectController.isConnected(recentFile.getRepositoryName())) {
        if (getSpoon().promptForSave()) {
            RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(recentFile.getRepositoryName());
            if (repositoryMeta != null) {
                if (repositoryMeta.getId().equals("KettleFileRepository")) {
                    getSpoon().closeRepository();
                    repositoryConnectController.connectToRepository(repositoryMeta);
                } else {
                    new RepositoryDialog(getSpoon().getShell(), repositoryConnectController).openLogin(repositoryMeta);
                }
                if (repositoryConnectController.isConnected(repositoryMeta.getName())) {
                    getSpoon().loadLastUsedFile(recentFile, repositoryMeta.getName());
                    getSpoon().addMenuLast();
                }
            }
        }
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 10 with LastUsedFile

use of org.pentaho.di.core.LastUsedFile 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)25 Point (org.pentaho.di.core.gui.Point)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4 Date (java.util.Date)3 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Calendar (java.util.Calendar)2 PropsUI (org.pentaho.di.ui.core.PropsUI)2 ArrayList (java.util.ArrayList)1 ResourceBundle (java.util.ResourceBundle)1 Action (org.eclipse.jface.action.Action)1 FontData (org.eclipse.swt.graphics.FontData)1 RGB (org.eclipse.swt.graphics.RGB)1 KettleException (org.pentaho.di.core.exception.KettleException)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 TransAction (org.pentaho.di.core.undo.TransAction)1 IUser (org.pentaho.di.repository.IUser)1 Repository (org.pentaho.di.repository.Repository)1 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)1 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)1