Author: dgolovin
Date: 2007-09-19 21:02:59 -0400 (Wed, 19 Sep 2007)
New Revision: 3725
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-914
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-19
20:47:06 UTC (rev 3724)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-20
01:02:59 UTC (rev 3725)
@@ -12,11 +12,17 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -45,6 +51,8 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
@@ -376,11 +384,50 @@
setPageComplete(false);
return;
}
+ String seamVersion = getSeamVersion(homeDir.getValueAsString());
+ if("".equals(seamVersion)) {
+ setErrorMessage("Cannot obtain Seam version number from jboss-seam.jar
file.");
+ setPageComplete(false);
+ return;
+ } else if(!seamVersion.matches(version.getValueAsString()+".*")) {
+ setErrorMessage("Selected seam has wrong version number '" +
seamVersion + "'");
+ setPageComplete(false);
+ return;
+ }
setErrorMessage(null);
setPageComplete(true);
}
+ public static String getSeamVersion(String path) {
+ File seamJarFile = new File(path, "jboss-seam.jar");
+ InputStream str=null;
+ ZipFile seamJar;
+ try {
+ seamJar = new ZipFile(seamJarFile);
+
+ ZipFileStructureProvider provider = new ZipFileStructureProvider(seamJar);
+ ZipEntry entry = seamJar.getEntry("META-INF/MANIFEST.MF");
+ str = provider.getContents(entry);
+
+ Properties manifest = new Properties();
+ manifest.load(str);
+ Object sv = manifest.get("Seam-Version");
+ return sv==null?"":sv.toString();
+
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError("Cannot read jboss-seam.jar
file",e);
+ } finally {
+ if(str!=null)
+ try {
+ str.close();
+ } catch (IOException e) {
+ // nothing to do with that
+ }
+ }
+ return "";
+ }
+
/**
*
* @return