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

Bug 356580

Summary: [M2x IDE Integration] Open an information dialog when code generation finished or aborted
Product: [Automotive] Sphinx Reporter: Idrissa Dieng <idydieng>
Component: CoreAssignee: Idrissa Dieng <idydieng>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: ali.akar82, stephaneberle9, yannick7777
Version: 0.7.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 356785    
Bug Blocks:    
Attachments:
Description Flags
Code Generation completed dialog information
none
Code Generation failed dialog information
none
Code Generation completed dialog information
none
Code Generation failed dialog information
none
Code Generation failed dialog information
none
Patches for xtendxpand plug-ins that add message dialog result handlers
none
Patches for xtendxpand plug-ins that add message dialog result handlers
none
Patches for xtendxpand plug-ins that add message dialog result handlers none

Description Idrissa Dieng CLA 2011-09-02 08:41:26 EDT
An information dialog should be opening after launching code generation using wizard in order to inform to end users the code generation status result (ok, error, aborded ect.)
Comment 1 Idrissa Dieng CLA 2011-09-05 09:30:47 EDT
(In reply to comment #0)
> An information dialog should be opening after launching code generation using
> wizard in order to inform to end users the code generation status result (ok,
> error, aborded ect.)

==== solution description ======
1) Add the org.eclipse.sphinx.xtendxpand.ui.dialogs.M2MMessageDialog class that extends AbstractDialog (for more details, please see atteched file that display the proposed dialog).

P.S: the "M2MMessageDialog" class name should be changed. I would found a name that will be apply both for M2M and M2T. Every idea is welcome!

2) Add a job change listener to org.eclipse.sphinx.xtendxpand.ui.wizards.M2TConfigurationWizard.doPerformFinish(IProgressMonitor).job in order to display dialog after code generation process.

3) Add a job change listener to org.eclipse.sphinx.xtendxpand.ui.wizards.M2MConfigurationWizard.doPerformFinish(IProgressMonitor).job in order to display dialog after model transformation process.
Comment 2 Idrissa Dieng CLA 2011-09-05 09:44:11 EDT
Created attachment 202753 [details]
Code Generation completed dialog information
Comment 3 Idrissa Dieng CLA 2011-09-05 09:44:40 EDT
Created attachment 202754 [details]
Code Generation failed dialog information
Comment 4 Idrissa Dieng CLA 2011-09-05 10:22:37 EDT
Created attachment 202761 [details]
Code Generation completed dialog information
Comment 5 Idrissa Dieng CLA 2011-09-05 10:25:32 EDT
Created attachment 202762 [details]
Code Generation failed dialog information
Comment 6 Idrissa Dieng CLA 2011-09-05 11:55:45 EDT
Created attachment 202766 [details]
Code Generation failed dialog information
Comment 7 Stephan Eberle CLA 2011-09-06 04:50:55 EDT
(In reply to comment #0)
> An information dialog should be opening after launching code generation using
> wizard in order to inform to end users the code generation status result (ok,
> error, aborded ect.)

We must be careful with that sort of user guidance. Many people just find it annoying if there are too many dialogs popping up here and there. I'm not against introducing support for that in Sphinx. However, it must not be hardcoded but kept customizable by clients. As default in Sphinx I'd say that we display a message dialog when an error has happend (code generation/model transformation failed or checks done before failed) but do NOT display anything when the code generation/model transformation completes successfully or has been cancelled by the user.
Comment 8 Stephan Eberle CLA 2011-09-06 05:01:43 EDT
(In reply to comment #1)
> ==== solution description ======
> 1) Add the org.eclipse.sphinx.xtendxpand.ui.dialogs.M2MMessageDialog class that
> extends AbstractDialog (for more details, please see atteched file that display
> the proposed dialog).

Just for my understanding: Why do you believe that a custom dialog class is necessary? Wouldn't a simple usage of org.eclipse.jface.dialogs.MessageDialog be sufficient?

> P.S: the "M2MMessageDialog" class name should be changed. I would found a name
> that will be apply both for M2M and M2T. Every idea is welcome!

M2MMessageDialog => M2xMessageDialog
 
> 2) Add a job change listener to
> org.eclipse.sphinx.xtendxpand.ui.wizards.M2TConfigurationWizard.doPerformFinish(IProgressMonitor).job
> in order to display dialog after code generation process.
> 
> 3) Add a job change listener to
> org.eclipse.sphinx.xtendxpand.ui.wizards.M2MConfigurationWizard.doPerformFinish(IProgressMonitor).job
> in order to display dialog after model transformation process.

These job listeners should be implemented in a similar way as the org.eclipse.sphinx.xtendxpand.jobs.SaveAsNewFileHandler. As name I suggest ResultMessageHandler. The constructor should offer parameters for specifying when the message is to be displayed (on errors only, on errors and completion and cancellation, etc.). Maybe a bit field plus appropriate constants would be a neat solution here.

