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.contents;
017
018import com.smartgwt.client.widgets.form.fields.CheckboxItem;
019import org.modeshape.web.shared.ModalDialog;
020
021/**
022 * Dialog for asking mixin.
023 * 
024 * @author kulikov
025 */
026public class RefreshSessionDialog extends ModalDialog {
027
028    private final static String TITLE = "Refresh session";
029    
030    private CheckboxItem keepChanges = new CheckboxItem();
031    private Contents contents;
032    
033    public RefreshSessionDialog(Contents contents) {
034        super(TITLE, 450, 150);
035        this.contents = contents;
036        
037        keepChanges.setName("name");
038        keepChanges.setTitle("Discard changes");
039        keepChanges.setDefaultValue("");
040        keepChanges.setWidth(250);
041        keepChanges.setRequired(true);
042        keepChanges.setVisible(true);
043        keepChanges.setStartRow(true);
044        keepChanges.setEndRow(true);
045
046        setControls(keepChanges);
047        keepChanges.focusInItem();
048    }
049
050    @Override
051    public void onConfirm(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
052        contents.refreshSession(!keepChanges.getValueAsBoolean());
053    }
054}