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

Bug 390924

Summary: Pressing enter calls the @Focus Method
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Eric Moffatt <emoffatt>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: emoffatt, jpetrakis, Lars.Vogel, mailings, nobody, pwebster, t.s.maeder, tom.schindl
Version: 4.2   
Target Milestone: 4.2.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Lars Vogel CLA 2012-10-02 08:27:04 EDT
I think we have a regression in Eclipse 4.2.1. 

If I define a user interface and press [ENTER] in a text field the @Focus method is called.

Example: Create the following part and press enter in one of the Text fields, e.g. the one defined with SWT.MULTI

Let me know if you need a complete example, I can upload one.
--------------


package com.example.e4.rcp.ui.parts;

import javax.annotation.PostConstruct;

import org.eclipse.e4.ui.di.Focus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class TodoDetailsPart {
	private Text text;
	private Text text_1;
	private Text text_2;
	private DateTime dateTime;
	private Button btnClickMe;
	private Label lblNewLabel_2;

	@PostConstruct
	public void buildUi(Composite parent) {
		parent.setLayout(new GridLayout(2, false));
		
		Label lblSummary = new Label(parent, SWT.NONE);
		lblSummary.setText("Summary");
		
		text = new Text(parent, SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		new Label(parent, SWT.NONE);
		
		lblNewLabel_2 = new Label(parent, SWT.NONE);
		lblNewLabel_2.setText("New Label");
		
		Label lblNewLabel = new Label(parent, SWT.NONE);
		lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblNewLabel.setText("Description");
		
		text_1 = new Text(parent, SWT.BORDER| SWT.MULTI);
		GridData gd_text_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gd_text_1.heightHint = 92;
		text_1.setLayoutData(gd_text_1);
		
		Label lblNewLabel_1 = new Label(parent, SWT.NONE);
		lblNewLabel_1.setText("Stuff");
		
		text_2 = new Text(parent, SWT.BORDER);
		text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		new Label(parent, SWT.NONE);
		
		dateTime = new DateTime(parent, SWT.BORDER);
		
		btnClickMe = new Button(parent, SWT.CHECK);
		btnClickMe.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
			}
		});
		btnClickMe.setText("Click me");
		new Label(parent, SWT.NONE);

	}

	@Focus
	public void focus() {
		btnClickMe.setFocus();
	}
}
Comment 1 Nobody - feel free to take it CLA 2012-10-02 09:30:12 EDT
This only happens in 421 and not in 42?
Comment 2 Nobody - feel free to take it CLA 2012-10-02 10:33:16 EDT
Moreover if there's no @Focus method it breaks spectacularly.
Comment 3 Nobody - feel free to take it CLA 2012-10-02 10:40:03 EDT
I think
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=7e4f7fe862a8927af779392e2478906c30695916 introduced this regression.
Comment 4 Nobody - feel free to take it CLA 2012-10-02 11:33:20 EDT
Created attachment 221782 [details]
Proposed fix

Patch
Comment 5 Eric Moffatt CLA 2012-10-02 13:19:05 EDT
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=d609fcbea6e6a33dd8213befd7e9553a8af9d954

Applied the patch ! Thanks guys...

BTW, sorry Sopot but I keep forgetting to change the 'Author' field when doing my commits...I'll try to get better at this
Comment 6 Eric Moffatt CLA 2012-10-02 13:19:24 EDT
Marking as FIXED...
Comment 7 Eric Moffatt CLA 2012-10-02 13:19:41 EDT
Really this time ;-)
Comment 8 Lars Vogel CLA 2012-10-02 13:21:24 EDT
@Eric, you can use git --amend (also available in EGit) to change the last commit, e.g. to change the author of the patch.
Comment 9 Nobody - feel free to take it CLA 2012-10-02 18:18:31 EDT
(In reply to comment #5)
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?h=R4_2_maintenance&id=d609fcbea6e6a33dd8213befd7e9553a8af9d954
> 
> Applied the patch ! Thanks guys...
> 
> BTW, sorry Sopot but I keep forgetting to change the 'Author' field when
> doing my commits...I'll try to get better at this

Np
Comment 10 Nobody - feel free to take it CLA 2012-10-17 08:04:25 EDT
*** Bug 392150 has been marked as a duplicate of this bug. ***
Comment 11 Nobody - feel free to take it CLA 2012-10-19 13:28:09 EDT
*** Bug 391830 has been marked as a duplicate of this bug. ***
Comment 12 Eric Moffatt CLA 2013-01-25 14:35:37 EST
Verified in M20130124-1700.