[teiid-commits] teiid SVN: r867 - in trunk/console/src/main/java/com/metamatrix/console: ui/views/deploy and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed May 6 13:19:14 EDT 2009


Author: rareddy
Date: 2009-05-06 13:19:14 -0400 (Wed, 06 May 2009)
New Revision: 867

Modified:
   trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java
   trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DeployMainPanel.java
   trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/model/ConfigurationTreeModel.java
Log:
TEIID-546: fixes to regression from psc changes

Modified: trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java	2009-05-05 23:30:21 UTC (rev 866)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java	2009-05-06 17:19:14 UTC (rev 867)
@@ -911,11 +911,9 @@
 //    }
 
     private void fireConfigurationChange(ConfigurationChangeEvent theEvent) {
-        LogManager.logDetail(LogContexts.PSCDEPLOY,
-                            "ConfigurationChangeEvent=" + theEvent.paramString()); //$NON-NLS-1$
+        LogManager.logDetail(LogContexts.PSCDEPLOY, "ConfigurationChangeEvent=" + theEvent.paramString()); //$NON-NLS-1$
         for (int size=listeners.size(), i=0; i<size; i++) {
-            ConfigurationChangeListener l =
-                (ConfigurationChangeListener)listeners.get(i);
+            ConfigurationChangeListener l = (ConfigurationChangeListener)listeners.get(i);
             l.configurationChanged(theEvent);
         }
     }
@@ -1176,22 +1174,15 @@
         return host;
     }
 
-    public Collection getHostProcesses(
-        Host theHost,
-        ConfigurationID theConfigId)
-        throws ExternalException {
+    public Collection getHostProcesses(Host theHost,ConfigurationID theConfigId) throws ExternalException {
 
         try {
             Collection result = null; // VMComponentDefn
             Collection ids = null;
             Configuration config = getConfig(theConfigId);
             if (config == null) {
-                LogManager.logCritical(
-                    LogContexts.PSCDEPLOY,
-                    "ConfigurationManager.getHostProcesses:" + //$NON-NLS-1$
-                        "Configuration " + config + " not found."); //$NON-NLS-1$ //$NON-NLS-2$
+                LogManager.logCritical(LogContexts.PSCDEPLOY,"ConfigurationManager.getHostProcesses: Configuration " + config + " not found."); //$NON-NLS-1$ //$NON-NLS-2$
                 result = Collections.EMPTY_LIST;
-                
             } 
                 
 //
@@ -1235,17 +1226,11 @@
 //                                VMComponentDefnID processId =
 //                                    deployedComp.getVMComponentDefnID();
                                 VMComponentDefn process = (VMComponentDefn) itr.next();
-//                                    config.getComponentDefn(processId);
+//                              config.getComponentDefn(processId);
                                 result.add(process);
                                 ids.add(process.getID());
                                 
-                                    fireConfigurationChange(
-                                        new ConfigurationChangeEvent(
-                                            ConfigurationChangeEvent.NEW,
-                                            process,
-                                            config,
-                                            new Object[] {theHost,
-                                                          config}));
+                                fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.NEW,process,config,new Object[] {theHost,config}));
     
                                     // call this to cache the pscs
  //                                   getDeployedPscs(process);
@@ -1721,6 +1706,11 @@
         }
     }
     
+    private void addConfig(ConfigurationModelContainer theConfig) {
+        config = theConfig;
+        fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.NEW,theConfig.getConfiguration(),theConfig.getConfiguration(), null));
+    }
+    
     public void refresh(){
         super.refresh();
         this.setRefreshNeeded();
@@ -1728,57 +1718,70 @@
             refreshImpl();
             refreshConfigs();
         } catch (ExternalException e) {
-            LogManager.logCritical(
-                LogContexts.CONFIG,
-                "ConfigurationManager.refreshConfigs:" + //$NON-NLS-1$
-                    "Error refreshing configuration."); //$NON-NLS-1$
-            
+            LogManager.logCritical(LogContexts.CONFIG, "ConfigurationManager.refreshConfigs: Error refreshing configuration."); //$NON-NLS-1$
         }
     }    
 
