[jbosstools-commits] JBoss Tools SVN: r9132 - in trunk: core/plugins/org.jboss.ide.eclipse.archives.core and 18 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Jul 14 14:22:49 EDT 2008


Author: rob.stryker at jboss.com
Date: 2008-07-14 14:22:49 -0400 (Mon, 14 Jul 2008)
New Revision: 9132

Added:
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/variableProvider.exsd
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/IVariableProvider.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariableManager.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchivesVariableDialog.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/VariablesPreferencePage.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationDialog.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveDestinationComposite.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveFilesetDestinationComposite.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveNodeDestinationComposite.java
Removed:
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchiveNodeDestinationDialog.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/DestinationChangeListener.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveDestinationComposite.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveFilesetDestinationComposite.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
Modified:
   trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
   trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
Log:
JBIDE-2493 JBIDE-1406

Fixes compilation errors, adds support for current project, and also variables. 

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -21,7 +21,6 @@
  */
 package org.jboss.ide.eclipse.as.ui;
 
-import java.util.ArrayList;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
@@ -29,10 +28,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.ui.IStartup;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.server.core.IServer;
 import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
-import org.jboss.tools.as.wst.server.ui.ExtensionManager;
 import org.osgi.framework.BundleContext;
 
 /**

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF	2008-07-14 18:22:49 UTC (rev 9132)
@@ -6,13 +6,13 @@
 Bundle-Activator: org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin
 Bundle-Vendor: JBoss, a division of Red Hat
 Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.runtime,
+Require-Bundle: org.apache.ant,
+ org.eclipse.core.commands,
  org.eclipse.core.filesystem,
- org.eclipse.core.commands,
- org.apache.ant,
  org.eclipse.core.resources,
- org.eclipse.jdt.core,
- org.eclipse.core.variables
+ org.eclipse.core.runtime,
+ org.eclipse.core.variables,
+ org.eclipse.jdt.core
 Eclipse-LazyStart: true
 Bundle-ClassPath: archivescore.jar,
  archivescore-eclipse.jar,

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml	2008-07-14 18:22:49 UTC (rev 9132)
@@ -2,7 +2,8 @@
 <?eclipse version="3.2"?>
 <plugin>
    <extension-point id="archiveTypes" name="JBoss Tools Package Type" schema="schema/archiveTypes.exsd"/>
-   <extension-point id="actionTypes" name="JBoss Tools Build Action Type" schema="schema/actionTypes.exsd"/>
+   <extension-point id="actionTypes" name="JBoss Tools Build Action Type" schema="schema/actionTypes.exsd"/>
+   <extension-point id="variableProviders" name="Variable Provider" schema="schema/variableProvider.exsd"/>
    <extension
          id="archivesNature"
          name="JBossIDE Packages Nature"
@@ -51,6 +52,15 @@
             id="org.jboss.ide.eclipse.archives.core.antActionType"
             label="Ant Task">
       </actionType>
-   </extension>
+   </extension>
+   
+   
+   <extension
+         point="org.jboss.ide.eclipse.archives.core.variableProviders">
+      <provider class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager$DefaultVariableProvider"/>
+      <provider class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager$LinkedResourceVariableProvider"/>
+      <provider class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager$ClasspathVariableProvider"/>
+      <provider class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager$ValueVariableProvider"/>
+   </extension> 
 
 </plugin>

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/variableProvider.exsd
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/variableProvider.exsd	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/variableProvider.exsd	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.archives.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.jboss.ide.eclipse.archives.core" id="packageTypes" name="JBoss Tools Package Type"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="provider" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="provider">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.jboss.ide.eclipse.archives.core.model.IVariableProvider"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiInfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/IVariableProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/IVariableProvider.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/IVariableProvider.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,11 @@
+package org.jboss.ide.eclipse.archives.core.model;
+
+public interface IVariableProvider extends IVariableManager {
+	public String getId();
+	public String getName();
+	public boolean getEnabled();
+	public void setEnabled(boolean val);
+	public int getWeight();
+	public void setWeight(int weight);
+	public int getDefaultWeight();
+}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -36,6 +36,7 @@
 import org.jboss.ide.eclipse.archives.core.model.IActionType;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
 import org.jboss.ide.eclipse.archives.core.model.IExtensionManager;
+import org.jboss.ide.eclipse.archives.core.model.IVariableProvider;
 
 /**
  * This class will be responsible for loading extension points in the core.
@@ -46,6 +47,7 @@
 public class WorkspaceExtensionManager implements IExtensionManager {
 	public static final String ARCHIVE_TYPES_EXTENSION_ID = "org.jboss.ide.eclipse.archives.core.archiveTypes";
 	public static final String ACTION_TYPES_EXTENSION_ID = "org.jboss.ide.eclipse.archives.core.actionTypes";
+	public static final String VARIABLE_PROVIDER_EXTENSION_ID = "org.jboss.ide.eclipse.archives.core.variableProviders";
 	
 	private IExtension[] findExtension (String extensionId) {
 		IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -53,9 +55,9 @@
 		return extensionPoint.getExtensions();
 	}
 	
-	private static Hashtable archiveTypes;
+	private static Hashtable<String, IArchiveType> archiveTypes;
 	private void loadPackageTypes () {
-		archiveTypes = new Hashtable();
+		archiveTypes = new Hashtable<String, IArchiveType>();
 		IExtension[] extensions = findExtension(ARCHIVE_TYPES_EXTENSION_ID);
 		
 		for (int i = 0; i < extensions.length; i++) {
@@ -77,22 +79,22 @@
 	public IArchiveType getArchiveType (String packageType) {
 		if (archiveTypes == null)
 			loadPackageTypes();
-		return (IArchiveType)archiveTypes.get(packageType);
+		return archiveTypes.get(packageType);
 	}
 
 	public IArchiveType[] getArchiveTypes() {
 		if( archiveTypes == null )
 			loadPackageTypes();
-		Collection c = archiveTypes.values();
-		return (IArchiveType[]) c.toArray(new IArchiveType[c.size()]);
+		Collection<IArchiveType> c = archiveTypes.values();
+		return c.toArray(new IArchiveType[c.size()]);
 	}
 
 
-	private static Hashtable actionTypes;
+	private static Hashtable<String, IActionType> actionTypes;
 	public IActionType getActionType(String id) {
 		if (actionTypes == null)
 			loadActionTypes();
-		return (IActionType)actionTypes.get(id);
+		return actionTypes.get(id);
 	}
 
 	/* (non-Javadoc)
@@ -101,12 +103,12 @@
 	public IActionType[] getActionTypes() {
 		if( actionTypes == null )
 			loadActionTypes();
-		Collection c = archiveTypes.values();
-		return (IActionType[]) c.toArray(new IActionType[c.size()]);
+		Collection<IArchiveType> c = archiveTypes.values();
+		return c.toArray(new IActionType[c.size()]);
 	}
 
 	private void loadActionTypes() {
-		actionTypes = new Hashtable();
+		actionTypes = new Hashtable<String, IActionType>();
 		IExtension[] extensions = findExtension(ACTION_TYPES_EXTENSION_ID);
 		for (int i = 0; i < extensions.length; i++) {
 			IConfigurationElement elements[] = extensions[i].getConfigurationElements();
@@ -123,4 +125,39 @@
 			}
 		}
 	}
+	
+	
+	
+	private static Hashtable<String, IVariableProvider> variableProviders;
+	public IVariableProvider getVariableProvider(String id) {
+		if (variableProviders == null)
+			loadVariableProviders();
+		return variableProviders.get(id);
+	}
+	public IVariableProvider[] getVariableProviders() {
+		if( variableProviders == null )
+			loadVariableProviders();
+		Collection<IVariableProvider> c = variableProviders.values();
+		return c.toArray(new IVariableProvider[c.size()]);
+	}
+
+	private void loadVariableProviders() {
+		variableProviders = new Hashtable<String, IVariableProvider>();
+		IExtension[] extensions = findExtension(VARIABLE_PROVIDER_EXTENSION_ID);
+		for (int i = 0; i < extensions.length; i++) {
+			IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+			for (int j = 0; j < elements.length; j++) {
+				try {
+					Object executable = elements[j].createExecutableExtension("class");
+					IVariableProvider type = (IVariableProvider)executable;
+					variableProviders.put(type.getId(), type);
+				} catch (InvalidRegistryObjectException e) {
+					ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, e.getMessage(), e);
+				} catch( CoreException e ) {
+					ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, e.getMessage(), e);
+				}
+			}
+		}
+	}
+	
 }

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -32,7 +32,9 @@
 import org.eclipse.core.runtime.preferences.DefaultScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
 import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
 import org.jboss.ide.eclipse.archives.core.model.IPreferenceManager;
 import org.osgi.service.prefs.BackingStoreException;
 
@@ -90,7 +92,7 @@
 		try {
 			prefs.flush();
 		} catch (BackingStoreException e) {	
-			e.printStackTrace();
+			ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
 		}
 	}
 	
@@ -100,8 +102,7 @@
 		try {
 			prefs.flush();
 		} catch (BackingStoreException e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
+			ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e1.getMessage(), e1);
 		}
 	}
 	

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -6,17 +6,10 @@
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jdt.core.JavaCore;
-import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
 import org.jboss.ide.eclipse.archives.core.model.IArchivesVFS;
 import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
 import org.jboss.ide.eclipse.archives.core.xpl.StringSubstitutionEngineClone;
-import org.osgi.service.prefs.BackingStoreException;
 
 public class WorkspaceVFS implements IArchivesVFS {
 	protected WorkspaceVariableManager manager;
@@ -26,62 +19,10 @@
 		engine = new StringSubstitutionEngineClone();
 	}
 	
-	public WorkspaceVariableManager getManager() {
+	public WorkspaceVariableManager getVariableManager() {
 		return manager;
 	}
 	
-	public class WorkspaceVariableManager implements IVariableManager {
-		private static final String PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager.";
-		private static final int TYPE_NONE = -1;
-		private static final int TYPE_CUSTOM = 0;
-		private static final int TYPE_LINK = 1;
-		private static final int TYPE_CLASSPATH = 2;
-		
-		public boolean containsVariable(String variable) {
-			return getVariableLocation(variable) != -1;
-		}
-
-		public String getVariableValue(String variable) {
-			int type = getVariableLocation(variable);
-			if( type == TYPE_CUSTOM ) {
-				IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
-				return prefs.get(PREFIX + variable, null);
-			}else if( type == TYPE_LINK ) {
-				return ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable).toString();
-			} else if( type == TYPE_CLASSPATH ) {
-				return JavaCore.getClasspathVariable(variable).toString();
-			}
-			return null;
-		}
-		
-		public int getVariableLocation(String variable) {
-			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
-			if( prefs.get(PREFIX + variable, null) != null ) 
-				return TYPE_CUSTOM;
-			
-			if( ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable) != null )
-				return TYPE_LINK;
-			
-			if( JavaCore.getClasspathVariable(variable) != null)
-				return TYPE_CLASSPATH;
-			return TYPE_NONE;
-		}
-		
-		public void setValue(String name, IPath value) throws CoreException {
-			try {
-				IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
-				if( value != null )
-					prefs.put(PREFIX + name, value.toString());
-				else 
-					prefs.remove(PREFIX + name);
-				prefs.flush();
-			} catch (BackingStoreException e) { 
-				IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, e.getMessage(), e);
-				throw new CoreException(status); 
-			}
-		}
-	}
-	
 	public String performStringSubstitution(String expression,
 			boolean reportUndefinedVariables) throws CoreException {
 		return performStringSubstitution(expression, null, reportUndefinedVariables);
@@ -91,8 +32,11 @@
 			String projectName, boolean reportUndefinedVariables)
 			throws CoreException {
 		// set this project name
+		if( expression == null )
+			return null;
+		
 		if( projectName != null ) {
-			manager.setValue(IVariableManager.CURRENT_PROJECT, new Path(projectName));
+			manager.setValue(IVariableManager.CURRENT_PROJECT, projectName);
 		}
 		
 		String ret = engine.performStringSubstitution(expression, reportUndefinedVariables, manager);

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariableManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariableManager.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariableManager.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,286 @@
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.variables.IStringVariable;
+import org.eclipse.core.variables.IValueVariable;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import org.jboss.ide.eclipse.archives.core.model.IExtensionManager;
+import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
+import org.jboss.ide.eclipse.archives.core.model.IVariableProvider;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class WorkspaceVariableManager implements IVariableManager {
+	public static final String DEFAULT_PROVIDER = "org.jboss.ide.eclipse.archives.core.defaultVariableProvider";
+	protected IVariableProvider[] delegates;
+	public WorkspaceVariableManager() {
+	}
+	
+	public IVariableProvider[] getDelegates() {
+		sort();
+		IVariableProvider[] copy = new IVariableProvider[delegates.length];
+		for( int i = 0; i < delegates.length; i++ ) 
+			copy[i] = delegates[i];
+		return copy;
+	}
+	
+	public void sort() {
+		if( delegates == null ) {
+			IExtensionManager mgr = ArchivesCore.getInstance().getExtensionManager();
+			delegates = ((WorkspaceExtensionManager)mgr).getVariableProviders();
+		}
+		List<IVariableProvider> l = Arrays.asList(delegates);
+		Comparator<IVariableProvider> x = new Comparator<IVariableProvider>() {
+			public int compare(IVariableProvider o1, IVariableProvider o2) {
+				// different enablements
+				if( o1.getEnabled() != o2.getEnabled())
+					return o1.getEnabled() ? 1 : -1;
+				// now weights
+				if( o1.getWeight() != o2.getWeight() ) 
+					return o1.getWeight() > o2.getWeight() ? 1 : -1;
+				return 0;
+			} 
+		};
+		Collections.sort(l, x);
+		delegates = (IVariableProvider[]) l.toArray(new IVariableProvider[l.size()]);
+	}
+	
+	public String[] getVariableNames() {
+		sort();
+		ArrayList<String> list = new ArrayList<String>();
+		String[] names;
+		for(int i = 0; i < delegates.length; i++ ) {
+			if( delegates[i].getEnabled()) {
+				names = delegates[i].getVariableNames();
+				for( int j = 0; j < names.length; j++ ) {
+					if( !list.contains(names[j]))
+						list.add(names[j]);
+				}
+			}
+		}
+
+		return (String[]) list.toArray(new String[list.size()]);
+	}
+	
+	public boolean containsVariable(String variable) {
+		sort();
+		for(int i = 0; i < delegates.length; i++ ) 
+			if( delegates[i].getEnabled() && delegates[i].containsVariable(variable))
+				return true;
+		return false;
+	}
+
+	public String getVariableValue(String variable) {
+		sort();
+		for(int i = 0; i < delegates.length; i++ ) 
+			if( delegates[i].getEnabled() && delegates[i].containsVariable(variable))
+				return delegates[i].getVariableValue(variable);
+		return null;
+	}
+	
+	
+	public IVariableProvider getVariableLocation(String variable) {
+		sort();
+		for(int i = 0; i < delegates.length; i++ ) 
+			if( delegates[i].getEnabled() && delegates[i].containsVariable(variable))
+				return delegates[i];
+		return null;
+	}
+		
+	public static abstract class AbstractVariableProvider implements IVariableProvider {
+		protected String id;
+		protected String name;
+		protected boolean enabled;
+		protected int weight;
+		protected int defaultWeight;
+		
+		public AbstractVariableProvider(String id, String name, int defaultWeight) {
+			this.id = id;
+			this.name = name;
+			this.defaultWeight = defaultWeight;
+		}
+		
+		public String getId() {
+			return id;
+		}
+
+		public String getName() {
+			return name;
+		}
+		
+		public boolean getEnabled() {
+			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+			return prefs.getBoolean(getPreferencePrefix() + "enabled", true);
+		}
+		
+		public int getWeight() {
+			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+			return prefs.getInt(getPreferencePrefix() + "weight", defaultWeight);
+		}
+
+		public void setEnabled(boolean b) {
+			try {
+				IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+				prefs.putBoolean(getPreferencePrefix() + "enabled", b);
+				prefs.flush();
+				enabled = b;
+			} catch (BackingStoreException e) { 
+				ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
+			}
+		}
+		
+		public void setWeight(int i) {
+			try {
+				IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+				prefs.putInt(getPreferencePrefix() + "weight", i);
+				prefs.flush();
+				weight = i;
+			} catch (BackingStoreException e) { 
+				ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
+			}
+		}
+		
+		public int getDefaultWeight() {
+			return defaultWeight;
+		}
+		
+		public abstract String getPreferencePrefix();
+	}
+	
+	
+	public static class DefaultVariableProvider extends AbstractVariableProvider {
+		public static final String VALUE_PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.VariableManager.values.";
+		public static final String PREFERENCE_PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.VariableManager.prefs.";
+		public static final String ID = "org.jboss.ide.eclipse.archives.core.defaultVariableProvider";
+		public DefaultVariableProvider() {
+			super(ID, "Archives Variables", 0);
+		}
+		public String getPreferencePrefix() {
+			return PREFERENCE_PREFIX;
+		}
+		public boolean containsVariable(String variable) {
+			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+			return prefs.get(VALUE_PREFIX + variable, null) != null;
+		}
+
+		public String[] getVariableNames() {
+			int prefixLength = VALUE_PREFIX.length();
+			ArrayList<String> list = new ArrayList<String>();
+			try {
+				IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+				String[] keys = prefs.keys();
+				for( int i = 0; i < keys.length; i++ )
+					if( keys[i].startsWith(VALUE_PREFIX) && !list.contains(keys[i].substring(prefixLength))) {
+						list.add(keys[i].substring(prefixLength));
+					}
+			} catch( BackingStoreException bse) {}
+			return (String[]) list.toArray(new String[list.size()]);
+		}
+
+		public String getVariableValue(String variable) {
+			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+			return prefs.get(VALUE_PREFIX + variable, null);
+		}
+	}
+	
+	public static class LinkedResourceVariableProvider extends AbstractVariableProvider {
+		public static final String PREFERENCE_PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.LinkedResourceVariableManager.prefs.";
+		public static final String ID = "org.jboss.ide.eclipse.archives.core.resourceVariableProvider";
+		public LinkedResourceVariableProvider() {
+			super(ID, "Linked Resources Path Variables", 1);
+		}
+		public String getPreferencePrefix() {
+			return PREFERENCE_PREFIX;
+		}
+		public boolean containsVariable(String variable) {
+			return ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable) != null;
+		}
+
+		public String[] getVariableNames() {
+			return ResourcesPlugin.getWorkspace().getPathVariableManager().getPathVariableNames();
+		}
+
+		public String getVariableValue(String variable) {
+			return ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable).toString();
+		}
+	}
+	
+	public static class ClasspathVariableProvider extends AbstractVariableProvider {
+		public static final String PREFERENCE_PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.JDTVariableProvider.prefs.";
+		public static final String ID = "org.jboss.ide.eclipse.archives.core.classpathVariableProvider";
+		public ClasspathVariableProvider() {
+			super(ID, "Classpath Variables", 2);
+		}
+		public String getPreferencePrefix() {
+			return PREFERENCE_PREFIX;
+		}
+
+		public boolean containsVariable(String variable) {
+			return Arrays.asList(JavaCore.getClasspathVariableNames()).contains(variable);
+		}
+
+		public String[] getVariableNames() {
+			return JavaCore.getClasspathVariableNames();
+		}
+
+		public String getVariableValue(String variable) {
+			return JavaCore.getClasspathVariable(variable).toString();
+		}
+	}
+	
+
+	public static class ValueVariableProvider extends AbstractVariableProvider {
+		public static final String PREFERENCE_PREFIX = "org.jboss.ide.eclipse.archives.core.model.other.internal.ValueVariableProvider.prefs.";
+		public static final String ID = "org.jboss.ide.eclipse.archives.core.stringReplacementValueVariables";
+		public ValueVariableProvider() {
+			super(ID, "String Replacement Variables", 3);
+		}
+		public String getPreferencePrefix() {
+			return PREFERENCE_PREFIX;
+		}
+
+		public boolean containsVariable(String variable) {
+			return VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(variable) != null;
+		}
+
+		public String[] getVariableNames() {
+			ArrayList<String> list = new ArrayList<String>();
+			IStringVariable[] keys2 = VariablesPlugin.getDefault().getStringVariableManager().getValueVariables();
+			for( int i = 0; i < keys2.length; i++ )
+				list.add(keys2[i].getName());
+			return (String[]) list.toArray(new String[list.size()]);
+		}
+
+		public String getVariableValue(String variable) {
+			IValueVariable v = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(variable);
+			if( v != null )
+				return v.getValue();
+			return null;
+		}
+	}
+	
+	public void setValue(String name, String value) {
+		try {
+			IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+			if( value != null )
+				prefs.put(DefaultVariableProvider.VALUE_PREFIX + name, value.toString());
+			else 
+				prefs.remove(DefaultVariableProvider.VALUE_PREFIX + name);
+			prefs.flush();
+		} catch (BackingStoreException e) { 
+			ArchivesCore.getInstance().getLogger().log(IArchivesLogger.MSG_ERR, e.getMessage(), e);
+		}
+	}
+}
\ No newline at end of file

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -22,7 +22,9 @@
 		// TODO Auto-generated method stub
 		return null;
 	}
-
+	public String[] getVariableNames() {
+		return new String[0];
+	}
 	public boolean containsVariable(String variable) {
 		return false;
 	}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -96,11 +96,6 @@
 			setBasedir2(fs.rawPath);
 		}
 		
-		/* TODO:
-		 * This *must* translate all variables out before
-		 * setting in superclass. Ant will not understand
-		 * variables!
-		 */
 		public void setBasedir2(String path) {
 			String translatedPath = replaceVariables(path);
 			if( translatedPath != null ) {

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -99,6 +99,12 @@
 	public IPath getDestinationPath();
 
 	/**
+	 * Exactly as from the delegate
+	 * @return
+	 */
+	public String getRawDestinationPath();
+
+	/**
 	 * Set the package type of this package
 	 * @param type The package type
 	 */

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -29,4 +29,5 @@
 	public static final String CURRENT_PROJECT = "current.project";
 	public boolean containsVariable(String variable);
 	public String getVariableValue(String variable);
+	public String[] getVariableNames();
 }

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -95,6 +95,13 @@
 		return packageDelegate.getToDir() == null ? Path.EMPTY : new Path(packageDelegate.getToDir());
 	}
 	
