Search in sources :

Example 1 with LogEntryBuilder

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);
    }
}
Also used : Screenshot(org.csstudio.javafx.Screenshot) LogEntryBuilderDialog(org.csstudio.logbook.ui.LogEntryBuilderDialog) LogEntryBuilder(org.csstudio.logbook.LogEntryBuilder) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with LogEntryBuilder

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());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ArrayList(java.util.ArrayList) Event(org.eclipse.swt.widgets.Event) Attachment(org.csstudio.logbook.Attachment) LogEntryBuilder(org.csstudio.logbook.LogEntryBuilder)

Aggregations

LogEntryBuilder (org.csstudio.logbook.LogEntryBuilder)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Screenshot (org.csstudio.javafx.Screenshot)1 Attachment (org.csstudio.logbook.Attachment)1 LogEntryBuilderDialog (org.csstudio.logbook.ui.LogEntryBuilderDialog)1 Event (org.eclipse.swt.widgets.Event)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 IHandlerService (org.eclipse.ui.handlers.IHandlerService)1