Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/fetish/toolkit/AdminToolFrontEnd.java


1   /*
2    * AdminToolFrontEnd.java
3    *
4    * Created on July 4, 2001, 9:43 AM
5    */
6   
7   package com.fetish.toolkit;
8   
9   import net.jini.lookup.*;
10  import net.jini.core.lookup.*;
11  import com.fetish.directory.*;
12  import java.rmi.*;
13  import javax.swing.*;
14  import java.awt.*;
15  
16  /**
17   * The Administrator Tool GUI.
18   * @author  bnt
19   */
20  public class AdminToolFrontEnd extends javax.swing.JFrame {
21      
22      private Administrator ad;
23  
24      /** Creates new form AdminToolFrontEnd */
25      public AdminToolFrontEnd() {
26          if( System.getSecurityManager() == null ) {
27              System.setSecurityManager(new RMISecurityManager());
28          }
29          this.ad = new Administrator();
30          //this.ad = null;
31          initComponents();
32      }
33  
34      /** This method is called from within the constructor to
35       * initialize the form.
36       * WARNING: Do NOT modify this code. The content of this method is
37       * always regenerated by the Form Editor.
38       */
39      private void initComponents() {//GEN-BEGIN:initComponents
40          jMenuBar1 = new javax.swing.JMenuBar();
41          jMenu3 = new javax.swing.JMenu();
42          jMenuItem4 = new javax.swing.JMenuItem();
43          jMenu2 = new javax.swing.JMenu();
44          HelpMenuAbout = new javax.swing.JMenuItem();
45          jPanel1 = new javax.swing.JPanel();
46          jLabel1 = new javax.swing.JLabel();
47          urlTextField = new javax.swing.JTextField();
48          butStop = new javax.swing.JButton();
49          jPanel6 = new javax.swing.JPanel();
50          jLabel3 = new javax.swing.JLabel();
51          sidLabel = new javax.swing.JLabel();
52          jTabbedPane1 = new javax.swing.JTabbedPane();
53          jPanel3 = new javax.swing.JPanel();
54          jSplitPane1 = new javax.swing.JSplitPane();
55          neighborScrollPane1 = new javax.swing.JScrollPane();
56          neighborList = new javax.swing.JList();
57          jPanel4 = new javax.swing.JPanel();
58          butAdd = new javax.swing.JButton();
59          butDisconnect = new javax.swing.JButton();
60          butIsolate = new javax.swing.JButton();
61          jPanel2 = new javax.swing.JPanel();
62          jScrollPane3 = new javax.swing.JScrollPane();
63          serviceList = new javax.swing.JList();
64          jPanel5 = new javax.swing.JPanel();
65          statusBarTextField = new javax.swing.JLabel();
66          
67          jMenu3.setText("Application");
68          
69          jMenuItem4.setText("Exit application");
70          jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
71              public void actionPerformed(java.awt.event.ActionEvent evt) {
72                  jMenuItem4ActionPerformed(evt);
73              }
74          }
75          );
76          jMenu3.add(jMenuItem4);
77          jMenuBar1.add(jMenu3);
78          
79          jMenu2.setToolTipText("Help");
80          jMenu2.setText("Help");
81          jMenu2.setAlignmentX(1.0F);
82          jMenu2.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
83          jMenu2.setName("HelpMenu");
84          jMenu2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
85          
86          HelpMenuAbout.setText("About");
87          HelpMenuAbout.addActionListener(new java.awt.event.ActionListener() {
88              public void actionPerformed(java.awt.event.ActionEvent evt) {
89                  HelpMenuAboutActionPerformed(evt);
90              }
91          }
92          );
93          jMenu2.add(HelpMenuAbout);
94          jMenuBar1.add(jMenu2);
95          getContentPane().setLayout(new java.awt.GridBagLayout());
96          java.awt.GridBagConstraints gridBagConstraints1;
97          setTitle("FADA Administration Tool");
98          setFont(new java.awt.Font ("Default", 0, 10));
99          addWindowListener(new java.awt.event.WindowAdapter() {
100             public void windowClosing(java.awt.event.WindowEvent evt) {
101                 exitForm(evt);
102             }
103         }
104         );
105         
106         jPanel1.setLayout(new java.awt.GridBagLayout());
107         java.awt.GridBagConstraints gridBagConstraints2;
108         jPanel1.setBorder(new javax.swing.border.EtchedBorder());
109         
110         jLabel1.setText("URL");
111         gridBagConstraints2 = new java.awt.GridBagConstraints();
112         gridBagConstraints2.insets = new java.awt.Insets(1, 1, 1, 2);
113         jPanel1.add(jLabel1, gridBagConstraints2);
114         
115         
116         urlTextField.setToolTipText("Fada node URL");
117         urlTextField.setPreferredSize(new java.awt.Dimension(120, 16));
118         urlTextField.setMinimumSize(new java.awt.Dimension(40, 16));
119         urlTextField.addActionListener(new java.awt.event.ActionListener() {
120             public void actionPerformed(java.awt.event.ActionEvent evt) {
121                 urlTextFieldActionPerformed(evt);
122             }
123         }
124         );
125         urlTextField.addInputMethodListener(new java.awt.event.InputMethodListener() {
126             public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
127                 urlTextFieldInputMethodTextChanged(evt);
128             }
129             public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
130                 
131             }
132         }
133         );
134         urlTextField.addKeyListener(new java.awt.event.KeyAdapter() {
135             public void keyReleased(java.awt.event.KeyEvent evt) {
136                 urlTextFieldKeyReleased(evt);
137             }
138         }
139         );
140         gridBagConstraints2 = new java.awt.GridBagConstraints();
141         gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
142         gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 2);
143         gridBagConstraints2.weightx = 6.0;
144         jPanel1.add(urlTextField, gridBagConstraints2);
145         
146         
147         butStop.setToolTipText("Stop Fada node");
148         butStop.setText("Stop");
149         butStop.addActionListener(new java.awt.event.ActionListener() {
150             public void actionPerformed(java.awt.event.ActionEvent evt) {
151                 butConnectActionPerformed(evt);
152             }
153         }
154         );
155         gridBagConstraints2 = new java.awt.GridBagConstraints();
156         gridBagConstraints2.gridx = 2;
157         gridBagConstraints2.gridy = 0;
158         gridBagConstraints2.insets = new java.awt.Insets(1, 1, 1, 1);
159         jPanel1.add(butStop, gridBagConstraints2);
160         
161         
162         jPanel6.setLayout(new java.awt.GridBagLayout());
163         java.awt.GridBagConstraints gridBagConstraints3;
164         
165         jLabel3.setText("SID");
166         gridBagConstraints3 = new java.awt.GridBagConstraints();
167         gridBagConstraints3.gridx = 0;
168         gridBagConstraints3.gridy = 1;
169         gridBagConstraints3.insets = new java.awt.Insets(1, 1, 1, 2);
170         jPanel6.add(jLabel3, gridBagConstraints3);
171         
172         
173         sidLabel.setToolTipText("Selected Fada node ServiceID");
174         sidLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
175         sidLabel.setMinimumSize(new java.awt.Dimension(120, 0));
176         gridBagConstraints3 = new java.awt.GridBagConstraints();
177         gridBagConstraints3.gridx = 1;
178         gridBagConstraints3.gridy = 1;
179         gridBagConstraints3.gridwidth = 2;
180         gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
181         gridBagConstraints3.insets = new java.awt.Insets(2, 0, 0, 0);
182         gridBagConstraints3.weightx = 6.0;
183         jPanel6.add(sidLabel, gridBagConstraints3);
184         
185         gridBagConstraints2 = new java.awt.GridBagConstraints();
186         gridBagConstraints2.gridx = 0;
187         gridBagConstraints2.gridy = 1;
188         gridBagConstraints2.gridwidth = 3;
189         gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
190         jPanel1.add(jPanel6, gridBagConstraints2);
191         
192         
193         gridBagConstraints1 = new java.awt.GridBagConstraints();
194         gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
195         gridBagConstraints1.ipadx = 2;
196         gridBagConstraints1.ipady = 2;
197         getContentPane().add(jPanel1, gridBagConstraints1);
198         
199         
200         jTabbedPane1.setAutoscrolls(true);
201         
202         jPanel3.setLayout(new java.awt.GridBagLayout());
203         java.awt.GridBagConstraints gridBagConstraints4;
204         
205         jSplitPane1.setDividerLocation( 200 );
206         jSplitPane1.setBorder(new javax.swing.border.EtchedBorder());
207         jSplitPane1.setBottomComponent(jPanel4);
208         jSplitPane1.setOneTouchExpandable(true);
209         jSplitPane1.setLeftComponent(neighborScrollPane1);
210         jSplitPane1.setAutoscrolls(true);
211         
212         neighborScrollPane1.setPreferredSize(new java.awt.Dimension(116, 58));
213         neighborScrollPane1.setRequestFocusEnabled(false);
214         neighborScrollPane1.setAutoscrolls(true);
215         
216         neighborList.setToolTipText("Fada node neighbors");
217         neighborList.setPreferredSize(new java.awt.Dimension(600, 400));
218         neighborList.setValueIsAdjusting(true);
219         neighborList.setVerifyInputWhenFocusTarget(false);
220         neighborList.setMaximumSize(new java.awt.Dimension(1024, 1024));
221         neighborList.setName("NeighborList");
222         neighborList.setMinimumSize(new java.awt.Dimension(400, 400));
223         neighborList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
224         neighborList.setAutoscrolls(false);
225         neighborList.addMouseListener(new java.awt.event.MouseAdapter() {
226             public void mouseClicked(java.awt.event.MouseEvent evt) {
227                 neighborListMouseClicked(evt);
228             }
229         }
230         );
231         neighborScrollPane1.setViewportView(neighborList);
232         
233         jSplitPane1.setLeftComponent(neighborScrollPane1);
234         
235         
236         jPanel4.setLayout(new java.awt.GridBagLayout());
237         java.awt.GridBagConstraints gridBagConstraints5;
238         
239         butAdd.setToolTipText("Add a new node");
240         butAdd.setText("Add");
241         butAdd.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
242         butAdd.addActionListener(new java.awt.event.ActionListener() {
243             public void actionPerformed(java.awt.event.ActionEvent evt) {
244                 butAddActionPerformed(evt);
245             }
246         }
247         );
248         gridBagConstraints5 = new java.awt.GridBagConstraints();
249         gridBagConstraints5.gridx = 0;
250         gridBagConstraints5.gridy = 0;
251         jPanel4.add(butAdd, gridBagConstraints5);
252         
253         
254         butDisconnect.setToolTipText("Disconnect from selected node");
255         butDisconnect.setText("Disconnect");
256         butDisconnect.addActionListener(new java.awt.event.ActionListener() {
257             public void actionPerformed(java.awt.event.ActionEvent evt) {
258                 butDisconnectActionPerformed(evt);
259             }
260         }
261         );
262         gridBagConstraints5 = new java.awt.GridBagConstraints();
263         gridBagConstraints5.gridx = 0;
264         gridBagConstraints5.gridy = 1;
265         jPanel4.add(butDisconnect, gridBagConstraints5);
266         
267         
268         butIsolate.setToolTipText("Disconnect from all neighbors");
269         butIsolate.setText("Isolate");
270         butIsolate.addActionListener(new java.awt.event.ActionListener() {
271             public void actionPerformed(java.awt.event.ActionEvent evt) {
272                 butIsolateActionPerformed(evt);
273             }
274         }
275         );
276         gridBagConstraints5 = new java.awt.GridBagConstraints();
277         gridBagConstraints5.gridx = 0;
278         gridBagConstraints5.gridy = 2;
279         jPanel4.add(butIsolate, gridBagConstraints5);
280         
281         jSplitPane1.setRightComponent(jPanel4);
282         
283         gridBagConstraints4 = new java.awt.GridBagConstraints();
284         gridBagConstraints4.gridx = 0;
285         gridBagConstraints4.gridy = 0;
286         gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
287         gridBagConstraints4.ipadx = 1;
288         gridBagConstraints4.ipady = 1;
289         gridBagConstraints4.weightx = 1.0;
290         gridBagConstraints4.weighty = 1.0;
291         jPanel3.add(jSplitPane1, gridBagConstraints4);
292         
293         jTabbedPane1.addTab("Neighbors", jPanel3);
294         
295         
296         jPanel2.setLayout(new java.awt.GridBagLayout());
297         java.awt.GridBagConstraints gridBagConstraints6;
298         
299         
300         serviceList.setToolTipText("Services in Fada node");
301         serviceList.setBackground(new java.awt.Color (204, 204, 204));
302         serviceList.setValueIsAdjusting(true);
303         serviceList.setMinimumSize(new java.awt.Dimension(40, 40));
304         jScrollPane3.setViewportView(serviceList);
305         
306         gridBagConstraints6 = new java.awt.GridBagConstraints();
307         gridBagConstraints6.gridx = 0;
308         gridBagConstraints6.gridy = 0;
309         gridBagConstraints6.fill = java.awt.GridBagConstraints.BOTH;
310         gridBagConstraints6.weightx = 1.0;
311         gridBagConstraints6.weighty = 1.0;
312         jPanel2.add(jScrollPane3, gridBagConstraints6);
313         
314         jTabbedPane1.addTab("Services", jPanel2);
315         
316         
317         gridBagConstraints1 = new java.awt.GridBagConstraints();
318         gridBagConstraints1.gridx = 0;
319         gridBagConstraints1.gridy = 1;
320         gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
321         gridBagConstraints1.weightx = 1.0;
322         gridBagConstraints1.weighty = 1.0;
323         getContentPane().add(jTabbedPane1, gridBagConstraints1);
324         
325         
326         jPanel5.setLayout(new java.awt.GridBagLayout());
327         java.awt.GridBagConstraints gridBagConstraints7;
328         jPanel5.setBorder(new javax.swing.border.EtchedBorder());
329         
330         statusBarTextField.setToolTipText("Status bar");
331         statusBarTextField.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
332         statusBarTextField.setPreferredSize(new java.awt.Dimension(0, 12));
333         statusBarTextField.setMinimumSize(new java.awt.Dimension(0, 12));
334         statusBarTextField.setDoubleBuffered(true);
335         statusBarTextField.setAlignmentY(0.0F);
336         statusBarTextField.setMaximumSize(new java.awt.Dimension(1200, 12));
337         statusBarTextField.setOpaque(true);
338         statusBarTextField.setRequestFocusEnabled(false);
339         statusBarTextField.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
340         gridBagConstraints7 = new java.awt.GridBagConstraints();
341         gridBagConstraints7.gridx = 0;
342         gridBagConstraints7.gridy = 0;
343         gridBagConstraints7.fill = java.awt.GridBagConstraints.BOTH;
344         gridBagConstraints7.weightx = 1.0;
345         gridBagConstraints7.weighty = 1.0;
346         jPanel5.add(statusBarTextField, gridBagConstraints7);
347         
348         
349         gridBagConstraints1 = new java.awt.GridBagConstraints();
350         gridBagConstraints1.gridx = 0;
351         gridBagConstraints1.gridy = 2;
352         gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
353         gridBagConstraints1.ipadx = 1;
354         gridBagConstraints1.ipady = 1;
355         getContentPane().add(jPanel5, gridBagConstraints1);
356         
357         setJMenuBar(jMenuBar1);
358         
359         pack();
360     }//GEN-END:initComponents
361 
362     private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
363         // Add your handling code here:
364         System.exit(0);
365     }//GEN-LAST:event_jMenuItem4ActionPerformed
366 
367     private void HelpMenuAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HelpMenuAboutActionPerformed
368         // Add your handling code here:
369         final JFrame parent = this;
370         Runnable showAbout = new Runnable() {
371             public void run() {
372                 AboutDialog abdlg = new AboutDialog( parent, true );
373                 abdlg.setVisible(true);
374             }
375         };
376         new Thread( showAbout ).start();
377     }//GEN-LAST:event_HelpMenuAboutActionPerformed
378 
379     private void urlTextFieldInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_urlTextFieldInputMethodTextChanged
380         // Add your handling code here:
381     }//GEN-LAST:event_urlTextFieldInputMethodTextChanged
382 
383     private void urlTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_urlTextFieldKeyReleased
384         // Add your handling code here:
385         if( evt.getKeyCode() == evt.VK_ENTER ) {
386             url = urlTextField.getText();
387             Runnable connectToNodeAction = new Runnable() {
388                 public void run() {
389                     statusBarTextField.setText("");
390                     connectToNode();
391                 }
392             };
393             new Thread( connectToNodeAction ).start();
394             try {
395             } catch( Exception e ) {
396             }
397         }
398     }//GEN-LAST:event_urlTextFieldKeyReleased
399 
400     private void neighborListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_neighborListMouseClicked
401         // Add your handling code here:
402         if( evt.getClickCount() == 2 ) {
403             // Double click, switch to neighbor
404             Runnable selectNeighbor = new Runnable() {
405                 public void run() {
406                     statusBarTextField.setText("");
407                     int neighbor = neighborList.getSelectedIndex();
408                     lusm = ( LUSManager )neighbors[ neighbor ];
409                     try {
410             url = lusm.getUrl();
411             urlTextField.setText( url );
412             connectToNode();
413                     } catch( Exception e ) {
414                       statusBarTextField.setText( "Error" );
415                     }
416                 }
417             };
418             new Thread( selectNeighbor ).start();
419         }
420     }//GEN-LAST:event_neighborListMouseClicked
421 
422     private void butIsolateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butIsolateActionPerformed
423         // Add your handling code here:
424         Runnable isolateAction = new Runnable() {
425             public void run() {
426                 statusBarTextField.setText("");
427                 urlTextField.setText( url );
428                 if( url != null ) {
429                     statusBarTextField.setText( "Isolating..." );
430                     jPanel5.repaint();
431                     try {
432                         ad.isolate( url );
433                         statusBarTextField.setText( "Isolated" );
434                         jPanel5.repaint();
435             try {
436               getNeighbors( url );
437             } catch( Exception ex ) {
438               statusBarTextField.setText(
439                 "Couldn't reread neighbors"
440               );
441             }
442                     } catch( Exception e ) {
443                         statusBarTextField.setText( "Couldn't isolate node" );
444                         jPanel5.repaint();
445                     }
446                 }
447             }
448         };
449         new Thread( isolateAction ).start();
450     }//GEN-LAST:event_butIsolateActionPerformed
451 
452     private void butAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butAddActionPerformed
453         // Add your handling code here:
454         final JFrame parent = this;
455         Runnable addAction = new Runnable() {
456             public void run() {
457                 statusBarTextField.setText("");
458                 // Open a dialog to get the URL
459                 urlTextField.setText( url );
460                 com.fetish.toolkit.URLDialog urldialog = new com.fetish.toolkit.URLDialog( parent, true );
461                 urldialog.setVisible( true );
462                 // Here only after dialog has been closed
463                 if( urldialog.isAccepted() ) {
464                     String url2 = urldialog.getURL();
465                     try {
466                         statusBarTextField.setText( "Connecting" );
467                         jPanel5.repaint();
468                         boolean result = ad.connect( url, url2 );
469                         if( result ) {
470               getNeighbors( url );
471                           statusBarTextField.setText( "Connected" );
472               jPanel5.repaint();
473                         } else {
474                           statusBarTextField.setText( "Unable to connect" );
475                           jPanel5.repaint();
476                         }
477                     } catch( Exception e ) {
478                         statusBarTextField.setText( "Couldn't add new neighbor" );
479                         jPanel5.repaint();
480                         //url = "";
481                         //urlTextField.setText( url );
482                     }
483                 }
484             }
485         };
486         new Thread( addAction ).start();
487     }//GEN-LAST:event_butAddActionPerformed
488 
489     private void butDisconnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butDisconnectActionPerformed
490         // Add your handling code here:
491         Runnable disconnectAction = new Runnable() {
492             public void run() {
493                 statusBarTextField.setText("");
494                 int index = neighborList.getSelectedIndex();
495                 if( index != -1 ) {
496                     statusBarTextField.setText( "Disconnecting..." );
497                     String url1 = neighborUrls[ index ];
498                     ServiceID sid1 = neighborSids[ index ];
499                     try {
500                         ad.disconnect( url, url1 );
501                         //ad.disconnect( url, sid1 );
502                         statusBarTextField.setText( "Disconnected" );
503                         jPanel5.repaint();
504                         getNeighbors( url );
505                     } catch( Exception e ) {
506                         statusBarTextField.setText( "Couldn't disconnect" );
507                         jPanel5.repaint();
508                     }
509                 } else {
510                     statusBarTextField.setText( "You must first choose a neighbor to disconnect from" );
511                 }
512             }
513         };
514         new Thread( disconnectAction ).start();
515     }//GEN-LAST:event_butDisconnectActionPerformed
516 
517     private void urlTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urlTextFieldActionPerformed
518         // Add your handling code here:
519     }//GEN-LAST:event_urlTextFieldActionPerformed
520    
521     private void getNeighbors( String url ) throws RemoteException {
522         LUSManager lusm = ad.getLUSManager( url );
523         getNeighbors( lusm );
524     }
525     
526     private void getNeighbors( LUSManager lusm ) {
527         neighborUrls = new String[0];
528         neighborSids = new ServiceID[0];
529         neighbors = new Remote[0];
530         try {
531             neighbors = ad.getNeighbors( url );
532         } catch( Exception e ) {
533         }
534         neighborSids = new ServiceID[ neighbors.length ];
535         neighborUrls = new String[ neighbors.length ];
536         String[] neighborInfo = new String[ neighbors.length ];
537         for( int i=0; i < neighbors.length; i++ ) {
538             try {
539             neighborUrls[ i ] = (( LUSManager )neighbors[i]).getUrl();
540             neighborSids[ i ] = (( LUSManager )neighbors[i]).getServiceID();
541             neighborInfo[ i ] = neighborUrls[i] + " - " + neighborSids[ i ];
542             } catch( Exception e ) {
543             }
544         }
545         neighborList.setListData( neighborInfo );
546         neighborScrollPane1.repaint();
547     }
548     
549 //    private void getServices() throws RemoteException {
550 //        LUSManager lusm = ad.getLUSManager( url );
551 //        getServices( lusm );
552 //    }
553     
554     private void getServices( LUSManager lusm ) {
555         ServiceItem[] data = null;
556         try {
557             data = ad.getServices( ( Directory )lusm );
558         } catch( Exception e1 ) {
559         }
560         services = null;
561         if( data != null ) {
562             services = new String[ data.length ];
563             for( int i=0; i < services.length; i++ ) {
564                 try {
565                     services[i] = data[i].serviceID + " - " +
566                     data[i].service.getClass().getName();
567                 } catch( Exception e2 ) {
568                 }
569             }
570         } else {
571             services = new String[0];
572         }
573         serviceList.setListData( services );
574         jScrollPane3.repaint();
575     }
576     
577     private void connectToNode() {
578       boolean status = true;
579         Runnable setConnecting = new Runnable() {
580             public void run() {
581                 statusBarTextField.setText( "Connecting..." );
582                 sidLabel.setText( "" );
583             }
584         };
585         try {
586           SwingUtilities.invokeAndWait( setConnecting );
587           //new Thread( setConnecting ).start();
588         } catch( Exception e ) {
589         }
590         LUSManager lusm = null;
591         ServiceID sid = null;
592         try {
593             ad = new Administrator();
594             //ad = new Administrator( url );
595             lusm = ad.getLUSManager( url );
596             sid = lusm.getServiceID();
597         } catch( Exception e2 ) {
598           status = false;
599         }
600         url = null;
601         try {
602                 url = lusm.getUrl();
603         } catch( Exception e ) {
604                 status = false;
605         }
606         urlTextField.setText( url );
607         String auxSid = "" + sid;
608         if( sid == null ) {
609             auxSid = "";
610         }
611         final String mySid = auxSid;
612         Runnable showSid = new Runnable() {
613                 public void run() {
614                         if( mySid == null ) {
615                                 sidLabel.setText( "" );
616                         } else {
617                                 sidLabel.setText( mySid );
618                         }
619                 }
620         };
621         try {
622                 SwingUtilities.invokeAndWait( showSid );
623                 //new Thread( showSid ).start();
624         } catch( Exception e ) {
625                 status = false;
626         }
627         statusBarTextField.setText( "Getting neighbors..." );
628         try {
629                 getNeighbors( lusm );
630         } catch( Exception e1 ) {
631                 status = false;
632         }
633         statusBarTextField.setText( "Getting services..." );
634         try {
635                 getServices( lusm );
636         } catch( Exception e2 ) {
637                 status = false;
638         }
639         if( status ) {
640                 statusBarTextField.setText( "Connected" );
641         } else {
642                 statusBarTextField.setText( "Unable to connect" );
643         }
644         System.gc();
645     }
646     
647     private void stopNode() {
648         // Note: in the current implementation of FADA
649         // no stop facilities are given
650         try {
651             statusBarTextField.setText( "Stopping..." );
652             ad.stop( url, "password" ); // Should take password from user
653             neighborList.setListData( ( Object[] )new Object[0] );
654             serviceList.setListData( ( Object[] )new Object[0] );
655             urlTextField.setText( "" );
656             url = "";
657             sidLabel.setText( "" );
658             statusBarTextField.setText( "Stopped" );
659         } catch( Exception e ) {
660                 statusBarTextField.setText( "" );
661         }
662     }
663     
664     private void butConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butConnectActionPerformed
665         // Add your handling code here:
666         urlTextField.setText( url );
667         Runnable stopNodeAction = new Runnable() {
668             public void run() {
669                 statusBarTextField.setText("");
670                 stopNode();
671             }
672         };
673         new Thread( stopNodeAction ).start();
674     }//GEN-LAST:event_butConnectActionPerformed
675 
676     /** Exit the Application */
677     private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
678         System.exit(0);
679     }//GEN-LAST:event_exitForm
680 
681     /**
682     * @param args the command line arguments
683     */
684     public static void main(String args[]) {
685         new AdminToolFrontEnd().show();
686     }
687 
688 
689     // Variables declaration - do not modify//GEN-BEGIN:variables
690     private javax.swing.JMenuBar jMenuBar1;
691     private javax.swing.JMenu jMenu3;
692     private javax.swing.JMenuItem jMenuItem4;
693     private javax.swing.JMenu jMenu2;
694     private javax.swing.JMenuItem HelpMenuAbout;
695     private javax.swing.JPanel jPanel1;
696     private javax.swing.JLabel jLabel1;
697     private javax.swing.JTextField urlTextField;
698     private javax.swing.JButton butStop;
699     private javax.swing.JPanel jPanel6;
700     private javax.swing.JLabel jLabel3;
701     private javax.swing.JLabel sidLabel;
702     private javax.swing.JTabbedPane jTabbedPane1;
703     private javax.swing.JPanel jPanel3;
704     private javax.swing.JSplitPane jSplitPane1;
705     private javax.swing.JScrollPane neighborScrollPane1;
706     private javax.swing.JList neighborList;
707     private javax.swing.JPanel jPanel4;
708     private javax.swing.JButton butAdd;
709     private javax.swing.JButton butDisconnect;
710     private javax.swing.JButton butIsolate;
711     private javax.swing.JPanel jPanel2;
712     private javax.swing.JScrollPane jScrollPane3;
713     private javax.swing.JList serviceList;
714     private javax.swing.JPanel jPanel5;
715     private javax.swing.JLabel statusBarTextField;
716     // End of variables declaration//GEN-END:variables
717     private String url;
718     private LUSManager lusm;
719     private Remote[] neighbors;
720     private String[] neighborUrls;
721     private ServiceID[] neighborSids;
722     private String[] services;
723     
724 }