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

Bug 344543

Summary: Extension for the Delete Server Dialog
Product: [WebTools] WTP ServerTools Reporter: Kaloyan Raev <kaloyan>
Component: wst.serverAssignee: Elson Yuen <eyuen7>
Status: RESOLVED FIXED QA Contact: Elson Yuen <eyuen7>
Severity: enhancement    
Priority: P3 CC: alexander.silgidjian, dimitar.giormov, eyuen7, manderse, shr31223, stryker
Version: 3.3   
Target Milestone: 3.6 M5   
Hardware: PC   
OS: Windows Vista   
See Also: https://git.eclipse.org/r/109215
https://git.eclipse.org/r/109216
https://git.eclipse.org/r/109856
https://git.eclipse.org/c/servertools/webtools.servertools.git/commit/?id=e6a8bb987a980d93f3006c889a8c1237f04e9491
Whiteboard:
Attachments:
Description Flags
patch
eyuen7: iplog+
test for the patch
eyuen7: iplog+
v1.0
none
v1.0 test none

Description Kaloyan Raev CLA 2011-05-03 05:42:58 EDT
The Delete Server Dialog is the one that pops up when users call the Delete action on a server in the Servers view. It requests the user to confirm the deletion of the server instance. The dialog also has some built-in logic for additional actions to be executed together with the deletion:
  * Delete unused server configuration(s)
  * Delete running server(s)
    * Stop server(s) before deleting

For the server adapter of our vendor's app server, we need to add more options that, if selected, call additional actions on deletions. 

It would be nice if such options can be added using an appropriate extension point. It's perfectly OK that these options are displayed like checkboxes. There is no need for more complex options.

Additional requirement is to have dependency between the different options like we already have between "Delete running server(s)" and "Stop server(s) before deleting": the second option is only available if the first one is selected. 

Default value for each options should be also set using the extension point.
Comment 1 Max Rydahl Andersen CLA 2011-05-11 06:00:30 EDT
Wouldn't this be better done as a refactoring operation ?

Use the refactoring extensibility to react/participate in the Delete operation ?
Comment 2 Kaloyan Raev CLA 2011-05-11 14:25:54 EDT
Max, I am not sure this would fit to this use case. 

The additional vendor specific actions does not change resources in the Eclipse workspace, but invokes actions on the server-side. These actions are optional and it is up to the user to decide if they will be invoked. This is why I think extending the Delete Server Dialog with additional checkboxes fits best.
Comment 3 Alexander Silgidjian CLA 2013-10-02 09:53:21 EDT
I have created a patch for this and uploaded it in GitHub: https://github.com/asilgidjian/wtp-server-tools

Here are the details with regards to the implementation:

An extension point should be defined providing the possibility to describe a sequence of additional options that will appear in the delete dialog.
The additional delete options will have the following attributes:
1.	id – id of the option
2.	label – the label that will appear in delete dialog for the option
3.	order – optional ordering of this option relative to other options
4.	selected - specifies if the option is selected by default
5.	operation - optional operation that will be executed if the option is selected
6.	serverTypes - The Server Types for which the option will appear
7.	parent - optional id of a parent option
8.	enablement – optional expression which evaluation will show or hide the option

For the purposes of operation attribute, a new interface extending IUndoableOperation will be defined. The new interface will provide possibility to pass the IServer[] for which DeleteServerDialog is called to the operation.

The enablement expression will be evaluated with every call of the DeleteServerDialog, thus the options will be reloaded every time.


A testcase will be provided in another repository.
Comment 4 Alexander Silgidjian CLA 2013-10-02 10:14:19 EDT
Here is the repository with the test: https://github.com/asilgidjian/webtools.servertools.tests
Comment 5 Max Rydahl Andersen CLA 2013-10-03 08:34:25 EDT
Looks nice, but just want to point out that refactoring participants does *not* have to be doing raw resource changes.

They can change anything and can provide custom diffs for the preview view.
Comment 6 Alexander Silgidjian CLA 2013-10-03 09:02:58 EDT
Hi Max,

Would you explain a little bit more?
I am not quite sure that I am using "refactoring participant" and I am performing "raw resource change".

Kind Regards,
Alex
Comment 7 Max Rydahl Andersen CLA 2013-10-03 10:48:49 EDT
My comment was to Kaloyan's comment that using the refactoring (ltk?) api in Eclipse couldn't be applied here.

I claim it can and I think your patch/approach would fit into it too and use the same kind of UI and API for it like other "delete' or "renames" in other part of eclipse.