For their installation in the perfomFinish() methods of the wizards we should introduce a overridable createResultMessageHandler() factory method in which applications can customize the result message behavior.
Comment 9 Idrissa Dieng CLA 2011-09-06 05:14:32 EDT
(In reply to comment #8)
> (In reply to comment #1)
> > ==== solution description ======
> > 1) Add the org.eclipse.sphinx.xtendxpand.ui.dialogs.M2MMessageDialog class that
> > extends AbstractDialog (for more details, please see atteched file that display
> > the proposed dialog).
> 
> Just for my understanding: Why do you believe that a custom dialog class is
> necessary? Wouldn't a simple usage of org.eclipse.jface.dialogs.MessageDialog
> be sufficient?
I was just to add the icon (information or error) and the link to open console that contains more log information. In Sphinx, I aggree just a MessageDialog can be suffisant. 
> 
> > P.S: the "M2MMessageDialog" class name should be changed. I would found a name
> > that will be apply both for M2M and M2T. Every idea is welcome!
> 
> M2MMessageDialog => M2xMessageDialog

OK thanks!
> 
> > 2) Add a job change listener to
> > org.eclipse.sphinx.xtendxpand.ui.wizards.M2TConfigurationWizard.doPerformFinish(IProgressMonitor).job
> > in order to display dialog after code generation process.
> > 
> > 3) Add a job change listener to
> > org.eclipse.sphinx.xtendxpand.ui.wizards.M2MConfigurationWizard.doPerformFinish(IProgressMonitor).job
> > in order to display dialog after model transformation process.
> 
> These job listeners should be implemented in a similar way as the
> org.eclipse.sphinx.xtendxpand.jobs.SaveAsNewFileHandler. As name I suggest
> ResultMessageHandler. The constructor should offer parameters for specifying
> when the message is to be displayed (on errors only, on errors and completion
> and cancellation, etc.). Maybe a bit field plus appropriate constants would be
> a neat solution here.

yes!
I see also when check fails we return a cancel status. I think we should distinct cancel and checks done before failed in order to display relevant information.
> 
> For their installation in the perfomFinish() methods of the wizards we should
> introduce a overridable createResultMessageHandler() factory method in which
> applications can customize the result message behavior.

YES
Comment 10 Stephan Eberle CLA 2011-09-06 07:27:41 EDT
(In reply to comment #9)
> > Just for my understanding: Why do you believe that a custom dialog class is
> > necessary? Wouldn't a simple usage of org.eclipse.jface.dialogs.MessageDialog
> > be sufficient?
> I was just to add the icon (information or error) and the link to open console
> that contains more log information. In Sphinx, I aggree just a MessageDialog
> can be suffisant. 

Then let's go us this way and not add any extra dialog classes to Sphinx for that purpose. I.e., the ResultMessageHandler should just open standard MessageDialogs and applications are free to come up with their own subclass of ResultMessageHandler which they bend to whatever message dialog they like.

> I see also when check fails we return a cancel status. I think we should
> distinct cancel and checks done before failed in order to display relevant
> information.

I agree. You have however to be careful because automatically Eclipse opens a message dialog with a status message as soon as you return an error status from a job. So we have to find a way to indicate Check errors/warnings without returning IStatus.ERROR from the job to avoid two message dialogs popping up.

I would say that this can be done by leaving the implementation of the jobs in the performFinish() as it is and provide an abstract implementation of the ResultMessageHandler which evaluates if the CheckJob has had errors/warnings or not. Implies that the ResultMessageHandler gets an instance of CheckJob and XtendJob/XpandJob for that purpose (just as SaveAsNewFileHandler gets an instance of XtendJob).
Comment 11 Idrissa Dieng CLA 2011-09-07 04:16:25 EDT
Created attachment 202861 [details]
Patches for xtendxpand plug-ins that add message dialog result handlers
Comment 12 Idrissa Dieng CLA 2011-09-07 04:35:22 EDT
> Created attachment 202861 [details]
> Patches for xtendxpand plug-ins that add message dialog result handlers

This patch includes:

 *Ase M2TJob and M2MJob in perform finish of M2x configuration wizards. In these job, if check job ends with errors imply returning cancel status.
 *Add the ResultMessageHandler class which evaluates if the CheckJob ends errors/warnings or not. 
  ** If the CheckJob ends with errors then open a mesage dialog that indicated check failed message is displayed.
  ** When the message is to be displayed only on errors and m2x job ends with errors then a mesage dialog that indicated error status message is displayed.
  ** When the message is to be displayed on errors or completion or cancellation and m2x job ends with errors or completed or cancelled then a mesage dialog that indicated status message is displayed.

> I agree. You have however to be careful because automatically Eclipse opens a
> message dialog with a status message as soon as you return an error status from
> a job. So we have to find a way to indicate Check errors/warnings without
> returning IStatus.ERROR from the job to avoid two message dialogs popping up.
> 

I sugger to not open a message dialog when M2x job end with error because as you said Eclipse automatically  opens a message dialog with a status message as soon as we return an error status.

If OK, I will adapt proposed patch in order to display only message dialog:
 - if check failed
 - if completed or cancelled When the message is to be displayed on completion or cancellation and m2x job ends completed or cancelled.
Comment 13 Idrissa Dieng CLA 2011-09-07 08:34:36 EDT
Created attachment 202887 [details]
Patches for xtendxpand plug-ins that add message dialog result handlers
Comment 14 Idrissa Dieng CLA 2011-09-07 11:14:56 EDT
Created attachment 202905 [details]
Patches for xtendxpand plug-ins that add message dialog result handlers

Last patch take into account Comment 10 and 12 in order to avoid opening 2 dialogs when M2x job ends with error status.
Comment 15 Idrissa Dieng CLA 2011-09-13 06:20:12 EDT
Fixed as following:

As default in Sphinx we display a message dialog when an error has happend:
 * Code generation/model transformation failed or 
 * Check done before failed

If M2x failed the Eclipse automatically  opens a message dialog with a status message.

If check done before fails then we open explicitity a message dialog with error message (because in M2x jobs we return a cancel status when check fails)

Client should use the relevant ResultMessageHandler constructor for displaying message dialog on completion or/and cancellation also.
Comment 16 Balazs Grill CLA 2021-07-14 02:14:28 EDT
Mass-closing Resolved tickets