CIB jrec technical documentation (EN)

Site: CIB eLearning
Course: CIB jrec
Book: CIB jrec technical documentation (EN)
Printed by: Guest user
Date: Tuesday, 7 May 2024, 12:52 PM

1. Scope of delivery

Component

Software scope

CIB jrec

The application is delivered as a zip file: CibJrec-<version>.zip

 

After unpacking, the following directory structure with the specified files results:

Path

File

Content

CibJrec

readme.txt

ReadMe file

 

run.bat

Batch file for start via console

 

cibjrec.ini

CIB jrec INI file

CibJrec\docs\api and subdirectories

All javadoc files, especially index.html

Java documentation for CIB jrec:
Entry via index.html

CibJrec\docs\manual

 

CIB jrec manual documents

CibJrec\lib

CibGUI-<version>.jar

CIB GUI Java archive file

 

CibJrec-<version>.jar

CIB jrec Java archive file


2. Introduction

CIB jrec is a Java-based rich text editor component, which can be integrated easily into masks and third-party applications using the interface concept known from other CIB modules.

Like the other CIB modules, this RTF edit control can be controlled easily by setting various properties. This fulfills a frequent customer request for a slim text (passage) editor with reduced functionality, which can be easily integrated into other Java applications.

The CIB jrec editor can be started either empty, with ASCII or RTF texts. Vice versa, the texts can be read from the edit control in ASCII or RTF format.

CIB jrec has the following options for text formatting:

  • Different fonts and font sizes
  • Character attributes bold, italic, underlined, colored
  • Paragraph alignment left-aligned, centered, right-aligned
  • Copy, cut and paste marked text sections
  • Show/hide formatting characters

Tabulator positions in an RTF document (across documents or per paragraph) are evaluated and displayed accordingly.

This technical documentation gives an overview of the configuration and application possibilities, together with code examples for a "quick start" into the topic.

Two sample documents are shown below: The first document was created with CIB jrec and shows some functions of the Rich Text Edit control. The second document contains different tabulators and was created with MS Word, because in CIB jrec documents with explicit tab positions can be displayed but not created.



3. Configuration via properties

In this chapter you can find  informaion about configuration through properties.

3.1. General properties

The following properties can be used to set general settings for the application.

Property description

Type

PROPERTY_TITLE

String

Sets the title that is displayed in the title bar of the application.

Default: „JCibRec“

 

Property description

Type

PROPERTY_ICON_PATH

String

Sets the icon that is displayed in the title bar of the application.

The name of the icon file with complete path will be transferred.

Default: „/de/cib/jrec/resource/CIBRichEdit.png“

 

Property description

Type

PROPERTY_JREC_INIFILENAME

String

Sets the name of the CIB jrec INI file.

Default: cibjrec.ini

Note: This property sets the name of the CIB jrec INI file. If "null" is set as value, no INI file is used for usage.

 

Property description

Type

PROPERTY_INPUTFILE

String

Sets the name of the document that will be opened when the application starts.

Default: CIB jrec will be opened with an empty document.


3.2. Properties for toolbar configuration

With the following properties the individual elements of the toolbar can be switched on or off. Setting the property to TRUE causes the element to be visible and active, FALSE means the element is invisible and deactivated.

Property description

Type

PROPERTY_BOLD_ENABLED

Boolean

Enable or disable button for font setting "Bold".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_ITALIC_ENABLED

Boolean

Enable or disable button for font setting "Italic".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_FONT_UNDERLINE_ENABLED

Boolean

Enable or disable button for font setting "Underline".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_ALIGN_LEFT_ENABLED

Boolean

Enable or disable button for font setting "Align Left".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_ALIGN_CENTER_ENABLED

Boolean

Enable or disable button for font setting "Align Center".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_ALIGN_RIGHT_ENABLED

Boolean

Enable or disable button for font setting "Align Right".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_ALIGN_BLOCK_ENABLED

Boolean

Enable or disable button for font setting "Align Block".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_COPY_ENABLED

Boolean

Enable or disable button for functionality "Copy".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_PASTE_ENABLED

Boolean

Enable or disable button for functionality "Paste".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_CUT_ENABLED

Boolean

Enable or disable button for functionality "Cut".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_FOREGROUND_COLOR_ENABLED

Boolean

Enable or disable button for font setting "Font Color".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

  

Property description

Type

PROPERTY_AUTOMATIC_COLOR_ENABLED

Boolean

Note: This property is not implemented yet.

 

Property description

Type

PROPERTY_FONT_SIZE_ENABLED

Boolean

Enable or disable selection list (ComboBox) for "Font Size".

TRUE (default): ComboBox is visible and active.

FALSE: ComboBox is invisible and deactivated.

 

Property description

Type

PROPERTY_FONT_ENABLED

Boolean

Enable or disable selection list (ComboBox) for "Font Type".

TRUE (default): ComboBox is visible and active.

FALSE: ComboBox is invisible and deactivated.

 

Property description

Type

PROPERTY_SHOW_NONPRINTABLE_CHARS_ENABLED

Boolean

