BlobViewer

Overview

Influence and Behaviour

Blob Images and Aspect Ratio

CSV Editor

Invoking the CSV Editor

CSV Editor Options

Predefining the Parser Settings

Overview

BlobViewer is used to display and edit BYTE or TEXT values e.g. a text or a picture.

Form XML code:

<BlobViewer dataType="Byte,,,," visible="true" identifier="bl1" gridItemLocation="0,0,1,1"/>

Inheritance diagram:

Most commonly used form properties:

classnames

editor

identifier

horizontalAlignment

verticalAlignment

maxSize

minSize

preferredSize

 

Return to top

Influence and Behaviour

To add a BlobViewer to your form, do the following:

Step 1. Decide on a place in your form for the BlobViewer widget. Mind that the form must have at least one container (a Root Container) to be able to contain widgets.

Step 2. In the Form Builder's Palette, find the BlobViewer widget.

Step 3. Select the BlobViewer, then drag-and-drop it into the defined place in your form.

After that, the BlobViewer will be added to your form. You will also see it appear in the Form Structure view.

To find an Identifier for referencing that BlobViewer in your .4gl file, select the BlobViewer in the Design Area or in the Form Structure (on that, the Properties view will be activated). Next, find that BlobViewer's Identifier in the list of its properties.

When you specify a file name, be careful with its case.

UNIX is case-sensitive, so it will treat files which names come in different cases as separate files.

#1

Manipulating the BlobViewer contents via DISPLAY <> TO statement:

MAIN

  DEFINE bl1 BYTE

    OPEN WINDOW test WITH FORM "test_blobviewer"

      MENU "m1"

        COMMAND "IMG"

          LOCATE bl1 IN FILE "lycia.jpg"

          DISPLAY bl1 TO bl1

        COMMAND "EXIT"

          EXIT MENU

  END MENU

END MAIN

#2

Manipulating the BlobViewer contents via DISPLAY BY NAME statement

MAIN

  DEFINE bl1 BYTE

    OPEN WINDOW test WITH FORM "test_blobviewer"

      MENU "m1"

        COMMAND "IMG"

          LOCATE bl1 IN FILE "lycia.jpg"

          DISPLAY BY NAME bl1

        COMMAND "EXIT"

          EXIT MENU

  END MENU

END MAIN

Runtime Appearance

BlobViewer can hold any file, but at runtime it will display and allow editing only those file types (content types) which can be processed by your operation system (for LyciaDesktop) or the browser you use (for LyciaWeb). If the file cannot be displayed due to its format, the placeholder image will display.

