Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Clipboard issue in RAP environment
Clipboard issue in RAP environment [message #1857748] Thu, 23 February 2023 23:43 Go to next message
Kunok Joung is currently offline Kunok JoungFriend
Messages: 7
Registered: February 2023
Junior Member
We are implementing a feature that copies text data to the clipboard using the setContents() method of the org.eclipse.swt.dnd.Clipboard class.
When connecting from a localhost PC, it works normally, but when connecting from a remote PC, the following error occurs and it does not work normally.
I want to know the reason.

org.eclipse.swt.SWTError: Cannot set data in clipboard
at org.eclipse.swt.dnd.DND.error(DND.java:263)
at org.eclipse.swt.dnd.DND.error(DND.java:219)
at org.eclipse.swt.dnd.Clipboard.setContents(Clipboard.java:272)
at kr.dazzle.ui.common.EnClipboard.setContents(EnClipboard.java:138)
at kr.dazzle.ui.common.EnClipboard.setContents(EnClipboard.java:124)
at kr.dazzle.ui.tree.actions.CopyCellAction$1.run(CopyCellAction.java:51)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
at kr.dazzle.ui.tree.actions.CopyCellAction.run(CopyCellAction.java:46)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:493)
...
Re: Clipboard issue in RAP environment [message #1857766 is a reply to message #1857748] Fri, 24 February 2023 10:34 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,

Which browser are you using - Chrome or Firefox?
There is a difference between the too.

Best regards,
Ivan
Re: Clipboard issue in RAP environment [message #1857767 is a reply to message #1857748] Fri, 24 February 2023 10:37 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
... on first run there should be a browser native dialog pops up that asks for permission to access the clipboard.
Re: Clipboard issue in RAP environment [message #1857930 is a reply to message #1857766] Tue, 07 March 2023 08:42 Go to previous messageGo to next message
Kunok Joung is currently offline Kunok JoungFriend
Messages: 7
Registered: February 2023
Junior Member
This symptom occurs in both chrome and firefox.
And no error popup is displayed in the browser.
I also checked if Javascript errors were output using developer tools, but no errors were output.

Thank you for your reply and interest. ^^

[Updated on: Tue, 07 March 2023 08:51]

Report message to a moderator

Re: Clipboard issue in RAP environment [message #1857940 is a reply to message #1857930] Tue, 07 March 2023 14:14 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
show us code pls
I have tried all ways and there are not problems with clipboard (chrome safari firefox)
Re: Clipboard issue in RAP environment [message #1857947 is a reply to message #1857940] Wed, 08 March 2023 00:58 Go to previous messageGo to next message
Kunok Joung is currently offline Kunok JoungFriend
Messages: 7
Registered: February 2023
Junior Member
I wrote a sample program to reproduce this problem.
The mail template plugin of the RAP sample has been slightly modified and works as follows.
index.php/fa/43002/0/
This is a simple sample that saves the entered sentence to the clipboard when you enter a sentence in the text field and click the "Copy" button.

If you test with the URL below on the device where the server is running, it works perfectly.
http://localhost:Port/mail

but,
If you test by accessing the URL below from another device, an error occurs.
http://IP:Port/mail

Am I just not sure how to use it properly?
I hope so. ^^

Here's the code that implements clipboard handling:
public class ViewComposite extends Composite {
	private Text text;

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public ViewComposite(Composite parent, int style) {
		super(parent, style);
		setLayout(new GridLayout(3, false));

		Label lblText = new Label(this, SWT.NONE);
		lblText.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblText.setText("Text: ");

		text = new Text(this, SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Button btnCopy = new Button(this, SWT.NONE);
		btnCopy.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				String str = text.getText();
				System.out.println("Text:" + str);

				Clipboard clipboard = new Clipboard(getDisplay());
				clipboard.setContents(new Object[] { str }, new Transfer[] { TextTransfer.getInstance() });
			}
		});
		btnCopy.setText("Copy");

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
  • Attachment: ClipboardTest.zip
    (Size: 30.81KB, Downloaded 46 times)
  • Attachment: OK.png
    (Size: 26.79KB, Downloaded 220 times)

[Updated on: Wed, 08 March 2023 01:03]

Report message to a moderator

Re: Clipboard issue in RAP environment [message #1857970 is a reply to message #1857947] Wed, 08 March 2023 22:32 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
I'm not sure
but try to replace getDisplay(). to Display.getCurrent()
and add clipboard.dispose() after setContents
Re: Clipboard issue in RAP environment [message #1857975 is a reply to message #1857970] Thu, 09 March 2023 06:13 Go to previous messageGo to next message
Kunok Joung is currently offline Kunok JoungFriend
Messages: 7
Registered: February 2023
Junior Member
Unfortunately, even though I corrected it as instructed, the problem remains.
public ViewComposite(Composite parent, int style) {
		super(parent, style);
		setLayout(new GridLayout(3, false));

		Label lblText = new Label(this, SWT.NONE);
		lblText.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblText.setText("Text: ");

		text = new Text(this, SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Button btnCopy = new Button(this, SWT.NONE);
		btnCopy.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				String str = text.getText();
				System.out.println("Text:" + str);

				Clipboard clipboard = new Clipboard(Display.getCurrent());
				clipboard.setContents(new Object[] { str }, new Transfer[] { TextTransfer.getInstance() });
				clipboard.dispose();
			}
		});
		btnCopy.setText("Copy");
	}
Re: Clipboard issue in RAP environment [message #1858004 is a reply to message #1857975] Fri, 10 March 2023 14:18 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
magic.. lets try to isolate the problem
try copy to clipboard from my RAP application. (code is the same)
https://159.69.216.78:5020/start
=>enter
=> select any table =>mouse menu=> Copy rows=> click on copy button
If you will still have the problem that possible there is browser problem
Re: Clipboard issue in RAP environment [message #1858013 is a reply to message #1858004] Sat, 11 March 2023 01:48 Go to previous messageGo to next message
Kunok Joung is currently offline Kunok JoungFriend
Messages: 7
Registered: February 2023
Junior Member
oh!!!
I did it the way you told me to, and it worked fine.
I found a difference between my environment and yours.
I tested with HTTP and your environment is HTTPS.

I found the exact cause, and confirmed that my application works perfectly when connected to HTTPS.

When accessing via HTTP, for security reasons, only localhost was allowed and the rest were blocked.

thank you.

And TSMExplorer is awesome!!
I am also working on a site using RAP. Please stop by when you have time.
https://www.dazzleat.link/
Re: Clipboard issue in RAP environment [message #1858078 is a reply to message #1858013] Tue, 14 March 2023 22:18 Go to previous message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
good news
clipboard works well
Previous Topic:Focus issues with ContextMenu in Chrome browser
Next Topic:Is RAP still heavily in use - or are there other stacks recommended?
Goto Forum:
  


Current Time: Thu Jun 13 23:06:45 GMT 2024

Powered by FUDForum. Page generated in 0.04074 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top