use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class AnalyticQueryDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
int sizegroup = wGroup.nrNonEmpty();
int nrfields = wAgg.nrNonEmpty();
input.allocate(sizegroup, nrfields);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < sizegroup; i++) {
TableItem item = wGroup.getNonEmpty(i);
input.getGroupField()[i] = item.getText(1);
}
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrfields; i++) {
TableItem item = wAgg.getNonEmpty(i);
input.getAggregateField()[i] = item.getText(1);
input.getSubjectField()[i] = item.getText(2);
input.getAggregateType()[i] = AnalyticQueryMeta.getType(item.getText(3));
input.getValueField()[i] = Const.toInt(item.getText(4), 1);
}
stepname = wStepname.getText();
if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "AnalyticQueryDialog.GroupByWarningDialog.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 JobGraph method handleJobMetaChanges.
public void handleJobMetaChanges(JobMeta jobMeta) throws KettleException {
if (jobMeta.hasChanged()) {
if (spoon.props.getAutoSave()) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "JobLog.Log.AutoSaveFileBeforeRunning"));
}
spoon.saveToFile(jobMeta);
} else {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "JobLog.Dialog.SaveChangedFile.Title"), null, BaseMessages.getString(PKG, "JobLog.Dialog.SaveChangedFile.Message") + Const.CR + BaseMessages.getString(PKG, "JobLog.Dialog.SaveChangedFile.Message2") + Const.CR, MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 0, BaseMessages.getString(PKG, "JobLog.Dialog.SaveChangedFile.Toggle"), spoon.props.getAutoSave());
int answer = md.open();
if ((answer & 0xFF) == 0) {
spoon.saveToFile(jobMeta);
}
spoon.props.setAutoSave(md.getToggleState());
}
}
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class JobGraph method mouseUp.
public void mouseUp(MouseEvent e) {
boolean control = (e.stateMask & SWT.MOD1) != 0;
if (iconoffset == null) {
iconoffset = new Point(0, 0);
}
Point real = screen2real(e.x, e.y);
Point icon = new Point(real.x - iconoffset.x, real.y - iconoffset.y);
//
if (hop_candidate != null) {
addCandidateAsHop();
redraw();
} else {
//
if (selectionRegion != null) {
selectionRegion.width = real.x - selectionRegion.x;
selectionRegion.height = real.y - selectionRegion.y;
jobMeta.unselectAll();
selectInRect(jobMeta, selectionRegion);
selectionRegion = null;
stopEntryMouseOverDelayTimers();
redraw();
} else {
//
if (selectedEntry != null && startHopEntry == null) {
if (e.button == 1) {
Point realclick = screen2real(e.x, e.y);
if (lastclick.x == realclick.x && lastclick.y == realclick.y) {
// Flip selection when control is pressed!
if (control) {
selectedEntry.flipSelected();
} else {
// Otherwise, select only the icon clicked on!
jobMeta.unselectAll();
selectedEntry.setSelected(true);
}
} else {
// Find out which Steps & Notes are selected
selectedEntries = jobMeta.getSelectedEntries();
selectedNotes = jobMeta.getSelectedNotes();
// We moved around some items: store undo info...
//
boolean also = false;
if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
int[] indexes = jobMeta.getNoteIndexes(selectedNotes);
addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, jobMeta.getSelectedNoteLocations(), also);
also = selectedEntries != null && selectedEntries.size() > 0;
}
if (selectedEntries != null && selectedEntries.size() > 0 && previous_step_locations != null) {
int[] indexes = jobMeta.getEntryIndexes(selectedEntries);
addUndoPosition(selectedEntries.toArray(new JobEntryCopy[selectedEntries.size()]), indexes, previous_step_locations, jobMeta.getSelectedLocations(), also);
}
}
}
// If so, ask to split the hop!
if (split_hop) {
JobHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedEntry);
if (hi != null) {
int id = 0;
if (!spoon.props.getAutoSplit()) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Title"), null, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Message") + Const.CR + hi.toString(), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 0, BaseMessages.getString(PKG, "TransGraph.Dialog.Option.SplitHop.DoNotAskAgain"), spoon.props.getAutoSplit());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
id = md.open();
spoon.props.setAutoSplit(md.getToggleState());
}
if ((id & 0xFF) == 0) {
//
if (jobMeta.findJobHop(selectedEntry, hi.getFromEntry()) == null && jobMeta.findJobHop(hi.getToEntry(), selectedEntry) == null) {
if (jobMeta.findJobHop(hi.getFromEntry(), selectedEntry, true) == null) {
JobHopMeta newhop1 = new JobHopMeta(hi.getFromEntry(), selectedEntry);
if (hi.getFromEntry().getEntry().isUnconditional()) {
newhop1.setUnconditional();
}
jobMeta.addJobHop(newhop1);
spoon.addUndoNew(jobMeta, new JobHopMeta[] { newhop1 }, new int[] { jobMeta.indexOfJobHop(newhop1) }, true);
}
if (jobMeta.findJobHop(selectedEntry, hi.getToEntry(), true) == null) {
JobHopMeta newhop2 = new JobHopMeta(selectedEntry, hi.getToEntry());
if (selectedEntry.getEntry().isUnconditional()) {
newhop2.setUnconditional();
}
jobMeta.addJobHop(newhop2);
spoon.addUndoNew(jobMeta, new JobHopMeta[] { newhop2 }, new int[] { jobMeta.indexOfJobHop(newhop2) }, true);
}
int idx = jobMeta.indexOfJobHop(hi);
spoon.addUndoDelete(jobMeta, new JobHopMeta[] { hi }, new int[] { idx }, true);
jobMeta.removeJobHop(idx);
spoon.refreshTree();
}
// else: Silently discard this hop-split attempt.
}
}
split_hop = false;
}
selectedEntries = null;
selectedNotes = null;
selectedEntry = null;
selectedNote = null;
startHopEntry = null;
endHopLocation = null;
redraw();
spoon.setShellText();
} else {
// Notes?
if (selectedNote != null) {
if (e.button == 1) {
if (lastclick.x == e.x && lastclick.y == e.y) {
// Flip selection when control is pressed!
if (control) {
selectedNote.flipSelected();
} else {
// Otherwise, select only the note clicked on!
jobMeta.unselectAll();
selectedNote.setSelected(true);
}
} else {
// Find out which Steps & Notes are selected
selectedEntries = jobMeta.getSelectedEntries();
selectedNotes = jobMeta.getSelectedNotes();
// We moved around some items: store undo info...
boolean also = false;
if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
int[] indexes = jobMeta.getNoteIndexes(selectedNotes);
addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, jobMeta.getSelectedNoteLocations(), also);
also = selectedEntries != null && selectedEntries.size() > 0;
}
if (selectedEntries != null && selectedEntries.size() > 0 && previous_step_locations != null) {
int[] indexes = jobMeta.getEntryIndexes(selectedEntries);
addUndoPosition(selectedEntries.toArray(new JobEntryCopy[selectedEntries.size()]), indexes, previous_step_locations, jobMeta.getSelectedLocations(), also);
}
}
}
selectedNotes = null;
selectedEntries = null;
selectedEntry = null;
selectedNote = null;
startHopEntry = null;
endHopLocation = null;
} else {
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
if (areaOwner == null && selectionRegion == null) {
// Hit absolutely nothing: clear the settings
//
clearSettings();
}
}
}
}
}
lastButton = 0;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.
the class SortedMergeDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
// return value
stepname = wStepname.getText();
int nrfields = wFields.nrNonEmpty();
input.allocate(nrfields);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrfields; i++) {
TableItem ti = wFields.getNonEmpty(i);
input.getFieldName()[i] = ti.getText(1);
input.getAscending()[i] = BaseMessages.getString(PKG, "System.Combo.Yes").equalsIgnoreCase(ti.getText(2));
}
//
if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "SortedMergeDialog.InputNeedSort.DialogTitle"), null, BaseMessages.getString(PKG, "SortedMergeDialog.InputNeedSort.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "SortedMergeDialog.InputNeedSort.Option1") }, 0, BaseMessages.getString(PKG, "SortedMergeDialog.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();
}
dispose();
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project xtext-eclipse by eclipse.
the class DontAskAgainDialogs method askUser.
/**
* Opens a {@link MessageDialogWithToggle} and stores the answer, if user activated the corresponding checkbox.
*
* @param question
* The question to ask.
* @param dialogTitle
* Title
* @param storeKey
* The key used to store the decision in {@link IDialogSettings}, also used to read the
* {@link #getUserDecision(String)}
* @param shell
* the parent {@link Shell} of the dialog
* @return User answer, one of {@link IDialogConstants#YES_ID}, {@link IDialogConstants#NO_ID} or
* {@link IDialogConstants#CANCEL_ID}
*/
public int askUser(String question, String dialogTitle, String storeKey, Shell shell) {
MessageDialogWithToggle dialogWithToggle = MessageDialogWithToggle.openYesNoCancelQuestion(shell, dialogTitle, question, null, false, null, null);
boolean rememberDecision = dialogWithToggle.getToggleState();
int userAnswer = dialogWithToggle.getReturnCode();
if (rememberDecision) {
if (userAnswer == IDialogConstants.NO_ID) {
neverAskAgain(storeKey);
} else if (userAnswer == IDialogConstants.YES_ID) {
storeUserDecision(storeKey, MessageDialogWithToggle.ALWAYS);
}
}
return userAnswer;
}
Aggregations