Search in sources :

Example 11 with TabMapEntry

use of org.pentaho.di.ui.spoon.TabMapEntry in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method closeJob.

/**
 * @param jobMeta
 *          the transformation to close, make sure it's ok to dispose of it BEFORE you call this.
 */
public void closeJob(JobMeta jobMeta) {
    // Close the associated tabs...
    // 
    TabMapEntry entry = getSpoon().delegates.tabs.findTabMapEntry(jobMeta);
    if (entry != null) {
        getSpoon().delegates.tabs.removeTab(entry);
    }
    // Also remove it from the item from the jobMap
    // Otherwise it keeps showing up in the objects tree
    // 
    int index = getJobList().indexOf(jobMeta);
    while (index >= 0) {
        getJobList().remove(index);
        index = getJobList().indexOf(jobMeta);
    }
    getSpoon().refreshTree();
    getSpoon().enableMenus();
}
Also used : TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 12 with TabMapEntry

use of org.pentaho.di.ui.spoon.TabMapEntry 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)

Example 13 with TabMapEntry

use of org.pentaho.di.ui.spoon.TabMapEntry in project pentaho-kettle by pentaho.

the class SpoonSlaveDelegate method addSpoonSlave.

public void addSpoonSlave(SlaveServer slaveServer) {
    TabSet tabfolder = spoon.tabfolder;
    // See if there is a SpoonSlave for this slaveServer...
    String tabName = spoon.delegates.tabs.makeSlaveTabName(slaveServer);
    TabMapEntry tabMapEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.SLAVE_SERVER);
    if (tabMapEntry == null) {
        SpoonSlave spoonSlave = new SpoonSlave(tabfolder.getSwtTabset(), SWT.NONE, spoon, slaveServer);
        PropsUI props = PropsUI.getInstance();
        TabItem tabItem = new TabItem(tabfolder, tabName, tabName, props.getSashWeights());
        tabItem.setToolTipText("Status of slave server : " + slaveServer.getName() + " : " + slaveServer.getServerAndPort());
        tabItem.setControl(spoonSlave);
        tabMapEntry = new TabMapEntry(tabItem, null, tabName, null, null, spoonSlave, ObjectType.SLAVE_SERVER);
        spoon.delegates.tabs.addTab(tabMapEntry);
    }
    int idx = tabfolder.indexOf(tabMapEntry.getTabItem());
    tabfolder.setSelected(idx);
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) TabSet(org.pentaho.xul.swt.tab.TabSet) SpoonSlave(org.pentaho.di.ui.spoon.SpoonSlave) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 14 with TabMapEntry

use of org.pentaho.di.ui.spoon.TabMapEntry in project pentaho-kettle by pentaho.

the class SpoonTabsDelegate method tabSelected.

public void tabSelected(TabItem item) {
    // 
    for (TabMapEntry entry : tabMap) {
        boolean isAbstractGraph = (entry.getObject() instanceof AbstractGraph);
        if (item.equals(entry.getTabItem())) {
            if (isAbstractGraph) {
                EngineMetaInterface meta = entry.getObject().getMeta();
                if (meta != null) {
                    meta.setInternalKettleVariables();
                }
                if (spoon.getCoreObjectsState() != SpoonInterface.STATE_CORE_OBJECTS_SPOON) {
                    spoon.refreshCoreObjects();
                }
                ((AbstractGraph) entry.getObject()).setFocus();
            }
            break;
        }
    }
    // Also refresh the tree
    spoon.refreshTree();
    // calls also enableMenus() and markTabsChanged()
    spoon.setShellText();
}
Also used : AbstractGraph(org.pentaho.di.ui.spoon.AbstractGraph) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry)

Example 15 with TabMapEntry

use of org.pentaho.di.ui.spoon.TabMapEntry in project pentaho-kettle by pentaho.

the class SpoonTabsDelegate method addSpoonBrowser.

