use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class RepositoryOpenSaveExtensionPoint method getStartingDir.
private String getStartingDir(FileDialogOperation fileDialogOperation, List<LastUsedFile> lastUsedFileList) {
String startingDir = fileDialogOperation.getStartDir();
if (!Utils.isEmpty(startingDir)) {
return startingDir;
}
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, DAYS);
Date dateBefore = calendar.getTime();
LastUsedFile lastUsedFile = null;
if (lastUsedFileList.size() > 0 && lastUsedFileList.get(0).getLastOpened().after(dateBefore)) {
lastUsedFile = lastUsedFileList.get(0);
}
return lastUsedFile != null ? lastUsedFile.getDirectory() : null;
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class Spoon method lastFileSelect.
public void lastFileSelect(String id) {
int idx = Integer.parseInt(id);
List<LastUsedFile> lastUsedFiles = props.getLastUsedFiles();
lastFileSelect(lastUsedFiles.get(idx));
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class PropsUI method loadLastUsedRepoFiles.
public void loadLastUsedRepoFiles() {
lastUsedRepoFiles = new LinkedHashMap<>();
int nr = Const.toInt(properties.getProperty("lastrepofiles"), 0);
for (int i = 0; i < nr; i++) {
String fileType = properties.getProperty("repofiletype" + (i + 1), LastUsedFile.FILE_TYPE_TRANSFORMATION);
String filename = properties.getProperty("repolastfile" + (i + 1), "");
String directory = properties.getProperty("repolastdir" + (i + 1), "");
boolean sourceRepository = YES.equalsIgnoreCase(properties.getProperty("repolasttype" + (i + 1), NO));
String repositoryName = properties.getProperty("repolastrepo" + (i + 1));
String username = properties.getProperty("repolastuser" + (i + 1));
boolean isOpened = YES.equalsIgnoreCase(properties.getProperty("repolastopened" + (i + 1), NO));
int openItemTypes = Const.toInt(properties.getProperty("repolastopentypes" + (i + 1), "0"), 0);
Date lastOpened = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
String repoLastDate = properties.getProperty("repolastdate" + (i + 1));
if (repoLastDate != null) {
lastOpened = simpleDateFormat.parse(repoLastDate);
}
} catch (ParseException pe) {
// Default of null is acceptable
}
List<LastUsedFile> lastUsedFiles = lastUsedRepoFiles.getOrDefault(repositoryName + ":" + username, new ArrayList<>());
lastUsedFiles.add(new LastUsedFile(fileType, filename, directory, sourceRepository, repositoryName, username, isOpened, openItemTypes, lastOpened));
lastUsedRepoFiles.put(repositoryName + ":" + username, lastUsedFiles);
}
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class PropsUI method setLastFiles.
public void setLastFiles() {
properties.setProperty("lastfiles", "" + lastUsedFiles.size());
for (int i = 0; i < lastUsedFiles.size(); i++) {
LastUsedFile lastUsedFile = lastUsedFiles.get(i);
properties.setProperty("filetype" + (i + 1), Const.NVL(lastUsedFile.getFileType(), LastUsedFile.FILE_TYPE_TRANSFORMATION));
properties.setProperty("lastfile" + (i + 1), Const.NVL(lastUsedFile.getFilename(), ""));
properties.setProperty("lastdir" + (i + 1), Const.NVL(lastUsedFile.getDirectory(), ""));
properties.setProperty("lasttype" + (i + 1), lastUsedFile.isSourceRepository() ? YES : NO);
properties.setProperty("lastrepo" + (i + 1), Const.NVL(lastUsedFile.getRepositoryName(), ""));
properties.setProperty("lastuser" + (i + 1), Const.NVL(lastUsedFile.getUsername(), ""));
}
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class PropsUI method addLastRepoFile.
private void addLastRepoFile(LastUsedFile lastUsedFile) {
String repositoryName = lastUsedFile.getRepositoryName();
String username = lastUsedFile.getUsername() != null ? lastUsedFile.getUsername() : "";
if (!Utils.isEmpty(repositoryName)) {
List<LastUsedFile> lastUsedFiles = lastUsedRepoFiles.getOrDefault(repositoryName + ":" + username, new ArrayList<>());
int idx = lastUsedFiles.indexOf(lastUsedFile);
if (idx >= 0) {
lastUsedFiles.remove(idx);
}
lastUsedFiles.add(0, lastUsedFile);
lastUsedRepoFiles.put(repositoryName + ":" + username, lastUsedFiles);
// If we have more than Const.MAX_FILE_HIST, top it off
while (lastUsedFiles.size() > 12) {
lastUsedFiles.remove(lastUsedRepoFiles.get(repositoryName + ":" + username).size() - 1);
}
}
}
Aggregations