use of org.csstudio.logbook.LogEntryBuilder in project org.csstudio.display.builder by kasemir.
the class SendLogbookAction method run.
@Override
public void run() {
File image_file = null;
try {
final Screenshot screenshot = new Screenshot(scene);
image_file = screenshot.writeToTempfile("display");
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(shell, "Cannot obtain screenshot", ex);
image_file = null;
}
try {
final LogEntryBuilder entry = LogEntryBuilder.withText(Messages.DefaultLogbookText);
if (image_file != null)
entry.attach(attachment(image_file.getAbsolutePath()).inputStream(new FileInputStream(image_file)));
final LogEntryBuilderDialog dialog = new LogEntryBuilderDialog(shell, entry);
dialog.setBlockOnOpen(true);
dialog.open();
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(shell, "Cannot create log entry", ex);
}
}
use of org.csstudio.logbook.LogEntryBuilder in project org.csstudio.display.builder by kasemir.
the class SendToElogAction method makeLogEntry.
/**
* Make a logbook entry.
*/
public void makeLogEntry() {
try {
final Attachment image_attachment = createImageAttachment();
final String text = Messages.LogentryDefaultTitle + "\n" + Messages.LogentryDefaultBody;
final LogEntryBuilder entry = LogEntryBuilder.withText(text).attach(AttachmentBuilder.attachment(image_attachment));
// get the command from plugin.xml
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
List<LogEntryBuilder> logList = new ArrayList<LogEntryBuilder>();
logList.add(entry);
Event event = new Event();
event.data = logList;
// execute the command
IHandlerService handlerService = window.getService(IHandlerService.class);
handlerService.executeCommand(OPEN_LOGENTRY_BUILDER_DIALOG_ID, event);
} catch (Exception e) {
MessageDialog.openError(null, "Logbook Error", "Failed to make logbook entry: \n" + e.getMessage());
}
}
Aggregations