Author: rob.stryker(a)jboss.com
Date: 2009-09-28 16:03:27 -0400 (Mon, 28 Sep 2009)
New Revision: 17782
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/VCFUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/META-INF/MANIFEST.MF
Log:
making a vcf utility class
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/META-INF/MANIFEST.MF 2009-09-28
15:09:58 UTC (rev 17781)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/META-INF/MANIFEST.MF 2009-09-28
20:03:27 UTC (rev 17782)
@@ -24,5 +24,6 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.ide.eclipse.as.wtp.core.modules,
+ org.jboss.ide.eclipse.as.wtp.core.util,
org.jboss.ide.eclipse.as.wtp.core.vcf
Bundle-Vendor: JBoss by Red Hat
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/VCFUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/VCFUtil.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/VCFUtil.java 2009-09-28
20:03:27 UTC (rev 17782)
@@ -0,0 +1,52 @@
+package org.jboss.ide.eclipse.as.wtp.core.util;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import
org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.jboss.ide.eclipse.as.wtp.core.Activator;
+
+public class VCFUtil {
+ public static void addReference(IVirtualComponent component,
+ IVirtualComponent rootComponent,
+ String path, String archiveName)
+ throws CoreException {
+ IDataModelProvider provider = new CreateReferenceComponentsDataModelProvider();
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
rootComponent);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
Arrays.asList(component));
+
+ //[Bug 238264] the uri map needs to be manually set correctly
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent,
String>();
+ uriMap.put(component, archiveName);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP,
uriMap);
+
dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
path);
+
+ IStatus stat =
dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ Throwable t = stat == null ? null : stat.getException();
+ if (stat == null || stat.isOK()) {
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ return;
+ } catch (ExecutionException e) {
+ t = e;
+ }
+ }
+ if( t != null ) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, t.getMessage(), t);
+ throw new CoreException(status);
+ }
+ }
+}
Show replies by date