[jbosstools-commits] JBoss Tools SVN: r23835 - in workspace/rstryker/rse/as/plugins: org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Jul 30 08:27:45 EDT 2010


Author: rob.stryker at jboss.com
Date: 2010-07-30 08:27:44 -0400 (Fri, 30 Jul 2010)
New Revision: 23835

Modified:
   workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
   workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
   workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
Log:
 JBIDE-6580 ensuring changes on page one accurately change settings / widgets on page 2.  Ugh. 

Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java	2010-07-30 12:11:09 UTC (rev 23834)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java	2010-07-30 12:27:44 UTC (rev 23835)
@@ -15,6 +15,7 @@
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerAttributes;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.ServerCore;
 import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
@@ -108,8 +109,11 @@
 		servers.toArray(ret);
 		return ret;
 	}
+	public static IJBossServerRuntime getJBossRuntime(IServer server) {
+		return getJBossRuntime((IServerAttributes)server);
+	}
 
-	public static IJBossServerRuntime getJBossRuntime(IServer server) {
+	public static IJBossServerRuntime getJBossRuntime(IServerAttributes server) {
 		IRuntime rt = server.getRuntime();
 		return (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, null);
 	}

Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java	2010-07-30 12:11:09 UTC (rev 23834)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java	2010-07-30 12:27:44 UTC (rev 23835)
@@ -13,6 +13,7 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerAttributes;
 import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
 import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
 import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
@@ -35,11 +36,11 @@
 		return server.getAttribute(RSEUtils.RSE_SERVER_HOST, RSE_SERVER_DEFAULT_HOST);
 	}
 	
-	public static String getRSEHomeDir(IServer server) {
+	public static String getRSEHomeDir(IServerAttributes server) {
 		return server.getAttribute(RSEUtils.RSE_SERVER_HOME_DIR, server.getRuntime().getLocation().toString());
 	}
 	
-	public static String getRSEConfigName(IServer server) {
+	public static String getRSEConfigName(IServerAttributes server) {
 		IJBossServerRuntime runtime = ServerConverter.getJBossRuntime(server);
 		return server.getAttribute(RSEUtils.RSE_SERVER_CONFIG, runtime.getJBossConfiguration());
 	}

Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	2010-07-30 12:11:09 UTC (rev 23834)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java	2010-07-30 12:27:44 UTC (rev 23835)
@@ -64,7 +64,10 @@
 import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
 import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
 import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
 import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
+import org.jboss.ide.eclipse.as.rse.core.RSEUtils;
 import org.jboss.ide.eclipse.as.ui.Messages;
 
 public class DeploymentModuleOptionCompositeAssistant implements PropertyChangeListener {
@@ -138,13 +141,8 @@
 
 		IRuntime rt = getServer().getServer().getRuntime();
 		boolean showRadios = true;
-		if( rt == null )
+		if( rt == null || rt.loadAdapter(IJBossServerRuntime.class, null) == null)
 			showRadios = false;
-		else {
-			IJBossServerRuntime jbsrt = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
-			if( jbsrt == null )
-				showRadios = false;
-		}
 
 		if( showRadios ) {
 			metadataRadio = toolkit.createButton(inner,
@@ -154,15 +152,6 @@
 			customRadio = toolkit.createButton(inner,
 					Messages.EditorUseCustomDeployFolder, SWT.RADIO);
 	
-			metadataRadio.setSelection(getDeployType().equals(
-					IDeployableServer.DEPLOY_METADATA));
-			serverRadio.setSelection(getDeployType().equals(
-					IDeployableServer.DEPLOY_SERVER));
-			customRadio.setSelection(getDeployType().equals(
-					IDeployableServer.DEPLOY_CUSTOM));
-			currentSelection = metadataRadio.getSelection() ? metadataRadio
-					: serverRadio.getSelection() ? serverRadio : customRadio;
-	
 			radioListener = new SelectionListener() {
 				public void widgetDefaultSelected(SelectionEvent e) {
 					widgetSelected(e);
@@ -242,11 +231,6 @@
 			}
 		});
 
-		deployText
-				.setEnabled(customRadio == null || customRadio.getSelection());
-		tempDeployText.setEnabled(customRadio == null
-				|| customRadio.getSelection());
-
 		FormData descriptionLabelData = new FormData();
 		descriptionLabelData.left = new FormAttachment(0, 5);
 		descriptionLabelData.top = new FormAttachment(0, 5);
@@ -317,9 +301,38 @@
 		toolkit.paintBordersFor(composite);
 		section.setClient(composite);
 		page.getSaveStatus();
+		updateWidgets();
 		return section;
 	}
 	
+	private void updateWidgets() {
+		metadataRadio.setSelection(getDeployType().equals(
+				IDeployableServer.DEPLOY_METADATA));
+		serverRadio.setSelection(getDeployType().equals(
+				IDeployableServer.DEPLOY_SERVER));
+		customRadio.setSelection(getDeployType().equals(
+				IDeployableServer.DEPLOY_CUSTOM));
+		currentSelection = metadataRadio.getSelection() ? metadataRadio
+				: serverRadio.getSelection() ? serverRadio : customRadio;
+		
+		String mode = page.getServer().getAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+		metadataRadio.setEnabled(!mode.equals(RSEPublishMethod.RSE_ID));
+		
+		String newDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY, "");
+		String newTemp = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, "");
+		deployText.removeModifyListener(deployListener);
+		deployText.setText(newDir);
+		deployText.addModifyListener(deployListener);
+		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));
+	}
+	
 	protected void radioSelected(Object c) {
 		if (c == currentSelection)
 			return; // do nothing
@@ -360,13 +373,12 @@
 		public void execute() {
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
 			lastCustomDeploy = newDir;
+			updateWidgets();
 			page.getSaveStatus();
 		}
 		public void undo() {
-			text.removeModifyListener(listener);
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
-			text.setText(oldDir);
-			text.addModifyListener(listener);
+			updateWidgets();
 			page.getSaveStatus();
 		}
 	}
