### Eclipse Workspace Patch 1.0
#P org.jboss.ide.eclipse.as.ui
Index: jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java	(revision 31081)
+++ jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java	(working copy)
@@ -43,7 +43,6 @@
 
 public class ModuleDeploymentPage extends ServerEditorPart {
 	protected ServerResourceCommandManager commandManager;
-	protected ArrayList<IModule> possibleModules;
 	protected DeploymentPreferences preferences;
 	protected ServerAttributeHelper helper; 
 	protected DeploymentModuleOptionCompositeAssistant tab;
@@ -60,10 +59,6 @@
 		return helper;
 	}
 
-	public IModule[] getPossibleModules() {
-		return (IModule[]) possibleModules.toArray(new IModule[possibleModules.size()]);
-	}
-	
 	public FormToolkit getFormToolkit(Composite parent) {
 		return getFormToolkit(parent.getDisplay());
 	}
@@ -74,7 +69,6 @@
 	
 	public void init(IEditorSite site, IEditorInput input) {
 		super.init(site, input);
-		refreshPossibleModules();
 		if (input instanceof IServerEditorPartInput) {
 			IServerEditorPartInput sepi = (IServerEditorPartInput) input;
 			server = sepi.getServer();
@@ -84,21 +78,6 @@
 		helper = new ServerAttributeHelper(server.getOriginal(), server);
 	}
 	
-	public void refreshPossibleModules() {
-		ArrayList<IModule> possibleChildren = new ArrayList<IModule>();
-		IModule[] modules2 = org.eclipse.wst.server.core.ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes());
-		if (modules2 != null) {
-			int size = modules2.length;
-			for (int i = 0; i < size; i++) {
-				IModule module = modules2[i];
-				IStatus status = server.canModifyModules(new IModule[] { module }, null, null);
-				if (status != null && status.getSeverity() != IStatus.ERROR)
-					possibleChildren.add(module);
-			}
-		}
-		this.possibleModules = possibleChildren;
-	}
-
 	public void createPartControl(Composite parent) {
 		preferences = DeploymentPreferenceLoader.loadPreferencesFromServer(server.getOriginal());
 		ScrolledForm innerContent = createPageStructure(parent);
Index: jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
===================================================================
--- jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	(revision 31081)
+++ jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
-* Copyright (c) 2011 Red Hat, Inc. 
+ * Copyright (c) 2011 Red Hat, Inc. 
  * Distributed under license by Red Hat, Inc. All rights reserved. 
  * This program is made available under the terms of the 
  * Eclipse Public License v1.0 which accompanies this distribution, 
@@ -7,16 +7,24 @@
  * 
  * Contributors: 
  * Red Hat, Inc. - initial API and implementation 
- ******************************************************************************/ 
+ ******************************************************************************/
 package org.jboss.ide.eclipse.as.ui.editor;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ICellModifier;
 import org.eclipse.jface.viewers.ILabelProvider;
@@ -27,6 +35,8 @@
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
@@ -42,7 +52,6 @@
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.DirectoryDialog;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.TreeColumn;
@@ -51,6 +60,7 @@
 import org.eclipse.ui.forms.widgets.ExpandableComposite;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.progress.UIJob;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
@@ -76,43 +86,48 @@
 public class DeploymentModuleOptionCompositeAssistant implements PropertyChangeListener {
 	public static interface IDeploymentPageCallback {
 		public boolean metadataEnabled();
+
 		public String getServerLocation(IServerWorkingCopy wc);
+
 		public String getServerConfigName(IServerWorkingCopy wc);
+
 		public void propertyChange(PropertyChangeEvent evt, DeploymentModuleOptionCompositeAssistant composite);
 	}
-	
+
 	public static class LocalDeploymentPageCallback implements IDeploymentPageCallback {
 		public boolean metadataEnabled() {
 			return true;
 		}
 
 		public String getServerLocation(IServerWorkingCopy wc) {
-			IJBossServerRuntime jbsrt = (IJBossServerRuntime)wc.getRuntime().loadAdapter(IJBossServerRuntime.class, null);
+			IJBossServerRuntime jbsrt = (IJBossServerRuntime) wc.getRuntime().loadAdapter(IJBossServerRuntime.class,
+					null);
 			return jbsrt.getConfigLocation();
 		}
 
 		public String getServerConfigName(IServerWorkingCopy wc) {
-			IJBossServerRuntime jbsrt = (IJBossServerRuntime)wc.getRuntime().loadAdapter(IJBossServerRuntime.class, null);
+			IJBossServerRuntime jbsrt = (IJBossServerRuntime) wc.getRuntime().loadAdapter(IJBossServerRuntime.class,
+					null);
 			return jbsrt.getJBossConfiguration();
 		}
 
 		public void propertyChange(PropertyChangeEvent evt,
 				DeploymentModuleOptionCompositeAssistant composite) {
 			// TODO Auto-generated method stub
-			
+
 		}
 	}
-	
+
 	private static HashMap<String, IDeploymentPageCallback> callbackMappings;
 	static {
 		callbackMappings = new HashMap<String, IDeploymentPageCallback>();
 		callbackMappings.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new LocalDeploymentPageCallback());
 	}
-	
+
 	public static void addMapping(String mode, IDeploymentPageCallback callback) {
 		callbackMappings.put(mode, callback);
 	}
-	
+
 	private ModuleDeploymentPage page;
 	private DeploymentPreferences preferences;
 	private TreeViewer viewer;
@@ -121,16 +136,16 @@
 	protected static final String COLUMN_TEMP_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC;
 	protected static final String OUTPUT_NAME = IJBossToolingConstants.LOCAL_DEPLOYMENT_OUTPUT_NAME;
 	protected String currentDeployType = LocalPublishMethod.LOCAL_PUBLISH_METHOD;
-	
+
 	private IServerWorkingCopy lastWC;
-	
+
 	public DeploymentModuleOptionCompositeAssistant() {
 	}
 
 	public ModuleDeploymentPage getPage() {
 		return page;
 	}
-	
+
 	public void setDeploymentPage(ModuleDeploymentPage page) {
 		this.page = page;
 	}
@@ -142,7 +157,7 @@
 	protected ServerAttributeHelper getHelper() {
 		return page.getHelper();
 	}
-	
+
 	private Text deployText, tempDeployText;
 	private Button metadataRadio, serverRadio, customRadio, currentSelection;
 	private Button deployButton, tempDeployButton;
@@ -150,7 +165,7 @@
 	private SelectionListener radioListener, zipListener;
 	private Button zipDeployWTPProjects;
 	private String lastCustomDeploy, lastCustomTemp;
-	
+
 	public Button getServerRadio() {
 		return serverRadio;
 	}
@@ -158,7 +173,7 @@
 	public Button getCurrentSelection() {
 		return currentSelection;
 	}
-	
+
 	protected Composite createDefaultComposite(Composite parent) {
 
 		FormToolkit toolkit = new FormToolkit(parent.getDisplay());
@@ -182,19 +197,19 @@
 		Composite inner = toolkit.createComposite(composite);
 		inner.setLayout(new GridLayout(1, false));
 
-		if( getShowRadios() ) {
+		if (getShowRadios()) {
 			metadataRadio = toolkit.createButton(inner,
 					Messages.EditorUseWorkspaceMetadata, SWT.RADIO);
 			serverRadio = toolkit.createButton(inner,
 					Messages.EditorUseServersDeployFolder, SWT.RADIO);
 			customRadio = toolkit.createButton(inner,
 					Messages.EditorUseCustomDeployFolder, SWT.RADIO);
-	
+
 			radioListener = new SelectionListener() {
 				public void widgetDefaultSelected(SelectionEvent e) {
 					widgetSelected(e);
 				}
-	
+
 				public void widgetSelected(SelectionEvent e) {
 					radioSelected(e.getSource());
 				}
@@ -205,7 +220,7 @@
 		}
 		lastWC = page.getServer();
 		lastWC.addPropertyChangeListener(this);
-		
+
 		FormData radios = new FormData();
 		radios.top = new FormAttachment(descriptionLabel, 5);
 		radios.left = new FormAttachment(0, 5);
@@ -314,7 +329,7 @@
 
 		zipDeployWTPProjects = toolkit.createButton(composite,
 				Messages.EditorZipDeployments, SWT.CHECK);
-		boolean zippedPublisherAvailable = isZippedPublisherAvailable(); 
+		boolean zippedPublisherAvailable = isZippedPublisherAvailable();
 		boolean value = getServer().zipsWTPDeployments();
 		zipDeployWTPProjects.setEnabled(zippedPublisherAvailable);
 		zipDeployWTPProjects.setSelection(zippedPublisherAvailable && value);
@@ -342,19 +357,19 @@
 		updateWidgets();
 		return section;
 	}
-	
+
 	protected boolean getShowRadios() {
 		IRuntime rt = getServer().getServer().getRuntime();
 		boolean showRadios = true;
-		if( rt == null || rt.loadAdapter(IJBossServerRuntime.class, null) == null)
+		if (rt == null || rt.loadAdapter(IJBossServerRuntime.class, null) == null)
 			showRadios = false;
-		if( ServerUtil.isJBoss7(getServer().getServer()))
+		if (ServerUtil.isJBoss7(getServer().getServer()))
 			showRadios = false;
 		return showRadios;
 	}
-	
+
 	private void updateWidgets() {
-		if( getShowRadios()) {
+		if (getShowRadios()) {
 			metadataRadio.setSelection(getDeployType().equals(
 					IDeployableServer.DEPLOY_METADATA));
 			serverRadio.setSelection(getDeployType().equals(
@@ -363,17 +378,17 @@
 					IDeployableServer.DEPLOY_CUSTOM));
 			currentSelection = metadataRadio.getSelection() ? metadataRadio
 					: serverRadio.getSelection() ? serverRadio : customRadio;
-			
-			String mode = page.getServer().getAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+
+			String mode = page.getServer().getAttribute(IDeployableServer.SERVER_MODE,
+					LocalPublishMethod.LOCAL_PUBLISH_METHOD);
 			boolean metaEnabled = callbackMappings.get(mode).metadataEnabled();
 			metadataRadio.setEnabled(metaEnabled);
 		}
-		
-		
+
 		JBossServer jbs = ServerConverter.getJBossServer(page.getServer().getOriginal());
-		String newDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY, 
+		String newDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY,
 				jbs == null ? "" : jbs.getDeployFolder());
-		String newTemp = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, 
+		String newTemp = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
 				jbs == null ? "" : jbs.getTempDeployFolder());
 		deployText.removeModifyListener(deployListener);
 		deployText.setText(newDir);
@@ -381,56 +396,60 @@
 		tempDeployText.removeModifyListener(tempDeployListener);
 		tempDeployText.setText(newTemp);
 		tempDeployText.addModifyListener(tempDeployListener);
-		
+
 		deployText.setEnabled(getDeployType().equals(IDeployableServer.DEPLOY_CUSTOM));
 		tempDeployText.setEnabled(getDeployType().equals(IDeployableServer.DEPLOY_CUSTOM));
 		deployButton.setEnabled(getDeployType().equals(IDeployableServer.DEPLOY_CUSTOM));
 		tempDeployButton.setEnabled(getDeployType().equals(IDeployableServer.DEPLOY_CUSTOM));
 	}
-	
+
 	public void radioSelected(Object c) {
 		if (c == currentSelection)
 			return; // do nothing
-		page.execute(new RadioClickedCommand((Button)c, currentSelection));
-		currentSelection = (Button)c;
+		page.execute(new RadioClickedCommand((Button) c, currentSelection));
+		currentSelection = (Button) c;
 	}
-	
+
 	protected boolean isZippedPublisherAvailable() {
 		/*
-		 * Maybe use IJBossServerPublishMethodType type = DeploymentPreferenceLoader.getCurrentDeploymentMethodType(getServer());
-		 * But this class has no reference to the server, and it also might not want to go by stored data,
-		 * but rather the combo in the ModuleDeploymentPage somehow? 
+		 * Maybe use IJBossServerPublishMethodType type =
+		 * DeploymentPreferenceLoader
+		 * .getCurrentDeploymentMethodType(getServer()); But this class has no
+		 * reference to the server, and it also might not want to go by stored
+		 * data, but rather the combo in the ModuleDeploymentPage somehow?
 		 */
 
-		// String method = DeploymentPreferenceLoader.getCurrentDeploymentMethodType(getServer()).getId();
+		// String method =
+		// DeploymentPreferenceLoader.getCurrentDeploymentMethodType(getServer()).getId();
 		String method = LocalPublishMethod.LOCAL_PUBLISH_METHOD;
-		IJBossServerPublisher[] publishers = 
-			ExtensionManager.getDefault().getZippedPublishers();
-		for( int i = 0; i < publishers.length; i++ ) {
-			if( publishers[i].accepts(method, getServer().getServer(), null))
+		IJBossServerPublisher[] publishers =
+				ExtensionManager.getDefault().getZippedPublishers();
+		for (int i = 0; i < publishers.length; i++) {
+			if (publishers[i].accepts(method, getServer().getServer(), null))
 				return true;
 		}
 		return false;
 	}
-	
+
 	public class SetDeployDirCommand extends ServerCommand {
 		private String oldDir;
 		private String newDir;
-		private Text text;
 		private ModifyListener listener;
+
 		public SetDeployDirCommand() {
 			super(page.getServer(), Messages.EditorSetDeployLabel);
-			this.text = deployText;
 			this.newDir = deployText.getText();
 			this.listener = deployListener;
 			this.oldDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY, ""); //$NON-NLS-1$
 		}
+
 		public void execute() {
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
 			lastCustomDeploy = newDir;
 			updateWidgets();
 			page.getSaveStatus();
 		}
+
 		public void undo() {
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
 			updateWidgets();
@@ -441,15 +460,18 @@
 	public class SetZipCommand extends ServerCommand {
 		boolean oldVal;
 		boolean newVal;
+
 		public SetZipCommand() {
 			super(page.getServer(), Messages.EditorZipDeployments);
 			oldVal = getHelper().getAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, false);
 			newVal = zipDeployWTPProjects.getSelection();
 		}
+
 		public void execute() {
 			getHelper().setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, newVal);
 			page.getSaveStatus();
 		}
+
 		public void undo() {
 			zipDeployWTPProjects.removeSelectionListener(zipListener);
 			zipDeployWTPProjects.setSelection(oldVal);
@@ -458,12 +480,13 @@
 			page.getSaveStatus();
 		}
 	}
-	
+
 	public class SetTempDeployDirCommand extends ServerCommand {
 		private String oldDir;
 		private String newDir;
 		private Text text;
 		private ModifyListener listener;
+
 		public SetTempDeployDirCommand() {
 			super(page.getServer(), Messages.EditorSetTempDeployLabel);
 			text = tempDeployText;
@@ -471,36 +494,40 @@
 			listener = tempDeployListener;
 			oldDir = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, ""); //$NON-NLS-1$
 		}
+
 		public void execute() {
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
 			lastCustomTemp = newDir;
 			updateWidgets();
 			page.getSaveStatus();
 		}
+
 		public void undo() {
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
 			updateWidgets();
 			page.getSaveStatus();
 		}
 	}
-	
+
 	public class RadioClickedCommand extends ServerCommand {
 		private Button newSelection, oldSelection;
 		private String oldDir, newDir;
 		private String oldTemp, newTemp;
 		private String id;
+
 		public RadioClickedCommand(Button clicked, Button previous) {
 			super(page.getServer(), Messages.EditorSetRadioClicked);
 			newSelection = clicked;
 			oldSelection = previous;
 			id = server.getId();
 		}
+
 		public void execute() {
 			oldDir = deployText.getText();
 			oldTemp = tempDeployText.getText();
 			String newType = newSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
-	 			newSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
-	 				IDeployableServer.DEPLOY_METADATA;
+					newSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+							IDeployableServer.DEPLOY_METADATA;
 			discoverNewFolders();
 			ServerAttributeHelper helper = getHelper();
 			helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
@@ -509,32 +536,33 @@
 			updateWidgets();
 			page.getSaveStatus();
 		}
-		
+
 		protected void discoverNewFolders() {
 			// Discover the new folders
-			if( newSelection == metadataRadio  ) {
+			if (newSelection == metadataRadio) {
 				newDir = JBossServerCorePlugin.getServerStateLocation(id)
-					.append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+						.append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
 				newTemp = JBossServerCorePlugin.getServerStateLocation(id)
-					.append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+						.append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
 				new File(newDir).mkdirs();
 				new File(newTemp).mkdirs();
-			} else if( newSelection == serverRadio ) {
-				if( server.getRuntime() != null && 
+			} else if (newSelection == serverRadio) {
+				if (server.getRuntime() != null &&
 						server.getRuntime().loadAdapter(IJBossServerRuntime.class, null) != null) {
 					String loc, config;
 					loc = config = null;
-					String mode = getHelper().getAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD); 
+					String mode = getHelper().getAttribute(IDeployableServer.SERVER_MODE,
+							LocalPublishMethod.LOCAL_PUBLISH_METHOD);
 					IDeploymentPageCallback cb = callbackMappings.get(mode);
 					loc = cb.getServerLocation(page.getServer());
 					config = cb.getServerConfigName(page.getServer());
 					newDir = new Path(loc)
-						.append(config)
-						.append(IJBossServerConstants.DEPLOY).toString();
+							.append(config)
+							.append(IJBossServerConstants.DEPLOY).toString();
 					newTemp = new Path(loc).append(config)
-						.append(IJBossServerConstants.TMP)
-						.append(IJBossServerConstants.JBOSSTOOLS_TMP).toString();
-					if( mode.equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD))
+							.append(IJBossServerConstants.TMP)
+							.append(IJBossServerConstants.JBOSSTOOLS_TMP).toString();
+					if (mode.equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD))
 						new File(newTemp).mkdirs();
 				}
 			} else {
@@ -542,13 +570,13 @@
 				newTemp = lastCustomTemp;
 			}
 			newDir = newDir == null ? oldDir : newDir;
-			newTemp = newTemp == null ? oldTemp : newTemp; 
+			newTemp = newTemp == null ? oldTemp : newTemp;
 		}
-		
+
 		public void undo() {
 			String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
-	 			oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
-	 				IDeployableServer.DEPLOY_METADATA;
+					oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+							IDeployableServer.DEPLOY_METADATA;
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldTemp);
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, oldType);
@@ -556,39 +584,36 @@
 			page.getSaveStatus();
 		}
 	}
