use of org.eclipse.jst.server.tomcat.core.internal.WebModule 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.WebModule in project webtools.servertools by eclipse.
the class ConfigurationWebModuleEditorPart method initialize.
/**
*/
protected void initialize() {
if (webAppTable == null)
return;
webAppTable.removeAll();
setErrorMessage(null);
ILabelProvider labelProvider = ServerUICore.getLabelProvider();
List list = configuration.getWebModules();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
WebModule module = (WebModule) iterator.next();
TableItem item = new TableItem(webAppTable, SWT.NONE);
String memento = module.getMemento();
String projectName = "";
Image projectImage = null;
if (memento != null && memento.length() > 0) {
projectName = NLS.bind(Messages.configurationEditorProjectMissing, new String[] { memento });
projectImage = TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PROJECT_MISSING);
IModule module2 = ServerUtil.getModule(memento);
if (module2 != null) {
projectName = labelProvider.getText(module2);
projectImage = labelProvider.getImage(module2);
item.setData(module2);
}
}
String reload = module.isReloadable() ? Messages.configurationEditorReloadEnabled : Messages.configurationEditorReloadDisabled;
String[] s = new String[] { module.getPath(), module.getDocumentBase(), projectName, reload };
item.setText(s);
item.setImage(0, TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_WEB_MODULE));
if (projectImage != null)
item.setImage(2, projectImage);
if (!isDocumentBaseValid(module.getDocumentBase())) {
item.setImage(1, TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PROJECT_MISSING));
setErrorMessage(NLS.bind(Messages.errorMissingWebModule, module.getDocumentBase()));
}
}
labelProvider = null;
if (readOnly) {
addProject.setEnabled(false);
addExtProject.setEnabled(false);
edit.setEnabled(false);
remove.setEnabled(false);
} else {
addProject.setEnabled(canAddWebModule());
addExtProject.setEnabled(true);
}
}
use of org.eclipse.jst.server.tomcat.core.internal.WebModule in project webtools.servertools by eclipse.
the class ConfigurationWebModuleEditorPart method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
FormToolkit toolkit = getFormToolkit(parent.getDisplay());
ScrolledForm form = toolkit.createScrolledForm(parent);
toolkit.decorateFormHeading(form.getForm());
form.setText(Messages.configurationEditorWebModulesPageTitle);
form.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_WEB_MODULE));
GridLayout layout = new GridLayout();
layout.marginTop = 6;
layout.marginLeft = 6;
form.getBody().setLayout(layout);
Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(Messages.configurationEditorWebModulesSection);
section.setDescription(Messages.configurationEditorWebModulesDescription);
section.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite composite = toolkit.createComposite(section);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 15;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULES);
toolkit.paintBordersFor(composite);
section.setClient(composite);
webAppTable = toolkit.createTable(composite, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
webAppTable.setHeaderVisible(true);
webAppTable.setLinesVisible(true);
whs.setHelp(webAppTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_LIST);
// toolkit.paintBordersFor(webAppTable);
TableLayout tableLayout = new TableLayout();
TableColumn col = new TableColumn(webAppTable, SWT.NONE);
col.setText(Messages.configurationEditorPathColumn);
ColumnWeightData colData = new ColumnWeightData(8, 85, true);
tableLayout.addColumnData(colData);
TableColumn col2 = new TableColumn(webAppTable, SWT.NONE);
col2.setText(Messages.configurationEditorDocBaseColumn);
colData = new ColumnWeightData(13, 135, true);
tableLayout.addColumnData(colData);
TableColumn col3 = new TableColumn(webAppTable, SWT.NONE);
col3.setText(Messages.configurationEditorProjectColumn);
colData = new ColumnWeightData(8, 85, true);
tableLayout.addColumnData(colData);
TableColumn col4 = new TableColumn(webAppTable, SWT.NONE);
col4.setText(Messages.configurationEditorReloadColumn);
colData = new ColumnWeightData(7, 75, true);
tableLayout.addColumnData(colData);
webAppTable.setLayout(tableLayout);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 450;
data.heightHint = 120;
webAppTable.setLayoutData(data);
webAppTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
selectWebApp();
}
});
Composite rightPanel = toolkit.createComposite(composite);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
rightPanel.setLayout(layout);
data = new GridData();
rightPanel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
// toolkit.paintBordersFor(rightPanel);
// buttons still to add:
// add project, add external module, remove module
addProject = toolkit.createButton(rightPanel, Messages.configurationEditorAddProjectModule, SWT.PUSH);
data = new GridData(GridData.FILL_HORIZONTAL);
addProject.setLayoutData(data);
whs.setHelp(addProject, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_ADD_PROJECT);
// web projects in the workbench
if (!canAddWebModule())
addProject.setEnabled(false);
else {
addProject.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, true);
dialog.open();
if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
execute(new AddModuleCommand(getServer(), dialog.module4));
}
}
});
}
addExtProject = toolkit.createButton(rightPanel, Messages.configurationEditorAddExternalModule, SWT.PUSH);
data = new GridData(GridData.FILL_HORIZONTAL);
addExtProject.setLayoutData(data);
addExtProject.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, false);
dialog.open();
if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
execute(new AddWebModuleCommand(configuration, dialog.getWebModule()));
}
}
});
whs.setHelp(addExtProject, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_ADD_EXTERNAL);
edit = toolkit.createButton(rightPanel, Messages.editorEdit, SWT.PUSH);
data = new GridData(GridData.FILL_HORIZONTAL);
edit.setLayoutData(data);
edit.setEnabled(false);
edit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (selection < 0)
return;
WebModule module = (WebModule) configuration.getWebModules().get(selection);
WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, module);
dialog.open();
if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
execute(new ModifyWebModuleCommand(configuration, selection, dialog.getWebModule()));
}
}
});
whs.setHelp(edit, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_EDIT);
remove = toolkit.createButton(rightPanel, Messages.editorRemove, SWT.PUSH);
data = new GridData(GridData.FILL_HORIZONTAL);
remove.setLayoutData(data);
remove.setEnabled(false);
remove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (selection < 0)
return;
TableItem item = webAppTable.getItem(selection);
if (item.getData() != null) {
IModule module = (IModule) item.getData();
execute(new RemoveModuleCommand(getServer(), module));
} else {
execute(new RemoveWebModuleCommand(configuration, selection));
}
remove.setEnabled(false);
edit.setEnabled(false);
selection = -1;
}
});
whs.setHelp(remove, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_REMOVE);
form.setContent(section);
form.reflow(true);
initialize();
}
use of org.eclipse.jst.server.tomcat.core.internal.WebModule in project webtools.servertools by eclipse.
the class WebModuleDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part
* of this dialog (above the button bar).
* <p>
* The <code>Dialog</code> implementation of this framework method
* creates and returns a new <code>Composite</code> with
* standard margins and spacing. Subclasses should override.
* </p>
*
* @param parent the parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
// create a composite with standard margins and spacing
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG);
// add project field if we are adding a project
if (!isEdit && isProject) {
Label l = new Label(composite, SWT.NONE);
l.setText(Messages.configurationEditorWebModuleDialogProjects);
GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
l.setLayoutData(data);
projTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
data = new GridData();
data.widthHint = 150;
data.heightHint = 75;
projTable.setLayoutData(data);
whs.setHelp(projTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT);
// fill table with web module projects
ILabelProvider labelProvider = ServerUICore.getLabelProvider();
IModule[] modules = ServerUtil.getModules(server2.getServerType().getRuntimeType().getModuleTypes());
if (modules != null) {
int size = modules.length;
for (int i = 0; i < size; i++) {
IModule module3 = modules[i];
if ("jst.web".equals(module3.getModuleType().getId())) {
IStatus status = server2.canModifyModules(new IModule[] { module3 }, null, null);
if (status != null && status.isOK()) {
TableItem item = new TableItem(projTable, SWT.NONE);
item.setText(0, labelProvider.getText(module3));
item.setImage(0, labelProvider.getImage(module3));
item.setData(module3);
}
}
}
}
labelProvider.dispose();
new Label(composite, SWT.NONE).setText(" ");
}
new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogDocumentBase);
docBase = new Text(composite, SWT.BORDER);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
docBase.setLayoutData(data);
docBase.setText(module.getDocumentBase());
whs.setHelp(docBase, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_DOCBASE);
// disable document base for project modules
if (isProject || (module.getMemento() != null && module.getMemento().length() > 0))
docBase.setEditable(false);
else {
docBase.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
module = new WebModule(module.getPath(), docBase.getText(), module.getMemento(), module.isReloadable());
validate();
}
});
}
if (isEdit || isProject)
new Label(composite, SWT.NONE).setText(" ");
else {
Button browse = new Button(composite, SWT.NONE);
browse.setText(Messages.browse);
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
try {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setMessage(Messages.configurationEditorWebModuleDialogSelectDirectory);
String selectedDirectory = dialog.open();
if (selectedDirectory != null)
docBase.setText(selectedDirectory);
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error browsing", e);
}
}
});
}
// path (context-root)
new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogPath);
final Text path = new Text(composite, SWT.BORDER);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
data.widthHint = 150;
path.setLayoutData(data);
path.setText(module.getPath());
/*if (module.getMemento() != null && module.getMemento().length() > 0)
path.setEditable(false);
else*/
path.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
module = new WebModule(path.getText(), module.getDocumentBase(), module.getMemento(), module.isReloadable());
}
});
whs.setHelp(path, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PATH);
new Label(composite, SWT.NONE).setText("");
if (!isProject) {
// auto reload
new Label(composite, SWT.NONE).setText("");
final Button reloadable = new Button(composite, SWT.CHECK);
reloadable.setText(Messages.configurationEditorWebModuleDialogReloadEnabled);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
reloadable.setLayoutData(data);
reloadable.setSelection(module.isReloadable());
reloadable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
module = new WebModule(module.getPath(), module.getDocumentBase(), module.getMemento(), reloadable.getSelection());
}
});
whs.setHelp(reloadable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_RELOAD);
}
if (!isEdit && isProject) {
projTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
IModule module3 = (IModule) projTable.getSelection()[0].getData();
IWebModule module2 = (IWebModule) module3.loadAdapter(IWebModule.class, null);
String contextRoot = module2.getContextRoot();
if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
contextRoot = "/" + contextRoot;
module = new WebModule(contextRoot, module3.getName(), module3.getId(), module.isReloadable());
docBase.setText(module3.getName());
path.setText(contextRoot);
module4 = module3;
} catch (Exception e) {
// ignore
}
validate();
}
});
new Label(composite, SWT.NONE).setText("");
}
Dialog.applyDialogFont(composite);
return composite;
}
use of org.eclipse.jst.server.tomcat.core.internal.WebModule in project webtools.servertools by eclipse.
the class SetWebModulePathCommand method execute.
/**
* 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);
}
Aggregations