|
| 1 | +Retep Tools Implementation |
| 2 | +-------------------------- |
| 3 | + |
| 4 | + |
| 5 | +The tools are designed to be put into a single jar file, but each one is |
| 6 | +executable either individually or part of one single application. |
| 7 | + |
| 8 | +To run the big application, you can either: |
| 9 | + |
| 10 | + java -jar retepTools.jar |
| 11 | + |
| 12 | +or with the retepTools.jar in the classpath run: |
| 13 | + |
| 14 | + java uk.org.retep.tools.Main |
| 15 | + |
| 16 | +Windows users: For you you can also double click the retepTools.jar as windows |
| 17 | +will automatically run javac for you. |
| 18 | + |
| 19 | +To run the individual tools, you must have the .jar file in your classpath and |
| 20 | +then run the relevant Main class. |
| 21 | + |
| 22 | +Tool Type Class |
| 23 | +------------------------------------------------------------------------------ |
| 24 | +pg_hba.conf Editor/repairer Editor uk.org.retep.util.hba.Main |
| 25 | +Properties Editor Editor uk.org.retep.util.proped.Main |
| 26 | + |
| 27 | + |
| 28 | +Layout of the classes |
| 29 | +--------------------- |
| 30 | + |
| 31 | +Simply, tools that work on property files (Java properties, resource files, |
| 32 | +configuration settings - pg_hba.conf for example) go under uk.org.retep.util in |
| 33 | +their own package. Other utility classes (like PropertyIO) go in to the |
| 34 | +uk.org.retep.util.misc package except for certain ones where they are related. |
| 35 | + |
| 36 | +ie: TableModels. In swing you have JTable which uses a TableModel to display |
| 37 | +(and possibly update) some data. These go under uk.org.retep.util.models where |
| 38 | +you will find PropertiesTableModel for example. This one allows a Properties |
| 39 | +object to be displayed & updated. |
| 40 | + |
| 41 | +Come core classes like Logger, ExceptionDialog etc go into the main |
| 42 | +uk.org.retep.util package. |
| 43 | + |
| 44 | +Directory/Package Contents |
| 45 | +------------------------------------------------------------------------------ |
| 46 | +uk.org.retep Home of the tools.properties file |
| 47 | +uk.org.retep.tools The main all-in-one application |
| 48 | +uk.org.retep.dtu The Data Transform Unit |
| 49 | +uk.org.retep.util Core utility classes |
| 50 | +uk.org.retep.util.hba pg_hba.conf editor/repairer |
| 51 | +uk.org.retep.util.misc Misc utility classes |
| 52 | +uk.org.retep.util.models Swing table models |
| 53 | +uk.org.retep.util.proped Property Editor |
| 54 | +uk.org.retep.util.xml.core Basic XML Factory |
| 55 | +uk.org.retep.util.xml.jdbc JDBC/XML interface |
| 56 | +uk.org.retep.util.xml.parser Simple SAX parser |
| 57 | + |
| 58 | +Structure of a tool |
| 59 | +------------------- |
| 60 | + |
| 61 | +Each tool has at least 2 base classes, and an entry in the tools.properties |
| 62 | +file. For this example, I'll show you the Properties Editor: |
| 63 | + |
| 64 | +Base package uk.org.retep.util.proped |
| 65 | +Main tool class uk.org.retep.util.proped.PropertyEditor |
| 66 | +Standalone class uk.org.retep.util.proped.Main |
| 67 | + |
| 68 | +The main tool class is the entry point used by the main application. Because |
| 69 | +they are used in a GUI, this class must extend javax.swing.JComponent and |
| 70 | +implement the uk.org.retep.tools.Tool interface. (NB: You will find I always |
| 71 | +use JPanel, but JComponent is used here so that any swing class can be used |
| 72 | +you are not limited to JPanel.) |
| 73 | + |
| 74 | +The standalone class is a basic static class that implements the main method. |
| 75 | +It should extend the uk.org.retep.misc.StandaloneApp class and be written along |
| 76 | +the lines of the following example: |
| 77 | + |
| 78 | + import uk.org.retep.util.StandaloneApp; |
| 79 | + import javax.swing.JComponent; |
| 80 | + |
| 81 | + public class Main extends StandaloneApp |
| 82 | + { |
| 83 | + public Main(String[] args) |
| 84 | + throws Exception |
| 85 | + { |
| 86 | + super(args); |
| 87 | + } |
| 88 | + |
| 89 | + public JComponent init() |
| 90 | + throws Exception |
| 91 | + { |
| 92 | + // Your initialisation here. In this case the PropertyEditor |
| 93 | + PropertyEditor panel = new PropertyEditor(); |
| 94 | + |
| 95 | + // do stuff here, ie load a file if supplied |
| 96 | + |
| 97 | + // return the tool |
| 98 | + return panel; |
| 99 | + } |
| 100 | + |
| 101 | + public static void main(String[] args) |
| 102 | + throws Exception |
| 103 | + { |
| 104 | + Main main = new Main(args); |
| 105 | + main.pack(); |
| 106 | + main.setVisible(true); |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | +you will find a template in the uk.org.retep.util.Main class. Simply copy this |
| 111 | +classes source, as it gives you the basic stub. Just add your own implementation |
| 112 | +if init() like the one above. Look at the full Main class for the |
| 113 | +PropertiesEditor to see how to get at the command line args. |
| 114 | + |
| 115 | +By convention, the standalone class is named Main. |
| 116 | + |
0 commit comments