1 30 package com.genimen.djeneric.tools.modeler.dialogs; 31 32 import java.awt.BorderLayout ; 33 import java.awt.Dimension ; 34 import java.awt.FlowLayout ; 35 import java.awt.Frame ; 36 import java.awt.Toolkit ; 37 import java.awt.event.ActionEvent ; 38 39 import javax.swing.DefaultComboBoxModel ; 40 import javax.swing.JButton ; 41 import javax.swing.JComboBox ; 42 import javax.swing.JDialog ; 43 import javax.swing.JLabel ; 44 import javax.swing.JPanel ; 45 46 import com.genimen.djeneric.language.Messages; 47 import com.genimen.djeneric.util.DjLogger; 48 49 public class ImportModeDialog extends JDialog 50 { 51 private static final long serialVersionUID = 1L; 52 public static final int REPLACE_ALL = 0; 54 public static final int MERGE_SKIP = 1; 55 public static final int MERGE_OVERWRITE = 2; 56 57 JPanel panel1 = new JPanel (); 58 BorderLayout borderLayout1 = new BorderLayout (); 59 JPanel jPanel1 = new JPanel (); 60 JPanel jPanel2 = new JPanel (); 61 BorderLayout borderLayout2 = new BorderLayout (); 62 JPanel jPanel3 = new JPanel (); 63 JButton _butOk = new JButton (); 64 JButton _butCancel = new JButton (); 65 FlowLayout flowLayout1 = new FlowLayout (); 66 JLabel _lblMode = new JLabel (); 67 JComboBox _cbbMode = new JComboBox (); 68 boolean _canceled = true; 69 70 public ImportModeDialog(Frame frame) 71 { 72 super(frame, Messages.getString("ImportModeDialog.Title"), true); 73 try 74 { 75 jbInit(); 76 _cbbMode.setModel(new DefaultComboBoxModel (new String []{Messages.getString("ImportModeDialog.ReplaceAll"), 77 Messages.getString("ImportModeDialog.MergeSkip"), Messages.getString("ImportModeDialog.MergeOverwrite")})); 78 pack(); 79 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 80 Dimension frameSize = getSize(); 81 setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); 82 83 setVisible(true); 84 } 85 catch (Exception ex) 86 { 87 DjLogger.log(ex); 88 } 89 } 90 91 public boolean wasCanceled() 92 { 93 return _canceled; 94 } 95 96 public int getMode() 97 { 98 return _cbbMode.getSelectedIndex(); 99 } 100 101 private void jbInit() throws Exception 102 { 103 panel1.setLayout(borderLayout1); 104 jPanel1.setLayout(borderLayout2); 105 _butOk.setText(Messages.getString("global.Ok")); 106 _butOk.addActionListener(new ImportModeDialog__butOk_actionAdapter(this)); _butCancel.setText(Messages.getString("global.Cancel")); 108 _butCancel.addActionListener(new ImportModeDialog__butCancel_actionAdapter(this)); jPanel2.setLayout(flowLayout1); 110 _lblMode.setText(Messages.getString("ImportModeDialog.Mode")); flowLayout1.setAlignment(FlowLayout.LEFT); 112 getContentPane().add(panel1); 113 panel1.add(jPanel1, BorderLayout.SOUTH); 114 jPanel1.add(jPanel3, BorderLayout.EAST); 115 jPanel3.add(_butCancel, null); 116 jPanel3.add(_butOk, null); 117 panel1.add(jPanel2, BorderLayout.CENTER); 118 jPanel2.add(_lblMode, null); 119 jPanel2.add(_cbbMode, null); 120 } 121 122 void _butCancel_actionPerformed(ActionEvent e) 123 { 124 setVisible(false); 125 } 126 127 void _butOk_actionPerformed(ActionEvent e) 128 { 129 _canceled = false; 130 setVisible(false); 131 } 132 } 133 134 class ImportModeDialog__butCancel_actionAdapter implements java.awt.event.ActionListener 135 { 136 ImportModeDialog adaptee; 137 138 ImportModeDialog__butCancel_actionAdapter(ImportModeDialog adaptee) 139 { 140 this.adaptee = adaptee; 141 } 142 143 public void actionPerformed(ActionEvent e) 144 { 145 adaptee._butCancel_actionPerformed(e); 146 } 147 } 148 149 class ImportModeDialog__butOk_actionAdapter implements java.awt.event.ActionListener 150 { 151 ImportModeDialog adaptee; 152 153 ImportModeDialog__butOk_actionAdapter(ImportModeDialog adaptee) 154 { 155 this.adaptee = adaptee; 156 } 157 158 public void actionPerformed(ActionEvent e) 159 { 160 adaptee._butOk_actionPerformed(e); 161 } 162 } | Popular Tags |