@@ -407,13 +419,12 @@
 		public void execute() {
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
 			lastCustomTemp = newDir;
+			updateWidgets();
 			page.getSaveStatus();
 		}
 		public void undo() {
-			text.removeModifyListener(listener);
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
-			text.setText(oldDir);
-			text.addModifyListener(listener);
+			updateWidgets();
 			page.getSaveStatus();
 		}
 	}
@@ -430,109 +441,72 @@
 			id = server.getId();
 		}
 		public void execute() {
-			boolean custom = newSelection == customRadio;
-			deployText.setEnabled(custom);
-			tempDeployText.setEnabled(custom);
-			deployButton.setEnabled(custom);
-			tempDeployButton.setEnabled(custom);
 			oldDir = deployText.getText();
 			oldTemp = tempDeployText.getText();
-			
-			String type = null;
-			String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
-	 			oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+			String newType = newSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
+	 			newSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
 	 				IDeployableServer.DEPLOY_METADATA;
-			
+			discoverNewFolders();
+			ServerAttributeHelper helper = getHelper();
+			helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
+			helper.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newTemp);
+			helper.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, newType);
+			updateWidgets();
+			page.getSaveStatus();
+		}
+		
+		protected void discoverNewFolders() {
+			// Discover the new folders
 			if( newSelection == metadataRadio  ) {
 				newDir = JBossServerCorePlugin.getServerStateLocation(id)
 					.append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
 				newTemp = JBossServerCorePlugin.getServerStateLocation(id)
 					.append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
-				type = IDeployableServer.DEPLOY_METADATA;
 				new File(newDir).mkdirs();
 				new File(newTemp).mkdirs();
 			} else if( newSelection == serverRadio ) {
-				IRuntime rt = server.getRuntime();
-				if( rt != null ) {
-					IJBossServerRuntime jbsrt = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
-					if( jbsrt != null ) {
-						String loc = jbsrt.getConfigLocation();
-						String config = jbsrt.getJBossConfiguration();
-						newDir = new Path(loc)
-							.append(config)
-							.append(IJBossServerConstants.DEPLOY).toString();
-						newTemp = new Path(loc).append(config)
-							.append(IJBossServerConstants.TMP)
-							.append(IJBossServerConstants.JBOSSTOOLS_TMP).toString();
-						new File(newTemp).mkdirs();
-						type = IDeployableServer.DEPLOY_SERVER;
+				if( server.getRuntime() != null && 
+						server.getRuntime().loadAdapter(IJBossServerRuntime.class, null) != null) {
+					IJBossServerRuntime jbsrt = (IJBossServerRuntime)getServer().getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
+					String loc, config;
+					loc = config = null;
+					String mode = getHelper().getAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD); 
+					if(  mode.equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD)){
+						loc = jbsrt.getConfigLocation();
+						config = jbsrt.getJBossConfiguration();
+					} else if( mode.equals(RSEPublishMethod.RSE_ID)) {
+						loc = IConstants.SERVER;
+						config = RSEUtils.getRSEConfigName(getHelper().getWorkingCopy());
 					}
+					newDir = new Path(loc)
+						.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))
+						new File(newTemp).mkdirs();
 				}
 			} else {
 				newDir = lastCustomDeploy;
 				newTemp = lastCustomTemp;
-				type = IDeployableServer.DEPLOY_CUSTOM;
 			}
