use of org.pentaho.di.ui.spoon.dialog.SaveProgressDialog in project pentaho-kettle by pentaho.
the class Spoon method saveToRepositoryConfirmed.
public boolean saveToRepositoryConfirmed(EngineMetaInterface meta) throws KettleException {
if (!Utils.isEmpty(meta.getName()) && rep != null) {
ObjectId existingId = null;
if (meta instanceof TransMeta) {
existingId = rep.getTransformationID(meta.getName(), meta.getRepositoryDirectory());
}
if (meta instanceof JobMeta) {
existingId = rep.getJobId(meta.getName(), meta.getRepositoryDirectory());
}
boolean saved = false;
if (meta.getObjectId() == null) {
meta.setObjectId(existingId);
}
try {
shell.setCursor(cursor_hourglass);
// created and or modified...
if (meta.getCreatedDate() == null) {
meta.setCreatedDate(new Date());
if (capabilities.supportsUsers()) {
meta.setCreatedUser(rep.getUserInfo().getLogin());
}
}
// Keep info on who & when this transformation was
// changed...
meta.setModifiedDate(new Date());
if (capabilities.supportsUsers()) {
meta.setModifiedUser(rep.getUserInfo().getLogin());
}
boolean versioningEnabled = true;
boolean versionCommentsEnabled = true;
String fullPath = getJobTransfFullPath(meta);
RepositorySecurityProvider repositorySecurityProvider = rep != null && rep.getSecurityProvider() != null ? rep.getSecurityProvider() : null;
if (repositorySecurityProvider != null && fullPath != null) {
versioningEnabled = repositorySecurityProvider.isVersioningEnabled(fullPath);
versionCommentsEnabled = repositorySecurityProvider.allowsVersionComments(fullPath);
}
// Finally before saving, ask for a version comment (if
// applicable)
//
String versionComment = null;
boolean versionOk;
if (!versioningEnabled || !versionCommentsEnabled) {
versionOk = true;
versionComment = "";
} else {
versionOk = false;
}
while (!versionOk) {
versionComment = RepositorySecurityUI.getVersionComment(shell, rep, meta.getName(), fullPath, false);
// if the version comment is null, the user hit cancel, exit.
if (rep != null && rep.getSecurityProvider() != null && rep.getSecurityProvider().allowsVersionComments(fullPath) && versionComment == null) {
return false;
}
if (Utils.isEmpty(versionComment) && rep.getSecurityProvider().isVersioningEnabled(fullPath) && rep.getSecurityProvider().isVersionCommentMandatory()) {
if (!RepositorySecurityUI.showVersionCommentMandatoryDialog(shell)) {
// no, I don't want to enter a
return false;
// version comment and yes,
// it's mandatory.
}
} else {
versionOk = true;
}
}
if (versionOk) {
SaveProgressDialog spd = new SaveProgressDialog(shell, rep, meta, versionComment);
if (spd.open()) {
saved = true;
if (!props.getSaveConfirmation()) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "Spoon.Message.Warning.SaveOK"), null, BaseMessages.getString(PKG, "Spoon.Message.Warning.TransformationWasStored"), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "Spoon.Message.Warning.OK") }, 0, BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowThisMessage"), props.getSaveConfirmation());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
md.open();
props.setSaveConfirmation(md.getToggleState());
}
// Handle last opened files...
props.addLastFile(meta.getFileType(), meta.getName(), meta.getRepositoryDirectory().getPath(), true, getRepositoryName(), getUsername(), null);
saveSettings();
addMenuLast();
setShellText();
}
}
} finally {
shell.setCursor(null);
}
return saved;
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
// "There is no repository connection available."
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Message"));
// "No repository available."
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Title"));
mb.open();
}
return false;
}
Aggregations