Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349017 - HtmlComposer sometimes not initialised
Summary: HtmlComposer sometimes not initialised
Status: CLOSED MOVED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Tom Seidel CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-10 08:44 EDT by Robert Munteanu CLA
Modified: 2012-03-08 10:12 EST (History)
0 users

See Also:


Attachments
My Eclipse configuration (382.10 KB, text/plain)
2011-06-17 08:25 EDT, Robert Munteanu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Munteanu CLA 2011-06-10 08:44:45 EDT
While testing the HtmlComposer embedded in the Task Editor of the MantisBT Mylyn connector I've noticed that the editors sometimes initialise with no content. I have 4 composers rendered in a single task editor page, and sometimes some of them do not get initialised. I am unable to reproduce this behaviour on Windows or Linux.

By adding debug statements I have discovered that init() is not called for the editors that remain blank.

Here's some debugging output:

Setting the data using 'setHtml':

pre. 
Added integration.editor.setData('<b>description</b><br/><ol>  <li>   First</li>  <li>   Second</li>  <li>   Third</li> </ol> Bla bla bla<br/><ul>  <li>   Line</li>  <li>   Another line</li>  <li>   Yet another line</li> </ul>'); as pending
Added integration.editor.setData('<b>steps_to_reproduce</b><br/>'); as pending
Added integration.editor.setData('<b>additional_information</b><br/>'); as pending
Added integration.editor.setData('<b>new_comment</b><br/>'); as pending

First editor get initialised

pre. 
At init got 1 pending commands
Executing integration.pendingCommandIdentifier = '1307709358770676000';
Executing integration.editor.setData('<b>description</b><br/><ol>  <li>   First</li>  <li>   Second</li>  <li>   Third</li> </ol> Bla bla bla<br/><ul>  <li>   Line</li>  <li>   Another line</li>  <li>   Yet another line</li> </ul>');

Second editor getting initialised

pre. 
At init got 1 pending commands
Executing integration.pendingCommandIdentifier = '1307709358884411000';
Executing integration.editor.setData('<b>additional_information</b><br/>');

Third editor getting initialised

pre. 
At init got 1 pending commands
Executing integration.pendingCommandIdentifier = '1307709358985044000';
Executing integration.editor.setData('<b>steps_to_reproduce</b><br/>');

The fourth one does not get initialised.
Comment 1 Tom Seidel CLA 2011-06-10 09:18:45 EDT
Could you attach a minimalistic snippet for reproducing?
Comment 2 Robert Munteanu CLA 2011-06-10 09:36:23 EDT
I don't do anything exotic, but here's my simplified code nonetheless . Code might look a little strange since I've eliminated some paths which end up not instantiating the HtmlComposer, but just a simple Browser widget.

pre..     
            Control control;
            String value = /* get value */ null;
            
                CoolBar coolbar = new CoolBar(parent, SWT.NONE);
                GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                coolbar.setLayoutData(gd);

                ToolBar menu = new ToolBar(coolbar, SWT.HORIZONTAL | SWT.FLAT);
                ToolBarManager manager = new ToolBarManager(menu);
                CoolItem item = new CoolItem(coolbar, SWT.NONE);
                item.setControl(menu);
                
                Configuration configuration = new Configuration();
                configuration.addConfigurationNode(new EnterModeConfiguration(EnterMode.BR));

                composer = new HtmlComposer(parent, SWT.None, configuration);

                manager.add(new BoldAction(composer));
                manager.add(new ItalicAction(composer));
                manager.add(new PreformatAction(composer));
                manager.add(new UnderlineAction(composer));
                manager.add(new Separator());
                manager.add(new BulletlistAction(composer));
                manager.add(new NumlistAction(composer));

                manager.update(true);

                composer.setHtml(value);
                GridDataFactory.fillDefaults().applyTo(composer.getBrowser());

                composer.addModifyListener(new ModifyListener() {

                    public void modifyText(ModifyEvent e) {

                        String oldValue = getAttributeMapper().getValue(getTaskAttribute());

                        String newValue = HtmlFormatter.convertFromDisplayHtml(composer.getHtml());

                        getAttributeMapper().setValue(getTaskAttribute(), newValue);

                        if ( !newValue.equals(oldValue) )
                            attributeChanged();
                    }
                });
            
            setControl(control);
Comment 4 Tom Seidel CLA 2011-06-12 07:19:37 EDT
I've tried the following snippet under Max OSX 10.6 with Eclipse 3.6.2 Cocoa and it worked so far. Could you please test the snippet on your system for a further isolation of a possible issue?

