├── src
├── main
│ ├── resources
│ │ ├── splash.png
│ │ ├── icons
│ │ │ ├── run-24px.png
│ │ │ ├── clock-24px.png
│ │ │ ├── link-24px.png
│ │ │ ├── lock-24px.png
│ │ │ ├── lock-48px.png
│ │ │ ├── plus-24px.png
│ │ │ ├── skull-24px.png
│ │ │ ├── account-24px.png
│ │ │ ├── arrow-up-24px.png
│ │ │ ├── cancel-24px.png
│ │ │ ├── database-24px.png
│ │ │ ├── dialog-error.png
│ │ │ ├── pencil-24px.png
│ │ │ ├── settings-24px.png
│ │ │ ├── arrow-down-24px.png
│ │ │ ├── alert-outline-24px.png
│ │ │ ├── content-copy-24px.png
│ │ │ ├── content-cut-24px.png
│ │ │ ├── content-paste-24px.png
│ │ │ ├── content-save-24px.png
│ │ │ ├── folder-open-24px.png
│ │ │ ├── lan-connect-24px.png
│ │ │ ├── table-large-24px.png
│ │ │ ├── code-not-equal-24px.png
│ │ │ ├── database-search-24px.png
│ │ │ ├── delete-forever-24px.png
│ │ │ ├── logout-variant-24px.png
│ │ │ ├── content-duplicate-24px.png
│ │ │ └── table-column-width-24px.png
│ │ ├── logback.xml
│ │ ├── css
│ │ │ ├── style.css
│ │ │ └── style_dark.css
│ │ └── project.gml
│ └── java
│ │ ├── cruft
│ │ └── wtf
│ │ │ └── gimlet
│ │ │ ├── util
│ │ │ ├── package-info.java
│ │ │ ├── DispatchAppender.java
│ │ │ ├── Xdg.java
│ │ │ ├── LimitedSizePriorityQueue.java
│ │ │ └── VersionInfo.java
│ │ │ ├── ui
│ │ │ ├── drilldown
│ │ │ │ ├── package-info.java
│ │ │ │ ├── DrillResultTable.java
│ │ │ │ └── DrillDownTab.java
│ │ │ ├── objects
│ │ │ │ ├── package-info.java
│ │ │ │ ├── DatabaseObject.java
│ │ │ │ ├── ObjectsTableData.java
│ │ │ │ └── ObjectsTable.java
│ │ │ ├── Direction.java
│ │ │ ├── controls
│ │ │ │ ├── ParamInput.java
│ │ │ │ ├── LabeledSeparatorMenuItem.java
│ │ │ │ ├── StringTextField.java
│ │ │ │ ├── DatePicker.java
│ │ │ │ ├── NumberTextField.java
│ │ │ │ └── DateTimePicker.java
│ │ │ ├── NavigationPane.java
│ │ │ ├── AliasPane.java
│ │ │ ├── FormPane.java
│ │ │ ├── dialog
│ │ │ │ ├── PasswordInputDialog.java
│ │ │ │ ├── QueryReferenceDialog.java
│ │ │ │ ├── ColumnContentDialog.java
│ │ │ │ ├── AboutWindow.java
│ │ │ │ ├── SettingsDialog.java
│ │ │ │ ├── FileDialogs.java
│ │ │ │ ├── QueryDialog.java
│ │ │ │ └── CopyAsDialog.java
│ │ │ ├── ProjectPropertiesPane.java
│ │ │ ├── QueryPane.java
│ │ │ ├── JdbcPropertiesTab.java
│ │ │ ├── ResultTabPane.java
│ │ │ ├── ResultSetCell.java
│ │ │ ├── StatusBar.java
│ │ │ ├── JdbcPropertiesTable.java
│ │ │ ├── ResultTable.java
│ │ │ ├── ResultTableRow.java
│ │ │ ├── RotatedTable.java
│ │ │ ├── BasicQueryTree.java
│ │ │ ├── Images.java
│ │ │ ├── LogTable.java
│ │ │ └── ConnectionTabPane.java
│ │ │ ├── jdbc
│ │ │ ├── package-info.java
│ │ │ ├── task
│ │ │ │ ├── package-info.java
│ │ │ │ ├── SimpleQueryTask.java
│ │ │ │ ├── NamedQueryTask.java
│ │ │ │ ├── ConnectTask.java
│ │ │ │ ├── ConnectionValidityTimer.java
│ │ │ │ ├── TableColumnMetaDataTask.java
│ │ │ │ ├── QueryTask.java
│ │ │ │ └── ObjectLoaderTask.java
│ │ │ ├── Column.java
│ │ │ ├── CachedRowSetTransformer.java
│ │ │ └── SqlType.java
│ │ │ ├── event
│ │ │ ├── package-info.java
│ │ │ ├── FileSavedEvent.java
│ │ │ ├── LoadProjectEvent.java
│ │ │ ├── ScriptExecutedEvent.java
│ │ │ ├── ConnectEvent.java
│ │ │ ├── FileOpenedEvent.java
│ │ │ ├── EventDispatcher.java
│ │ │ ├── QueryExecuteEvent.java
│ │ │ └── QueryExecutedEvent.java
│ │ │ ├── conf
│ │ │ ├── Item.java
│ │ │ └── Alias.java
│ │ │ ├── RecentProjectList.java
│ │ │ ├── Script.java
│ │ │ └── ScriptLoader.java
│ │ └── module-info.java
├── assembly
│ ├── bin
│ │ ├── gimlet.bat
│ │ ├── gimletw.bat
│ │ └── gimlet.sh
│ ├── drivers
│ │ └── README.md
│ ├── distribution.xml
│ └── etc
│ │ ├── example.gml
│ │ └── hsql-test-data.bsh
└── test
│ ├── resources
│ ├── exporter
│ │ ├── case03.txt
│ │ ├── case02.txt
│ │ ├── case01.txt
│ │ └── html.html
│ ├── scripts
│ │ ├── bad_register.bsh
│ │ ├── ok_bindings.bsh
│ │ └── ok.bsh
│ ├── create.sql
│ ├── sql
│ │ ├── complete-expected.sql
│ │ └── complete-actual.sql
│ └── project.xml
│ └── java
│ └── cruft
│ └── wtf
│ └── gimlet
│ ├── TestUtils.java
│ ├── conf
│ ├── AliasTest.java
│ ├── GimletProjectTest.java
│ └── QueryTest.java
│ ├── util
│ └── LimitedSizePriorityQueueTest.java
│ ├── jdbc
│ ├── task
│ │ ├── QueryTaskTest.java
│ │ └── SimpleQueryTaskTest.java
│ ├── SqlUtil.java
│ └── ParseResultTest.java
│ ├── TestTask.java
│ ├── ScriptLoaderTest.java
│ ├── ScriptTest.java
│ └── DataConverterTest.java
├── .gitignore
└── LICENSE
/src/main/resources/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/splash.png
--------------------------------------------------------------------------------
/src/main/resources/icons/run-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/run-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/clock-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/clock-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/link-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/link-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/lock-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/lock-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/lock-48px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/lock-48px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/plus-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/plus-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/skull-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/skull-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/account-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/account-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/arrow-up-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/arrow-up-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/cancel-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/cancel-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/database-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/database-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/dialog-error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/dialog-error.png
--------------------------------------------------------------------------------
/src/main/resources/icons/pencil-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/pencil-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/settings-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/settings-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/arrow-down-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/arrow-down-24px.png
--------------------------------------------------------------------------------
/src/assembly/bin/gimlet.bat:
--------------------------------------------------------------------------------
1 | java -cp "..\lib\*;..\drivers\*" --module-path="..\lib" --add-modules=javafx.controls cruft.wtf.gimlet.GimletApp
--------------------------------------------------------------------------------
/src/assembly/bin/gimletw.bat:
--------------------------------------------------------------------------------
1 | javaw -cp "..\lib\*;..\drivers\*" --module-path="..\lib" --add-modules=javafx.controls cruft.wtf.gimlet.GimletApp
--------------------------------------------------------------------------------
/src/main/resources/icons/alert-outline-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/alert-outline-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/content-copy-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/content-copy-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/content-cut-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/content-cut-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/content-paste-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/content-paste-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/content-save-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/content-save-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/folder-open-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/folder-open-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/lan-connect-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/lan-connect-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/table-large-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/table-large-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/code-not-equal-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/code-not-equal-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/database-search-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/database-search-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/delete-forever-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/delete-forever-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/logout-variant-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/logout-variant-24px.png
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Miscellaneous classes which are too varied.
3 | */
4 | package cruft.wtf.gimlet.util;
--------------------------------------------------------------------------------
/src/main/resources/icons/content-duplicate-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/content-duplicate-24px.png
--------------------------------------------------------------------------------
/src/main/resources/icons/table-column-width-24px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/krpors/gimlet/HEAD/src/main/resources/icons/table-column-width-24px.png
--------------------------------------------------------------------------------
/src/assembly/bin/gimlet.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | java -cp "../lib/*:../drivers/*" --module-path="../lib" --add-modules=javafx.controls cruft.wtf.gimlet.GimletApp $@
--------------------------------------------------------------------------------
/src/assembly/drivers/README.md:
--------------------------------------------------------------------------------
1 | # Drivers
2 |
3 | This directory can be used to put JDBC driver in. They will be automatically
4 | loaded by the shell script when starting Gimlet.
--------------------------------------------------------------------------------
/src/test/resources/exporter/case03.txt:
--------------------------------------------------------------------------------
1 | Kevin;Pors
2 | Derpy;Derpington
3 | Cruft and all;Jazzy newsflash
4 | Ozzy;Bozzy something
5 | This col;The other column, contains a newline!!
6 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/drilldown/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains the classes responsible for the drilldown tab and the
3 | * functionality therein.
4 | */
5 | package cruft.wtf.gimlet.ui.drilldown;
--------------------------------------------------------------------------------
/src/test/resources/exporter/case02.txt:
--------------------------------------------------------------------------------
1 | LARGE_FIRST_COLUMN_NAME|Two
2 | Kevin|Pors
3 | Derpy|Derpington
4 | Cruft and all|Jazzy newsflash
5 | Ozzy|Bozzy something
6 | This col|The other column, contains a newline!!
7 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/bad_register.bsh:
--------------------------------------------------------------------------------
1 | script_register() {
2 | return new String[] {
3 | "Example script, only one array element (FAULTY!)"
4 | };
5 | }
6 |
7 | script_execute() {
8 | return "fail!";
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/jdbc/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains classes specific to the interaction with databases and its objects, and the
3 | * POJOs for usages in the user interface.
4 | */
5 | package cruft.wtf.gimlet.jdbc;
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/jdbc/task/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains mostly asynchronous timed tasks or the like, which run
3 | * on the background and do something when the task is finished.
4 | */
5 | package cruft.wtf.gimlet.jdbc.task;
--------------------------------------------------------------------------------
/src/test/resources/scripts/ok_bindings.bsh:
--------------------------------------------------------------------------------
1 | script_register() {
2 | return new String[] {
3 | "Example script for bindings",
4 | "Example script description",
5 | "Herp A. Derp"
6 | };
7 | }
8 |
9 | script_execute() {
10 | return someVar * 8;
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/objects/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains classes for the "Database objects" tabs and all things relevant.
3 | * It contains (meta) information about the database, including schemas, tables, columns and such.
4 | */
5 | package cruft.wtf.gimlet.ui.objects;
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains lightweight POJOs with events emitted by the {@link cruft.wtf.gimlet.event.EventDispatcher}.
3 | * Consumers can listen for these events to do something with the information given.
4 | */
5 | package cruft.wtf.gimlet.event;
--------------------------------------------------------------------------------
/src/test/resources/exporter/case01.txt:
--------------------------------------------------------------------------------
1 | LARGE_FIRST_COLUMN_NAME |Two
2 | Kevin |Pors
3 | Derpy |Derpington
4 | Cruft and all |Jazzy newsflash
5 | Ozzy |Bozzy something
6 | This col |The other column, contains a newline!!
7 |
--------------------------------------------------------------------------------
/src/test/resources/create.sql:
--------------------------------------------------------------------------------
1 | drop table customer if exists;
2 | drop table invoice if exists;
3 |
4 | create table customer(
5 | id int,
6 | name varchar(32)
7 | );
8 |
9 | insert into customer values (0, 'Kevin');
10 |
11 | create table invoice(
12 | id int,
13 | customer_id int,
14 | );
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/Direction.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui;
2 |
3 | /**
4 | * Enumeration to clarify movement direction.
5 | */
6 | public enum Direction {
7 | UP(-1),
8 | DOWN(1);
9 |
10 | protected final int dir;
11 |
12 | Direction(int dir) {
13 | this.dir = dir;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/resources/exporter/html.html:
--------------------------------------------------------------------------------
1 |
| LARGE_FIRST_COLUMN_NAME | Two |
|---|
| Kevin | Pors |
| Derpy | Derpington |
| Cruft and all | Jazzy newsflash |
| Ozzy | Bozzy <b>something</b> |
| This col | The other column, contains
2 | a newline!! |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/FileSavedEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import java.io.File;
4 |
5 | public class FileSavedEvent {
6 | private File file;
7 |
8 | public FileSavedEvent(File file) {
9 | this.file = file;
10 | }
11 |
12 | public File getFile() {
13 | return file;
14 | }
15 |
16 | public void setFile(File file) {
17 | this.file = file;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/LoadProjectEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * Event emitted when a project is attempt to be loaded.
7 | */
8 | public class LoadProjectEvent {
9 | private final File file;
10 |
11 | public LoadProjectEvent(File file) {
12 | this.file = file;
13 | }
14 |
15 | public File getFile() {
16 | return file;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/ScriptExecutedEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | public class ScriptExecutedEvent {
4 |
5 | private Object message;
6 |
7 | public ScriptExecutedEvent(Object message) {
8 | this.message = message;
9 | }
10 |
11 | public Object getMessage() {
12 | return message;
13 | }
14 |
15 | public void setMessage(Object message) {
16 | this.message = message;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/sql/complete-expected.sql:
--------------------------------------------------------------------------------
1 | -- This file contains a complete SQL with all possible variations to
2 | -- test the parsing.
3 |
4 | /*
5 | This is some multiline comment. It's not officially supported in regular SQL,
6 | but we apparently support it anyway.
7 | */
8 |
9 | -- Actual query
10 | select
11 | id,
12 | name::varchar -- test casting here
13 | from some_table
14 | where
15 | some_table.id = ?
16 | and some_table.name = ?
17 | and some_table.other = ?
18 | and some_table.bla = ?
19 | and some_table.somenum = ?
20 | and some_other_table = ? -- same id here
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 |
24 | # IntelliJ:
25 | *.iml
26 | .idea
27 |
28 | # Maven
29 | target
30 | dependency-reduced-pom.xml
31 | *.versionsBackup
32 |
33 | # hsql cruft
34 | hsql:mem.properties
35 | hsql:mem.script
36 | mem.properties
37 | mem.script
38 |
39 |
--------------------------------------------------------------------------------
/src/test/resources/sql/complete-actual.sql:
--------------------------------------------------------------------------------
1 | -- This file contains a complete SQL with all possible variations to
2 | -- test the parsing.
3 |
4 | /*
5 | This is some multiline comment. It's not officially supported in regular SQL,
6 | but we apparently support it anyway.
7 | */
8 |
9 | -- Actual query
10 | select
11 | id,
12 | name::varchar -- test casting here
13 | from some_table
14 | where
15 | some_table.id = :id
16 | and some_table.name = :name[STRING]
17 | and some_table.other = :other[DATE]
18 | and some_table.bla = :bla[DATETIME]
19 | and some_table.somenum = :num[NUMBER]
20 | and some_other_table = :id -- same id here
21 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/drilldown/DrillResultTable.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.drilldown;
2 |
3 |
4 | import cruft.wtf.gimlet.conf.Query;
5 | import cruft.wtf.gimlet.ui.ResultTable;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /**
10 | * This class is a specialization of the regular {@link ResultTable}. The main difference is that this class allows us
11 | * to 'drill down'.
12 | */
13 | public class DrillResultTable extends ResultTable {
14 |
15 |
16 | public DrillResultTable(final Query query) {
17 | setRowFactory(param -> new DrillResultTableRow(query));
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/TestUtils.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | public final class TestUtils {
7 |
8 | public static String readFromClasspath(String name) {
9 | StringBuilder b = new StringBuilder();
10 | try (InputStream is = TestUtils.class.getResourceAsStream(name)) {
11 | int c;
12 | while ((c = is.read()) != -1) {
13 | b.append((char)c);
14 | }
15 | } catch (IOException e) {
16 | e.printStackTrace();
17 | }
18 |
19 | return b.toString();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/ok.bsh:
--------------------------------------------------------------------------------
1 | /**
2 | * The script_register function will be invoked by Gimlet to register the plugin.
3 | * It must return (for now) an array of three elements.
4 | */
5 | script_register() {
6 | name = "Example script";
7 | desc = "Example script description";
8 | author = "Herp A. Derp";
9 |
10 | return new String[] {
11 | name,
12 | desc,
13 | author
14 | };
15 | }
16 |
17 | /**
18 | * This function will be executed by Gimlet if the script is selected for running.
19 | */
20 | script_execute() {
21 | print("This is the execution of an example script");
22 | return "OK";
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/util/DispatchAppender.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.util;
2 |
3 | import ch.qos.logback.classic.spi.ILoggingEvent;
4 | import ch.qos.logback.core.AppenderBase;
5 | import cruft.wtf.gimlet.event.EventDispatcher;
6 |
7 | /**
8 | * Extremely simple appender which effectively just dispatches the logging event to the event bus.
9 | *
10 | * @see cruft.wtf.gimlet.ui.LogTable#onLoggingEvent(ILoggingEvent)
11 | */
12 | public class DispatchAppender extends AppenderBase {
13 |
14 | @Override
15 | protected void append(ILoggingEvent iLoggingEvent) {
16 | EventDispatcher.getInstance().post(iLoggingEvent);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/conf/AliasTest.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.conf;
2 |
3 | import jakarta.xml.bind.JAXBContext;
4 | import jakarta.xml.bind.JAXBException;
5 | import jakarta.xml.bind.Marshaller;
6 | import org.junit.jupiter.api.Test;
7 |
8 | public class AliasTest {
9 |
10 | @Test
11 | public void asd() throws JAXBException {
12 | Alias a = new Alias();
13 | a.getJdbcProperties().put("k1", "v1");
14 |
15 | JAXBContext ctx = JAXBContext.newInstance(Alias.class);
16 | Marshaller m = ctx.createMarshaller();
17 | m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
18 | m.marshal(a, System.out);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/jdbc/task/SimpleQueryTask.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.jdbc.task;
2 |
3 | import java.sql.Connection;
4 | import java.sql.PreparedStatement;
5 | import java.sql.SQLException;
6 |
7 | /**
8 | * A JavaFX task to run a simple query (i.e. a typed query, without named parameters).
9 | */
10 | public class SimpleQueryTask extends QueryTask {
11 |
12 | public SimpleQueryTask(final Connection connection, final String query, int maxRows) {
13 | super(connection, query, maxRows);
14 | }
15 |
16 | @Override
17 | public PreparedStatement prepareStatement() throws SQLException {
18 | return this.connection.prepareStatement(query);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/jdbc/Column.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.jdbc;
2 |
3 | public class Column {
4 |
5 | private final int type;
6 |
7 | private final String columnName;
8 |
9 | public Column(String columnName) {
10 | this(-1, columnName);
11 | }
12 |
13 | public Column(int type, String columnName) {
14 | this.type = type;
15 | this.columnName = columnName;
16 | }
17 |
18 | public int getType() {
19 | return type;
20 | }
21 |
22 | public String getColumnName() {
23 | return columnName;
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | return "Column{" +
29 | "type=" + type +
30 | ", columnName='" + columnName + '\'' +
31 | '}';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | module gimlet {
2 | requires java.base;
3 | requires java.scripting;
4 | requires java.xml;
5 | requires java.sql;
6 | requires java.sql.rowset;
7 |
8 | requires com.google.common;
9 | requires ch.qos.logback.classic;
10 | requires ch.qos.logback.core;
11 | requires org.slf4j;
12 | requires jakarta.activation;
13 | requires jakarta.xml.bind;
14 |
15 | requires javafx.base;
16 | requires javafx.controls;
17 | requires javafx.graphics;
18 |
19 | // Third party libs require us to export certain packages for introspection.
20 | exports cruft.wtf.gimlet;
21 | exports cruft.wtf.gimlet.ui;
22 | exports cruft.wtf.gimlet.util;
23 |
24 | // Some opens directives for Guava as well.
25 | opens cruft.wtf.gimlet;
26 | opens cruft.wtf.gimlet.conf to jakarta.xml.bind;
27 |
28 |
29 | }
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/ConnectEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import cruft.wtf.gimlet.conf.Alias;
4 |
5 | /**
6 | * Emitted when a connection attempt has occurred.
7 | */
8 | public class ConnectEvent {
9 |
10 | public enum Type {
11 | INITATED,
12 | CONNECTED,
13 | CLOSED;
14 | }
15 |
16 | private Alias alias;
17 | private Type type;
18 |
19 | public ConnectEvent(Type type, Alias alias) {
20 | this.type = type;
21 | this.alias = alias;
22 | }
23 |
24 | public Alias getAlias() {
25 | return alias;
26 | }
27 |
28 | public void setAlias(Alias alias) {
29 | this.alias = alias;
30 | }
31 |
32 | public Type getType() {
33 | return type;
34 | }
35 |
36 | public void setType(Type type) {
37 | this.type = type;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/controls/ParamInput.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.controls;
2 |
3 | /**
4 | * This interface provides methods which can be used by the {@link cruft.wtf.gimlet.ui.dialog.ParamInputDialog},
5 | * to get and set parameters based on specific JavaFX controls in this package.
6 | */
7 | public interface ParamInput {
8 |
9 | /**
10 | * Gets the parameter name for the input dialog. Usually this is just the {@link javafx.scene.Node}'s ID.
11 | *
12 | * @return The parameter name.
13 | */
14 | String getParameterName();
15 |
16 | /**
17 | * Gets the parameter value which has been set in the control.
18 | *
19 | * @return The parameter value.
20 | */
21 | Object getParameterValue();
22 |
23 | /**
24 | * Sets the parameter value.
25 | *
26 | * @param o The value.
27 | */
28 | void setParameterValue(Object o);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/FileOpenedEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import cruft.wtf.gimlet.conf.GimletProject;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * Emitted when a file has been opened successfully.
9 | */
10 | public class FileOpenedEvent {
11 | private File file;
12 |
13 | private GimletProject gimletProject;
14 |
15 | public FileOpenedEvent(File file, GimletProject gimletProject) {
16 | this.file = file;
17 | this.gimletProject = gimletProject;
18 | }
19 |
20 | public File getFile() {
21 | return file;
22 | }
23 |
24 | public void setFile(File file) {
25 | this.file = file;
26 | }
27 |
28 | public GimletProject getGimletProject() {
29 | return gimletProject;
30 | }
31 |
32 | public void setGimletProject(GimletProject gimletProject) {
33 | this.gimletProject = gimletProject;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/EventDispatcher.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import com.google.common.eventbus.EventBus;
4 |
5 | /**
6 | * JVM-wide event dispatcher.
7 | */
8 | public final class EventDispatcher {
9 | private static EventDispatcher ourInstance = new EventDispatcher();
10 |
11 | private EventBus eventBus;
12 |
13 | public static EventDispatcher getInstance() {
14 | return ourInstance;
15 | }
16 |
17 | private EventDispatcher() {
18 | this.eventBus = new EventBus("javafx-dispatcher");
19 | }
20 |
21 | public String identifier() {
22 | return eventBus.identifier();
23 | }
24 |
25 | public void register(Object object) {
26 | eventBus.register(object);
27 | }
28 |
29 | public void unregister(Object object) {
30 | eventBus.unregister(object);
31 | }
32 |
33 | public void post(Object event) {
34 | eventBus.post(event);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/QueryExecuteEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import cruft.wtf.gimlet.conf.Query;
4 |
5 | import java.util.Map;
6 | import java.util.TreeMap;
7 |
8 | public class QueryExecuteEvent {
9 |
10 | private Query query;
11 |
12 | private String targetTab;
13 |
14 | private Map columnnMap = new TreeMap<>();
15 |
16 | public Query getQuery() {
17 | return query;
18 | }
19 |
20 | public void setQuery(Query query) {
21 | this.query = query;
22 | }
23 |
24 | public Map getColumnnMap() {
25 | return columnnMap;
26 | }
27 |
28 | public void setColumnnMap(Map columnnMap) {
29 | this.columnnMap = columnnMap;
30 | }
31 |
32 | public String getTargetTab() {
33 | return targetTab;
34 | }
35 |
36 | public void setTargetTab(String targetTab) {
37 | this.targetTab = targetTab;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/controls/LabeledSeparatorMenuItem.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.controls;
2 |
3 | import javafx.scene.control.CustomMenuItem;
4 | import javafx.scene.control.Label;
5 | import javafx.scene.control.Tooltip;
6 |
7 | /**
8 | * This is a simple menu item for separation, but instead of using a horizontal
9 | * rule, we use a label.
10 | */
11 | public class LabeledSeparatorMenuItem extends CustomMenuItem {
12 |
13 | private Label lbl;
14 |
15 | public LabeledSeparatorMenuItem(String text) {
16 | // We must give the item, AND the label the same class
17 | // or else we get the (blue) highlighting as well of the item!
18 | getStyleClass().add("labeledMenuItem");
19 |
20 | setHideOnClick(false);
21 | lbl = new Label(text);
22 | lbl.getStyleClass().add("labeledMenuItem");
23 | setContent(lbl);
24 | }
25 |
26 | public void setTooltip(Tooltip tooltip) {
27 | lbl.setTooltip(tooltip);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/controls/StringTextField.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.controls;
2 |
3 | import javafx.scene.control.TextField;
4 |
5 | import java.util.Map;
6 | import java.util.Set;
7 |
8 | /**
9 | * Basically this is just a specialization of a {@link TextField}, except it satisfies the {@link ParamInput}
10 | * interface so it can be transparently used by the {@link cruft.wtf.gimlet.ui.dialog.ParamInputDialog}.
11 | *
12 | * @see cruft.wtf.gimlet.ui.dialog.ParamInputDialog#ParamInputDialog(String, Set)
13 | * @see cruft.wtf.gimlet.ui.dialog.ParamInputDialog#prefill(Map)
14 | */
15 | public class StringTextField extends TextField implements ParamInput {
16 | @Override
17 | public String getParameterName() {
18 | return getId();
19 | }
20 |
21 | @Override
22 | public Object getParameterValue() {
23 | return getText();
24 | }
25 |
26 | @Override
27 | public void setParameterValue(Object o) {
28 | setText(String.valueOf(o));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/util/LimitedSizePriorityQueueTest.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.util;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import static org.junit.jupiter.api.Assertions.assertEquals;
6 |
7 | public class LimitedSizePriorityQueueTest {
8 |
9 | @Test
10 | public void all() {
11 | LimitedSizePriorityQueue s = new LimitedSizePriorityQueue<>(5);
12 | s.push("first");
13 | s.push("second");
14 | s.push("third");
15 | s.push("fourth");
16 | s.push("fifth");
17 | s.push("sixth");
18 | s.push("seventh");
19 | s.push("eighth");
20 | s.push("ninth");
21 |
22 | s.push("eighth"); // this should now be the first again.
23 |
24 | assertEquals(5, s.size());
25 |
26 | assertEquals("eighth", s.pop());
27 | assertEquals("ninth", s.pop());
28 | assertEquals("seventh", s.pop());
29 | assertEquals("sixth", s.pop());
30 | assertEquals("fifth", s.pop());
31 |
32 | assertEquals(0, s.size());
33 | }
34 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Kevin Pors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/conf/GimletProjectTest.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.conf;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import static org.junit.jupiter.api.Assertions.assertEquals;
6 | import static org.junit.jupiter.api.Assertions.assertNotNull;
7 |
8 | public class GimletProjectTest {
9 |
10 | @Test
11 | public void findQueryByName() throws Exception{
12 | GimletProject gp = GimletProject.read(GimletProjectTest.class.getResourceAsStream("/project.xml"));
13 | assertNotNull(gp);
14 |
15 | Query q = gp.findQueryByName("Some other query");
16 | assertEquals("Some other query", q.getName());
17 | assertEquals(gp.getQueries().get(0).getSubQueries().get(1), q);
18 | }
19 |
20 | @Test
21 | public void read() throws Exception {
22 | GimletProject gp = GimletProject.read(GimletProjectTest.class.getResourceAsStream("/project.xml"));
23 | assertNotNull(gp);
24 | assertNotNull(gp.getName());
25 | assertNotNull(gp.getDescription());
26 | assertEquals(2, gp.getAliases().size());
27 | assertEquals(1, gp.getQueries().size());
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/event/QueryExecutedEvent.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.event;
2 |
3 | import cruft.wtf.gimlet.conf.Query;
4 |
5 | /**
6 | * Event emitted when a {@link Query} was executed successfully.
7 | */
8 | public class QueryExecutedEvent {
9 | private String query;
10 |
11 | private int rowCount;
12 |
13 | private Long runtime;
14 |
15 | public QueryExecutedEvent() {
16 | }
17 |
18 | public QueryExecutedEvent(final String query, final int rowCount, final Long runtime) {
19 | this.query = query;
20 | this.rowCount = rowCount;
21 | this.runtime = runtime;
22 | }
23 |
24 | public String getQuery() {
25 | return query;
26 | }
27 |
28 | public void setQuery(String query) {
29 | this.query = query;
30 | }
31 |
32 | public int getRowCount() {
33 | return rowCount;
34 | }
35 |
36 | public void setRowCount(int rowCount) {
37 | this.rowCount = rowCount;
38 | }
39 |
40 | public Long getRuntime() {
41 | return runtime;
42 | }
43 |
44 | public void setRuntime(Long runtime) {
45 | this.runtime = runtime;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/jdbc/task/QueryTaskTest.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.jdbc.task;
2 |
3 | import cruft.wtf.gimlet.jdbc.SqlUtil;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import javax.sql.rowset.CachedRowSet;
7 | import java.sql.Connection;
8 | import java.sql.DriverManager;
9 | import java.sql.PreparedStatement;
10 | import java.sql.SQLException;
11 |
12 | public class QueryTaskTest {
13 |
14 | @Test
15 | public void asdas() throws Exception {
16 | Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:querytasktest;shutdown=true");
17 | SqlUtil.runSql("/create.sql", c);
18 |
19 | QueryTask queryTask = new QueryTask(c, "select * from customer") {
20 | @Override
21 | public PreparedStatement prepareStatement() throws SQLException {
22 | return connection.prepareStatement(getQuery());
23 | }
24 | };
25 |
26 | CachedRowSet rowSet = queryTask.call();
27 | while (rowSet.next()) {
28 | System.out.println(rowSet.getString(2));
29 | }
30 | rowSet.release();
31 | rowSet.close();
32 |
33 | c.close();
34 | }
35 | }
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/NavigationPane.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui;
2 |
3 | import cruft.wtf.gimlet.event.EventDispatcher;
4 | import javafx.geometry.Insets;
5 | import javafx.geometry.Orientation;
6 | import javafx.scene.control.Separator;
7 | import javafx.scene.control.Tab;
8 | import javafx.scene.control.TabPane;
9 | import javafx.scene.layout.BorderPane;
10 |
11 | public class NavigationPane extends BorderPane {
12 |
13 | private AliasPane aliasPane = new AliasPane();
14 | private QueryPane queryPane = new QueryPane();
15 |
16 | public NavigationPane() {
17 | createCenter();
18 |
19 | EventDispatcher.getInstance().register(this);
20 | }
21 |
22 | public void createCenter() {
23 | Tab tabAliases = new Tab("Aliases", this.aliasPane);
24 | tabAliases.setGraphic(Images.ACCOUNT_LOGIN.imageView());
25 | tabAliases.setClosable(false);
26 | Tab tabQueries = new Tab("Queries", this.queryPane);
27 | tabQueries.setGraphic(Images.MAGNIFYING_GLASS.imageView());
28 | tabQueries.setClosable(false);
29 | TabPane tabPane = new TabPane(tabAliases, tabQueries);
30 | setCenter(tabPane);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/AliasPane.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui;
2 |
3 | import javafx.scene.control.Button;
4 | import javafx.scene.control.ToolBar;
5 | import javafx.scene.control.Tooltip;
6 | import javafx.scene.layout.BorderPane;
7 |
8 | /**
9 | * The {@link AliasPane} is nothing more than a container for the {@link AliasList} and a toolbar containing
10 | * buttons for actions on the list itself.
11 | */
12 | public class AliasPane extends BorderPane {
13 |
14 | private AliasList aliasList;
15 |
16 | public AliasPane() {
17 | this.aliasList = new AliasList();
18 |
19 | Button btnUp = new Button("", Images.ARROW_UP.imageView());
20 | btnUp.setOnAction(event -> this.aliasList.moveAlias(Direction.UP));
21 | btnUp.setTooltip(new Tooltip("Move selected alias up"));
22 |
23 | Button btnDown = new Button("", Images.ARROW_DOWN.imageView());
24 | btnDown.setOnAction(event -> this.aliasList.moveAlias(Direction.DOWN));
25 | btnDown.setTooltip(new Tooltip("Move selected alias down"));
26 |
27 | ToolBar bar = new ToolBar(btnUp, btnDown);
28 |
29 | setTop(bar);
30 | setCenter(this.aliasList);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/FormPane.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui;
2 |
3 | import javafx.geometry.Insets;
4 | import javafx.geometry.VPos;
5 | import javafx.scene.Node;
6 | import javafx.scene.control.Label;
7 | import javafx.scene.control.OverrunStyle;
8 | import javafx.scene.layout.ColumnConstraints;
9 | import javafx.scene.layout.GridPane;
10 | import javafx.scene.layout.Priority;
11 |
12 | public class FormPane extends GridPane {
13 |
14 | private int rowCounter = 0;
15 |
16 | public FormPane() {
17 | setHgap(10);
18 | setVgap(5);
19 | setPadding(new Insets(10));
20 |
21 | ColumnConstraints col1 = new ColumnConstraints();
22 | ColumnConstraints col2 = new ColumnConstraints();
23 | col1.setMinWidth(90);
24 | col2.setHgrow(Priority.ALWAYS);
25 |
26 | getColumnConstraints().addAll(col1, col2);
27 | }
28 |
29 | public void add(String label, Node node) {
30 | Label lbl = new Label(label);
31 | GridPane.setValignment(lbl, VPos.CENTER);
32 | lbl.setMnemonicParsing(true);
33 | lbl.setLabelFor(node);
34 | super.add(lbl, 0, rowCounter);
35 | super.add(node, 1, rowCounter);
36 | rowCounter++;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/TestTask.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet;
2 |
3 | import cruft.wtf.gimlet.jdbc.SqlUtil;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import javax.sql.rowset.CachedRowSet;
7 | import javax.sql.rowset.RowSetProvider;
8 | import java.sql.Connection;
9 | import java.sql.DriverManager;
10 | import java.sql.ResultSet;
11 | import java.sql.Statement;
12 |
13 | public class TestTask {
14 |
15 | @Test
16 | public void stuff() throws Exception {
17 | CachedRowSet rowSet = null;
18 |
19 | Connection c = DriverManager.getConnection("jdbc:hsqldb:mem");
20 | SqlUtil.runSql("/create.sql", c);
21 | rowSet = RowSetProvider.newFactory().createCachedRowSet();
22 | rowSet.setReadOnly(true);
23 | Statement stmt = c.createStatement();
24 | ResultSet rs = stmt.executeQuery("select * from customer");
25 | rowSet.populate(rs);
26 | rs.close();
27 | stmt.close();
28 |
29 |
30 | while (rowSet.next()) {
31 | System.out.println(rowSet.getString(2));
32 | }
33 |
34 | rowSet.restoreOriginal();
35 |
36 | while (rowSet.next()) {
37 | System.out.println(rowSet.getString(2));
38 | }
39 |
40 | rowSet.release();
41 | rowSet.close();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/dialog/PasswordInputDialog.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.dialog;
2 |
3 |
4 | import cruft.wtf.gimlet.GimletApp;
5 | import cruft.wtf.gimlet.ui.Images;
6 | import javafx.scene.control.ButtonType;
7 | import javafx.scene.control.Dialog;
8 | import javafx.scene.control.PasswordField;
9 | import javafx.scene.layout.BorderPane;
10 |
11 | /**
12 | * Simple dialog to enter a password.
13 | */
14 | public class PasswordInputDialog extends Dialog {
15 |
16 | public PasswordInputDialog(String username) {
17 | initOwner(GimletApp.window);
18 | setTitle("Input for query");
19 | setHeaderText("Specify password for user '" + username + "'");
20 | setGraphic(Images.LOCK_LOCKED_4X.imageView());
21 |
22 | BorderPane pane = new BorderPane();
23 | PasswordField field = new PasswordField();
24 | pane.setCenter(field);
25 |
26 | getDialogPane().setContent(pane);
27 | getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
28 | setWidth(320);
29 | setHeight(240);
30 |
31 | setResultConverter(btnType -> {
32 | if (btnType == ButtonType.OK) {
33 | // convert cruft to hashmap.
34 | return field.getText();
35 | }
36 |
37 | return null;
38 | });
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/cruft/wtf/gimlet/ui/objects/DatabaseObject.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet.ui.objects;
2 |
3 | public class DatabaseObject {
4 |
5 | public static final int ROOT = 0;
6 |
7 | public static final int SCHEMA = 1;
8 |
9 | public static final int TABLE = 2;
10 |
11 | public static final int COLUMN = 3;
12 |
13 | private int type;
14 |
15 | private String schema;
16 |
17 | private String table;
18 |
19 | public DatabaseObject(int type, String schema, String table) {
20 | this.type = type;
21 | this.schema = schema;
22 | this.table = table;
23 | }
24 |
25 | public int getType() {
26 | return type;
27 | }
28 |
29 | public void setType(int type) {
30 | this.type = type;
31 | }
32 |
33 | public String getTable() {
34 | return table;
35 | }
36 |
37 | public void setTable(String table) {
38 | this.table = table;
39 | }
40 |
41 | public String getSchema() {
42 | return schema;
43 | }
44 |
45 | public void setSchema(String schema) {
46 | this.schema = schema;
47 | }
48 |
49 | public String getDisplayName() {
50 | if (table != null) {
51 | return table;
52 | } else if (schema != null) {
53 | return schema;
54 | } else {
55 | return "!NO NAME!";
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/cruft/wtf/gimlet/ScriptLoaderTest.java:
--------------------------------------------------------------------------------
1 | package cruft.wtf.gimlet;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.nio.file.Path;
6 | import java.nio.file.Paths;
7 | import java.util.List;
8 |
9 | import static org.junit.jupiter.api.Assertions.*;
10 |
11 | public class ScriptLoaderTest {
12 |
13 | /**
14 | * This test checks the {@link ScriptLoader#load(String, boolean)} method.
15 | *
16 | * @throws Exception If anything fails.
17 | */
18 | @Test
19 | public void loadScripts() throws Exception {
20 | Path p = Paths.get(ScriptLoaderTest.class.getResource("/scripts/").toURI());
21 | List