Ignore:
Timestamp:
2009-01-12T11:40:15+13:00 (15 years ago)
Author:
kjdon
Message:

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318, and fixed some conflicts. I think this is the last commit following merging the files. Haven't tried to compile yet... here goes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/WarningDialog.java

    r18297 r18364  
    4848    private JButton ok_button;
    4949    private JCheckBox show_check;
    50     private JTextField value_field;
     50    private JComponent value_field;
    5151    private JPanel value_panel;
    5252    private String affected_property;
    5353    private String full_property;
    54 
    55 
    56     public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel)
     54    /** Whether or not to display the checkbox that will turn off this dialog in future */
     55    private final boolean showcheckbox;
     56
     57
     58    public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel)
     59    {
     60    this(warning_name, warning_title, warning_message, affected_property, can_cancel, true); // true for show checkbox
     61    }
     62
     63
     64    public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel,
     65             boolean showcheckbox)
    5766    {
    5867    super(Gatherer.g_man, "Warning", true);
    5968        this.setComponentOrientation(Dictionary.getOrientation());
     69    this.showcheckbox = showcheckbox;
     70
    6071    // Determine the name of this prompt.
    6172    this.affected_property = affected_property;
     
    7687    JPanel text_pane = new JPanel();
    7788        text_pane.setComponentOrientation(Dictionary.getOrientation());
    78     JLabel icon_label = new JLabel(JarTools.getImage("gatherer_medium.gif"));
     89       
     90    String gmedium_image = "gatherer_medium.gif";
     91    if (Configuration.fedora_info.isActive()) {
     92        gmedium_image = "fli-" + gmedium_image;
     93    }
     94
     95    JLabel icon_label = new JLabel(JarTools.getImage(gmedium_image));
    7996        icon_label.setComponentOrientation(Dictionary.getOrientation());
    80        
     97
    8198    JTextArea text_area = new JTextArea();
    8299        text_area.setComponentOrientation(Dictionary.getOrientation());
     
    96113    JPanel bottom_pane = new JPanel();
    97114        bottom_pane.setComponentOrientation(Dictionary.getOrientation());
    98     show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again"));
    99         show_check.setComponentOrientation(Dictionary.getOrientation());
     115       
    100116    JPanel control_pane = new JPanel();
    101117        control_pane.setComponentOrientation(Dictionary.getOrientation());
     
    139155    bottom_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
    140156    bottom_pane.setLayout(new BorderLayout());
    141     bottom_pane.add(show_check, BorderLayout.CENTER);
    142157    bottom_pane.add(control_pane, BorderLayout.LINE_END);
     158    if(showcheckbox) {
     159        show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again"));
     160        show_check.setComponentOrientation(Dictionary.getOrientation());
     161        bottom_pane.add(show_check, BorderLayout.CENTER);
     162    }
    143163
    144164    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     
    160180
    161181    public void actionPerformed(ActionEvent event) {
    162     boolean bad_value = false;
     182    boolean valid_value = true;
    163183    if(event.getSource() == ok_button) {
    164184        if(affected_property != null && Configuration.self != null) {
    165         String value = value_field.getText();
    166         if(value.length() > 0) {
    167            if(value_field instanceof URLField) {
    168               bad_value = !((URLField)value_field).validateURL();
    169            }
    170            if(!bad_value) {
    171               // Store the value of the property
    172               Configuration.setString(affected_property, true, value_field.getText());
    173            }
     185        valid_value = URLField.validateURL(value_field);
     186        if(valid_value) {
     187            // Store the value of the property
     188            URLField.store(value_field, affected_property); //Configuration.setString(affected_property, true, value);
    174189        }
    175190        }
    176         if(!bad_value) {
     191        if(valid_value) {
    177192        result = JOptionPane.OK_OPTION;
    178193        }
    179     }
    180     if(!bad_value) {
    181         if (Configuration.self != null) {
     194    }
     195
     196    if(valid_value) {
     197        if (Configuration.self != null && showcheckbox) {
    182198        // Store the state of the show message checkbox.
    183199        Configuration.set(full_property, true, !show_check.isSelected());
     
    202218    }
    203219
    204     public void keyReleased(KeyEvent e) { }
    205 
    206     public void keyTyped(KeyEvent e) { }
     220    public void keyReleased(KeyEvent e) {}
     221
     222    public void keyTyped(KeyEvent e) {}
    207223
    208224
     
    226242     */
    227243    public void setMessageOnly(boolean message_only) {
     244    if(!showcheckbox) {
     245        return;
     246    }
     247
    228248    // If this is a message then change the checkbox
    229249    if(message_only) {
     
    239259     * @param  control the JTextField subclass you want to use for the control
    240260     */
    241     public void setValueField(JTextField control) {
     261    public void setValueField(JComponent control) {
    242262    // Remove the current control
    243263    value_panel.remove(value_field);
     
    263283
    264284    public void setValueField(String field_value){
    265     this.value_field.setText(field_value);
     285    URLField.setText(this.value_field, field_value);
    266286    }
    267287
Note: See TracChangeset for help on using the changeset viewer.