- Timestamp:
- 2017-08-14T22:23:04+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r31861 r31880 56 56 extends ModalDialog 57 57 { 58 static final public String HTTP = "HTTP"; 59 static final public String HTTPS = "HTTPS"; 60 static final public String FTP = "FTP"; 61 58 62 static final public String CONNECTION_PREFS = "connection"; 59 63 static final public String GENERAL_PREFS = "general"; … … 86 90 private JRadioButton expert_mode_radio_button; 87 91 private JRadioButton librarian_mode_radio_button; 88 private JSpinner proxy_port_field; 92 private JSpinner http_proxy_port_field; 93 private JSpinner https_proxy_port_field; 94 private JSpinner ftp_proxy_port_field; 89 95 private JTabbedPane tab_pane; 90 96 private JTextArea mode_description_textarea; … … 93 99 private JTextField library_path_field; 94 100 private JTextField program_field; 95 private JTextField proxy_host_field; 101 private JTextField http_proxy_host_field; 102 private JTextField https_proxy_host_field; 103 private JTextField ftp_proxy_host_field; 96 104 private JTextField collect_dir_field; 97 105 … … 337 345 use_proxy_checkbox.setPreferredSize(ROW_SIZE); 338 346 339 JPanel proxy_host_pane = new JPanel();340 proxy_host_pane.setComponentOrientation(Dictionary.getOrientation());341 proxy_host_pane.setPreferredSize(ROW_SIZE);342 343 JLabel proxy_host_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Host"));344 proxy_host_label.setComponentOrientation(Dictionary.getOrientation());345 proxy_host_label.setPreferredSize(LABEL_SIZE);346 347 proxy_host_field = new JTextField(Configuration.getString("general.proxy_host", true));348 proxy_host_field.setEnabled(currently_enabled);349 proxy_host_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Host_Tooltip"));350 proxy_host_field.setComponentOrientation(Dictionary.getOrientation());351 352 JPanel proxy_port_pane = new JPanel();353 proxy_port_pane.setComponentOrientation(Dictionary.getOrientation());354 proxy_port_pane.setPreferredSize(ROW_SIZE);355 356 JLabel proxy_port_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Port"));357 proxy_port_label.setPreferredSize(LABEL_SIZE);358 proxy_port_label.setComponentOrientation(Dictionary.getOrientation());359 360 String port_value = Configuration.getString("general.proxy_port", true);361 if(port_value.length() > 0) {362 proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1));363 }364 else {365 proxy_port_field = new JSpinner(new SpinnerNumberModel(0, 0, 65535, 1));366 }367 proxy_port_field.setEnabled(currently_enabled);368 proxy_port_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Port_Tooltip"));369 347 370 348 // Connection … … 405 383 collect_dir_pane.add(chdir_button, BorderLayout.LINE_END); 406 384 407 proxy_host_pane.setLayout(new BorderLayout());408 proxy_host_pane.add(proxy_host_label, BorderLayout.LINE_START);409 proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER);410 411 proxy_port_pane.setLayout(new BorderLayout());412 proxy_port_pane.add(proxy_port_label, BorderLayout.LINE_START);413 proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER);414 385 415 386 connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 416 connection_pane.setLayout(new GridLayout( 9,1,0,2));387 connection_pane.setLayout(new GridLayout(10,1,0,2)); 417 388 connection_pane.add(program_pane); 418 389 connection_pane.add(library_path_pane); … … 428 399 connection_pane.add(no_check_certificate_checkbox); 429 400 connection_pane.add(use_proxy_checkbox); 430 connection_pane.add(proxy_host_pane); 431 connection_pane.add(proxy_port_pane); 401 402 // set up the proxy host and port fields for each of http, https and ftp 403 setupProxyHostPane(HTTP, connection_pane, currently_enabled, http_proxy_host_field, http_proxy_port_field); 404 setupProxyHostPane(HTTPS, connection_pane, currently_enabled, https_proxy_host_field, https_proxy_port_field); 405 setupProxyHostPane(FTP, connection_pane, currently_enabled, ftp_proxy_host_field, ftp_proxy_port_field); 432 406 433 407 return connection_pane; … … 570 544 return general_pane; 571 545 } 546 547 private void setupProxyHostPane(String protocol, JPanel connection_pane, boolean isEnabled, 548 JTextField proxy_host_field, JSpinner proxy_port_field) 549 { 550 final Dimension WIDER_LABEL_SIZE = new Dimension(180, 25); 551 final Dimension NARROWER_LABEL_SIZE = new Dimension(60, 25); 552 final Dimension WIDER_ROW_SIZE = new Dimension(480, 25); 553 final Dimension NARROWER_ROW_SIZE = new Dimension(120, 25); 554 555 JPanel proxy_host_pane = new JPanel(); 556 proxy_host_pane.setComponentOrientation(Dictionary.getOrientation()); 557 proxy_host_pane.setPreferredSize(WIDER_ROW_SIZE); 558 559 JLabel proxy_host_label = new JLabel(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Host")); 560 proxy_host_label.setComponentOrientation(Dictionary.getOrientation()); 561 proxy_host_label.setPreferredSize(WIDER_LABEL_SIZE); 562 563 proxy_host_field = new JTextField(Configuration.getString("general."+protocol+"_proxy_host", true)); 564 proxy_host_field.setEnabled(isEnabled); 565 proxy_host_field.setToolTipText(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Host_Tooltip")); 566 proxy_host_field.setComponentOrientation(Dictionary.getOrientation()); 567 568 JPanel proxy_port_pane = new JPanel(); 569 proxy_port_pane.setComponentOrientation(Dictionary.getOrientation()); 570 proxy_port_pane.setPreferredSize(NARROWER_ROW_SIZE); 571 572 JLabel proxy_port_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Port")); 573 proxy_port_label.setPreferredSize(NARROWER_LABEL_SIZE); 574 proxy_port_label.setComponentOrientation(Dictionary.getOrientation()); 575 576 String port_value = Configuration.getString("general."+protocol+"_proxy_port", true); 577 if(port_value.length() > 0) { 578 proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1)); 579 } 580 else { 581 proxy_port_field = new JSpinner(new SpinnerNumberModel(0, 0, 65535, 1)); 582 } 583 proxy_port_field.setEnabled(isEnabled); 584 proxy_port_field.setToolTipText(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Port_Tooltip")); 585 586 587 // Since the actual object member vars were null when this method is called 588 // need to ensure they are assigned the correct value now, else those refs will remain null 589 if(protocol.equals(HTTP)) { 590 http_proxy_host_field = proxy_host_field; 591 http_proxy_port_field = proxy_port_field; 592 } else if (protocol.equals(HTTPS)) { 593 https_proxy_host_field = proxy_host_field; 594 https_proxy_port_field = proxy_port_field; 595 } else if(protocol.equals(FTP)) { 596 ftp_proxy_host_field = proxy_host_field; 597 ftp_proxy_port_field = proxy_port_field; 598 } 599 600 proxy_host_pane.setLayout(new BorderLayout()); 601 proxy_host_pane.add(proxy_host_label, BorderLayout.LINE_START); 602 proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER); 603 604 proxy_port_pane.setLayout(new BorderLayout()); 605 proxy_port_pane.add(proxy_port_label, BorderLayout.LINE_START); 606 proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER); 607 608 //connection_pane.add(proxy_host_pane); 609 //connection_pane.add(proxy_port_pane); 610 611 JPanel proxy_panel = new JPanel(); 612 proxy_panel.setLayout(new BorderLayout()); 613 proxy_panel.add(proxy_host_pane, BorderLayout.WEST); 614 proxy_panel.add(proxy_port_pane, BorderLayout.CENTER); 615 616 connection_pane.add(proxy_panel); 617 } 618 572 619 573 620 /** Generate the controls for altering the detail mode. … … 786 833 this.close = close; 787 834 } 835 836 private void setProxyHostForProtocol(String protocol, 837 JTextField proxy_host_field, 838 JSpinner proxy_port_field) 839 { 840 Configuration.setString("general."+protocol+"_proxy_host", true, proxy_host_field.getText()); 841 Configuration.setString("general."+protocol+"_proxy_port", true, proxy_port_field.getValue() + ""); 842 } 843 788 844 public void actionPerformed(ActionEvent event) 789 845 { … … 876 932 877 933 Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 878 Configuration.setString("general.proxy_host", true, proxy_host_field.getText()); 879 Configuration.setString("general.proxy_port", true, proxy_port_field.getValue() + ""); 934 setProxyHostForProtocol(HTTP, http_proxy_host_field, http_proxy_port_field); 935 setProxyHostForProtocol(HTTPS, https_proxy_host_field, https_proxy_port_field); 936 setProxyHostForProtocol(FTP, ftp_proxy_host_field, ftp_proxy_port_field); 880 937 Gatherer.setProxy(); 881 938 … … 975 1032 976 1033 // If proxy is on but proxy details are incomplete, then can't continue 977 if (use_proxy_checkbox.isSelected() && proxy_host_field.getText().equals("")) { 1034 if (use_proxy_checkbox.isSelected() 1035 && http_proxy_host_field.getText().equals("") 1036 && https_proxy_host_field.getText().equals("") 1037 && ftp_proxy_host_field.getText().equals("")) { 978 1038 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.Connection.Proxy_Host_Missing"), 979 1039 Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); … … 1144 1204 Configuration.set("general.use_proxy", true, enabled); 1145 1205 // Fortunately this is already driven by the event thread. 1146 proxy_host_field.setEnabled(enabled); 1147 proxy_port_field.setEnabled(enabled); 1206 http_proxy_host_field.setEnabled(enabled); 1207 http_proxy_port_field.setEnabled(enabled); 1208 https_proxy_host_field.setEnabled(enabled); 1209 https_proxy_port_field.setEnabled(enabled); 1210 ftp_proxy_host_field.setEnabled(enabled); 1211 ftp_proxy_port_field.setEnabled(enabled); 1148 1212 } 1149 1213 }
Note:
See TracChangeset
for help on using the changeset viewer.