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

svn commit: r410409 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/ org.apache.geronimo.st.ui/src/org/apache/geronimo/s...

Author: sppatel
Date: Tue May 30 17:18:23 2006
New Revision: 410409

URL: http://svn.apache.org/viewvc?rev=410409&view=rev
Log:
GERONIMODEVTOOLS-75

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServer.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerBehaviour.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetConsoleLogLevelCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorLogLevelSection.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServer.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServer.java?rev=410409&r1=410408&r2=410409&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServer.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServer.java Tue May 30 17:18:23 2006
@@ -22,6 +22,7 @@
 import java.util.jar.Manifest;
 
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jst.server.core.IWebModule;
 import org.eclipse.jst.server.generic.core.internal.GenericServer;
 import org.eclipse.jst.server.generic.core.internal.Trace;
@@ -39,6 +40,12 @@
 
 	public static final String PROPERTY_HTTP_PORT = "port";
 
+	public static final String PROPERTY_LOG_LEVEL = "logLevel";
+
+	public static final String CONSOLE_INFO = "-v";
+
+	public static final String CONSOLE_DEBUG = "-vv";
+
 	public abstract String getContextRoot(IModule module);
 
 	public URL getModuleRootURL(IModule module) {
@@ -88,6 +95,10 @@
 		return (String) getServerInstanceProperties().get(PROPERTY_HTTP_PORT);
 	}
 
+	public String getConsoleLogLevel() {
+		return (String) getServerInstanceProperties().get(PROPERTY_LOG_LEVEL);
+	}
+
 	public void setAdminID(String value) {
 		getServerInstanceProperties().put(PROPERTY_ADMIN_ID, value);
 	}
@@ -103,7 +114,11 @@
 	public void setHTTPPort(String value) {
 		getServerInstanceProperties().put(PROPERTY_HTTP_PORT, value);
 	}
-	
+
+	public void setConsoleLogLevel(String value) {
+		getServerInstanceProperties().put(PROPERTY_LOG_LEVEL, value);
+	}
+
 	public String discoverDeploymentFactoryClassName(IPath jarPath) {
 		try {
 			JarFile deployerJar = new JarFile(jarPath.toFile());
@@ -112,8 +127,15 @@
 			return attributes.getValue("J2EE-DeploymentFactory-Implementation-Class");
 		} catch (IOException e) {
 			e.printStackTrace();
-		}		
+		}
 		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jst.server.generic.core.internal.GenericServer#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public void setDefaults(IProgressMonitor monitor) {
+		setConsoleLogLevel(CONSOLE_INFO);
 	}
 
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerBehaviour.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerBehaviour.java?rev=410409&r1=410408&r2=410409&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerBehaviour.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerBehaviour.java Tue May 30 17:18:23 2006
@@ -258,21 +258,12 @@
 	 * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy,
 	 *      org.eclipse.core.runtime.IProgressMonitor)
 	 */