-    private void refreshConfigs()
-        throws ExternalException {
+    private void refreshConfigs() throws ExternalException {
         	
-			fireConfigurationChange(
-				new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_START,
-			this));         	
-
+		fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_START,this));         	
  
         try {
             ConfigurationModelContainer nextStartUp = getAPI().getConfigurationModel(Configuration.NEXT_STARTUP);
             if (nextStartUp == null) {
-                LogManager.logCritical(
-                    LogContexts.CONFIG,
-                    "ConfigurationManager.refreshConfigs:" + //$NON-NLS-1$
-                        "Next Startup Configuration is null."); //$NON-NLS-1$
+                LogManager.logCritical(LogContexts.CONFIG,"ConfigurationManager.refreshConfigs:Next Startup Configuration is null."); //$NON-NLS-1$
             } else {
-                config = nextStartUp;
+                addConfig(nextStartUp);
             }
 
-			fireConfigurationChange(
-				new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_END,
-											 this));   
+			fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_END,this));   
             
             refreshNeeded = false;            
         } catch (Exception theException) {
-            throw new ExternalException(
-                formatErrorMsg("refreshConfigs", theException), //$NON-NLS-1$
-                theException);
+            throw new ExternalException(formatErrorMsg("refreshConfigs", theException), theException); //$NON-NLS-1$
         }
     }
+    
+    private void refreshDeployedHosts() throws ExternalException {
+		Iterator itr = config.getHosts().iterator();
+		while (itr.hasNext()) {
+			Host host = (Host) itr.next();
+			getHostProcesses(host, config.getConfigurationID());
+		}
+	}
 
+	private void refreshHosts()
+	    throws ExternalException {
+	
+	    try {
+	        Collection hostCollection = getConfigModel(Configuration.NEXT_STARTUP_ID).getHosts();
+	        if ((hostCollection == null) || (hostCollection.isEmpty()))  {
+	            LogManager.logCritical(LogContexts.CONFIG,"ConfigurationManager.refreshHosts: No hosts found or is null."); //$NON-NLS-1$
+	        } else {
+	            Iterator itr = hostCollection.iterator();
+	            while (itr.hasNext()) {
+	                Host host = (Host)itr.next();
+	                LogManager.logDetail(LogContexts.CONFIG,"ConfigurationManager.refreshHosts: Adding Host:" + host); //$NON-NLS-1$
+	                notifyHostChangeToConfigs(host, ConfigurationChangeEvent.NEW);
+	            }
+	        }
+	    } catch (Exception theException) {
+	        throw new ExternalException(
+	            formatErrorMsg("refreshHosts", theException), //$NON-NLS-1$
+	            theException);
+	    }
+	}    
+
     public void refreshImpl()
         throws ExternalException {
 
-        fireConfigurationChange(
-            new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_START,
-                                         this));
+        fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_START,this));
+        
         refreshConfigs();
-//        refreshHosts();
- //       refreshDeployedHosts();
-         fireConfigurationChange(
-            new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_END,
-                                         this));
+        refreshHosts();
+        refreshDeployedHosts();
+        
+        fireConfigurationChange(new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_END,this));
         refreshNeeded = false;
     }
 

Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DeployMainPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DeployMainPanel.java	2009-05-05 23:30:21 UTC (rev 866)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DeployMainPanel.java	2009-05-06 17:19:14 UTC (rev 867)
@@ -444,7 +444,7 @@
         pnlTreeOps.add(pnlTreeOpsSizer);
 
         getConfigurationManager().addConfigurationChangeListener(treeModel);
-        getConfigurationManager().refreshImpl();
+        //getConfigurationManager().refresh();
         setInitialTreeState(true);
         treeModel.addConfigurationTreeModelListener(this);
     }
@@ -1024,13 +1024,12 @@
             // if new host event, only select if the currently selected
             // node has the same configuration. this is because when
             // a host is created, events fire to add into all configurations.
