felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfre...@apache.org
Subject svn commit: r463216 - in /incubator/felix/trunk: mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/ mosgi.console.component/src/main/resources/icons/ mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/ mosgi...
Date Thu, 12 Oct 2006 11:54:38 GMT
Author: sfrenot
Date: Thu Oct 12 04:54:37 2006
New Revision: 463216

URL: http://svn.apache.org/viewvc?view=rev&rev=463216
Log:
FELIX-151

- RemoteLogger_jtree can now ask the remote logger to send the old log at connection time.
- A right click on remoteLogger_jtree now allows deleting log.
- Addition of an "add" and "remove" button into NodesTree.
- Improvement of propertyChangeEvent's in mosgi.console.gui.


Added:
    incubator/felix/trunk/mosgi.console.component/src/main/resources/icons/OLDLOG.gif   (with props)
Modified:
    incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtableCellRenderer.java
    incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtreeCellRenderer.java
    incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtable.java
    incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtree.java
    incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Activator.java
    incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
    incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodePanel.java
    incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
    incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/Logger.java
    incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/LoggerMBean.java

Modified: incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtableCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtableCellRenderer.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtableCellRenderer.java (original)
+++ incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtableCellRenderer.java Thu Oct 12 04:54:37 2006
@@ -40,8 +40,7 @@
     eventName.put(new Integer( Bundle.UNINSTALLED ), Color.black  );
   }
 
-  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
-  						 boolean hasFocus, int row, int column) {
+  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
     setOpaque(true);
     if (column==0){
       Integer state;
@@ -50,7 +49,11 @@
       }catch (NumberFormatException nfe) {
         state=new Integer(-1);
       }
-      setBackground((Color) eventName.get(state));
+      if (((String) value).equals("??/??/??")) {
+	setBackground(Color.white);
+      } else{
+	setBackground((Color) eventName.get(state));
+      }
     }
     setText((String) value);
 

