use of org.jowidgets.api.widgets.blueprint.IQuestionDialogBluePrint in project jo-client-platform by jo-source.
the class CsvExportFileParameterProvider method getParameter.
@Override
public IMaybe<ICsvExportParameter> getParameter(final IExecutionContext executionContext, final List<IBeanProxy<BEAN_TYPE>> beans, final ICsvExportParameter defaultParameter) throws Exception {
final IFileChooserBluePrint fileChooserBp = BPF.fileChooser(FileChooserType.SAVE).setFilterList(filterList);
final IFileChooser fileChooser = Toolkit.getActiveWindow().createChildWindow(fileChooserBp);
fileChooser.setSelectedFile(new File(filename));
final DialogResult result = fileChooser.open();
if (result == DialogResult.OK) {
for (final File file : fileChooser.getSelectedFiles()) {
filename = file.getAbsolutePath();
}
if (!filename.contains(fileChooser.getSelectedFilter().getExtensions().get(0))) {
filename = filename + "." + fileChooser.getSelectedFilter().getExtensions().get(0);
}
if (EmptyCheck.isEmpty(filename)) {
Toolkit.getMessagePane().showInfo(executionContext, Messages.getString("CsvExportFileParameterProvider.no_file_choosen"));
return Nothing.getInstance();
}
if (!checkFileType(filename.substring(filename.length() - 3))) {
Toolkit.getMessagePane().showError(executionContext, Messages.getString("CsvExportFileParameterProvider.incompatible_file"));
return Nothing.getInstance();
}
final File file = new File(filename);
if (file.exists()) {
final String question = Messages.getString("CsvExportFileParameterProvider.file_overwritten");
final IQuestionDialogBluePrint dialogBp = BPF.questionDialog();
dialogBp.setTitle(executionContext.getAction().getText());
dialogBp.setIcon(executionContext.getAction().getIcon());
dialogBp.setIcon(Icons.WARNING);
dialogBp.setText(MessageReplacer.replace(question, file.getName()));
dialogBp.setDefaultResult(QuestionResult.NO);
final IQuestionDialog dialog = Toolkit.getActiveWindow().createChildWindow(dialogBp);
if (!QuestionResult.YES.equals(dialog.question())) {
return Nothing.getInstance();
}
}
return new Some<ICsvExportParameter>(new CsvExportParameter(defaultParameter.getExportType(), defaultParameter.isExportHeader(), defaultParameter.isExportInvisibleProperties(), defaultParameter.getSeparator(), defaultParameter.getMask(), defaultParameter.getEncoding(), filename));
} else {
return Nothing.getInstance();
}
}
use of org.jowidgets.api.widgets.blueprint.IQuestionDialogBluePrint in project jo-client-platform by jo-source.
the class DataModelContextImpl method shouldDataBeSaved.
private QuestionResult shouldDataBeSaved() {
final IQuestionDialogBluePrint dialogBp = BPF.questionDialog();
dialogBp.setTitle(UNSAVED_DATA_TITLE.get());
dialogBp.setText(UNSAVED_DATA_TEXT.get());
dialogBp.setYesButton(BPF.button(UNSAVED_DATA_YES_BTN.get()));
dialogBp.setNoButton(BPF.button(UNSAVED_DATA_NO_BTN.get()));
dialogBp.setCancelButton(BPF.button(UNSAVED_DATA_CANCEL_BTN.get()));
dialogBp.setDefaultResult(QuestionResult.YES);
final IQuestionDialog dialog = Toolkit.getActiveWindow().createChildWindow(dialogBp);
return dialog.question();
}
use of org.jowidgets.api.widgets.blueprint.IQuestionDialogBluePrint in project jo-client-platform by jo-source.
the class DataModelContextImpl method shouldDataBeRefused.
private boolean shouldDataBeRefused() {
final IQuestionDialogBluePrint dialogBp = BPF.questionDialog();
dialogBp.setTitle(UNSAVED_INVALID_DATA_TITLE.get());
dialogBp.setText(UNSAVED_INVALID_DATA_TEXT.get());
dialogBp.setYesButton(BPF.button(UNSAVED_INVALID_DATA_YES_BTN.get()));
dialogBp.setNoButton(BPF.button(UNSAVED_INVALID_DATA_NO_BTN.get()));
final IQuestionDialog dialog = Toolkit.getActiveWindow().createChildWindow(dialogBp);
final QuestionResult questionResult = dialog.question();
if (QuestionResult.YES == questionResult) {
return true;
} else {
return false;
}
}
Aggregations