-	
+
 	private String getDeployType() {
 		return getServer().getDeployLocationType();
 	}
 
 	private String getDeployDir() {
-		if( page.getServer().getRuntime() == null || ServerUtil.isJBoss7(page.getServer().getOriginal()))
+		if (page.getServer().getRuntime() == null || ServerUtil.isJBoss7(page.getServer().getOriginal()))
 			return "";//$NON-NLS-1$
-		return ModuleDeploymentPage.makeRelative(getServer().getDeployFolder(), 
-					page.getServer().getRuntime());
+		return ModuleDeploymentPage.makeRelative(getServer().getDeployFolder(),
+				page.getServer().getRuntime());
 	}
 
 	private String getTempDeployDir() {
-		if( page.getServer().getRuntime() == null || ServerUtil.isJBoss7(page.getServer().getOriginal()))
+		if (page.getServer().getRuntime() == null || ServerUtil.isJBoss7(page.getServer().getOriginal()))
 			return "";//$NON-NLS-1$
-		return 
-			ModuleDeploymentPage.makeRelative(getServer().getTempDeployFolder(), 
-					page.getServer().getRuntime());
+		return ModuleDeploymentPage.makeRelative(getServer().getTempDeployFolder(),
+				page.getServer().getRuntime());
 	}
 
 	private IDeployableServer getServer() {
 		return (IDeployableServer) page.getServer().loadAdapter(
 				IDeployableServer.class, new NullProgressMonitor());
 	}
