use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method getRecentFiles.
public List<RepositoryFile> getRecentFiles() {
PropsUI props = PropsUI.getInstance();
List<RepositoryFile> repositoryFiles = new ArrayList<>();
IUser userInfo = Spoon.getInstance().rep.getUserInfo();
String repoAndUser = Spoon.getInstance().rep.getName() + ":" + (userInfo != null ? userInfo.getLogin() : "");
List<LastUsedFile> lastUsedFiles = props.getLastUsedRepoFiles().getOrDefault(repoAndUser, Collections.emptyList());
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -30);
Date dateBefore = calendar.getTime();
for (int i = 0; i < lastUsedFiles.size(); i++) {
LastUsedFile lastUsedFile = lastUsedFiles.get(i);
if (lastUsedFile.getLastOpened().before(dateBefore)) {
continue;
}
if (lastUsedFile.getRepositoryName() != null && lastUsedFile.getRepositoryName().equals(Spoon.getInstance().rep.getName())) {
RepositoryFile repositoryFile = new RepositoryFile();
final String index = String.valueOf(i);
repositoryFile.setObjectId(() -> index);
repositoryFile.setType(lastUsedFile.isTransformation() ? TRANSFORMATION : JOB);
repositoryFile.setName(lastUsedFile.getFilename());
repositoryFile.setPath(lastUsedFile.getDirectory());
repositoryFile.setDate(lastUsedFile.getLastOpened());
repositoryFile.setRepository(lastUsedFile.getRepositoryName());
repositoryFile.setUsername(lastUsedFile.getUsername());
repositoryFiles.add(repositoryFile);
}
}
return repositoryFiles;
}
use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.
the class SalesforceInputDialogTest method hackPropsUi.
@BeforeClass
public static void hackPropsUi() throws Exception {
Field props = getPropsField();
if (props == null) {
throw new IllegalStateException("Cannot find 'props' field in " + Props.class.getName());
}
Object value = FieldUtils.readStaticField(props, true);
if (value == null) {
PropsUI mock = mock(PropsUI.class);
FieldUtils.writeStaticField(props, mock, true);
changedPropsUi = true;
} else {
changedPropsUi = false;
}
}
use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.
the class BaseStepDialog method setSize.
/**
* Sets the size of this dialog with respect to the given parameters.
*
* @param shell the shell
* @param minWidth the minimum width
* @param minHeight the minimum height
* @param packIt true to pack the dialog components, false otherwise
*/
public static void setSize(Shell shell, int minWidth, int minHeight, boolean packIt) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen(shell.getText());
if (winprop != null) {
winprop.setShell(shell, minWidth, minHeight);
} else {
if (packIt) {
shell.pack();
} else {
shell.layout();
}
// OK, sometimes this produces dialogs that are waay too big.
// Try to limit this a bit, m'kay?
// Use the same algorithm by cheating :-)
//
winprop = new WindowProperty(shell);
winprop.setShell(shell, minWidth, minHeight);
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (shell.getParent() != null) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + (monitorClientArea.width - shellBounds.width) / 2;
int middleY = monitorClientArea.y + (monitorClientArea.height - shellBounds.height) / 2;
shell.setLocation(middleX, middleY);
}
}
use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.
the class BaseStepXulDialog method setSize.
public static void setSize(Shell shell, int minWidth, int minHeight, boolean packIt) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen(shell.getText());
if (winprop != null) {
winprop.setShell(shell, minWidth, minHeight);
} else {
if (packIt) {
shell.pack();
} else {
shell.layout();
}
// OK, sometimes this produces dialogs that are waay too big.
// Try to limit this a bit, m'kay?
// Use the same algorithm by cheating :-)
//
winprop = new WindowProperty(shell);
winprop.setShell(shell, minWidth, minHeight);
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (shell.getParent() != null) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + (monitorClientArea.width - shellBounds.width) / 2;
int middleY = monitorClientArea.y + (monitorClientArea.height - shellBounds.height) / 2;
shell.setLocation(middleX, middleY);
}
}
use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.
the class SpoonJobDelegate method addJobGraph.
public void addJobGraph(JobMeta jobMeta) {
boolean added = addJob(jobMeta);
if (added) {
// See if there already is a tab for this graph with the short default name.
// If there is, set that one to show the location as well.
// If not, simply add it without
// If no, add it
// If yes, select that tab
//
boolean showLocation = false;
boolean addTab = true;
String tabName = spoon.delegates.tabs.makeTabName(jobMeta, false);
TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
if (tabEntry != null) {
// We change the already loaded job to also show the location.
//
showLocation = true;
tabEntry.setShowingLocation(true);
String newTabName = spoon.delegates.tabs.makeTabName(tabEntry.getObject().getMeta(), true);
tabEntry.getTabItem().setText(newTabName);
// Try again, including the location of the object...
//
tabName = spoon.delegates.tabs.makeTabName(jobMeta, true);
tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
if (tabEntry != null) {
// Already loaded, simply select the tab item in question...
//
addTab = false;
}
}
if (addTab) {
JobGraph jobGraph = new JobGraph(spoon.tabfolder.getSwtTabset(), spoon, jobMeta);
PropsUI props = PropsUI.getInstance();
TabItem tabItem = new TabItem(spoon.tabfolder, tabName, tabName, props.getSashWeights());
String toolTipText = BaseMessages.getString(PKG, "Spoon.TabJob.Tooltip", spoon.delegates.tabs.makeTabName(jobMeta, showLocation));
if (!Utils.isEmpty(jobMeta.getFilename())) {
toolTipText += Const.CR + Const.CR + jobMeta.getFilename();
}
tabItem.setToolTipText(toolTipText);
tabItem.setImage(GUIResource.getInstance().getImageJobGraph());
tabItem.setControl(jobGraph);
// OK, also see if we need to open a new history window.
if (jobMeta.getJobLogTable().getDatabaseMeta() != null && !Utils.isEmpty(jobMeta.getJobLogTable().getTableName())) {
jobGraph.addAllTabs();
jobGraph.extraViewTabFolder.setSelection(jobGraph.jobHistoryDelegate.getJobHistoryTab());
}
String versionLabel = jobMeta.getObjectRevision() == null ? null : jobMeta.getObjectRevision().getName();
tabEntry = new TabMapEntry(tabItem, jobMeta.getFilename(), jobMeta.getName(), jobMeta.getRepositoryDirectory(), versionLabel, jobGraph, ObjectType.JOB_GRAPH);
tabEntry.setShowingLocation(showLocation);
spoon.delegates.tabs.addTab(tabEntry);
}
int idx = spoon.tabfolder.indexOf(tabEntry.getTabItem());
// keep the focus on the graph
spoon.tabfolder.setSelected(idx);
spoon.setUndoMenu(jobMeta);
spoon.enableMenus();
} else {
TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(jobMeta);
if (tabEntry != null) {
int idx = spoon.tabfolder.indexOf(tabEntry.getTabItem());
// keep the focus on the graph
spoon.tabfolder.setSelected(idx);
// keep the focus on the graph
spoon.tabfolder.setSelected(idx);
spoon.setUndoMenu(jobMeta);
spoon.enableMenus();
}
}
}
Aggregations