Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336148

Summary: ServerEditorSection Extension Point Doesn't Correctly Support Redo
Product: [WebTools] WTP ServerTools Reporter: Daniel Johnson <danijoh2>
Component: wst.serverAssignee: wst.server <wst.server-inbox>
Status: NEW --- QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Daniel Johnson CLA 2011-02-02 15:37:02 EST
I have created an extension for <extension point="org.eclipse.wst.server.ui.editorPageSections"> that subclasses org.eclipse.wst.server.ui.editor.ServerEditorSection

I have added a checkbox button on the form:

@Override
public void createSection(Composite parent) {
    super.createSection(parent);    
    FormToolkit toolkit = getFormToolkit(parent.getDisplay());
    Composite comp = toolkit.createComposite(parent);
    Button button = toolkit.createButton(comp, "My Button", SWT.CHECK);
    button..addSelectionListener(selectionListener);
}

And my selection listener looks like this:

private SelectionListener selectionListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (!(e.widget instanceof Button)) {
                return;
            }
            final Button button = (Button)e.widget;
            execute(new AbstractOperation(XMPServerUIPlugin.PLUGIN_ID) {
                
                @Override
                public boolean canRedo() {
                    return true;
                }

                @Override
                public boolean canUndo() {
                    return true;
                }
                
                @Override
                public IStatus undo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
                    button.setSelection(!button.getSelection());
                    return Status.OK_STATUS;
                }

                @Override
                public IStatus redo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
                    button.setSelection(!button.getSelection());
                    return Status.OK_STATUS;
                }
                
                @Override
                public IStatus execute(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
                    return Status.OK_STATUS;
                }
            });
            
        }
};

Everything works as excepted for execute() and undo(), but when doing a redo in the editor neither the canRedo() or redo() functions of the AbstractOperation are called, though the editor correctly shows as no longer being dirty. Support for redo should be added/fixed.