Changeset 15374 for gli

Show
Ignore:
Timestamp:
09.05.2008 14:42:59 (12 years ago)
Author:
ak19
Message:

FedoraLogin? allows for looping whenever connecting to a Fedora server fails

Files:
1 modified

Legend:

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

    r14975 r15374  
    7070{ 
    7171 
     72    private JPanel m_infoPane; 
    7273    private JComboBox m_serverComboBox; 
    7374    private JComboBox m_protocolComboBox; 
     
    8990    { 
    9091    super(Gatherer.g_man, "Login", true); 
     92    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); 
    9193         
    9294        m_servers=new HashMap(); 
     
    136138                new JComponent[] {m_serverComboBox, m_protocolComboBox, m_usernameComboBox, m_passwordField},  
    137139                gridBag, inputPane); 
     140     
     141    // handling Closing and cancelling events 
     142    this.addWindowListener(new WindowAdapter() { 
     143        public void windowClosing(WindowEvent e){ 
     144            // this is important, if we want to stop looping on displaying the dialog: 
     145            login_requested = false;  
     146            //dispose(); // defaultCloseOperation of this dialog already set to dispose it 
     147        } 
     148        }); 
    138149 
    139150        JButton cancelButton=new JButton(new AbstractAction() { 
    140151            private static final long serialVersionUID = 1L; 
    141152            public void actionPerformed(ActionEvent evt) { 
     153        // this is important, if we want to stop looping on displaying the dialog: 
     154        login_requested = false; 
    142155                dispose(); 
    143156            } 
     
    150163        buttonPane.add(cancelButton); 
    151164        Container contentPane=getContentPane(); 
     165 
    152166        contentPane.setLayout(new BorderLayout()); 
     167    m_infoPane = new JPanel(); 
     168    contentPane.add(m_infoPane, BorderLayout.NORTH); 
    153169        contentPane.add(inputPane, BorderLayout.CENTER); 
    154170        contentPane.add(buttonPane, BorderLayout.SOUTH); 
     
    305321        } 
    306322 
     323    } 
     324 
     325    public void setErrorMessage(String[] errorLines) { 
     326    m_infoPane.removeAll(); 
     327    // n rows and 1 column 
     328    m_infoPane.setLayout(new java.awt.GridLayout(errorLines.length, 1)); 
     329    for(int i = 0; i < errorLines.length; i++) { 
     330        JLabel line = new JLabel("  " + errorLines[i] + "  "); 
     331        m_infoPane.add(line); 
     332    } 
     333     
     334    // Adjust and resize this dialog to take into account the  
     335    // recently added components (labels) 
     336    m_infoPane.validate();   
     337    this.pack(); 
    307338    } 
    308339 
     
    403434            login_requested = true; 
    404435 
    405                     m_loginDialog.dispose(); 
     436            // hiding it instead of disposing it on OK-press allows us to loop 
     437            // on displaying the dialog in case there's more checking to do 
     438            m_loginDialog.setVisible(false); 
     439 
    406440                } catch (Exception e) { 
    407441                    //String msg = e.getMessage(); 
     
    413447                } 
    414448            } 
    415       } 
    416      
    417  
     449      }     
    418450      } 
    419451