use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class RecentUtilsTest method setPathsUnixTest.
@Test
public void setPathsUnixTest() {
LastUsedFile lastUsedFile = new LastUsedFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, UNIX_PATH, null, false, null, null, false, 1, new Date(), null);
RecentFile recentFile = new RecentFile();
RecentUtils.setPaths(lastUsedFile, recentFile);
Assert.assertEquals(UNIX_FILENAME, recentFile.getName());
Assert.assertEquals(UNIX_PARENT, recentFile.getParent());
Assert.assertEquals(UNIX_PATH, recentFile.getPath());
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class RecentUtilsTest method setPathsWindowsTest.
@Test
public void setPathsWindowsTest() {
LastUsedFile lastUsedFile = new LastUsedFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, WINDOWS_PATH, null, false, null, null, false, 1, new Date(), null);
RecentFile recentFile = new RecentFile();
RecentUtils.setPaths(lastUsedFile, recentFile);
Assert.assertEquals(WINDOWS_FILENAME, recentFile.getName());
Assert.assertEquals(WINDOWS_PARENT, recentFile.getParent());
Assert.assertEquals(WINDOWS_PATH, recentFile.getPath());
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class Spoon method addMenuLast.
public void addMenuLast() {
org.pentaho.ui.xul.dom.Document doc = mainSpoonContainer.getDocumentRoot();
JfaceMenupopup recentFilesPopup = (JfaceMenupopup) doc.getElementById("file-open-recent-popup");
recentFilesPopup.removeChildren();
// Previously loaded files...
List<LastUsedFile> lastUsedFiles = props.getLastUsedFiles();
for (int i = 0; i < lastUsedFiles.size(); i++) {
final LastUsedFile lastUsedFile = lastUsedFiles.get(i);
char chr = (char) ('1' + i);
String accessKey = "ctrl-" + chr;
String accessText = "CTRL-" + chr;
String text = lastUsedFile.toString();
String id = "last-file-" + i;
if (i > 8) {
accessKey = null;
accessText = null;
}
final String lastFileId = Integer.toString(i);
Action action = new Action("open-last-file-" + (i + 1), Action.AS_PUSH_BUTTON) {
@Override
public void run() {
lastFileSelect(lastFileId);
}
};
// shorten the filename if necessary
int targetLength = 40;
if (text.length() > targetLength) {
int lastSep = text.replace('\\', '/').lastIndexOf('/');
if (lastSep != -1) {
String fileName = "..." + text.substring(lastSep);
if (fileName.length() < targetLength) {
// add the start of the file path
int leadSize = targetLength - fileName.length();
text = text.substring(0, leadSize) + fileName;
} else {
text = fileName;
}
}
}
JfaceMenuitem miFileLast = new JfaceMenuitem(null, recentFilesPopup, mainSpoonContainer, text, 0, action);
miFileLast.setLabel(text);
miFileLast.setId(id);
if (accessText != null && accessKey != null) {
miFileLast.setAcceltext(accessText);
miFileLast.setAccesskey(accessKey);
}
if (lastUsedFile.isTransformation()) {
miFileLast.setImage(GUIResource.getInstance().getImageTransGraph());
} else if (lastUsedFile.isJob()) {
miFileLast.setImage(GUIResource.getInstance().getImageJobGraph());
}
miFileLast.setCommand("spoon.lastFileSelect('" + i + "')");
}
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class Spoon method getLastUsedRepoFile.
public LastUsedFile getLastUsedRepoFile(String repo, String indexStr) {
// this should never happen when used on a repo file, but we check just to be safe
if (rep == null) {
return null;
}
final int idx = Integer.parseInt(indexStr);
final List<LastUsedFile> lastUsedFiles = props.getLastUsedRepoFiles().getOrDefault(repo, Collections.emptyList());
return lastUsedFiles.get(idx);
}
use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class Spoon method lastRepoFileSelect.
public void lastRepoFileSelect(String repo, String id) {
int idx = Integer.parseInt(id);
List<LastUsedFile> lastUsedFiles = props.getLastUsedRepoFiles().getOrDefault(repo, Collections.emptyList());
lastFileSelect(lastUsedFiles.get(idx));
}
Aggregations