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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
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();
}
Aggregations