Changeset 17131 for gli


Ignore:
Timestamp:
09/04/08 11:15:51 (12 years ago)
Author:
kjdon
Message:

indented to 2 spaces. added a new constructor which takes a dialog as an argument - if calling this from a dialog, use the new constructor to block the calling dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/SimpleResultDialog.java

    r12119 r17131  
    4848
    4949public class SimpleResultDialog
    50     extends ModalDialog {
     50  extends ModalDialog {
    5151   
    52     private Dimension size = new Dimension(600,300);
    53     private SimpleResultDialog self;
     52  private Dimension size = new Dimension(600,300);
     53  private SimpleResultDialog self;
    5454   
    55     public SimpleResultDialog(String title, String label, String results) {
    56     super(Gatherer.g_man, title, true);
    57     this.self = this;
     55  public SimpleResultDialog(String title, String label, String results) {
     56    super(Gatherer.g_man, title, true);
     57    this.self = this;
    5858   
    59     setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    60     setSize(size);
     59    setUpGUI(label, results);
     60  }
     61
     62  /** If you are calling this from another dialog, and you want that dialog blocked while this is open, need to use this method, passing in the calling dialog as the parent */
     63  public SimpleResultDialog(Dialog parent, String title, String label, String results) {
     64
     65    super(parent, title, true);
     66    this.self = this;
     67 
     68    setUpGUI(label, results);
     69  }
     70
     71  private void setUpGUI(String label, String results) {
     72    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
     73    setSize(size);
    6174   
    62     JPanel content_pane = (JPanel) getContentPane();
    63     JLabel result_label = new JLabel(label);
     75    JPanel content_pane = (JPanel) getContentPane();
     76    JLabel result_label = new JLabel(label);
    6477   
    65     JPanel button_pane = new JPanel();
    66     JButton close_button = new GLIButton(Dictionary.get("General.Close"));
    67     close_button.addActionListener(new CloseButtonListener());
     78    JPanel button_pane = new JPanel();
     79    JButton close_button = new GLIButton(Dictionary.get("General.Close"));
     80    close_button.addActionListener(new CloseButtonListener());
    6881   
    69     JPanel output_pane = new JPanel();
    70     JLabel output_label = new JLabel(Dictionary.get("General.Review_Output"));
     82    JPanel output_pane = new JPanel();
     83    JLabel output_label = new JLabel(Dictionary.get("General.Review_Output"));
    7184       
    72     JTextArea output_textarea = new JTextArea(results);
    73     output_textarea.setCaretPosition(0);
    74     output_textarea.setEditable(false);
    75     output_textarea.setLineWrap(true);
    76     output_textarea.setWrapStyleWord(true);
     85    JTextArea output_textarea = new JTextArea(results);
     86    output_textarea.setCaretPosition(0);
     87    output_textarea.setEditable(false);
     88    output_textarea.setLineWrap(true);
     89    output_textarea.setWrapStyleWord(true);
    7790   
    78     button_pane.setLayout(new BorderLayout());
    79     button_pane.add(close_button, BorderLayout.EAST);
     91    button_pane.setLayout(new BorderLayout());
     92    button_pane.add(close_button, BorderLayout.EAST);
    8093   
    81     output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    82     output_pane.setLayout(new BorderLayout());
    83     output_pane.add(output_label, BorderLayout.NORTH);
    84     output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER);
     94    output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
     95    output_pane.setLayout(new BorderLayout());
     96    output_pane.add(output_label, BorderLayout.NORTH);
     97    output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER);
    8598   
    86     content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    87     content_pane.setLayout(new BorderLayout());
    88     content_pane.add(result_label, BorderLayout.NORTH);
    89     content_pane.add(output_pane, BorderLayout.CENTER);
    90     content_pane.add(button_pane, BorderLayout.SOUTH);
     99    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     100    content_pane.setLayout(new BorderLayout());
     101    content_pane.add(result_label, BorderLayout.NORTH);
     102    content_pane.add(output_pane, BorderLayout.CENTER);
     103    content_pane.add(button_pane, BorderLayout.SOUTH);
    91104   
    92     // Position
    93     Rectangle frame_bounds = Gatherer.g_man.getBounds();
    94     setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2);
     105    // Position
     106    Rectangle frame_bounds = Gatherer.g_man.getBounds();
     107    setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2);
     108    //new SimpleResultDialog(Gatherer.g_man, title, label, results);
     109  }
     110 
     111 
     112  private class CloseButtonListener
     113    implements ActionListener {
     114    public void actionPerformed(ActionEvent event) {
     115      self.setVisible(false);
    95116    }
    96    
    97     private class CloseButtonListener
    98     implements ActionListener {
    99     public void actionPerformed(ActionEvent event) {
    100         self.setVisible(false);
    101     }
    102     }
     117  }
    103118}
Note: See TracChangeset for help on using the changeset viewer.