1 56 package org.objectstyle.cayenne.modeler.dialog.datadomain; 57 58 import java.awt.BorderLayout ; 59 import java.awt.CardLayout ; 60 import java.awt.Component ; 61 import java.awt.FlowLayout ; 62 63 import javax.swing.JPanel ; 64 65 import org.scopemvc.core.Control; 66 import org.scopemvc.view.swing.SButton; 67 import org.scopemvc.view.swing.SComboBox; 68 import org.scopemvc.view.swing.SPanel; 69 import org.scopemvc.view.swing.SwingView; 70 71 import com.jgoodies.forms.builder.DefaultFormBuilder; 72 import com.jgoodies.forms.layout.FormLayout; 73 74 77 public class CacheSyncConfigDialog extends SPanel { 78 public static final String EMPTY_CARD_KEY = "Empty"; 79 80 protected JPanel configPanel; 81 82 public CacheSyncConfigDialog() { 83 initView(); 84 } 85 86 protected void initView() { 87 setDisplayMode(SwingView.MODAL_DIALOG); 88 this.setLayout(new BorderLayout ()); 89 this.setTitle("Configure Remote Cache Synchronization"); 90 91 SComboBox type = new SComboBox(); 92 type.setSelector(CacheSyncTypesModel.NOTIFICATION_TYPES_SELECTOR); 93 type.setSelectionSelector(CacheSyncTypesModel.FACTORY_LABEL_SELECTOR); 94 95 SButton saveButton = new SButton(CacheSyncConfigController.SAVE_CONFIG_CONTROL); 96 SButton cancelButton = 97 new SButton(CacheSyncConfigController.CANCEL_CONFIG_CONTROL); 98 99 JPanel buttonPanel = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 101 buttonPanel.add(saveButton); 102 buttonPanel.add(cancelButton); 103 104 FormLayout layout = new FormLayout("right:150, 3dlu, left:200", ""); 106 DefaultFormBuilder builder = new DefaultFormBuilder(layout); 107 builder.setDefaultDialogBorder(); 108 builder.append("Notification Transport Type:", type); 109 110 configPanel = new JPanel (new CardLayout ()); 112 addCard(new JPanel (), EMPTY_CARD_KEY); 113 114 this.add(builder.getPanel(), BorderLayout.NORTH); 115 this.add(configPanel, BorderLayout.CENTER); 116 this.add(buttonPanel, BorderLayout.SOUTH); 117 118 showCard(EMPTY_CARD_KEY); 119 } 120 121 public Control getCloseControl() { 122 return new Control(CacheSyncConfigController.CANCEL_CONFIG_CONTROL); 123 } 124 125 public void addCard(Component card, String key) { 126 configPanel.add(card, key); 127 } 128 129 public void showCard(String key) { 130 ((CardLayout ) configPanel.getLayout()).show(configPanel, key); 131 } 132 } 133 | Popular Tags |