+	public String getRawDestinationPath() {
+		if( !isTopLevel() )
+			return "";
+		return packageDelegate.getToDir() == null ? "" : packageDelegate.getToDir();
+	}
+	
+	
 	/*
 	 * @see IArchive#getArchiveFilePath()
 	 */
@@ -148,7 +155,7 @@
 	 * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPreActions()
 	 */
 	public IArchiveAction[] getPreActions() {
-		return new IArchiveAction[0]; // TODO
+		return new IArchiveAction[0]; // TODO getPreActions
 	}
 	
 	/*
@@ -156,7 +163,7 @@
 	 * @see org.jboss.ide.eclipse.archives.core.model.IArchive#getPostActions()
 	 */
 	public IArchiveAction[] getPostActions() {
-		return new IArchiveAction[0]; // TODO
+		return new IArchiveAction[0]; // TODO getPostActions
 	}
 
 	/*

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -198,7 +198,6 @@
 	
 	/**
 	 * Gets all properly-created de.sch destination files for a fileset
-	 * - // TODO MAKE SURE VARIABLES ARE TRANSLATED
 	 * @param inputFiles
 	 * @param fs
 	 * @return

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF	2008-07-14 18:22:49 UTC (rev 9132)
@@ -6,17 +6,18 @@
 Bundle-Activator: org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.ui,
+ org.eclipse.ui.ide,
  org.eclipse.core.runtime,
+ org.eclipse.core.resources,
  org.jboss.ide.eclipse.archives.core,
- org.eclipse.core.resources,
- org.eclipse.ui.ide
+ org.eclipse.jdt.ui;bundle-version="3.4.0",
+ org.eclipse.debug.ui;bundle-version="3.4.0"
 Eclipse-LazyStart: true
 Export-Package: org.jboss.ide.eclipse.archives.ui,
  org.jboss.ide.eclipse.archives.ui.actions,
  org.jboss.ide.eclipse.archives.ui.dialogs,
  org.jboss.ide.eclipse.archives.ui.preferences,
  org.jboss.ide.eclipse.archives.ui.providers,
- org.jboss.ide.eclipse.archives.ui.util,
  org.jboss.ide.eclipse.archives.ui.util.composites,
  org.jboss.ide.eclipse.archives.ui.views,
  org.jboss.ide.eclipse.archives.ui.wizards,

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml	2008-07-14 18:22:49 UTC (rev 9132)
@@ -56,6 +56,11 @@
             class="org.jboss.ide.eclipse.archives.ui.preferences.MainPreferencePage"
             id="org.jboss.ide.eclipse.archives.ui.archivesPreferencePage"
             name="Packaging Archives"/>
+      <page
+            category="org.jboss.ide.eclipse.archives.ui.archivesPreferencePage"
+            class="org.jboss.ide.eclipse.archives.ui.preferences.VariablesPreferencePage"
+            id="org.jboss.ide.eclipse.archives.ui.variablesPreferencePage"
+            name="Archives Variables"/>
    </extension>
    
    

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -87,6 +87,27 @@
 	public static String FilesetInfoWizardPage_fileWorkspaceBrowser_title;
 	public static String FilesetInfoWizardPage_fileWorkspaceBrowser_message;
 	
+	/* Preference Page */
+	public static String PreferencePageTitle;
+	public static String ProjectSpecificSettings;
+	public static String CorePreferences;
+	public static String EnableIncrementalBuilder;
+
+	public static String ProjectPackagesView;
+	public static String ShowFullOutputPath;
+	public static String ShowFullRootDirectory;
+	public static String ShowRootProject;
+	public static String ShowAllProjects;
+	public static String ArchivesVariables;
+	public static String VariablesGroup;
+	public static String Add;
+	public static String Edit;
+	public static String Remove;
+	public static String Enable;
+	public static String Disable;
+	public static String MoveUp;
+	public static String MoveDown;
+	
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, ArchivesUIMessages.class);
 	}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/ArchivesUIMessages.properties	2008-07-14 18:22:49 UTC (rev 9132)
@@ -78,4 +78,23 @@
 PackageNodeDestinationDialog_packageLabel=archive
 PackageNodeDestinationDialog_filesetLabel=fileset
 PackageNodeDestinationDialog_folderLabel=folder
