use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method saveFileAs.
public boolean saveFileAs(EngineMetaInterface meta) throws KettleException {
boolean saved;
if (getLog().isBasic()) {
// "Save as..."
getLog().logBasic(BaseMessages.getString(PKG, "Spoon.Log.SaveAs"));
}
((AbstractMeta) meta).setRepository(rep);
((AbstractMeta) meta).setMetaStore(metaStore);
String activePerspectiveId = SpoonPerspectiveManager.getInstance().getActivePerspective().getId();
boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
if (rep != null && etlPerspective) {
meta.setObjectId(null);
meta.setFilename(null);
saved = saveToRepository(meta, true);
} else {
saved = saveXMLFile(meta, false);
}
// rename the tab only if the meta was successfully saved
if (saved) {
// filename or name of transformation might have changed.
delegates.tabs.renameTabs();
}
refreshTree();
if (saved && (meta instanceof TransMeta || meta instanceof JobMeta)) {
TabMapEntry tabEntry = delegates.tabs.findTabMapEntry(meta);
TabItem tabItem = tabEntry.getTabItem();
if (meta.getFileType().equals(LastUsedFile.FILE_TYPE_TRANSFORMATION)) {
tabItem.setImage(GUIResource.getInstance().getImageTransGraph());
} else if (meta.getFileType().equals(LastUsedFile.FILE_TYPE_JOB)) {
tabItem.setImage(GUIResource.getInstance().getImageJobGraph());
}
}
// Update menu status for the newly saved object
enableMenus();
return saved;
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method saveFileAs.
public boolean saveFileAs() throws KettleException {
try {
EngineMetaInterface meta = getActiveMeta();
if (meta != null && AbstractMeta.class.isAssignableFrom(meta.getClass())) {
if (((AbstractMeta) meta).hasMissingPlugins()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
mb.open();
return false;
}
}
if (meta != null) {
if (meta.canSave()) {
return saveFileAs(meta);
}
}
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
closeRepository();
} else {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
}
}
return false;
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method saveFile.
public boolean saveFile() {
try {
EngineMetaInterface meta = getActiveMeta();
if (meta != null) {
if (AbstractMeta.class.isAssignableFrom(meta.getClass()) && ((AbstractMeta) meta).hasMissingPlugins()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
mb.open();
return false;
}
if (meta != null) {
return saveToFile(meta);
}
}
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
closeRepository();
} else {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
}
}
return false;
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method markTabsChanged.
private void markTabsChanged(boolean force) {
for (TabMapEntry entry : delegates.tabs.getTabs()) {
if (entry.getTabItem().isDisposed()) {
continue;
}
boolean changed = force || entry.getObject().hasContentChanged();
if (changed) {
// Call extension point to alert plugins that a transformation or job has changed
Object tabObject = entry.getObject().getManagedObject();
String changedId = null;
if (tabObject instanceof TransMeta) {
changedId = KettleExtensionPoint.TransChanged.id;
} else if (tabObject instanceof JobMeta) {
changedId = KettleExtensionPoint.JobChanged.id;
} else {
changed = false;
}
if (changedId != null) {
try {
if (force) {
((AbstractMeta) tabObject).setChanged();
}
ExtensionPointHandler.callExtensionPoint(log, changedId, tabObject);
} catch (KettleException e) {
// fails gracefully
}
}
}
entry.getTabItem().setChanged(changed);
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method clearRepositoryDirectory.
/**
* PDI-18997 - clear specific repository directory when connect and or disconnect from server
*/
public void clearRepositoryDirectory() {
for (TabMapEntry entry : delegates.tabs.getTabs()) {
Object managedObject = entry.getObject().getManagedObject();
if (managedObject instanceof AbstractMeta) {
AbstractMeta abstractMeta = (AbstractMeta) managedObject;
abstractMeta.setRepositoryDirectory(new RepositoryDirectory());
abstractMeta.setFilename(null);
}
}
}
Aggregations