Author: dennyxu
Date: 2009-12-18 01:53:24 -0500 (Fri, 18 Dec 2009)
New Revision: 19458
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/AbstractESBRuntimeResolver.java
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/IESBRuntimeResolver.java
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
Log:
JBIDE-5496:new runtime wizard very annoying, version not updated,
update it to be able to set version number automatically if there is version number in
jbossesb-rosetta.jar
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/AbstractESBRuntimeResolver.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/AbstractESBRuntimeResolver.java 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/AbstractESBRuntimeResolver.java 2009-12-18
06:53:24 UTC (rev 19458)
@@ -44,6 +44,17 @@
return directories;
}
+ public File getRosettaJar(String runtimeLocation , String configuration){
+ List<File> jars = getAllRuntimeJars(runtimeLocation, configuration);
+ for(File file : jars){
+ if(file.getName().equals(ROSETTA_JAR)){
+ return file;
+ }
+ }
+
+ return null;
+ }
+
public List<File> getAllRuntimeJars(String runtimeLocation, String configuration)
{
List<File> jarList = new ArrayList<File>();
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/IESBRuntimeResolver.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/IESBRuntimeResolver.java 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/IESBRuntimeResolver.java 2009-12-18
06:53:24 UTC (rev 19458)
@@ -13,4 +13,6 @@
public List<IPath> getJarDirectories(String runtimeLocation, String
configuration);
public List<File> getAllRuntimeJars(String runtimeLocation, String
configuration);
+
+ public File getRosettaJar(String runtimeLocation , String configuration);
}
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java 2009-12-18
06:53:24 UTC (rev 19458)
@@ -13,12 +13,17 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -31,6 +36,7 @@
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.jboss.tools.esb.core.ESBProjectCorePlugin;
import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
@@ -50,7 +56,12 @@
static String ATT_VERSION = "esbVersion"; //$NON-NLS-1$
static String ATT_ID = "id";
static String VERSION_SEPARATOR = ",";
+ static String VERSION_FILE_NAME = "VERSION";
+ static String VERSION_PROPERTIES_KEY = "Version";
+ static String VERSION_PROPERTIES_SEPERATOR = "_";
+
+
static Map<String, IESBRuntimeResolver> parserMap = new HashMap<String,
IESBRuntimeResolver>();
@@ -455,5 +466,62 @@
}
}
}
+
+ public String getVersion(String location, String configuration){
+ String version = "";
+ File rosettaJar = null;
+ Collection<IESBRuntimeResolver> resolvers = parserMap.values();
+ for(IESBRuntimeResolver resolver : resolvers){
+ rosettaJar = resolver.getRosettaJar(location, configuration);
+ if(rosettaJar != null && rosettaJar.exists()){
+ break;
+ }
+ }
+
+ if(rosettaJar == null || !rosettaJar.exists()){
+ return "";
+ }
+
+ try {
+ ZipFile zfile = new ZipFile(rosettaJar);
+ ZipEntry entry = zfile.getEntry(VERSION_FILE_NAME);
+
+ if(entry == null) return "";
+
+ InputStream input = zfile.getInputStream(entry);
+ Properties properties = new Properties();
+ properties.load(input);
+ version = properties.getProperty(VERSION_PROPERTIES_KEY);
+
+
+ if(version == null){
+ return "";
+ }
+ // soa-p5.0 and higher
+ else if(version.indexOf(VERSION_PROPERTIES_SEPERATOR) > 0){
+ version = version.substring(0, version.indexOf(VERSION_PROPERTIES_SEPERATOR));
+ }
+ //soa-p 4.3
+ else if(version.equals("4.3.0")) {
+ version = "4.4";
+ }
+ else if(version.length() > 3){
+ version = version.substring(0,3);
+ }
+
+ } catch (ZipException e) {
+ ESBProjectCorePlugin.log(e.getLocalizedMessage(), e);
+ } catch (IOException e) {
+ ESBProjectCorePlugin.log(e.getLocalizedMessage(), e);
+ }
+
+ return version;
+ }
+
+ public static void main(String[] args){
+ File file = new File("/home/fugang/jboss-all/jboss-soa-p.5.0.0/");
+ JBossRuntimeManager.getInstance().getVersion(file.getAbsolutePath().toString(),
"default");
+ }
+
}
\ No newline at end of file
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2009-12-18
06:53:24 UTC (rev 19458)
@@ -66,7 +66,9 @@
ESBFacetInstallationPage_Label_Source_Directory=Java Source Directory
ESBFacetInstallationPage_Title=Install ESB Facet
+ESBRuntimeContainerPage_Button_Text=Create an ESB Runtime
+
ESBProjectFirstPage_Description=Create a new JBoss ESB project.
ESBProjectFirstPage_Title=JBoss ESB Project
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2009-12-18
06:53:24 UTC (rev 19458)
@@ -53,6 +53,8 @@
public static String JBoss_Button_Field_Editor_Browse;
public static String JBoss_ESBRuntime_Classpath_Container_5;
public static String JBoss_Runtime_List_Field_Editor_Configuration;
+
+ public static String ESBRuntimeContainerPage_Button_Text;
public static String JBoss_ESBRuntime_Classpath_Container_Description;
Modified:
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java 2009-12-18
06:48:32 UTC (rev 19457)
+++
branches/jbosstools-3.1.0.RC1/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java 2009-12-18
06:53:24 UTC (rev 19458)
@@ -625,6 +625,8 @@
for(IProjectFacetVersion version: esbfacet.getVersions()){
versions.add(version.getVersionString());
}
+ versions.add("");
+
Collections.sort(versions);
Collections.reverse(versions);
return versions;
@@ -678,10 +680,21 @@
configuration.setText(source.getConfiguration());
}
}
+
+ // set version automatically according esb home location and configuration
+ updateDefaultVersion();
return configList;
}
+
+ private void updateDefaultVersion(){
+ String homeLocation = homeDir.getValueAsString();
+ String config = configuration.getText();
+ String defaultVersion = JBossRuntimeManager.getInstance().getVersion(homeLocation,
config);
+ version.setValue(defaultVersion);
+
+ }
/**
* Return JBossWS Runtime instance initialized by user input
*
Show replies by date