001/*
002 * ModeShape (http://www.modeshape.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *       http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.modeshape.web.client.admin;
017
018import com.smartgwt.client.widgets.form.fields.CheckboxItem;
019import com.smartgwt.client.widgets.form.fields.TextItem;
020import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
021import org.modeshape.web.shared.BackupParams;
022import org.modeshape.web.shared.ModalDialog;
023
024/**
025 * Dialog asking backup directory.
026 * 
027 * @author kulikov
028 */
029public class BackupOptionsDialog extends ModalDialog {
030    
031    private final CheckboxItem incBinariesField = new CheckboxItem("Include binaries");
032    private final CheckboxItem compressField = new CheckboxItem("Compress files");
033    private final TextItem docsPerFileField = new TextItem("Documents per file");
034    private final BackupDownloadControl control;
035    
036    public BackupOptionsDialog(BackupDownloadControl control) {
037        super("Backup", 400, 200);
038        this.control = control;
039        
040        setDefaults();        
041        setControls(incBinariesField, compressField, docsPerFileField);
042    }
043    
044    private void setDefaults() {
045        incBinariesField.setValue(true);
046        compressField.setValue(true);
047        docsPerFileField.setValue("10000");
048    }
049    
050    @Override
051    public void onConfirm(ClickEvent event) {
052        //prepare clean options
053        BackupParams params = new BackupParams();
054        
055        params.setIncludeBinaries(incBinariesField.getValueAsBoolean());
056        params.setCompress(compressField.getValueAsBoolean());
057        params.setDocumentsPerFile(Long.valueOf(docsPerFileField.getValueAsString()));
058        
059        control.backupAndDownload(params);
060    }
061 
062    
063}