-	public void setupLaunchConfiguration(
-			ILaunchConfigurationWorkingCopy workingCopy,
-			IProgressMonitor monitor) throws CoreException {
-		String defaultArgs = getServerDefinition().getResolver()
-				.resolveProperties(
-						getServerDefinition().getStart()
-								.getProgramArgumentsAsString());
-		String existingPrgArgs = workingCopy.getAttribute(
-				IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
-				defaultArgs);
+	public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
 		super.setupLaunchConfiguration(workingCopy, monitor);
-		if (existingPrgArgs != null) {
-			workingCopy.setAttribute(
-					IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
-					existingPrgArgs);
+		String args = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
+		if(args.length() == 0) {
+			GenericGeronimoServer gs = (GenericGeronimoServer) getServer().getAdapter(GenericGeronimoServer.class);
+			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args.concat(" ").concat(gs.getConsoleLogLevel()));
 		}
 	}
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetConsoleLogLevelCommand.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetConsoleLogLevelCommand.java?rev=410409&r1=410408&r2=410409&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetConsoleLogLevelCommand.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/commands/SetConsoleLogLevelCommand.java Tue May 30 17:18:23 2006
@@ -15,33 +15,22 @@
  */
 package org.apache.geronimo.st.ui.commands;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.apache.geronimo.st.core.GenericGeronimoServer;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.internal.Server;
 
 public class SetConsoleLogLevelCommand extends ServerCommand {
 
-	public static final String NONE = "--long";
+	String value;
 
-	public static final String INFO = "-v";
-
-	public static final String DEBUG = "-vv";
-
-	protected String value;
-
-	protected String oldValue;
-
-	private ILaunchConfigurationWorkingCopy wc = null;
+	String oldValue;
 
 	/**
 	 * @param server
 	 * @param name
 	 */
 	public SetConsoleLogLevelCommand(IServerWorkingCopy server, String value) {
-		super(server, value);
+		super(server, "SetConsoleLogLevelCommand");
 		this.value = value;
 	}
 
@@ -51,19 +40,9 @@
 	 * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#execute()
 	 */
 	public void execute() {
-		try {
-			oldValue = getCurrentValue();
-			if (oldValue != value) {
-				getLaunchConfiguration().setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, value);
-				getLaunchConfiguration().doSave();
-			}
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public String getCurrentValue() throws CoreException {
-		return getLaunchConfiguration().getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, NONE);
+		GenericGeronimoServer gs = getGeronimoServer();
+		oldValue = gs.getConsoleLogLevel();
+		gs.setConsoleLogLevel(value);
 	}
 
 	/*
@@ -72,21 +51,14 @@
 	 * @see org.eclipse.wst.server.ui.internal.command.ServerCommand#undo()
 	 */
 	public void undo() {
-		try {
-			getLaunchConfiguration().setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, oldValue);
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
+		getGeronimoServer().setConsoleLogLevel(oldValue);
 	}
 
-	private ILaunchConfigurationWorkingCopy getLaunchConfiguration()
-			throws CoreException {
-		if (wc == null) {
-			Server s = (Server) server.getAdapter(Server.class);
-			ILaunchConfiguration launchConfig = s.getLaunchConfiguration(true, null);
-			wc = launchConfig.getWorkingCopy();
+	private GenericGeronimoServer getGeronimoServer() {
+		GenericGeronimoServer gs = (GenericGeronimoServer) server.getAdapter(GenericGeronimoServer.class);
+		if (gs == null) {
+			gs = (GenericGeronimoServer) server.loadAdapter(GenericGeronimoServer.class, new NullProgressMonitor());
 		}
-		return wc;
+		return gs;
 	}
-
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorLogLevelSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorLogLevelSection.java?rev=410409&r1=410408&r2=410409&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorLogLevelSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorLogLevelSection.java Tue May 30 17:18:23 2006
@@ -15,9 +15,9 @@
  */
 package org.apache.geronimo.st.ui.sections;
 
+import org.apache.geronimo.st.core.GenericGeronimoServer;
 import org.apache.geronimo.st.ui.commands.SetConsoleLogLevelCommand;
 import org.apache.geronimo.st.ui.internal.Messages;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
@@ -45,10 +45,10 @@
 
 		FormToolkit toolkit = getFormToolkit(parent.getDisplay());
 
-		Section section = toolkit.createSection(parent,
-				ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
-						| ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
-						| ExpandableComposite.FOCUS_TITLE);
+		Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE
+				| ExpandableComposite.EXPANDED
+				| ExpandableComposite.TITLE_BAR
+				| Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE);
 
 		section.setText(Messages.editorSectionLogLevelTitle);
 		section.setDescription(Messages.editorSectionLogLevelDescription);
@@ -67,27 +67,19 @@
 
 		info = toolkit.createButton(composite, Messages.info, SWT.RADIO);
 		debug = toolkit.createButton(composite, Messages.debug, SWT.RADIO);
-
-		SetConsoleLogLevelCommand cmd = new SetConsoleLogLevelCommand(server,
-				null);
-		try {
-			String value = cmd.getCurrentValue();
-			if (value.indexOf("-vv") != -1) {
-				debug.setSelection(true);
-			} else {
-				info.setSelection(true);
-			}
-		} catch (CoreException e1) {
-			e1.printStackTrace();
+		
+		String currentValue = ((GenericGeronimoServer)server.getAdapter(GenericGeronimoServer.class)).getConsoleLogLevel();
+		if(GenericGeronimoServer.CONSOLE_DEBUG.equals(currentValue)) {
+			debug.setSelection(true);
+		} else {
+			info.setSelection(true);
 		}
 
 		info.addSelectionListener(new SelectionListener() {
 
 			public void widgetSelected(SelectionEvent e) {
 				if (info.getSelection()) {
-					SetConsoleLogLevelCommand cmd = new SetConsoleLogLevelCommand(
-							server, SetConsoleLogLevelCommand.INFO);
-					cmd.execute();
+					execute(new SetConsoleLogLevelCommand(server, GenericGeronimoServer.CONSOLE_INFO));
 				}
 			}
 
@@ -100,9 +92,7 @@
 
 			public void widgetSelected(SelectionEvent e) {
 				if (debug.getSelection()) {
-					SetConsoleLogLevelCommand cmd = new SetConsoleLogLevelCommand(
-							server, SetConsoleLogLevelCommand.DEBUG);
-					cmd.execute();
+					execute(new SetConsoleLogLevelCommand(server, GenericGeronimoServer.CONSOLE_DEBUG));
 				}
 			}
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java?rev=410409&r1=410408&r2=410409&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java Tue May 30 17:18:23 2006
@@ -23,6 +23,7 @@
 import org.apache.geronimo.st.core.GenericGeronimoServer;
 import org.apache.geronimo.st.core.IGeronimoVersionHandler;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.util.SocketUtil;
 
@@ -145,6 +146,16 @@
 	public void setRunFromWorkspace(boolean enable) {
 		setAttribute(PROPERTY_RUN_FROM_WORKSPACE, enable);
 		//getServerInstanceProperties().put(PROPERTY_RUN_FROM_WORKSPACE, Boolean.toString(enable));
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jst.server.generic.core.internal.GenericServer#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public void setDefaults(IProgressMonitor monitor) {
+		super.setDefaults(monitor);
+		setPersistent(true);
+		setInPlace(false);
+		setRunFromWorkspace(false);
 	}
 
 }