Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 251339 - [ds tooling] Strange label selection in Service Component editor
Summary: [ds tooling] Strange label selection in Service Component editor
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Chris Aniszczyk CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-19 22:34 EDT by Simon Archer CLA
Modified: 2008-10-20 18:23 EDT (History)
2 users (show)

See Also:


Attachments
Screen shot (24.06 KB, image/png)
2008-10-19 22:34 EDT, Simon Archer CLA
no flags Details
mylyn/context/zip (1.42 KB, application/octet-stream)
2008-10-20 17:49 EDT, Benjamin Cabé CLA
no flags Details
patch (1.11 KB, patch)
2008-10-20 18:13 EDT, Benjamin Cabé CLA
caniszczyk: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Archer CLA 2008-10-19 22:34:41 EDT
Created attachment 115533 [details]
Screen shot

Using Eclipse 3.5M2 from HEAD.

Upon opening a component XML document in the Service Component editor and switching to the Source page and back to the Overview page results in the label "Specify the component's and class:" being selected.  This is strange behavior; no labels should be selected in this way.
Comment 1 Rafael Oliveira Nóbrega CLA 2008-10-20 16:39:36 EDT
hum... very, very interesting. 

We don't set this on code. It seems as a default behavior. Any insights how can I fix it?

Comment 2 Chris Aniszczyk CLA 2008-10-20 16:48:08 EDT
I've seen this happen recently too.

I am not sure why it's happening yet but it needs investigating as it is affecting all PDE editors.
Comment 3 Simon Archer CLA 2008-10-20 16:55:08 EDT
It could be the case that a bug in one of PDE's prerequisites has been fixed and that up until now PDE has been "getting away with" neglecting to do something... I'm just speculating. I must admit, selecting a label is quite peculiar.
Comment 4 Chris Aniszczyk CLA 2008-10-20 17:03:21 EDT
Well, we could override behavior of the setFocus() method in our sections...

the default behavior is this:

* (non-Javadoc)
	 * @see org.eclipse.ui.forms.AbstractFormPart#setFocus()
	 */
	public void setFocus() {
		Control client = section.getClient();
		if (client != null)
			client.setFocus();
	}

This gets trigged from the editor:
org.eclipse.pde.internal.ui.editor.PDEFormPage.updateFormSelection()

Without debugging, I have a feeling that we're simply focusing on the first control that makes sense in the editor if there hasn't been focus before. We should be a bit more intelligent of where we should focus if we didn't have focus before.
Comment 5 Rafael Oliveira Nóbrega CLA 2008-10-20 17:37:02 EDT
I tried to override the setFocus() with an empty content in DSEditor, DSOverviewPage and DSComponentSection, but have no success.

I found a comment in Control.java file, that maybe related to the problem:
public boolean forceFocus () {
.....
/*
	* This code is intentionally commented.
	*
	* When setting focus to a control, it is
	* possible that application code can set
	* the focus to another control inside of
	* WM_SETFOCUS.  In this case, the original
	* control will no longer have the focus
	* and the call to setFocus() will return
	* false indicating failure.
	* 
	* We are still working on a solution at
	* this time.
	*/
//	if (OS.GetFocus () != OS.SetFocus (handle)) return false;
.....
}


Comment 6 Benjamin Cabé CLA 2008-10-20 17:49:15 EDT
well this is indeed something not specific to DS editor.
This is due to updateFormSelection() in PDEFormPage which basically selects *any* text widget which had the focus (fLastFocusControl) while we were leaving the page we're switching back to again (ouch, is it correct english..??)
Comment 7 Benjamin Cabé CLA 2008-10-20 17:49:21 EDT
Created attachment 115635 [details]
mylyn/context/zip
Comment 8 Benjamin Cabé CLA 2008-10-20 17:54:42 EDT
Just to be convinced, just test switching from a tab to another in the manifest editor 
1/ leaving the Overview page with the focus inside a text field ==> the text fields gets selected once we come back
2/ leaving the Overview page with the focus inside the section header ==> the text "This section ....." is selected once we come back

For some obscure reason, the header text *always* gets selected in the DS UI Overview page, but it should not be very hard to find where the "fLastFocusControl" does not get updated correctly
Comment 9 Benjamin Cabé CLA 2008-10-20 18:13:36 EDT
Created attachment 115639 [details]
patch

What seems to happen is that fLastFocusControl changes just after l277 has been executed (because the form header text may get the focus when the page gets the focus, and so is *unfocused* when we ask to set the focus on the textfield).
The proposed patch just makes sure we keep working on the initial control until we're done with it
Comment 10 Chris Aniszczyk CLA 2008-10-20 18:20:03 EDT
done.

> 20091020

The fix seems fair. I can't think of any negative consequences at the moment.