-PackageNodeDestinationDialog_title=Select a destination
\ No newline at end of file
+PackageNodeDestinationDialog_title=Select a destination
+
+PreferencePageTitle=Packaging Archives
+ProjectSpecificSettings=Enable Project Specific Settings
+CorePreferences=Core Preferences
+EnableIncrementalBuilder=Enable incremental builder
+ProjectPackagesView=Project Packages View
+ShowFullOutputPath=Show full output path next to packages.
+ShowFullRootDirectory=Show the full root directory of filesets.
+ShowRootProject=Show project at the root
+ShowAllProjects=Show all projects that contain packages
+ArchivesVariables=Archives Variables
+VariablesGroup=Enabled Variables
+Add=Add
+Edit=Edit
+Remove=Remove
+Enable=Enable
+Disable=Disable
+MoveUp=Move Up
+MoveDown=Move Down
\ No newline at end of file

Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchiveNodeDestinationDialog.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchiveNodeDestinationDialog.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchiveNodeDestinationDialog.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,179 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.ide.IDE;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
-
-public class ArchiveNodeDestinationDialog extends ElementTreeSelectionDialog {
-
-	public ArchiveNodeDestinationDialog(Shell parent, Object destination,
-			boolean showWorkspace, boolean showNodes) {
-		super(parent, new DestinationLabelProvider(),
-				new DestinationContentProvider(showWorkspace, showNodes));
-		setAllowMultiple(false);
-		setTitle(ArchivesUIMessages.PackageNodeDestinationDialog_title);
-		setInput(ResourcesPlugin.getWorkspace());
-	}
-
-	private static class DestinationContentProvider implements
-			ITreeContentProvider {
-		private static final Object[] NO_CHILDREN = new Object[0];
-		private boolean showWorkspace, showNodes;
-
-		public DestinationContentProvider(boolean showWorkspace,
-				boolean showNodes) {
-			this.showWorkspace = showWorkspace;
-			this.showNodes = showNodes;
-		}
-
-		public Object[] getChildren(Object parentElement) {
-			if (parentElement instanceof IArchiveNode) {
-				IArchiveNode node = (IArchiveNode) parentElement;
-				List children = new ArrayList(Arrays.asList(node
-						.getAllChildren()));
-				for (Iterator iter = children.iterator(); iter.hasNext();) {
-					IArchiveNode child = (IArchiveNode) iter.next();
-					if (child.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET)
-						iter.remove();
-				}
-				return children.toArray();
-			} else if (parentElement instanceof IContainer) {
-				IContainer container = (IContainer) parentElement;
-				ArrayList result = new ArrayList();
-				if (showWorkspace) {
-					try {
-						IResource members[] = container.members();
-						for (int i = 0; i < members.length; i++) {
-							if (members[i].getType() == IResource.FOLDER)
-								result.add(members[i]);
-						}
-					} catch (CoreException e) {
-					}
-				}
-				if (showNodes && parentElement instanceof IProject) {
-					IPath path = ((IProject)parentElement).getLocation();
-					IArchive[] archives = ModelUtil.getProjectArchives(path);
-					result.addAll(Arrays.asList(archives));
-				}
-				return result.toArray();
-			}
-			return NO_CHILDREN;
-		}
-
-		public Object getParent(Object element) {
-			if (element instanceof IArchiveNode) {
-				IArchiveNode node = (IArchiveNode) element;
-				return node.getParent();
-			} else if (element instanceof IContainer) {
-				IContainer container = (IContainer) element;
-				return container.getParent();
-			}
-			return null;
-		}
-
-		public boolean hasChildren(Object element) {
-			return getChildren(element).length > 0;
-		}
-
-		public Object[] getElements(Object inputElement) {
-			 ArrayList destinations = new ArrayList();
-
-			 if (showWorkspace) {
-				 destinations.addAll(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
-			 }
-			 
-			 IProgressMonitor monitor = new NullProgressMonitor();
-			 
-			 if( showNodes ) {
-				 // add ALL packages from ALL projects
-				 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-				 for( int i = 0; i < projects.length; i++ ) {
-					 if( projects[i].isAccessible()) {
-						 IArchive[] archives = ModelUtil.getProjectArchives(projects[i].getLocation());
-						 List tmp = Arrays.asList(archives);
-						 if( tmp.size() > 0 && !destinations.contains(projects[i]))
-							 destinations.add(projects[i]);
-					 }
-				 }
-			 }
-			 return destinations.toArray();
-		}
-
-		public void dispose() {
-		}
-
-		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-		}
-	}
-
-	private static class DestinationLabelProvider implements ILabelProvider {
-		private ArchivesLabelProvider delegate;
-
-		public DestinationLabelProvider() {
-			delegate = new ArchivesLabelProvider();
-		}
-
-		public Image getImage(Object element) {
-			if (element instanceof IArchiveNode) {
-				return delegate.getImage(element);
-			} else if (element instanceof IProject) {
-				return PlatformUI.getWorkbench().getSharedImages().getImage(
-						IDE.SharedImages.IMG_OBJ_PROJECT);
-			} else if (element instanceof IFolder) {
-				return PlatformUI.getWorkbench().getSharedImages().getImage(
-						ISharedImages.IMG_OBJ_FOLDER);
-			}
-			return null;
-		}
-
-		public String getText(Object element) {
-			if (element instanceof IArchiveNode) {
-				return delegate.getText(element);
-			} else if (element instanceof IContainer) {
-				return ((IContainer) element).getName();
-			}
-			return "";
-		}
-
-		public void addListener(ILabelProviderListener listener) {
-		}
-
-		public void dispose() {
-		}
-
-		public boolean isLabelProperty(Object element, String property) {
-			return true;
-		}
-
-		public void removeListener(ILabelProviderListener listener) {
-		}
-
-	}
-}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchivesVariableDialog.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchivesVariableDialog.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/ArchivesVariableDialog.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * I had to copy this class from debug.ui because
+ * there were no getters or setters provided in the
+ * FieldSummary class. 
+ * 
+ * Assholes. 
+ */
+package org.jboss.ide.eclipse.archives.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IVariableProvider;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVFS;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager.DefaultVariableProvider;
+
+public class ArchivesVariableDialog extends Dialog {
+	private String title;
+	protected Composite panel;
+	private String name;
+	private String value;
+	private boolean canChangeName = true;
+	public ArchivesVariableDialog(Shell shell) {
+		super(shell);
+		this.title = "Archives Variable";
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+		this.name = "";
+		this.value = "";
+	}
+
+	public ArchivesVariableDialog(Shell shell, String name, String value) {
+		this(shell);
+		this.name = name;
+		this.value = value;
+		canChangeName = false;
+	}
+	protected void configureShell(Shell shell) {
+		super.configureShell(shell);
+		if (title != null) {
+			shell.setText(title);
+		}
+	}
+
+	protected Control createButtonBar(Composite parent) {
+		Control bar = super.createButtonBar(parent);
+		validateFields();
+		return bar;
+	}
+	
+	protected Control createDialogArea(Composite parent) {
+		Composite container = (Composite)super.createDialogArea(parent);
+		container.setLayout(new GridLayout(2, false));
+		container.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		panel = new Composite(container, SWT.NONE);
+		GridLayout layout = new GridLayout(2, false);
+		panel.setLayout(layout);
+		panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		
+		createNameField("Name", name);
+		createValueField("Value", value);
+		Dialog.applyDialogFont(container);
+		return container;
+	}
+
+	protected void createNameField(String labelText, String initialValue) { 
+		Label label = new Label(panel, SWT.NONE);
+		label.setText(labelText);
+		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+		
+		final Text text = new Text(panel, SWT.SINGLE | SWT.BORDER);
+		text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		// make sure rows are the same height on both panels.
+		label.setSize(label.getSize().x, text.getSize().y); 
+		
+		if (initialValue != null) {
+			text.setText(initialValue);
+		}
+		
+		text.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				name = text.getText();
+				validateFields();
+			}
+		});
+		if( !canChangeName )
+			text.setEnabled(false);
+	}
+	
+	protected void createValueField(String labelText, String initialValue) {
+		Label label = new Label(panel, SWT.NONE);
+		label.setText(labelText);
+		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+		
+		Composite comp = new Composite(panel, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.marginHeight=0;
+		layout.marginWidth=0;
+		comp.setLayout(layout);
+		comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		
+		final Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
+		GridData data = new GridData(GridData.FILL_HORIZONTAL);
+		data.widthHint = 200;
+		text.setLayoutData(data);
+
+		// make sure rows are the same height on both panels.
+		label.setSize(label.getSize().x, text.getSize().y); 
+		
+		if (initialValue != null) {
+			text.setText(initialValue);
+		}
+
+		text.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				value=text.getText();
+				validateFields();
+			}
+		});
+
+		Button button = createButton(comp, IDialogConstants.IGNORE_ID, "Browse", false); 
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				DirectoryDialog dialog = new DirectoryDialog(getShell());
+				String currentWorkingDir = text.getText();
+				if (!currentWorkingDir.trim().equals("")) {
+					File path = new File(currentWorkingDir);
+					if (path.exists()) {
+						dialog.setFilterPath(currentWorkingDir);
+					}			
+				}
+				
+				String selectedDirectory = dialog.open();
+				if (selectedDirectory != null) {
+					text.setText(selectedDirectory);
+				}		
+			}
+		});
+	}
+	
+	public void validateFields() {
+		boolean valid = true;
+		if( "".equals(name)) valid = false;
+		if( "".equals(value)) valid = false;
+		WorkspaceVariableManager mgr = ((WorkspaceVFS)ArchivesCore.getInstance().getVFS()).getVariableManager();
+		IVariableProvider loc = mgr.getVariableLocation(name);
+		// already declared
+		if( loc != null && DefaultVariableProvider.ID.equals(loc.getId()) && canChangeName)
+			valid = false;
+		getButton(IDialogConstants.OK_ID).setEnabled(valid);
+	}
+	public String getName() {
+		return name;
+	}
+
+	public String getValue() {
+		return value;
+	}
+}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -19,6 +19,7 @@
 import org.jboss.ide.eclipse.archives.core.ArchivesCore;
 import org.jboss.ide.eclipse.archives.core.model.IPreferenceManager;
 import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
 import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
 import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
 
@@ -34,7 +35,7 @@
 	
 	public MainPreferencePage() {
 		super();
-		setTitle("Packaging Archives");
+		setTitle(ArchivesUIMessages.PreferencePageTitle);
 		setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE));
 	}
 
@@ -86,7 +87,7 @@
 			overrideComp = new Composite(main, SWT.NONE);
 			overrideComp.setLayout(new FillLayout());
 			overrideButton = new Button(overrideComp, SWT.CHECK);
