Search in sources :

Example 1 with AddWebModuleCommand

use of org.eclipse.jst.server.tomcat.core.internal.command.AddWebModuleCommand 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();
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ModifyWebModuleCommand(org.eclipse.jst.server.tomcat.core.internal.command.ModifyWebModuleCommand) RemoveWebModuleCommand(org.eclipse.jst.server.tomcat.core.internal.command.RemoveWebModuleCommand) AddWebModuleCommand(org.eclipse.jst.server.tomcat.core.internal.command.AddWebModuleCommand) IModule(org.eclipse.wst.server.core.IModule) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) WebModule(org.eclipse.jst.server.tomcat.core.internal.WebModule) IWebModule(org.eclipse.jst.server.core.IWebModule) Section(org.eclipse.ui.forms.widgets.Section) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) AddModuleCommand(org.eclipse.jst.server.tomcat.core.internal.command.AddModuleCommand) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RemoveModuleCommand(org.eclipse.jst.server.tomcat.core.internal.command.RemoveModuleCommand) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 TableLayout (org.eclipse.jface.viewers.TableLayout)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 WebModule (org.eclipse.jst.server.tomcat.core.internal.WebModule)1 AddModuleCommand (org.eclipse.jst.server.tomcat.core.internal.command.AddModuleCommand)1 AddWebModuleCommand (org.eclipse.jst.server.tomcat.core.internal.command.AddWebModuleCommand)1 ModifyWebModuleCommand (org.eclipse.jst.server.tomcat.core.internal.command.ModifyWebModuleCommand)1 RemoveModuleCommand (org.eclipse.jst.server.tomcat.core.internal.command.RemoveModuleCommand)1 RemoveWebModuleCommand (org.eclipse.jst.server.tomcat.core.internal.command.RemoveWebModuleCommand)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)1 Section (org.eclipse.ui.forms.widgets.Section)1