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.RadioGroupItem; 019import com.smartgwt.client.widgets.form.fields.StaticTextItem; 020import com.smartgwt.client.widgets.form.fields.TextItem; 021import com.smartgwt.client.widgets.form.fields.events.ClickEvent; 022import javax.jcr.ImportUUIDBehavior; 023import org.modeshape.web.shared.ModalDialog; 024 025/** 026 * Dialog asking backup directory. 027 * 028 * @author kulikov 029 */ 030public class ImportDialog extends ModalDialog { 031 032 private TextItem name = new TextItem("Import from"); 033 private Contents contents; 034 private RadioGroupItem radioGroupItem = new RadioGroupItem(); 035 036 public ImportDialog(Contents contents) { 037 super("Import", 400, 300); 038 this.contents = contents; 039 040 StaticTextItem description = new StaticTextItem(""); 041 description.setValue("Specify name"); 042 043 044 radioGroupItem.setTitle("Options"); 045 radioGroupItem.setValueMap("Create new", "Remove existing", 046 "Replace existing", "Collision throw"); 047 radioGroupItem.setWidth(150); 048 setControls(description, name, radioGroupItem); 049 } 050 051 @Override 052 public void onConfirm(ClickEvent event) { 053 String selection = radioGroupItem.getValueAsString(); 054 int option = 0; 055 if (selection.equals("Create new")) { 056 option = ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW; 057 } else if (selection.equals("Remove existing")) { 058 option = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING; 059 } else if (selection.equals("Replace existing")) { 060 option = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING; 061 } else if (selection.equals("Collision throw")) { 062 option = ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW; 063 } 064 065 contents.importXML(name.getValueAsString(), option); 066 } 067 068}