use of org.eclipse.jst.server.tomcat.core.internal.command.RemoveWebModuleCommand 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();
}
Aggregations