blob: e40f1daa7ad8493a2e5b1c0c96d44ed9b717e98a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2003, 2005 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.jst.server.tomcat.core.internal.command;
import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy;
import org.eclipse.jst.server.tomcat.core.internal.Messages;
import org.eclipse.jst.server.tomcat.core.internal.WebModule;
/**
* Command to modify the path of a Web module.
*/
public class SetWebModulePathCommand extends ConfigurationCommand {
protected int index;
protected WebModule oldModule;
protected String path;
/**
* SetWebModulePathCommand constructor comment.
*
* @param configuration a tomcat configuration
* @param index an index
* @param contextRoot the context root
*/
public SetWebModulePathCommand(ITomcatConfigurationWorkingCopy configuration, int index, String contextRoot) {
super(configuration, Messages.configurationEditorActionEditWebModulePath);
this.index = index;
this.path = contextRoot;
}
/**
* Execute the command.
*/
public void execute() {
oldModule = (WebModule) configuration.getWebModules().get(index);
configuration.removeWebModule(index);
WebModule module = new WebModule(path, oldModule.getDocumentBase(), oldModule.getMemento(), oldModule.isReloadable());
configuration.addWebModule(index, module);
}
/**
* Undo the command.
*/
public void undo() {
configuration.removeWebModule(index);
configuration.addWebModule(index, oldModule);
}
}
|