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++;
}
}
}
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;
}
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;
}
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();
}
}
}
}
}
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);
}
}
Aggregations