use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.
the class ContextPublisherDelegate method execute.
public IStatus execute(int kind, IProgressMonitor monitor, IAdaptable info) throws CoreException {
// this publisher only runs when there is a UI
if (info == null)
return Status.OK_STATUS;
final Shell shell = (Shell) info.getAdapter(Shell.class);
if (shell == null)
return Status.OK_STATUS;
IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, monitor);
final TomcatConfiguration configuration = tomcatServer.getTomcatConfiguration();
final boolean[] save = new boolean[1];
List modules = (List) getTaskModel().getObject(TaskModel.TASK_MODULES);
int size = modules.size();
for (int i = 0; i < size; i++) {
IModule[] module = (IModule[]) modules.get(i);
final IModule m = module[module.length - 1];
IWebModule webModule = (IWebModule) m.loadAdapter(IWebModule.class, monitor);
final WebModule webModule2 = configuration.getWebModule(m);
if (webModule != null && webModule2 != null) {
String contextRoot = webModule.getContextRoot();
if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
contextRoot = "/" + contextRoot;
if (!contextRoot.equals(webModule2.getPath()) && shouldPrompt(m, contextRoot)) {
final String context = contextRoot;
shell.getDisplay().syncExec(new Runnable() {
public void run() {
if (MessageDialog.openQuestion(shell, Messages.wizardTitle, NLS.bind(Messages.contextCleanup, m.getName()))) {
int index = configuration.getWebModules().indexOf(webModule2);
configuration.modifyWebModule(index, webModule2.getDocumentBase(), context, webModule2.isReloadable());
save[0] = true;
}
}
});
markProject(m, contextRoot);
}
}
}
if (save[0])
tomcatServer.saveConfiguration(monitor);
return Status.OK_STATUS;
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.
the class ConfigurationMimeEditorSection method init.
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class);
try {
tomcatConfiguration = ts.getTomcatConfiguration();
} catch (Exception e) {
// ignore
}
addChangeListener();
initialize();
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.
the class ConfigurationPortEditorSection method init.
/* (non-Javadoc)
* Initializes the editor part with a site and input.
*/
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class);
try {
tomcatConfiguration = ts.getTomcatConfiguration();
} catch (Exception e) {
// ignore
}
addChangeListener();
initialize();
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.
the class AbstractTomcatServerTestCase method createServer.
public IServer createServer() throws Exception {
IServerType st = ServerCore.findServerType(getServerTypeId());
IRuntime runtime = createRuntime();
IServerWorkingCopy wc = st.createServer(null, null, runtime, null);
ServerPort[] ports = wc.getServerPorts(null);
TomcatServer tomcatServer = (TomcatServer) wc.getAdapter(TomcatServer.class);
ITomcatConfigurationWorkingCopy configuration = (ITomcatConfigurationWorkingCopy) tomcatServer.getServerConfiguration();
// if no ports from the server, use the configuration
if (ports == null || ports.length == 0) {
List portsList = configuration.getServerPorts();
if (portsList != null && portsList.size() > 0) {
ports = (ServerPort[]) portsList.toArray(new ServerPort[portsList.size()]);
}
}
if (ports != null) {
int size = ports.length;
for (int i = 0; i < size; i++) {
configuration.modifyServerPort(ports[i].getId(), 22100 + i);
}
}
return wc.save(true, null);
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.
the class AbstractTomcatServerTestCase method verifyDefaultDeployConfig.
/*
* Tests to verify modules are deployed correctly per configuration
*/
/**
* @throws Exception
*/
public void verifyDefaultDeployConfig() throws Exception {
TomcatServer ts = getTomcatServer();
assertNotNull(ts);
TomcatServerBehaviour tsb = getTomcatServerBehaviour();
assertNotNull(tsb);
assertEquals(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR, ts.getDeployDirectory());
IPath tempDir = tsb.getTempDirectory();
IPath baseDir = tsb.getRuntimeBaseDirectory();
assertEquals(tempDir, baseDir);
IPath deployDir = tsb.getServerDeployDirectory();
assertEquals(baseDir.append(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR), deployDir);
}
Aggregations