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

Bug 167866

Summary: make Bugzilla URL link clickable
Product: z_Archived Reporter: sam <s.marshall>
Component: MylynAssignee: Eugene Kuleshov <ekuleshov>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, robert.elves, wmitsuda
Version: unspecified   
Target Milestone: 3.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed patch
none
mylyn/context/zip
none
updated patch
none
mylyn/context/zip
none
wrong source viewer rendering none

Description sam CLA 2006-12-13 10:51:14 EST
(I am using whatever Mylar version you get if you download today. Eclipse 'About' box gives it as version 1.0.0, but that isn't listed in the version box above.)

When viewing a bug from Bugzilla it displays the URL field as an edit box, which is fine. 

However it would be nice if the label ('URL') next to the field was an underlined, clickable link which would launch the user's default browser [as per Eclipse preferences].

Current use:

1) View bug
2) Expand 'Attributes'
3) Click in URL field
4) Press Ctrl-A, Ctrl-C
5) Switch to external browser program
6) Open new window or tab
7) Press Ctrl-V, Return
(Now viewing URL in preferred browser)

Use after proposal implemented:

1) View bug
2) Expand 'Attributes'
3) Click the underlined label 'URL'
(URL launches in preferred browser)
Comment 1 Willian Mitsuda CLA 2006-12-13 11:38:11 EST
+1
Comment 2 Mik Kersten CLA 2006-12-13 12:25:51 EST
Rob: do we already have a bug for this?
Comment 3 Robert Elves CLA 2006-12-13 13:09:40 EST
Lets keep this one open to target that field specifically. But both the url field and the summary field will be hyperlinked as soon as I convert them over to our viewer widget (pending resolution of layout issues). (summary field is bug#155278).
Comment 4 Eugene Kuleshov CLA 2007-09-13 23:07:35 EDT
Created attachment 78400 [details]
proposed patch

This makes url field in bugzilla clickable. 

Someone may want to do some refactoring for addTextEditor() methods to reuse change listeners and incoming decoration as in addTextField()...
Comment 5 Eugene Kuleshov CLA 2007-09-13 23:07:37 EDT
Created attachment 78401 [details]
mylyn/context/zip
Comment 6 Mik Kersten CLA 2007-09-21 20:36:05 EDT
Patch reviewed but not applied.  With my testing this had the regression of not setting the incoming background color.  There appears to be a bit of blue background added, but the text is not blue.  

Also, this changes the visual style of the URL box not to match the others.  As that may be necessary, I wonder if it's position in the Attributes section should be moved to preserve visual consistency.
Comment 7 Eugene Kuleshov CLA 2007-09-24 18:55:53 EDT
(In reply to comment #6)
> Patch reviewed but not applied.  With my testing this had the regression of not
> setting the incoming background color.  There appears to be a bit of blue
> background added, but the text is not blue.

Right. It seems like this is result of hyperlinking/annotation decoration coloring and after quick look I couldn't figure out how to get around that.

> Also, this changes the visual style of the URL box not to match the others.  As
> that may be necessary, I wonder if it's position in the Attributes section
> should be moved to preserve visual consistency.

Mik, can you please elaborate about visual style and/or post screenshot of what you mean? 
If you are speaking about hyperlink presentation that is underlined/activated by default with this change, that supposed to be tracked on bug 203399

Speaking of consistency, I just discovered that there is a hidden time management subsection in Bugzilla editor that is not visible on eclipse.org bugzilla. Note that this hidden section is NOT using flat form look and the whole section don't seem to belong under Attributes section.
Comment 8 Mik Kersten CLA 2007-09-24 21:35:52 EDT
By "visual style" I meant that the box for entering the value looked different than the other boxes.  I wasn't citing that as a problem per se, because this box now had additional functionality, just saying that if it's going to look inconsistent it should be moved.

That hidden attributes section only works if time tracking is enabled on the Bugzilla repository.
Comment 9 Eugene Kuleshov CLA 2007-09-24 21:47:14 EDT
 (In reply to comment #8)
> By "visual style" I meant that the box for entering the value looked different
> than the other boxes.  I wasn't citing that as a problem per se, because this
> box now had additional functionality, just saying that if it's going to look
> inconsistent it should be moved.

Can you please post screenshot of that? I don't see any visual difference in Eclipse 3.3 and Win XP

> That hidden attributes section only works if time tracking is enabled on the
> Bugzilla repository.

I know that, but that ain't an excuse for not using SWT.FLAT :-)
Comment 10 Robert Elves CLA 2007-10-05 00:43:21 EDT
My 10minutes weren't enough to get the background to change properly either.

Willian: do you know the trick to this?

Also note that instead of making colorIncoming protected you can just use getColorIncoming().
Comment 11 Eugene Kuleshov CLA 2007-10-05 23:17:28 EDT
Created attachment 79842 [details]
updated patch

Rob, here is updated patch for conflicting changes in CVS and with cahnge you suggested. Issue with the background is still not resolved.

Daniel, I am sorry to bother you, but maybe you can give us a hint?

There is a SourceViewer with spellchecking decoration and standard hyperlinking enabled and we need to set non white background on that widget. 
We tried to get text control and then use setBackground() method, but that doesn't work and it seem like background is covered by something that is drawing decoration over that control.

SourceViewer is created in org.eclipse.mylyn.tasks.ui.editors.TaskFormPage.addTextEditor() method. There is also Mylyn context attached that include relevant classes.
Comment 12 Eugene Kuleshov CLA 2007-10-05 23:17:32 EDT
Created attachment 79843 [details]
mylyn/context/zip
Comment 13 Dani Megert CLA 2007-10-08 04:19:17 EDT
>We tried to get text control and then use setBackground() method, 
This should work i.e. the source and text viewers don't set the background color - that's at the level of editors. Maybe the text is selected and hence you don't see  your color? Maybe you added an annotation and it draws on top of it?
Comment 14 Eugene Kuleshov CLA 2007-10-08 15:42:13 EDT
Thanks Daniel, I also though that it could be something with decorations, but I am not sure how to debug that. Do you know if there are any limitations around using multiple source viewers within same form?

Rob, I tried to look at it again and now I am totally puzzled. If you look at the summary field, which is created using the same TaskFormPage.addTextedtior() method as I used for url field, so code is identical. But then summary field is rendered just fine (you can stick url to summary to verify that it is highlighted properly), but for url field we have this weird rendering where only thin border is around url field is being highlighted.
Comment 15 Dani Megert CLA 2007-10-09 02:59:15 EDT
Hi Eugene,

what does #addTextEditor do? Is it maybe adding a LineBackgroundListener or LineStyleListener? Here are two interesting points to start debugging:
- org.eclipse.swt.custom.StyledText.handlePaint(Event)
- org.eclipse.swt.custom.StyledTextRenderer.getLineBackground(int, Color)
Comment 16 Eugene Kuleshov CLA 2007-10-09 10:13:45 EDT
Created attachment 79954 [details]
wrong source viewer rendering

(In reply to comment #15)
> what does #addTextEditor do? Is it maybe adding a LineBackgroundListener or
> LineStyleListener? 

It creates initialized instance of the SourceViewer. You can look at the source code at http://tinyurl.com/3a8hk7

> Here are two interesting points to start debugging:
> - org.eclipse.swt.custom.StyledText.handlePaint(Event)
> - org.eclipse.swt.custom.StyledTextRenderer.getLineBackground(int, Color)

I checked those and can see that my widget has the right background color in handlePaint() and getLineBackground() returns the same color, but widget is drawn with the white background. On attached screenshot you can see that summary text is rendered correctly with blue background, but "URL" field only have 1px thin blue border instead of the solid blue background.
Comment 17 Dani Megert CLA 2007-10-09 11:33:28 EDT
It could be the cursor line painter (depending on which source viewer config and which prefs you use).
Comment 18 Eugene Kuleshov CLA 2007-10-09 14:26:55 EDT
 (In reply to comment #17)
> It could be the cursor line painter (depending on which source viewer config and
> which prefs you use).

Can you give me a pointer how to trace cursor line painter? BTW, widget is created with SWT.SINGLE

This viewer config is a subclass of org.eclipse.ui.editors.text.TextSourceViewerConfiguration http://tinyurl.com/26mvzz and it gets preferences from the EditorsUI.getPreferenceStore()
Comment 19 Dani Megert CLA 2007-10-10 03:27:34 EDT
>Can you give me a pointer how to trace cursor line painter?
  org.eclipse.jface.text.CursorLinePainter.lineGetBackground(LineBackgroundEvent)
But this will only play a role if you've also setup source viewer decoration support along with the correct preference keys i.e. called org.eclipse.ui.texteditor.SourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(String, String)

>BTW, widget is created with SWT.SINGLE
You're probably the first one to try this out with a viewer ;-)
Try without and see what happens.
Comment 20 Eugene Kuleshov CLA 2007-11-02 15:18:17 EDT
I give up on this. Can't make it work
Comment 21 Willian Mitsuda CLA 2007-11-02 19:49:08 EDT
I found why it is not working. For some reason, the color settings from enclosing Section widget is interfering with TextViewer background color setting.

Just for testing, if you apply the following patch after applying Eugene's one, it will work as expected. If you use ExpandableComposite.TITLE_BAR style on FormToolkit.createSection, it triggers a lot of color settings I was not able to understand yet.

### Eclipse Workspace Patch 1.0
#P org.eclipse.mylyn.tasks.ui
Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java,v
retrieving revision 1.241
diff -u -r1.241 AbstractRepositoryTaskEditor.java
--- src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java	26 Oct 2007 03:36:28 -0000	1.241
+++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java	2 Nov 2007 23:37:17 -0000
@@ -2492,7 +2492,7 @@
 	}
 
 	protected Section createSection(Composite composite, String title) {
-		Section section = toolkit.createSection(composite, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
+		Section section = toolkit.createSection(composite, Section.TWISTIE);
 		section.setText(title);
 		section.setExpanded(true);
 		section.setLayout(new GridLayout());

Daniel, can you explain how a parent color setting (in this case, a form toolkit Section widget) may interfere in a child TextViewer rendering?

The following sample view reproduces the same situation with minimum code:

public class SampleView extends ViewPart {

	private SourceViewer viewer;

	@Override
	public void createPartControl(Composite parent) {
		ManagedForm mf = new ManagedForm(parent);
		mf.getForm().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
		
		Composite body = mf.getForm().getBody();
		body.setLayout(new GridLayout());
		
		Section section = mf.getToolkit().createSection(body, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
		section.setText("Test");
		Composite composite = mf.getToolkit().createComposite(section, SWT.NONE);
		composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
		composite.setLayout(new GridLayout());
		section.setClient(composite);
		
		viewer = new SourceViewer(composite, null, SWT.NONE);
		viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
		
		viewer.configure(new TextSourceViewerConfiguration());
		Document doc = new Document("bababa\rbobobo");
		viewer.setDocument(doc);
		viewer.getControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
	}

	@Override
	public void setFocus() {
		viewer.getControl().setFocus();
	}
}

This view contains a TextViewer with a green background inside a expandable section. It will only be rendered with the green background if you remove ExpandableComposite.TITLE_BAR from "Section section = mf.getToolkit().createSection(..." call.
Comment 22 Robert Elves CLA 2008-04-05 19:37:46 EDT
Just revisited this and seems to work now (background colour being set properly).  Fixed layout (width) issue.
Comment 23 Robert Elves CLA 2008-04-05 19:38:06 EDT
Fixed
Comment 24 Eugene Kuleshov CLA 2008-04-05 20:07:27 EDT
 (In reply to comment #22)
> Just revisited this and seems to work now (background colour being set
> properly).  Fixed layout (width) issue.

Thats great Rob! Did you had a chance to check it with both Eclispe 3.3 and 3.4?
Comment 25 Robert Elves CLA 2008-04-08 20:10:34 EDT
Tested fine on 3.4, still fails on 3.3 (note added to code warning not to backport to 3.3).