001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019 020/* 021 * ClientOptions.java 022 * 023 * Created on 4/Mai/2010, 13:03:33 024 */ 025package pt.ua.dicoogle.rGUI.client.windows; 026 027import java.awt.Image; 028import java.awt.Toolkit; 029import java.net.URL; 030import java.util.concurrent.Semaphore; 031import org.slf4j.Logger; 032import org.slf4j.LoggerFactory; 033import org.slf4j.Logger; 034import org.slf4j.LoggerFactory; 035import javax.swing.ImageIcon; 036import javax.swing.JFileChooser; 037import javax.swing.JOptionPane; 038import pt.ua.dicoogle.core.ClientSettings; 039import pt.ua.dicoogle.core.XMLClientSupport; 040import pt.ua.dicoogle.server.users.HashService; 041 042/** 043 * 044 * @author samuelcampos 045 */ 046@Deprecated 047public class ClientOptions extends javax.swing.JFrame { 048 private ClientSettings settings; 049 050 private static ClientOptions instance = null; 051 private static Semaphore sem = new Semaphore(1, true); 052 053 public static synchronized ClientOptions getInstance() 054 { 055 try 056 { 057 sem.acquire(); 058 if (instance == null) 059 { 060 instance = new ClientOptions(); 061 } 062 sem.release(); 063 064 } 065 catch (InterruptedException ex) 066 { 067 LoggerFactory.getLogger(ClientOptions.class).error(ex.getMessage(), ex); 068 } 069 return instance; 070 } 071 public static Image getImage(final String pathAndFileName) { 072 final URL url = Thread.currentThread().getContextClassLoader().getResource(pathAndFileName); 073 return Toolkit.getDefaultToolkit().getImage(url); 074 } 075 076 /** Creates new form ClientOptions */ 077 private ClientOptions() { 078 initComponents(); 079 080 081 Image image = Toolkit.getDefaultToolkit().getImage(Thread.currentThread().getContextClassLoader().getResource("trayicon.gif")); 082 this.setIconImage(image); 083 084 settings = ClientSettings.getInstance(); 085 086 jLabelExternalViewer.setText(settings.getExtV()); 087 Host.setText(settings.getDefaultServerHost()); 088 Port.setText(String.valueOf(settings.getDefaultServerPort())); 089 Username.setText(settings.getDefaultUserName()); 090 jLabelTempFilesDir.setText(settings.getTempFilesDir()); 091 092 if(settings.getDefaultPassword() != null && !settings.getDefaultPassword().equals("")) 093 Password.setText("lixo_lixo_lixo"); 094 095 jCheckBoxAutoConnect.setSelected(settings.getAutoConnect()); 096 } 097 098 /** This method is called from within the constructor to 099 * initialize the form. 100 * WARNING: Do NOT modify this code. The content of this method is 101 * always regenerated by the Form Editor. 102 */ 103 @SuppressWarnings("unchecked") 104 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 105 private void initComponents() { 106 107 jTabbedPane1 = new javax.swing.JTabbedPane(); 108 jPanel1 = new javax.swing.JPanel(); 109 jLabel34 = new javax.swing.JLabel(); 110 jLabelExternalViewer = new javax.swing.JLabel(); 111 jButtoViewerPath = new javax.swing.JButton(); 112 jLabel23 = new javax.swing.JLabel(); 113 jLabel3 = new javax.swing.JLabel(); 114 jLabelTempFilesDir = new javax.swing.JLabel(); 115 jLabel35 = new javax.swing.JLabel(); 116 jButtonTempDir = new javax.swing.JButton(); 117 jButtonRemoveEV = new javax.swing.JButton(); 118 jPanel2 = new javax.swing.JPanel(); 119 jLabel4 = new javax.swing.JLabel(); 120 Port = new javax.swing.JTextField(); 121 jLabel1 = new javax.swing.JLabel(); 122 Host = new javax.swing.JTextField(); 123 jLabel2 = new javax.swing.JLabel(); 124 jLabel5 = new javax.swing.JLabel(); 125 Username = new javax.swing.JTextField(); 126 jLabel6 = new javax.swing.JLabel(); 127 Password = new javax.swing.JPasswordField(); 128 jCheckBoxAutoConnect = new javax.swing.JCheckBox(); 129 jButtonWrite = new javax.swing.JButton(); 130 jButtonClose = new javax.swing.JButton(); 131 132 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 133 setTitle("Client Options"); 134 setMinimumSize(new java.awt.Dimension(453, 311)); 135 136 jTabbedPane1.setMinimumSize(new java.awt.Dimension(0, 0)); 137 138 jLabel34.setIcon(new ImageIcon(getImage("aboutico.gif"))); 139 jLabel34.addMouseListener(new java.awt.event.MouseAdapter() { 140 public void mouseClicked(java.awt.event.MouseEvent evt) { 141 jLabel34MouseClicked(evt); 142 } 143 }); 144 145 jLabelExternalViewer.setText("<External Viewer Path>"); 146 147 jButtoViewerPath.setText("Change External Viewer Path"); 148 jButtoViewerPath.addActionListener(new java.awt.event.ActionListener() { 149 public void actionPerformed(java.awt.event.ActionEvent evt) { 150 jButtoViewerPathActionPerformed(evt); 151 } 152 }); 153 154 jLabel23.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N 155 jLabel23.setText("External Viewer Path:"); 156 157 jLabel3.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N 158 jLabel3.setText("Temporary Files Directory: "); 159 160 jLabelTempFilesDir.setText("<Temporary Files Directory>"); 161 162 jLabel35.setIcon(new ImageIcon(getImage("aboutico.gif"))); 163 jLabel35.addMouseListener(new java.awt.event.MouseAdapter() { 164 public void mouseClicked(java.awt.event.MouseEvent evt) { 165 jLabel35MouseClicked(evt); 166 } 167 }); 168 169 jButtonTempDir.setText("Change External Viewer Path"); 170 jButtonTempDir.setActionCommand("Change Temporary Dir"); 171 jButtonTempDir.addActionListener(new java.awt.event.ActionListener() { 172 public void actionPerformed(java.awt.event.ActionEvent evt) { 173 jButtonTempDirActionPerformed(evt); 174 } 175 }); 176 177 jButtonRemoveEV.setText("Remove E.V."); 178 jButtonRemoveEV.addActionListener(new java.awt.event.ActionListener() { 179 public void actionPerformed(java.awt.event.ActionEvent evt) { 180 jButtonRemoveEVActionPerformed(evt); 181 } 182 }); 183 184 org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); 185 jPanel1.setLayout(jPanel1Layout); 186 jPanel1Layout.setHorizontalGroup( 187 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 188 .add(jPanel1Layout.createSequentialGroup() 189 .addContainerGap() 190 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 191 .add(jLabel23) 192 .add(jPanel1Layout.createSequentialGroup() 193 .add(jLabel34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 194 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) 195 .add(jButtoViewerPath) 196 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 197 .add(jButtonRemoveEV)) 198 .add(jLabelExternalViewer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE) 199 .add(jLabel3) 200 .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabelTempFilesDir, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE) 201 .add(jPanel1Layout.createSequentialGroup() 202 .add(jLabel35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 203 .add(18, 18, 18) 204 .add(jButtonTempDir))) 205 .addContainerGap()) 206 ); 207 jPanel1Layout.setVerticalGroup( 208 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 209 .add(jPanel1Layout.createSequentialGroup() 210 .addContainerGap() 211 .add(jLabel23) 212 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 213 .add(jLabelExternalViewer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 214 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 215 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 216 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 217 .add(jButtoViewerPath) 218 .add(jButtonRemoveEV)) 219 .add(jLabel34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 220 .add(18, 18, 18) 221 .add(jLabel3) 222 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 223 .add(jLabelTempFilesDir, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 224 .add(8, 8, 8) 225 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 226 .add(jButtonTempDir) 227 .add(jLabel35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 228 .addContainerGap(29, Short.MAX_VALUE)) 229 ); 230 231 jTabbedPane1.addTab("Directory Settings", jPanel1); 232 233 jLabel4.setText("Port:"); 234 235 Port.addFocusListener(new java.awt.event.FocusAdapter() { 236 public void focusLost(java.awt.event.FocusEvent evt) { 237 PortFocusLost(evt); 238 } 239 }); 240 241 jLabel1.setText("Host:"); 242 243 jLabel2.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N 244 jLabel2.setText("Default GUI Server:"); 245 246 jLabel5.setText("Username:"); 247 248 jLabel6.setText("Password:"); 249 250 Password.addFocusListener(new java.awt.event.FocusAdapter() { 251 public void focusGained(java.awt.event.FocusEvent evt) { 252 PasswordFocusGained(evt); 253 } 254 }); 255 256 jCheckBoxAutoConnect.setText("AutoConnect at Startup"); 257 258 org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); 259 jPanel2.setLayout(jPanel2Layout); 260 jPanel2Layout.setHorizontalGroup( 261 jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 262 .add(jPanel2Layout.createSequentialGroup() 263 .addContainerGap() 264 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 265 .add(jPanel2Layout.createSequentialGroup() 266 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 267 .add(jLabel1) 268 .add(jLabel4) 269 .add(jLabel2) 270 .add(jLabel5) 271 .add(jLabel6)) 272 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 273 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 274 .add(Password, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) 275 .add(Username, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE) 276 .add(Port, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE) 277 .add(Host, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)) 278 .add(163, 163, 163)) 279 .add(jPanel2Layout.createSequentialGroup() 280 .add(jCheckBoxAutoConnect) 281 .addContainerGap(272, Short.MAX_VALUE)))) 282 ); 283 jPanel2Layout.setVerticalGroup( 284 jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 285 .add(jPanel2Layout.createSequentialGroup() 286 .addContainerGap() 287 .add(jLabel2) 288 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) 289 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 290 .add(jLabel1) 291 .add(Host, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 292 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 293 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 294 .add(jLabel4) 295 .add(Port, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 296 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 297 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 298 .add(jLabel5) 299 .add(Username, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 300 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 301 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 302 .add(jLabel6) 303 .add(Password, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 304 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) 305 .add(jCheckBoxAutoConnect) 306 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 307 ); 308 309 jTabbedPane1.addTab("Default GUI Server", jPanel2); 310 311 jButtonWrite.setIcon(new ImageIcon(getImage("floopy-icon.png"))); 312 jButtonWrite.setText("Save Configurations"); 313 jButtonWrite.addActionListener(new java.awt.event.ActionListener() { 314 public void actionPerformed(java.awt.event.ActionEvent evt) { 315 jButtonWriteActionPerformed(evt); 316 } 317 }); 318 319 jButtonClose.setText("Close"); 320 jButtonClose.addActionListener(new java.awt.event.ActionListener() { 321 public void actionPerformed(java.awt.event.ActionEvent evt) { 322 jButtonCloseActionPerformed(evt); 323 } 324 }); 325 326 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); 327 getContentPane().setLayout(layout); 328 layout.setHorizontalGroup( 329 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 330 .add(layout.createSequentialGroup() 331 .addContainerGap() 332 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 333 .add(layout.createSequentialGroup() 334 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 335 .addContainerGap()) 336 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 337 .add(jButtonWrite) 338 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) 339 .add(jButtonClose) 340 .add(18, 18, 18)))) 341 ); 342 layout.setVerticalGroup( 343 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 344 .add(layout.createSequentialGroup() 345 .add(23, 23, 23) 346 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 347 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 348 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 349 .add(jButtonWrite) 350 .add(jButtonClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) 351 ); 352 353 pack(); 354 }// </editor-fold>//GEN-END:initComponents 355 356 private void jButtonWriteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWriteActionPerformed 357 saveSettings(); 358}//GEN-LAST:event_jButtonWriteActionPerformed 359 360 private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed 361 this.dispatchEvent(new java.awt.event.WindowEvent(this, java.awt.Event.WINDOW_DESTROY)); 362}//GEN-LAST:event_jButtonCloseActionPerformed 363 364 private void jLabel34MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel34MouseClicked 365 JOptionPane.showMessageDialog(this, "The external viewer path sets the aplication that Dicoogle Client will use to open DICOM files", "Did you know?", JOptionPane.INFORMATION_MESSAGE); 366}//GEN-LAST:event_jLabel34MouseClicked 367 368 private void jButtoViewerPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoViewerPathActionPerformed 369 JFileChooser chooser = new JFileChooser(); 370 chooser.setCurrentDirectory(new java.io.File(".")); 371 chooser.setDialogTitle("External Viewer Path"); 372 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 373 chooser.setAcceptAllFileFilterUsed(false); 374 375 if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) 376 { 377 jLabelExternalViewer.setText(chooser.getSelectedFile().toString()); 378 jLabelExternalViewer.setToolTipText(jLabelExternalViewer.getText()); 379 } 380}//GEN-LAST:event_jButtoViewerPathActionPerformed 381 382 private void PortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_PortFocusLost 383 try { 384 Integer.valueOf(Port.getText()); 385 } catch (NumberFormatException ex) { 386 JOptionPane.showMessageDialog(this, "Only numbers are accepted!", 387 "Invalid Input", JOptionPane.ERROR_MESSAGE); 388 389 Port.grabFocus(); 390 } 391 }//GEN-LAST:event_PortFocusLost 392 393 private void jLabel35MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel35MouseClicked 394 JOptionPane.showMessageDialog(this, "The temporary files directory sets the directory that Dicoogle Client will use to save temporary DICOM files", "Did you know?", JOptionPane.INFORMATION_MESSAGE); 395 }//GEN-LAST:event_jLabel35MouseClicked 396 397 private void jButtonTempDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTempDirActionPerformed 398 JFileChooser chooser = new JFileChooser(); 399 chooser.setCurrentDirectory(new java.io.File(".")); 400 chooser.setDialogTitle("Temporary Files Directory"); 401 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 402 chooser.setAcceptAllFileFilterUsed(false); 403 404 if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) 405 { 406 jLabelTempFilesDir.setText(chooser.getSelectedFile().toString()); 407 jLabelTempFilesDir.setToolTipText(jLabelTempFilesDir.getText()); 408 } 409 }//GEN-LAST:event_jButtonTempDirActionPerformed 410 411 private void PasswordFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_PasswordFocusGained 412 String pass = new String(Password.getPassword()); 413 414 if(pass.equals("lixo_lixo_lixo")) 415 Password.setText(""); 416 }//GEN-LAST:event_PasswordFocusGained 417 418 private void jButtonRemoveEVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveEVActionPerformed 419 jLabelExternalViewer.setText(""); 420 }//GEN-LAST:event_jButtonRemoveEVActionPerformed 421 422 // Variables declaration - do not modify//GEN-BEGIN:variables 423 private javax.swing.JTextField Host; 424 private javax.swing.JPasswordField Password; 425 private javax.swing.JTextField Port; 426 private javax.swing.JTextField Username; 427 private javax.swing.JButton jButtoViewerPath; 428 private javax.swing.JButton jButtonClose; 429 private javax.swing.JButton jButtonRemoveEV; 430 private javax.swing.JButton jButtonTempDir; 431 private javax.swing.JButton jButtonWrite; 432 private javax.swing.JCheckBox jCheckBoxAutoConnect; 433 private javax.swing.JLabel jLabel1; 434 private javax.swing.JLabel jLabel2; 435 private javax.swing.JLabel jLabel23; 436 private javax.swing.JLabel jLabel3; 437 private javax.swing.JLabel jLabel34; 438 private javax.swing.JLabel jLabel35; 439 private javax.swing.JLabel jLabel4; 440 private javax.swing.JLabel jLabel5; 441 private javax.swing.JLabel jLabel6; 442 private javax.swing.JLabel jLabelExternalViewer; 443 private javax.swing.JLabel jLabelTempFilesDir; 444 private javax.swing.JPanel jPanel1; 445 private javax.swing.JPanel jPanel2; 446 private javax.swing.JTabbedPane jTabbedPane1; 447 // End of variables declaration//GEN-END:variables 448 449 public boolean unsavedSettings(){ 450 if(!jLabelExternalViewer.getText().equals(settings.getExtV()) 451 || !Host.getText().equals(settings.getDefaultServerHost()) 452 || Integer.valueOf(Port.getText()) != settings.getDefaultServerPort() 453 || !Username.getText().equals(settings.getDefaultUserName()) 454 || !jLabelTempFilesDir.getText().equals(settings.getTempFilesDir()) 455 || jCheckBoxAutoConnect.isSelected() != settings.getAutoConnect()) 456 return true; 457 458 String pass = new String(Password.getPassword()); 459 460 if(!pass.equals("lixo_lixo_lixo") && !HashService.getSHA1Hash(pass).equals(settings.getDefaultPassword())) 461 return true; 462 463 return false; 464 } 465 466 public void saveSettings(){ 467 // save settings to ClientSettings 468 settings.setExtV(jLabelExternalViewer.getText()); 469 settings.setDefaultServerHost(Host.getText()); 470 settings.setDefaultServerPort(Integer.valueOf(Port.getText())); 471 settings.setDefaultUserName(Username.getText()); 472 settings.setTempFilesDir(jLabelTempFilesDir.getText()); 473 474 String pass = new String(Password.getPassword()); 475 476 if(!pass.equals("lixo_lixo_lixo")) 477 settings.setDefaultPassword(HashService.getSHA1Hash(pass)); 478 479 settings.setAutoConnect(jCheckBoxAutoConnect.isSelected()); 480 481 // save settings to xml 482 XMLClientSupport xmlClient = new XMLClientSupport(); 483 xmlClient.printXML(); 484 } 485}