Enable or disable button for font setting "Show/hide formatting characters".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 

Property description

Type

PROPERTY_EXIT_REC_ENABLED

Boolean

Enable or disable toolbar button for "Close".

TRUE (default): Button is visible and active.

FALSE: Button is invisible and deactivated.

 


3.3. Properties to configure the jrec edit controls

With these properties the behavior of the jrec edit controls can be set.

Property description

Type

PROPERTY_ALLOWED_FONT_LIST

String

List of allowed fonts separated by semicolons (font name1;font name2; ...).

If not empty, the list of allowed fonts is restricted to the fonts in the list.

Default: All allowed fonts are available in the jrec edit control.

Note: This property can be used to restrict the list of allowed fonts to the fonts in the list. If the list is empty, all allowed fonts are available.

 

Property description

Type

PROPERTY_DEFAULT_FONT_FAMILY

String

Sets the default font of the RTF document.

Default: RTF default font (Times New Roman).

Note: This property sets the name of the default font. If the property is not set, the default RTF font usage is used.

 

Property description

Type

PROPERTY_DEFAULT_FONT_SIZE

String

Sets the default font size of the RTF document.

Default: RTF default font size (12).

Note: This property sets the default font size. If the property is not set, the default RTF font size is used for usage.

 

Property description

Type

PROPERTY_GRAB_FOCUS_AFTER_SETRTF

Boolean

Determines whether in CIB jrec after setting an RTF text with setRTF() the focus is set on the text or not.

Default: FALSE

Note: This property determines whether or not the focus is automatically set to the edit control after loading or setting a text.

 

Property description

Type

PROPERTY_USE_ONLY_STANDARD_COLORS

Boolean

Only RTF standard colors can be selected in the color selection dialog.

TRUE: Only RTF standard colors are selectable.

FALSE (default): Self defined and RTF standard colors are selectable.

Note: This property determines the selection of colors in the color selection dialog.

 

Property description

Type

PROPERTY_POPUP_ENABLED

Boolean

Determines whether or not the pop-up menu is activated in CIB jrec.

Since this property is also read from the INI file, it should only be set after calling cibRec.start(), otherwise it will be overwritten.

TRUE: The pop-up menu can be activated by clicking the right mouse button.

FALSE (default): The pop-up menu cannot be accessed.

Note: This property determines the usability of the pop-up menu.

 

Property description

Type

PROPERTY_WRITE_DEFAULTFONTSIZE

Boolean

Determines whether CIB jrec writes the default font size into the RTF document.

TRUE: Writes the default font size into the RTF document.

FALSE (default): Does not write the default font size to the RTF document.

Note: This property is used to configure the writing of the default font size in the RTF document.

 

Property description

Type

PROPERTY_WRITE_DEFAULTTABS

Boolean

Determines whether CIB jrec writes the standard tabs per paragraph to the RTF document.

TRUE: Writes the default tabs per paragraph into the RTF document.

FALSE (default): Does not write the standard tabs to the RTF document.

Note: This property is used to configure the writing of standard tabs to the RTF document.

 

Property description

Type

PROPERTY_REC_IGNORE_FIELDS

Boolean

Determines whether CIB jrec ignores the fields embedded in the RTF document or not.

TRUE: The fields embedded in the RTF are ignored, i.e. they are not displayed and not saved.

FALSE (default): The fields embedded in the RTF are not ignored, i.e. they are displayed and saved.

Note: If the switch is set, embedded fields are not displayed and not saved. Only the fieldresult is displayed as normal formatted text and saved as such. This applies especially to hyperlinks and file links.


4. Configuration via call parameters

CIB jrec can also be controlled by call parameters in the batch file (run.bat).

The usual syntax for command line parameters applies:

-<Parametername-1> <Parameterwert-1> … -<Parametername-n> <Parameterwert-n>

The names of the parameters correspond to the internal names of the properties. If not known, they can be requested from the support.

Additionally there are the following call parameters:

<Filename>               Name of the document to be leaded when starting the application. (Without previous minus sign)

-t                                 Enables output of trace information to the console


5. Configuration file (INI file)

CIB jrec can be controlled by a configuration file. If no other name is set by the PROPERTY_JREC_INIFILENAME property, the INI file name is "cibjrec.ini". If no INI file should be used, the INI file must be set to the value "null".

The INI file is read when CIB jrec is started (in the method cibRec.start) and can in principle contain all the properties described above, which then overwrite the previously set property values.

The names of the properties must correspond to the internal names of the properties. If not known, they can be requested from the support.

If a line starts with "#", the property is ignored.

 

Example for the content of an INI file:

[Properties]
TITLE=CIB Java Rich Edit Control
INPUTFILE=D:\CIB\TestDokumente\RTF\Tabtest_All.rtf
 
# Enable popup menu
popup.Enabled=true
 
# Show status line
showstatus.Enabled=true
 
# Show toolbar icon for nonprintable-characters
#show-nonprintable-chars.Enabled=false
 
# Set default font family and size
defaultFontFamily=Arial
defaultFontSize=10
 
