Search in sources :

Example 21 with PropsUI

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;
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) IUser(org.pentaho.di.repository.IUser) RepositoryFile(org.pentaho.repo.model.RepositoryFile) LastUsedFile(org.pentaho.di.core.LastUsedFile) Date(java.util.Date) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 22 with PropsUI

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;
    }
}
Also used : Field(java.lang.reflect.Field) XmlObject(com.sforce.ws.bind.XmlObject) SObject(com.sforce.soap.partner.sobject.SObject) PropsUI(org.pentaho.di.ui.core.PropsUI) BeforeClass(org.junit.BeforeClass)

Example 23 with PropsUI

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);
    }
}
Also used : WindowProperty(org.pentaho.di.ui.core.gui.WindowProperty) Monitor(org.eclipse.swt.widgets.Monitor) Rectangle(org.eclipse.swt.graphics.Rectangle) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 24 with PropsUI

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);
    }
}
Also used : WindowProperty(org.pentaho.di.ui.core.gui.WindowProperty) Monitor(org.eclipse.swt.widgets.Monitor) Rectangle(org.eclipse.swt.graphics.Rectangle) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 25 with PropsUI

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();
        }
    }
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

PropsUI (org.pentaho.di.ui.core.PropsUI)28 Label (org.eclipse.swt.widgets.Label)9 FormLayout (org.eclipse.swt.layout.FormLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 Text (org.eclipse.swt.widgets.Text)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 Button (org.eclipse.swt.widgets.Button)4 KettleException (org.pentaho.di.core.exception.KettleException)4 Field (java.lang.reflect.Field)3 Group (org.eclipse.swt.widgets.Group)3 Monitor (org.eclipse.swt.widgets.Monitor)3 BeforeClass (org.junit.BeforeClass)3 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)3 TabItem (org.pentaho.xul.swt.tab.TabItem)3 WindowEvent (org.eclipse.swt.browser.WindowEvent)2