-			overrideButton.setText("Enable Project Specific Settings");
+			overrideButton.setText(ArchivesUIMessages.ProjectSpecificSettings);
 			
 			overrideButton.addSelectionListener(new SelectionListener(){
 				public void widgetDefaultSelected(SelectionEvent e) {
@@ -110,29 +111,29 @@
 	
 	protected void createCorePrefs(Composite main) {
 		corePrefGroup = new Group(main, SWT.NONE);
-		corePrefGroup.setText("Core Preferences");
+		corePrefGroup.setText(ArchivesUIMessages.CorePreferences);
 		corePrefGroup.setLayout(new GridLayout(1, false));
 		corePrefGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));		
 		
 		automaticBuilder = new Button(corePrefGroup, SWT.CHECK);
-		automaticBuilder.setText("Enable incremental builder");
+		automaticBuilder.setText(ArchivesUIMessages.EnableIncrementalBuilder);
 	}
 	
 	protected void createViewPrefs(Composite main) {
 		
 		viewPrefGroup = new Group(main, SWT.NONE);
-		viewPrefGroup.setText("Project Packages View");
+		viewPrefGroup.setText(ArchivesUIMessages.ProjectPackagesView);
 		viewPrefGroup.setLayout(new GridLayout(1, false));
 		viewPrefGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 		
 		showPackageOutputPath = new Button(viewPrefGroup, SWT.CHECK);
-		showPackageOutputPath.setText("Show full output path next to packages.");
+		showPackageOutputPath.setText(ArchivesUIMessages.ShowFullOutputPath);
 		
 		showFullFilesetRootDir = new Button(viewPrefGroup, SWT.CHECK);
-		showFullFilesetRootDir.setText("Show the full root directory of filesets.");
+		showFullFilesetRootDir.setText(ArchivesUIMessages.ShowFullRootDirectory);
 		
 		showProjectRoot = new Button(viewPrefGroup, SWT.CHECK);
-		showProjectRoot.setText("Show project at the root");
+		showProjectRoot.setText(ArchivesUIMessages.ShowRootProject);
 		
 		showProjectRoot.addSelectionListener(new SelectionListener () {
 			public void widgetDefaultSelected(SelectionEvent e) {
@@ -149,13 +150,13 @@
 		});
 		
 		showAllProjects = new Button(viewPrefGroup, SWT.CHECK);
-		showAllProjects.setText("Show all projects that contain packages");
+		showAllProjects.setText(ArchivesUIMessages.ShowAllProjects);
 		showAllProjects.setEnabled(showProjectRoot.getSelection());
 		if( !showProjectRoot.getSelection() ) 
 			showAllProjects.setSelection(false);
 
 	}
-
+	
 	public void init(IWorkbench workbench) {
 	}
 

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/VariablesPreferencePage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/VariablesPreferencePage.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/VariablesPreferencePage.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,429 @@
+package org.jboss.ide.eclipse.archives.ui.preferences;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IPreferenceManager;
+import org.jboss.ide.eclipse.archives.core.model.IVariableProvider;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVFS;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager.DefaultVariableProvider;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.dialogs.ArchivesVariableDialog;
+
+public class VariablesPreferencePage extends PropertyPage implements
+		IWorkbenchPreferencePage {
+	
+	private Group variablesGroup;
+	private TreeViewer variablesViewer;
+	private Button add,edit,remove,moveUp,moveDown,enable,disable;
+	private HashMap<IVariableProvider, Integer> newWeights;
+	private HashMap<IVariableProvider, Boolean> newEnablement;
+	
+	public VariablesPreferencePage() {
+		super();
+		setTitle(ArchivesUIMessages.ArchivesVariables);
+		setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE));
+		newWeights = new HashMap<IVariableProvider, Integer>();
+		newEnablement = new HashMap<IVariableProvider, Boolean>();
+	}
+
+	protected Control createContents(Composite parent) {
+		Composite main = new Composite(parent, SWT.NONE);
+		main.setLayout(new GridLayout(1, false));
+		
+		createVariablesGroup(main);
+		return main;
+	}
+	
+	public IPreferenceManager getPrefManager() {
+		return ArchivesCore.getInstance().getPreferenceManager();
+	}
+	
+	protected void createVariablesGroup(Composite main) {
+		variablesGroup = new Group(main, SWT.NONE);
+		variablesGroup.setText(ArchivesUIMessages.VariablesGroup);
+		variablesGroup.setLayout(new FormLayout());
+		variablesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		variablesViewer = new TreeViewer(variablesGroup);
+		FormData fd = new FormData();
+		fd.left = new FormAttachment(0,5);
+		fd.top = new FormAttachment(0,5);
+		fd.right = new FormAttachment(0,300);
+		fd.bottom = new FormAttachment(80,0);
+		variablesViewer.getTree().setLayoutData(fd);
+		variablesViewer.setContentProvider(new VariablesContentProvider());
+		variablesViewer.setLabelProvider(new VariablesLabelProvider());
+		variablesViewer.setInput("");
+		
+		variablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				viewerSelectionChanged();
+			} 
+		});
+		
+		// buttons
+		add = new Button(variablesGroup, SWT.NONE);
+		edit = new Button(variablesGroup, SWT.NONE);
+		remove = new Button(variablesGroup, SWT.NONE);
+		moveUp = new Button(variablesGroup, SWT.NONE);
+		moveDown = new Button(variablesGroup, SWT.NONE);
+		enable = new Button(variablesGroup, SWT.NONE);
+		disable = new Button(variablesGroup, SWT.NONE);
+		add.setLayoutData(createButtonLayoutData(null));
+		edit.setLayoutData(createButtonLayoutData(add));
+		remove.setLayoutData(createButtonLayoutData(edit));
+		moveUp.setLayoutData(createButtonLayoutData(remove));
+		moveDown.setLayoutData(createButtonLayoutData(moveUp));
+		enable.setLayoutData(createButtonLayoutData(moveDown));
+		disable.setLayoutData(createButtonLayoutData(enable));
+		add.setText(ArchivesUIMessages.Add);
+		edit.setText(ArchivesUIMessages.Edit);
+		remove.setText(ArchivesUIMessages.Remove);
+		moveUp.setText(ArchivesUIMessages.MoveUp);
+		moveDown.setText(ArchivesUIMessages.MoveDown);
+		enable.setText(ArchivesUIMessages.Enable);
+		disable.setText(ArchivesUIMessages.Disable);
+		
+		add.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addPressed();
+			} });
+		edit.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				editPressed();
+			} });
+		remove.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				removePressed();
+			} });
+
+		moveUp.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				Object sel = getSelection();
+				List<IVariableProvider> sorted = getSortedDelegates();
+				int current = sorted.indexOf(sel);
+				if( current > 0 ) {
+					newWeights.put(sorted.get(current-1), new Integer(current));
+					newWeights.put(sorted.get(current), new Integer(current-1));
+				}
+				refreshAll();
+			} });
+
+		moveDown.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				Object sel = getSelection();
+				List<IVariableProvider> sorted = getSortedDelegates();
+				int current = sorted.indexOf(sel);
+				if( current < sorted.size()-1 ) {
+					newWeights.put(sorted.get(current+1), new Integer(current));
+					newWeights.put(sorted.get(current), new Integer(current+1));
+				}
+				refreshAll();
+			} });
+
+		
+		enable.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				Object sel = getSelection();
+				if( sel instanceof IVariableProvider )
+					newEnablement.put((IVariableProvider)sel, new Boolean(true));
+				refreshAll();
+			} });
+		disable.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+			public void widgetSelected(SelectionEvent e) {
+				Object sel = getSelection();
+				if( sel instanceof IVariableProvider )
+					newEnablement.put((IVariableProvider)sel, new Boolean(false));
+				refreshAll();
+			} });
+		
+	}
+	protected void addPressed() {
+		ArchivesVariableDialog dialog= new ArchivesVariableDialog(getShell()); 
+		if (dialog.open() == Window.OK) {
+			String name= dialog.getName();
+			String value = dialog.getValue();
+			WorkspaceVariableManager mgr = ((WorkspaceVFS)ArchivesCore.getInstance().getVFS()).getVariableManager();
+			mgr.setValue(name, value);
+		}
+		refreshAll();
+	}
+	protected void editPressed() {
+		Object sel = getSelection();
+		if( sel instanceof Wrapped && ((Wrapped)sel).getProvider().getId().equals(DefaultVariableProvider.ID)) {
+			String name = ((Wrapped)sel).getName();
+			String value = ((WorkspaceVFS)ArchivesCore.getInstance().getVFS()).getVariableManager().getVariableValue(name);
+			ArchivesVariableDialog dialog= new ArchivesVariableDialog(getShell(), name, value); 
+			if (dialog.open() == Window.OK) {
+				name= dialog.getName();
+				value = dialog.getValue();
+				WorkspaceVariableManager mgr = ((WorkspaceVFS)ArchivesCore.getInstance().getVFS()).getVariableManager();
+				mgr.setValue(name, value);
+			}
+		}
+		refreshAll();
+	}
+	protected void removePressed() {
+		Object sel = getSelection();
+		if( sel instanceof Wrapped && ((Wrapped)sel).getProvider().getId().equals(DefaultVariableProvider.ID)) {
+			String name = ((Wrapped)sel).getName();
+			((WorkspaceVFS)ArchivesCore.getInstance().getVFS()).getVariableManager().setValue(name, null);
+		}
+			
+		refreshAll();
+	}
+
+	protected void refreshAll() {
+		variablesViewer.refresh();
+		viewerSelectionChanged();
+	}
+	
+	protected FormData createButtonLayoutData(Control top) {
+		FormData fd = new FormData();
+		if( top != null )
+			fd.top = new FormAttachment(top, 5);
+		else 
+			fd.top = new FormAttachment(0,5);
+		fd.left = new FormAttachment(variablesViewer.getTree(), 5);
+		fd.right = new FormAttachment(100,-5);
+		return fd;
+	}
+
+	protected class Wrapped {
+		protected IVariableProvider p;
+		protected String name;
+		public Wrapped(IVariableProvider p, String name) {
+			this.p = p;
+			this.name = name;
+		}
+		public IVariableProvider getProvider() { return p; }
+		public String getName() { return name; }
+		public String toString() {
+			return name + ": " + p.getVariableValue(name);
+		}
+	}
+	
+	protected class VariablesContentProvider implements ITreeContentProvider {
+
+		public Object[] getChildren(Object parentElement) {
+			if( parentElement instanceof IVariableProvider ) {
+				String[] props = ((IVariableProvider)parentElement).getVariableNames();
+				Wrapped[] items = new Wrapped[props.length];
+				for( int i = 0; i < props.length; i++ ) 
+					items[i] = new Wrapped((IVariableProvider)parentElement, props[i]);
+				return items;
+			}
+			return null;
+		}
+
+		public Object getParent(Object element) {
+			return null;
+		}
+
+		public boolean hasChildren(Object element) {
+			return element instanceof IVariableProvider && ((IVariableProvider)element).getVariableNames().length > 0;
+		}
+
+		public Object[] getElements(Object inputElement) {
+			List<IVariableProvider> elements = getSortedDelegates();
+			return (IVariableProvider[]) elements
+					.toArray(new IVariableProvider[elements.size()]);
+		}
+
+		public void dispose() {
+		}
+
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		}
+	}
+
+	protected List<IVariableProvider> getSortedDelegates() {
+		WorkspaceVFS vfs = (WorkspaceVFS)ArchivesCore.getInstance().getVFS();
+		WorkspaceVariableManager mgr = vfs.getVariableManager();
+		IVariableProvider[] delegates = mgr.getDelegates();
+		
+		// sort with changed data
+		List<IVariableProvider> l = Arrays.asList(delegates);
+		Comparator<IVariableProvider> x = new Comparator<IVariableProvider>() {
+			public int compare(IVariableProvider o1, IVariableProvider o2) {
+				if( nowEnabled(o1) != nowEnabled(o2))
+					return nowEnabled(o1) ? -1 : 1;
+
+				// now weights
+				if( nowWeight(o1) != nowWeight(o2) ) 
+					return nowWeight(o1) > nowWeight(o2) ? 1 : -1;
+				return 0;
+			}
+		};
+		Collections.sort(l, x);
+		return l;
+	}
+	protected boolean nowEnabled(IVariableProvider o) {
+		boolean enabled = o.getEnabled();
+		if( newEnablement.get(o) != null)
+			enabled = newEnablement.get(o).booleanValue();
+		return enabled;
+	}
+	protected int nowWeight(IVariableProvider o) {
+		int weight = o.getWeight();
+		if( newWeights.get(o) != null )
+			weight = newWeights.get(o).intValue();
+		return weight;
+	}
+	
+	protected class VariablesLabelProvider extends BaseLabelProvider implements ILabelProvider {
+		
+		private HashMap<Image, Image> disabledImages;
+		public VariablesLabelProvider() {
+			disabledImages = new HashMap<Image, Image>();
+		}
+		public Image getImage(Object element) {
+			if( element instanceof IVariableProvider ) {
+				String id = ((IVariableProvider)element).getId();
+				boolean enabled = nowEnabled((IVariableProvider)element);
+				if(id.equals("org.jboss.ide.eclipse.archives.core.resourceVariableProvider"))
+					return getImage2(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER), enabled);
+				if( id.equals("org.jboss.ide.eclipse.archives.core.classpathVariableProvider"))
+					return getImage2(JavaPlugin.getDefault().getImageRegistry().get(JavaPluginImages.IMG_OBJS_EXTJAR), enabled);
+				if( id.equals("org.jboss.ide.eclipse.archives.core.stringReplacementValueVariables"))
+					return getImage2(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_PASTE), enabled);
+			}
+			if( element instanceof Wrapped ) {
+				return getImage(((Wrapped)element).getProvider());
+			}
+			return null;
+		}
+		protected Image getImage2(Image original, boolean enabled) {
+			if( enabled ) 
+				return original;
+			if( disabledImages.get(original) == null ) {
+				Image i2 = new DecorationOverlayIcon(original, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage();
+				disabledImages.put(original, i2);
+			}
+			return disabledImages.get(original);
+		}
+		public String getText(Object element) {
+			if( element instanceof IVariableProvider ) {
+				return ((IVariableProvider)element).getName();
+			}
+			if( element instanceof Wrapped )
+				return ((Wrapped)element).toString();
+			return "";
+		}
+	    public void dispose() {
+	    	super.dispose();
+	    	Iterator<Image> i = disabledImages.values().iterator();
+	    	while(i.hasNext()) 
+	    		i.next().dispose();
+	    }
+	}
+	
+	protected Object getSelection() {
+		IStructuredSelection sel = (IStructuredSelection)variablesViewer.getSelection();
+		return sel.getFirstElement();
+	}
+	
+	protected void viewerSelectionChanged() {
+		Object selected = getSelection();
+		List<IVariableProvider> dels = getSortedDelegates();
+		boolean variableProvider = selected != null && selected instanceof IVariableProvider;
+		boolean defaultProvider = selected != null && 
+			(variableProvider ? (IVariableProvider)selected : ((Wrapped)selected).getProvider())
+				.getId().equals(WorkspaceVariableManager.DEFAULT_PROVIDER);
+		boolean removable = !variableProvider && defaultProvider;
+		boolean notLast = dels.indexOf(selected) != dels.size()-1;
+		boolean notFirst = dels.indexOf(selected) != 0;
+		boolean canMoveDown = variableProvider && notLast 
+			&& nowEnabled(dels.get(dels.indexOf(selected)+1)) == nowEnabled((IVariableProvider)selected);
+		boolean canMoveUp = variableProvider && notFirst 
+			&& nowEnabled(dels.get(dels.indexOf(selected)-1)) == nowEnabled((IVariableProvider)selected);
+		
+		add.setEnabled(defaultProvider || selected == null);
+		edit.setEnabled(removable);
+		remove.setEnabled(removable);
+		moveUp.setEnabled(variableProvider && canMoveUp);
+		moveDown.setEnabled(variableProvider && canMoveDown);
+		enable.setEnabled(variableProvider && !nowEnabled((IVariableProvider)selected));
+		disable.setEnabled(variableProvider && nowEnabled((IVariableProvider)selected));
+	}
+	
+	public void init(IWorkbench workbench) {
+	}
+
+	public void performDefaults() {
+		List<IVariableProvider> dels = getSortedDelegates();
+		IVariableProvider provider;
+		for( int i = 0; i < dels.size(); i++ ) {
+			provider = dels.get(i);
+			newEnablement.put(provider, new Boolean(true));
+			newWeights.put(provider, new Integer(provider.getDefaultWeight()));
+		}
+		refreshAll();
+	}
+
+	public boolean performOk() {
+		List<IVariableProvider> dels = getSortedDelegates();
+		IVariableProvider provider;
+		for( int i = 0; i < dels.size(); i++ ) {
+			provider = dels.get(i);
+			if( newEnablement.get(provider) != null )
+				provider.setEnabled(newEnablement.get(provider).booleanValue());
+			if( newWeights.get(provider) != null )
+				provider.setWeight(newWeights.get(provider).intValue());
+		}
+		return true;
+	}
+}

Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/DestinationChangeListener.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/DestinationChangeListener.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/DestinationChangeListener.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,7 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.util;
-
-public interface DestinationChangeListener {
-
-	public void destinationChanged (Object newDestination);
-	
-}

Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveDestinationComposite.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,82 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.util.composites;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.dialogs.ArchiveNodeDestinationDialog;
-
-public class ArchiveDestinationComposite extends ArchiveNodeDestinationComposite {
-
-	protected boolean inWorkspace;
-	protected Button filesystemBrowseButton, workspaceBrowseButton;
-	
-	public ArchiveDestinationComposite (Composite parent, int style, Object destination) {
-		super(parent, style, destination);
-	}
-	
-	protected void fillBrowseComposite(Composite parent) {
-		Composite browseComposite = new Composite(parent, SWT.NONE);
-		browseComposite.setLayout(new GridLayout(2, false));
-		
-		workspaceBrowseButton = new Button(browseComposite, SWT.PUSH);
-		workspaceBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_workspaceBrowseButton_label);
-		workspaceBrowseButton.addSelectionListener(new SelectionAdapter () {
-			public void widgetSelected(SelectionEvent e) {
-				openDestinationDialog();
-			}
-		});
-		
-		filesystemBrowseButton = new Button(browseComposite, SWT.PUSH);
-		filesystemBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_filesystemBrowseButton_label);
-		filesystemBrowseButton.addSelectionListener(new SelectionAdapter () {
-			public void widgetSelected(SelectionEvent e) {
-				browseFilesystem();
-			}
-		});
-	}
-	
-	protected void openDestinationDialog() {
-		ArchiveNodeDestinationDialog dialog = new ArchiveNodeDestinationDialog(getShell(), nodeDestination, true, true);
-		if (nodeDestination != null)
-			dialog.setInitialSelection(nodeDestination);
-		
-		if (dialog.open() == Dialog.OK) 
-			setPackageNodeDestination(dialog.getResult()[0]);
-	}
-	
-	protected void browseFilesystem () {
-		DirectoryDialog dialog = new DirectoryDialog(getShell());
-		String currentPath = destinationText.getText();
-		if (currentPath != null && currentPath.length() > 0 && !inWorkspace) {
-			dialog.setFilterPath(destinationText.getText());
-		}
-		
-		String path = dialog.open();
-		if (path != null) 
-			setPackageNodeDestination(new Path(path));
-	}
-	
-	protected void updateDestinationViewer() {
-		super.updateDestinationViewer();
-
-		if (nodeDestination instanceof IPath) {
-			inWorkspace = false;
-			IPath path = (IPath) nodeDestination;
-			destinationText.setText(path.toString());
-			destinationImage.setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_EXTERNAL_FILE));
-		} else if (nodeDestination instanceof IContainer || nodeDestination instanceof IArchiveNode) {
-			inWorkspace = true;
-		}
-	}
-}

Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveFilesetDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveFilesetDestinationComposite.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveFilesetDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,41 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.util.composites;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.dialogs.ArchiveNodeDestinationDialog;
-
-public class ArchiveFilesetDestinationComposite extends ArchiveNodeDestinationComposite {
-	protected Button filesystemBrowseButton;
-	public ArchiveFilesetDestinationComposite(Composite parent, int style,
-			Object destination) {
-		super(parent, style, destination);
-	}
-
-	protected void fillBrowseComposite(Composite parent) {
-		Composite browseComposite = new Composite(parent, SWT.NONE);
-		browseComposite.setLayout(new GridLayout(2, false));
-		
-		filesystemBrowseButton = new Button(browseComposite, SWT.PUSH);
-		filesystemBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_workspaceBrowseButton_label);
-		filesystemBrowseButton.addSelectionListener(new SelectionAdapter () {
-			public void widgetSelected(SelectionEvent e) {
-				openDestinationDialog();
-			}
-		});
-	}
-	
-	protected void openDestinationDialog() {
-		ArchiveNodeDestinationDialog dialog = new ArchiveNodeDestinationDialog(getShell(), nodeDestination, false, true);
-		if (nodeDestination != null)
-			dialog.setInitialSelection(nodeDestination);
-		
-		if (dialog.open() == Dialog.OK) 
-			setPackageNodeDestination(dialog.getResult()[0]);
-	}
-}

Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,156 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.util.composites;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
-
-public abstract class ArchiveNodeDestinationComposite extends Composite {
-
-	protected Composite parent;
-	protected Label destinationImage;
-	protected Text destinationText;
-	protected Object nodeDestination;
-	protected ArrayList<DestinationChangeListener> listeners;
-	
-	public ArchiveNodeDestinationComposite(Composite parent, int style, Object destination) {
-		super(parent, style);
-		this.parent = parent;
-		this.nodeDestination = destination;
-		this.listeners = new ArrayList<DestinationChangeListener>();
-		
-		createComposite();
-	}
-	
-	protected void createComposite() {
-		setLayout(new FormLayout());
-		
-		// create widgets
-		destinationImage = new Label(this, SWT.NONE);
-		destinationText = new Text(this, SWT.BORDER);
-		Composite browseComposite = new Composite(this, SWT.NONE);
-		
-		// set up their layout positioning
-		destinationImage.setLayoutData(createFormData(0,5,null, 0, 0, 0, null, 0));
-		destinationText.setLayoutData(createFormData(0, 5, null, 0, destinationImage, 5, destinationImage, 205));
-	
-		
-		// set text, add listeners, etc
-		destinationText.setEditable(false);
-
-		browseComposite.setLayout(new FillLayout());
-		browseComposite.setLayoutData(createFormData(0,0,null,0,destinationText,5,100,-5)); 
-		fillBrowseComposite(browseComposite);
-		
-		// call other functions required for startup
-		updateDestinationViewer();
-	}
-	
-	protected abstract void fillBrowseComposite(Composite browseComposite);
-	
-	private FormData createFormData(Object topStart, int topOffset, Object bottomStart, int bottomOffset, 
-									Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
-		FormData data = new FormData();
-
-		if( topStart != null ) {
-			data.top = topStart instanceof Control ? new FormAttachment((Control)topStart, topOffset) : 
-				new FormAttachment(((Integer)topStart).intValue(), topOffset);
-		}
-
-		if( bottomStart != null ) {
-			data.bottom = bottomStart instanceof Control ? new FormAttachment((Control)bottomStart, bottomOffset) : 
-				new FormAttachment(((Integer)bottomStart).intValue(), bottomOffset);
-		}
-		
-		if( leftStart != null ) {
-			data.left = leftStart instanceof Control ? new FormAttachment((Control)leftStart, leftOffset) : 
-				new FormAttachment(((Integer)leftStart).intValue(), leftOffset);
-		}
-		
-		if( rightStart != null ) {
-			data.right = rightStart instanceof Control ? new FormAttachment((Control)rightStart, rightOffset) : 
-				new FormAttachment(((Integer)rightStart).intValue(), rightOffset);
-		}
-		
-		return data;
-	}
-
-	public void setPackageNodeDestination (Object destination) {
-		nodeDestination = destination;
-		updateDestinationViewer();
-		fireDestinationChanged();
-	}
-	
-	protected void updateDestinationViewer () {
-		if (nodeDestination == null) return;
-		destinationText.setText("");
-		
-		if (nodeDestination instanceof IArchive) {
-			IArchive pkg = (IArchive) nodeDestination;
-			String txt = pkg.isTopLevel() ? pkg.getName() : pkg.getRootArchiveRelativePath().toOSString();
-			String imgKey = pkg.isExploded() ? ArchivesSharedImages.IMG_PACKAGE_EXPLODED : ArchivesSharedImages.IMG_PACKAGE;
-
-			destinationText.setText(txt);
-			destinationImage.setImage(ArchivesSharedImages.getImage(imgKey));
-		} else if (nodeDestination instanceof IArchiveFolder) {
-			IArchiveFolder folder = (IArchiveFolder) nodeDestination;
-			destinationText.setText(folder.getRootArchiveRelativePath().toString());
-			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
-		} else if (nodeDestination instanceof IProject) {
-			IProject project = (IProject) nodeDestination;
-			destinationText.setText(project.getName());
-			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT));
-		} else if (nodeDestination instanceof IFolder) {
-			IFolder folder = (IFolder) nodeDestination;
-			destinationText.setText("/" + folder.getProject().getName() + "/" + folder.getProjectRelativePath().toString());
-			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
-		}
-	}
-	
-	
-	/**
-	 * The current destination
-	 * @return
-	 */
-	
-	public Object getPackageNodeDestination () {
-		return nodeDestination;
-	}
-	
-	
-	/*
-	 * Destination change listeners
-	 */
-	
-	public void addDestinationChangeListener (DestinationChangeListener listener) {
-		listeners.add(listener);
-	}
-	
-	public void removeDestinationChangeListener (DestinationChangeListener listener) {
-		listeners.remove(listener);
-	}
-	
-	private void fireDestinationChanged () {
-		for (Iterator<DestinationChangeListener> iter = listeners.iterator(); iter.hasNext(); ) {
-			((DestinationChangeListener) iter.next()).destinationChanged(nodeDestination);
-		}
-	}
-}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationDialog.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationDialog.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveNodeDestinationDialog.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,174 @@
+package org.jboss.ide.eclipse.archives.ui.util.composites;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
+
+public class ArchiveNodeDestinationDialog extends ElementTreeSelectionDialog {
+
+	public ArchiveNodeDestinationDialog(Shell parent,
+			boolean showWorkspace, boolean showNodes) {
+		super(parent, new DestinationLabelProvider(),
+				new DestinationContentProvider(showWorkspace, showNodes));
+		setAllowMultiple(false);
+		setTitle(ArchivesUIMessages.PackageNodeDestinationDialog_title);
+		setInput(ResourcesPlugin.getWorkspace());
+	}
+
+	private static class DestinationContentProvider implements
+			ITreeContentProvider {
+		private static final Object[] NO_CHILDREN = new Object[0];
+		private boolean showWorkspace, showNodes;
+
+		public DestinationContentProvider(boolean showWorkspace,
+				boolean showNodes) {
+			this.showWorkspace = showWorkspace;
+			this.showNodes = showNodes;
+		}
+
+		public Object[] getChildren(Object parentElement) {
+			if (parentElement instanceof IArchiveNode) {
+				IArchiveNode node = (IArchiveNode) parentElement;
+				List<IArchiveNode> children = new ArrayList<IArchiveNode>(Arrays.asList(node
+						.getAllChildren()));
+				for (Iterator<IArchiveNode> iter = children.iterator(); iter.hasNext();) {
+					IArchiveNode child = iter.next();
+					if (child.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET)
+						iter.remove();
+				}
+				return children.toArray();
+			} else if (parentElement instanceof IContainer) {
+				IContainer container = (IContainer) parentElement;
+				ArrayList<Object> result = new ArrayList<Object>();
+				if (showWorkspace) {
+					try {
+						IResource members[] = container.members();
+						for (int i = 0; i < members.length; i++) {
+							if (members[i].getType() == IResource.FOLDER)
+								result.add(members[i]);
+						}
+					} catch (CoreException e) {
+					}
+				}
+				if (showNodes && parentElement instanceof IProject) {
+					IPath path = ((IProject)parentElement).getLocation();
+					IArchive[] archives = ModelUtil.getProjectArchives(path);
+					result.addAll(Arrays.asList(archives));
+				}
+				return result.toArray();
+			}
+			return NO_CHILDREN;
+		}
+
+		public Object getParent(Object element) {
+			if (element instanceof IArchiveNode) {
+				IArchiveNode node = (IArchiveNode) element;
+				return node.getParent();
+			} else if (element instanceof IContainer) {
+				IContainer container = (IContainer) element;
+				return container.getParent();
+			}
+			return null;
+		}
+
+		public boolean hasChildren(Object element) {
+			return getChildren(element).length > 0;
+		}
+
+		public Object[] getElements(Object inputElement) {
+			 ArrayList<IProject> destinations = new ArrayList<IProject>();
+
+			 if (showWorkspace) {
+				 destinations.addAll(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
+			 }
+
+			 if( showNodes ) {
+				 // add ALL packages from ALL projects
+				 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+				 for( int i = 0; i < projects.length; i++ ) {
+					 if( projects[i].isAccessible()) {
+						 IArchive[] archives = ModelUtil.getProjectArchives(projects[i].getLocation());
+						 List<IArchive> tmp = Arrays.asList(archives);
+						 if( tmp.size() > 0 && !destinations.contains(projects[i]))
+							 destinations.add(projects[i]);
+					 }
+				 }
+			 }
+			 return destinations.toArray();
+		}
+
+		public void dispose() {
+		}
+
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		}
+	}
+
+	private static class DestinationLabelProvider extends LabelProvider {
+		private ArchivesLabelProvider delegate;
+
+		public DestinationLabelProvider() {
+			delegate = new ArchivesLabelProvider();
+		}
+
+		public Image getImage(Object element) {
+			if (element instanceof IArchiveNode) {
+				return delegate.getImage(element);
+			} else if (element instanceof IProject) {
+				return PlatformUI.getWorkbench().getSharedImages().getImage(
+						IDE.SharedImages.IMG_OBJ_PROJECT);
+			} else if (element instanceof IFolder) {
+				return PlatformUI.getWorkbench().getSharedImages().getImage(
+						ISharedImages.IMG_OBJ_FOLDER);
+			}
+			return null;
+		}
+
+		public String getText(Object element) {
+			if (element instanceof IArchiveNode) {
+				return delegate.getText(element);
+			} else if (element instanceof IContainer) {
+				return ((IContainer) element).getName();
+			}
+			return "";
+		}
+
+		public void addListener(ILabelProviderListener listener) {
+		}
+
+		public void dispose() {
+		}
+
+		public boolean isLabelProperty(Object element, String property) {
+			return true;
+		}
+
+		public void removeListener(ILabelProviderListener listener) {
+		}
+
+	}
+}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,359 @@
+package org.jboss.ide.eclipse.archives.ui.util.composites;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
+
+public class ArchiveSourceDestinationComposite extends Composite {
+	private Text text;
+	private Label pathImage, translatedPath, translatedPathImage;
+	private Button workspaceButton, filesystemButton, variablesButton,
+			wsRadioButton, fsRadioButton;
+	
+	private String projectName;
+	private boolean workspaceRelative = false;
+	private IArchiveNode destinationNode;
+	private String path;
+	private boolean error;
+	private String errorString;
+	private ArrayList<ChangeListener> listeners = new ArrayList<ChangeListener>();
+
+	public ArchiveSourceDestinationComposite(Composite parent, String project) {
+		super(parent, SWT.NONE);
+		this.projectName = project;
+		setLayout(new FormLayout());
+		createWidgets();
+		layoutWidgets();
+		setWidgetData();
+		addListeners();
+		variablesButton.setEnabled(false); // todo
+	}
+	
+	protected void createWidgets() {
+		text = new Text(this, SWT.SINGLE | SWT.BORDER);
+		pathImage = new Label(this, SWT.NONE);
+		translatedPath = new Label(this, SWT.NONE);
+		translatedPathImage = new Label(this, SWT.NONE);
+		workspaceButton = new Button(this, SWT.PUSH);
+		filesystemButton = new Button(this, SWT.PUSH);
+		variablesButton = new Button(this, SWT.PUSH);
+		wsRadioButton = new Button(this, SWT.RADIO);
+		fsRadioButton = new Button(this, SWT.RADIO);
+	}
+	
+	protected void layoutWidgets() {
+		pathImage.setLayoutData(createFormData(0,0,null,0,0,0,null,0));
+		text.setLayoutData(createFormData(0,0,null,0,pathImage,5,100,0));
+		filesystemButton.setLayoutData(createFormData(text,5,null,0,null,0,100,-5));
+		workspaceButton.setLayoutData(createFormData(text,5,null,0,null,0,filesystemButton,-5));
+		variablesButton.setLayoutData(createFormData(text,5,null,0,null,0,workspaceButton,-5));
+		fsRadioButton.setLayoutData(createFormData(text,5,null,0,null,0,variablesButton,-5));
+		wsRadioButton.setLayoutData(createFormData(text,5,null,0,null,0,fsRadioButton,-5));
+		translatedPathImage.setLayoutData(createFormData(filesystemButton,5,null,0,0,0,0,20));
+		translatedPath.setLayoutData(createFormData(filesystemButton,5,null,0,translatedPathImage,5,100,-5));
+	}
+	
+	protected void setWidgetData() {
+		filesystemButton.setText("Filesystem...");
+		workspaceButton.setText("Workspace...");
+		variablesButton.setText("Variables...");
+		wsRadioButton.setText("Workspace Relative");
+		fsRadioButton.setText("Filesystem Relative");
+		pathImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+		FontData[] translatedPathData = translatedPath.getFont().getFontData();
+		for( int i = 0; i < translatedPathData.length; i++ )
+			translatedPathData[i].setHeight(7);
+		Font newFont = new Font(Display.getDefault(), translatedPathData);
+		translatedPath.setFont(newFont);
+		translatedPathImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
+	}
+	
+	protected void addListeners() {
+		text.addKeyListener(new KeyListener() {
+			public void keyPressed(KeyEvent e) {}
+			public void keyReleased(KeyEvent e) {
+				destinationNode = null;
+				path = text.getText();
+				textModified(); } });
+		
+		// selection listeners
+		filesystemButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {}
+			public void widgetSelected(SelectionEvent e) {
+				filesystemButtonPressed();} });
+		workspaceButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {}
+			public void widgetSelected(SelectionEvent e) {
+				workspaceButtonPressed();} });
+		variablesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {}
+			public void widgetSelected(SelectionEvent e) {
+				variablesButtonPressed();} });
+		fsRadioButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {}
+			public void widgetSelected(SelectionEvent e) {
+				fsRadioButtonPressed();} });
+		wsRadioButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {}
+			public void widgetSelected(SelectionEvent e) {
+				wsRadioButtonPressed();} });
+		
+	}
+	protected void textModified() {validateAndUpdateWidgets();}
+	protected void filesystemButtonPressed() {browseFilesystem();}
+	protected void workspaceButtonPressed() {openDestinationDialog();}
+	protected void variablesButtonPressed() {}
+	protected void fsRadioButtonPressed() {radioPressed(fsRadioButton);}
+	protected void wsRadioButtonPressed() {radioPressed(wsRadioButton);}
+	
+	
+	protected void openDestinationDialog() {
+		ArchiveNodeDestinationDialog dialog = new ArchiveNodeDestinationDialog(getShell(), true, true);
+		if( dialog.open() == Dialog.OK ) {
+			Object result = dialog.getResult()[0];
+			if( result instanceof IArchiveNode ) {
+				destinationNode = (IArchiveNode)result;
+				path = null;
+				workspaceRelative = true;
+			} else if( result instanceof IContainer ) {
+				destinationNode = null;
+				path = ((IContainer)result).getFullPath().toString();
+				workspaceRelative = true;
+			}
+			validateAndUpdateWidgets();
+		}
+	}
+	
+	protected void browseFilesystem () {
+		DirectoryDialog dialog = new DirectoryDialog(getShell());
+		String currentPath = null; 
+		try {
+			currentPath = getTranslatedGlobalPath();
+		} catch(CoreException ce){/* ignore */}
+
+		if (currentPath != null && currentPath.length() > 0 ) {
+			dialog.setFilterPath(currentPath);
+		}
+		
+		String path = dialog.open();
+		if( path != null ) {
+			destinationNode = null;
+			this.path = path;
+			workspaceRelative = false;
+			validateAndUpdateWidgets();
+		}
+	}
+	
+	protected void radioPressed(Button button) {
+		workspaceRelative = button == wsRadioButton;
+		validateAndUpdateWidgets();
+	}
+	
+	protected void validateAndUpdateWidgets() {
+		// clear old status
+		error = false;
+		errorString = null;
+		
+		
+		wsRadioButton.setEnabled(destinationNode == null);
+		fsRadioButton.setEnabled(destinationNode == null);
+		wsRadioButton.setSelection(destinationNode == null && workspaceRelative);
+		fsRadioButton.setSelection(destinationNode == null && !workspaceRelative);
+
+		Image image = (destinationNode == null ? 
+				PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER) : 
+				ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_PACKAGE));
+		pathImage.setImage(image);
+		text.setText(destinationNode == null ? 
+				(path == null ? "" : path) : ((INamedContainerArchiveNode)destinationNode).getName());
+
+		String translated;
+		Image img=null;
+		try { 
+			if( destinationNode != null ) {
+				translated=""; img=null;
+			} else {
+				translated = getTranslatedGlobalPath();
+				if( !new Path(translated).toFile().exists()) {
+					translated=translated + " does not exist in the filesystem.";
+					img = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+				} else {
+					img = null;
+				}
+			}
+		} catch( CoreException ce ) { 
+			translated = ce.getMessage();
+			if( ce.getStatus().getSeverity() == IStatus.ERROR) {
+				img = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+				error = true;
+				errorString = ce.getMessage();
+			} else if( ce.getStatus().getSeverity() == IStatus.WARNING)
+				img = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+		}
+		translatedPathImage.setImage(img);
+		translatedPath.setText(translated);
+		fireChange();
+	}
+
+	protected String getTranslatedGlobalPathOrError() {
+		try {
+			String postSub = ArchivesCore.getInstance().getVFS().
+								performStringSubstitution(path, projectName, true);
+			if( workspaceRelative ) { 
+				IPath p = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new Path(postSub));
+				if( p != null ) return p.toString();
+				return "Unable to convert workspace path into global path: " + postSub;
+			}
+			return postSub;
+		} catch( CoreException e ) { 
+			return "Error during string substitution: " + e.getMessage();
+		}
+		
+	}
+
+	protected String getTranslatedGlobalPath() throws CoreException {
+		try {
+			String postSub = ArchivesCore.getInstance().getVFS().
+								performStringSubstitution(path, projectName, true);
+			if( workspaceRelative ) { 
+				IPath p = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new Path(postSub));
+				if( p != null ) return p.toString();
+				String ERROR ="Unable to convert workspace path into global path: " + postSub; 
+				Status s = new Status(IStatus.WARNING, PackagesUIPlugin.PLUGIN_ID, ERROR);
+				throw new CoreException(s);
+			}
+			return postSub;
+		} catch( CoreException e ) {
+			String ERROR = "Error during string substitution: " + e.getMessage();
+			Status s = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ERROR, e);
+			throw new CoreException(s);
+		}
+	}
+	
+	private FormData createFormData(Object topStart, int topOffset,
+			Object bottomStart, int bottomOffset, Object leftStart,
+			int leftOffset, Object rightStart, int rightOffset) {
+		FormData data = new FormData();
+
+		if (topStart != null) {
+			data.top = topStart instanceof Control ? new FormAttachment(
+					(Control) topStart, topOffset) : new FormAttachment(
+					((Integer) topStart).intValue(), topOffset);
+		}
+
+		if (bottomStart != null) {
+			data.bottom = bottomStart instanceof Control ? new FormAttachment(
+					(Control) bottomStart, bottomOffset) : new FormAttachment(
+					((Integer) bottomStart).intValue(), bottomOffset);
+		}
+
+		if (leftStart != null) {
+			data.left = leftStart instanceof Control ? new FormAttachment(
+					(Control) leftStart, leftOffset) : new FormAttachment(
+					((Integer) leftStart).intValue(), leftOffset);
+		}
+
+		if (rightStart != null) {
+			data.right = rightStart instanceof Control ? new FormAttachment(
+					(Control) rightStart, rightOffset) : new FormAttachment(
+					((Integer) rightStart).intValue(), rightOffset);
+		}
+
+		return data;
+	}
+
+	
+	
+	// APIs
+	public void init(IArchiveNode dest) {
+		destinationNode = dest;
+		path = null;
+		workspaceRelative = true;
+		validateAndUpdateWidgets();
+	}
+	
+	public void init(String path, boolean workspaceRelative) {
+		this.path = path;
+		this.workspaceRelative = workspaceRelative;
+		this.destinationNode = null;
+		validateAndUpdateWidgets();
+	}
+	
+	public boolean isValid() {
+		return !error;
+	}
+	
+	public String getErrorMessage() {
+		return errorString;
+	}
+	
+	public boolean isWorkspaceRelative() {
+		return workspaceRelative;
+	}
+
+	public IArchiveNode getDestinationNode() {
+		return destinationNode;
+	}
+
+	public String getPath() {
+		return path;
+	}
+	
+	public String getTranslatedPath() {
+		try {
+			return ArchivesCore.getInstance().getVFS().
+				performStringSubstitution(path, projectName, true);
+		} catch( CoreException ce ) {}
+		return null;
+	}
+	
+	
+	public static interface ChangeListener {
+		public void compositeChanged();
+	}
+	public void addChangeListener (ChangeListener listener) {
+		listeners.add(listener);
+	}
+	
+	public void removeChangeListener (ChangeListener listener) {
+		listeners.remove(listener);
+	}
+	
+	private void fireChange() {
+		for (Iterator<ChangeListener> iter = listeners.iterator(); iter.hasNext(); ) {
+			((ChangeListener) iter.next()).compositeChanged();
+		}
+	}
+}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveDestinationComposite.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,82 @@
+package org.jboss.ide.eclipse.archives.ui.util.garbage;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveNodeDestinationDialog;
+
+public class ArchiveDestinationComposite extends ArchiveNodeDestinationComposite {
+
+	protected boolean inWorkspace;
+	protected Button filesystemBrowseButton, workspaceBrowseButton;
+	
+	public ArchiveDestinationComposite (Composite parent, int style, Object destination) {
+		super(parent, style, destination);
+	}
+	
+	protected void fillBrowseComposite(Composite parent) {
+		Composite browseComposite = new Composite(parent, SWT.NONE);
+		browseComposite.setLayout(new GridLayout(2, false));
+		
+		workspaceBrowseButton = new Button(browseComposite, SWT.PUSH);
+		workspaceBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_workspaceBrowseButton_label);
+		workspaceBrowseButton.addSelectionListener(new SelectionAdapter () {
+			public void widgetSelected(SelectionEvent e) {
+				openDestinationDialog();
+			}
+		});
+		
+		filesystemBrowseButton = new Button(browseComposite, SWT.PUSH);
+		filesystemBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_filesystemBrowseButton_label);
+		filesystemBrowseButton.addSelectionListener(new SelectionAdapter () {
+			public void widgetSelected(SelectionEvent e) {
+				browseFilesystem();
+			}
+		});
+	}
+	
+	protected void openDestinationDialog() {
+		ArchiveNodeDestinationDialog dialog = new ArchiveNodeDestinationDialog(getShell(), true, true);
+		if (nodeDestination != null)
+			dialog.setInitialSelection(nodeDestination);
+		
+		if (dialog.open() == Dialog.OK) 
+			setPackageNodeDestination(dialog.getResult()[0]);
+	}
+	
+	protected void browseFilesystem () {
+		DirectoryDialog dialog = new DirectoryDialog(getShell());
+		String currentPath = destinationText.getText();
+		if (currentPath != null && currentPath.length() > 0 && !inWorkspace) {
+			dialog.setFilterPath(destinationText.getText());
+		}
+		
+		String path = dialog.open();
+		if (path != null) 
+			setPackageNodeDestination(new Path(path));
+	}
+	
+	protected void updateDestinationViewer() {
+		super.updateDestinationViewer();
+
+		if (nodeDestination instanceof IPath) {
+			inWorkspace = false;
+			IPath path = (IPath) nodeDestination;
+			destinationText.setText(path.toString());
+			destinationImage.setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_EXTERNAL_FILE));
+		} else if (nodeDestination instanceof IContainer || nodeDestination instanceof IArchiveNode) {
+			inWorkspace = true;
+		}
+	}
+}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveFilesetDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveFilesetDestinationComposite.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveFilesetDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,56 @@
+package org.jboss.ide.eclipse.archives.ui.util.garbage;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveNodeDestinationDialog;
+
+public class ArchiveFilesetDestinationComposite extends ArchiveNodeDestinationComposite {
+	protected Button filesystemBrowseButton;
+	public ArchiveFilesetDestinationComposite(Composite parent, int style,
+			Object destination) {
+		super(parent, style, destination);
+	}
+
+	protected void fillBrowseComposite(Composite parent) {
+		Composite browseComposite = new Composite(parent, SWT.NONE);
+		browseComposite.setLayout(new GridLayout(2, false));
+		
+		filesystemBrowseButton = new Button(browseComposite, SWT.PUSH);
+		filesystemBrowseButton.setText(ArchivesUIMessages.PackageDestinationComposite_workspaceBrowseButton_label);
+		filesystemBrowseButton.addSelectionListener(new SelectionAdapter () {
+			public void widgetSelected(SelectionEvent e) {
+				openDestinationDialog();
+			}
+		});
+	}
+	
+	protected void openDestinationDialog() {
+		ArchiveNodeDestinationDialog dialog = new ArchiveNodeDestinationDialog(getShell(), false, true);
+		dialog.setValidator(new ISelectionStatusValidator() {
+			public IStatus validate(Object[] selection) {
+				if( selection != null && selection.length == 1 ) {
+					if( selection[0] instanceof IArchiveNode && !(selection[0] instanceof IArchiveFileSet) )
+						return Status.OK_STATUS;
+				}
+				return new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, "Selection not valid");
+			}
+		});
+		if (nodeDestination != null)
+			dialog.setInitialSelection(nodeDestination);
+		
+		if (dialog.open() == Dialog.OK) 
+			setPackageNodeDestination(dialog.getResult()[0]);
+	}
+}

Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveNodeDestinationComposite.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveNodeDestinationComposite.java	                        (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/ArchiveNodeDestinationComposite.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -0,0 +1,151 @@
+package org.jboss.ide.eclipse.archives.ui.util.garbage;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+
+public abstract class ArchiveNodeDestinationComposite extends Composite {
+
+	protected Composite parent;
+	protected Label destinationImage;
+	protected Text destinationText;
+	protected Object nodeDestination;
+	//protected ArrayList<DestinationChangeListener> listeners;
+	
+	public ArchiveNodeDestinationComposite(Composite parent, int style, Object destination) {
+		super(parent, style);
+		this.parent = parent;
+		this.nodeDestination = destination;
+		//this.listeners = new ArrayList<DestinationChangeListener>();
+		
+		createComposite();
+	}
+	
+	protected void createComposite() {
+		setLayout(new FormLayout());
+		
+		// create widgets
+		destinationImage = new Label(this, SWT.NONE);
+		destinationText = new Text(this, SWT.BORDER);
+		Composite browseComposite = new Composite(this, SWT.NONE);
+		
+		// set up their layout positioning
+		destinationImage.setLayoutData(createFormData(0,5,null, 0, 0, 0, null, 0));
+		destinationText.setLayoutData(createFormData(0, 5, null, 0, destinationImage, 5, destinationImage, 205));
+	
+		
+		// set text, add listeners, etc
+		destinationText.setEditable(false);
+
+		browseComposite.setLayout(new FillLayout());
+		browseComposite.setLayoutData(createFormData(0,0,null,0,destinationText,5,100,-5)); 
+		fillBrowseComposite(browseComposite);
+		
+		// call other functions required for startup
+		updateDestinationViewer();
+	}
+	
+	protected abstract void fillBrowseComposite(Composite browseComposite);
+	
+	private FormData createFormData(Object topStart, int topOffset, Object bottomStart, int bottomOffset, 
+									Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
+		FormData data = new FormData();
+
+		if( topStart != null ) {
+			data.top = topStart instanceof Control ? new FormAttachment((Control)topStart, topOffset) : 
+				new FormAttachment(((Integer)topStart).intValue(), topOffset);
+		}
+
+		if( bottomStart != null ) {
+			data.bottom = bottomStart instanceof Control ? new FormAttachment((Control)bottomStart, bottomOffset) : 
+				new FormAttachment(((Integer)bottomStart).intValue(), bottomOffset);
+		}
+		
+		if( leftStart != null ) {
+			data.left = leftStart instanceof Control ? new FormAttachment((Control)leftStart, leftOffset) : 
+				new FormAttachment(((Integer)leftStart).intValue(), leftOffset);
+		}
+		
+		if( rightStart != null ) {
+			data.right = rightStart instanceof Control ? new FormAttachment((Control)rightStart, rightOffset) : 
+				new FormAttachment(((Integer)rightStart).intValue(), rightOffset);
+		}
+		
+		return data;
+	}
+
+	public void setPackageNodeDestination (Object destination) {
+		nodeDestination = destination;
+		updateDestinationViewer();
+		//fireDestinationChanged();
+	}
+	
+	protected void updateDestinationViewer () {
+		if (nodeDestination == null) return;
+		destinationText.setText("");
+		
+		if (nodeDestination instanceof IArchive) {
+			IArchive pkg = (IArchive) nodeDestination;
+			String txt = pkg.isTopLevel() ? pkg.getName() : pkg.getRootArchiveRelativePath().toOSString();
+			String imgKey = pkg.isExploded() ? ArchivesSharedImages.IMG_PACKAGE_EXPLODED : ArchivesSharedImages.IMG_PACKAGE;
+
+			destinationText.setText(txt);
+			destinationImage.setImage(ArchivesSharedImages.getImage(imgKey));
+		} else if (nodeDestination instanceof IArchiveFolder) {
+			IArchiveFolder folder = (IArchiveFolder) nodeDestination;
+			destinationText.setText(folder.getRootArchiveRelativePath().toString());
+			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+		} else if (nodeDestination instanceof IProject) {
+			IProject project = (IProject) nodeDestination;
+			destinationText.setText(project.getName());
+			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT));
+		} else if (nodeDestination instanceof IFolder) {
+			IFolder folder = (IFolder) nodeDestination;
+			destinationText.setText("/" + folder.getProject().getName() + "/" + folder.getProjectRelativePath().toString());
+			destinationImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
+		}
+	}
+	
+	
+	/**
+	 * The current destination
+	 * @return
+	 */
+	
+	public Object getPackageNodeDestination () {
+		return nodeDestination;
+	}
+	
+	
+	/*
+	 * Destination change listeners
+	 */
+//	
+//	public void addDestinationChangeListener (DestinationChangeListener listener) {
+//		listeners.add(listener);
+//	}
+//	
+//	public void removeDestinationChangeListener (DestinationChangeListener listener) {
+//		listeners.remove(listener);
+//	}
+//	
+//	private void fireDestinationChanged () {
+//		for (Iterator<DestinationChangeListener> iter = listeners.iterator(); iter.hasNext(); ) {
+//			((DestinationChangeListener) iter.next()).destinationChanged(nodeDestination);
+//		}
+//	}
+}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -5,7 +5,6 @@
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -28,8 +27,10 @@
 	private ArchiveInfoWizardPage firstPage;
 	private WizardPage pages[];
 	protected IProject project;