# Write default font size on saving
writeDefaultFontSize=true
 
# Write default tabs on saving
#writeDefaultTabs=true
 
# Grab focus after setting rtf file
#grab.focus.after.setrtf.Enabled=false
 
# Ignore field instructions within rtf content
#JREC.ignoreFields=true

6. Integration of CIB jrec in Java

If the Jrec is integrated into a Java application that has its own menu, the JRec menu must be deactivated explicitly. For this purpose the following property must be set for the Jrec instance before the Jrec instance is started:

      // disable jrec menu bar – must be done 
      // if custom application uses its own menu bar
 m_cibRec.setProperty(ICibApplication.PROPERTY_MENU_ENABLED,
            Boolean.FALSE);
 
      // set other Properties
      //...
     
      // jrec start and load
      m_cibRec.start();
      m_cibRec.load();

 

See also the sample code for integration into a Java Swing application.


6.1. Integration into a Java Swing application

import java.awt.Dimension;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
 
import de.cib.jrec.JCibRec;
 
public class MyRecTest extends JFrame {
 
      private static final long serialVersionUID = 1L;
      public static final String TEST_FILENAME = "c://tmp//rtf_data.rtf";
 
      JCibRec m_cibRec;
 
      public MySwingRecTest() {
            m_cibRec = new JCibRec();
 
            JPanel recPanel = new JPanel();
            recPanel.add(m_cibRec);
          getContentPane().add(recPanel);
            m_cibRec.setPreferredSize(new Dimension(650, 200));
 
            // set standard formatting
            initDocumentAttributes();
 
            // set input file (optional)
      m_cibRec.setProperty(ICibApplication.PROPERTY_INPUTFILE,                         TEST_FILENAME);
            // set Jrec application title
      m_cibRec.setProperty(ICibApplication.PROPERTY_TITLE,                   "CIB JRec integriert in Swing");
            // disable jrec menu bar – must be done
            // if custom application uses its own menu bar
            // if custom application uses its own menu bar
      m_cibRec.setProperty(ICibApplication.PROPERTY_MENU_ENABLED,                   Boolean.FALSE);
 
            // set other Properties
            //...
           
            // jrec start and load
            m_cibRec.start();
            m_cibRec.load();
 
      setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
            setLocation(200, 50);
            setResizable(false);
            pack();
      }
 
      // set standard formatting
      private void initDocumentAttributes() {
            MutableAttributeSet defaultAttributes =
                        new SimpleAttributeSet();
 
      StyleConstants.setFontSize(defaultAttributes, 8);
      StyleConstants.setFontFamily(defaultAttributes, "Courier New");
 
      m_cibRec.getRecRichEditPane().setDocumentAttributeDefaults(
                        defaultAttributes);
      }
 
      public static void main(String[] args)
      {
            MySwingRecTest recTest = new MySwingRecTest();
            recTest.setVisible(true);
      }
}

The functionality initDocumentAttributes() shows an example of how to set the default font and font size for the document.

6.2. Integration into a Java SWT application

In order to integrate JCibRec into an SWT application, some special features have to be considered. JCibRec must be embedded into an AWT frame, which contains an instance of RootPaneContainer (e.g. JApplet) as the topmost object. All further components are then inserted into this RootPaneContainer.

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
 
import de.cib.gui.framework.ICibApplication;
import de.cib.jrec.ICibRecApplication;
import de.cib.jrec.JCibRec;
 
 
public class JRecInSWT {
 
      public static final String TEST_FILENAME = "Testdokument2.rtf";
 
      public static void main(String[] args) {
            final Display display = new Display();
            final Shell shell = new Shell(display);
            shell.setLayout(new FillLayout());
            shell.setText("Shell for JRec integriert in SWT");
            Composite composite = new Composite(shell, SWT.NO_BACKGROUND
                        | SWT.EMBEDDED);
           
            /*
             * Set a Windows specific AWT property that prevents
             * heavyweight components from erasing their background.
             * Note that this is a global property and cannot be scoped.
             * It might not be suitable for your application.
             */
            try {
                System.setProperty("sun.awt.noerasebackground", "true");
            }
            catch (NoSuchMethodError error) {
            }
 
            final JCibRec cibRec = new JCibRec(composite);
           
      cibRec.setProperty(ICibApplication.PROPERTY_INPUTFILE,                   TEST_FILENAME);
      cibRec.setProperty(ICibApplication.PROPERTY_TITLE,                   "CIB JRec integriert in SWT");
      cibRec.setProperty(ICibRecApplication.PROPERTY_POPUP_ENABLED,                   Boolean.TRUE);
 
            // disable jrec menu bar – must be done             // if custom application uses its own menu bar
      cibRec.setProperty(ICibApplication.PROPERTY_MENU_ENABLED,                   Boolean.FALSE);
 
           
            cibRec.setVisible(true);
            cibRec.start();
            cibRec.load();
           
            shell.open();
            cibRec.grabFocus();
           
            while (!shell.isDisposed()) {
                  if (!display.readAndDispatch())
                        display.sleep();
            }
            display.dispose();
      }
}