geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1101592 - /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
Date Tue, 10 May 2011 18:44:56 GMT
Author: gawor
Date: Tue May 10 18:44:55 2011
New Revision: 1101592

URL: http://svn.apache.org/viewvc?rev=1101592&view=rev
Log:
GERONIMODEVTOOLS-716: Ensure target platform is always re-created when server runtime is changed

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java?rev=1101592&r1=1101591&r2=1101592&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
Tue May 10 18:44:55 2011
@@ -426,20 +426,32 @@ public class GeronimoRuntimeWizardFragme
 
     public void performFinish(IProgressMonitor monitor) throws CoreException {
 
-        IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
-
-        // whether the target platform is already created
-        if (null == varManager.getValueVariable(GERONIMO_SERVER_LOCATION_VARIABLE_NAME))
{
+        ITargetPlatformService service = 
+            (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
+        
+        ITargetHandle geronimoTargetHandle = findGeronimoTargetDefinition(service);
+        
+        if (geronimoTargetHandle == null) {
+            // target definition not found - generate one 
             
-            // add string substitution variable named ${geronimo_30_server_location} 
             String geronimoServerLocation = getRuntimeDelegate().getRuntime().getLocation().toString();
             if (geronimoServerLocation.endsWith("/")) {
                 geronimoServerLocation = geronimoServerLocation.substring(0, geronimoServerLocation.length()-1);
             }
-            IValueVariable v = varManager.newValueVariable(GERONIMO_SERVER_LOCATION_VARIABLE_NAME,
-                    "The server location of Geronimo v3.0", false, geronimoServerLocation);
-            varManager.addVariables(new IValueVariable[] { v });
             
+            // add or update string substitution variable named ${geronimo_30_server_location}

+            IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
+            IValueVariable v = varManager.getValueVariable(GERONIMO_SERVER_LOCATION_VARIABLE_NAME);
+            if (v == null) {
+                v = varManager.newValueVariable(GERONIMO_SERVER_LOCATION_VARIABLE_NAME,
+                                                "The server location of Geronimo v3.0", 
+                                                false, 
+                                                geronimoServerLocation);
+                varManager.addVariables(new IValueVariable[] { v });
+            } else {
+                v.setValue(geronimoServerLocation);
+            }
+                        
             // copy the target file for target platform into workspace
             IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
             IPath rootLocation = root.getLocation();
@@ -451,32 +463,30 @@ public class GeronimoRuntimeWizardFragme
             URL template = bundle.getEntry(TARGET_TEMPLATE_FILE);
             
             copyFile(template, destination, getLocationEntryLists(geronimoServerLocation));
+                        
+            geronimoTargetHandle = findGeronimoTargetDefinition(service);               
    
         }
         
-        ITargetPlatformService service = (ITargetPlatformService)PDECore.getDefault().acquireService(
-                ITargetPlatformService.class.getName());
         ITargetHandle activeTargetHandle = service.getWorkspaceTargetHandle();
-        ITargetHandle[] targetHandles = service.getTargets(null);
-        ITargetHandle geronimoTargetHandle = null;
-        for (ITargetHandle cur : targetHandles) {
-            if (cur.getTargetDefinition().getName().equals("Apache Geronimo 3.0")) {
-                geronimoTargetHandle = cur;
-            }
-        }
+        
         if (geronimoTargetHandle != null) {
-            boolean resetFlag = false;
-            if (activeTargetHandle == null ) {
-                resetFlag = true;
-            } else if (!activeTargetHandle.equals(geronimoTargetHandle)) {
-                resetFlag = true;
-            }                
-            if (resetFlag) {
+            if (activeTargetHandle == null || !activeTargetHandle.equals(geronimoTargetHandle))
{
                 ITargetDefinition geronimoTarget = geronimoTargetHandle.getTargetDefinition();
                 LoadTargetDefinitionJob.load(geronimoTarget);
             }            
         }
     }
     
+    private ITargetHandle findGeronimoTargetDefinition(ITargetPlatformService service) throws
CoreException {
+        ITargetHandle[] targetHandles = service.getTargets(null);
+        for (ITargetHandle cur : targetHandles) {
+            if (cur.getTargetDefinition().getName().equals("Apache Geronimo 3.0")) {
+                return cur;
+            }
+        }
+        return null;
+    }
+    
     protected void copyFile(URL source, IPath dest, String replacement) throws CoreException
{
         Reader reader = null;
         Writer writer = null;



Mime
View raw message