Skip to content

Commit

Permalink
0004943: Fixed some issues with SQL Explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-miller-jumpmind committed Oct 6, 2021
1 parent 186ab35 commit 00c19c5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
Expand Up @@ -143,6 +143,20 @@ public void remove(String name) {
}
}

public void remove(EnhancedTab tab) {
int tabCount = tabList.size();
if (tab.isSelected() && tabCount > 1) {
int index = tabList.indexOf(tab);
if (index < tabCount - 1) {
tabs.setSelectedIndex(index + 1);
} else {
tabs.setSelectedIndex(index - 1);
}
}
tabs.remove(tab);
tabList.remove(tab);
}

public void setCloseable(boolean closeable) {
this.closeable = closeable;
for (EnhancedTab tab : tabList) {
Expand Down Expand Up @@ -230,20 +244,6 @@ public void setAutoselect(boolean autoselect) {
tabs.setAutoselect(autoselect);
}

protected void remove(EnhancedTab tab) {
int tabCount = tabList.size();
if (tab.isSelected() && tabCount > 1) {
int index = tabList.indexOf(tab);
if (index < tabCount - 1) {
tabs.setSelectedIndex(index + 1);
} else {
tabs.setSelectedIndex(index - 1);
}
}
tabs.remove(tab);
tabList.remove(tab);
}

public class EnhancedTab extends Tab {

private static final long serialVersionUID = 1L;
Expand Down
Expand Up @@ -73,7 +73,7 @@ public void addCloseableTab(String caption, Icon icon, Component component) {
}

@Override
protected void remove(EnhancedTab tab) {
public void remove(EnhancedTab tab) {
Component component = tab.getComponent();
if (!(component instanceof IUiPanel) || ((IUiPanel) component).closing()) {
int tabCount = tabList.size();
Expand Down
Expand Up @@ -259,14 +259,15 @@ public void removeGeneralResultsTab() {
addResultsTab(((TabularResultLayout) content).refreshWithoutSaveButton(),
StringUtils.abbreviate(((TabularResultLayout) content).getSql(), 20), generalResultsTab.getIcon(), 0);
}
resultsTabs.remove(generalResultsTab.getComponent());
resultsTabs.remove(generalResultsTab);
generalResultsTab = null;
}
}

public void resetGeneralResultsTab() {
if (generalResultsTab != null) {
replaceGeneralResultsWith(emptyResults, null);
generalResultsTab.setCloseable(false);
}
}

Expand Down Expand Up @@ -483,7 +484,7 @@ public void finished(final VaadinIcon icon, final List<Component> results, final
} finally {
setButtonsEnabled();
if (executingTab != null) {
resultsTabs.remove(executingTab.getName());
resultsTabs.remove(executingTab);
} else if (results.size() > 1) {
resetGeneralResultsTab();
}
Expand All @@ -499,7 +500,12 @@ public void finished(final VaadinIcon icon, final List<Component> results, final
final Button cancel = new Button("Cancel");
cancel.addClickListener(event -> {
log.info("Canceling sql: " + sql);
label.setText("Canceling" + label.getText().substring(9));
String labelText = label.getText();
if (labelText != null) {
label.setText("Canceling" + labelText.substring(9));
} else {
label.setText("Canceling:\n\n" + StringUtils.abbreviate(sql, 250));
}
executingLayout.remove(cancel);
canceled = true;
new Thread(new Runnable() {
Expand Down Expand Up @@ -535,8 +541,8 @@ public void addResultsTab(Component resultComponent, String title, Icon icon, in
errorTab = null;
}

if (maxNumberOfResultTabs > 0 && resultsTabs.getComponentCount() > maxNumberOfResultTabs) {
resultsTabs.remove(resultsTabs.getTab(resultsTabs.getComponentCount() - 1));
if (maxNumberOfResultTabs > 0 && resultsTabs.getTabCount() > maxNumberOfResultTabs) {
resultsTabs.remove(resultsTabs.getTab(resultsTabs.getTabCount() - 1));
}

if (icon.equals(new Icon(VaadinIcon.STOP))) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public SqlExplorerTabPanel() {
}

@Override
protected void remove(EnhancedTab tab) {
public void remove(EnhancedTab tab) {
Component component = tab.getComponent();
if (component != null && component instanceof QueryPanel && ((QueryPanel) component).commitButtonValue) {
NotifyDialog.show("Cannot Close Tab", "You must commit or rollback queries before closing this tab.", null,
Expand Down

0 comments on commit 00c19c5

Please sign in to comment.