-			
-			if( !newSelection.getSelection() ) {
-				// REDO, so no one actually clicked the radio. UGH!
-				oldSelection.removeSelectionListener(radioListener);
-				oldSelection.setSelection(false);
-				oldSelection.addSelectionListener(radioListener);
-				
-				newSelection.removeSelectionListener(radioListener);
-				newSelection.setSelection(true);
-				newSelection.addSelectionListener(radioListener);
-			}
-			
-			type = type == null ? oldType : type;
 			newDir = newDir == null ? oldDir : newDir;
 			newTemp = newTemp == null ? oldTemp : newTemp; 
-			
-			deployText.removeModifyListener(deployListener);
-			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
-			deployText.setText(newDir);
-			deployText.addModifyListener(deployListener);
-
-			tempDeployText.removeModifyListener(tempDeployListener);
-			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newTemp);
-			tempDeployText.setText(newTemp);
-			tempDeployText.addModifyListener(tempDeployListener);
-			
-			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, type);
-			page.getSaveStatus();
 		}
+		
 		public void undo() {
-			deployText.removeModifyListener(deployListener);
+			String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
+	 			oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+	 				IDeployableServer.DEPLOY_METADATA;
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
-			deployText.setText(oldDir);
-			deployText.addModifyListener(deployListener);
-
-			tempDeployText.removeModifyListener(tempDeployListener);
 			getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldTemp);
-			tempDeployText.setText(oldTemp);
-			tempDeployText.addModifyListener(tempDeployListener);
-			
-			oldSelection.removeSelectionListener(radioListener);
-			oldSelection.setSelection(true);
-			oldSelection.addSelectionListener(radioListener);
-			
-			newSelection.removeSelectionListener(radioListener);
-			newSelection.setSelection(false);
-			newSelection.addSelectionListener(radioListener);
-			
-			deployText.setEnabled(customRadio.getSelection());
-			tempDeployText.setEnabled(customRadio.getSelection());
-			
-			String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
-				 			oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
-				 				IDeployableServer.DEPLOY_METADATA;
 			getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, oldType);
+			updateWidgets();
 			page.getSaveStatus();
 		}
 	}
 	
-	
 	private String getDeployType() {
 		return getServer().getDeployLocationType();
 	}
@@ -736,11 +710,12 @@
 			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()) {
-				metadataRadio.setSelection(false);
-				serverRadio.setSelection(true);
-				radioSelected(serverRadio);
-				int x = 3; x++;
+				page.execute(new RadioClickedCommand(serverRadio, currentSelection));
 			}
+		} else if( serverRadio.getSelection() && ( 
+				evt.getPropertyName().equals( RSEUtils.RSE_SERVER_CONFIG) || 
+				evt.getPropertyName().equals( RSEUtils.RSE_SERVER_HOME_DIR))) {
+			page.execute(new RadioClickedCommand(serverRadio, currentSelection));
 		}
 	}
 }



More information about the jbosstools-commits mailing list