[390603] Publish before start servers synchronization problem [390693] Finish button not disabled when no entries selected [390696] New Server wizard doesn't block user from creating server with existing name [390698] Runtime search function results in duplicate entries on Server Runtime Environments preferences page [390702] ServerToolTip too aggressive at opening tooltips [390705] ServerToolTip escape on focussed tooltip not working perfectly
diff --git a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html index 7d8a423..2dc1278 100644 --- a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html +++ b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
@@ -15,6 +15,5 @@ <h3>Plugin(s) replaced:</h3> <ul><li>org.eclipse.wst.server.core</li></ul> <p>Bug <a href='https://bugs.eclipse.org/377845'>377845</a>. The server timeout timer begins at the incorrect time (port to 3.3.2 patches)</p> - - +<p>Bug <a href='https://bugs.eclipse.org/390603'>390603</a>. Publish before start servers synchronization problem</p> </body></html> \ No newline at end of file
diff --git a/features/org.eclipse.wst.server_core.feature.patch/feature.properties b/features/org.eclipse.wst.server_core.feature.patch/feature.properties index e9c9606..c362362 100644 --- a/features/org.eclipse.wst.server_core.feature.patch/feature.properties +++ b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
@@ -28,6 +28,7 @@ Contains fixes described in the following bugzilla(s):\n\ \n\ Bug https://bugs.eclipse.org/377845 The server timeout timer begins at the incorrect time (port to 3.3.2 patches)\n\ +Bug https://bugs.eclipse.org/390603 Publish before start servers synchronization problem\n\ \n\ # "copyright" property - text of the "Feature Update Copyright" copyright=\
diff --git a/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html b/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html index bc9f758..c447d31 100644 --- a/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html +++ b/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html
@@ -23,5 +23,9 @@ <p>Bug <a href='https://bugs.eclipse.org/375507'>375507</a>. deleting a server with a dirty server editor</p> <p>Bug <a href='https://bugs.eclipse.org/377000'>377000</a>. Run on Server Wizard server name and status cannot be re-sized (target for 3.3 patches)</p> <p>Bug <a href='https://bugs.eclipse.org/378172'>378172</a>. Server view tooltip not colour accessible (port for 3.3.2 patches)</p> - +<p>Bug <a href='https://bugs.eclipse.org/390693'>390693</a>. Finish button not disabled when no entries selected</p> +<p>Bug <a href='https://bugs.eclipse.org/390696'>390696</a>. New Server wizard doesn't block user from creating server with existing name</p> +<p>Bug <a href='https://bugs.eclipse.org/390698'>390698</a>. Runtime search function results in duplicate entries on Server Runtime Environments preferences page</p> +<p>Bug <a href='https://bugs.eclipse.org/390702'>390702</a>. ServerToolTip too aggressive at opening tooltips</p> +<p>Bug <a href='https://bugs.eclipse.org/390705'>390705</a>. ServerToolTip escape on focussed tooltip not working perfectly</p> </body></html> \ No newline at end of file
diff --git a/features/org.eclipse.wst.server_ui.feature.patch/feature.properties b/features/org.eclipse.wst.server_ui.feature.patch/feature.properties index 183b17c..3b0b9dc 100644 --- a/features/org.eclipse.wst.server_ui.feature.patch/feature.properties +++ b/features/org.eclipse.wst.server_ui.feature.patch/feature.properties
@@ -35,6 +35,11 @@ Bug https://bugs.eclipse.org/375507 deleting a server with a dirty server editor\n\ Bug https://bugs.eclipse.org/377000 Run on Server Wizard server name and status cannot be re-sized (target for 3.3 patches)\n\ Bug https://bugs.eclipse.org/378172 Server view tooltip not colour accessible (port for 3.3.2 patches)\n\ +Bug https://bugs.eclipse.org/390693 Finish button not disabled when no entries selected\n\ +Bug https://bugs.eclipse.org/390696 New Server wizard doesn't block user from creating server with existing name\n\ +Bug https://bugs.eclipse.org/390698 Runtime search function results in duplicate entries on Server Runtime Environments preferences page\n\ +Bug https://bugs.eclipse.org/390702 ServerToolTip too aggressive at opening tooltips \n\ +Bug https://bugs.eclipse.org/390705 ServerToolTip escape on focussed tooltip not working perfectly\n\ \n\ # "copyright" property - text of the "Feature Update Copyright" copyright=\
diff --git a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF index 826b8ba..7898880 100644 --- a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.server.core; singleton:=true -Bundle-Version: 1.1.305.qualifier +Bundle-Version: 1.1.306.qualifier Bundle-Activator: org.eclipse.wst.server.core.internal.ServerPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java index 23c2494..df84497 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -375,11 +375,18 @@ public RestartJob(String launchMode) { super(NLS.bind(Messages.jobRestarting, Server.this.getName())); this.launchMode = launchMode; - setRule(Server.this); } protected IStatus run(IProgressMonitor monitor) { - return restartImpl(launchMode, monitor); + try{ + // Do begin rule in here instead of setRule on constructor to prevent deadlock + // on the default restart operation during the join() in the StartJob. + Job.getJobManager().beginRule(Server.this, monitor); + return restartImpl(launchMode, monitor); + } + finally{ + Job.getJobManager().endRule(Server.this); + } } } @@ -1891,7 +1898,7 @@ job.schedule(); } - protected IStatus publishBeforeStart(IProgressMonitor monitor, boolean synchronous){ + protected IStatus publishBeforeStart(IProgressMonitor monitor, final StartJob startJob, final boolean synchronous){ // check if we need to publish byte pub = StartJob.PUBLISH_NONE; @@ -1910,22 +1917,53 @@ pubJob.addJobChangeListener(new JobChangeAdapter(){ public void done(IJobChangeEvent event) { IStatus status = event.getResult(); - if (status != null && status.getSeverity() == IStatus.ERROR) - pubStatus[0] = status; + if (status != null && status.getSeverity() == IStatus.ERROR) { + pubStatus[0] = status; + if (Trace.INFO) { + Trace.trace(Trace.STRING_INFO, + "Skipping server start job schedule since the server publish failed on a publish before start server."); + } + } else { + if (Trace.INFO) { + Trace.trace(Trace.STRING_INFO, + "Scheduling server start job after successful publish."); + } + // Schedule the server start job since the publish operation is completed successfully. + startJob.schedule(); + + try { + if (synchronous) + startJob.join(); + } catch (InterruptedException e) { + if (Trace.WARNING) { + Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + } + } + } } }); - pubJob.schedule(); - try{ + try { if (synchronous) pubJob.join(); - - } - catch (InterruptedException ie){ + } catch (InterruptedException ie) { return Status.CANCEL_STATUS; } + } else { + // Schedule the server start since a publish is not needed so + // Schedule the server start job since the publish operation is completed successfully. + startJob.schedule(); + + try { + if (synchronous) + startJob.join(); + } catch (InterruptedException e) { + if (Trace.WARNING) { + Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + } + } } return pubStatus[0]; } @@ -1989,18 +2027,10 @@ // make sure that the delegate is loaded and the server state is correct loadAdapter(ServerBehaviourDelegate.class, null); - IStatus status = publishBeforeStart(monitor,false); - - if (status != null && status.getSeverity() == IStatus.ERROR){ - if (Trace.FINEST) { - Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); - } - return; - } - StartJob startJob = new StartJob(mode2); // 287442 - only do publish after start if the server start is successful. final IProgressMonitor monitor2 = monitor; + final boolean synchronous = false; startJob.addJobChangeListener(new JobChangeAdapter() { public void done(IJobChangeEvent event) { IStatus resultStatus = event.getResult(); @@ -2010,11 +2040,31 @@ "Skipping auto publish after server start since the server start failed."); } } else { - publishAfterStart(monitor2,false,null); + publishAfterStart(monitor2,synchronous,null); } } }); - startJob.schedule(); + // Forces synchronous start since this method is supposed to wait until the publish operation is completed. + IStatus status = publishBeforeStart(monitor, startJob, true); + + if (status != null && status.getSeverity() == IStatus.ERROR){ + if (Trace.FINEST) { + Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); + } + return; + } + + if (((ServerType)getServerType()).startBeforePublish()) { + startJob.schedule(); + try { + if(synchronous) + startJob.join(); + } catch (InterruptedException e) { + if (Trace.WARNING) { + Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + } + } + } } /** @@ -2030,17 +2080,6 @@ // make sure that the delegate is loaded and the server state is correct loadAdapter(ServerBehaviourDelegate.class, null); - IStatus status = publishBeforeStart(null,false); - - if (status != null && status.getSeverity() == IStatus.ERROR){ - if (Trace.FINEST) { - Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); - } - if (opListener != null) - opListener.done(Status.OK_STATUS); - return; - } - // check the publish flag (again) to determine when to call opListener.done byte pub = StartJob.PUBLISH_NONE; if (ServerCore.isAutoPublishing() && shouldPublish()) { @@ -2062,6 +2101,21 @@ } }); } + + final boolean synchronous = false; + // For publish before start servers, the start job will only be kicked off if the publishing + // operation is completed successfully. + IStatus status = publishBeforeStart(null, startJob, synchronous); + + if (status != null && status.getSeverity() == IStatus.ERROR){ + if (Trace.FINEST) { + Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); + } + if (opListener != null) + opListener.done(Status.OK_STATUS); + return; + } + // 287442 - only do publish after start if the server start is successful. if (pub == StartJob.PUBLISH_AFTER) { startJob.addJobChangeListener(new JobChangeAdapter() { @@ -2077,12 +2131,21 @@ opListener.done(Status.OK_STATUS); } else { - publishAfterStart(null,false,opListener); + publishAfterStart(null,synchronous,opListener); } } }); + startJob.schedule(); + + try { + if(synchronous) + startJob.join(); + } catch (InterruptedException e) { + if (Trace.WARNING) { + Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + } + } } - startJob.schedule(); } public void synchronousStart(String mode2, IProgressMonitor monitor) throws CoreException { @@ -2092,15 +2155,6 @@ // make sure that the delegate is loaded and the server state is correct loadAdapter(ServerBehaviourDelegate.class, monitor); - IStatus status = publishBeforeStart(monitor,true); - - if (status != null && status.getSeverity() == IStatus.ERROR){ - if (Trace.FINEST) { - Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); - } - return; - } - StartJob startJob = new StartJob(mode2); // 287442 - only do publish after start if the server start is successful. final IProgressMonitor monitor2 = monitor; @@ -2117,13 +2171,25 @@ } } }); - startJob.schedule(); - try { - startJob.join(); - } catch (InterruptedException e) { - if (Trace.WARNING) { - Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + IStatus status = publishBeforeStart(monitor, startJob, true); + + if (status != null && status.getSeverity() == IStatus.ERROR){ + if (Trace.FINEST) { + Trace.trace(Trace.STRING_FINEST, "Failed publish job during start routine"); + } + return; + } + + if (((ServerType)getServerType()).startBeforePublish()) { + startJob.schedule(); + + try { + startJob.join(); + } catch (InterruptedException e) { + if (Trace.WARNING) { + Trace.trace(Trace.STRING_WARNING, "Error waiting for job", e); + } } } } @@ -3126,6 +3192,7 @@ Trace.trace(Trace.STRING_FINEST, "Restarting server: " + getName()); } + ISchedulingRule curRule = null; try { try { // synchronous restart @@ -3142,14 +3209,21 @@ } // if restart is not implemented by the server adopter // lets provide a default implementation + // Ending the current rule setup by the RestartJob to prevent deadlock since the StopJob triggered + // by the stop(false) also setup the Server as the scheduling rule. + curRule = Job.getJobManager().currentRule(); + Job.getJobManager().endRule(curRule); stop(false); start(launchMode, monitor); - } catch (Exception e) { if (Trace.SEVERE) { Trace.trace(Trace.STRING_SEVERE, "Error restarting server", e); } return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorStartFailed, getName()), e); + } finally { + if (curRule != null) { + Job.getJobManager().beginRule(curRule, monitor); + } } return Status.OK_STATUS; } @@ -3256,7 +3330,7 @@ getBehaviourDelegate(null).restart(launchMode); thread.setDaemon(true); - thread.start(); + thread.start(); } catch (CoreException e) { removeServerListener(listener); timer.alreadyDone = true; @@ -3402,7 +3476,6 @@ thread.start(); } catch (CoreException e) { removeServerListener(listener); - timer.alreadyDone = true; return e.getStatus(); } if (monitor.isCanceled()) { @@ -3517,13 +3590,13 @@ if (serverTimeout > 0) { thread = new Thread("Server Stop Timeout") { public void run() { - try { + try { int totalTimeout = serverTimeout; if (totalTimeout < 0) totalTimeout = 1; int retryPeriod = 1000; - + while (totalTimeout > 0 && !timer.alreadyDone){ Thread.sleep(retryPeriod); if (serverTimeout > 0)
diff --git a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF index da90d9b..a797596 100644 --- a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.server.ui; singleton:=true -Bundle-Version: 1.3.1.qualifier +Bundle-Version: 1.3.2.qualifier Bundle-Activator: org.eclipse.wst.server.ui.internal.ServerUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java index af8285e..a48ac33 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
@@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -268,6 +268,7 @@ public static String editorRenameFiles; public static String errorEditorCantSave; public static String errorDuplicateName; + public static String errorDuplicateServerName; public static String editorReadOnly; public static String editorWritable; public static String editorResourceModifiedTitle;
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties index cb9ff0b..7304db5 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
@@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2011 IBM Corporation and others. +# Copyright (c) 2004, 2012 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -401,6 +401,7 @@ errorConfigurationNotAccessible=The server configuration is not accessible. The {0} project is closed. errorRootModule=Could not find a valid parent module to add to the server. errorDuplicateName=The name is already in use. Specify a different name. +errorDuplicateServerName=The server name is already in use. Specify a different name. # Info messages infoNoRuntimesFound=No new server runtime environments were found.
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java index 16b86f3..1283443 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -281,7 +281,7 @@ Trace.trace(Trace.STRING_SEVERE, "Error finding runtimes", ex); } } - runtimeComp.refresh(); + runtimeComp2.refresh(); } }); @@ -434,7 +434,7 @@ final RuntimeComposite runtimeComp2 = this.runtimeComp; Display.getDefault().asyncExec(new Runnable(){ public void run(){ - runtimeComp2.add(runtime); + runtimeComp2.refresh(); } }); } @@ -442,7 +442,7 @@ final RuntimeComposite runtimeComp2 = this.runtimeComp; Display.getDefault().asyncExec(new Runnable(){ public void run(){ - runtimeComp2.remove(runtime); + runtimeComp2.refresh(); } }); }
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java index 1ff11a6..e84746f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
@@ -86,7 +86,16 @@ | SWT.NO_FOCUS); stickyTooltip.setLayout(new FillLayout()); stickyTooltip.setBackground(stickyTooltip.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - + stickyTooltip.addShellListener(new ShellAdapter() { + public void shellClosed(ShellEvent e) { + if (CURRENT_TOOLTIP != null) { + CURRENT_TOOLTIP.dispose(); + CURRENT_TOOLTIP = null; + } + activate(); + } + }); + control.getDisplay().asyncExec(new Runnable() { public void run() { Event event = new Event(); @@ -130,8 +139,25 @@ } protected final boolean shouldCreateToolTip(Event event) { - if (tree.getItem(new Point(event.x, event.y)) == null) + Object o = tree.getItem(new Point(event.x, event.y)); + if (o == null) { return false; + } + IServer server = null; + IServerModule module = null; + if (o instanceof TreeItem) { + Object obj = ((TreeItem)o).getData(); + if (obj instanceof IServer) { + server = (IServer) obj; + } + if (obj instanceof IServerModule) { + module = (IServerModule) obj; + } + } + // Only enable for supported objects. + if (server == null && module == null) { + return false; + } return super.shouldCreateToolTip(event); }
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java index 273d1ed..2aaa32f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,6 +40,10 @@ protected Map<String, WizardFragment> fragmentMap = new HashMap<String, WizardFragment>(); + // Storing the NewRuntimeComposite is required to determine if the selected item + // by the user is a valid server runtime + protected NewRuntimeComposite comp; + public NewRuntimeWizardFragment() { // do nothing } @@ -58,7 +62,8 @@ * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() */ public Composite createComposite(Composite parent, IWizardHandle wizard) { - return new NewRuntimeComposite(parent, wizard, getTaskModel(), type, version, runtimeTypeId); + comp = new NewRuntimeComposite(parent, wizard, getTaskModel(), type, version, runtimeTypeId); + return comp; } public List getChildFragments() { @@ -121,4 +126,13 @@ fragmentMap.put(typeId, fragment); return fragment; } + + public boolean isComplete(){ + // If the selected runtime is invalid, the wizard + // should not allow the user to press Finish + if (comp.hasValidSelectedRuntime()){ + return true; + } + return false; + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java index 5747e58..ba6c982 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -149,10 +149,15 @@ if(getServer().getServerType() == null) return false; - return checkHostAndServerType(); + return checkValidInput(); } - private boolean checkHostAndServerType(){ + /* + * Checks for valid host name, server type, and server name + * + * @return true if input is valid, false otherwise + */ + private boolean checkValidInput(){ boolean isComplete = false; boolean supportsRemote = getServer().getServerType().supportsRemoteHosts(); @@ -165,6 +170,10 @@ return false; } + if (manualComp.isServerNameInUse()){ + return false; + } + if (manualComp.getCurrentHostname().trim().length() == 0){ isComplete = false; } else if(!supportsRemote && !SocketUtil.isLocalhost(manualComp.getCurrentHostname())){
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java index 9b33496..45a26d8 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,6 +40,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.help.IWorkbenchHelpSystem; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ServerPlugin; import org.eclipse.wst.server.core.internal.ServerWorkingCopy; import org.eclipse.wst.server.core.util.SocketUtil; import org.eclipse.wst.server.ui.AbstractUIControl; @@ -110,6 +111,10 @@ private boolean canSupportModule=true; + // These variables deal with caching server name checks + private boolean isServerNameInUse=false; + private String cacheServerNameCheck=""; + /** * Creates a new server and server configuration. If the initial * resource selection contains exactly one container resource then it will be @@ -236,6 +241,13 @@ return; String name = serverName.getText(); + + IServerType selectedServerType = serverTypeComposite.getSelectedServerType(); + if (validate(selectedServerType)) { + // Do not set the server name if it is invalid + return; + } + if (server != null) { server.setName(name); IRuntime runtime2 = server.getRuntime(); @@ -392,7 +404,7 @@ protected void handleHostnameChange(IServerType serverType) { wizard.setMessage(null, IMessageProvider.NONE); - if (!checkHostAndServerType(serverType)) { + if (!validate(serverType)) { return;// Host name validation failed, so there is no need to continue handling hostname change event } loadServerImpl(serverType); @@ -438,10 +450,23 @@ wizard.setMessage(NLS.bind(Messages.wizCheckRemoteSupport, new Object[0]), IMessageProvider.ERROR); return false; } - + return true; } + protected boolean checkServerName(){ + if (isServerNameInUse()){ + wizard.setMessage(Messages.errorDuplicateServerName, IMessageProvider.ERROR); + return false; + } + return true; + } + + protected boolean validate(IServerType selectedServerType){ + wizard.setMessage(null, IMessageProvider.NONE); + return (checkHostAndServerType(selectedServerType) & checkServerName()); + } + /** * Load a server of the given type. */ @@ -723,7 +748,7 @@ // Update the old server type value. oldServerType = serverType; - checkHostAndServerType(serverType); + validate(serverType); wizard.update(); } @@ -883,4 +908,28 @@ hostName = host; } } + + /** + * Determines if the server name is in use. The server name that is checked + * is cached to increase performance on multiple calls. + * + * @return true if name is in use, false otherwise + */ + public boolean isServerNameInUse(){ + String myServerName=""; + if (serverName != null){ + myServerName = serverName.getText().trim(); + // If the server name is equal to the cached server name, then return the + // previously cached value. If the server name is not equal to the cached + // server name, check to see if the name is in use + if (!cacheServerNameCheck.equals(myServerName)){ + cacheServerNameCheck = myServerName; + isServerNameInUse = ServerPlugin.isNameInUse(server, serverName.getText().trim()); + } + return isServerNameInUse; + } + + // If the widget is null, return false + return false; + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java index 5962e97..c8d69d0 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -202,4 +202,17 @@ c[i].setVisible(visible); } } + + /** + * + * Determines if the selected runtime is a + * valid. + * + */ + public boolean hasValidSelectedRuntime(){ + if (runtime == null){ + return false; + } + return true; + } } \ No newline at end of file