View Javadoc

1   /*
2    * Copyright 2007 Sebastien Brunot (sbrunot@gmail.com)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *   
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * BambooPropertiesDialog.java
18   *
19   * Created on May 29, 2007, 1:54 PM
20   */
21  
22  package net.sourceforge.buildmonitor.dialogs;
23  
24  import java.awt.Color;
25  import java.awt.Desktop;
26  import java.io.IOException;
27  import java.net.MalformedURLException;
28  import java.net.URI;
29  import java.net.URL;
30  import java.text.ParseException;
31  
32  import javax.swing.event.DocumentEvent;
33  import javax.swing.event.DocumentListener;
34  
35  /**
36   *
37   * @author  sbrunot
38   */
39  public class BambooPropertiesDialog extends javax.swing.JDialog {
40      
41      // TODO: use UIDefaults colors instead of this ones
42      private static final Color COLOR_TEXT_IN_ERROR = Color.RED;
43      private static final Color COLOR_TEXT_DEFAULT = Color.BLACK;
44      private static final Color COLOR_BACKGROUND_MANDATORY_FIELD_EMPY = Color.RED;
45      private static final Color COLOR_BACKGROUND_FIELD_NORMAL = Color.WHITE;
46      
47      public static final int BUTTON_CLOSE = 1;
48      public static final int BUTTON_OK = 2;
49      public static final int BUTTON_CANCEL = 3;
50      
51      private int lastClickedButton;
52      
53      /**
54       * Get the last clicked button
55       */
56      public int getLastClickedButton()
57      {
58          return this.lastClickedButton;
59      }
60      
61      /** Creates new form BambooPropertiesDialog */
62      public BambooPropertiesDialog(java.awt.Frame parent, boolean modal) {
63          super(parent, modal);
64          initComponents();
65      }
66      
67      /**
68       * Enable or disable the ok button regarding the values of the different
69       * fields
70       */
71      private void setButtonsState()
72      {
73      	// Ok button
74      	if (isBaseUrlOk() && isUsernameOk() && isPasswordOk() && isUpdatePeriodOk())
75          {
76              this.okButton.setEnabled(true);
77          }
78          else
79          {
80              this.okButton.setEnabled(false);
81          }
82      	
83      	// Open button
84      	if (isBaseUrlOk())
85      	{
86      		this.openBaseURLButton.setEnabled(true);
87      	}
88      	else
89      	{
90      		this.openBaseURLButton.setEnabled(false);
91      	}
92      }
93      
94      private boolean isBaseUrlOk()
95      {
96          return (!isBaseUrlEmptyWhenTrimed() && isBaseUrlValid());
97      }
98  
99      /**
100      * Is the base url field value a valid URL ?
101      */
102     private boolean isBaseUrlValid()
103     {
104         boolean returnedValue = true;
105         try
106         {
107             URL baseUrl = new URL(this.baseURLField.getText());
108             if (!"http".equals(baseUrl.getProtocol()))
109             {
110             	returnedValue = false;
111             }
112         }
113         catch (MalformedURLException e)
114         {
115             returnedValue = false;
116         }
117         return returnedValue;
118     }
119 
120     /**
121      * Is the base url field value empty when trimed ?
122      */
123     private boolean isBaseUrlEmptyWhenTrimed()
124     {
125         return ("".equals(this.baseURLField.getText().trim()));
126     }
127 
128     /**
129      * Is the username field value ok ?
130      */
131     private boolean isUsernameOk()
132     {
133         return (!"".equals(this.usernameField.getText().trim()));
134     }
135 
136     /**
137      * Is the password field value ok ?
138      */
139     private boolean isPasswordOk()
140     {
141         return (!"".equals(new String(this.passwordField.getPassword()).trim()));
142     }
143     
144     /**
145      * Is the value in the update period field ok ?
146      */
147     private boolean isUpdatePeriodOk()
148     {
149         return true;
150     }
151 
152     /** This method is called from within the constructor to
153      * initialize the form.
154      * WARNING: Do NOT modify this code. The content of this method is
155      * always regenerated by the Form Editor.
156      */
157     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
158     private void initComponents() {
159         javax.swing.JLabel jLabel1;
160         javax.swing.JLabel jLabel10;
161         javax.swing.JLabel jLabel11;
162         javax.swing.JLabel jLabel12;
163         javax.swing.JLabel jLabel13;
164         javax.swing.JLabel jLabel2;
165         javax.swing.JLabel jLabel3;
166         javax.swing.JLabel jLabel4;
167         javax.swing.JLabel jLabel5;
168         javax.swing.JLabel jLabel6;
169         javax.swing.JLabel jLabel7;
170         javax.swing.JLabel jLabel8;
171         javax.swing.JLabel jLabel9;
172         javax.swing.JPanel jPanel1;
173         javax.swing.JSeparator jSeparator1;
174         javax.swing.JSeparator jSeparator2;
175 
176         jPanel1 = new javax.swing.JPanel();
177         jLabel1 = new javax.swing.JLabel();
178         jLabel2 = new javax.swing.JLabel();
179         jLabel3 = new javax.swing.JLabel();
180         jLabel4 = new javax.swing.JLabel();
181         jLabel5 = new javax.swing.JLabel();
182         jLabel6 = new javax.swing.JLabel();
183         jSeparator2 = new javax.swing.JSeparator();
184         jSeparator1 = new javax.swing.JSeparator();
185         jLabel7 = new javax.swing.JLabel();
186         jLabel9 = new javax.swing.JLabel();
187         jLabel8 = new javax.swing.JLabel();
188         jLabel10 = new javax.swing.JLabel();
189         baseURLField = new javax.swing.JTextField();
190         this.baseURLField.getDocument().addDocumentListener(new DocumentListener() {
191             public void insertUpdate(DocumentEvent evt)
192             {
193                 updateBaseURLFieldStatus();
194                 setButtonsState();
195             }
196             public void removeUpdate(DocumentEvent evt)
197             {
198                 updateBaseURLFieldStatus();
199                 setButtonsState();
200             }
201             public void changedUpdate(DocumentEvent evt)
202             {
203             }
204         });
205         passwordField = new javax.swing.JPasswordField();
206         this.passwordField.getDocument().addDocumentListener(new DocumentListener() {
207             public void insertUpdate(DocumentEvent evt)
208             {
209                 updatePasswordFieldStatus();
210                 setButtonsState();
211             }
212             public void removeUpdate(DocumentEvent evt)
213             {
214                 updatePasswordFieldStatus();
215                 setButtonsState();
216             }
217             public void changedUpdate(DocumentEvent evt)
218             {
219             }
220         });
221         usernameField = new javax.swing.JTextField();
222         this.usernameField.getDocument().addDocumentListener(new DocumentListener() {
223             public void insertUpdate(DocumentEvent evt)
224             {
225                 updateUsernameFieldStatus();
226                 setButtonsState();
227             }
228             public void removeUpdate(DocumentEvent evt)
229             {
230                 updateUsernameFieldStatus();
231                 setButtonsState();
232             }
233             public void changedUpdate(DocumentEvent evt)
234             {
235             }
236         });
237         jLabel11 = new javax.swing.JLabel();
238         jLabel12 = new javax.swing.JLabel();
239         updatePeriodField = new javax.swing.JFormattedTextField();
240         this.updatePeriodField.setValue(new Integer(5));
241         jLabel13 = new javax.swing.JLabel();
242         okButton = new javax.swing.JButton();
243         cancelButton = new javax.swing.JButton();
244         openBaseURLButton = new javax.swing.JButton();
245 
246         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
247         setModal(true);
248         setResizable(false);
249         addWindowListener(new java.awt.event.WindowAdapter() {
250             public void windowClosed(java.awt.event.WindowEvent evt) {
251                 formWindowClosed(evt);
252             }
253             public void windowOpened(java.awt.event.WindowEvent evt) {
254                 formWindowOpened(evt);
255             }
256         });
257 
258         jPanel1.setBackground(java.awt.SystemColor.info);
259         jLabel1.setFont(new java.awt.Font("Tahoma", 1, 13));
260         jLabel1.setText("Bamboo build monitoring parameters");
261 
262         jLabel2.setText("Here you must define the parameters that Build Monitor will use to monitor your bamboo builds. ");
263 
264         jLabel3.setText("The Bamboo server parameters are mandatory for Build Monitor to be able to connect to your Bamboo server.");
265 
266         jLabel4.setText("The update period defines the delay, in minutes, between two queries to the Bamboo server in order to retrieve");
267 
268         jLabel5.setText("the states of the lasts builds.");
269 
270         jLabel6.setText("After you've clicked the Ok button, all values are saved in the bamboo-monitor.properties file in your user directory.");
271 
272         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
273         jPanel1.setLayout(jPanel1Layout);
274         jPanel1Layout.setHorizontalGroup(
275             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
276             .addGroup(jPanel1Layout.createSequentialGroup()
277                 .addContainerGap()
278                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
279                     .addComponent(jLabel1)
280                     .addComponent(jLabel2)
281                     .addComponent(jLabel3)
282                     .addComponent(jLabel4)
283                     .addComponent(jLabel5)
284                     .addComponent(jLabel6))
285                 .addContainerGap(22, Short.MAX_VALUE))
286         );
287         jPanel1Layout.setVerticalGroup(
288             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289             .addGroup(jPanel1Layout.createSequentialGroup()
290                 .addContainerGap()
291                 .addComponent(jLabel1)
292                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
293                 .addComponent(jLabel2)
294                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
295                 .addComponent(jLabel3)
296                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
297                 .addComponent(jLabel4)
298                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
299                 .addComponent(jLabel5)
300                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
301                 .addComponent(jLabel6)
302                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
303         );
304 
305         jLabel7.setText("Bamboo server parameters");
306 
307         jLabel9.setText("Username:");
308         jLabel9.setToolTipText("A valid Bamboo user defined for the server to monitor.");
309 
310         jLabel8.setText("Base URL:");
311         jLabel8.setToolTipText("The base URL to connect to the Bamboo server instance to monitor.");
312 
313         jLabel10.setText("Password:");
314         jLabel10.setToolTipText("The password of the Bamboo user.");
315 
316         baseURLField.setText("http://server:port");
317         baseURLField.addFocusListener(new java.awt.event.FocusAdapter() {
318             public void focusLost(java.awt.event.FocusEvent evt) {
319                 baseURLFieldFocusLost(evt);
320             }
321         });
322 
323         passwordField.addFocusListener(new java.awt.event.FocusAdapter() {
324             public void focusLost(java.awt.event.FocusEvent evt) {
325                 passwordFieldFocusLost(evt);
326             }
327         });
328 
329         usernameField.addFocusListener(new java.awt.event.FocusAdapter() {
330             public void focusLost(java.awt.event.FocusEvent evt) {
331                 usernameFieldFocusLost(evt);
332             }
333         });
334 
335         jLabel11.setText("Monitoring parameters");
336 
337         jLabel12.setText("Update period:");
338         jLabel12.setToolTipText("The delay between two queries of the Bamboo server to retrieve status of the last builds.");
339 
340         updatePeriodField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
341         updatePeriodField.addFocusListener(new java.awt.event.FocusAdapter() {
342             public void focusLost(java.awt.event.FocusEvent evt) {
343                 updatePeriodFieldFocusLost(evt);
344             }
345         });
346 
347         jLabel13.setText("minutes.");
348 
349         okButton.setText("Ok");
350         okButton.addActionListener(new java.awt.event.ActionListener() {
351             public void actionPerformed(java.awt.event.ActionEvent evt) {
352                 okButtonActionPerformed(evt);
353             }
354         });
355 
356         cancelButton.setText("Cancel");
357         cancelButton.addActionListener(new java.awt.event.ActionListener() {
358             public void actionPerformed(java.awt.event.ActionEvent evt) {
359                 cancelButtonActionPerformed(evt);
360             }
361         });
362 
363         openBaseURLButton.setText("Open...");
364         openBaseURLButton.setFocusable(false);
365         openBaseURLButton.addActionListener(new java.awt.event.ActionListener() {
366             public void actionPerformed(java.awt.event.ActionEvent evt) {
367                 openBaseURLButtonActionPerformed(evt);
368             }
369         });
370 
371         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
372         getContentPane().setLayout(layout);
373         layout.setHorizontalGroup(
374             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375             .addGroup(layout.createSequentialGroup()
376                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
377                     .addGroup(layout.createSequentialGroup()
378                         .addContainerGap()
379                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
380                             .addGroup(layout.createSequentialGroup()
381                                 .addGap(17, 17, 17)
382                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
383                                     .addComponent(jLabel8)
384                                     .addComponent(jLabel9)
385                                     .addComponent(jLabel10))
386                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
387                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
388                                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
389                                         .addComponent(passwordField, javax.swing.GroupLayout.Alignment.LEADING)
390                                         .addComponent(usernameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE))
391                                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
392                                         .addComponent(baseURLField, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
393                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
394                                         .addComponent(openBaseURLButton))))
395                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
396                                 .addComponent(okButton)
397                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
398                                 .addComponent(cancelButton))
399                             .addGroup(layout.createSequentialGroup()
400                                 .addGap(10, 10, 10)
401                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
402                                     .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)
403                                     .addComponent(jLabel7)))
404                             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
405                     .addGroup(layout.createSequentialGroup()
406                         .addGap(22, 22, 22)
407                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
408                             .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)
409                             .addComponent(jLabel11)
410                             .addGroup(layout.createSequentialGroup()
411                                 .addGap(10, 10, 10)
412                                 .addComponent(jLabel12)
413                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
414                                 .addComponent(updatePeriodField, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
415                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
416                                 .addComponent(jLabel13)))))
417                 .addContainerGap())
418         );
419         layout.setVerticalGroup(
420             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
421             .addGroup(layout.createSequentialGroup()
422                 .addContainerGap()
423                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
424                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
425                 .addComponent(jLabel7)
426                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
427                 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
428                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
429                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
430                     .addComponent(jLabel8)
431                     .addComponent(openBaseURLButton)
432                     .addComponent(baseURLField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
433                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
434                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
435                     .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
436                     .addComponent(jLabel9))
437                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
438                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
439                     .addComponent(jLabel10)
440                     .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
441                 .addGap(21, 21, 21)
442                 .addComponent(jLabel11)
443                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
444                 .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
445                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
446                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
447                     .addComponent(jLabel12)
448                     .addComponent(updatePeriodField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
449                     .addComponent(jLabel13))
450                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
451                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
452                     .addComponent(cancelButton)
453                     .addComponent(okButton))
454                 .addContainerGap())
455         );
456         pack();
457     }// </editor-fold>//GEN-END:initComponents
458 
459     private void openBaseURLButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBaseURLButtonActionPerformed
460         if (Desktop.isDesktopSupported())
461             {
462                     try
463                     {
464                         URI baseURI = new URI(this.baseURLField.getText());
465                         Desktop.getDesktop().browse(baseURI);
466                     }
467                     catch (Exception err)
468                     {
469                         // Nothing can be done here...
470                     }
471             }
472     }//GEN-LAST:event_openBaseURLButtonActionPerformed
473 
474     private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
475         // Initialize the state of the Ok button
476         setButtonsState();
477     }//GEN-LAST:event_formWindowOpened
478 
479     private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
480         this.lastClickedButton = BUTTON_CLOSE;
481     }//GEN-LAST:event_formWindowClosed
482 
483     private void updatePeriodFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_updatePeriodFieldFocusLost
484     	try
485     	{
486     		this.updatePeriodField.commitEdit();
487     	}
488     	catch (ParseException e)
489     	{
490     		//
491     	}
492         if (((Integer) this.updatePeriodField.getValue()).intValue() < 1)
493         {
494             this.updatePeriodField.setValue(new Integer(1));
495         }
496     }//GEN-LAST:event_updatePeriodFieldFocusLost
497 
498     private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
499         this.lastClickedButton = BUTTON_CANCEL;
500         // "Close" the window
501         setVisible(false);
502         dispose();
503     }//GEN-LAST:event_cancelButtonActionPerformed
504 
505     private void passwordFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_passwordFieldFocusLost
506     	updatePasswordFieldStatus();
507         setButtonsState();
508     }//GEN-LAST:event_passwordFieldFocusLost
509 
510     private void usernameFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_usernameFieldFocusLost
511     	updateUsernameFieldStatus();
512         setButtonsState();
513     }//GEN-LAST:event_usernameFieldFocusLost
514 
515     private void baseURLFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_baseURLFieldFocusLost
516     	updateBaseURLFieldStatus();
517         setButtonsState();
518     }//GEN-LAST:event_baseURLFieldFocusLost
519 
520     public void updateBaseURLFieldStatus()
521     {
522         if (isBaseUrlEmptyWhenTrimed())
523         {
524             this.baseURLField.setBackground(COLOR_BACKGROUND_MANDATORY_FIELD_EMPY);
525             this.baseURLField.setToolTipText("base URL is mandatory to connect to the bamboo server !");
526             if (COLOR_TEXT_IN_ERROR.equals(this.baseURLField.getForeground()))
527             {
528                 this.baseURLField.setForeground(COLOR_TEXT_DEFAULT);
529             }
530         }
531         else
532         {
533             this.baseURLField.setBackground(COLOR_BACKGROUND_FIELD_NORMAL);            
534             if (isBaseUrlValid())
535             {
536                 this.baseURLField.setForeground(COLOR_TEXT_DEFAULT);
537                 this.baseURLField.setToolTipText(null);
538             }
539             else
540             {
541                 this.baseURLField.setForeground(COLOR_TEXT_IN_ERROR);
542                 this.baseURLField.setToolTipText(this.baseURLField.getText() + " is not a valid http URL !");
543             }
544         }
545     }
546     
547     public void updateUsernameFieldStatus()
548     {
549         if (isUsernameOk())
550         {
551             this.usernameField.setBackground(COLOR_BACKGROUND_FIELD_NORMAL);
552             this.usernameField.setToolTipText(null);
553         }
554         else
555         {
556             this.usernameField.setBackground(COLOR_BACKGROUND_MANDATORY_FIELD_EMPY);
557             this.usernameField.setToolTipText("username is mandatory to connect to the bamboo server !");
558         }    	
559     }
560 
561     public void updatePasswordFieldStatus()
562     {
563         if (isPasswordOk())
564         {
565             this.passwordField.setBackground(COLOR_BACKGROUND_FIELD_NORMAL);
566             this.passwordField.setToolTipText(null);
567         }
568         else
569         {
570             this.passwordField.setBackground(COLOR_BACKGROUND_MANDATORY_FIELD_EMPY);
571             this.passwordField.setToolTipText("password is mandatory to connect to the bamboo server !");
572         }
573     }
574 
575     private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
576         this.lastClickedButton = BUTTON_OK;
577         // "Close" the window
578         setVisible(false);
579         dispose();
580     }//GEN-LAST:event_okButtonActionPerformed
581     
582     /**
583      * @param args the command line arguments
584      */
585     public static void main(String args[]) {
586         java.awt.EventQueue.invokeLater(new Runnable() {
587             public void run() {
588                 new BambooPropertiesDialog(new javax.swing.JFrame(), true).setVisible(true);
589             }
590         });
591     }
592     
593     // Variables declaration - do not modify//GEN-BEGIN:variables
594     public javax.swing.JTextField baseURLField;
595     private javax.swing.JButton cancelButton;
596     private javax.swing.JButton okButton;
597     private javax.swing.JButton openBaseURLButton;
598     public javax.swing.JPasswordField passwordField;
599     public javax.swing.JFormattedTextField updatePeriodField;
600     public javax.swing.JTextField usernameField;
601     // End of variables declaration//GEN-END:variables
602     
603 }