You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sp...@apache.org on 2006/09/18 16:47:11 UTC

svn commit: r447418 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/ org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/ org.apache.geronimo.st.v...

Author: sppatel
Date: Mon Sep 18 07:47:10 2006
New Revision: 447418

URL: http://svn.apache.org/viewvc?view=rev&rev=447418
Log:
add checkbox to easily allow add/remove of sharedlib dependency

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/V11DeploymentPlanCreationOperation.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/CommonGeneralSection.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/V11DeploymentPlanCreationOperation.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/V11DeploymentPlanCreationOperation.java?view=diff&rev=447418&r1=447417&r2=447418
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/V11DeploymentPlanCreationOperation.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/operations/V11DeploymentPlanCreationOperation.java Mon Sep 18 07:47:10 2006
@@ -240,7 +240,7 @@
 		return env;
 	}
 
-	private ArtifactType createArtifactType(String groupId, String artifactId, String version, String type) {
+	public static ArtifactType createArtifactType(String groupId, String artifactId, String version, String type) {
 		ArtifactType artifact = DeploymentFactory.eINSTANCE.createArtifactType();
 		if (groupId != null)
 			artifact.setGroupId(groupId);
@@ -252,7 +252,7 @@
 		return artifact;
 	}
 
-	private ArtifactType createDependencyType(String groupId, String artifactId, String version, String type) {
+	public static ArtifactType createDependencyType(String groupId, String artifactId, String version, String type) {
 		DependencyType artifact = DeploymentFactory.eINSTANCE.createDependencyType();
 		if (groupId != null)
 			artifact.setGroupId(groupId);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.java?view=diff&rev=447418&r1=447417&r2=447418
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.java Mon Sep 18 07:47:10 2006
@@ -25,6 +25,7 @@
 	public static String artifactType;
 	public static String inverseClassloading;
 	public static String supressDefaultEnv;
+	public static String sharedLibDepends;
 	
 	public static String addSharedLib;
 	public static String version;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.properties?view=diff&rev=447418&r1=447417&r2=447418
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.properties (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/internal/Messages.properties Mon Sep 18 07:47:10 2006
@@ -10,6 +10,7 @@
 artifactType=Artifact Type:
 inverseClassloading=Inverse classloading
 supressDefaultEnv=Supress default environment
+sharedLibDepends=Add a runtime dependency to Geronimo's shared library.
 
 addSharedLib=Add a runtime dependency to Geronimo's shared library.
 webContainerSection=Web Container

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/CommonGeneralSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/CommonGeneralSection.java?view=diff&rev=447418&r1=447417&r2=447418
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/CommonGeneralSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/CommonGeneralSection.java Mon Sep 18 07:47:10 2006
@@ -15,10 +15,15 @@
  */
 package org.apache.geronimo.st.v11.ui.sections;
 
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.geronimo.st.ui.CommonMessages;
 import org.apache.geronimo.st.ui.sections.AbstractSectionPart;
+import org.apache.geronimo.st.v11.core.operations.V11DeploymentPlanCreationOperation;
 import org.apache.geronimo.st.v11.ui.internal.Messages;
 import org.apache.geronimo.xml.ns.deployment.ArtifactType;
+import org.apache.geronimo.xml.ns.deployment.DependenciesType;
 import org.apache.geronimo.xml.ns.deployment.DeploymentFactory;
 import org.apache.geronimo.xml.ns.deployment.DeploymentPackage;
 import org.apache.geronimo.xml.ns.deployment.EnvironmentType;
@@ -52,6 +57,8 @@
 	protected Button inverseClassLoading;
 
 	protected Button suppressDefaultEnv;
+	
+	protected Button sharedLibDepends;
 
 	public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, EObject plan) {
 		super(parent, toolkit, style, plan);
@@ -151,6 +158,22 @@
 				markDirty();
 			}
 		});
+		
+		sharedLibDepends = toolkit.createButton(composite, Messages.sharedLibDepends, SWT.CHECK);
+		sharedLibDepends.setSelection(isSharedLibDependency());
+		data = new GridData();
+		data.horizontalSpan = 2;
+		sharedLibDepends.setLayoutData(data);
+
+		sharedLibDepends.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				setSharedLibDependency(sharedLibDepends.getSelection());
+				markDirty();
+			}
+		});
 	}
 
 	protected Label createLabel(Composite parent, String text) {
@@ -207,6 +230,14 @@
 		EnvironmentType type = getEnvironmentType(false);
 		return type != null && type.getSuppressDefaultEnvironment() != null;
 	}
+	
+	protected boolean isSharedLibDependency() {
+		DependenciesType depType = getDependenciesType(false);
+		if(depType != null) {
+			return getSharedLibDependency(depType) != null;
+		}
+		return false;
+	}
 
 	protected void setInverseClassloading(boolean enable) {
 		if (enable) {
@@ -231,6 +262,35 @@
 			}
 		}
 	}
+	
+	protected void setSharedLibDependency(boolean enable) {
+		if (enable) {
+			DependenciesType deptype = getDependenciesType(true);
+			ArtifactType sharedLib = V11DeploymentPlanCreationOperation.createDependencyType("geronimo", "sharedlib", null, "car");
+			deptype.getDependency().add(sharedLib);
+		} else {
+			DependenciesType deptype = getDependenciesType(false);
+			if (deptype != null) {
+				ArtifactType artifact = getSharedLibDependency(deptype);
+				if(artifact != null) {
+					deptype.getDependency().remove(artifact);
+				}
+			}
+		}
+	}
+	
+	private ArtifactType getSharedLibDependency(DependenciesType dependenciesType) {
+		DependenciesType depType = getDependenciesType(false);
+		List dependencies = depType.getDependency();
+		Iterator i = dependencies.iterator();
+		while(i.hasNext()) {
+			ArtifactType artifact = (ArtifactType) i.next();
+			if("geronimo".equals(artifact.getGroupId()) && "sharedlib".equals(artifact.getArtifactId()) && "car".equals(artifact.getType())) {
+				return artifact;
+			}
+		}
+		return null;
+	}
 
 	private EnvironmentType getEnvironmentType(boolean create) {
 		EnvironmentType type = (EnvironmentType) getPlan().eGet(getEnvironmentEReference());
@@ -239,6 +299,19 @@
 			getPlan().eSet(getEnvironmentEReference(), type);
 		}
 		return type;
+	}
+	
+	private DependenciesType getDependenciesType(boolean create) {
+		EnvironmentType env = getEnvironmentType(create);
+		if(env != null) {
+			DependenciesType dep = env.getDependencies();
+			if (dep == null && create) {
+				dep = DeploymentFactory.eINSTANCE.createDependenciesType();
+				env.setDependencies(dep);
+			}
+			return dep;
+		}
+		return null;
 	}
 
 	private ArtifactType getModuleId(boolean create) {