use of org.eclipse.jface.dialogs.MessageDialogWithToggle 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, 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;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class Spoon method verifyCopyDistribute.
public void verifyCopyDistribute(TransMeta transMeta, StepMeta fr) {
List<StepMeta> nextSteps = transMeta.findNextSteps(fr);
int nrNextSteps = nextSteps.size();
// message
if (nrNextSteps == 2) {
boolean distributes = fr.getStepMetaInterface().excludeFromCopyDistributeVerification();
boolean customDistribution = false;
if (props.showCopyOrDistributeWarning() && !fr.getStepMetaInterface().excludeFromCopyDistributeVerification()) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "System.Warning"), null, BaseMessages.getString(PKG, "Spoon.Dialog.CopyOrDistribute.Message", fr.getName(), Integer.toString(nrNextSteps)), MessageDialog.WARNING, getRowDistributionLabels(), 0, BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowWarning"), !props.showCopyOrDistributeWarning());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
int idx = md.open();
props.setShowCopyOrDistributeWarning(!md.getToggleState());
props.saveProps();
distributes = idx == Spoon.MESSAGE_DIALOG_WITH_TOGGLE_YES_BUTTON_ID;
customDistribution = idx == Spoon.MESSAGE_DIALOG_WITH_TOGGLE_CUSTOM_DISTRIBUTION_BUTTON_ID;
}
if (distributes) {
fr.setDistributes(true);
fr.setRowDistribution(null);
} else if (customDistribution) {
RowDistributionInterface rowDistribution = getActiveTransGraph().askUserForCustomDistributionMethod();
fr.setDistributes(true);
fr.setRowDistribution(rowDistribution);
} else {
fr.setDistributes(false);
fr.setDistributes(false);
}
refreshTree();
refreshGraph();
}
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class MergeRowsDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
List<StreamInterface> infoStreams = input.getStepIOMeta().getInfoStreams();
infoStreams.get(0).setStepMeta(transMeta.findStep(wReference.getText()));
infoStreams.get(1).setStepMeta(transMeta.findStep(wCompare.getText()));
input.setFlagField(wFlagfield.getText());
int nrKeys = wKeys.nrNonEmpty();
int nrValues = wValues.nrNonEmpty();
input.allocate(nrKeys, nrValues);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrKeys; i++) {
TableItem item = wKeys.getNonEmpty(i);
input.getKeyFields()[i] = item.getText(1);
}
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrValues; i++) {
TableItem item = wValues.getNonEmpty(i);
input.getValueFields()[i] = item.getText(1);
}
// return value
stepname = wStepname.getText();
// PDI-13509 Fix
if (nrKeys > 0 && "Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
md.open();
props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
props.saveProps();
}
dispose();
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class MultiMergeJoinDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
getMeta(joinMeta);
// Show a warning (optional)
if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle"), null, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option1") }, 0, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
md.open();
props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
props.saveProps();
}
// return value
stepname = wStepname.getText();
dispose();
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class PaloCellInputDialog method showPaloLibWarningDialog.
public static void showPaloLibWarningDialog(Shell shell) {
PropsUI props = PropsUI.getInstance();
if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y"))) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y")));
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
md.open();
props.setCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
props.saveProps();
}
}
Aggregations