http://www.eclipse.org/articles/Article-LTK/ltk.html
Comment 8 Elson Yuen CLA 2013-10-31 09:33:37 EDT
From your note to the WTP distribution list, the usage of this new extension is that you want to do action on deleting the last server of a certain server type.  Given that you want to do certain action when deleting the server, have you considered using the IServerLifeCycleListener to do the appropriate action on a serverRemoved event?  You can pop up your own GUI when needed in that case.  Is there anything that you find missing from this approach?
Comment 9 Alexander Silgidjian CLA 2013-10-31 09:46:29 EDT
We wanted to avoid the double popups, which will appear in that case.
The extension point is more robust solution and provides better usability.
Comment 10 Elson Yuen CLA 2013-10-31 16:43:50 EDT
ok, thanks for the clarification on the usage.  Looking at the proposed implementation, it is exposed as boolean delete options to the existing delete dialog.  If we are going to allow expansion or customization on that dialog, I wonder if we should expose in a way that will pass the composite to the extension and allow the user to inject their own custom UI in that dialog under the existing check boxes.

Doing it that way provides the flexibility for user to add their own customization without limiting to boolean input.  Also, as long as we expose a way to access the existing check boxes in the dialog, the adopter can implement listener to events from the existing check boxes to fulfill the dependency addition requirement on the original request.  Then, we don't have to burn the parent/child relationship and ordering in the extension point.
Comment 11 Dimitar Giormov CLA 2013-11-01 06:12:32 EDT
Hi Elson,

this sounds good, allowing the adopter to extend the delete dialog with custom composite will be much more flexible and will allow us and the other adopters to plug additional more complex logic in delete dialog. 

One way to do this is making similar extensions like in create server wizard and server editor (org.eclipse.wst.server.ui.serverEditorOverviewPageModifier). We should allow the user to completely overwrite the current composite containing the stop and delete configuration checkboxes. But still the adopter can reuse the current composite in his own composite implementation.

Another way to achieve this is without using extensions, through the API. But I am not sure where the integration point should be. I mean where the adopter will attach the custom composite to the dialog. Should we create a method that will accept this composite and if yes, where do you think should we add this method?

best regards,
Dimitar
Comment 12 Elson Yuen CLA 2013-11-01 16:38:25 EDT
The extension point will look like a combination of  org.eclipse.wst.server.ui.serverCreationWizardPageExtension and serverEditorOverviewPageModifier.  We tend to be cautious on completely replacing existing GUI.  In both the existing extension points serverCreationWizardPageExtension and serverEditorOverviewPageModifier, we tend to provide ways for using to add addition GUI instead of completely replace the existing one.  This design ensure all the adapters has similar look and feel on the product and prevent adopters to go off on a tangent to do an operation that is completely different operation.

I think an extension will be a cleaner design instead of doing direct API in general.  It also allow quick server type filtering.
Comment 13 Rob Stryker CLA 2013-11-08 02:53:58 EST
Please consider how this API will work when used with multiple-selection on the delete event.

We've had issues in the past with multiple-selection delete being broken.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=409475
https://bugs.eclipse.org/bugs/show_bug.cgi?id=345087
Comment 14 Alexander Silgidjian CLA 2013-11-19 07:13:49 EST
I have created an extension as discussed and uploaded it here: https://github.com/asilgidjian/webtools.servertools-344543
A test for the newly created extension is available here: https://github.com/asilgidjian/webtools.servertools.tests-344543

@Rob: With the proposed extension the adopters will receive the array of servers for which deletion is triggered. Based on that they may visualize their custom controls and perform custom cleanup logic upon deletion.
Comment 15 Alexander Silgidjian CLA 2013-12-09 09:07:18 EST
Created attachment 238161 [details]
patch
Comment 16 Alexander Silgidjian CLA 2013-12-09 09:07:58 EST
Created attachment 238162 [details]
test for the patch
Comment 17 Elson Yuen CLA 2014-01-08 14:22:17 EST
Created attachment 238790 [details]
v1.0

Thank you for submitting the patch. 

A new patch has been created based on the original suggested patch with the following changes:
1. Introduced isEnabled(), performPreDeleteAction() and performPostDeleteAction() to org.eclipse.wst.server.ui.internal.DeleteServerDialogExtension.
2. Moved DeleteServerDialogExtension to external package.
3. Changed the life cycle of DeleteServerDialogExtension.
4. Other code and extension point cleanup

Please try it out to see if it addresses all your requirements.
Comment 18 Elson Yuen CLA 2014-01-08 14:24:28 EST
Created attachment 238791 [details]
v1.0 test

Updated test patch to match the latest patch v1.0 based on the original patch on the tests.
Comment 19 Alexander Silgidjian CLA 2014-01-13 03:59:24 EST
The patch addresses all our requirements. Thanks for amending it.
Comment 20 Elson Yuen CLA 2014-01-15 12:21:37 EST
Code released to 3.6.
Comment 21 Elson Yuen CLA 2014-01-15 12:22:15 EST
Resolving as code goes to master.
Comment 22 Eclipse Genie CLA 2017-10-11 16:41:26 EDT
New Gerrit change created: https://git.eclipse.org/r/109215
Comment 23 Eclipse Genie CLA 2017-10-11 16:41:34 EDT
New Gerrit change created: https://git.eclipse.org/r/109216
Comment 24 Eclipse Genie CLA 2017-10-11 16:54:39 EDT
New Gerrit change created: https://git.eclipse.org/r/109856