Search in sources :

Example 1 with ICsvExportParameter

use of org.jowidgets.cap.ui.api.table.ICsvExportParameter in project jo-client-platform by jo-source.

the class CsvExportParameterContentProvider method setValue.

@Override
public void setValue(ICsvExportParameter parameter) {
    if (parameter == null) {
        if (this.parameter != null) {
            parameter = this.parameter;
        } else {
            parameter = new CsvExportParameter();
        }
    }
    this.parameter = parameter;
    headerCmb.setValue(parameter.isExportHeader());
    propertiesCmb.setValue(parameter.isExportInvisibleProperties());
    exportTypeCmb.setValue(parameter.getExportType());
    separatorCmb.setValue(String.valueOf(parameter.getSeparator()));
    maskCmb.setValue(String.valueOf(parameter.getMask()));
    encodingCmb.setValue(parameter.getEncoding());
}
Also used : ICsvExportParameter(org.jowidgets.cap.ui.api.table.ICsvExportParameter)

Example 2 with ICsvExportParameter

use of org.jowidgets.cap.ui.api.table.ICsvExportParameter 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();
    }
}
Also used : IQuestionDialogBluePrint(org.jowidgets.api.widgets.blueprint.IQuestionDialogBluePrint) DialogResult(org.jowidgets.common.types.DialogResult) Some(org.jowidgets.util.maybe.Some) ICsvExportParameter(org.jowidgets.cap.ui.api.table.ICsvExportParameter) IFileChooserBluePrint(org.jowidgets.api.widgets.blueprint.IFileChooserBluePrint) IFileChooser(org.jowidgets.api.widgets.IFileChooser) File(java.io.File) IQuestionDialog(org.jowidgets.api.widgets.IQuestionDialog)

Aggregations

ICsvExportParameter (org.jowidgets.cap.ui.api.table.ICsvExportParameter)2 File (java.io.File)1 IFileChooser (org.jowidgets.api.widgets.IFileChooser)1 IQuestionDialog (org.jowidgets.api.widgets.IQuestionDialog)1 IFileChooserBluePrint (org.jowidgets.api.widgets.blueprint.IFileChooserBluePrint)1 IQuestionDialogBluePrint (org.jowidgets.api.widgets.blueprint.IQuestionDialogBluePrint)1 DialogResult (org.jowidgets.common.types.DialogResult)1 Some (org.jowidgets.util.maybe.Some)1