-/*
- * 
- * 
- * 
- * This is where the second half goes
- * 
- * 
- * 
- */
+
+	/*
+	 * 
+	 * 
+	 * 
+	 * This is where the second half goes
+	 */
 	protected Composite createViewerPortion(Composite random) {
 		Composite root = new Composite(random, SWT.NONE);
 		root.setLayout(new FormLayout());
@@ -615,46 +640,60 @@
 		viewer.setLabelProvider(new ModulePageLabelProvider());
 		viewer.setColumnProperties(new String[] { COLUMN_NAME,
 				COLUMN_LOC, COLUMN_TEMP_LOC });
-		viewer.setInput(""); // irrelevent
+		viewer.setInput(""); // irrelevent //$NON-NLS-1$
 		CellEditor[] editors = new CellEditor[] {
 				new TextCellEditor(viewer.getTree()),
 				new TextCellEditor(viewer.getTree()),
 				new TextCellEditor(viewer.getTree()) };
 		viewer.setCellModifier(new LocalDeploymentCellModifier());
 		viewer.setCellEditors(editors);
-		
-		Link link = new Link(root, SWT.DEFAULT);
-		link.setText("<a>" + Messages.EditorRefreshViewer + "</a>");
-		link.addSelectionListener(new SelectionListener() {
-			public void widgetSelected(SelectionEvent e) {
-				refreshViewer();
-			}
-			public void widgetDefaultSelected(SelectionEvent e) {
-			}
-		});
-		FormData linkData = new FormData();
-		linkData.bottom = new FormAttachment(100,-5);
-		linkData.left = new FormAttachment(0, 5);
-		link.setLayoutData(linkData);
-		
+
 		FormData treeData = new FormData();
 		treeData.top = new FormAttachment(0, 5);
-		treeData.bottom = new FormAttachment(link, -5);
+		// treeData.bottom = new FormAttachment(link, -5);
+		treeData.bottom = new FormAttachment(100, -5);
 		treeData.left = new FormAttachment(0, 5);
 		treeData.right = new FormAttachment(100, -5);
 		viewer.getTree().setLayoutData(treeData);
 
+		initWorkspaceChangeListener(root);
+		
 		return root;
 	}
 
