Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Wisser/Jailer.git
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser committed Dec 6, 2024
2 parents 1e23a69 + 8e6740c commit 901a079
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 24 deletions.
3 changes: 3 additions & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
16.5.3
- Fix: the file name was not displayed in the titles of the SQL console tabs.

16.5.2
- The desktop overview view has been improved.
- Some JDBC drivers were updated.
Expand Down
8 changes: 6 additions & 2 deletions src/main/gui/net/sf/jailer/ui/DbConnectionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void select(ConnectionInfo ci) {
}
}

public boolean connectSilent(ConnectionInfo ci) {
public boolean connectSilent(ConnectionInfo ci, Runnable[] afterConnectAction) {
if (connectionsTable.getModel().getRowCount() > 0) {
int cRI = -1;
for (int i = 0; i < connectionList.size(); ++i) {
Expand Down Expand Up @@ -376,7 +376,11 @@ public boolean connectSilent(ConnectionInfo ci) {
}
onConnect(currentConnection);
if (dataModelChanger != null) {
dataModelChanger.afterConnect(currentConnection);
if (afterConnectAction != null) {
afterConnectAction[0] = () -> dataModelChanger.afterConnect(currentConnection);
} else {
dataModelChanger.afterConnect(currentConnection);
}
}
if (currentConnection.alias != null && !"".equals(currentConnection.alias)) {
UISettings.addRecentConnectionAliases(currentConnection.alias);
Expand Down
2 changes: 1 addition & 1 deletion src/main/gui/net/sf/jailer/ui/ExtractionModelEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ protected void onCancellation() {
public void run() throws Throwable {
Object obj;
try {
obj = BrowserContentCellEditor.forTable(table, extractionModelFrame.theSession);
obj = BrowserContentCellEditor.forTable(table, null, extractionModelFrame.theSession);
} catch (SQLException e) {
obj = e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.sf.jailer.database.Session;
import net.sf.jailer.database.Session.AbstractResultSetReader;
import net.sf.jailer.datamodel.Column;
import net.sf.jailer.datamodel.RowIdSupport;
import net.sf.jailer.datamodel.Table;
import net.sf.jailer.util.CellContentConverter;
import net.sf.jailer.util.CellContentConverter.PObjectWrapper;
Expand Down Expand Up @@ -578,7 +579,7 @@ public void setInDetailsView(boolean inDetailsView) {
this.inDetailsView = inDetailsView;
}

public static BrowserContentCellEditor forTable(Table table, Session session) throws SQLException {
public static BrowserContentCellEditor forTable(Table table, RowIdSupport rowIdSupport, Session session) throws SQLException {
String key = "browserContentCellEditor-" + table.getName();
BrowserContentCellEditor browserContentCellEditor[] = new BrowserContentCellEditor[] {
(BrowserContentCellEditor) session.getSessionProperty(BrowserContentCellEditor.class, key) };
Expand All @@ -602,8 +603,9 @@ public void readCurrentRow(ResultSet resultSet) throws SQLException {
// nothing to do
}
};
List<Column> columns = rowIdSupport != null? rowIdSupport.getColumns(table, session, false) : table.getColumns();
String sqlQuery = "Select "
+ (table.getColumns().stream().map(c -> c.name).collect(Collectors.joining(", "))) + " From "
+ (columns.stream().map(c -> c.name).collect(Collectors.joining(", "))) + " From "
+ table.getName() + " Where 1=0";
session.executeQuery(sqlQuery, reader, null, null, 1);
session.setSessionProperty(BrowserContentCellEditor.class, key, browserContentCellEditor[0]);
Expand Down
22 changes: 18 additions & 4 deletions src/main/gui/net/sf/jailer/ui/databrowser/BrowserContentPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public void run() {
}
if (exception != null && (browserContentCellEditor == null || browserContentCellEditor.getColumnTypes().length == 0)) {
try {
browserContentCellEditor = BrowserContentCellEditor.forTable(table, session);
browserContentCellEditor = BrowserContentCellEditor.forTable(table, rowIdSupport, session);
onContentCellEditorCreated(browserContentCellEditor);
} catch (Throwable t) {
// ignore
Expand Down Expand Up @@ -782,7 +782,7 @@ private void updateERCounts(Table table, boolean limitExceeded, int numRowsRead)
/**
* {@link RowIdSupport} for data model.
*/
private final RowIdSupport rowIdSupport;
private RowIdSupport rowIdSupport;

/**
* {@link Association} with parent row, or <code>null</code>.
Expand Down Expand Up @@ -855,7 +855,7 @@ private void updateERCounts(Table table, boolean limitExceeded, int numRowsRead)
/**
* DB session.
*/
Session session;
private Session session;

private int currentRowSelection = -1;

Expand Down Expand Up @@ -5710,7 +5710,9 @@ public int getPriority() {
tableContentViewFilter.filter(rowData, columnNameMap);
}
for (int i = 0; i < columns.size(); ++i) {
TableModelItem item = new TableModelItem(row.getParentModelIndex(), row.getInheritedParentModelIndex(), rowData[i], columnTypes == null? 0: columnTypes[i]);
TableModelItem item = new TableModelItem(row.getParentModelIndex(), row.getInheritedParentModelIndex(), rowData[i],
columnTypes == null || columnTypes.length >= i?
0: columnTypes[i]);
rowData[i] = item;
}
dtm.addRow(rowData);
Expand Down Expand Up @@ -8524,6 +8526,18 @@ protected Table getWhereClauseEditorBaseTable() {

private int currentEditState;

public void reset(Session session, DataModel dataModel) {
this.session = session;
this.rowIdSupport = new RowIdSupport(dataModel, session.dbms, executionContext);;
this.rows.clear();
}

public void reset(Session session) {
this.session = session;
this.rowIdSupport = new RowIdSupport(dataModel, session.dbms, executionContext);;
this.rows.clear();
}

public void destroy() {
if (rows != null) {
rows.clear();
Expand Down
55 changes: 40 additions & 15 deletions src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
import net.sf.jailer.datamodel.Column;
import net.sf.jailer.datamodel.DataModel;
import net.sf.jailer.datamodel.PrimaryKeyFactory;
import net.sf.jailer.datamodel.RowIdSupport;
import net.sf.jailer.datamodel.Table;
import net.sf.jailer.modelbuilder.JDBCMetaDataBasedModelElementFinder;
import net.sf.jailer.modelbuilder.ModelBuilder;
Expand Down Expand Up @@ -1783,13 +1784,23 @@ public void actionPerformed(ActionEvent e) {

private void connect(DataBrowser dataBrowser, Object o) {
ConnectionInfo oldCurrentConnectionInfo = currentConnectionInfo;
if (dataBrowser.dbConnectionDialog.connectSilent((ConnectionInfo) o)) {
Runnable[] afterConnectAction = new Runnable[1];
if (dataBrowser.dbConnectionDialog.connectSilent((ConnectionInfo) o, afterConnectAction)) {
try {
if (!dataBrowser.setConnection(dataBrowser.dbConnectionDialog)) {
boolean ok;
BrowserContentPane.suppressReloadStatic = true;
try {
ok = dataBrowser.setConnection(dataBrowser.dbConnectionDialog);
} finally {
BrowserContentPane.suppressReloadStatic = false;
}
if (!ok) {
if (oldCurrentConnectionInfo != null) {
dataBrowser.dbConnectionDialog.connectSilent(oldCurrentConnectionInfo);
dataBrowser.dbConnectionDialog.connectSilent(oldCurrentConnectionInfo, null);
updateModelNavigation();
}
} else {
afterConnectAction[0].run();
}
} catch (Exception ex) {
UIUtil.showException(dataBrowser, "Error", ex);
Expand Down Expand Up @@ -1954,12 +1965,9 @@ public void change(String dataModelSubfolder) {
if (new File(sessionFile).exists()) {
afterReconnectAction = () -> {
try {
BrowserContentPane.suppressReloadStatic = true;
desktop.restoreSession(null, DataBrowser.this, sessionFile, true);
} catch (Exception e) {
LogUtil.warn(e);
} finally {
BrowserContentPane.suppressReloadStatic = false;
}
};
}
Expand Down Expand Up @@ -2173,8 +2181,7 @@ protected boolean setConnection(DbConnectionDialog dbConnectionDialog) throws Ex
.forEach(sqlConsole -> sqlConsole.onReconnect(prevDatabaseName, currentDatabaseName));
}
for (RowBrowser rb : desktop.getBrowsers()) {
rb.browserContentPane.session = session;
rb.browserContentPane.rows.clear();
rb.browserContentPane.reset(session, datamodel.get());
}
for (RowBrowser rb : desktop.getRootBrowsers(false)) {
rb.browserContentPane.reloadRows();
Expand Down Expand Up @@ -4165,8 +4172,7 @@ public void cleanUp() {
if (desktop != null) {
desktop.updateMenu();
for (RowBrowser rb : desktop.getBrowsers()) {
rb.browserContentPane.session = session;
rb.browserContentPane.rows.clear();
rb.browserContentPane.reset(session);
}
for (RowBrowser rb : desktop.getRootBrowsers(false)) {
rb.browserContentPane.reloadRows();
Expand Down Expand Up @@ -4268,12 +4274,25 @@ private void reconnectMenuItemActionPerformed(java.awt.event.ActionEvent evt) {/
if (lastConnectionInfo != null) {
dbConnectionDialog.select(lastConnectionInfo);
}
if (dbConnectionDialog.connect("Reconnect", true)) {
try {
setConnection(dbConnectionDialog);
} catch (Exception e) {
UIUtil.showException(this, "Error", e, session);
BrowserContentPane.suppressReloadStatic = true;
try {
if (dbConnectionDialog.connect("Reconnect", true)) {
try {
BrowserContentPane.suppressReloadStatic = true;
setConnection(dbConnectionDialog);
} catch (Exception e) {
UIUtil.showException(this, "Error", e, session);
} finally {
BrowserContentPane.suppressReloadStatic = false;
}
UIUtil.invokeLater(() -> {
for (RowBrowser rb : desktop.getRootBrowsers(false)) {
rb.browserContentPane.reloadRows();
}
});
}
} finally {
BrowserContentPane.suppressReloadStatic = false;
}
}
}// GEN-LAST:event_reconnectMenuItemActionPerformed
Expand Down Expand Up @@ -6375,6 +6394,12 @@ private SQLConsole createNewSQLConsole(MetaDataSource metaDataSource) throws SQL

private SQLConsoleWithTitle createNewSQLConsole(MetaDataSource metaDataSource, SQLConsoleWithTitle alreadyCreatedSqlConsole) throws SQLException {
final JLabel titleLbl = new JLabel(sqlConsoleIcon);
if (alreadyCreatedSqlConsole != null) {
alreadyCreatedSqlConsole.titleLbl.addPropertyChangeListener("text", e -> {
titleLbl.setText(alreadyCreatedSqlConsole.titleLbl.getText());
titleLbl.setToolTipText(alreadyCreatedSqlConsole.titleLbl.getToolTipText());
});
}
String tabName = "SQL Console";
if (alreadyCreatedSqlConsole == null) {
++sqlConsoleNr;
Expand Down

0 comments on commit 901a079

Please sign in to comment.