Prev Up Next

Options for starting the RecordEditor

The RecordEditor can also be started in a number of ways from Java programs. This section shows various ways of doing this.


Editing a Specific file

If you want to start the RecordEditor with a specific file, then the following code from XmplEditSpecificFile1.Java will do it.

33:public class XmplEditSpecificFile1 {
34:
35:    private static String filename   = Constants.EXAMPLE_FILE_DIRECTORY
36:                                     + "Ams_LocDownload_20041228.txt";
37:    private static String layoutName = "ams Store";
38:    private static int initialRow = 0;
39:
40:    /**
41:     * This is an example of editing a specific file
42:     * (without displaying the RecordEditor File selection screen)
43:     *
44:     * @param args program args
45:     */
46:    public static void main(String[] args) {
47:        CopyBookDbReader copyBookInterface = new CopyBookDbReader();
48:        LayoutDetail fileDescription = copyBookInterface.getLayout(layoutName);
49:
50:        if (fileDescription == null) {
51:            System.out.println(
52:                "Record Layout \"" + layoutName + "\" not loaded: "
53:                + copyBookInterface.getMessage());
54:        } else {
55:            try {
56:                FileView file = new FileView(filename,
57:                                       fileDescription,
58:                                       false);
59:
60:                new ReMainFrame("Specific file", "");
61:                LineList list = new LineList(fileDescription, file, file);
62:                list.setCurrRow(initialRow, -1, -1);
63:                list.addInternalFrameListener(new InternalFrameAdapter() {
64:                    public void internalFrameClosed(final InternalFrameEvent e) {
65:                        Common.closeConnection();
66:
67:                        System.exit(0);
68:                    }
69:                });
70:
71:            } catch (Exception e) {
72:                e.printStackTrace();
73:            }
74:        }
75:    }
76:}


Edit a File one Record at time

It is also possible to edit a file with the Single Record view (i.e. one line or record is displayed on the screen at a time with fields going down the screen). The following code from XmplEditSpecificFile2.Java does this.

46:            try {
47:                FileView file = new FileView(filename,
48:                                       fileDescription,
49:                                       false);
50:
51:                new ReMainFrame("Specific file", "");
52:                LineFrame lineFrame = new LineFrame(fileDescription, file, file, null, 0);
53:            } catch (Exception e) {
54:                e.printStackTrace();


Other Examples

XmplEditSpecificFile3.Java

Shows how to edit a file using your own JTable

XmplEditSuppliedData.Java

This example demonstrates calling the RecordEditor using program-generated data.

Prev Up Next