1 6 7 package com.memoire.vainstall.xui; 8 9 import java.io.*; 10 import java.awt.*; 11 import java.awt.event.*; 12 import javax.swing.*; 13 import javax.swing.filechooser.*; 14 import javax.swing.border.*; 15 import com.memoire.vainstall.VALicenseKeyStep; 16 import com.memoire.vainstall.VAGlobals; 17 import com.memoire.vainstall.AbstractInstall; 18 import com.memoire.vainstall.LicenseKeySupport; 19 23 24 public class XuiLicenseKeyPanel 25 extends XuiAbstractPanel 26 implements VALicenseKeyStep 27 { 28 JPanel pnFields; 29 JButton btBrowse_; 30 JLabel lbLabels[] = new JLabel[0]; 31 JTextField tfFields[] = new JTextField[0]; 32 JTextField tfUri; 33 JPanel pnRegPage; 34 35 public XuiLicenseKeyPanel() 36 { 37 super(); 38 39 setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); 40 41 42 JPanel pnMain=new XuiPanel(); 43 pnMain.setLayout(new BorderLayout()); 44 pnMain.setBorder(new EmptyBorder(5,5,5,5)); 45 pnMain.setForeground(new Color(128,255,255)); 46 47 JPanel pnHaut=new XuiPanel(); 48 pnHaut.setLayout(new BorderLayout(0,0)); 49 pnHaut.setBorder(new CompoundBorder 50 (new LineBorder(Color.black,2), 51 new CompoundBorder(new EmptyBorder(5,5,5,5), 52 new LineBorder(Color.black,2)))); 53 54 56 XuiLabel lbTitle=new XuiLabel("Enter License Information"); 57 lbTitle.setFont(new Font("SansSerif",Font.PLAIN,16)); 58 lbTitle.setOpaque(true); 59 lbTitle.setBorder(new EmptyBorder(new Insets(5, 0, 5, 0))); 60 lbTitle.setBackground(pnMain.getBackground().darker()); 61 lbTitle.setForeground(Color.white); 62 pnHaut.add(BorderLayout.NORTH, lbTitle); 63 pnFields = new JPanel(); 64 pnFields.setLayout(new GridBagLayout()); 65 pnHaut.add(BorderLayout.CENTER, pnFields); 66 67 pnMain.add(pnHaut); 68 69 JPanel q=new JPanel(); 70 q.setOpaque(false); 71 q.setBorder(null); 72 q.setLayout(new BorderLayout()); 73 q.add(lbTitle ,BorderLayout.NORTH); 74 q.add(pnHaut,BorderLayout.CENTER); 75 76 pnMain.add(q,BorderLayout.NORTH); 77 78 JPanel pnImage=XuiImagePanel.IMAGE_PANEL; 79 add(pnImage,BorderLayout.WEST); 80 add(pnMain,BorderLayout.CENTER); 81 } 82 83 public void setLicenseKeySupport(LicenseKeySupport lks) 84 { 85 final LicenseKeySupport.FieldInfo fis[] = lks.getFieldInfo(); 86 final String uri = lks.getRegistrationPage(); 87 88 if(uri != null) { 89 pnRegPage = new JPanel(); 91 pnRegPage.setLayout(new GridBagLayout()); 92 XuiLabel lbReg = new XuiLabel("Product Registraion Page"); 93 pnRegPage.add(lbReg, 94 new GridBagConstraints(0,0,2,1, 95 1.0,0.0, 96 GridBagConstraints.CENTER, 97 GridBagConstraints.HORIZONTAL, 98 new Insets(1,1,1,1),0,0)); 99 tfUri = new JTextField(); 100 tfUri.setText(uri); 101 tfUri.setEditable(false); 102 pnRegPage.add(tfUri, 103 new GridBagConstraints(0,1,1,1, 104 1.0,0.0, 105 GridBagConstraints.CENTER, 106 GridBagConstraints.HORIZONTAL, 107 new Insets(1,1,1,1),0,0)); 108 if(AbstractInstall.IS_WIN){ 109 XuiButton bt = new XuiButton("View ..."); 110 pnRegPage.add(bt, 111 new GridBagConstraints(1,1,1,1, 112 0.0,0.0, 113 GridBagConstraints.CENTER, 114 GridBagConstraints.NONE, 115 new Insets(1,1,1,1),0,0)); 116 bt.addActionListener(new ActionListener(){ 117 public void actionPerformed(ActionEvent evt){ 118 try { 119 String os = System.getProperty("os.name"); 120 if(os.startsWith("Windows 2000") || 121 os.startsWith("Windows NT")) { 122 Runtime.getRuntime().exec(new String []{"cmd.exe", "/C", "\"start "+uri+"\""}); 124 } else { 125 Runtime.getRuntime().exec(new String []{"command.com", "/C", "\"start "+uri+"\""}); 127 } 128 } catch (RuntimeException ex) { 129 throw ex; 130 } catch (Exception ex) { 131 throw new RuntimeException (ex.toString()); 132 } 133 } 134 }); 135 } 136 pnFields.add(pnRegPage, 137 new GridBagConstraints(0,0,2,1, 138 0.1,0.0, 139 GridBagConstraints.CENTER, 140 GridBagConstraints.HORIZONTAL, 141 new Insets(2,2,2,2),0,0)); 142 } 143 tfFields = new JTextField[fis.length]; 144 lbLabels = new JLabel[fis.length]; 145 for(int i=0; i<fis.length; i++) { 146 lbLabels[i] = new XuiLabel(fis[i].name+":"); 147 pnFields.add(lbLabels[i], 148 new GridBagConstraints(0,i+1,1,1, 149 0.0,0.0, 150 GridBagConstraints.WEST, 151 GridBagConstraints.NONE, 152 new Insets(2,2,2,2),0,0)); 153 tfFields[i] = new JTextField(); 154 tfFields[i].setColumns(fis[i].size); 155 tfFields[i].setText(fis[i].text); 156 pnFields.add(tfFields[i], 157 new GridBagConstraints(1,i+1,1,1, 158 0.0,0.0, 159 GridBagConstraints.WEST, 160 GridBagConstraints.NONE, 161 new Insets(2,2,2,2),0,0)); 162 } 163 pnFields.invalidate(); 164 validate(); 165 } 166 167 public boolean getGetFields(LicenseKeySupport lks) 168 { 169 String rc[] = new String [tfFields.length]; 170 for(int i=0; i<tfFields.length; i++) { 171 rc[i]=tfFields[i].getText().trim(); 172 } 173 lks.setFieldValues(rc); 174 if( ! lks.isLicenseKeyValid() ) { 175 180 return false; 181 } 182 return true; 183 } 184 185 } 186 | Popular Tags |