-	protected Object selectedDestination;
 	protected IArchive existingPackage;
+	protected String initialDestinationPath;
+	protected boolean isPathWorkspaceRelative;
+	protected IArchiveNode initialDestinationNode;
 	
 	public AbstractArchiveWizard () {	
 		this.project = ProjectArchivesView.getInstance().getCurrentProject();
@@ -37,19 +38,12 @@
 	
 	public AbstractArchiveWizard (IArchive existingPackage) {
 		this.existingPackage = existingPackage;
-		this.project = findProject(existingPackage.getProjectPath());
+		this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(existingPackage.getProjectName());
 	}
-	protected IProject findProject(IPath path) {
-		IProject[] list = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-		for( int i = 0; i < list.length; i++ )
-			if( list[i].getProject().getLocation().equals(path))
-				return list[i];
-		return null;
-	}
+	
 	public void addPages() {
 		firstPage = new ArchiveInfoWizardPage(this, existingPackage);
 		addPage(firstPage);
-		
 		pages = createWizardPages();
 		for (int i = 0; i < pages.length; i++) {
 			addPage(pages[i]);
@@ -63,20 +57,17 @@
 			}
 			return true;
 		}
-		
 		return false;
 	}
 	
 	public boolean performFinish() {
 		IWizardPage currentPage = getContainer().getCurrentPage();
-		
 		if (currentPage instanceof WizardPageWithNotification) {
 			((WizardPageWithNotification)currentPage).pageExited(WizardWithNotification.FINISH);
 		}
 		
-		final boolean create = this.existingPackage == null;
+		final boolean create = (this.existingPackage == null);
 		final IArchive pkg = firstPage.getArchive();
-		final Object destination = firstPage.getPackageDestination();
 		
 		boolean performed = performFinish(pkg);
 		
@@ -84,23 +75,24 @@
 			try {
 				getContainer().run(true, false, new IRunnableWithProgress () {
 					public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-						IArchiveNode parent = null;
-						
-						try {
-							if (destination instanceof IArchiveNode) {
-								// if we're modifying an existing package, remove old parentage
-								if (!create && !destination.equals(pkg.getParent())) {
-									if (pkg.getParent() != null) {
-										pkg.getParent().removeChild(pkg);
-									}
+						IArchiveNode parent;
+						IArchiveNode destNode = firstPage.getDestinationNode();
+						if( destNode != null ) {
+							// if we're modifying an existing package, remove old parentage
+							if (!create && !destNode.equals(pkg.getParent())) {
+								if (pkg.getParent() != null) {
+									pkg.getParent().removeChild(pkg);
 								}
-								parent = (IArchiveNode)destination;
-							} else {
-								parent = ArchivesModel.instance().getRoot(project.getLocation());
-								if( parent == null ) 
-									parent = ArchivesModel.instance().registerProject(project.getLocation(), null);
-							}
+							}							
+							parent = (IArchiveNode)destNode;
+						} else {
+							// parent is a String / path, so this is a top level node
+							parent = ArchivesModel.instance().getRoot(project.getLocation());
+							if( parent == null ) 
+								parent = ArchivesModel.instance().registerProject(project.getLocation(), null);
+						}
 						
+						try {
 							if( create ) 
 								parent.addChild(pkg);
 							ArchivesModel.instance().save(project.getLocation(), monitor);
@@ -108,7 +100,6 @@
 							IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, "Error Completing Wizard", ame);
 							PackagesUIPlugin.getDefault().getLog().log(status);
 						}
-
 					}
 				});
 			} catch (InvocationTargetException e) {
@@ -121,46 +112,37 @@
 	public void init(IWorkbench workbench, IStructuredSelection selection) {
 		if (selection == null) return;
 		project = ProjectArchivesView.getInstance().getCurrentProject();
-		Object selected;
+		Object selected = (selection.isEmpty() ? project : selection.getFirstElement());
 		
-		if( selection.isEmpty() ) {
-			selected = project;
-		} else {
-			selected = selection.getFirstElement();
-		}
-
-		if (selected instanceof IArchiveNode)
-		{
+		if (selected instanceof IArchiveNode) {
 			IArchiveNode node = (IArchiveNode) selected;
-			if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER)
-			{
-				selectedDestination = selected;
+			if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+				initialDestinationNode = (IArchiveNode)selected;
 			}
-			project = findProject(node.getProjectPath());
+			project = ResourcesPlugin.getWorkspace().getRoot().getProject(node.getProjectName());
+		} else if (selected instanceof IContainer) {
+			initialDestinationPath = ((IContainer)selected).getFullPath().toString();
+			isPathWorkspaceRelative = true;
+		} else {
+			initialDestinationPath = project.getFullPath().toString();
+			isPathWorkspaceRelative = true;
 		}
-		else if (selected instanceof IContainer)
-		{
-			selectedDestination = selected;
-		}
-		else {
-			// find project
-			String proj = project.getLocation().toOSString().substring(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString().length()+1);
-			selectedDestination = ResourcesPlugin.getWorkspace().getRoot().getProject(proj);
-		}
 		
-		setNeedsProgressMonitor(true);
+		setNeedsProgressMonitor(true);	
 	}
 	
-	public Object getSelectedDestination ()
-	{
-		return selectedDestination;
+	public IArchiveNode getInitialNode() {
+		return initialDestinationNode;
 	}
 	
-	public abstract boolean performFinish(IArchive pkg);
-	public abstract WizardPage[] createWizardPages();
-	public abstract ImageDescriptor getImageDescriptor();
-	public abstract String getArchiveExtension();
+	public String getInitialPath() {
+		return initialDestinationPath;
+	}
 	
+	public boolean isInitialPathWorkspaceRelative() {
+		return isPathWorkspaceRelative;
+	}
+	
 	public IProject getProject() {
 		return project;
 	}
@@ -173,4 +155,9 @@
 	public IArchive getArchive () {
 		return firstPage.getArchive();
 	}
+	
+	public abstract boolean performFinish(IArchive pkg);
+	public abstract WizardPage[] createWizardPages();
+	public abstract ImageDescriptor getImageDescriptor();
+	public abstract String getArchiveExtension();
 }

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,19 +1,9 @@
 package org.jboss.ide.eclipse.archives.ui.wizards;
 
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.wizard.Wizard;
 import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
 import org.jboss.ide.eclipse.archives.ui.wizards.pages.FilesetInfoWizardPage;
 
 public class FilesetWizard extends Wizard {

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -7,24 +7,22 @@
 import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
 import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
 
-public class NewJARWizard extends AbstractArchiveWizard
-{
+public class NewJARWizard extends AbstractArchiveWizard {
 	public WizardPage[] createWizardPages() {
 		return new WizardPage[0];
 	}
 
 	public NewJARWizard () {
+		super();
 		setWindowTitle(ArchivesUIMessages.NewJARWizard_windowTitle);
 	}
 	
 	public NewJARWizard (IArchive existingPackage) {
 		super(existingPackage);
-		
 		setWindowTitle(ArchivesUIMessages.NewJARWizard_windowTitle_editJAR);
 	}
 	
 	public boolean performFinish(IArchive pkg) {
-		
 		pkg.setArchiveType(ArchivesCore.getInstance().getExtensionManager().getArchiveType("jar"));
 		return true;
 	}

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -1,8 +1,7 @@
 package org.jboss.ide.eclipse.archives.ui.wizards.pages;
 
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -16,15 +15,16 @@
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
 import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
 import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
 import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
 import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
 import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.util.DestinationChangeListener;
-import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveDestinationComposite;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveSourceDestinationComposite;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveSourceDestinationComposite.ChangeListener;
 import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
 import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
 import org.jboss.ide.eclipse.archives.ui.wizards.WizardWithNotification;
@@ -37,7 +37,7 @@
 	private Button explodedButton;
 	private String packageName;
 	private boolean packageExploded;
-	private ArchiveDestinationComposite destinationComposite;
+	private ArchiveSourceDestinationComposite destinationComposite;
 	private IArchive archive;
 	
 	public ArchiveInfoWizardPage (AbstractArchiveWizard wizard, IArchive existingPackage) {
@@ -47,7 +47,7 @@
 	}
 	
 	public void createControl(Composite parent) {
-		setMessage(ArchivesUIMessages.PackageInfoWizardPage_message);		
+		setMessage(ArchivesUIMessages.PackageInfoWizardPage_message);
 		
 		Composite main = new Composite(parent, SWT.NONE);
 		main.setLayout(new GridLayout(1, false));
@@ -79,26 +79,26 @@
 		
 		packageNameText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				if (validate())
-				{
+				if (validate()) {
 					packageName = packageNameText.getText();
 				}
 			}
 		});
 
-		new Label(infoGroup, SWT.NONE).setText(ArchivesUIMessages.PackageInfoWizardPage_destination_label);
-
+		Label l = new Label(infoGroup, SWT.NONE);
+		l.setText(ArchivesUIMessages.PackageInfoWizardPage_destination_label);
+		GridData lData = new GridData(GridData.BEGINNING, GridData.BEGINNING,false,false);
+		l.setLayoutData(lData);
+		
 		GridData destinationTextData = new GridData(GridData.FILL_BOTH);
 		destinationTextData.horizontalSpan = 2;
 		GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
 		buttonData.horizontalSpan = 3;
 		buttonData.horizontalAlignment = SWT.END;
 		
-		Object destination = wizard.getSelectedDestination();
-		destinationComposite = new ArchiveDestinationComposite(
-			infoGroup, SWT.NONE, destination);
-		destinationComposite.addDestinationChangeListener(new DestinationChangeListener () {
-			public void destinationChanged(Object newDestination) {
+		destinationComposite = new ArchiveSourceDestinationComposite(infoGroup, wizard.getProject().getName());
+		destinationComposite.addChangeListener(new ChangeListener () {
+			public void compositeChanged() {
 				validate();
 			}
 		});
@@ -131,112 +131,71 @@
 		validate();
 	}
 	
-	private void fillDefaults ()
-	{
-		if (archive != null)
-		{
+	private void fillDefaults () {
+		if (archive != null) {
 			compressedButton.setSelection(!archive.isExploded());
 			explodedButton.setSelection(archive.isExploded());
 			packageNameText.setText(archive.getName());
 			packageName = archive.getName();
-			
-			if (archive.isTopLevel()) {
-				
-				// TODO:  FIX THIS
-				IPath globalDest = archive.getGlobalDestinationPath();
-				IContainer container = globalDest == null ? null : ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(globalDest);
-				if( container != null )
-					destinationComposite.setPackageNodeDestination(container);
-				else 
-					destinationComposite.setPackageNodeDestination(globalDest);
+			explodedButton.setSelection(archive.isExploded());
+			compressedButton.setSelection(!archive.isExploded());
+			IArchiveNode parent = archive.getParent();
+			if( parent != null && !(parent instanceof IArchiveModelRootNode)) {
+				destinationComposite.init(parent);
 			} else {
-				destinationComposite.setPackageNodeDestination(archive.getParent());
+				destinationComposite.init(archive.getDestinationPath().toString(), archive.isDestinationInWorkspace());
 			}
-			
-			if (archive.isExploded()) {
-				explodedButton.setEnabled(true);
-			} else {
-				compressedButton.setEnabled(true);
-			}
 		}
 	}
 
-	private boolean validate ()
-	{
+	private boolean validate () {
+		String errorMessage = null;
 		if (packageNameText.getText() == null || packageNameText.getText().length() == 0)
-		{
-			setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noPackageName);
-			setPageComplete(false);
-			return false;
-		}
-		else {
-			setErrorMessage(null);
-		}
-		
-		Object destination = getPackageDestination();
-		if (destination instanceof IArchiveNode)
-		{
-			IArchiveNode parentNode = (IArchiveNode) destination;
-			
-			// verify no child has the same name
-			IArchiveNode subPackages[] = parentNode.getChildren(IArchiveNode.TYPE_ARCHIVE);
-			for (int i = 0; i < subPackages.length; i++)
-			{
-				IArchive subPackage = (IArchive) subPackages[i];
-				if (subPackage.getName().equals(packageNameText.getText())
-					&& (!subPackage.equals(this.archive)))
-				{
-					setErrorMessage(
-						ArchivesUIMessages.bind(
-							ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
-					setPageComplete(false);
-					return false;
-				}
-			}
-		} else if (destination instanceof IContainer) {
-			IContainer container = (IContainer) destination;
-			IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
-			if (packages != null) {
-				for( int i = 0; i < packages.length; i++ ) {
-					IArchive pkg = (IArchive) packages[i];
-					if (pkg.getName().equals(packageNameText.getText())
-						&& (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(container.getFullPath()))
-						&& (!pkg.equals(this.archive)))
-					{
-						setErrorMessage(
-								ArchivesUIMessages.bind(
-									ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
-							setPageComplete(false);
-							return false;
+			errorMessage = ArchivesUIMessages.PackageInfoWizardPage_error_noPackageName;
+		else if( !destinationComposite.isValid() ) 
+			errorMessage = destinationComposite.getErrorMessage();
+		else if( destinationComposite.getDestinationNode() != null ) {
+				IArchiveNode parentNode = destinationComposite.getDestinationNode();
+				// verify no child has the same name
+				IArchiveNode subPackages[] = parentNode.getChildren(IArchiveNode.TYPE_ARCHIVE);
+				for (int i = 0; i < subPackages.length; i++) {
+					IArchive subPackage = (IArchive) subPackages[i];
+					if (subPackage.getName().equals(packageNameText.getText())
+						&& (!subPackage.equals(this.archive))) {
+							errorMessage =  ArchivesUIMessages.bind(
+								ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, 
+								packageNameText.getText());
 					}
 				}
+		} else if( destinationComposite.getPath() != null ) {
+			boolean relative = destinationComposite.isWorkspaceRelative();
+			IPath destinationLocation; 
+			if( relative ) {
+				IPath translatedPath = new Path(destinationComposite.getTranslatedPath());
+				destinationLocation = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(translatedPath);
+			} else {
+				destinationLocation = new Path(destinationComposite.getPath());
 			}
-		} else if (destination instanceof IPath) {
-			IPath path = (IPath) destination;
+
 			IArchive[] packages = ModelUtil.getProjectArchives(wizard.getProject().getLocation());
 			if (packages != null) {
 				for( int i = 0; i < packages.length; i++ ) {
 					IArchive pkg = (IArchive) packages[i];
 					if (pkg.getName().equals(packageNameText.getText())
-						&& (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(path))
-						&& (!pkg.equals(this.archive)))
-					{
-						setErrorMessage(
-								ArchivesUIMessages.bind(
-									ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText()));
-							setPageComplete(false);
-							return false;
+						&& (pkg.getGlobalDestinationPath() != null && pkg.getGlobalDestinationPath().equals(destinationLocation))
+						&& (!pkg.equals(this.archive))) {
+						errorMessage = ArchivesUIMessages.bind(
+									ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists, packageNameText.getText());
 					}
 				}
-			} else if (destination == null) {
-				setErrorMessage(ArchivesUIMessages.PackageInfoWizardPage_error_noDestination);
-				setPageComplete(false);
-				return false;
 			}
+		} else {
+			errorMessage = (ArchivesUIMessages.PackageInfoWizardPage_error_noDestination);
 		}
 		
-		setPageComplete(true);
-		return true;
+		setErrorMessage(errorMessage);
+		setPageComplete(errorMessage == null);
+		return errorMessage == null;
 	}
 	
 	
@@ -247,27 +206,19 @@
 	}
 	
 	private void createPackage () {
-		Object destContainer = getPackageDestination();
-		
-		
 		if (archive == null) {
 			archive = ArchiveNodeFactory.createArchive();
 		}
 		
 		archive.setName(getPackageName());
 		archive.setExploded(isPackageExploded());
-		
-		if (destContainer instanceof IContainer) {
-			archive.setDestinationPath(((IContainer)destContainer).getFullPath());
-			archive.setInWorkspace(true);
-		} else if (destContainer instanceof IPath) {
-			archive.setDestinationPath((IPath) destContainer);
-			archive.setInWorkspace(false);
+		if( destinationComposite.getPath() != null ) {
+			archive.setInWorkspace(destinationComposite.isWorkspaceRelative());
+			archive.setDestinationPath(new Path(destinationComposite.getPath()));
 		}
 	}
 	
-	private void expand(Control control)
-	{
+	private void expand(Control control) {
 		control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 	}
 
@@ -278,18 +229,23 @@
 	public boolean isPackageExploded() {
 		return packageExploded;
 	}
-
-	public Object getPackageDestination() {
-		return destinationComposite.getPackageNodeDestination();
-	}
 	
-	private void setWizard(AbstractArchiveWizard wizard)
-	{
+	private void setWizard(AbstractArchiveWizard wizard) {
 		this.wizard = wizard;
 	}
 	
-	public IArchive getArchive ()
-	{
+	public IArchive getArchive () {
 		return archive;
 	}
+	
+	// Getters for the wizard to call
+	public String getDestinationPath() {
+		return destinationComposite.getPath();
+	}
+	public IArchiveNode getDestinationNode() {
+		return destinationComposite.getDestinationNode();
+	}
+	public boolean isDestinationWorkspaceRelative() {
+		return destinationComposite.isWorkspaceRelative();
+	}
 }

Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java	2008-07-14 15:38:08 UTC (rev 9131)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java	2008-07-14 18:22:49 UTC (rev 9132)
@@ -2,8 +2,6 @@
 
 import java.util.ArrayList;
 
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -28,21 +26,22 @@
 import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
 import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
 import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
 import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
 import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveFilesetDestinationComposite;
-import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveNodeDestinationComposite;
+import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveSourceDestinationComposite;
 import org.jboss.ide.eclipse.archives.ui.util.composites.FilesetPreviewComposite;
+import org.jboss.ide.eclipse.archives.ui.util.garbage.ArchiveFilesetDestinationComposite;
+import org.jboss.ide.eclipse.archives.ui.util.garbage.ArchiveNodeDestinationComposite;
 
 public class FilesetInfoWizardPage extends WizardPage {
 
 	private IArchiveNode parentNode;
 	private IArchiveFileSet fileset;
-	private String includes, excludes, rawPath;
+	private String includes, excludes;
 	private String projectName;
 	private boolean flattened;
-	private boolean workspaceRelative;
 	
 	/**
 	 * This variable must at all times be global. ALWAYS
@@ -50,10 +49,8 @@
 	private FilesetPreviewComposite previewComposite;
 
 	private Composite mainComposite;
-	private Text rootDirText;
 	private Label flattenedLabel;
-	private Button rootDirWorkspaceBrowseButton;
-	private Button rootDirFilesystemBrowseButton;
+	private ArchiveSourceDestinationComposite srcDestComposite;
 	private Button flattenedYes;
 	private Button flattenedNo;
 	private Text includesText;
@@ -73,6 +70,7 @@
 		
 		this.fileset = fileset;
 		this.parentNode = parentNode;
+		projectName = parentNode.getProjectName();
 	}
 		
 	public void createControl (Composite parent) {
@@ -142,30 +140,18 @@
 		// my layout
 		infoGroup.setLayout(new FormLayout());
 
-		
-		int max = 100;
-
 		// destination row
 		Label destinationKey = new Label(infoGroup, SWT.NONE);
 		destinationComposite = new ArchiveFilesetDestinationComposite(infoGroup, SWT.NONE, parentNode);
 
-		destinationKey.setLayoutData(createFormData(0,10,null,0,null,5, 0, max));
+		destinationKey.setLayoutData(createFormData(0,10,null,0,null,5, 0, 100));
 		destinationComposite.setLayoutData(createFormData(0,5,null,0,destinationKey,5, 100, -5));
 		
 		// root dir
 		Label rootDirectoryLabel = new Label(infoGroup, SWT.NONE);
-		Composite rootDirValue = new Composite(infoGroup, SWT.NONE);
-		rootDirValue.setLayout(new FormLayout());
-		
-		rootDirText = new Text(rootDirValue, SWT.BORDER);
-		rootDirWorkspaceBrowseButton = new Button(rootDirValue, SWT.PUSH);
-		rootDirFilesystemBrowseButton = new Button(rootDirValue, SWT.PUSH);
-		
-		rootDirText.setLayoutData(createFormData(0,5,null,0,0,5,100,-5));
-		rootDirFilesystemBrowseButton.setLayoutData(createFormData(rootDirText,5,null,0,null,0,100,-5));
-		rootDirWorkspaceBrowseButton.setLayoutData(createFormData(rootDirText,5,null,0,null,0,rootDirFilesystemBrowseButton, -5));
-		
-		rootDirectoryLabel.setLayoutData(createFormData(destinationComposite,10,null,0,null,5,0,max));
+		srcDestComposite = new ArchiveSourceDestinationComposite(infoGroup, projectName);
+		Composite rootDirValue = srcDestComposite; 
+		rootDirectoryLabel.setLayoutData(createFormData(destinationComposite,10,null,0,null,5,0,100));
 		rootDirValue.setLayoutData(createFormData(destinationComposite,5,null,0,rootDirectoryLabel,5,100,-5));
 		
 		flattenedLabel = new Label(infoGroup, SWT.NONE);
@@ -184,7 +170,7 @@
 		includesImage.setLayoutData(createFormData(0,0,null,0,0,0,null,0));
 		includesTextLabel.setLayoutData(createFormData(0,0,null,0,includesImage,5,null,0));
 		
-		includesKey.setLayoutData(createFormData(flattenedLabel,5,null,0,null,5,0,max));
+		includesKey.setLayoutData(createFormData(flattenedLabel,5,null,0,null,5,0,100));
 		includesText.setLayoutData(createFormData(flattenedLabel,5,null,0,includesKey,10,100,-5));
 
 		
@@ -197,19 +183,16 @@
 		excludesImage.setLayoutData(createFormData(0,0,null,0,0,0,null,0));
 		excludesTextLabel.setLayoutData(createFormData(0,0,null,0,excludesImage,5,null,0));
 		
-		excludesKey.setLayoutData(createFormData(includesText,5,null,0,null,5,0,max));
+		excludesKey.setLayoutData(createFormData(includesText,5,null,0,null,5,0,100));
 		excludesText.setLayoutData(createFormData(includesText,5,100,-5,excludesKey,10,100,-5));
 
 		// customize widgets
 		destinationKey.setText(ArchivesUIMessages.FilesetInfoWizardPage_destination_label);
 		rootDirectoryLabel.setText(ArchivesUIMessages.FilesetInfoWizardPage_rootDirectory_label);
-		rootDirWorkspaceBrowseButton.setText(ArchivesUIMessages.FilesetInfoWizardPage_rootDirWorkspaceBrowseButton_label);
-		rootDirFilesystemBrowseButton.setText(ArchivesUIMessages.FilesetInfoWizardPage_rootDirFilesystemBrowseButton_label);
 		includesImage.setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_INCLUDES));
 		includesTextLabel.setText(ArchivesUIMessages.FilesetInfoWizardPage_includes_label);
 		excludesImage.setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_EXCLUDES));
 		excludesTextLabel.setText(ArchivesUIMessages.FilesetInfoWizardPage_excludes_label);
-		rootDirText.setEnabled(false);
 
 		flattenedLabel.setText("Flatten?");
 		flattenedYes.setText("Yes");
@@ -218,8 +201,7 @@
 		return infoGroup;
 	}
 	
-	private void addListeners ()
-	{
+	private void addListeners () {
 		includesText.addModifyListener(new ModifyListener () { 
 			public void modifyText(ModifyEvent e) {
 				includes = includesText.getText();
@@ -234,19 +216,6 @@
 			}
 		});
 		
-		
-		rootDirWorkspaceBrowseButton.addSelectionListener(new SelectionAdapter () {
-			public void widgetSelected(SelectionEvent e) {
-				//browseWorkspaceForRootDir();
-			}
-		});
-		
-		rootDirFilesystemBrowseButton.addSelectionListener(new SelectionAdapter () {
-			public void widgetSelected(SelectionEvent e) {
-				//browseFilesystemForRootDir();
-			}
-		});
-		
 		SelectionAdapter flattenAdapter = new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
 				flattened = flattenedYes.getSelection();
@@ -274,17 +243,17 @@
 	}
 	
 	public boolean isRootDirWorkspaceRelative () {
-		return workspaceRelative;
+		return srcDestComposite.isWorkspaceRelative();
 	}
 	
 	public String getRawPath() {
-		return rawPath;
+		return srcDestComposite.getPath();
 	}
 	
 	public String replaceVariables() {
 		try {
 			return ArchivesCore.getInstance().getVFS().
-				performStringSubstitution(rawPath, 
+				performStringSubstitution(srcDestComposite.getPath(), 
 						projectName, true);
 		} catch( CoreException ce ) {
 		}
@@ -292,36 +261,28 @@
 	}
 	
 	private void fillDefaults () {
-		IProject[] project = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-		for( int i = 0; i < project.length; i++ ) 
-			if( project[i].getLocation().equals(parentNode.getProjectPath()))
-				projectName = project[i].getName();
-		
 		if (fileset != null) {
-				if (fileset.getIncludesPattern() != null) {
-					includes = fileset.getIncludesPattern();
-					includesText.setText(includes);
-				}
-				if (fileset.getExcludesPattern() != null) {
-					excludes = fileset.getExcludesPattern();
-					excludesText.setText(excludes);
-				}
-				
-				if (fileset.getRawSourcePath() != null) {
-					rawPath = fileset.getRawSourcePath();
-					rootDirText.setText(rawPath);
-				}
+			flattened = fileset.isFlattened();
+			flattenedYes.setSelection(flattened);
+			flattenedNo.setSelection(!flattened);
+			
+			if (fileset.getIncludesPattern() != null) {
+				includes = fileset.getIncludesPattern();
+				includesText.setText(includes);
+			}
+			if (fileset.getExcludesPattern() != null) {
+				excludes = fileset.getExcludesPattern();
+				excludesText.setText(excludes);
+			}
+			
+			if (fileset.getRawSourcePath() != null) {
+				srcDestComposite.init(fileset.getRawSourcePath(), fileset.isInWorkspace());
+			}
 
-				workspaceRelative = fileset.isInWorkspace();
-				flattened = fileset.isFlattened();
-				flattenedYes.setSelection(flattened);
-				flattenedNo.setSelection(!flattened);
-				
 		} else {
-			rawPath = "${current_project}";
-			workspaceRelative = true;
+			String rawPath = "${" + IVariableManager.CURRENT_PROJECT + "}";
+			srcDestComposite.init(rawPath, true);
 			flattened = false;
-			rootDirText.setText(rawPath);
 			flattenedYes.setSelection(flattened);
 			flattenedNo.setSelection(!flattened);
 		}
@@ -330,7 +291,7 @@
 	
 	private void changePreview() {
 		DirectoryScannerExtension ds = DirectoryScannerFactory.createDirectoryScanner( 
-				replaceVariables(), null, includes, excludes, parentNode.getProjectName(), workspaceRelative, true);
+				replaceVariables(), null, includes, excludes, parentNode.getProjectName(), srcDestComposite.isWorkspaceRelative(), true);
 		String[] fsRelative = ds.getIncludedFiles();
 		IPath filesetRelative;
 		ArrayList<IPath> list = new ArrayList<IPath>();
@@ -343,54 +304,5 @@
 				list.add(filesetRelative);
 		}
 		previewComposite.setInput(list.toArray());
-	}
-	
-	/*
-	private void browseWorkspaceForRootDir () {
-		IContainer workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-		ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), workspaceRoot, true,
-			ArchivesUIMessages.FilesetInfoWizardPage_rootDirWorkspaceBrowser_message);
-		
-		int response = dialog.open();
-		if (response == Dialog.OK) {
-			Object results[] = dialog.getResult();
-			IPath path = (IPath) results[0];
-			String projectName = path.segment(0);
-			
-			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-			if (project != null) {
-				IPath projectRelativePath = path.removeFirstSegments(1);
-				rootProjectLabel.setText(project.getName());
-				rootDir = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
-				workspaceRelativeRootDir = path.toString();
-				if (!projectRelativePath.isEmpty()) {
-					rootDirText.setText(projectRelativePath.toString());
-				} else {
-					rootDirText.setText("");
-				}
-				
-				rootDirIsWorkspaceRelative = true;
-				changePreview();
-			}
-		}
-	}
-	
-	private void browseFilesystemForRootDir () {
-		DirectoryDialog dialog = new DirectoryDialog(getShell());
-		if (rootDirText.getText() != null && rootDirText.getText().length() > 0 && !isRootDirWorkspaceRelative()) {
-			dialog.setFilterPath(rootDirText.getText());
-		}
-		
-		String path = dialog.open();
-		if (path != null && path.length() > 0) {
-			rootDirText.setText(path);
-			rootDir = new Path(path);
-			workspaceRelativeRootDir = null;
-			rootDirIsWorkspaceRelative = false;
-			rootProjectLabel.setText(ArchivesUIMessages.FilesetInfoWizardPage_noProjectMessage);
-			changePreview();
-		}
-	}
-	*/
-	
+	}	
 }




More information about the jbosstools-commits mailing list