public void createPartControl(Composite parent) {
	
	final Composite comp = new Composite(parent, SWT.NO_FOCUS);
	comp.setLayout(new GridLayout(1, false));
	comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));


	Configuration configuration = new Configuration();
	configuration.addConfigurationNode(new EnterModeConfiguration(
			EnterMode.BR));

	CoolBar coolbar = new CoolBar(comp, SWT.NONE);
	GridData gd_cool = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
	coolbar.setLayoutData(gd_cool);

	ToolBar menu = new ToolBar(coolbar, SWT.HORIZONTAL | SWT.FLAT);
	ToolBarManager manager = new ToolBarManager(menu);

	CoolItem item = new CoolItem(coolbar, SWT.NONE);
	item.setControl(menu);

	HtmlComposer comp1 = new HtmlComposer(comp, SWT.NONE, configuration);
	comp1.setHtml("<b>description</b><br/><ol>  <li>  \n"
			+ "First</li>  <li>   Second</li>  <li>   Third</li> </ol> Bla bla bla<br/><ul> \n"
			+ "<li>   Line</li>  <li>   Another line</li>  <li>   Yet another line</li>\n"
			+ "</ul>");
	GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	

	manager.add(new BoldAction(comp1));
	manager.add(new ItalicAction(comp1));

	manager.add(new UnderlineAction(comp1));
	manager.add(new Separator());
	manager.add(new BulletlistAction(comp1));
	manager.add(new NumlistAction(comp1));

	manager.update(true);

	HtmlComposer comp2 = new HtmlComposer(comp, SWT.NONE, configuration);
	comp2.setHtml("<b>additional_information</b><br/>");

	HtmlComposer comp3 = new HtmlComposer(comp, SWT.NONE, configuration);
	comp3.setHtml("<b>steps_to_reproduce</b><br/>");

	HtmlComposer comp4 = new HtmlComposer(comp, SWT.NONE, configuration);
	comp4.setHtml("<b>steps_to_reproduce4</b><br/>");
	comp1.setLayoutData(gd);
	comp2.setLayoutData(gd);
	comp3.setLayoutData(gd);
	comp4.setLayoutData(gd);
}
Comment 5 Robert Munteanu CLA 2011-06-17 08:24:28 EDT
Sorry for the delay, I don't usually run Mac OS , but I had the change to try out your code. I simply replaced the existing method in the example application attached to bug #319018 and executed it. It randomly fails for me, with some of the composers being initialised as empty. I will attach my Eclipse configuration and will try to upload a video of what goes on, perhaps it will give you some hints.
Comment 6 Robert Munteanu CLA 2011-06-17 08:25:49 EDT
Created attachment 198174 [details]
My Eclipse configuration
Comment 7 Robert Munteanu CLA 2011-06-17 09:01:57 EDT
Please find below a link to a video of my attempts using the RPC app. The first four attempts succeeded, but the fifth ended up with one uninitialised composer. The success rate is much higher compared to using the composer in Eclipse, which makes me believe that it is somehow related to timing.

http://dl.dropbox.com/u/11860058/htmlcomposer-error.mp4
Comment 8 Tom Seidel CLA 2011-08-14 06:51:56 EDT
I was able to reproduce this problem, although it is not real reproducable, occurs randomly. I'm afraid this is a problem of the underlying browser-bridge. I'll investigate further on the JavaScript-side but currently I have no idea what the problem could be.
In addition I'll try the latest ckeditor implementation, maybe that helps..
Comment 9 Robert Munteanu CLA 2011-09-27 07:09:50 EDT
(In reply to comment #8)
> I was able to reproduce this problem, although it is not real reproducable,
> occurs randomly. I'm afraid this is a problem of the underlying browser-bridge.
> I'll investigate further on the JavaScript-side but currently I have no idea
> what the problem could be.
> In addition I'll try the latest ckeditor implementation, maybe that helps..

What would an update involve? If it's just overwriting the contents of the ckeditor with the latest version I will give it a try.
Comment 10 Tom Seidel CLA 2011-09-27 17:32:11 EDT
(In reply to comment #9)
> (In reply to comment #8)
> > I was able to reproduce this problem, although it is not real reproducable,
> > occurs randomly. I'm afraid this is a problem of the underlying browser-bridge.
> > I'll investigate further on the JavaScript-side but currently I have no idea
> > what the problem could be.
> > In addition I'll try the latest ckeditor implementation, maybe that helps..
> 
> What would an update involve? If it's just overwriting the contents of the
> ckeditor with the latest version I will give it a try.

Overwriting the contents of this folder should be enough...
Comment 11 Robert Munteanu CLA 2011-09-28 08:36:37 EDT
After doing a quick spike with WikiText I've decided to go that route instead, as I feel that there are less 'moving parts' out of my control - the SWT Browser widget, CKEditor - and therefore won't be investigating the upgrade.
Comment 12 Eclipse Webmaster CLA 2022-11-15 11:45:08 EST
Mylyn has been restructured, and our issue tracking has moved to GitHub [1].

We are closing ~14K Bugzilla issues to give the new team a fresh start. If you feel that this issue is still relevant, please create a new one on GitHub.

[1] https://github.com/orgs/eclipse-mylyn