Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318966 - In a RCP application, copy (resp. paste) to a Swing JTextField fails
Summary: In a RCP application, copy (resp. paste) to a Swing JTextField fails
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-06 04:25 EDT by Billout CLA
Modified: 2022-02-15 19:56 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Billout CLA 2010-07-06 04:25:11 EDT
Build Identifier: 20100218-1602

Hi,

I create a RCP projet from "example with a one view". I replace the swt code in View.java by a JPanel that contains a JLabel and a JTextField  (see the program below).
I run the application under Eclipse 
  - if I paste a text into the JTextField with CTRL V the paste operation fails : none character appears in the JTextField.
  - if some characters are present in the JTextField, I copy these characters with CTRL V, and I paste into a notepad then nothing occurs in the notepad.


My plateform
- Windows XP Pro, service pack 2 
- Eclipse 3.5.2
 
The same bugs occur with Windows XP Pro, service pack 3


package hello;

import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {
	public static final String ID = "Hello.view";

	private Composite fTop = null;
	private Composite fComposite = null;
	
	private java.awt.Frame fFrame = null;
	private JScrollPane fScrollPane = null; 

	/**
	 * The content provider class is responsible for providing objects to the
	 * view. It can wrap existing objects in adapters or simply return objects
	 * as-is. These objects may be sensitive to the current input of the view,
	 * or ignore it and always show the same content (like Task List, for
	 * example).
	 */
	class ViewContentProvider implements IStructuredContentProvider {
		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
		}

		public void dispose() {
		}

		public Object[] getElements(Object parent) {
			return new String[] { "One", "Two", "Three" };
		}
	}

	class ViewLabelProvider extends LabelProvider implements
			ITableLabelProvider {
		public String getColumnText(Object obj, int index) {
			return getText(obj);
		}

		public Image getColumnImage(Object obj, int index) {
			return getImage(obj);
		}

		public Image getImage(Object obj) {
			return PlatformUI.getWorkbench().getSharedImages().getImage(
					ISharedImages.IMG_OBJ_ELEMENT);
		}
	}

	/**
	 * This is a callback that will allow us to create the viewer and initialize
	 * it.
	 */
	public void createPartControl(Composite parent) {
		fTop = new Composite(parent, SWT.NONE);
		fTop.setBackground(new Color(Display.getCurrent(), 195, 212, 232));
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		fTop.setLayout(gridLayout);
				
		createComposite();
	}

	private void createComposite(){
		GridData gridData = new org.eclipse.swt.layout.GridData();
		gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		fComposite = new Composite(fTop, SWT.EMBEDDED);
		fComposite.setLayout(new GridLayout());
		fComposite.setLayoutData(gridData);		
		fFrame = SWT_AWT.new_Frame(fComposite);
		fScrollPane = new JScrollPane();
		fScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		fScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		fFrame.add(fScrollPane) ;
		JPanel panel = new JPanel() ;
		panel.setLayout(new FlowLayout()) ;
		panel.add(new JLabel("Nom:")) ;
		panel.add(new JTextField("saisir le nom")) ;
		
		fScrollPane.setViewportView(panel);
		fFrame.add(fScrollPane) ;
	}
	
	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		//viewer.getControl().setFocus();
	}
}


Reproducible: Always

Steps to Reproduce:
1.launch the RCP¨application in Eclipse 
2. run a notepad and copy some characters with CTRL C
3. paste with CTRL V the clipboard contents into the JTextField of the RCP application
Comment 1 Billout CLA 2010-07-06 04:31:36 EDT
I use sun jdk 1.5.06 and sun jdk 1.5.22
The same bugs appear.
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:08:21 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 3 Eclipse Genie CLA 2022-02-15 19:56:59 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.