|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2003, 2011 IBM Corporation and others. |
2 |
* Copyright (c) 2003, 2012 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 40-45
Link Here
|
| 40 |
import org.eclipse.ui.dialogs.PreferencesUtil; |
40 |
import org.eclipse.ui.dialogs.PreferencesUtil; |
| 41 |
import org.eclipse.ui.help.IWorkbenchHelpSystem; |
41 |
import org.eclipse.ui.help.IWorkbenchHelpSystem; |
| 42 |
import org.eclipse.wst.server.core.*; |
42 |
import org.eclipse.wst.server.core.*; |
|
|
43 |
import org.eclipse.wst.server.core.internal.ServerPlugin; |
| 43 |
import org.eclipse.wst.server.core.internal.ServerWorkingCopy; |
44 |
import org.eclipse.wst.server.core.internal.ServerWorkingCopy; |
| 44 |
import org.eclipse.wst.server.core.util.SocketUtil; |
45 |
import org.eclipse.wst.server.core.util.SocketUtil; |
| 45 |
import org.eclipse.wst.server.ui.AbstractUIControl; |
46 |
import org.eclipse.wst.server.ui.AbstractUIControl; |
|
Lines 110-115
Link Here
|
| 110 |
|
111 |
|
| 111 |
private boolean canSupportModule=true; |
112 |
private boolean canSupportModule=true; |
| 112 |
|
113 |
|
|
|
114 |
// These variables deal with caching server name checks |
| 115 |
private boolean isServerNameInUse=false; |
| 116 |
private String cacheServerNameCheck=""; |
| 117 |
|
| 113 |
/** |
118 |
/** |
| 114 |
* Creates a new server and server configuration. If the initial |
119 |
* Creates a new server and server configuration. If the initial |
| 115 |
* resource selection contains exactly one container resource then it will be |
120 |
* resource selection contains exactly one container resource then it will be |
|
Lines 236-241
Link Here
|
| 236 |
return; |
241 |
return; |
| 237 |
|
242 |
|
| 238 |
String name = serverName.getText(); |
243 |
String name = serverName.getText(); |
|
|
244 |
|
| 245 |
IServerType selectedServerType = serverTypeComposite.getSelectedServerType(); |
| 246 |
if (!validate(selectedServerType)) { |
| 247 |
// Do not set the server name if it is invalid |
| 248 |
return; |
| 249 |
} |
| 250 |
|
| 239 |
if (server != null) { |
251 |
if (server != null) { |
| 240 |
server.setName(name); |
252 |
server.setName(name); |
| 241 |
IRuntime runtime2 = server.getRuntime(); |
253 |
IRuntime runtime2 = server.getRuntime(); |
|
Lines 392-398
Link Here
|
| 392 |
protected void handleHostnameChange(IServerType serverType) { |
404 |
protected void handleHostnameChange(IServerType serverType) { |
| 393 |
|
405 |
|
| 394 |
wizard.setMessage(null, IMessageProvider.NONE); |
406 |
wizard.setMessage(null, IMessageProvider.NONE); |
| 395 |
if (!checkHostAndServerType(serverType)) { |
407 |
if (!validate(serverType)) { |
| 396 |
return;// Host name validation failed, so there is no need to continue handling hostname change event |
408 |
return;// Host name validation failed, so there is no need to continue handling hostname change event |
| 397 |
} |
409 |
} |
| 398 |
loadServerImpl(serverType); |
410 |
loadServerImpl(serverType); |
|
Lines 438-447
Link Here
|
| 438 |
wizard.setMessage(NLS.bind(Messages.wizCheckRemoteSupport, new Object[0]), IMessageProvider.ERROR); |
450 |
wizard.setMessage(NLS.bind(Messages.wizCheckRemoteSupport, new Object[0]), IMessageProvider.ERROR); |
| 439 |
return false; |
451 |
return false; |
| 440 |
} |
452 |
} |
| 441 |
|
453 |
|
|
|
454 |
return true; |
| 455 |
} |
| 456 |
|
| 457 |
protected boolean checkServerName(){ |
| 458 |
if (isServerNameInUse()){ |
| 459 |
wizard.setMessage(Messages.errorDuplicateServerName, IMessageProvider.ERROR); |
| 460 |
return false; |
| 461 |
} |
| 442 |
return true; |
462 |
return true; |
| 443 |
} |
463 |
} |
| 444 |
|
464 |
|
|
|
465 |
protected boolean validate(IServerType selectedServerType){ |
| 466 |
wizard.setMessage(null, IMessageProvider.NONE); |
| 467 |
return (checkHostAndServerType(selectedServerType) & checkServerName()); |
| 468 |
} |
| 469 |
|
| 445 |
/** |
470 |
/** |
| 446 |
* Load a server of the given type. |
471 |
* Load a server of the given type. |
| 447 |
*/ |
472 |
*/ |
|
Lines 723-729
Link Here
|
| 723 |
// Update the old server type value. |
748 |
// Update the old server type value. |
| 724 |
oldServerType = serverType; |
749 |
oldServerType = serverType; |
| 725 |
|
750 |
|
| 726 |
checkHostAndServerType(serverType); |
751 |
validate(serverType); |
| 727 |
wizard.update(); |
752 |
wizard.update(); |
| 728 |
} |
753 |
} |
| 729 |
|
754 |
|
|
Lines 883-886
Link Here
|
| 883 |
hostName = host; |
908 |
hostName = host; |
| 884 |
} |
909 |
} |
| 885 |
} |
910 |
} |
|
|
911 |
|
| 912 |
/** |
| 913 |
* Determines if the server name is in use. The server name that is checked |
| 914 |
* is cached to increase performance on multiple calls. |
| 915 |
* |
| 916 |
* @return true if name is in use, false otherwise |
| 917 |
*/ |
| 918 |
public boolean isServerNameInUse(){ |
| 919 |
String myServerName=""; |
| 920 |
if (serverName != null){ |
| 921 |
myServerName = serverName.getText().trim(); |
| 922 |
// If the server name is equal to the cached server name, then return the |
| 923 |
// previously cached value. If the server name is not equal to the cached |
| 924 |
// server name, check to see if the name is in use |
| 925 |
if (!cacheServerNameCheck.equals(myServerName)){ |
| 926 |
cacheServerNameCheck = myServerName; |
| 927 |
isServerNameInUse = ServerPlugin.isNameInUse(server, serverName.getText().trim()); |
| 928 |
} |
| 929 |
return isServerNameInUse; |
| 930 |
} |
| 931 |
|
| 932 |
// If the widget is null, return false |
| 933 |
return false; |
| 934 |
} |
| 886 |
} |
935 |
} |