use of org.eclipse.swt.dnd.Transfer in project yamcs-studio by yamcs.
the class CopyEventDetailsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
if (sel != null && sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
String property = event.getParameter(EventLog.CMDPARAM_EVENT_PROPERTY);
StringBuilder text = new StringBuilder();
Iterator<?> it = selection.iterator();
while (it.hasNext()) {
Event rec = (Event) it.next();
switch(property) {
case PARAM_MESSAGE:
text.append(rec.getMessage());
break;
case PARAM_SOURCE:
text.append(rec.getSource());
break;
case PARAM_TYPE:
text.append(rec.getSource());
break;
case PARAM_GENTIME:
text.append(rec.getGenerationTimeUTC());
break;
case PARAM_RECTIME:
text.append(rec.getReceptionTimeUTC());
break;
case PARAM_SEQNO:
text.append(rec.getSeqNumber());
break;
case PARAM_SEVERITY:
text.append(rec.getSeverity());
break;
default:
throw new IllegalStateException("Unexpected property: " + property);
}
if (it.hasNext()) {
text.append("\n");
}
}
Display display = Display.getCurrent();
Clipboard clipboard = new Clipboard(display);
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(new Object[] { text.toString() }, transfers);
clipboard.dispose();
}
return null;
}
use of org.eclipse.swt.dnd.Transfer in project yamcs-studio by yamcs.
the class CopyEventHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
if (sel != null && sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
StringBuilder text = new StringBuilder("Severity\tMessage\tType\tSource\tGeneration\tReception\tSequence Number\n");
Iterator<?> it = selection.iterator();
while (it.hasNext()) {
Event rec = (Event) it.next();
text.append(rec.getSeverity()).append("\t").append(rec.getMessage()).append("\t").append(rec.getType()).append("\t").append(rec.getSource()).append("\t").append(rec.getGenerationTimeUTC()).append("\t").append(rec.getReceptionTimeUTC()).append("\t").append(rec.getSeqNumber()).append("\n");
}
Display display = Display.getCurrent();
Clipboard clipboard = new Clipboard(display);
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(new Object[] { text.toString() }, transfers);
clipboard.dispose();
}
return null;
}
Aggregations