use of alma.acs.eventbrowser.parts.ParsedAnyData in project ACS by ACS-Community.
the class CopyDetailsToClipboardHandler method execute.
/**
* Receives the selection from the event detail part.
* <p>
* It may be my lack of understanding of good Eclipse 4 RCP practices that I wish
* I could handle the mouse menu action locally in the event detail part,
* instead of sending the data via selection service to separate handler.
* Perhaps to be refactored once this becomes clearer.
*/
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) ParsedAnyData[] parsedAnyData) throws ExecutionException {
if (parsedAnyData == null || parsedAnyData.length == 0) {
return;
}
System.out.println("Will copy event details to the clipboard...");
// Convert selected table rows into a multi-line String
StringBuilder sb = new StringBuilder();
for (ParsedAnyData parsedAny : parsedAnyData) {
sb.append(parsedAnyDataToString(parsedAny));
}
// Write that data to the system clipboard
Clipboard cb = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { sb.toString() }, new Transfer[] { textTransfer });
cb.dispose();
}
Aggregations