-            if (theEvent.isHostChange()) {
+            if (theEvent.isHostChange() && pnlDetail != null) {
                 Configuration config = theEvent.getConfiguration();
                 if (config.getID().equals(pnlDetail.getConfigId())) {
                     selectNode(theEvent.getSourceNode());
                 }
-            } else if (!(pnlDetail instanceof DeployedProcessPanel) &&
-                     !theEvent.isServiceDefinitionChange()) {
+            } else if (!(pnlDetail instanceof DeployedProcessPanel) && !theEvent.isServiceDefinitionChange()) {
                 // if a new object is created, don't select it if
                 // current detail panel is the DeployedProcessPane.
                 // focus should stay on the panel, not the new one.

Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/model/ConfigurationTreeModel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/model/ConfigurationTreeModel.java	2009-05-05 23:30:21 UTC (rev 866)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/model/ConfigurationTreeModel.java	2009-05-06 17:19:14 UTC (rev 867)
@@ -142,12 +142,7 @@
 
         // notify tree model listeners
         if (fireevent) {
-	        ConfigurationTreeModelEvent event =
-	            new ConfigurationTreeModelEvent(ConfigurationTreeModelEvent.NEW,
-	                                            configNode,
-	                                            configNode,
-	                                            null);
-	        fireConfigurationChange(event);
+	        fireConfigurationChange(new ConfigurationTreeModelEvent(ConfigurationTreeModelEvent.NEW,configNode,configNode,null));
         }
     }
 
@@ -178,8 +173,10 @@
     private void addDeloyedHost(Host theHost, Configuration theConfig, boolean fireevent) {
 
         DefaultTreeNode configNode = getUserObjectNode(theConfig);
-        DefaultTreeNode hostNode =
-            createHostNode(theHost, theConfig, configNode);
+        DefaultTreeNode hostNode = createHostNode(theHost, theConfig, configNode);
+        if (configNode == null) {
+        	configNode = hostNode;
+        }
         HashMap map = (HashMap)hostConfigMap.get(theHost.getID());
         if (map == null) {
             // has not been deployed
@@ -361,22 +358,15 @@
      * @param theUserObject the user object of the new node
      * @param theParent the parent node of the new node
      */
-    private SortableChildrenNode createNode(
-        Object theUserObject,
-        DefaultTreeNode theParent) {
-
+    private SortableChildrenNode createNode(Object theUserObject, DefaultTreeNode theParent) {
         SortableChildrenNode child = new SortableChildrenNode(theUserObject);
-        theParent.addChild(child);
+    	theParent.addChild(child);
         objNodeMap.put(theUserObject, child);
         fireNodeAddedEvent(this, child);
         return child;
     }
 
-    private SortableChildrenNode createHostNode(
-        Host theHost,
-        Configuration theConfig,
-        DefaultTreeNode theParent) {
-
+    private SortableChildrenNode createHostNode(Host theHost, Configuration theConfig, DefaultTreeNode theParent) {
         HostWrapper wrap = new HostWrapper(theHost, theConfig);
         return createNode(wrap, theParent);
     }
@@ -445,12 +435,9 @@
      * @param theEvent the event being sent to the listeners
      */
     private void fireConfigurationChange(ConfigurationTreeModelEvent theEvent) {
-        LogManager.logDetail(
-            LogContexts.PSCDEPLOY,
-            "ConfigurationTreeModelEvent=" + theEvent.paramString()); //$NON-NLS-1$
+        LogManager.logDetail(LogContexts.PSCDEPLOY,"ConfigurationTreeModelEvent=" + theEvent.paramString()); //$NON-NLS-1$
         for (int size=listeners.size(), i=0; i<size; i++) {
-            ConfigurationTreeModelListener l =
-                (ConfigurationTreeModelListener)listeners.get(i);
+            ConfigurationTreeModelListener l = (ConfigurationTreeModelListener)listeners.get(i);
             l.treeNodesChanged(theEvent);
         }
     }




More information about the teiid-commits mailing list