db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bakk...@apache.org
Subject svn commit: r329187 [65/66] - in /db/derby/code/trunk: ./ frameworks/NetworkServer/ frameworks/NetworkServer/bin/ frameworks/embedded/bin/ java/build/ java/build/org/apache/derbyBuild/ java/build/org/apache/derbyBuild/eclipse/ java/build/org/apache/der...
Date Fri, 28 Oct 2005 12:52:21 GMT
Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/AddDerbyNature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java Fri Oct 28 04:51:50 2005
@@ -1,121 +1,121 @@
-/*
-
-	Derby - Class org.apache.derby.ui.popup.actions.RemoveDerbyNature
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-package org.apache.derby.ui.popup.actions;
-
-import java.util.ArrayList;
-
-import org.apache.derby.ui.common.CommonNames;
-import org.apache.derby.ui.common.Messages;
-import org.apache.derby.ui.util.DerbyServerUtils;
-import org.apache.derby.ui.util.DerbyUtils;
-import org.apache.derby.ui.util.Logger;
-import org.apache.derby.ui.util.SelectionUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-public class RemoveDerbyNature implements IObjectActionDelegate {
-
-	private IJavaProject currentJavaProject;
-	private IProject currentProject;
-	/* (non-Javadoc)
-	 * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
-	 */
-	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
-		}
-
-
-	private static String[] removeDerbyNature(String [] natures){
-		ArrayList arrL=new ArrayList();
-		
-		for (int i=0;i<natures.length;i++){
-			if(!(natures[i].equalsIgnoreCase(CommonNames.DERBY_NATURE))){
-				arrL.add(natures[i]);
-			}
-		}
-		String [] newNatures= new String [arrL.size()];
-		for(int i=0;i<arrL.size();i++){
-			newNatures[i]=(String)arrL.get(i);
-		}
-		return newNatures;
-	}
-	/* (non-Javadoc)
-	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
-	 */	
-	public void run(IAction action) {
-		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-		try {
-			((ApplicationWindow)window).setStatus(Messages.REMOVING_NATURE);
-			
-			if(currentJavaProject==null){
-				currentJavaProject=JavaCore.create(currentProject);
-			}
-			//Shutdown server if running for the current project
-			if(DerbyServerUtils.getDefault().getRunning(currentJavaProject.getProject())){
-				DerbyServerUtils.getDefault().stopDerbyServer(currentJavaProject.getProject());
-			}
-			IClasspathEntry[] rawClasspath = currentJavaProject.getRawClasspath();
-			currentJavaProject.setRawClasspath(DerbyUtils.removeDerbyJars(rawClasspath), null);
-			
-			IProjectDescription description = currentJavaProject.getProject().getDescription();
-			String[] natures = description.getNatureIds();
-
-			description.setNatureIds(removeDerbyNature(natures));
-			currentJavaProject.getProject().setDescription(description, null);
-			// refresh project so user sees changes
-			currentJavaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
-			((ApplicationWindow)window).setStatus(Messages.DERBY_NATURE_REMOVED);
-		}catch (Exception e) {
-			Logger.log(Messages.ERROR_REMOVING_NATURE+" '"+currentJavaProject.getProject().getName()+"': "+e,IStatus.ERROR);
-
-			Shell shell = new Shell();
-			MessageDialog.openInformation(
-				shell,
-				CommonNames.PLUGIN_NAME,
-				Messages.ERROR_REMOVING_NATURE+":\n" +
-				 SelectionUtil.getStatusMessages(e));
-		}
-
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
-	 */
-	public void selectionChanged(IAction action, ISelection selection) {
-		currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);
-		if(currentJavaProject==null){
-			currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
-		}
-	}
-
-}
+/*
+
+	Derby - Class org.apache.derby.ui.popup.actions.RemoveDerbyNature
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+package org.apache.derby.ui.popup.actions;
+
+import java.util.ArrayList;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.apache.derby.ui.util.DerbyUtils;
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class RemoveDerbyNature implements IObjectActionDelegate {
+
+	private IJavaProject currentJavaProject;
+	private IProject currentProject;
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+	 */
+	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+		}
+
+
+	private static String[] removeDerbyNature(String [] natures){
+		ArrayList arrL=new ArrayList();
+		
+		for (int i=0;i<natures.length;i++){
+			if(!(natures[i].equalsIgnoreCase(CommonNames.DERBY_NATURE))){
+				arrL.add(natures[i]);
+			}
+		}
+		String [] newNatures= new String [arrL.size()];
+		for(int i=0;i<arrL.size();i++){
+			newNatures[i]=(String)arrL.get(i);
+		}
+		return newNatures;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+	 */	
+	public void run(IAction action) {
+		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+		try {
+			((ApplicationWindow)window).setStatus(Messages.REMOVING_NATURE);
+			
+			if(currentJavaProject==null){
+				currentJavaProject=JavaCore.create(currentProject);
+			}
+			//Shutdown server if running for the current project
+			if(DerbyServerUtils.getDefault().getRunning(currentJavaProject.getProject())){
+				DerbyServerUtils.getDefault().stopDerbyServer(currentJavaProject.getProject());
+			}
+			IClasspathEntry[] rawClasspath = currentJavaProject.getRawClasspath();
+			currentJavaProject.setRawClasspath(DerbyUtils.removeDerbyJars(rawClasspath), null);
+			
+			IProjectDescription description = currentJavaProject.getProject().getDescription();
+			String[] natures = description.getNatureIds();
+
+			description.setNatureIds(removeDerbyNature(natures));
+			currentJavaProject.getProject().setDescription(description, null);
+			// refresh project so user sees changes
+			currentJavaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+			((ApplicationWindow)window).setStatus(Messages.DERBY_NATURE_REMOVED);
+		}catch (Exception e) {
+			Logger.log(Messages.ERROR_REMOVING_NATURE+" '"+currentJavaProject.getProject().getName()+"': "+e,IStatus.ERROR);
+
+			Shell shell = new Shell();
+			MessageDialog.openInformation(
+				shell,
+				CommonNames.PLUGIN_NAME,
+				Messages.ERROR_REMOVING_NATURE+":\n" +
+				 SelectionUtil.getStatusMessages(e));
+		}
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+	 */
+	public void selectionChanged(IAction action, ISelection selection) {
+		currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);
+		if(currentJavaProject==null){
+			currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+		}
+	}
+
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java Fri Oct 28 04:51:50 2005
@@ -1,122 +1,122 @@
-/*
-
-	Derby - Class org.apache.derby.ui.properties.DerbyProperties
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.properties;
-
-import org.apache.derby.ui.common.CommonNames;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.jdt.core.IJavaProject;
-
-
-
-public class DerbyProperties {
-
-	public static final String DSPORT = "ds.port";
-	//public static final String DS_RUNNING_PORT = "ds.running.port";
-	public static final String DSHOST = "ds.host";
-	public static final String DS_SYS_HOME = "derby.system.home";
-	
-	//Default Derby Properties
-	private int port = 1527;
-	//private int runningPort=0;
-	private String host = "localhost";
-	private String systemHome = ".";
-	
-	public DerbyProperties() {}
-	
-	public DerbyProperties(IJavaProject javaProject) throws CoreException {
-		load(javaProject.getProject());
-	}
-	public DerbyProperties(IProject project) throws CoreException {
-		load(project);
-	}
-	
-	public void save(IProject project) throws CoreException {
-		
-		project.setPersistentProperty(new QualifiedName (
-			CommonNames.UI_PATH, DSPORT), Integer.toString(port));
-		project.setPersistentProperty(new QualifiedName (
-			CommonNames.UI_PATH, DSHOST), host);
-		project.setPersistentProperty(new QualifiedName (
-			CommonNames.UI_PATH, DS_SYS_HOME), systemHome);
-//		project.setPersistentProperty(new QualifiedName (
-//				CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
-	}
-	
-	public void load(IProject project) throws CoreException {
-		
-		String property = project.getPersistentProperty(new QualifiedName (
-				CommonNames.UI_PATH, DSPORT));
-		port = (property != null && property.length() > 0) ? Integer.parseInt(property) : port;
-		property = project.getPersistentProperty(new QualifiedName (
-				CommonNames.UI_PATH, DSHOST));
-		host = (property != null && property.length() > 0) ? property : host;
-		property = project.getPersistentProperty(new QualifiedName (
-				CommonNames.UI_PATH, DS_SYS_HOME));
-		systemHome = (property != null && property.length() > 0) ? property : systemHome;
-//		property = project.getPersistentProperty(new QualifiedName (
-//				CommonNames.UI_PATH, DS_RUNNING_PORT));
-//		runningPort = (property != null && property.length() > 0) ? Integer.parseInt(property) : runningPort;
-	}
-	public String toString(){
-		return "Derby Server Properties:\n Port = "+getPort()+" Host = "+getHost()+" System Home = "+getSystemHome();
-	}
-	
-	/**
-	 * @return Returns the host.
-	 */
-	public String getHost() {
-		return host;
-	}
-	/**
-	 * @param host The host to set.
-	 */
-	public void setHost(String host) {
-		this.host = host;
-	}
-	/**
-	 * @return Returns the port.
-	 */
-	public int getPort() {
-		return port;
-	}
-	/**
-	 * @param port The port to set.
-	 */
-	public void setPort(int port) {
-		this.port = port;
-	}
-	/**
-	 * @return Returns the systemHome.
-	 */
-	public String getSystemHome() {
-		return systemHome;
-	}
-	/**
-	 * @param systemHome The systemHome to set.
-	 */
-	public void setSystemHome(String systemHome) {
-		this.systemHome = systemHome;
-	}
-	
-}
-
+/*
+
+	Derby - Class org.apache.derby.ui.properties.DerbyProperties
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.properties;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jdt.core.IJavaProject;
+
+
+
+public class DerbyProperties {
+
+	public static final String DSPORT = "ds.port";
+	//public static final String DS_RUNNING_PORT = "ds.running.port";
+	public static final String DSHOST = "ds.host";
+	public static final String DS_SYS_HOME = "derby.system.home";
+	
+	//Default Derby Properties
+	private int port = 1527;
+	//private int runningPort=0;
+	private String host = "localhost";
+	private String systemHome = ".";
+	
+	public DerbyProperties() {}
+	
+	public DerbyProperties(IJavaProject javaProject) throws CoreException {
+		load(javaProject.getProject());
+	}
+	public DerbyProperties(IProject project) throws CoreException {
+		load(project);
+	}
+	
+	public void save(IProject project) throws CoreException {
+		
+		project.setPersistentProperty(new QualifiedName (
+			CommonNames.UI_PATH, DSPORT), Integer.toString(port));
+		project.setPersistentProperty(new QualifiedName (
+			CommonNames.UI_PATH, DSHOST), host);
+		project.setPersistentProperty(new QualifiedName (
+			CommonNames.UI_PATH, DS_SYS_HOME), systemHome);
+//		project.setPersistentProperty(new QualifiedName (
+//				CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
+	}
+	
+	public void load(IProject project) throws CoreException {
+		
+		String property = project.getPersistentProperty(new QualifiedName (
+				CommonNames.UI_PATH, DSPORT));
+		port = (property != null && property.length() > 0) ? Integer.parseInt(property) : port;
+		property = project.getPersistentProperty(new QualifiedName (
+				CommonNames.UI_PATH, DSHOST));
+		host = (property != null && property.length() > 0) ? property : host;
+		property = project.getPersistentProperty(new QualifiedName (
+				CommonNames.UI_PATH, DS_SYS_HOME));
+		systemHome = (property != null && property.length() > 0) ? property : systemHome;
+//		property = project.getPersistentProperty(new QualifiedName (
+//				CommonNames.UI_PATH, DS_RUNNING_PORT));
+//		runningPort = (property != null && property.length() > 0) ? Integer.parseInt(property) : runningPort;
+	}
+	public String toString(){
+		return "Derby Server Properties:\n Port = "+getPort()+" Host = "+getHost()+" System Home = "+getSystemHome();
+	}
+	
+	/**
+	 * @return Returns the host.
+	 */
+	public String getHost() {
+		return host;
+	}
+	/**
+	 * @param host The host to set.
+	 */
+	public void setHost(String host) {
+		this.host = host;
+	}
+	/**
+	 * @return Returns the port.
+	 */
+	public int getPort() {
+		return port;
+	}
+	/**
+	 * @param port The port to set.
+	 */
+	public void setPort(int port) {
+		this.port = port;
+	}
+	/**
+	 * @return Returns the systemHome.
+	 */
+	public String getSystemHome() {
+		return systemHome;
+	}
+	/**
+	 * @param systemHome The systemHome to set.
+	 */
+	public void setSystemHome(String systemHome) {
+		this.systemHome = systemHome;
+	}
+	
+}
+

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java Fri Oct 28 04:51:50 2005
@@ -1,220 +1,220 @@
-/*
-
-	Derby - Class org.apache.derby.ui.properties.DerbyPropertiesPage
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.properties;
-
-import org.apache.derby.ui.common.CommonNames;
-import org.apache.derby.ui.common.Messages;
-import org.apache.derby.ui.util.DerbyServerUtils;
-import org.apache.derby.ui.util.Logger;
-import org.apache.derby.ui.util.SelectionUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-
-
-public   class DerbyPropertiesPage extends PropertyPage {
-	public DerbyPropertiesPage() {
-		super();
-	}
-	protected DerbyProperties dsProps;
-	protected Text hostText;
-	protected Text portText;
-	protected Text systemHomeText;
-	private boolean isServerRunning;
-	
-
-	protected void addControls(Composite parent) {
-		Composite composite = createDefaultComposite(parent);
-		
-		//Network Server Settings
-		Label txt=new Label(composite,SWT.NONE);
-		txt.setBackground(new Color(null,0,0,0));
-		txt.setForeground(new Color(null,255,255,255));
-		txt.setText("Network Server Settings:");
-		
-		//separator
-		Label separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
-	    separatorLabel.setLayoutData(getSeperatorLabelGridData());
-	
-		org.eclipse.swt.widgets.
-		Label portLabel = new Label(composite, SWT.NONE);
-		portLabel.setText("&Network Server Port:");
-		portText = new Text(composite, SWT.SINGLE | SWT.BORDER);
-		GridData gd = new GridData();
-		gd.widthHint = convertWidthInCharsToPixels(6);
-		portText.setLayoutData(gd);
-	
-		Label hostLabel = new Label(composite, SWT.NONE);
-		hostLabel.setText("&Network Server Host:");
-		hostText = new Text(composite, SWT.SINGLE | SWT.BORDER);
-		gd = new GridData();
-		gd.widthHint = convertWidthInCharsToPixels(16);
-		hostText.setLayoutData(gd);
-	
-		//Derby System Properties
-		separatorLabel=new Label(composite, SWT.NONE);
-		separatorLabel.setLayoutData(getSeperatorLabelGridData());
-		separatorLabel.setText("");
-	
-		Label txt1=new Label(composite,SWT.NONE);
-		txt1.setBackground(new Color(null,0,0,0));
-		txt1.setForeground(new Color(null,255,255,255));
-		txt1.setText("Derby System Properties:");
-		
-		//separator
-		separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
-	    separatorLabel.setLayoutData(getSeperatorLabelGridData());
-		
-		Label sytemHomeLabel = new Label(composite, SWT.NONE);
-		sytemHomeLabel.setText("&derby.system.home=");
-		systemHomeText = new Text(composite, SWT.SINGLE | SWT.BORDER);
-		gd = new GridData();
-		gd.widthHint = convertWidthInCharsToPixels(16);
-		systemHomeText.setLayoutData(gd);
-	}
-
-	protected Composite createDefaultComposite(Composite parent) {
-		Composite composite = new Composite(parent, SWT.NULL);
-		GridLayout layout = new GridLayout();
-		layout.numColumns = 2;
-		composite.setLayout(layout);
-	
-		GridData data = new GridData();
-		data.verticalAlignment = GridData.FILL;
-		data.horizontalAlignment = GridData.FILL;
-		composite.setLayoutData(data);
-	
-		return composite;
-	}
-
-	protected void fillControls() {
-		portText.setText(Integer.toString(dsProps.getPort()));
-		hostText.setText(dsProps.getHost());
-		systemHomeText.setText(dsProps.getSystemHome());
-		isServerRunning = checkServer();
-		// if the server is running do not allow
-		// editing of the settings
-		if (isServerRunning) {
-		    portText.setEditable(false);
-		    hostText.setEditable(false);
-		    systemHomeText.setEditable(false);
-		}
-	}
-	
-	protected boolean checkServer() {
-	    IProject proj = (IProject)getElement();
-	    boolean serverRunning = false;
-	    try {
-	        serverRunning = DerbyServerUtils.getDefault().getRunning(proj);
-	    }
-	    catch (CoreException ce) {
-	        Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
-	    }
-	    return serverRunning;
-	}
-
-	protected void getParams() {
-		dsProps = new DerbyProperties();		
-		try {
-			dsProps.setPort(Integer.parseInt(portText.getText()));
-		}
-		catch (NumberFormatException ne) {
-			// do nothing; use the default port number
-		}
-		dsProps.setHost(hostText.getText());
-		dsProps.setSystemHome(systemHomeText.getText());
-		
-		// if the server is running inform the user
-		// to stop the server before changing the settings
-		if (isServerRunning) {
-		    Shell shell = new Shell();
-			MessageDialog.openInformation(
-			shell,
-			CommonNames.PLUGIN_NAME,
-			Messages.SERVER_RUNNING );
-		}
-	}
-
-	protected GridData getSeperatorLabelGridData() {
-	
-	    GridData gridData = new GridData(GridData.BEGINNING |
-	                            GridData.HORIZONTAL_ALIGN_FILL |
-	                            GridData.GRAB_VERTICAL |
-	                            GridData.BEGINNING |
-	                            GridData.VERTICAL_ALIGN_BEGINNING |
-	                            GridData.VERTICAL_ALIGN_FILL) ;
-	    gridData.horizontalSpan = 2;
-	    gridData.grabExcessVerticalSpace  = false;
-	    gridData.grabExcessHorizontalSpace = true;
-	    return gridData;
-	
-	}
-
-	protected void performDefaults() {
-		dsProps = new DerbyProperties();
-		fillControls();
-	}
-	public boolean performOk() {
-		IProject proj = (IProject)getElement();
-		getParams();
-		try {
-		
-			dsProps.save(proj.getProject());
-		}
-		catch (CoreException ce) {
-			System.err.println(SelectionUtil.getStatusMessages(ce));
-			return false;
-		}
-		return true;
-	}
-
-	protected Control createContents(Composite parent) {
-		Composite composite = new Composite(parent, SWT.NONE);
-		GridLayout layout = new GridLayout();
-		composite.setLayout(layout);
-		GridData data = new GridData(GridData.FILL);
-		data.grabExcessHorizontalSpace = true;
-		composite.setLayoutData(data);
-		addControls(composite);
-		IProject proj = (IProject)getElement();
-		try {
-			dsProps = new DerbyProperties(proj);
-			fillControls();
-		}
-		catch (CoreException ce) {
-			Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
-		}
-		return composite;
-	}	
-
-}
+/*
+
+	Derby - Class org.apache.derby.ui.properties.DerbyPropertiesPage
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.properties;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+
+public   class DerbyPropertiesPage extends PropertyPage {
+	public DerbyPropertiesPage() {
+		super();
+	}
+	protected DerbyProperties dsProps;
+	protected Text hostText;
+	protected Text portText;
+	protected Text systemHomeText;
+	private boolean isServerRunning;
+	
+
+	protected void addControls(Composite parent) {
+		Composite composite = createDefaultComposite(parent);
+		
+		//Network Server Settings
+		Label txt=new Label(composite,SWT.NONE);
+		txt.setBackground(new Color(null,0,0,0));
+		txt.setForeground(new Color(null,255,255,255));
+		txt.setText("Network Server Settings:");
+		
+		//separator
+		Label separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+	    separatorLabel.setLayoutData(getSeperatorLabelGridData());
+	
+		org.eclipse.swt.widgets.
+		Label portLabel = new Label(composite, SWT.NONE);
+		portLabel.setText("&Network Server Port:");
+		portText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+		GridData gd = new GridData();
+		gd.widthHint = convertWidthInCharsToPixels(6);
+		portText.setLayoutData(gd);
+	
+		Label hostLabel = new Label(composite, SWT.NONE);
+		hostLabel.setText("&Network Server Host:");
+		hostText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+		gd = new GridData();
+		gd.widthHint = convertWidthInCharsToPixels(16);
+		hostText.setLayoutData(gd);
+	
+		//Derby System Properties
+		separatorLabel=new Label(composite, SWT.NONE);
+		separatorLabel.setLayoutData(getSeperatorLabelGridData());
+		separatorLabel.setText("");
+	
+		Label txt1=new Label(composite,SWT.NONE);
+		txt1.setBackground(new Color(null,0,0,0));
+		txt1.setForeground(new Color(null,255,255,255));
+		txt1.setText("Derby System Properties:");
+		
+		//separator
+		separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+	    separatorLabel.setLayoutData(getSeperatorLabelGridData());
+		
+		Label sytemHomeLabel = new Label(composite, SWT.NONE);
+		sytemHomeLabel.setText("&derby.system.home=");
+		systemHomeText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+		gd = new GridData();
+		gd.widthHint = convertWidthInCharsToPixels(16);
+		systemHomeText.setLayoutData(gd);
+	}
+
+	protected Composite createDefaultComposite(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		composite.setLayout(layout);
+	
+		GridData data = new GridData();
+		data.verticalAlignment = GridData.FILL;
+		data.horizontalAlignment = GridData.FILL;
+		composite.setLayoutData(data);
+	
+		return composite;
+	}
+
+	protected void fillControls() {
+		portText.setText(Integer.toString(dsProps.getPort()));
+		hostText.setText(dsProps.getHost());
+		systemHomeText.setText(dsProps.getSystemHome());
+		isServerRunning = checkServer();
+		// if the server is running do not allow
+		// editing of the settings
+		if (isServerRunning) {
+		    portText.setEditable(false);
+		    hostText.setEditable(false);
+		    systemHomeText.setEditable(false);
+		}
+	}
+	
+	protected boolean checkServer() {
+	    IProject proj = (IProject)getElement();
+	    boolean serverRunning = false;
+	    try {
+	        serverRunning = DerbyServerUtils.getDefault().getRunning(proj);
+	    }
+	    catch (CoreException ce) {
+	        Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
+	    }
+	    return serverRunning;
+	}
+
+	protected void getParams() {
+		dsProps = new DerbyProperties();		
+		try {
+			dsProps.setPort(Integer.parseInt(portText.getText()));
+		}
+		catch (NumberFormatException ne) {
+			// do nothing; use the default port number
+		}
+		dsProps.setHost(hostText.getText());
+		dsProps.setSystemHome(systemHomeText.getText());
+		
+		// if the server is running inform the user
+		// to stop the server before changing the settings
+		if (isServerRunning) {
+		    Shell shell = new Shell();
+			MessageDialog.openInformation(
+			shell,
+			CommonNames.PLUGIN_NAME,
+			Messages.SERVER_RUNNING );
+		}
+	}
+
+	protected GridData getSeperatorLabelGridData() {
+	
+	    GridData gridData = new GridData(GridData.BEGINNING |
+	                            GridData.HORIZONTAL_ALIGN_FILL |
+	                            GridData.GRAB_VERTICAL |
+	                            GridData.BEGINNING |
+	                            GridData.VERTICAL_ALIGN_BEGINNING |
+	                            GridData.VERTICAL_ALIGN_FILL) ;
+	    gridData.horizontalSpan = 2;
+	    gridData.grabExcessVerticalSpace  = false;
+	    gridData.grabExcessHorizontalSpace = true;
+	    return gridData;
+	
+	}
+
+	protected void performDefaults() {
+		dsProps = new DerbyProperties();
+		fillControls();
+	}
+	public boolean performOk() {
+		IProject proj = (IProject)getElement();
+		getParams();
+		try {
+		
+			dsProps.save(proj.getProject());
+		}
+		catch (CoreException ce) {
+			System.err.println(SelectionUtil.getStatusMessages(ce));
+			return false;
+		}
+		return true;
+	}
+
+	protected Control createContents(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		composite.setLayout(layout);
+		GridData data = new GridData(GridData.FILL);
+		data.grabExcessHorizontalSpace = true;
+		composite.setLayoutData(data);
+		addControls(composite);
+		IProject proj = (IProject)getElement();
+		try {
+			dsProps = new DerbyProperties(proj);
+			fillControls();
+		}
+		catch (CoreException ce) {
+			Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
+		}
+		return composite;
+	}	
+
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java Fri Oct 28 04:51:50 2005
@@ -1,223 +1,223 @@
-/*
-
-	Derby - Class org.apache.derby.ui.util.DerbyServerUtils
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.util;
-
-//import org.apache.ui.decorator.DerbyRunningDecorator;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.apache.derby.ui.common.CommonNames;
-import org.apache.derby.ui.common.Messages;
-import org.apache.derby.ui.decorate.DerbyIsRunningDecorator;
-import org.apache.derby.ui.properties.DerbyProperties;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.widgets.Shell;
-
-
-
-public class DerbyServerUtils {
-	
-	//Singleton Class
-	private static DerbyServerUtils dsUtils = new DerbyServerUtils();
-	private HashMap servers = new HashMap();
- 
-    private DerbyServerUtils() {
-        super();
-    }
-
-	public static DerbyServerUtils getDefault() {
-		if (dsUtils == null)
-			dsUtils = new DerbyServerUtils();
-		return dsUtils;
-	}
-	
-	// listener for DebugEvents, to know if a server was stopped by the client
-	// or died by itself
-	 
-	private IDebugEventSetListener listener = new IDebugEventSetListener() {
-	    public void handleDebugEvents(DebugEvent[] events) {
-	    	// type of event was a terminate...
-	    	if(events.length>0){
-				if (events[0].getKind() == DebugEvent.TERMINATE) {
-					Object source = events[0].getSource();
-					if (source instanceof IProcess) {
-						// check for Derby Network Servre process.
-						Object proj = servers.get(source);
-						if (proj != null) {
-							try {
-								//remove it from the hashmap, update the ui
-								servers.remove(source);
-								if(proj instanceof IJavaProject){
-									setRunning(((IJavaProject)proj).getProject(), null);
-								}else if(proj instanceof IProject){
-									setRunning((IProject)proj,null);
-								}
-							}
-							catch (CoreException ce) {
-								Logger.log("DerbyServerTracker.handleDebugEvents: "+ce, IStatus.ERROR);
-							}catch(Exception e){
-								Logger.log("DerbyServerTracker.handleDebugEvents: "+e, IStatus.ERROR);
-							}
-						}
-					}
-				}
-	    	}
-	    }
-	};
-
-	private IResourceChangeListener rlistener = new IResourceChangeListener() {
-	      public void resourceChanged(IResourceChangeEvent event){
-	         if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
-	         	try{
-	         		if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
-	         			if(getRunning(event.getResource().getProject())){
-	         				stopDerbyServer(event.getResource().getProject());
-	         			}
-	         		}
-	         	}catch(SWTException swe){
-	         		//The SWTException is thrown during the Shell creation
-	         		//Logger.log("Exception shutting down "+swe,IStatus.ERROR);
-	         		//e.printStackTrace();
-	         	}catch(Exception e){
-	         		Logger.log("Exception shutting down "+e,IStatus.ERROR);
-	         	}
-	         }
-	      }
-	   };
-
-	public boolean getRunning(IProject proj) throws CoreException {
-		Object value = proj.getSessionProperty(new QualifiedName(CommonNames.UI_PATH, CommonNames.ISRUNNING));
-		
-		return value != null;
-	}
-	
-	public void setRunning(IProject proj, Boolean value) throws CoreException {
-		try{
-			if (value != null && value.equals(Boolean.FALSE)){
-				value = null;
-			}
-			if(proj.isOpen()){
-				proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
-			}
-		}catch(Exception e){
-			Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);	
-			
-		}
-		DerbyIsRunningDecorator.performUpdateDecor(proj);
-	}
-
-	public void startDerbyServer( IProject proj) throws CoreException {
-		String args = CommonNames.START_DERBY_SERVER;
-		String vmargs="";
-		DerbyProperties dprop=new DerbyProperties(proj);
-		//Starts the server as a Java app
-		args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
-		
-		//Set Derby System Home from the Derby Properties
-		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
-			vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
-		}
-		String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
-		ILaunch launch = DerbyUtils.launch(proj, procName ,		
-		CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
-		IProcess ip=launch.getProcesses()[0];
-		//set a name to be seen in the Console list
-		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
-		
-		// saves the mapping between (server) process and project
-		//servers.put(launch.getProcesses()[0], proj);
-		servers.put(ip, proj);
-		// register a listener to listen, when this process is finished
-		DebugPlugin.getDefault().addDebugEventListener(listener);
-		//Add resource listener
-		IWorkspace workspace = ResourcesPlugin.getWorkspace();
-		
-		workspace.addResourceChangeListener(rlistener);
-		setRunning(proj, Boolean.TRUE);
-		Shell shell = new Shell();
-		MessageDialog.openInformation(
-			shell,
-			CommonNames.PLUGIN_NAME,
-			Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");
-
-	}
-
-	public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
-		String args = CommonNames.SHUTDOWN_DERBY_SERVER;
-		String vmargs="";
-		DerbyProperties dprop=new DerbyProperties(proj);
-		args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
-		
-		//	Set Derby System Home from the Derby Properties
-		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
-			vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
-		}
-		String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
-		
-		// starts the server as a Java app
-		ILaunch launch = DerbyUtils.launch(proj, procName,
-		CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
-		IProcess ip=launch.getProcesses()[0];
-		
-		//set a name to be seen in the Console list
-		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
-		
-		//update the objectState
-		setRunning(proj, Boolean.FALSE);
-		if(proj.isOpen()){
-			Shell shell = new Shell();
-			MessageDialog.openInformation(
-			shell,
-			CommonNames.PLUGIN_NAME,
-			Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
-		}
-	}
-	public void shutdownAllServers() {
-		Iterator it = servers.values().iterator();
-		while (it.hasNext()) {
-			try {
-				stopDerbyServer((IProject)it.next());
-			}
-			catch (Exception e) {
-				Logger.log("DerbyServerUtils.shutdownServers",IStatus.ERROR);
-				Logger.log(SelectionUtil.getStatusMessages(e), IStatus.ERROR);
-			}
-		}
-	}
-
-}
+/*
+
+	Derby - Class org.apache.derby.ui.util.DerbyServerUtils
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.util;
+
+//import org.apache.ui.decorator.DerbyRunningDecorator;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.decorate.DerbyIsRunningDecorator;
+import org.apache.derby.ui.properties.DerbyProperties;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Shell;
+
+
+
+public class DerbyServerUtils {
+	
+	//Singleton Class
+	private static DerbyServerUtils dsUtils = new DerbyServerUtils();
+	private HashMap servers = new HashMap();
+ 
+    private DerbyServerUtils() {
+        super();
+    }
+
+	public static DerbyServerUtils getDefault() {
+		if (dsUtils == null)
+			dsUtils = new DerbyServerUtils();
+		return dsUtils;
+	}
+	
+	// listener for DebugEvents, to know if a server was stopped by the client
+	// or died by itself
+	 
+	private IDebugEventSetListener listener = new IDebugEventSetListener() {
+	    public void handleDebugEvents(DebugEvent[] events) {
+	    	// type of event was a terminate...
+	    	if(events.length>0){
+				if (events[0].getKind() == DebugEvent.TERMINATE) {
+					Object source = events[0].getSource();
+					if (source instanceof IProcess) {
+						// check for Derby Network Servre process.
+						Object proj = servers.get(source);
+						if (proj != null) {
+							try {
+								//remove it from the hashmap, update the ui
+								servers.remove(source);
+								if(proj instanceof IJavaProject){
+									setRunning(((IJavaProject)proj).getProject(), null);
+								}else if(proj instanceof IProject){
+									setRunning((IProject)proj,null);
+								}
+							}
+							catch (CoreException ce) {
+								Logger.log("DerbyServerTracker.handleDebugEvents: "+ce, IStatus.ERROR);
+							}catch(Exception e){
+								Logger.log("DerbyServerTracker.handleDebugEvents: "+e, IStatus.ERROR);
+							}
+						}
+					}
+				}
+	    	}
+	    }
+	};
+
+	private IResourceChangeListener rlistener = new IResourceChangeListener() {
+	      public void resourceChanged(IResourceChangeEvent event){
+	         if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
+	         	try{
+	         		if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
+	         			if(getRunning(event.getResource().getProject())){
+	         				stopDerbyServer(event.getResource().getProject());
+	         			}
+	         		}
+	         	}catch(SWTException swe){
+	         		//The SWTException is thrown during the Shell creation
+	         		//Logger.log("Exception shutting down "+swe,IStatus.ERROR);
+	         		//e.printStackTrace();
+	         	}catch(Exception e){
+	         		Logger.log("Exception shutting down "+e,IStatus.ERROR);
+	         	}
+	         }
+	      }
+	   };
+
+	public boolean getRunning(IProject proj) throws CoreException {
+		Object value = proj.getSessionProperty(new QualifiedName(CommonNames.UI_PATH, CommonNames.ISRUNNING));
+		
+		return value != null;
+	}
+	
+	public void setRunning(IProject proj, Boolean value) throws CoreException {
+		try{
+			if (value != null && value.equals(Boolean.FALSE)){
+				value = null;
+			}
+			if(proj.isOpen()){
+				proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
+			}
+		}catch(Exception e){
+			Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);	
+			
+		}
+		DerbyIsRunningDecorator.performUpdateDecor(proj);
+	}
+
+	public void startDerbyServer( IProject proj) throws CoreException {
+		String args = CommonNames.START_DERBY_SERVER;
+		String vmargs="";
+		DerbyProperties dprop=new DerbyProperties(proj);
+		//Starts the server as a Java app
+		args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
+		
+		//Set Derby System Home from the Derby Properties
+		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
+			vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
+		}
+		String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
+		ILaunch launch = DerbyUtils.launch(proj, procName ,		
+		CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
+		IProcess ip=launch.getProcesses()[0];
+		//set a name to be seen in the Console list
+		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+		
+		// saves the mapping between (server) process and project
+		//servers.put(launch.getProcesses()[0], proj);
+		servers.put(ip, proj);
+		// register a listener to listen, when this process is finished
+		DebugPlugin.getDefault().addDebugEventListener(listener);
+		//Add resource listener
+		IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		
+		workspace.addResourceChangeListener(rlistener);
+		setRunning(proj, Boolean.TRUE);
+		Shell shell = new Shell();
+		MessageDialog.openInformation(
+			shell,
+			CommonNames.PLUGIN_NAME,
+			Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");
+
+	}
+
+	public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
+		String args = CommonNames.SHUTDOWN_DERBY_SERVER;
+		String vmargs="";
+		DerbyProperties dprop=new DerbyProperties(proj);
+		args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
+		
+		//	Set Derby System Home from the Derby Properties
+		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
+			vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
+		}
+		String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
+		
+		// starts the server as a Java app
+		ILaunch launch = DerbyUtils.launch(proj, procName,
+		CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
+		IProcess ip=launch.getProcesses()[0];
+		
+		//set a name to be seen in the Console list
+		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+		
+		//update the objectState
+		setRunning(proj, Boolean.FALSE);
+		if(proj.isOpen()){
+			Shell shell = new Shell();
+			MessageDialog.openInformation(
+			shell,
+			CommonNames.PLUGIN_NAME,
+			Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
+		}
+	}
+	public void shutdownAllServers() {
+		Iterator it = servers.values().iterator();
+		while (it.hasNext()) {
+			try {
+				stopDerbyServer((IProject)it.next());
+			}
+			catch (Exception e) {
+				Logger.log("DerbyServerUtils.shutdownServers",IStatus.ERROR);
+				Logger.log(SelectionUtil.getStatusMessages(e), IStatus.ERROR);
+			}
+		}
+	}
+
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyUtils.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyUtils.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyUtils.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyUtils.java Fri Oct 28 04:51:50 2005
@@ -1,305 +1,305 @@
-/*
-
-	Derby - Class org.apache.derby.ui.util.DerbyUtils
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.util;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.derby.ui.DerbyPlugin;
-import org.apache.derby.ui.common.CommonNames;
-import org.apache.derby.ui.properties.DerbyProperties;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-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.Platform;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-
-
-public class DerbyUtils {
-	
-	private static ManifestElement[] getElements(String bundleName) throws BundleException {
-		String requires = (String)Platform.getBundle(bundleName).getHeaders().get(Constants.BUNDLE_CLASSPATH);
-		return ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
-	}
-	public static IClasspathEntry[] addDerbyJars(IClasspathEntry[] rawCP) throws Exception{
-		
-		IClasspathEntry[] newRawCP= null;
-		try{
-			//New OSGI way
-			ManifestElement[] elements_core, elements_ui;
-			elements_core = getElements(CommonNames.CORE_PATH);
-			elements_ui=getElements(CommonNames.UI_PATH);
-			
-			Bundle bundle=Platform.getBundle(CommonNames.CORE_PATH);
-			URL pluginURL = bundle.getEntry("/");
-			URL jarURL=null;
-			URL localURL=null;
-
-			newRawCP=new IClasspathEntry[rawCP.length + (elements_core.length) + (elements_ui.length-1)];
-			System.arraycopy(rawCP, 0, newRawCP, 0, rawCP.length);
-			
-			//Add the CORE jars
-			int oldLength=rawCP.length;
-			 for(int i=0;i<elements_core.length;i++){
-				jarURL= new URL(pluginURL,elements_core[i].getValue());
-				localURL=Platform.asLocalURL(jarURL);
-				newRawCP[oldLength+i]=JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null);
-				
-			}
-			 // Add the UI jars
-			bundle=Platform.getBundle(CommonNames.UI_PATH);
-			pluginURL = bundle.getEntry("/");
-			oldLength=oldLength+elements_core.length -1; 
-			for(int i=0;i<elements_ui.length;i++){
-				if(!(elements_ui[i].getValue().toLowerCase().equals("ui.jar"))){
-					jarURL= new URL(pluginURL,elements_ui[i].getValue());
-					localURL=Platform.asLocalURL(jarURL);
-					newRawCP[oldLength+i]=JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null);
-				}
-			}					
-			return newRawCP;
-		}catch(Exception e){
-			throw e;
-		}
-		
-	}
-	public static IClasspathEntry[] removeDerbyJars(IClasspathEntry[] rawCP) throws Exception{
-		ArrayList arrL=new ArrayList();
-		for (int i=0;i<rawCP.length;i++){
-			arrL.add(rawCP[i]);
-		}
-		IClasspathEntry[] newRawCP= null;
-		try{
-			ManifestElement[] elements_core, elements_ui;
-			elements_core = getElements(CommonNames.CORE_PATH);
-			elements_ui=getElements(CommonNames.UI_PATH);
-			
-			Bundle bundle;
-			URL pluginURL,jarURL,localURL;
-
-			boolean add;
-			IClasspathEntry icp=null;
-			for (int j=0;j<arrL.size();j++){
-				bundle=Platform.getBundle(CommonNames.CORE_PATH);
-				pluginURL = bundle.getEntry("/");
-				add=true;
-				icp=(IClasspathEntry)arrL.get(j);
-				//remove 'core' jars
-				for (int i=0;i<elements_core.length;i++){
-					jarURL= new URL(pluginURL,elements_core[i].getValue());
-					localURL=Platform.asLocalURL(jarURL);
-					if(((icp).equals(JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null)))||
-							icp.getPath().toString().toLowerCase().endsWith("derby.jar")||
-							icp.getPath().toString().toLowerCase().endsWith("derbynet.jar")||
-							icp.getPath().toString().toLowerCase().endsWith("derbyclient.jar")||
-							icp.getPath().toString().toLowerCase().endsWith("derbytools.jar")){
-						add=false;
-					}
-				}
-				if(!add){
-					arrL.remove(j);
-					j=j-1;
-				}
-				//REMOVE 'ui' jars
-				bundle=Platform.getBundle(CommonNames.UI_PATH);
-				pluginURL = bundle.getEntry("/");
-				add=true;
-				
-				for (int i=0;i<elements_ui.length;i++){
-					if(!(elements_ui[i].getValue().toLowerCase().equals("ui.jar"))){
-						jarURL= new URL(pluginURL,elements_ui[i].getValue());
-						localURL=Platform.asLocalURL(jarURL);					
-						if((icp).equals(JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null))){
-							add=false;
-						}
-					}
-				}
-				if(!add){
-					arrL.remove(j);
-					j=j-1;
-				}
-			}
-			newRawCP=new IClasspathEntry[arrL.size()];
-			for (int i=0;i<arrL.size();i++){
-				newRawCP[i]=(IClasspathEntry)arrL.get(i);
-			}
-			return newRawCP;
-		}catch(Exception e){
-			e.printStackTrace();
-			//return rawCP;
-			throw e;
-		}
-		
-	}
-	protected static ILaunch launch(IProject proj, String name, String mainClass, String args, String vmargs, String app) throws CoreException {	
-		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
-	
-		ILaunchConfigurationType type=null;
-		if(app.equalsIgnoreCase(CommonNames.START_DERBY_SERVER)){
-			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.startDerbyServerLaunchConfigurationType");
-			type= manager.getLaunchConfigurationType(CommonNames.START_SERVER_LAUNCH_CONFIG_TYPE);
-		}else if(app.equalsIgnoreCase(CommonNames.SHUTDOWN_DERBY_SERVER)){
-			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.stopDerbyServerLaunchConfigurationType");
-			type= manager.getLaunchConfigurationType(CommonNames.STOP_SERVER_LAUNCH_CONFIG_TYPE);
-		}else if(app.equalsIgnoreCase(CommonNames.IJ)){
-			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.ijDerbyLaunchConfigurationType");
-			type= manager.getLaunchConfigurationType(CommonNames.IJ_LAUNCH_CONFIG_TYPE);
-		}else if(app.equalsIgnoreCase(CommonNames.SYSINFO)){
-			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType");
-			type= manager.getLaunchConfigurationType(CommonNames.SYSINFO_LAUNCH_CONFIG_TYPE);
-		}else{
-			type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-		}
-		ILaunchConfiguration config = null;
-		// if the configuration already exists, delete it
-		ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
-		for (int i = 0; i < configurations.length; i++) {
-			if (configurations[i].getName().equals(name))
-				configurations[i].delete();
-		}
-		// else create a new one
-		if (config == null) {
-			ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
-				proj.getProject().getName());
-			// current directory should be the project root
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
-				proj.getProject().getLocation().toString());
-			// use the suplied args
-			if((vmargs!=null)&&!(vmargs.equals(""))){
-				wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmargs);
-			}
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
-				mainClass);
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
-				args);
-			// saves the new config
-			config = wc.doSave();
-		}
-		ILaunch launch=config.launch(ILaunchManager.RUN_MODE, null);
-		config.delete();
-		return launch;
-	}
-	public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException {	
-
-		String launchType="";
-		String args="";
-		
-		//the above some times throws wrong 'create=true|false' errors
-		String vmargs="";
-		DerbyProperties dprop=new DerbyProperties(currentProject);
-		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
-			vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
-		}
-		
-		if(currentScript!=null){
-			launchType=CommonNames.SQL_SCRIPT;
-			
-			//Preferable to use the full String with quotes to take care of spaces 
-			//in file names
-			args="\""+currentScript.getLocation().toOSString()+"\"";
-		}else{
-			launchType=CommonNames.IJ;
-			args="";	
-		}
-		
-		ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ);
-		IProcess ip=launch.getProcesses()[0];
-		String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args;
-		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
-	}
-	public static void runSysInfo(IProject currentProject) throws CoreException {	
-		String args="";
-		ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO);
-		IProcess ip=launch.getProcesses()[0];
-		String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO;
-		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
-	}
-	//another launch mechanism 																	
-	public void launch() throws CoreException{
-		DerbyPlugin plugin = DerbyPlugin.getDefault();
-
-		// constructs a classpath from the default JRE...
-		IPath systemLibs = new Path(JavaRuntime.JRE_CONTAINER);
-		IRuntimeClasspathEntry systemLibsEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
-			systemLibs, IRuntimeClasspathEntry.STANDARD_CLASSES);
-		systemLibsEntry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
-		//include org.apache.derby.core plugin
-		IRuntimeClasspathEntry derbyCPEntry = null;
-		List classpath = new ArrayList();
-		classpath.add(systemLibsEntry.getMemento());
-		
-		try {
-			ManifestElement[] elements_core, elements_ui;
-			elements_core = getElements(CommonNames.CORE_PATH);
-			elements_ui=getElements(CommonNames.UI_PATH);
-			
-			Bundle bundle;
-			URL pluginURL,jarURL,localURL;
-			bundle=Platform.getBundle(CommonNames.CORE_PATH);
-			pluginURL = bundle.getEntry("/");
-			for(int i=0;i<elements_core.length;i++){
-				if(!elements_core[i].getValue().toLowerCase().endsWith("derbynet.jar")){
-					jarURL= new URL(pluginURL,elements_core[i].getValue());
-					localURL=Platform.asLocalURL(jarURL);
-					derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
-					derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-					classpath.add(derbyCPEntry.getMemento());
-				}
-			}
-			bundle=Platform.getBundle(CommonNames.CORE_PATH);
-			pluginURL = bundle.getEntry("/");
-			for(int i=0;i<elements_ui.length;i++){
-				if(!elements_ui[i].getValue().toLowerCase().equals("ui.jar")){
-					jarURL= new URL(pluginURL,elements_ui[i].getValue());
-					localURL=Platform.asLocalURL(jarURL);
-					derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
-					derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-					classpath.add(derbyCPEntry.getMemento());
-				}
-			}
-		}
-		catch(Exception e) {
-			e.printStackTrace();
-			Logger.log("Error in launch() "+e,IStatus.ERROR);
-		}
-	
-	}
-}
+/*
+
+	Derby - Class org.apache.derby.ui.util.DerbyUtils
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.util;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.derby.ui.DerbyPlugin;
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.properties.DerbyProperties;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.osgi.util.ManifestElement;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+
+
+public class DerbyUtils {
+	
+	private static ManifestElement[] getElements(String bundleName) throws BundleException {
+		String requires = (String)Platform.getBundle(bundleName).getHeaders().get(Constants.BUNDLE_CLASSPATH);
+		return ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
+	}
+	public static IClasspathEntry[] addDerbyJars(IClasspathEntry[] rawCP) throws Exception{
+		
+		IClasspathEntry[] newRawCP= null;
+		try{
+			//New OSGI way
+			ManifestElement[] elements_core, elements_ui;
+			elements_core = getElements(CommonNames.CORE_PATH);
+			elements_ui=getElements(CommonNames.UI_PATH);
+			
+			Bundle bundle=Platform.getBundle(CommonNames.CORE_PATH);
+			URL pluginURL = bundle.getEntry("/");
+			URL jarURL=null;
+			URL localURL=null;
+
+			newRawCP=new IClasspathEntry[rawCP.length + (elements_core.length) + (elements_ui.length-1)];
+			System.arraycopy(rawCP, 0, newRawCP, 0, rawCP.length);
+			
+			//Add the CORE jars
+			int oldLength=rawCP.length;
+			 for(int i=0;i<elements_core.length;i++){
+				jarURL= new URL(pluginURL,elements_core[i].getValue());
+				localURL=Platform.asLocalURL(jarURL);
+				newRawCP[oldLength+i]=JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null);
+				
+			}
+			 // Add the UI jars
+			bundle=Platform.getBundle(CommonNames.UI_PATH);
+			pluginURL = bundle.getEntry("/");
+			oldLength=oldLength+elements_core.length -1; 
+			for(int i=0;i<elements_ui.length;i++){
+				if(!(elements_ui[i].getValue().toLowerCase().equals("ui.jar"))){
+					jarURL= new URL(pluginURL,elements_ui[i].getValue());
+					localURL=Platform.asLocalURL(jarURL);
+					newRawCP[oldLength+i]=JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null);
+				}
+			}					
+			return newRawCP;
+		}catch(Exception e){
+			throw e;
+		}
+		
+	}
+	public static IClasspathEntry[] removeDerbyJars(IClasspathEntry[] rawCP) throws Exception{
+		ArrayList arrL=new ArrayList();
+		for (int i=0;i<rawCP.length;i++){
+			arrL.add(rawCP[i]);
+		}
+		IClasspathEntry[] newRawCP= null;
+		try{
+			ManifestElement[] elements_core, elements_ui;
+			elements_core = getElements(CommonNames.CORE_PATH);
+			elements_ui=getElements(CommonNames.UI_PATH);
+			
+			Bundle bundle;
+			URL pluginURL,jarURL,localURL;
+
+			boolean add;
+			IClasspathEntry icp=null;
+			for (int j=0;j<arrL.size();j++){
+				bundle=Platform.getBundle(CommonNames.CORE_PATH);
+				pluginURL = bundle.getEntry("/");
+				add=true;
+				icp=(IClasspathEntry)arrL.get(j);
+				//remove 'core' jars
+				for (int i=0;i<elements_core.length;i++){
+					jarURL= new URL(pluginURL,elements_core[i].getValue());
+					localURL=Platform.asLocalURL(jarURL);
+					if(((icp).equals(JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null)))||
+							icp.getPath().toString().toLowerCase().endsWith("derby.jar")||
+							icp.getPath().toString().toLowerCase().endsWith("derbynet.jar")||
+							icp.getPath().toString().toLowerCase().endsWith("derbyclient.jar")||
+							icp.getPath().toString().toLowerCase().endsWith("derbytools.jar")){
+						add=false;
+					}
+				}
+				if(!add){
+					arrL.remove(j);
+					j=j-1;
+				}
+				//REMOVE 'ui' jars
+				bundle=Platform.getBundle(CommonNames.UI_PATH);
+				pluginURL = bundle.getEntry("/");
+				add=true;
+				
+				for (int i=0;i<elements_ui.length;i++){
+					if(!(elements_ui[i].getValue().toLowerCase().equals("ui.jar"))){
+						jarURL= new URL(pluginURL,elements_ui[i].getValue());
+						localURL=Platform.asLocalURL(jarURL);					
+						if((icp).equals(JavaCore.newLibraryEntry(new Path(localURL.getPath()), null, null))){
+							add=false;
+						}
+					}
+				}
+				if(!add){
+					arrL.remove(j);
+					j=j-1;
+				}
+			}
+			newRawCP=new IClasspathEntry[arrL.size()];
+			for (int i=0;i<arrL.size();i++){
+				newRawCP[i]=(IClasspathEntry)arrL.get(i);
+			}
+			return newRawCP;
+		}catch(Exception e){
+			e.printStackTrace();
+			//return rawCP;
+			throw e;
+		}
+		
+	}
+	protected static ILaunch launch(IProject proj, String name, String mainClass, String args, String vmargs, String app) throws CoreException {	
+		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+	
+		ILaunchConfigurationType type=null;
+		if(app.equalsIgnoreCase(CommonNames.START_DERBY_SERVER)){
+			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.startDerbyServerLaunchConfigurationType");
+			type= manager.getLaunchConfigurationType(CommonNames.START_SERVER_LAUNCH_CONFIG_TYPE);
+		}else if(app.equalsIgnoreCase(CommonNames.SHUTDOWN_DERBY_SERVER)){
+			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.stopDerbyServerLaunchConfigurationType");
+			type= manager.getLaunchConfigurationType(CommonNames.STOP_SERVER_LAUNCH_CONFIG_TYPE);
+		}else if(app.equalsIgnoreCase(CommonNames.IJ)){
+			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.ijDerbyLaunchConfigurationType");
+			type= manager.getLaunchConfigurationType(CommonNames.IJ_LAUNCH_CONFIG_TYPE);
+		}else if(app.equalsIgnoreCase(CommonNames.SYSINFO)){
+			//type= manager.getLaunchConfigurationType("org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType");
+			type= manager.getLaunchConfigurationType(CommonNames.SYSINFO_LAUNCH_CONFIG_TYPE);
+		}else{
+			type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+		}
+		ILaunchConfiguration config = null;
+		// if the configuration already exists, delete it
+		ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
+		for (int i = 0; i < configurations.length; i++) {
+			if (configurations[i].getName().equals(name))
+				configurations[i].delete();
+		}
+		// else create a new one
+		if (config == null) {
+			ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
+			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+				proj.getProject().getName());
+			// current directory should be the project root
+			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+				proj.getProject().getLocation().toString());
+			// use the suplied args
+			if((vmargs!=null)&&!(vmargs.equals(""))){
+				wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmargs);
+			}
+			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
+				mainClass);
+			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+				args);
+			// saves the new config
+			config = wc.doSave();
+		}
+		ILaunch launch=config.launch(ILaunchManager.RUN_MODE, null);
+		config.delete();
+		return launch;
+	}
+	public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException {	
+
+		String launchType="";
+		String args="";
+		
+		//the above some times throws wrong 'create=true|false' errors
+		String vmargs="";
+		DerbyProperties dprop=new DerbyProperties(currentProject);
+		if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
+			vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
+		}
+		
+		if(currentScript!=null){
+			launchType=CommonNames.SQL_SCRIPT;
+			
+			//Preferable to use the full String with quotes to take care of spaces 
+			//in file names
+			args="\""+currentScript.getLocation().toOSString()+"\"";
+		}else{
+			launchType=CommonNames.IJ;
+			args="";	
+		}
+		
+		ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ);
+		IProcess ip=launch.getProcesses()[0];
+		String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args;
+		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+	}
+	public static void runSysInfo(IProject currentProject) throws CoreException {	
+		String args="";
+		ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO);
+		IProcess ip=launch.getProcesses()[0];
+		String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO;
+		ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+	}
+	//another launch mechanism 																	
+	public void launch() throws CoreException{
+		DerbyPlugin plugin = DerbyPlugin.getDefault();
+
+		// constructs a classpath from the default JRE...
+		IPath systemLibs = new Path(JavaRuntime.JRE_CONTAINER);
+		IRuntimeClasspathEntry systemLibsEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
+			systemLibs, IRuntimeClasspathEntry.STANDARD_CLASSES);
+		systemLibsEntry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
+		//include org.apache.derby.core plugin
+		IRuntimeClasspathEntry derbyCPEntry = null;
+		List classpath = new ArrayList();
+		classpath.add(systemLibsEntry.getMemento());
+		
+		try {
+			ManifestElement[] elements_core, elements_ui;
+			elements_core = getElements(CommonNames.CORE_PATH);
+			elements_ui=getElements(CommonNames.UI_PATH);
+			
+			Bundle bundle;
+			URL pluginURL,jarURL,localURL;
+			bundle=Platform.getBundle(CommonNames.CORE_PATH);
+			pluginURL = bundle.getEntry("/");
+			for(int i=0;i<elements_core.length;i++){
+				if(!elements_core[i].getValue().toLowerCase().endsWith("derbynet.jar")){
+					jarURL= new URL(pluginURL,elements_core[i].getValue());
+					localURL=Platform.asLocalURL(jarURL);
+					derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
+					derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+					classpath.add(derbyCPEntry.getMemento());
+				}
+			}
+			bundle=Platform.getBundle(CommonNames.CORE_PATH);
+			pluginURL = bundle.getEntry("/");
+			for(int i=0;i<elements_ui.length;i++){
+				if(!elements_ui[i].getValue().toLowerCase().equals("ui.jar")){
+					jarURL= new URL(pluginURL,elements_ui[i].getValue());
+					localURL=Platform.asLocalURL(jarURL);
+					derbyCPEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(localURL.getPath()));
+					derbyCPEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+					classpath.add(derbyCPEntry.getMemento());
+				}
+			}
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+			Logger.log("Error in launch() "+e,IStatus.ERROR);
+		}
+	
+	}
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/Logger.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/Logger.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/Logger.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/Logger.java Fri Oct 28 04:51:50 2005
@@ -1,35 +1,35 @@
-/*
-
-	Derby - Class org.apache.derby.ui.util.Logger
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.util;
-
-import org.apache.derby.ui.DerbyPlugin;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.Status;
-
-
-public class Logger {
-	static public void log(String msg, int msgType) {
-		ILog log = DerbyPlugin.getDefault().getLog();
-		Status status = new Status(msgType, DerbyPlugin.getDefault().getBundle().getSymbolicName(), msgType, msg + "\n", null);
-		log.log(status);
-		
-	}
-}
+/*
+
+	Derby - Class org.apache.derby.ui.util.Logger
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.util;
+
+import org.apache.derby.ui.DerbyPlugin;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.Status;
+
+
+public class Logger {
+	static public void log(String msg, int msgType) {
+		ILog log = DerbyPlugin.getDefault().getLog();
+		Status status = new Status(msgType, DerbyPlugin.getDefault().getBundle().getSymbolicName(), msgType, msg + "\n", null);
+		log.log(status);
+		
+	}
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/Logger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/SelectionUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/SelectionUtil.java?rev=329187&r1=329186&r2=329187&view=diff
==============================================================================
--- db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/SelectionUtil.java (original)
+++ db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/SelectionUtil.java Fri Oct 28 04:51:50 2005
@@ -1,73 +1,73 @@
-/*
-
-	Derby - Class org.apache.derby.ui.util.SelectionUtil
-	
-	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	   http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-
-*/
-
-package org.apache.derby.ui.util;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-
-public class SelectionUtil {
-    public static IProject findSelectedProject(ISelection selection) {
-    	IProject currentProject = null;
-    	if (selection != null) {
-    		if (selection instanceof IStructuredSelection) {
-    			IStructuredSelection ss = (IStructuredSelection)selection;
-    			Object obj = ss.getFirstElement();
-    			if (obj instanceof IProject) {
-    				currentProject = (IProject)obj;
-    			}
-    		}
-    	}
-    	return currentProject;
-    }
-	
-     public static IJavaProject findSelectedJavaProject(ISelection selection) {
-    	IJavaProject currentProject = null;
-    	if (selection != null) {
-    		if (selection instanceof IStructuredSelection) {
-    			IStructuredSelection ss = (IStructuredSelection)selection;
-    			Object obj = ss.getFirstElement();
-    			if (obj instanceof IJavaProject) {
-    				currentProject = (IJavaProject)obj;
-    			}
-    		}
-    	}
-    	return currentProject;
-    }
-    
-    public static String getStatusMessages(Exception e) {
-    	String msg = e.getMessage();
-    	if (e instanceof CoreException) {
-    		CoreException ce = (CoreException)e;	
-			IStatus status = ce.getStatus();
-			IStatus[] children = status.getChildren();
-			for (int i = 0; i < children.length; i++)
-				msg += "\n" + children[i].getMessage();
-			System.err.println(msg);
-			ce.printStackTrace(System.err);
-    	}
-    	return msg;
-    }
-}
+/*
+
+	Derby - Class org.apache.derby.ui.util.SelectionUtil
+	
+	Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+
+*/
+
+package org.apache.derby.ui.util;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+
+public class SelectionUtil {
+    public static IProject findSelectedProject(ISelection selection) {
+    	IProject currentProject = null;
+    	if (selection != null) {
+    		if (selection instanceof IStructuredSelection) {
+    			IStructuredSelection ss = (IStructuredSelection)selection;
+    			Object obj = ss.getFirstElement();
+    			if (obj instanceof IProject) {
+    				currentProject = (IProject)obj;
+    			}
+    		}
+    	}
+    	return currentProject;
+    }
+	
+     public static IJavaProject findSelectedJavaProject(ISelection selection) {
+    	IJavaProject currentProject = null;
+    	if (selection != null) {
+    		if (selection instanceof IStructuredSelection) {
+    			IStructuredSelection ss = (IStructuredSelection)selection;
+    			Object obj = ss.getFirstElement();
+    			if (obj instanceof IJavaProject) {
+    				currentProject = (IJavaProject)obj;
+    			}
+    		}
+    	}
+    	return currentProject;
+    }
+    
+    public static String getStatusMessages(Exception e) {
+    	String msg = e.getMessage();
+    	if (e instanceof CoreException) {
+    		CoreException ce = (CoreException)e;	
+			IStatus status = ce.getStatus();
+			IStatus[] children = status.getChildren();
+			for (int i = 0; i < children.length; i++)
+				msg += "\n" + children[i].getMessage();
+			System.err.println(msg);
+			ce.printStackTrace(System.err);
+    	}
+    	return msg;
+    }
+}

Propchange: db/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/SelectionUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: db/derby/code/trunk/tools/ant/properties/compilepath.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/defaultcompiler.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/dirs.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/extrapath.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/jikes.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/modern.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/release.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/sanefalse.properties
            ('svn:executable' removed)

Propchange: db/derby/code/trunk/tools/ant/properties/sanetrue.properties
            ('svn:executable' removed)



Mime
View raw message