Search in sources :

Example 1 with TabMapEntry

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

the class SpoonEEJobDelegate method addJobGraph.

@Override
public void addJobGraph(JobMeta jobMeta) {
    super.addJobGraph(jobMeta);
    TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(jobMeta);
    if (tabEntry != null) {
        TabItem tabItem = tabEntry.getTabItem();
        try {
            if ((service != null) && (jobMeta.getObjectId() != null) && (service.getJobLock(jobMeta.getObjectId()) != null)) {
                tabItem.setImage(GUIResource.getInstance().getImageLocked());
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) KettleException(org.pentaho.di.core.exception.KettleException)

Example 2 with TabMapEntry

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

the class JobGraph method openJob.

public void openJob(JobEntryJob entry, JobEntryCopy jobEntryCopy) {
    try {
        JobMeta launchJobMeta = null;
        switch(entry.getSpecificationMethod()) {
            case FILENAME:
                // See if this file is already loaded...
                // 
                String exactFilename = jobMeta.environmentSubstitute(entry.getFilename());
                if (Utils.isEmpty(exactFilename)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoFilenameSpecified"));
                }
                // 
                if (KettleVFS.fileExists(exactFilename)) {
                    launchJobMeta = new JobMeta(jobMeta, exactFilename, spoon.rep, spoon.metaStore, null);
                } else {
                    launchJobMeta = new JobMeta();
                }
                launchJobMeta.setFilename(exactFilename);
                break;
            case REPOSITORY_BY_NAME:
                String exactJobname = jobMeta.environmentSubstitute(entry.getJobName());
                String exactDirectory = jobMeta.environmentSubstitute(entry.getDirectory());
                if (Utils.isEmpty(exactJobname)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobNameSpecified"));
                }
                if (Utils.isEmpty(exactDirectory)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobDirectorySpecified"));
                }
                // Open the job or create a new one...
                // 
                RepositoryDirectoryInterface repDir = spoon.rep.findDirectory(entry.getDirectory());
                boolean exists = spoon.rep.exists(exactJobname, repDir, RepositoryObjectType.JOB);
                if (!exists) {
                    launchJobMeta = new JobMeta();
                    launchJobMeta.setName(exactJobname);
                    launchJobMeta.setRepositoryDirectory(repDir);
                } else {
                    // Always reads last revision
                    launchJobMeta = spoon.rep.loadJob(exactJobname, repDir, null, null);
                }
                break;
            case REPOSITORY_BY_REFERENCE:
                if (entry.getJobObjectId() == null) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobReferenceSpecified"));
                }
                // Always reads last revision
                launchJobMeta = spoon.rep.loadJob(entry.getJobObjectId(), null);
                break;
            default:
                break;
        }
        // 
        if (launchJobMeta == null) {
            throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoValidJobSpecified"));
        }
        launchJobMeta.setRepository(spoon.getRepository());
        launchJobMeta.setMetaStore(spoon.getMetaStore());
        // Try to see if this job is already loaded in another tab...
        // 
        String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
        TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
        if (tabEntry != null) {
            // Switch to this one!
            // 
            spoon.tabfolder.setSelected(tabEntry.getTabItem());
            return;
        }
        spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
        spoon.addJobGraph(launchJobMeta);
        launchJobMeta.clearChanged();
        JobGraph jobGraph = spoon.getActiveJobGraph();
        attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
        spoon.refreshTree();
        spoon.applyVariables();
    } catch (Throwable e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Message"), e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 3 with TabMapEntry

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

the class JobGraph method loadReferencedObject.

protected void loadReferencedObject(JobEntryCopy jobEntryCopy, int index) {
    try {
        Object referencedMeta = jobEntryCopy.getEntry().loadReferencedObject(index, spoon.rep, spoon.metaStore, jobMeta);
        if (referencedMeta == null) {
            // Compatible re-try for older plugins.
            referencedMeta = compatibleJobEntryLoadReferencedObject(jobEntryCopy.getEntry(), index, spoon.rep, jobMeta);
        }
        if (referencedMeta != null && (referencedMeta instanceof TransMeta)) {
            TransMeta launchTransMeta = (TransMeta) referencedMeta;
            // Try to see if this transformation is already loaded in another tab...
            // 
            TabMapEntry tabEntry = spoon.delegates.tabs.findTabForTransformation(launchTransMeta);
            if (tabEntry != null) {
                // Switch to this one!
                // 
                spoon.tabfolder.setSelected(tabEntry.getTabItem());
                return;
            }
            copyInternalJobVariables(jobMeta, launchTransMeta);
            spoon.setParametersAsVariablesInUI(launchTransMeta, launchTransMeta);
            launchTransMeta.clearChanged();
            spoon.addTransGraph(launchTransMeta);
            TransGraph transGraph = spoon.getActiveTransGraph();
            attachActiveTrans(transGraph, launchTransMeta, jobEntryCopy);
            spoon.refreshTree();
            spoon.applyVariables();
        }
        if (referencedMeta != null && (referencedMeta instanceof JobMeta)) {
            JobMeta launchJobMeta = (JobMeta) referencedMeta;
            // Try to see if this job is already loaded in another tab...
            // 
            String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
            TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
            if (tabEntry != null) {
                // Switch to this one!
                // 
                spoon.tabfolder.setSelected(tabEntry.getTabItem());
                return;
            }
            spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
            launchJobMeta.clearChanged();
            spoon.addJobGraph(launchJobMeta);
            JobGraph jobGraph = spoon.getActiveJobGraph();
            attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
            spoon.refreshTree();
            spoon.applyVariables();
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Message"), e);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 4 with TabMapEntry

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

the class JobGraph method openTransformation.

protected void openTransformation(JobEntryTrans entry, JobEntryCopy jobEntryCopy) {
    try {
        TransMeta launchTransMeta = null;
        switch(entry.getSpecificationMethod()) {
            case FILENAME:
                // See if this file is already loaded...
                // 
                String exactFilename = jobMeta.environmentSubstitute(entry.getFilename());
                if (Utils.isEmpty(exactFilename)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoFilenameSpecified"));
                }
                // 
                if (KettleVFS.fileExists(exactFilename)) {
                    launchTransMeta = new TransMeta(exactFilename);
                } else {
                    launchTransMeta = new TransMeta();
                }
                launchTransMeta.setFilename(exactFilename);
                break;
            case REPOSITORY_BY_NAME:
                String exactTransname = jobMeta.environmentSubstitute(entry.getTransname());
                String exactDirectory = jobMeta.environmentSubstitute(entry.getDirectory());
                if (Utils.isEmpty(exactTransname)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoTransNameSpecified"));
                }
                if (Utils.isEmpty(exactDirectory)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoTransDirectorySpecified"));
                }
                // Open the transformation or create a new one...
                // But first we look to see if the directory does exist
                RepositoryDirectoryInterface repositoryDirectoryInterface = spoon.rep.findDirectory(jobMeta.environmentSubstitute(entry.getDirectory()));
                if (repositoryDirectoryInterface == null) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.DirectoryDoesNotExist", jobMeta.environmentSubstitute(entry.getDirectory())));
                }
                boolean exists = spoon.rep.getTransformationID(exactTransname, repositoryDirectoryInterface) != null;
                if (!exists) {
                    launchTransMeta = new TransMeta(null, exactTransname);
                } else {
                    launchTransMeta = spoon.rep.loadTransformation(exactTransname, spoon.rep.findDirectory(jobMeta.environmentSubstitute(entry.getDirectory())), null, true, // reads last version
                    null);
                }
                break;
            case REPOSITORY_BY_REFERENCE:
                if (entry.getTransObjectId() == null) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoTransReferenceSpecified"));
                }
                launchTransMeta = spoon.rep.loadTransformation(entry.getTransObjectId(), null);
                break;
            default:
                break;
        }
        // 
        if (launchTransMeta == null) {
            throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoValidTransSpecified"));
        }
        launchTransMeta.setRepository(spoon.getRepository());
        launchTransMeta.setMetaStore(spoon.getMetaStore());
        // Try to see if this transformation is already loaded in another tab...
        // 
        TabMapEntry tabEntry = spoon.delegates.tabs.findTabForTransformation(launchTransMeta);
        if (tabEntry != null) {
            // Switch to this one!
            // 
            spoon.tabfolder.setSelected(tabEntry.getTabItem());
            return;
        }
        copyInternalJobVariables(jobMeta, launchTransMeta);
        spoon.setParametersAsVariablesInUI(launchTransMeta, launchTransMeta);
        spoon.addTransGraph(launchTransMeta);
        launchTransMeta.clearChanged();
        TransGraph transGraph = spoon.getActiveTransGraph();
        attachActiveTrans(transGraph, launchTransMeta, jobEntryCopy);
        spoon.refreshTree();
        spoon.applyVariables();
    } catch (Throwable e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Message"), (Exception) e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 5 with TabMapEntry

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

the class SpoonTabsDelegate method renameTabs.

/**
 * Rename the tabs
 */
public void renameTabs() {
    List<TabMapEntry> list = new ArrayList<TabMapEntry>(tabMap);
    for (TabMapEntry entry : list) {
        if (entry.getTabItem().isDisposed()) {
            // this should not be in the map, get rid of it.
            tabMap.remove(entry.getObjectName());
            continue;
        }
        // TabItem before = entry.getTabItem();
        // PDI-1683: need to get the String here, otherwise using only the "before" instance below, the reference gets
        // changed and result is always the same
        // String beforeText=before.getText();
        // 
        Object managedObject = entry.getObject().getManagedObject();
        if (managedObject != null) {
            if (entry.getObject() instanceof AbstractGraph) {
                AbstractMeta meta = (AbstractMeta) managedObject;
                String tabText = makeTabName(meta, entry.isShowingLocation());
                entry.getTabItem().setText(tabText);
                String toolTipText = BaseMessages.getString(PKG, "Spoon.TabTrans.Tooltip", tabText);
                if (entry.getObject() instanceof JobGraph) {
                    toolTipText = BaseMessages.getString(PKG, "Spoon.TabJob.Tooltip", tabText);
                }
                if (Const.isWindows() && !Utils.isEmpty(meta.getFilename())) {
                    toolTipText += Const.CR + Const.CR + meta.getFilename();
                }
                entry.getTabItem().setToolTipText(toolTipText);
            }
        }
    }
    spoon.setShellText();
}
Also used : AbstractGraph(org.pentaho.di.ui.spoon.AbstractGraph) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) AbstractMeta(org.pentaho.di.base.AbstractMeta) ArrayList(java.util.ArrayList) FileObject(org.apache.commons.vfs2.FileObject) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry)

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