Note: The processing of the files in LyciaWeb depends on the settings of your browser (for example, processing of different types of files in Google Chrome is set in the chrome://settings/content section of the settings).

The editing in the browser is possible for the TEXT data only (txt, csv, xls files). For the editable file, the Edit button will be available in the toolbar in the bottom of the window:

By default, the editor type will be determined at runtime according to the type of the first manipulated BlobViewer content. You can set the value of the editor property to instruct LyciaDesktop and LyciaWeb on what type of editor should be used to manipulate that content. To get more information, refer to the editor property page.

In LyciaDesktop, the BlobViewer content can be edited. The editing capabilities depend on the file type and the program set as default for processing that file type.

After you left-click the Edit button, the file displayed by the BlobViewer will be opened in the corresponding editor:

LyciaDesktop will allow editing BlobViewer content in the editor associated with this file type (content type) in your system. If you want a file to be opened in the definite editor, you have to make that editor a default one for that file type.

Windows Photo Viewer is the default program for opening image files:  

Paint is the default program for opening image files.

If the file displayed by the BlobViewer cannot be edited, the Edit button will be hidden:

For the BlobViewer content to be properly displayed, you must either specify its type with the file extension or set the value of the Editor property.

 

Return to top

Blob Images and Aspect Ratio

By default, your blob image will keep aspect ratio at the window resizing. To override that behaviour, add image-ignore-aspect-ratio as the value for classNames parameter in the BlobViewer widget properties in the form.

Please see the examples of images behaviour at window resizing with aspect ratio preserved (upper figure) and aspect ratio ignored (lower figure):

 

Return to top

CSV Editor in BlobViewer

The BlobViewer widget has an editor that can display CSV files. You can use a separate form for the CSV spreadsheet, or integrate the spreadsheet with an existing form.

With this Editor, you can:

Note: The Editor recognizes the following delimiters: tab, comma, pipe (|), semicolon, record_sep (ASCII30), unit_sep (ASCII31).

 

Return to top

Invoking the CSV Editor

Prerequisites: Before doing the steps described below, prepare the following:

Step 1. Within the MAIN block of your .4gl file, define a variable with the TEXT data type:

DEFINE bl2 TEXT
Note: A value name bl2 in this example was chosen to follow a default BlobViewer widget naming for convenience.

Step 2. Assign a window to open with your form:

OPEN WINDOW w1 AT 1,1 WITH FORM "9056_spreadsheet01"

Step 3. Use the LOCATE clause to make bl2 store the spreadsheet data:

LOCATE bl2 IN FILE "9056_spreadsheet01.csv"

Step 4. Add an INPUT BY NAME clause followed by the WITHOUT DEFAULTS clause to reference and display the spreadsheet data:

INPUT BY NAME bl2 WITHOUT DEFAULTS

Step 5. Add a call for the fgl_getkey() function:

CALL fgl_getkey()

Next, you must adjust your form layout to display the CSV data. To do that, open your .fm2 form file in VS Code's Editor, and fill it in with the following code:

<?xml version="1.0" encoding="UTF-8"?>

<form xmlns="http://namespaces.querix.com/2015/fglForms">

<form.rootContainer>

<GridPanel visible="true" enable="true" fieldTable="formonly" preferredSize="500,500" identifier="rootContainer">

<GridPanel.gridRowDefinitions>

<GridRowDefinition gridLengthValue="100%" />

</GridPanel.gridRowDefinitions>

<GridPanel.gridColumnDefinitions>

<GridColumnDefinition gridLengthValue="100%" />

</GridPanel.gridColumnDefinitions>

<BlobViewer Editor="csv" visible="true" enable="true" verticalAlignment="Stretch" horizontalAlignment="Stretch" fieldTable="formonly" gridItemLocation="0,0,1,1" identifier="bl2" />

</GridPanel>

</form.rootContainer>

<form.screenRecords>

<ScreenRecord identifier="FormOnly" />

</form.screenRecords>

</form>

If you open the Form Builder after that and select the BlobViewer widget in the Design Area or in the Form Structure, in the Properties view you should see the following:

Attention: The CSV Editor in Form Builder relies on the first row of the spreadsheet to define the number of columns to parse data into. Edit the first row of the spreadsheet if it doesn’t have enough columns.

 

Return to top

CSV Editor Options

The options are located in the lower-left corner of the CSV Editor. Those are the following:

1. Download: By pressing this button, you will invoke the file downloading dialog.

2. Print: This button triggers the CSV file printing dialog:

After you configure the parameters you need and click Print, the Viewer will convert the CSV file into a PDF file, and invoke a printing dialog.

3. CSV Parser Settings: This button offers different options for the spreadsheet display:

Note: The changes will take effect dynamically after you select an option.

The settings for you to configure are:

If you set this to No, the columns will be assigned with nominal column identifiers (numbers starting from 0):

This is useful when there is no header row in the spreadsheet.

Click DONE after configuring the CSV spreadsheet display to exit the configuration dialog.

4. Upload: Using this button, you can upload another CSV file’s contents into the current view and to the server. Mind that this new data will replace the contents of the initially opened file, so at the next program run the BlobViewer’s CSV Editor will display the latest data.

5. Edit: Clicking this button invokes the editing mode so you can edit separate values in the spreadsheet. To edit a value, click Edit, double-click the value you need to edit, and input the new value. Double-click another cell to edit that cell. After all the editing is done, return to the CSV Parser Settings pane in the lower-left corner of the Editor, and select the Done button:

6. Full Screen: Invokes the fullscreen display (if the program is run as a web application, the spreadsheet will occupy the whole tab space).

 

Return to top

 

Predefining the Parser Settings

You can define the parser settings during the form creation for the CSV Editor to open the file(s) with a certain configuration.

There are two ways to do it:

Note: The program user will be able to edit these settings at runtime, yet at the application restart the Editor will use the settings from the form file code (therefore, if some values were added to the code, they will be reapplied at the next program run).
Parser Settings in the Form File Code

The parser settings can be stored within the tag <BlobViewer> as values of the editorConfig property. For example:

<BlobViewer editor="csv" editorConfig="header=yes&#10;delimiter=tab&#10;skipEmptyLines=true&#10;skipFirstNLines=3" />

Note: For the skipEmptyLines property, the values false, 0, no, n, off are treated as do not skip, and all other values are treated as skip.
Parser Settings at Visual Form Editing

To configure the parser using the Form Builder, do the following:

Step 1. Open the .fm2 form file in the Form Builder, find the BlobViewer in the Form Structure, and select it:

Step 2. In the Properties view, click the Advanced Properties Mode button:

Step 3. In the expanded list of properties, find a property called Editor Config, and click an ellipsis More button:

A dialog for values input will open:

Step 4. In the dialog, add the values in the following format, one setting per line:

header=yes

delimiter=tab

The possible values are the following:

Setting Possible Values
header {yes, no}
delimiter {comma, tab, pipe, semicolon, record_sep, unit_sep}
newLineCharacter {auto, lf, cr, crlf}
quoteCharacter {any character, empty field means auto-detection for the ", ', ` characters}
encoding {any encoding}
skipEmptyLines

{false, 0, no, n, off} - for no skipping

{true or any other value} - for skipping

skipFirstNLines {0, any positive integer}

Step 5. After the values have been added, click the DONE button:

The values will be added to the .fm2 form file's code.

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.