Skip to content

Commit

Permalink
0006449: Added a 'Show Triggers' option to SQL Explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-miller-jumpmind committed May 23, 2024
1 parent 01345d2 commit 6e32cad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ public Label apply(DbTreeNode node) {
treeData.removeItem(firstChild);
for (DbTreeNode child : node.getChildren()) {
treeData.addItem(node, child);
if (!child.getType().equals(NODE_TYPE_TRIGGER)) {
String childType = child.getType();
if (!childType.equals(NODE_TYPE_TRIGGER)
&& (settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_SHOW_TRIGGERS, "")
.equals("true") || !childType.equals(NODE_TYPE_TABLE))) {
treeData.addItem(child, new DbTreeNode(this, NODE_TYPE_PLACEHOLDER, child));
}
}
Expand Down Expand Up @@ -309,9 +312,11 @@ protected List<DbTreeNode> getTriggerTreeNodes(IDdlReader reader,
}

protected void addTriggerNodes(IDdlReader reader, DbTreeNode parent, String catalogName, String schemaName) {
List<DbTreeNode> nodes = getTriggerTreeNodes(reader, parent, catalogName, schemaName);
for (DbTreeNode treeNode : nodes) {
parent.getChildren().add(treeNode);
if (settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_SHOW_TRIGGERS, "").equals("true")) {
List<DbTreeNode> nodes = getTriggerTreeNodes(reader, parent, catalogName, schemaName);
for (DbTreeNode treeNode : nodes) {
parent.getChildren().add(treeNode);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Settings implements Serializable {
public static final String SQL_EXPLORER_MAX_RESULTS = "sql.explorer.max.results";
public static final String SQL_EXPLORER_MAX_HISTORY = "sql.explorer.max.history";
public static final String SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS = "sql.explorer.show.results.in.new.tabs";
public static final String SQL_EXPLORER_SHOW_TRIGGERS = "sql.explorer.show.triggers";
List<SqlHistory> sqlHistory = new ArrayList<SqlHistory>();
TypedProperties properties = new TypedProperties();

Expand All @@ -52,6 +53,7 @@ public Settings() {
properties.put(SQL_EXPLORER_MAX_HISTORY, "100");
properties.put(SQL_EXPLORER_IGNORE_ERRORS_WHEN_RUNNING_SCRIPTS, "false");
properties.put(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS, "false");
properties.put(SQL_EXPLORER_SHOW_TRIGGERS, "true");
}

public TypedProperties getProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class SettingsDialog extends ResizableDialog {
private Checkbox ignoreErrorsWhenRunningScript;
private Checkbox showRowNumbersBox;
private Checkbox showResultsInNewTabsBox;
private Checkbox showTriggersBox;
ISettingsProvider settingsProvider;
SqlExplorer explorer;

Expand Down Expand Up @@ -138,6 +139,10 @@ protected HorizontalLayout createSettingsLayout() {
showResultsInNewTabsBox.setValue(false);
}
settingsLayout.add(showResultsInNewTabsBox);
showTriggersBox = new Checkbox("Show Triggers");
String showTriggersValue = properties.getProperty(SQL_EXPLORER_SHOW_TRIGGERS, "false");
showTriggersBox.setValue(showTriggersValue.equals("true"));
settingsLayout.add(showTriggersBox);
layout.add(settingsLayout);
return layout;
}
Expand Down Expand Up @@ -165,6 +170,7 @@ protected boolean save() {
properties.setProperty(SQL_EXPLORER_EXCLUDE_TABLES_REGEX, excludeTablesWithPrefixField.getValue());
properties.setProperty(SQL_EXPLORER_IGNORE_ERRORS_WHEN_RUNNING_SCRIPTS, String.valueOf(ignoreErrorsWhenRunningScript.getValue()));
properties.setProperty(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS, String.valueOf(showResultsInNewTabsBox.getValue()));
properties.setProperty(SQL_EXPLORER_SHOW_TRIGGERS, String.valueOf(showTriggersBox.getValue()));
settingsProvider.save(settings);
explorer.refreshQueryPanels();
return true;
Expand Down

0 comments on commit 6e32cad

Please sign in to comment.