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

Bug 332291

Summary: [JavaScript-Bridging] Background and Foreground color
Product: z_Archived Reporter: Tom Seidel <tom.seidel>
Component: MylynAssignee: Tom Seidel <tom.seidel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: robert.munteanu, salever
Version: unspecified   
Target Milestone: 1.6.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch with two new commands for setting the colors
none
mylyn/context/zip none

Description Tom Seidel CLA 2010-12-10 06:06:36 EST
Setting the back- and foreground color for the current selection. This two commands are TriState commands and dependent from the current selection.
Comment 1 Tom Seidel CLA 2010-12-10 08:56:02 EST
Created attachment 184954 [details]
Patch with two new commands for setting the colors
Comment 2 salever CLA 2010-12-12 01:39:00 EST
I tested the patch, and it works. Here is BackgroundAction:

public class BackgroundAction extends AbstractCommandWrapper {

	public BackgroundAction(HtmlComposer composer) {
		super("Background", IAction.AS_CHECK_BOX, composer); 
                //Missing icon...
	}

	@Override
	protected Command getWrappedCommand() {
		return new SetBackgroundColorCommand();
	}

	public void run() {

		ColorDialog dialog = new ColorDialog(this.composer.getShell());
		RGB rgb = dialog.open();
		if (rgb != null) {
			((SetBackgroundColorCommand) getWrappedCommand()).setColor(rgb);
			super.run();
		}
	}

}
Comment 3 salever CLA 2010-12-14 03:54:32 EST
(In reply to comment #2)
> I tested the patch, and it works. Here is BackgroundAction:
> 
> public class BackgroundAction extends AbstractCommandWrapper {
> 
>     public BackgroundAction(HtmlComposer composer) {
>         super("Background", IAction.AS_CHECK_BOX, composer); 
>                 //Missing icon...
>     }
> 
>     @Override
>     protected Command getWrappedCommand() {
>         return new SetBackgroundColorCommand();
>     }
> 
>     public void run() {
> 
>         ColorDialog dialog = new ColorDialog(this.composer.getShell());
>         RGB rgb = dialog.open();
>         if (rgb != null) {
>             ((SetBackgroundColorCommand) getWrappedCommand()).setColor(rgb);
>             super.run();
>         }
>     }
> 
> }

  ((SetBackgroundColorCommand) getWrappedCommand()).setColor(rgb); should be
 ((SetBackgroundColorCommand) wrappedCommand).setColor(rgb);
Comment 4 salever CLA 2010-12-16 22:55:40 EST
I tested the demo at http://ckeditor.com/demo

Under MAC OS, default browser Safari ,version 5.0.2, set background and foreground color works well. And with Firefox 3.6.13, set background and foreground color also works well.

But using CKEditor in RCP in MAC, set foreground color command behaves like set background color command.
Comment 5 Tom Seidel CLA 2011-06-30 17:08:13 EDT
I have tested this and can reproduce the problem.

There seems to be a problem with the ColorDialog in this scenario. This is not a problem of the HtmlComposer but rather a problem of SWT. I have posted already on the SWT Newsgroup with a reproducable snippet, see http://www.eclipse.org/forums/index.php/t/217160/

You have to provide your own colorchooser dialog in the action to work around this problem, the commands are working like expected.

Closing this as fixed and pushing it to the repository.
Comment 6 Tom Seidel CLA 2011-06-30 17:34:16 EDT
Created attachment 198936 [details]
mylyn/context/zip