1 package SnowMailClient.gnupg.Views; 2 3 import SnowMailClient.gnupg.*; 4 import SnowMailClient.gnupg.Main.GnuPGCommands; 5 import SnowMailClient.Language.Language; 6 import SnowMailClient.SnowMailClientApp; 7 import snow.sortabletable.*; 8 import snow.utils.gui.*; 9 10 import SnowMailClient.model.accounts.*; 11 12 import SnowMailClient.gnupg.model.*; 13 14 import java.awt.*; 15 import java.awt.event.*; 16 import javax.swing.*; 17 import javax.swing.event.*; 18 import javax.swing.border.*; 19 import java.util.*; 20 21 public final class SetTrustDialog extends JDialog implements ItemListener 22 { 23 private final CloseControlPanel ccp; 24 private final JComboBox trustLevelCB; 25 private final KeysTableModel tableModel; 26 private final GnuPGKeyID key; 27 28 private final JTextArea actualTrustArea = new JTextArea(); 29 30 public SetTrustDialog(JDialog parent, KeysTableModel tableModel, GnuPGKeyID key) 31 { 32 super(parent, Language.translate("Set the trust level for %", key.getNames()), true); 33 34 this.tableModel = tableModel; 35 this.key = key; 36 37 getContentPane().setLayout(new BorderLayout()); 38 39 getContentPane().add(actualTrustArea, BorderLayout.NORTH); 41 actualTrustArea.setEditable(false); 42 43 actualTrustArea.setBorder(new EmptyBorder(3,5,3,5)); 44 actualTrustArea.setText(Language.translate("The actual calculated trust is")+": "+key.getCalculatedTrustMessage() 45 +"\n\n" 46 +Language.translate("Please enter your trust (ownertrust) for this key:") 47 ); 48 49 trustLevelCB = new JComboBox(new String []{ 50 Language.translate("I don't know or won't say"), Language.translate("I do NOT trust"), Language.translate("I trust marginally"), Language.translate("I trust fully"), Language.translate("I trust ultimately") }); 56 57 JPanel centerPanel = new JPanel(); 59 centerPanel.setBorder(new EmptyBorder(3,5,3,5)); 60 GridLayout3 gl = new GridLayout3(1, centerPanel); 61 centerPanel.setLayout(gl); 62 getContentPane().add(centerPanel, BorderLayout.CENTER); 63 64 actualTrustArea.setBackground(centerPanel.getBackground()); 65 66 gl.add(trustLevelCB, true); 68 trustLevelCB.addItemListener(this); 69 70 ccp = new CloseControlPanel(this, true, true, Language.translate("Update the ownertrust level")); 72 getContentPane().add(ccp, BorderLayout.SOUTH); 73 74 pack(); 76 SnowMailClientApp.centerComponentOnMainFrame(this); 77 setVisible(true); 78 79 if(!ccp.getWasCancelled()) 80 { 81 setTrustLevel(); 82 } 83 84 } 85 86 public void itemStateChanged(ItemEvent e) 87 { 88 } 89 90 private void setTrustLevel() 91 { 92 final ProgressModalDialog progress = new ProgressModalDialog(this, Language.translate("Updating the trust level"), false); 93 SnowMailClientApp.centerComponentOnMainFrame(progress); 94 95 Thread t = new Thread () 96 { 97 public void run() 98 { 99 try 100 { 101 102 GnuPGCommands.setTrust(SnowMailClientApp.getInstance().getGnuPGLink().getPathToGPG(), 103 key, 104 (Integer ) trustLevelCB.getSelectedIndex()+1, 105 progress); 106 107 EventQueue.invokeLater(new Runnable () { public void run() { 108 tableModel.refreshModel(SnowMailClientApp.getInstance().getGnuPGLink()); 109 }}); 110 } 111 catch(Exception ex) 112 { 113 JOptionPane.showMessageDialog(progress, 114 Language.translate("Error:")+"\n"+ex.getMessage(), 115 Language.translate("Cannot update the trust level"), JOptionPane.ERROR_MESSAGE); 116 ex.printStackTrace(); 117 } 118 finally 119 { 120 progress.closeDialog(); 121 } 122 } 123 }; 124 125 t.start(); 126 t.setPriority(Thread.NORM_PRIORITY-1); 127 progress.start(); 129 } 130 131 } | Popular Tags |