Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Copy to Clipboard
Copy to Clipboard [message #1740357] Fri, 12 August 2016 07:54 Go to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
We would like to copy some selected data from a table cell to the local clipboard, to insert it to a different application (e.g. MS Word). So, kind of "CTRL-C" on some execAction() (or similar).

Is there anything in Scout we could use?
Re: Copy to Clipboard [message #1740374 is a reply to message #1740357] Fri, 12 August 2016 12:14 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Andreas Christ wrote on Fri, 12 August 2016 03:54
Is there anything in Scout we could use?


Certainly! Smile

BEANS.get(IClipboardService.class).setTextContents("Hello");


Note that in the new HTML UI this triggers a popup window with the text to copy, and the user has to press Ctrl-C manually. Unfortunately, we cannot write directly to the clipboard due to security restrictions of the browser. (Writing to the clipboard from JavaScript is not entirely impossible. But when the Scout UI handles the command from the server to write something to the clipboard, it is no longer in a "user action context", and the browser ignores the command. If you want to write to the clipboard directly, you would have to create your own custom widget.)

Regards,
Beat
Re: Copy to Clipboard [message #1740381 is a reply to message #1740374] Fri, 12 August 2016 13:02 Go to previous messageGo to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
Ah, thank you. That's ok for us, the dialog is acceptable.
We thought about making some hidden column with the data, and make some bad JavaScript DOM tree computations to get it out of HTML into Clipboard. Well, your one-liner is much better!
Nice!
Re: Copy to Clipboard [message #1746694 is a reply to message #1740381] Thu, 03 November 2016 10:45 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
I have done copy operation for one/many rows with tab between values using separate modal window. (image's attached)
two step operation
- select copy on/all rows operations from menu
- ctrl-c or from browser menu copy result from window
Dmitry
Re: Copy to Clipboard [message #1750611 is a reply to message #1740357] Fri, 23 December 2016 09:51 Go to previous messageGo to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
What about this? https://clipboardjs.com/
Re: Copy to Clipboard [message #1751104 is a reply to message #1750611] Wed, 04 January 2017 13:43 Go to previous messageGo to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
We want to select one specific value in a table for later copy (CTRL-C). The problems are:
* it's possible to select a complete row, not a single cell - and not the cell's content at all
* if we make a cell editable (you can select a value now and copy!), it is also possible to alter/delete that value! Solution: reload page to display original values again

	private IColumn<?> clickedColumn;


in initPage():
getTable().addPropertyChangeListener(ITable.PROP_CONTEXT_COLUMN, new PropertyChangeListener() {
	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		Object o = evt.getNewValue();
		if (o instanceof IColumn<?>) {
			clickedColumn = (IColumn<?>) o;
		}
	}
});


in the table class:
// determines cell from "clickedColumn" in clicked row
@Override
protected void execRowClick(ITableRow row, MouseButton mouseButton) {
	final ICell cell = row.getCell(clickedColumn);
	LOG.info("Click: " + cell.getText());
	
	super.execRowClick(row, mouseButton);
}


But what exactly can I do with that cell? I cannot make it selectable or anything...
Re: Copy to Clipboard [message #1751159 is a reply to message #1751104] Thu, 05 January 2017 07:26 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I am not sure to have understood what you mean. But I wanted to react to this statement:
Andreas Christ wrote on Wed, 04 January 2017 14:43
* if we make a cell editable (you can select a value now and copy!), it is also possible to alter/delete that value! Solution: reload page to display original values again


Here is my idea that does not require to reload the page:

You make your table editable, but you ignore the modifications made by the user when the edition is complete (for example if he do CTRL-X to copy the value or if he change it by mistake). Here is how you can do this in your columns:
@Order(1000)
public class NameColumn extends AbstractStringColumn {
	//...
	
	@Override
	protected boolean getConfiguredEditable() {
		return true;
	}
	
	@Override
	protected void execCompleteEdit(ITableRow row, IFormField editingField) {
		// nothing to do.
	}
}

I think this is not a typical usage of the framework but you should obtain the result you want.

index.php/fa/28017/0/


Re: Copy to Clipboard [message #1751164 is a reply to message #1751159] Thu, 05 January 2017 08:40 Go to previous messageGo to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
Thank you! ... I was so close... in my execCompleteEdit I had the following two lines for reload:
	reloadPage();
	super.execCompleteEdit(row, editingField);

Without them - like in your solution - it works!

But there is a tiny grey triangle in each copyable cell (see your example) - that should indicate a editable filed, right? I'll have to ask the customer for acceptance of that.

But I'm still looking for an easier way: just select an entry in the table for copy with CTRL-C...

[Updated on: Thu, 05 January 2017 08:42]

Report message to a moderator

Re: Copy to Clipboard [message #1751176 is a reply to message #1751164] Thu, 05 January 2017 12:15 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
We solved this by supplying a context menu entry "copy value". The user can then right click on a cell and copy its content. We are using the clicked column listener same as you do.

One drawback is that the user can only copy the complete cell content and not a part of it. Another drawback is that while it worked perfectly in Scout Mars there are some bugs that need to be fixed for this to correctly work in Scout Neon (which we have submitted to the bugtracker and BSI is working on them).
Re: Copy to Clipboard [message #1751192 is a reply to message #1751176] Thu, 05 January 2017 14:17 Go to previous message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
Thank you, Urs! Sounds promising to me. If it's ready I'll give it a try. Smile
Andreas
Previous Topic:Mockito as mocking library?
Next Topic:[Blog Post] Business Applications on Blockchains: Eclipse Scout, Ethereum and web3j
Goto Forum:
  


Current Time: Thu Apr 25 11:53:47 GMT 2024

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

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

Back to the top