Modified: incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtreeCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtreeCellRenderer.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtreeCellRenderer.java (original)
+++ incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/JtreeCellRenderer.java Thu Oct 12 04:54:37 2006
@@ -39,16 +39,18 @@
 public class JtreeCellRenderer extends DefaultTreeCellRenderer {
 
   private boolean isLeaf=false;
-  //private int maxL;
 
   private String[] states=new String[]{"ACTIVE","INSTALLED","RESOLVED","STARTING","STOPPING","UNINSTALLED"};
   private Color[] colors=new Color[]{Color.green,Color.orange,Color.red,Color.white,Color.white,Color.black};
   private ImageIcon[] ii=new ImageIcon[6];
+  private ImageIcon iiOldLog=null;
 
   public JtreeCellRenderer(BundleContext bdlCtx){
     for (int i=0 ; i<states.length ; i++){
       this.ii[i]=new ImageIcon(Toolkit.getDefaultToolkit().getImage(bdlCtx.getBundle().getResource("icons/"+states[i]+".gif")));
     }
+    this.iiOldLog=new ImageIcon(Toolkit.getDefaultToolkit().getImage(bdlCtx.getBundle().getResource("icons/OLDLOG.gif")));
+
   }
 
   public Dimension getPreferredSize() {
@@ -65,6 +67,7 @@
     setOpaque(true);
     setBackground(Color.white);
     setFont(new Font("Monospaced",Font.BOLD,12));
+    setToolTipText(null);
 
     StringTokenizer st=null;
     DefaultMutableTreeNode dmtn=(DefaultMutableTreeNode)value;
@@ -77,17 +80,21 @@
     }
 
     if(st!=null){
-      st.nextToken();
+      String date=st.nextToken();
       st.nextToken();
       String state=st.nextToken();
       for (int i=0 ; i<states.length ; i++){
         if (state.equals(states[i])){
           if (lvl==4){
-            setIcon(ii[i]);
+	    if(!date.equals("??/??/??")){
+	      setIcon(ii[i]);
+	    }else{
+	      setIcon(iiOldLog);
+	    }
 	    setFont(new Font("Monospaced",Font.PLAIN,10));
           }else{ 
             StringTokenizer st2 = new StringTokenizer(((DefaultMutableTreeNode)dmtn.getFirstChild()).toString()," | ");
-            setToolTipText("<html><B>IP = </B>"+/*IP=<ip> Profil=<port>/<profil>*/dmtn.getParent().getParent()+"<B> Profil =</B>"+dmtn.getParent()+"<br><B>Bundle : </B>"+/*Bundle : Id=<bundleId> : <bundleSymbolicName>*/dmtn+"<br><B>Date : </B>"+/*<date> - <time>*/st2.nextToken()+" - "+st2.nextToken()+"<br><B>State : </B>"+/*<bundleState>*/st2.nextToken()+"<B><br>Event "+/*Event <eventNumber> : <logLevel> : <message>*/dmtn.getChildCount()+" : "+st2.nextToken()+" : "+st2.nextToken()+"</B></html>");
+            setToolTipText("<html><B>IP = </B>"+/*IP=<ip> Profil=<port>/<profil>*/dmtn.getParent().getParent()+"<B> Profil =</B>"+dmtn.getParent()+"<br><B>Bundle : </B>"+/*Bundle : Id=<bundleId> : <bundleSymbolicName>*/dmtn+"<br><B>Date : </B>"+/*<date> - <time>*/st2.nextToken()+" - "+st2.nextToken()+"<br><B>State : "+/*<bundleState>*/st2.nextToken()+"<br>Event "+/*Event <eventNumber> : <logLevel> : <message>*/dmtn.getChildCount()+" : "+st2.nextToken()+" : "+st2.nextToken()+"</B></html>");
             setBackground(colors[i]);
           }
 	break;

Modified: incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtable.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtable.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtable.java (original)
+++ incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtable.java Thu Oct 12 04:54:37 2006
@@ -153,7 +153,7 @@
       try{
         MBeanServerConnection mbs=(MBeanServerConnection)e.getNewValue();
         if (nodes.get(mbs)==null){
-	  System.out.println("Ajout d'un listener " +mbs);
+	  //System.out.println("Ajout d'un listener " +mbs);
           ((MBeanServerConnection)e.getNewValue()).addNotificationListener(new ObjectName("OSGI:name=Remote Logger"), this, null, e.getOldValue());
           nodes.put(mbs, "ok");
         }
@@ -164,18 +164,24 @@
   }
 
   public void handleNotification(Notification notification, Object handback) {
-    StringTokenizer st = new StringTokenizer(notification.getMessage(),":");
-    Date d=new Date(notification.getTimeStamp());
-    //DateFormat dateFormat = new SimpleDateFormat("hh'h'mm dd-MM-yy");
-    DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM); // utilise le format de date local
-    DateFormat df2 = DateFormat.getDateInstance(DateFormat.SHORT);
+    StringTokenizer st = new StringTokenizer(notification.getMessage(),"*");
+    
+    long ts=notification.getTimeStamp();
+    String date="??/??/??";
+    String time="??/??/??";
+    if (ts!=0){ // means it's not an old log
+      Date d=new Date(ts);
+      //DateFormat dateFormat = new SimpleDateFormat("hh'h'mm dd-MM-yy");
+      date=DateFormat.getDateInstance(DateFormat.SHORT).format(d);
+      time=DateFormat.getTimeInstance(DateFormat.MEDIUM).format(d);
+    }
     String id=st.nextToken();
     String name=st.nextToken();
     String shortName=name.substring(name.lastIndexOf(".")+1,name.length());
     String state=st.nextToken();
     String lvl=st.nextToken();
     String msg=st.nextToken();
-    Object [] event = new Object []{df2.format(d),df.format(d),handback,id,shortName,state,lvl,msg};
+    Object [] event = new Object []{date,time,handback,id,shortName,state,lvl,msg};
 				    
     this.insertRow(0,event); 
     this.fireTableRowsInserted(0, 0);

Modified: incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtree.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtree.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtree.java (original)
+++ incubator/felix/trunk/mosgi.console.component/src/main/java/org/apache/felix/mosgi/console/component/RemoteLogger_jtree.java Thu Oct 12 04:54:37 2006
@@ -61,16 +61,24 @@
 import javax.swing.JFrame;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.TreePath;
-
+import javax.swing.JOptionPane;
 //import org.osgi.service.prefs.Preferences;
 
+import java.awt.event.MouseListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JPopupMenu;
+import javax.swing.JMenuItem;
+
 public class RemoteLogger_jtree extends DefaultTreeModel implements CommonPlugin, NotificationListener{
 
   private MyTree logTree;
+  private MouseListener ml;
+  private TreePath selPath;
   private JPanel jp;
-  private Hashtable nodes=new Hashtable();
   private DefaultMutableTreeNode rootNode=new DefaultMutableTreeNode("root");
   private Hashtable eventName=new Hashtable();
+  private Hashtable nodes=new Hashtable();
 
   public RemoteLogger_jtree (BundleContext bdlCtx){
     super(null);
@@ -84,11 +92,31 @@
     JtreeCellRenderer treeCellRenderer=new JtreeCellRenderer(bdlCtx);
     this.logTree.setCellRenderer(treeCellRenderer);
     this.logTree.setLargeModel(true);
-    this.logTree.setToggleClickCount(1); 
+    this.logTree.setToggleClickCount(2); 
     this.logTree.setRootVisible(false);
     // this create an invisible tree even if I use *expand* so...
     // I use expand after the first insert into the tree
-  
+
+    MouseListener ml = new MouseAdapter() {
+      public void mousePressed(MouseEvent e) {
+        int selRow = logTree.getRowForLocation(e.getX(), e.getY());
+        selPath = logTree.getPathForLocation(e.getX(), e.getY());
+        if(selRow != -1 & e.getButton()>1) {
+	  String nodeString="\""+((DefaultMutableTreeNode) selPath.getLastPathComponent()).getUserObject()+"\"";
+	  JMenuItem itemm=new JMenuItem("Delete logs "+nodeString+"");
+	  itemm.addActionListener(new ActionListener(){
+            public void actionPerformed(ActionEvent e){
+	      removeNodeFromParent((DefaultMutableTreeNode) selPath.getLastPathComponent());
+	    }
+	  });
+	  JPopupMenu jpopup=new JPopupMenu();
+	  jpopup.add(itemm);
+          jpopup.show(jp, e.getX(), e.getY());
+        }
+      }
+    };
+    this.logTree.addMouseListener(ml);
+
     jp.add(new JScrollPane(logTree), BorderLayout.CENTER);    
     
     eventName.put(new Integer(Bundle.ACTIVE),     "ACTIVE     ");
@@ -112,16 +140,24 @@
   public void registerServicePlugin(){}
   public void unregisterServicePlugin(){}
 /* fin a supprimer */
-
-  
+ 
   public void propertyChange(PropertyChangeEvent e){
+    //System.out.println("PCE : "+e.getPropertyName());
     if (e.getPropertyName().equals(Plugin.NEW_NODE_CONNECTION)){
       try{
         MBeanServerConnection mbs=(MBeanServerConnection)e.getNewValue();
         if (nodes.get(mbs)==null){
-System.out.println("Ajout d'un listener " +mbs);
-          ((MBeanServerConnection)e.getNewValue()).addNotificationListener(new ObjectName("OSGI:name=Remote Logger"), this, null, e.getOldValue());
+          //System.out.println("RemoteLogger_jtree add a notification listener on this Remote Logger : "+mbs);
+	  ((MBeanServerConnection)e.getNewValue()).addNotificationListener(new ObjectName("OSGI:name=Remote Logger"), this, null, e.getOldValue());
           nodes.put(mbs, "ok");
+          if(JOptionPane.showConfirmDialog(null,"Do you want \""+this.getName()+"\" ask old log to this gateway :\n"+((String) e.getOldValue())+" ?")==JOptionPane.YES_OPTION) {
+            try {
+	      //System.out.println("   => mosgi.console.component.RemoteLoger_jtree gonna ask the oldLog");
+	      mbs.invoke(new ObjectName("OSGI:name=Remote Logger"), "sendOldLog", new Object[]{}, new String[]{});
+	    } catch (Exception ee) {
+	      System.out.println("   => mosgi.console.component.RemoteLoger_jtree : getOldLog : "+ee);
+	    }
+	  }
         }
       }catch(Exception ex){
         ex.printStackTrace();
@@ -129,59 +165,72 @@
     }
   }
 
-  private DefaultMutableTreeNode createIfNeed(String nodeToCreateAndGet, DefaultMutableTreeNode parent){
+  private DefaultMutableTreeNode createIfNeed(String nodeToCreateAndGet, DefaultMutableTreeNode parent, boolean isOldLog){
     int childNumber=this.getChildCount(parent);
     DefaultMutableTreeNode theNode=null;
     for (int i=0 ; i<childNumber ; i++){ // is node even exist ?
       String string_pool=((DefaultMutableTreeNode)(this.getChild(parent, i))).toString();
       if (string_pool.equals(nodeToCreateAndGet)){
         theNode=(DefaultMutableTreeNode) (this.getChild(parent, i));
-          break;
+        break;
       }
     }
     if (theNode==null){ // create the node
-      theNode=new DefaultMutableTreeNode(nodeToCreateAndGet);	
-      // Unable to set tree expand whithout a first node
+      theNode=new DefaultMutableTreeNode(nodeToCreateAndGet);
+      // Unable to set tree expand whithout a first node:
       if (rootNode.getChildCount()==0){
         this.insertNodeInto(theNode, parent, 0);
         logTree.expandPath(new TreePath(rootNode.getPath()));
-      }else{
-        this.insertNodeInto(theNode, parent, 0);
+      } else{
+        if(isOldLog){
+          this.insertNodeInto(theNode, parent, parent.getChildCount());
+        } else {
+          this.insertNodeInto(theNode, parent, 0);
+        }
       }
     }
-  return theNode;
+    return theNode;
   }
 
   public void handleNotification(Notification notification, Object handback) {
     StringTokenizer st=new StringTokenizer(handback.toString(),":");
+    boolean isOldLog=false;
     String ip=st.nextToken();
     String ref=st.nextToken();
     
-    st = new StringTokenizer(notification.getMessage(),":");
-    Date timeDate=new Date(notification.getTimeStamp());
-    //DateFormat dateFormat = new SimpleDateFormat("hh'h'mm dd-MM-yy");
-    DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM); // use local date format 
-    DateFormat df2 = DateFormat.getDateInstance(DateFormat.SHORT);
-    String time=df.format(timeDate);
-    String date=df2.format(timeDate);
-
+    st = new StringTokenizer(notification.getMessage(),"*");
+    long ts=notification.getTimeStamp();
+    String time="??:??:??";
+    String date="??/??/??";
+    if (ts==0) {
+      isOldLog=true;
+    }
+    if (!isOldLog){
+      Date timeDate=new Date(ts);
+      //DateFormat dateFormat = new SimpleDateFormat("hh'h'mm dd-MM-yy");
+      DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM); // use local date format
+      DateFormat df2 = DateFormat.getDateInstance(DateFormat.SHORT);
+      time=df.format(timeDate);
+      date=df2.format(timeDate);
+    }
     String id=st.nextToken();
     String name=st.nextToken();
     String idname=new String(id+" : "+name);
     String state=""+eventName.get(new Integer((int) Integer.parseInt(st.nextToken())));
     String lvl=st.nextToken();
     String msg=st.nextToken();
-
     // Get and maybe create parents nodes : ip, ref, idname
-    DefaultMutableTreeNode dmtn_ip=createIfNeed(ip, rootNode);
-    DefaultMutableTreeNode dmtn_ref=createIfNeed(ref, dmtn_ip);
-    DefaultMutableTreeNode dmtn_idname=createIfNeed(idname, dmtn_ref);
-
+    DefaultMutableTreeNode dmtn_ip=createIfNeed(ip, rootNode, isOldLog);
+    DefaultMutableTreeNode dmtn_ref=createIfNeed(ref, dmtn_ip, isOldLog);
+    DefaultMutableTreeNode dmtn_idname=createIfNeed(idname, dmtn_ref, isOldLog);
     // insert the leaf with message under id/ref/idname
-    DefaultMutableTreeNode dmtn=new DefaultMutableTreeNode(date+" | "+time+" | "+state+" | "+lvl+" | "+msg,false); 
-    this.insertNodeInto(dmtn, dmtn_idname, 0);
-
-    this.reload(dmtn_idname);
+    DefaultMutableTreeNode dmtn=new DefaultMutableTreeNode(date+" | "+time+" | "+state+" | "+lvl+" | "+msg,false);
+    if (isOldLog){
+      this.insertNodeInto(dmtn, dmtn_idname, dmtn_idname.getChildCount());
+    } else{
+      this.insertNodeInto(dmtn, dmtn_idname, 0);
     }
+    this.reload(dmtn_idname);
+  }
   
 }

Added: incubator/felix/trunk/mosgi.console.component/src/main/resources/icons/OLDLOG.gif
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.component/src/main/resources/icons/OLDLOG.gif?view=auto&rev=463216
==============================================================================
Binary file - no diff available.

Propchange: incubator/felix/trunk/mosgi.console.component/src/main/resources/icons/OLDLOG.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Activator.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Activator.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Activator.java (original)
+++ incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Activator.java Thu Oct 12 04:54:37 2006
@@ -41,12 +41,13 @@
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 
-
 public class Activator implements BundleActivator {
   protected BundleContext m_context = null;
+
   protected ArrayList m_pluginList = null;
   protected ArrayList m_commonpluginList = null; //TODO To I need this table ?
   private EventListenerList m_listenerList = null;
+  
   private JFrame m_frame = null;
   private NodesTree nodesTree=null;
 
@@ -71,6 +72,9 @@
               if(svcObj instanceof CommonPlugin){
                 m_commonpluginList.add(svcObj);
                 firePropertyChangedEvent(CommonPlugin.COMMON_PLUGIN_ADDED, null, svcObj);
+		//evite d'attendre le Thread pr que le common plugin remotelogger_jtree/jtable chope le MBean remote logger :
+		//nodesTree.tryToConnectAllNodes();
+		//createDefaultNodes(false);
               }else if (svcObj instanceof Plugin){
                 m_pluginList.add(svcObj);
                 firePropertyChangedEvent(Plugin.PLUGIN_ADDED, null, svcObj);
@@ -154,7 +158,8 @@
     m_frame.setVisible(true);
   }
 
-  private synchronized void initializePlugins() {
+  private synchronized void initializePlugins() { // Never used ?
+    System.out.println("??? private synchronized void initializePlugins() ???");
     try {
       // Get all model services.
       Object svcObj=null;
@@ -166,6 +171,7 @@
           if (!m_pluginList.contains(svcObj)) {
             m_pluginList.add(svcObj);
             firePropertyChangedEvent(Plugin.PLUGIN_ADDED, null, (Plugin)svcObj);
+	    //this.nodesTree.valueChanged(null);
           }
         }
       }
@@ -177,6 +183,7 @@
           if (!m_commonpluginList.contains(svcObj)) {
             m_commonpluginList.add(svcObj);
             firePropertyChangedEvent(CommonPlugin.COMMON_PLUGIN_ADDED, null, (CommonPlugin)svcObj);
+	    //this.nodesTree.valueChanged(null);
           }
         }
       }
@@ -196,9 +203,9 @@
     }
   }
 
-  //
-  // Event methods.
-  //
+  //////////////////////////////
+  // Event methods.           //
+  //////////////////////////////
   public void addPropertyChangeListener(PropertyChangeListener l) {
     m_listenerList.add(PropertyChangeListener.class, l);
   }
@@ -209,12 +216,23 @@
 
   public void firePropertyChangedEvent(String name, Object oldValue, Object newValue) {
     PropertyChangeEvent event = null;
-
     // Guaranteed to return a non-null array
     Object[] listeners = m_listenerList.getListenerList();
 
+/* a supprimer de ici
+    String mb="";
+    //System.out.println("name="+name);
+    if(name.equals("pluggin_added") | name.equals("pluggin_removed")){
+      mb="java.awt.Component";
+    } else {
+      mb=newValue.toString();
+      mb=mb.substring((mb.indexOf("$")==-1)?0:mb.indexOf("$")+1,mb.length());
+    }
+    System.out.println("console.gui whill firePCE "+(int)(listeners.length/2)+"* : (this,"+name+","+oldValue+","+mb+")");
+/* a ici */
+
     // Process the listeners last to first, notifying
-    // those that are interested in this event
+    // those that are interested in this event 
     for (int i = listeners.length - 2; i >= 0; i -= 2) {
       if (listeners[i] == PropertyChangeListener.class) {
         // Lazily create the event:

Modified: incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java (original)
+++ incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java Thu Oct 12 04:54:37 2006
@@ -38,12 +38,8 @@
     this.nodesTree=nt;
   }
 
-	public Component getTreeCellRendererComponent(JTree tree, Object value,
-			boolean sel, boolean expanded, boolean leaf, int row,
-			boolean hasFocus) {
-
-		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
-				row, hasFocus);
+  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
     String val=value.toString();
     if (!val.equals(NodesTree.TOP_NAME)){ 
       if (nodesTree.isNodeConnected(val)){

Modified: incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodePanel.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodePanel.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodePanel.java (original)
+++ incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodePanel.java Thu Oct 12 04:54:37 2006
@@ -48,152 +48,149 @@
 
 public class NodePanel extends JTabbedPane implements PropertyChangeListener, ChangeListener {
   //private String repo;
-  private Activator m_activator = null;
-  private BundleContext m_context = null;
+  private Activator a=null;
+  private BundleContext m_context=null;
   
-  private Hashtable pluginList = null;
+  private Hashtable pluginList=null;
 
   public NodePanel(Activator activator, BundleContext context){
-    m_context = context;
-    m_activator = activator;
-    m_activator.addPropertyChangeListener(this);
-    this.pluginList = new Hashtable();
+    this.m_context=context;
+    this.a=activator;
+    a.addPropertyChangeListener(this);
+    this.pluginList=new Hashtable();
     //repo = m_context.getProperty("mosgi.jmxconsole.repository");
     this.addChangeListener(this);
   }
 
   //////////////////////////////////////
-  // ChangeListener Implementation
+  // ChangeListener Implementation    //
   //////////////////////////////////////
   public void stateChanged(ChangeEvent e){
-//   System.out.println("coucou => "+((JTabbedPane)e.getSource()).getSelectedIndex()+":"+((JTabbedPane)e.getSource()).getSelectedComponent().getName());
-   if (this.getSelectedComponent()!=null){
-     m_activator.firePropertyChangedEvent(Plugin.PLUGIN_ACTIVATED, null, this.getSelectedComponent().getName());
-   }
+    //   System.out.println("coucou => "+((JTabbedPane)e.getSource()).getSelectedIndex()+":"+((JTabbedPane)e.getSource()).getSelectedComponent().getName());
+    if (this.getSelectedComponent()!=null){
+      a.firePropertyChangedEvent(Plugin.PLUGIN_ACTIVATED, null, this.getSelectedComponent().getName());
+    }
   }
 
-
   public void propertyChange(PropertyChangeEvent event) {
     if (event.getPropertyName().equals(Plugin.PLUGIN_ADDED)) {
-      Plugin cp = (Plugin) event.getNewValue();
+      Plugin cp=(Plugin) event.getNewValue();
       this.add(cp.getName(), cp.getGUI());
-System.out.println("add gui "+cp.getName()+" :: "+cp.getGUI());      
-      this.m_activator.addPropertyChangeListener(cp);
-      this.pluginList.put(cp.pluginLocation(), cp);
-      
+      System.out.println("Add gui \""+cp.getName()+"\" into NodePanel"/*+" :: "+cp.getGUI()*/);      
+      this.a.addPropertyChangeListener(cp);
+      this.pluginList.put(cp.pluginLocation(), cp); 
     }else if(event.getPropertyName().equals(Plugin.PLUGIN_REMOVED)) {
       Plugin cp = (Plugin) event.getNewValue();
       this.remove(cp.getGUI());
-      this.m_activator.removePropertyChangeListener(cp);
-//			this.pluginList.remove(cp.pluginLocation());
-      
+      this.a.removePropertyChangeListener(cp);
+      //	this.pluginList.remove(cp.pluginLocation());
     }else if(event.getPropertyName().equals(Plugin.EMPTY_NODE)) {
-System.out.println("******* Debug No node selected");
+      System.out.println("******* Debug No node selected");
       this.clean();
     }else if (event.getPropertyName().equals(Plugin.NEW_NODE_SELECTED)) {
-//System.out.println("Event NEW_NODE_SELECTED");
-    /* Update the tabs (Plugin) in the JTabbedPane (NodePanel) */
+      //System.out.println("Event NEW_NODE_SELECTED");
+      /* Update the tabs (Plugin) in the JTabbedPane (NodePanel) */
       MBeanServerConnection mbsc = (MBeanServerConnection)event.getNewValue();
       try {
 	this.clean();
-
         Set ons = mbsc.queryNames( null, null );
+        String msg="";
         for( Iterator i=ons.iterator(); i.hasNext(); ) {
-          ObjectName name = ( ObjectName )i.next();
-System.out.println("Queried name: "+name.toString());
+	  ObjectName name = ( ObjectName )i.next();
+          msg="Queried name: "+name.toString();
           if ( "TabUI".equals(name.getDomain()) ) {
-System.out.println("New tab: "+name.toString());
+            msg+=" New tab: "+name.toString();
 	    /* Get the plugin implementation via a bundle */
 	    String tabBundle = (String) mbsc.getAttribute(name, "BundleName");
-System.out.println("Bundle name for current Plugin: "+tabBundle);
+            msg+=" Bundle name for current Plugin: "+tabBundle;
 	    if (tabBundle!=null){
               Plugin p = (Plugin) this.pluginList.get(tabBundle);
               if (p == null){
   	          Bundle b = m_context.installBundle(tabBundle);
 		  b.start();
-System.out.println("Bundle started");
-//Thread.sleep(5000);
-               }else{
-System.out.println("register service plugin: " + p);
-                 p.registerServicePlugin();
-               }
-
-//             ServiceReference[] sr = b.getRegisteredServices();
-//             System.out.println(sr);
-//             Plugin p;
-//             for (int j=0 ; j < sr.length ; j++) {
-//               p=(Plugin)m_context.getService(sr[j]);
-//               this.add(p.getName(), p.getGUI());
-//               this.m_activator.addPropertyChangeListener(p);
-//             }
-
-//               System.out.println("Delegation for this");
-//               printcl = this.getClass().getClassLoader();
-//               while (printcl != null) {
-//                 System.out.println(printcl);
-//                 printcl = printcl.getParent();
-//               }
-//               System.out.println("{bootstrap loader}");
-//               System.out.println("");
+                  System.out.println(msg+" Bundle started");
+                  //Thread.sleep(5000);
+              }else{
+                System.out.println(msg+" Register service plugin: " + p);
+                p.registerServicePlugin();
+              }
+
+//            ServiceReference[] sr = b.getRegisteredServices();
+//            System.out.println(sr);
+//            Plugin p;
+//            for (int j=0 ; j < sr.length ; j++) {
+//              p=(Plugin)m_context.getService(sr[j]);
+//              this.add(p.getName(), p.getGUI());
+//              this.a.addPropertyChangeListener(p);
+//            }
+
+//            System.out.println("Delegation for this");
+//            printcl = this.getClass().getClassLoader();
+//            while (printcl != null) {
+//              System.out.println(printcl);
+//              printcl = printcl.getParent();
+//            }
+//            System.out.println("{bootstrap loader}");
+//            System.out.println("");
 
-					/* Get the tab object */
-//             Object tabObj = mbsc.getAttribute(name, "Tab");
+              /* Get the tab object */
+//            Object tabObj = mbsc.getAttribute(name, "Tab");
 // 
-//               System.out.println("Delegation for tabObj: " + tabObj);
-//               printcl = tabObj.getClass().getClassLoader();
-//               while (printcl != null) {
-//                 System.out.println(printcl);
-//                 printcl = printcl.getParent();
-//               }
-//               System.out.println("{bootstrap loader}");
-//               System.out.println("");
+//            System.out.println("Delegation for tabObj: " + tabObj);
+//            printcl = tabObj.getClass().getClassLoader();
+//            while (printcl != null) {
+//              System.out.println(printcl);
+//              printcl = printcl.getParent();
+//            }
+//            System.out.println("{bootstrap loader}");
+//            System.out.println("");
   
-//          System.out.println("tabObj.getName(): " + ((fr.inria.ares.managedelements.testprobe.tab.TestProbeTabUI) tabObj).getName());
+//            System.out.println("tabObj.getName(): " + ((fr.inria.ares.managedelements.testprobe.tab.TestProbeTabUI) tabObj).getName());
               
-          /* Cast the tab */  
+              /* Cast the tab */  
 //            Plugin tab = (Plugin)tabObj;
-          /* register the tab on the JTabbedPane */
+              /* register the tab on the JTabbedPane */
 //            this.add(tab.getName(), tab.getGUI());
             }else{
-	      System.out.println("No "+tabBundle+" property defined. I cannot install "+tabBundle+" tab");
+	      System.out.println(msg+" No "+tabBundle+" property defined. I cannot install "+tabBundle+" tab");
             }
           }
         }
-        m_activator.firePropertyChangedEvent(Plugin.NEW_NODE_READY, null, mbsc);
-        m_activator.firePropertyChangedEvent(Plugin.PLUGIN_ACTIVATED, null, this.getComponentAt(0).getName());
-
+        a.firePropertyChangedEvent(Plugin.NEW_NODE_READY, null, mbsc);
+        a.firePropertyChangedEvent(Plugin.PLUGIN_ACTIVATED, null, this.getComponentAt(0).getName());
 
       } catch (MBeanException e) {
-          System.err.println(e);
-//        } catch (MalformedObjectNameException e) {
-//          System.err.println(e);
+        System.err.println("MBeanException : "+e);
+//    } catch (MalformedObjectNameException e) {
+//      System.err.println(e);
       } catch (AttributeNotFoundException e) {
-        System.err.println(e);
+        System.err.println("AttributeNotFoundException : "+e);
       } catch (InstanceNotFoundException e) {
-        System.err.println(e);
+        System.err.println("InstanceNotFoundException : "+e);
       } catch (ReflectionException e) {
-        System.err.println(e);
+        System.err.println("ReflectionException : "+e);
       } catch (IOException e) {
-        System.err.println(e);
+        System.err.println("IOException : "+e);
       } catch (BundleException e) {
-        System.err.println(e);
+        System.err.println("BundleException : "+e);
+      } catch (Exception e) {
+        System.err.println("Exception : "+e);
       }
-      
-//       catch (java.lang.InterruptedException e) {
-// 	      System.err.println(e);
-//       }
+//    } catch (java.lang.InterruptedException e) {
+//      System.err.println(e);
+//    }
     }
   }
 
   private void clean(){
     this.removeAll();
     for ( Iterator i=pluginList.keySet().iterator(); i.hasNext();) {
-     Object o=i.next();
-     try {
-      ((Plugin) pluginList.get(o)).unregisterServicePlugin();
-     }catch(Exception e){
-      System.out.println("INFO Something went wrong when unregistering the Plugin. Please control the beavior of the unregisterServicePlugin function of this tab"+o);
-     }
+      Object o=i.next();
+      try {
+        ((Plugin) pluginList.get(o)).unregisterServicePlugin();
+      } catch(Exception e){
+        System.out.println("INFO Something went wrong when unregistering the Plugin. Please control the beavior of the unregisterServicePlugin function of this tab"+o);
+      }
     }
   }
 

Modified: incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java (original)
+++ incubator/felix/trunk/mosgi.console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java Thu Oct 12 04:54:37 2006
@@ -18,8 +18,14 @@
  */
 package org.apache.felix.mosgi.console.gui;
 
-import java.awt.GridLayout;
-import java.util.Hashtable;
+//import java.awt.GridLayout;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JOptionPane;
+
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTree;
@@ -28,10 +34,14 @@
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeSelectionModel;
+import javax.swing.tree.TreePath;
+import javax.swing.JButton;
 
+import java.util.Hashtable;
+import java.util.Enumeration;
 import org.osgi.framework.BundleContext;
-
 import org.apache.felix.mosgi.console.ifc.Plugin;
+import org.apache.felix.framework.cache.BundleCache;
 
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -43,91 +53,105 @@
 import javax.management.remote.JMXServiceURL;
 import javax.management.remote.JMXConnectionNotification;
 
-import org.apache.felix.framework.cache.BundleCache;
+//import javax.jmdns.ServiceInfo;
 
+public class NodesTree extends JPanel implements TreeSelectionListener, NotificationListener, ActionListener {
 
-public class NodesTree extends JPanel implements TreeSelectionListener, NotificationListener {
   static String TOP_NAME="Servers";
-  static int POOLING_TIME=10000;
-
-	protected JTree tree;
-  private DefaultTreeModel dtm;
-	private Hashtable connectedNodes = new Hashtable();
-	private Hashtable jmxConnectors = new Hashtable();
-	private DefaultMutableTreeNode top = null;
-  protected boolean cont=true;
+  static int POOLING_TIME=2000;
+  static String JMX_SERVICE_URL="service:jmx:rmi:///jndi/rmi://";
+  private static boolean useSystemLookAndFeel = false;
   
-	private static boolean useSystemLookAndFeel = false;
-
   private Activator a;
   private BundleContext bc;
-  private PoolingThread pt;
-  protected Thread poolThread;
+  
+  protected JTree tree;
+  private DefaultTreeModel dtm;
+  private DefaultMutableTreeNode top = null;
   private NodeCellRenderer ncr;
-  private Hashtable nodes=new Hashtable();
+  private JButton addNodeButton;
+  private JButton removeNodeButton;
 
+  private Hashtable connectedNodes = new Hashtable();
+  private Hashtable jmxConnectors = new Hashtable();
+  private Hashtable nodes=new Hashtable();
+ 
+  protected boolean cont=true; 
+  private PoolingThread pt;
+  protected Thread poolThread;
+  
+  private boolean isAllNodesConnected=false;
 
-	public NodesTree(Activator a,BundleContext bc) {
-		super(new GridLayout(1, 0));
+  public NodesTree(Activator a,BundleContext bc) {
+    super(new BorderLayout());
+    //super(new GridLayout(1, 0));
     this.a=a;
     this.bc=bc;
     this.pt=new PoolingThread();
     
-		System.setProperty("java.security.policy", "client.policy");
-		top = new DefaultMutableTreeNode(NodesTree.TOP_NAME);
+    System.setProperty("java.security.policy", "client.policy");
+    top=new DefaultMutableTreeNode(NodesTree.TOP_NAME);
     dtm=new DefaultTreeModel(top);
-		tree = new JTree(dtm);
+    tree=new JTree(dtm);
     tree.setCellRenderer(ncr=new NodeCellRenderer(bc,this));
-		tree.addTreeSelectionListener(this);
-		tree.getSelectionModel().setSelectionMode(
-				TreeSelectionModel.SINGLE_TREE_SELECTION);
+    tree.addTreeSelectionListener(this);
+    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
 
-		JScrollPane treeView = new JScrollPane(tree);
-		add(treeView);
-	}
+    JScrollPane treeView=new JScrollPane(tree);
+    add(createButtonPanel(), BorderLayout.NORTH);
+    add(treeView, BorderLayout.CENTER);
+  }
 
   public void runDiscovery(){
-	this.createDefaultNodes(true);
+    this.createDefaultNodes();
     poolThread=new Thread(this.pt);
     poolThread.start();
   }
 
+
+
+
   //////////////////////////////////////////////////////
-  //               TreeSelectionListener //
+  //               TreeSelectionListener              //
   //////////////////////////////////////////////////////
-	public void valueChanged(TreeSelectionEvent e) {
-//    System.out.println("coucou, value changed");
-		DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
-	  String selectedNode=(String)node.getUserObject();
-    if (!selectedNode.equals(NodesTree.TOP_NAME)){
-      Object mbsc=connectedNodes.get(selectedNode);
-      if (mbsc!=null){
-        a.firePropertyChangedEvent(Plugin.NEW_NODE_SELECTED, selectedNode, mbsc);
-      }else{
-        a.firePropertyChangedEvent(Plugin.EMPTY_NODE, null, "null");
+  public void valueChanged(TreeSelectionEvent e) {
+    //System.out.println("Value changed : e="+e);
+    DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
+    if (node!=null) {
+      String selectedNode=(String)node.getUserObject();
+      if (!selectedNode.equals(NodesTree.TOP_NAME)){
+        Object mbsc=connectedNodes.get(selectedNode);
+        if (mbsc!=null){
+	  //tryToConnectAllNodes();
+	  //createDefaultNodes(false);
+          a.firePropertyChangedEvent(Plugin.NEW_NODE_SELECTED, selectedNode, mbsc);
+        }else{
+          a.firePropertyChangedEvent(Plugin.EMPTY_NODE, null, "null");
+        }
       }
     }
-	}
+  }
 
   ////////////////////////////////////////////////////
   //            NotificationListener                //
   ////////////////////////////////////////////////////
   public void handleNotification(Notification notification, Object handback) {
-//    System.out.println("Connection ==> "+notification.getMessage()+":"+((JMXConnectionNotification)notification).getConnectionId()+":"+handback);
+    //    System.out.println("Connection ==> "+notification.getMessage()+":"+((JMXConnectionNotification)notification).getConnectionId()+":"+handback);
     if ( !JMXConnectionNotification.OPENED.equals(notification.getType()) ){
       this.disconnectFromNode((String)handback);
       tree.treeDidChange();
+      isAllNodesConnected=false;
     }
   }
   
   ////////////////////////////////////////////////////
-  //            Friend methods //
-  ///////////////////////////////////////////////////
-  void stop(){
+  //            Friend methods                      //
+  ////////////////////////////////////////////////////
+  void stop(){ //Never used ... ???
     this.cont=false;
   }
 
-  boolean isNodeConnected(String s){
+  boolean isNodeConnected(String s){//Never used ... ???
     if (this.connectedNodes.get(s)==null){
       return false;
     }else{
@@ -135,80 +159,80 @@
     }
   }
 
+  public void actionPerformed(ActionEvent e) {
+    Object object = e.getSource();
+    if (object==addNodeButton) {
+      String connString = JOptionPane.showInputDialog("Please input a connection string : ", "127.0.0.1:1099/vosgi");
+      TreePath tp=tree.getSelectionPath();
+      if (connString!=null) {
+	createTreeNode(connString,null,null);
+	dtm.reload(top);
+	isAllNodesConnected=false;
+	tree.setSelectionPath(tp);
+      }
+    } else if (object==removeNodeButton) {
+      DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
+      String connString=(String) node.getUserObject();
+      if (connString!=null){
+        if (!node.equals(top)){
+	  if(JOptionPane.showConfirmDialog(null,"Sure we remove \""+connString+"\" node ?")==JOptionPane.YES_OPTION) {
+	    if (top.getChildCount()>1){
+              disconnectFromNode(connString);
+	      dtm.removeNodeFromParent(node);
+	      System.out.println("Remove node : "+(String) (node.getUserObject()));
+	    }
+          }
+	}
+      }
+    }
+  }
+
   ///////////////////////////////////////////////////
-  //           Private part //
+  //           Private part                        //
   ///////////////////////////////////////////////////
-  protected void createDefaultNodes(boolean createTreeNode) {
-    String profile;
-    String rmiPort;
-    String ip;
-    
-    int i=1;
-    profile=bc.getProperty("mosgi.jmxconsole.profile." + i);
-
-    while (profile!=null){
-      rmiPort=bc.getProperty("mosgi.jmxconsole.rmiport."+profile);
-      if (rmiPort==null){rmiPort="1099";}
-      String virtual=bc.getProperty("mosgi.jmxconsole.core."+profile);
-      ip=bc.getProperty("mosgi.jmxconsole.ip." + i);
-      String connString=ip+":"+rmiPort+"/"+profile;
-      if (createTreeNode){
-        DefaultMutableTreeNode dmtn=new DefaultMutableTreeNode(connString);
-        DefaultMutableTreeNode parent=top;
-        if (virtual==null){
-          nodes.put(connString, dmtn);
-        }else{
-          String parentString=ip+":"+virtual;
-          parent=(DefaultMutableTreeNode)nodes.get(parentString);
+  protected void tryToConnectAllNodes(){
+    //boolean oldTreeState=isAllNodesConnected;
+    isAllNodesConnected=true;
+    String connString="";
+    Enumeration enu=top.breadthFirstEnumeration();
+    while (enu.hasMoreElements()) {
+      DefaultMutableTreeNode dmtn_tmp=(DefaultMutableTreeNode) enu.nextElement();
+      if (dmtn_tmp!=top) {
+        connString=(String) dmtn_tmp.getUserObject();
+        if (!this.connectToNode(connString)) {
+          isAllNodesConnected=false;
         }
-        parent.add(dmtn);
       }
-      this.connectToNode(connString);
-      i++;
-      profile=bc.getProperty("mosgi.jmxconsole.profile." + i);
     }
-      
-    if (i==1){
-      try{
-        System.out.println("No property mosgi.jmxconsole.profile., managing local profile");
-		String prof=bc.getProperty(BundleCache.CACHE_PROFILE_PROP);
-    	if (prof==null){
-	      prof=System.getProperty(BundleCache.CACHE_PROFILE_PROP);
-		}
-        String connString=java.net.InetAddress.getLocalHost().getHostAddress()+":1099/"+prof;
-        if (createTreeNode){
-          top.add(new DefaultMutableTreeNode(connString));
+    /*Enumeration dmtns_std=top.children();
+    while (dmtns_std.hasMoreElements()){
+      DefaultMutableTreeNode dmtn_std=(DefaultMutableTreeNode) dmtns_std.nextElement();
+      connString=(String) dmtn_std.getUserObject();
+      //System.out.println("   -connectToNode("+connString+")");
+      if (!this.connectToNode(connString)) {
+        isAllNodesConnected=false;
+      }
+      Enumeration dmtns_virtual=dmtn_std.children();
+      while (dmtns_virtual.hasMoreElements()){
+        DefaultMutableTreeNode dmtn_virtual=(DefaultMutableTreeNode) dmtns_virtual.nextElement();
+        connString=(String) dmtn_virtual.getUserObject();
+	//System.out.println("      -connectToNode("+connString+")");
+        if (!this.connectToNode(connString)) {
+          isAllNodesConnected=false;
         }
-//        this.connectToNode(connString);
-      }catch(Exception e){
-        e.printStackTrace();
       }
-    }
+    }*/
+    //if(oldTreeState!=isAllNodesConnected){
+    //  System.out.println("AllNodesConnected="+isAllNodesConnected);
+    //}
   }
 
-  private void disconnectFromNode(String connString){
-    JMXConnector jmxc=(JMXConnector)this.jmxConnectors.remove(connString);
-    MBeanServerConnection mbscl=(MBeanServerConnection)this.connectedNodes.remove(connString);
-    try{
-      jmxc.removeConnectionNotificationListener(this);
-      //mbscl.removeNotificationListener(new ObjectName("OSGI:name=OSGi
-      // Server"), this); // Does not work since the connexion is lost !!
-      jmxc.close();
-      a.firePropertyChangedEvent(Plugin.EMPTY_NODE, null, "null");
-    }catch (Exception e){
-      e.printStackTrace();
-    }
-    jmxc=null;
-    mbscl=null;
-  }
-     
-  private void connectToNode(String connString){
+  private boolean connectToNode(String connString){
     Object ls=this.connectedNodes.get(connString);
     if (ls==null){
-      JMXConnector jmxc = null;
+      JMXConnector jmxc=null;
       try {
-
-        JMXServiceURL surl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + connString);
+        JMXServiceURL surl=new JMXServiceURL(NodesTree.JMX_SERVICE_URL+connString);
 /*
 Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 System.out.println("=====> "+java.util.logging.Logger.getLogger("javax.management.remote.misc"));
@@ -219,39 +243,53 @@
 ch.setLevel(java.util.logging.Level.FINEST);
 java.util.logging.Logger.getLogger("javax.management.remote.misc").addHandler(ch);
 java.util.logging.Logger.getLogger("javax.management.remote.rmi").addHandler(ch);
-*/
-				
+*/				
         jmxc = JMXConnectorFactory.connect(surl);
         MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
         if (mbsc.isRegistered(new ObjectName("OSGI:name=Remote Logger"))){
           jmxc.addConnectionNotificationListener(this, null, connString);
-          mbsc.addNotificationListener(new ObjectName("TabUI:name=OsgiProbes"), this, null, null); //Needed,
-
+          mbsc.addNotificationListener(new ObjectName("TabUI:name=OsgiProbes"), this, null, null); //Needed ???
           this.connectedNodes.put(connString, mbsc);
           this.jmxConnectors.put(connString, jmxc);
           a.firePropertyChangedEvent(Plugin.NEW_NODE_CONNECTION, connString, mbsc);
- System.out.println("Node "+connString+" connected");
+	  // If new connected is the selected one then create a false valueChanged in order to load the NodePanel :
+	  DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); 
+	  if (node!=null) {
+  	    if (connString.equals((String)node.getUserObject())){
+	      this.valueChanged(null);
+            }
+	  }
+	  System.out.println("Node "+connString+" connected");
+	  return true;
         }else {
-System.out.println("The Remote Logger of "+connString+" is not started");
+          System.out.println("The Remote Logger of "+connString+" is not started");
+	  return false;
         }
       }catch(java.io.IOException ex){
-System.out.println("Impossible to connect to "+connString);
+        //System.out.println("Impossible to connect to "+connString);
       }catch(MalformedObjectNameException e){
         e.printStackTrace();
       }catch(Exception e){
-        e.printStackTrace();
+        //e.printStackTrace();
+	System.out.println("gui.NodesTree.connectToNode("+connString+") : "+e);
+	System.out.println("  => Delete this node ? to implement... ?");
+
       }
     }else{
-      a.firePropertyChangedEvent(Plugin.NEW_NODE_CONNECTION, connString, ls);
+      // a.firePCE(NEW_NODE_CONNECTION, connString, ls) inutile maintenant je sais plus pourqouoi ca l'etait d'ailleur ???
+      return true;
     }
+  return false;
   }
 
   protected class PoolingThread implements Runnable{
     public void run(){
       while (cont){
-        createDefaultNodes(false);
-        tree.treeDidChange();
-        try{
+        if (!isAllNodesConnected) {
+	  tryToConnectAllNodes();
+          tree.treeDidChange();
+        } 
+	try{
           Thread.sleep(POOLING_TIME);
         }catch(InterruptedException e){
           e.printStackTrace();
@@ -259,4 +297,101 @@
       }
     }
   }
+
+  private void createTreeNode(String connString, String ip, String virtual){
+    System.out.println("Add a gateway : ip="+ip+" connString="+connString+" virtual="+virtual);
+    DefaultMutableTreeNode dmtn=new DefaultMutableTreeNode(connString);
+    DefaultMutableTreeNode parent=top;
+    if (virtual==null){
+      nodes.put(connString, dmtn);
+    }else{
+      String parentString=ip+":"+virtual;
+      parent=(DefaultMutableTreeNode)nodes.get(parentString);
+    }
+    parent.add(dmtn);
+  }
+
+  protected void createDefaultNodes() {
+    String profile;
+    String rmiPort;
+    String ip;
+    int i=1;
+    profile=bc.getProperty("mosgi.jmxconsole.profile." + i);
+
+    while (profile!=null){
+      rmiPort=bc.getProperty("mosgi.jmxconsole.rmiport."+profile);
+      if (rmiPort==null) {rmiPort="1099";}
+      String virtual=bc.getProperty("mosgi.jmxconsole.core."+profile);
+      ip=bc.getProperty("mosgi.jmxconsole.ip."+i);
+      String connString=ip+":"+rmiPort+"/"+profile;
+      createTreeNode(connString, ip, virtual);
+      i++;
+      profile=bc.getProperty("mosgi.jmxconsole.profile." + i);
+    }
+
+    // Kesako ???
+    if (i==1){
+      try{
+        System.out.println("No property mosgi.jmxconsole.profile., managing local profile");
+	String prof=bc.getProperty(BundleCache.CACHE_PROFILE_PROP);
+    	if (prof==null){
+	  prof=System.getProperty(BundleCache.CACHE_PROFILE_PROP);
+	}
+        String connString=java.net.InetAddress.getLocalHost().getHostAddress()+":1099/"+prof;
+        top.add(new DefaultMutableTreeNode(connString));
+      }catch(Exception e){
+        e.printStackTrace();
+      }
+    }
+  }
+
+  private void disconnectFromNode(String connString){
+    JMXConnector jmxc=(JMXConnector)this.jmxConnectors.remove(connString);
+    MBeanServerConnection mbscl=(MBeanServerConnection)this.connectedNodes.remove(connString);
+    System.out.println("mbscl="+mbscl);
+    if (jmxc!=null) {
+      try{
+        jmxc.removeConnectionNotificationListener(this);
+        //mbscl.removeNotificationListener(new ObjectName("OSGI:name=OSGi
+        // Server"), this); // Does not work since the connexion is lost !!
+        jmxc.close();
+
+        // firePCE Plugin.EMPTY_NODE only if it's the selected one
+        DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); 
+        if (node!=null) {
+	  if (connString.equals((String)node.getUserObject())){
+            a.firePropertyChangedEvent(Plugin.EMPTY_NODE, null, "null");
+	  }
+        }
+      }catch (Exception e){
+        e.printStackTrace();
+      }
+      jmxc=null;
+    }
+    mbscl=null;
+  }
+     
+  private JPanel createButtonPanel(){
+    JPanel buttonPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,2,2));
+    //border...
+    addNodeButton=new MyButton('a', " + ", this, buttonPanel);
+    removeNodeButton=new MyButton('d', " - ", this, buttonPanel);
+    return buttonPanel;
+  }
+
+  static class MyButton extends JButton {
+    private int W =55;
+    private int H = 25;
+
+    public MyButton(char c, String name, NodesTree listener, JPanel panel) {
+      super.setText(name);
+      super.setMnemonic(c);
+      super.setMinimumSize(new Dimension(W, H));
+      super.setPreferredSize(new Dimension(W, H));
+      super.setMaximumSize(new Dimension(W, H));
+      super.addActionListener(listener);
+      panel.add(this);
+    }
+  }
+
 }

Modified: incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/Logger.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/Logger.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/Logger.java (original)
+++ incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/Logger.java Thu Oct 12 04:54:37 2006
@@ -38,6 +38,7 @@
 import javax.management.MalformedObjectNameException;
 
 import java.io.Serializable;
+import java.util.Enumeration;
 
 public class Logger extends NotificationBroadcasterSupport implements LogListener,BundleActivator,ServiceListener, LoggerMBean, Serializable{
 
@@ -58,6 +59,15 @@
   private MBeanServer agent=null;
   private ObjectName remoteLoggerON=null;
 
+//LogerMBean Interface
+  public void sendOldLog(){
+    System.out.println("mosgi.jmx.remoteLogger.Logger : send old log");
+    Enumeration oldLog = this.lrs.getLog();
+    while(oldLog.hasMoreElements()) {
+      logged((LogEntry)(oldLog.nextElement()),true);
+    }
+  }
+
 //ServiceListener Interface
   public void serviceChanged(ServiceEvent serviceevent) {
     ServiceReference servicereference= serviceevent.getServiceReference();
@@ -72,7 +82,7 @@
 	break;
       case ServiceEvent.UNREGISTERING :
         if (as[0].equals(LogReaderService.class.getName())){
-				  this.unRegisterLogReaderService(servicereference);
+	  this.unRegisterLogReaderService(servicereference);
         }else if (as[0].equals(MBeanServer.class.getName())){
           this.unRegisterFromAgent();
         }
@@ -83,13 +93,21 @@
 
 //LogListener Interface
   public void logged(LogEntry log){
-    String reg=new String(":");
+    logged(log, false);
+  }
+  public void logged(LogEntry log, boolean oldLog){
+    String reg=new String("*");
     StringBuffer message=new StringBuffer();
     //System.out.print("mosgi.jmx.remotelogger : new log : ");
 
     synchronized (logMutex){
       try{
-        message.append(""+log.getBundle().getBundleId());
+        long id=log.getBundle().getBundleId();
+	if (id<10) {
+	  message.append(" "+id);
+	} else{
+          message.append(""+id);
+	}
       }catch(NullPointerException e){
         message.append("Unknown source");
       }
@@ -115,23 +133,30 @@
       }else {
         message.append(reg+"NOLEVEL");
       }
-
-      message.append(reg+log.getMessage());
+	 
+      // into log.getMessage() replaceAll regex char by an other
+      String msg=log.getMessage();
+      if (msg!=null){
+	message.append(reg+msg.replace('*','X'));
+      } else {
+	message.append(reg+"\"null\"");
+      }
     }
     //System.out.println(message.toString());
     if (this.agent!=null){ // On envoie tous les logs a un MBeanServer
       //System.out.println("this.agent != null => remoteLogger.Logger.sendNotifiaction(...."+message.toString());
+      //System.out.println("RemoteLogger send notification : "+oldLog+" : "+message.toString()); 
       this.sendNotification(new  AttributeChangeNotification(this.remoteLoggerON, 0, 
-						             System.currentTimeMillis(),
+						             (oldLog)?0:System.currentTimeMillis(),
 						             message.toString(), null, "Log", null, null));
     }
   }
 
 //BundleActivator Interface
   public void start(BundleContext bc) throws Exception{
-		this.version=(String)bc.getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
+    this.version=(String)bc.getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
     this.bc=bc;
-		this.log(LogService.LOG_INFO, "Remote Logger starting "+version);
+    this.log(LogService.LOG_INFO, "Remote Logger starting "+version);
     try{
       this.remoteLoggerON=new ObjectName(Logger.REMOTE_LOGGER_ON_STRING);
     }catch(MalformedObjectNameException e){
@@ -157,7 +182,7 @@
   }
      
   public void stop(BundleContext bc) throws Exception{
-	this.log(LogService.LOG_INFO, "Stopping remote Logger "+version);
+   this.log(LogService.LOG_INFO, "Stopping remote Logger "+version);
    if (this.lrs==null){
       System.out.println("ERROR : Logger.stop : there is no logger or reader to stop");
    } else {
@@ -178,16 +203,6 @@
     //System.out.println("mosgi.jmx.remoteLogger.Logger.registerLogReaderService("+sr.toString()+") : oldLog=");
     this.lrs=(LogReaderService)this.bc.getService(sr);
     this.lrs.addLogListener(this);
-   
-    /*// old log :
-    System.out.println("oldLog=");
-    java.util.Enumeration oldLog = this.lrs.getLog();
-    int i=0;
-    while(oldLog.hasMoreElements()) {
-      LogEntry oldLogEntry = ((LogEntry) oldLog.nextElement());
-      System.out.println("   -"+(i++)+" : "+oldLogEntry.getMessage());
-      //logged(oldLogEntry);
-    }*/
   }
   
   private void unRegisterLogReaderService(ServiceReference sr) {
@@ -201,15 +216,6 @@
     this.agent=(MBeanServer)bc.getService(sr);
     try{   
       this.agent.registerMBean(this, this.remoteLoggerON); 
-      /*// old log :
-      System.out.println("oldLog=");
-      java.util.Enumeration oldLog = this.lrs.getLog();
-      int i=0;
-      while(oldLog.hasMoreElements()) {
-        LogEntry oldLogEntry = ((LogEntry) oldLog.nextElement());
-        System.out.println("   -"+(i++)+" : "+oldLogEntry.getMessage());
-        //logged(oldLogEntry);
-      }*/
     }catch(Exception e){
       e.printStackTrace();
     }
@@ -232,6 +238,5 @@
       System.out.println("ERROR : Logger.start : No service "+LogService.class.getName()+" is present");
     }
   }
-
 
 } 

Modified: incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/LoggerMBean.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/LoggerMBean.java?view=diff&rev=463216&r1=463215&r2=463216
==============================================================================
--- incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/LoggerMBean.java (original)
+++ incubator/felix/trunk/mosgi.jmx.remotelogger/src/main/java/org/apache/felix/mosgi/jmx/remotelogger/LoggerMBean.java Thu Oct 12 04:54:37 2006
@@ -18,4 +18,8 @@
  */
 package org.apache.felix.mosgi.jmx.remotelogger;
 
-public interface LoggerMBean{}
+public interface LoggerMBean{
+
+  public void sendOldLog();
+
+}



Mime
View raw message