public boolean addSpoonBrowser(String name, String urlString, boolean isURL, LocationListener listener, Map<String, Runnable> functions, boolean showControls) {
    TabSet tabfolder = spoon.tabfolder;
    try {
        // OK, now we have the HTML, create a new browser tab.
        // See if there already is a tab for this browser
        // If no, add it
        // If yes, select that tab
        // 
        TabMapEntry tabMapEntry = findTabMapEntry(name, ObjectType.BROWSER);
        if (tabMapEntry == null) {
            CTabFolder cTabFolder = tabfolder.getSwtTabset();
            final SpoonBrowser browser = new SpoonBrowser(cTabFolder, spoon, urlString, isURL, showControls, listener);
            browser.getBrowser().addOpenWindowListener(new OpenWindowListener() {

                @Override
                public void open(WindowEvent event) {
                    if (event.required) {
                        event.browser = browser.getBrowser();
                    }
                }
            });
            if (functions != null) {
                for (String functionName : functions.keySet()) {
                    new BrowserFunction(browser.getBrowser(), functionName) {

                        public Object function(Object[] arguments) {
                            functions.get(functionName).run();
                            return null;
                        }
                    };
                }
            }
            new BrowserFunction(browser.getBrowser(), "genericFunction") {

                public Object function(Object[] arguments) {
                    try {
                        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonBrowserFunction.id, arguments);
                    } catch (KettleException ignored) {
                    }
                    return null;
                }
            };
            new BrowserFunction(browser.getBrowser(), "openURL") {

                public Object function(Object[] arguments) {
                    Program.launch(arguments[0].toString());
                    return null;
                }
            };
            PropsUI props = PropsUI.getInstance();
            TabItem tabItem = new TabItem(tabfolder, name, name, props.getSashWeights());
            tabItem.setImage(GUIResource.getInstance().getImageLogoSmall());
            tabItem.setControl(browser.getComposite());
            tabMapEntry = new TabMapEntry(tabItem, isURL ? urlString : null, name, null, null, browser, ObjectType.BROWSER);
            tabMap.add(tabMapEntry);
        }
        int idx = tabfolder.indexOf(tabMapEntry.getTabItem());
        // keep the focus on the graph
        tabfolder.setSelected(idx);
        return true;
    } catch (Throwable e) {
        boolean ok = false;
        if (isURL) {
            // Retry to show the welcome page in an external browser.
            // 
            Status status = Launch.openURL(urlString);
            ok = status.equals(Status.Success);
        }
        if (!ok) {
            // Log an error
            // 
            log.logError("Unable to open browser tab", e);
            return false;
        } else {
            return true;
        }
    }
}
Also used : Status(org.pentaho.ui.util.Launch.Status) KettleException(org.pentaho.di.core.exception.KettleException) CTabFolder(org.eclipse.swt.custom.CTabFolder) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) PropsUI(org.pentaho.di.ui.core.PropsUI) TabItem(org.pentaho.xul.swt.tab.TabItem) BrowserFunction(org.eclipse.swt.browser.BrowserFunction) SpoonBrowser(org.pentaho.di.ui.spoon.SpoonBrowser) TabSet(org.pentaho.xul.swt.tab.TabSet) WindowEvent(org.eclipse.swt.browser.WindowEvent) OpenWindowListener(org.eclipse.swt.browser.OpenWindowListener)

Aggregations

TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)16 KettleException (org.pentaho.di.core.exception.KettleException)7 TabItem (org.pentaho.xul.swt.tab.TabItem)7 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)6 TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)6 JobGraph (org.pentaho.di.ui.spoon.job.JobGraph)5 Point (org.pentaho.di.core.gui.Point)4 PropsUI (org.pentaho.di.ui.core.PropsUI)4 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)3 JobMeta (org.pentaho.di.job.JobMeta)3 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)3 TransMeta (org.pentaho.di.trans.TransMeta)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3 XulException (org.pentaho.ui.xul.XulException)3 TabSet (org.pentaho.xul.swt.tab.TabSet)3 FileObject (org.apache.commons.vfs2.FileObject)2 AbstractMeta (org.pentaho.di.base.AbstractMeta)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 AbstractGraph (org.pentaho.di.ui.spoon.AbstractGraph)2 SpoonBrowser (org.pentaho.di.ui.spoon.SpoonBrowser)2