-	private void refreshViewer() {
-		page.refreshPossibleModules();
-		viewer.setInput(""); // irrelevent		
+	private void initWorkspaceChangeListener(Composite composite) {
+		final IResourceChangeListener workspaceChangeListener = onWorkspaceChanged();
+		ResourcesPlugin.getWorkspace().addResourceChangeListener(workspaceChangeListener);
+		composite.addDisposeListener(new DisposeListener() {
+			
+			@Override
+			public void widgetDisposed(DisposeEvent e) {
+				ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceChangeListener);
+				
+			}
+		});
 	}
-	
+
+	private IResourceChangeListener onWorkspaceChanged() {
+		return new IResourceChangeListener() {
+			
+			@Override
+			public void resourceChanged(final IResourceChangeEvent event) {
+				new UIJob("refreshing available deployments") {
+					
+					@Override
+					public IStatus runInUIThread(IProgressMonitor monitor) {
+						viewer.refresh();
+						return Status.OK_STATUS;
+					}
+				}.schedule();
+			}
+		};
+	}
+
 	private class LocalDeploymentCellModifier implements ICellModifier {
 		public boolean canModify(Object element, String property) {
-			if( property == COLUMN_NAME)
+			if (property == COLUMN_NAME)
 				return false;
 			return true;
 		}
@@ -663,7 +702,7 @@
 			DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
 					.getOrCreateModulePrefs((IModule) element);
 			if (property == COLUMN_LOC) {
-				return getOutputFolderAndName(p, (IModule)element);
+				return getOutputFolderAndName(p, (IModule) element);
 			}
 			if (property == COLUMN_TEMP_LOC) {
 				String ret = p.getProperty(COLUMN_TEMP_LOC);
@@ -679,11 +718,11 @@
 			DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
 					.getOrCreateModulePrefs(module);
 			if (property == COLUMN_LOC) {
-				String outputName = new Path(((String)value)).lastSegment();
-				String outPath = ((String)value).substring(0, ((String)value).length()-outputName.length());
-				page.firePropertyChangeCommand(p, 
-						new String[]{COLUMN_LOC, OUTPUT_NAME},
-						new String[]{outPath,outputName},
+				String outputName = new Path(((String) value)).lastSegment();
+				String outPath = ((String) value).substring(0, ((String) value).length() - outputName.length());
+				page.firePropertyChangeCommand(p,
+						new String[] { COLUMN_LOC, OUTPUT_NAME },
+						new String[] { outPath, outputName },
 						Messages.EditorEditDeployLocCommand);
 				viewer.refresh();
 			} else if (property == COLUMN_TEMP_LOC) {
@@ -702,7 +741,8 @@
 		}
 
 		public Object[] getElements(Object inputElement) {
-			return page.getPossibleModules();
+			// return page.getPossibleModules();
+			return getPossibleModules();
 		}
 
 		public boolean hasChildren(Object element) {
@@ -718,6 +758,26 @@
 		}
 	}
 
+	public IModule[] getPossibleModules() {
+		IServerWorkingCopy server = getPage().getServer();
+		List<IModule> possibleChildren = new ArrayList<IModule>();
+		IModule[] modules2 = org.eclipse.wst.server.core.ServerUtil.getModules(server.getServerType().getRuntimeType()
+				.getModuleTypes());
+		if (modules2 != null) {
+			int size = modules2.length;
+			for (int i = 0; i < size; i++) {
+				IModule module = modules2[i];
+				IStatus status = server.canModifyModules(new IModule[] { module }, null, null);
+				if (status != null 
+						&& status.getSeverity() != IStatus.ERROR
+						&& module.getProject().isAccessible()) {
+					possibleChildren.add(module);
+				}
+			}
+		}
+		return possibleChildren.toArray(new IModule[possibleChildren.size()]);
+	}
+
 	private class ModulePageLabelProvider implements ITableLabelProvider {
 		public Image getColumnImage(Object element, int columnIndex) {
 			if (element instanceof IModule && columnIndex == 0) {
@@ -769,39 +829,42 @@
 	}
 
 	public void updateListeners() {
-		// server has been saved. Remove property change listener from last wc and add to newest
-		if( lastWC != null )
+		// server has been saved. Remove property change listener from last wc
+		// and add to newest
+		if (lastWC != null)
 			lastWC.removePropertyChangeListener(this);
 		lastWC = page.getServer();
-		if( lastWC != null )
+		if (lastWC != null)
 			lastWC.addPropertyChangeListener(this);
 	}
 
 	public void propertyChange(PropertyChangeEvent evt) {
-		if( getShowRadios() && evt.getPropertyName().equals( IDeployableServer.SERVER_MODE)) { 
-			String mode = page.getServer().getAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+		if (getShowRadios() && evt.getPropertyName().equals(IDeployableServer.SERVER_MODE)) {
+			String mode = page.getServer().getAttribute(IDeployableServer.SERVER_MODE,
+					LocalPublishMethod.LOCAL_PUBLISH_METHOD);
 			metadataRadio.setEnabled(callbackMappings.get(mode).metadataEnabled());
-			String originalDeployLocation = page.getServer().getOriginal().getAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
-			String wcDeployLocation = page.getServer().getAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
-			if(!metadataRadio.isEnabled() && metadataRadio.getSelection()) {
+			String originalDeployLocation = page.getServer().getOriginal()
+					.getAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
+			String wcDeployLocation = page.getServer().getAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
+					IDeployableServer.DEPLOY_CUSTOM);
+			if (!metadataRadio.isEnabled() && metadataRadio.getSelection()) {
 				page.execute(new RadioClickedCommand(serverRadio, currentSelection));
 			}
-		} 
+		}
 		updateWidgets();
-		
+
 	}
-	
-	
+
 	public static String getDefaultOutputName(IModule module) {
 		return new Path(module.getName()).lastSegment() + PublishUtil.getSuffix(module.getModuleType().getId());
 	}
-	
+
 	protected static String getOutputFolderAndName(DeploymentModulePrefs modPref, IModule m) {
 		String folder = modPref.getProperty(COLUMN_LOC);
 		String outputName = modPref.getProperty(OUTPUT_NAME);
-		outputName = outputName == null || outputName.equals("") 
-			? getDefaultOutputName(m) : outputName;
-			
+		outputName = outputName == null || outputName.equals("")
+				? getDefaultOutputName(m) : outputName;
+
 		if (folder != null)
 			return new Path(folder).append(outputName).toPortableString();
 		return outputName;
