DBExplorer's custom output using SWTML
In DBExplorer, the default output for SQL result is built-in table. Now you can specify a custom output using SWTML. This gives you flexibility to create a report-style layout. Since release 2.0.3 this is now supported at Tab level. So for each Tab you can define different output format.
How To use custom layout:
-
Select SWTML for Output Format in Preference Window - Define outputformat := swtml
- Define swtml-xml := <xml> using define command
- Enter SELECT SQL
Structure of SWTML-XML :
- Define top-level SWT Composite.
<?xml version="1.0" encoding="UTF-8"?><composite style="SWT.BORDER"> <grid-data h-align="SWT.FILL" v-align="SWT.FILL" h-grab="true" v-grab="true" /> <!-- Add Labels and Texts for each column --> </composite>
- Define Label and Text for each table-column inside top-level composite. You can use any SWTML widgets, layout and resources (like color and fonts).
<label text="Page ID" /> <text id="page_id" style="SWT.BORDER" />
The Text's "id" attribute should be same as table-column name.
- Add navigation bar
SWTML has in-built event listener for record navigation
com.sheelapps.plugin.dbexplorer.output.FirstRowListener
com.sheelapps.plugin.dbexplorer.output.PreviousRowListener
com.sheelapps.plugin.dbexplorer.output.NextRowListener
com.sheelapps.plugin.dbexplorer.output.LastRowListener
You can use any SWT widget to invoke above events (Button, Tool-Item, Menu-Item etc).
Example :
/*Custom output using SWTML xml , change outputformat value to "table" to show default table output */ define outputformat := swtml ; define swtml-xml :=<?xml version="1.0" encoding="UTF-8"?><composite style="SWT.BORDER"> <grid-data h-align="SWT.FILL" v-align="SWT.FILL" h-grab="true" v-grab="true" /> <grid-layout numcolumns="2" /> <label text="Page ID" /> <text id="page_id" style="SWT.BORDER" > <grid-data h-align="SWT.FILL" h-grab="true" /> </text> <label text="Page Text" > <grid-data v-align="SWT.TOP" /> </label> <text id="pagetext" style="SWT.BORDER | SWT.MULTI | SWT.V_SCROLL"> <grid-data h-align="SWT.FILL" v-align="SWT.FILL" h-grab="true" v-grab="true" /> </text> <composite> <grid-data h-align="SWT.FILL" h-grab="true" h-span="2" /> <row-layout /> <button text="First" SWT.Selection="com.sheelapps.plugin.dbexplorer.output.FirstRowListener" /> <button text="Previous" SWT.Selection="com.sheelapps.plugin.dbexplorer.output.PreviousRowListener" /> <button text="Next" SWT.Selection="com.sheelapps.plugin.dbexplorer.output.NextRowListener" /> <button text="Last" SWT.Selection="com.sheelapps.plugin.dbexplorer.output.LastRowListener" /> <label text="${sql} took ${execution-time} secs." /> </composite> </composite> ;
SELECT page_id, pagetext FROM wb_pages ;