mirror of
https://github.com/Wisser/Jailer.git
synced 2026-05-20 11:29:05 -05:00
bind metaDataSource to session
git-svn-id: https://svn.code.sf.net/p/jailer/code/trunk@1429 3dd849cd-670e-4645-a7cd-dd197c8d0e81
This commit is contained in:
@@ -31,6 +31,7 @@ import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -711,7 +712,7 @@ public class Session {
|
||||
/**
|
||||
* Cached Database Meta Data.
|
||||
*/
|
||||
private DatabaseMetaData metaData = null;
|
||||
private Map<Connection, DatabaseMetaData> metaData = Collections.synchronizedMap(new IdentityHashMap<Connection, DatabaseMetaData>());
|
||||
|
||||
/**
|
||||
* Gets DB meta data.
|
||||
@@ -719,10 +720,13 @@ public class Session {
|
||||
* @return DB meta data
|
||||
*/
|
||||
public DatabaseMetaData getMetaData() throws SQLException {
|
||||
if (metaData == null) {
|
||||
metaData = connectionFactory.getConnection().getMetaData();
|
||||
Connection con = connectionFactory.getConnection();
|
||||
DatabaseMetaData mData = metaData.get(con);
|
||||
if (mData == null) {
|
||||
mData = con.getMetaData();
|
||||
metaData.put(con, mData);
|
||||
}
|
||||
return metaData;
|
||||
return mData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -271,7 +271,7 @@ public class AdditionalSubjectsDialog extends javax.swing.JDialog {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
detailsPanel = new javax.swing.JPanel();
|
||||
detailsComboBox = new javax.swing.JComboBox();
|
||||
detailsComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
detailsLabel = new javax.swing.JLabel();
|
||||
detailsCondtition = new javax.swing.JTextField();
|
||||
detailsWhere = new javax.swing.JLabel();
|
||||
@@ -449,7 +449,7 @@ public class AdditionalSubjectsDialog extends javax.swing.JDialog {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton addAllButton;
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JComboBox detailsComboBox;
|
||||
private net.sf.jailer.ui.JComboBox detailsComboBox;
|
||||
private javax.swing.JTextField detailsCondtition;
|
||||
private javax.swing.JLabel detailsLabel;
|
||||
private javax.swing.JPanel detailsPanel;
|
||||
|
||||
@@ -477,7 +477,7 @@ public class AnalyseOptionsDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JCheckBox removeCurrentAssociationsCheckBox;
|
||||
private javax.swing.JCheckBox removeCurrentTablesCheckBox;
|
||||
private javax.swing.JComboBox schemaComboBox;
|
||||
private net.sf.jailer.ui.JComboBox schemaComboBox;
|
||||
private javax.swing.JLabel schemaLabel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.swing.text.PlainDocument;
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
public class AutoCompletion extends PlainDocument {
|
||||
javax.swing.JComboBox comboBox;
|
||||
net.sf.jailer.ui.JComboBox comboBox;
|
||||
ComboBoxModel model;
|
||||
JTextComponent editor;
|
||||
// flag to indicate if setSelectedItem has been called
|
||||
@@ -37,7 +37,7 @@ public class AutoCompletion extends PlainDocument {
|
||||
KeyListener editorKeyListener;
|
||||
FocusListener editorFocusListener;
|
||||
|
||||
public AutoCompletion(final javax.swing.JComboBox detailsComboBox) {
|
||||
public AutoCompletion(final net.sf.jailer.ui.JComboBox detailsComboBox) {
|
||||
this.comboBox = detailsComboBox;
|
||||
model = detailsComboBox.getModel();
|
||||
detailsComboBox.addActionListener(new ActionListener() {
|
||||
@@ -97,7 +97,7 @@ public class AutoCompletion extends PlainDocument {
|
||||
highlightCompletedText(0);
|
||||
}
|
||||
|
||||
public static void enable(javax.swing.JComboBox detailsComboBox) {
|
||||
public static void enable(net.sf.jailer.ui.JComboBox detailsComboBox) {
|
||||
// has to be editable
|
||||
detailsComboBox.setEditable(true);
|
||||
// change the editor's document
|
||||
|
||||
@@ -1141,9 +1141,9 @@ public abstract class ClosureView extends javax.swing.JDialog {
|
||||
tablePanel = new javax.swing.JPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
closureTable = new javax.swing.JTable();
|
||||
searchComboBox = new javax.swing.JComboBox();
|
||||
searchComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
columnsComboBox = new javax.swing.JComboBox();
|
||||
columnsComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
findButton = new javax.swing.JButton();
|
||||
associationPane = new javax.swing.JPanel();
|
||||
associationPanel = new javax.swing.JPanel();
|
||||
@@ -1420,7 +1420,7 @@ public abstract class ClosureView extends javax.swing.JDialog {
|
||||
private javax.swing.JPanel associationPane;
|
||||
private javax.swing.JPanel associationPanel;
|
||||
private javax.swing.JTable closureTable;
|
||||
private javax.swing.JComboBox columnsComboBox;
|
||||
private net.sf.jailer.ui.JComboBox columnsComboBox;
|
||||
public javax.swing.JPanel contentPanel;
|
||||
private javax.swing.JButton findButton;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
@@ -1432,7 +1432,7 @@ public abstract class ClosureView extends javax.swing.JDialog {
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JSeparator jSeparator1;
|
||||
private javax.swing.JComboBox searchComboBox;
|
||||
private net.sf.jailer.ui.JComboBox searchComboBox;
|
||||
private javax.swing.JCheckBox showOnlyEnabledCheckBox;
|
||||
private javax.swing.JPanel tabAssAssPanel;
|
||||
private javax.swing.JPanel tabAssPanel;
|
||||
|
||||
@@ -140,7 +140,7 @@ public class ColumnMapperDialog extends javax.swing.JDialog {
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
tableCombobox = new javax.swing.JComboBox();
|
||||
tableCombobox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
formatButton = new javax.swing.JButton();
|
||||
@@ -283,7 +283,7 @@ public class ColumnMapperDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JPanel paramPanel;
|
||||
private javax.swing.JButton resetButton;
|
||||
private javax.swing.JComboBox tableCombobox;
|
||||
private net.sf.jailer.ui.JComboBox tableCombobox;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private final RSyntaxTextArea mappingField;
|
||||
|
||||
@@ -1951,7 +1951,7 @@ public class ExportDialog extends javax.swing.JDialog {
|
||||
public javax.swing.JCheckBox explain;
|
||||
private javax.swing.JLabel exportLabel;
|
||||
private javax.swing.JPanel iFMTPanel;
|
||||
private javax.swing.JComboBox iFMTableSchemaComboBox;
|
||||
private net.sf.jailer.ui.JComboBox iFMTableSchemaComboBox;
|
||||
private javax.swing.JTextField insert;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
@@ -2003,7 +2003,7 @@ public class ExportDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JCheckBox sortedCheckBox;
|
||||
public javax.swing.JPanel sourceSchemaMappingPanel;
|
||||
private javax.swing.JLabel subjectTable;
|
||||
private javax.swing.JComboBox targetDBMSComboBox;
|
||||
private net.sf.jailer.ui.JComboBox targetDBMSComboBox;
|
||||
private javax.swing.JLabel targetDBMSLabel;
|
||||
private javax.swing.JTextField threads;
|
||||
private javax.swing.JLabel toLabel;
|
||||
@@ -2011,7 +2011,7 @@ public class ExportDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JCheckBox upsertCheckbox;
|
||||
public javax.swing.JCheckBox useRowIds;
|
||||
private javax.swing.JTextField where;
|
||||
private javax.swing.JComboBox workingTableSchemaComboBox;
|
||||
private net.sf.jailer.ui.JComboBox workingTableSchemaComboBox;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private Icon loadIcon;
|
||||
|
||||
@@ -1336,16 +1336,16 @@ public class FilterEditorDialog extends javax.swing.JDialog {
|
||||
templatesDetailsClausePanel = new javax.swing.JPanel();
|
||||
jLabel13 = new javax.swing.JLabel();
|
||||
jPanel13 = new javax.swing.JPanel();
|
||||
templatesDetailsApplyAtComboBox = new javax.swing.JComboBox();
|
||||
templatesDetailsApplyAtComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel14 = new javax.swing.JLabel();
|
||||
templateDetailsTypeField = new javax.swing.JTextField();
|
||||
templateDetailsExcludedCheckBox = new javax.swing.JCheckBox();
|
||||
clauseDetailsPanel = new javax.swing.JPanel();
|
||||
jPanel9 = new javax.swing.JPanel();
|
||||
jPanel10 = new javax.swing.JPanel();
|
||||
clauseDetailsSubjectComboBox = new javax.swing.JComboBox();
|
||||
clauseDetailsPredicateComboBox = new javax.swing.JComboBox();
|
||||
clauseDetailsObjectTextField = new javax.swing.JComboBox();
|
||||
clauseDetailsSubjectComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
clauseDetailsPredicateComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
clauseDetailsObjectTextField = new net.sf.jailer.ui.JComboBox();
|
||||
jPanel11 = new javax.swing.JPanel();
|
||||
jLabel9 = new javax.swing.JLabel();
|
||||
clausePredHelpRE = new javax.swing.JPanel();
|
||||
@@ -1375,7 +1375,7 @@ public class FilterEditorDialog extends javax.swing.JDialog {
|
||||
Panel2 = new javax.swing.JPanel();
|
||||
derivedPanel1 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
tableBox = new javax.swing.JComboBox();
|
||||
tableBox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jPanel6 = new javax.swing.JPanel();
|
||||
jPanel7 = new javax.swing.JPanel();
|
||||
@@ -2042,10 +2042,10 @@ public class FilterEditorDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JPanel allFiltersPanel;
|
||||
private javax.swing.JButton applyButton;
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JComboBox clauseDetailsObjectTextField;
|
||||
private net.sf.jailer.ui.JComboBox clauseDetailsObjectTextField;
|
||||
private javax.swing.JPanel clauseDetailsPanel;
|
||||
private javax.swing.JComboBox clauseDetailsPredicateComboBox;
|
||||
private javax.swing.JComboBox clauseDetailsSubjectComboBox;
|
||||
private net.sf.jailer.ui.JComboBox clauseDetailsPredicateComboBox;
|
||||
private net.sf.jailer.ui.JComboBox clauseDetailsSubjectComboBox;
|
||||
private javax.swing.JPanel clausePredHelpLike;
|
||||
private javax.swing.JPanel clausePredHelpRE;
|
||||
private javax.swing.JPanel derivedPanel1;
|
||||
@@ -2087,14 +2087,14 @@ public class FilterEditorDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JSplitPane jSplitPane2;
|
||||
private javax.swing.JTabbedPane jTabbedPane1;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JComboBox tableBox;
|
||||
private net.sf.jailer.ui.JComboBox tableBox;
|
||||
private javax.swing.JCheckBox templateDetailsEnabledCheckBox;
|
||||
private javax.swing.JCheckBox templateDetailsExcludedCheckBox;
|
||||
private javax.swing.JTextField templateDetailsNameField;
|
||||
private javax.swing.JTextField templateDetailsNewValueField;
|
||||
private javax.swing.JPanel templateDetailsPanel;
|
||||
private javax.swing.JTextField templateDetailsTypeField;
|
||||
private javax.swing.JComboBox templatesDetailsApplyAtComboBox;
|
||||
private net.sf.jailer.ui.JComboBox templatesDetailsApplyAtComboBox;
|
||||
private javax.swing.JPanel templatesDetailsClausePanel;
|
||||
private javax.swing.JLabel templatesDetailsMulitlineLabel;
|
||||
private javax.swing.JPanel templatesPane;
|
||||
|
||||
@@ -467,7 +467,7 @@ public class ImportDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JLabel placeholder1;
|
||||
private javax.swing.JComboBox threadComboBox;
|
||||
private net.sf.jailer.ui.JComboBox threadComboBox;
|
||||
private javax.swing.JCheckBox transactionalCheckBox;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package net.sf.jailer.ui;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Workaround for Swing bug 4618607.
|
||||
@@ -27,6 +28,13 @@ public class JComboBox<T> extends javax.swing.JComboBox<T> {
|
||||
private static final long serialVersionUID = 1404824459186814788L;
|
||||
private boolean layingOut = false;
|
||||
|
||||
public JComboBox(Vector<T> model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
public JComboBox() {
|
||||
}
|
||||
|
||||
public void doLayout() {
|
||||
try {
|
||||
layingOut = true;
|
||||
|
||||
@@ -57,6 +57,10 @@ public class StringSearchPanel extends javax.swing.JPanel {
|
||||
private String result;
|
||||
|
||||
public static JButton createSearchButton(final Frame owner, final javax.swing.JComboBox comboBox, final String titel, final Runnable onSuccess) {
|
||||
return createSearchButton(owner, comboBox, titel, onSuccess, null);
|
||||
}
|
||||
|
||||
public static JButton createSearchButton(final Frame owner, final javax.swing.JComboBox comboBox, final String titel, final Runnable onSuccess, final Runnable prepare) {
|
||||
final JButton button = new JButton();
|
||||
button.setIcon(getScaledIcon(button, icon));
|
||||
button.setToolTipText("Find Table");
|
||||
@@ -68,6 +72,9 @@ public class StringSearchPanel extends javax.swing.JPanel {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (prepare != null) {
|
||||
prepare.run();
|
||||
}
|
||||
Point location = button.getLocationOnScreen();
|
||||
StringSearchPanel searchPanel = new StringSearchPanel((DefaultComboBoxModel<String>) comboBox.getModel());
|
||||
String result = searchPanel.find(owner, titel, location.x, location.y);
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import net.sf.jailer.ui.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.sf.jailer.datamodel.Association;
|
||||
|
||||
@@ -3026,7 +3026,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
where = new javax.swing.JLabel();
|
||||
jPanel7 = new javax.swing.JPanel();
|
||||
loadButton = new javax.swing.JButton();
|
||||
andCondition = new javax.swing.JComboBox();
|
||||
andCondition = new net.sf.jailer.ui.JComboBox();
|
||||
onPanel = new javax.swing.JPanel();
|
||||
on = new javax.swing.JLabel();
|
||||
joinPanel = new javax.swing.JPanel();
|
||||
@@ -3061,7 +3061,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
fetchLabel = new javax.swing.JLabel();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
limitBox = new javax.swing.JComboBox();
|
||||
limitBox = new net.sf.jailer.ui.JComboBox();
|
||||
relatedRowsPanel = new javax.swing.JPanel();
|
||||
relatedRowsLabel = new javax.swing.JLabel();
|
||||
jPanel9 = new javax.swing.JPanel();
|
||||
@@ -3505,7 +3505,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
javax.swing.JComboBox andCondition;
|
||||
net.sf.jailer.ui.JComboBox andCondition;
|
||||
private javax.swing.JLabel andLabel;
|
||||
private javax.swing.JButton cancelLoadButton;
|
||||
private javax.swing.JPanel cardPanel;
|
||||
@@ -3535,7 +3535,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
private javax.swing.JPanel jPanel9;
|
||||
private javax.swing.JLabel join;
|
||||
private javax.swing.JPanel joinPanel;
|
||||
javax.swing.JComboBox limitBox;
|
||||
net.sf.jailer.ui.JComboBox limitBox;
|
||||
private javax.swing.JButton loadButton;
|
||||
private javax.swing.JLabel on;
|
||||
private javax.swing.JPanel onPanel;
|
||||
|
||||
@@ -70,7 +70,6 @@ import net.sf.jailer.datamodel.Association;
|
||||
import net.sf.jailer.datamodel.DataModel;
|
||||
import net.sf.jailer.datamodel.Table;
|
||||
import net.sf.jailer.ui.AutoCompletion;
|
||||
import net.sf.jailer.ui.JComboBox;
|
||||
import net.sf.jailer.ui.StringSearchPanel;
|
||||
import net.sf.jailer.ui.UIUtil;
|
||||
import net.sf.jailer.ui.databrowser.Desktop.RowBrowser;
|
||||
@@ -886,9 +885,9 @@ public abstract class DBClosureView extends javax.swing.JDialog {
|
||||
tablePanel = new javax.swing.JPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
closureTable = new javax.swing.JTable();
|
||||
searchComboBox = new javax.swing.JComboBox();
|
||||
searchComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
columnsComboBox = new javax.swing.JComboBox();
|
||||
columnsComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
findButton = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
@@ -1066,7 +1065,7 @@ public abstract class DBClosureView extends javax.swing.JDialog {
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JTable closureTable;
|
||||
private javax.swing.JComboBox columnsComboBox;
|
||||
private net.sf.jailer.ui.JComboBox columnsComboBox;
|
||||
public javax.swing.JPanel contentPanel;
|
||||
private javax.swing.JButton findButton;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
@@ -1079,7 +1078,7 @@ public abstract class DBClosureView extends javax.swing.JDialog {
|
||||
private javax.swing.JLabel jLabel8;
|
||||
private javax.swing.JLabel jLabel9;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JComboBox searchComboBox;
|
||||
private net.sf.jailer.ui.JComboBox searchComboBox;
|
||||
public javax.swing.JPanel tablePanel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
|
||||
@@ -2825,10 +2825,12 @@ public class DataBrowser extends javax.swing.JFrame {
|
||||
try {
|
||||
metaDataSource = getMetaDataSource(newSession);
|
||||
if (metaDataSource == null || Boolean.TRUE.equals(session.getSessionProperty(DataBrowser.class, "removeMetaDataSource"))) {
|
||||
session.setSessionProperty(DataBrowser.class, "removeMetaDataSource", null);
|
||||
metaDataSource = new MetaDataSource(newSession, datamodel.get(), alias, executionContext);
|
||||
newSession.setSessionProperty(DataBrowser.class, "MetaDataSource", metaDataSource);
|
||||
} else {
|
||||
metaDataSource = new MetaDataSource(metaDataSource, datamodel.get());
|
||||
}
|
||||
session.setSessionProperty(DataBrowser.class, "removeMetaDataSource", null);
|
||||
newSession.setSessionProperty(DataBrowser.class, "MetaDataSource", metaDataSource);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public abstract class NewTableBrowser extends javax.swing.JDialog {
|
||||
analyzeButton = new javax.swing.JButton();
|
||||
restoreSessionButton = new javax.swing.JButton();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
tableComboBox = new javax.swing.JComboBox();
|
||||
tableComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
@@ -230,7 +230,7 @@ public abstract class NewTableBrowser extends javax.swing.JDialog {
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JButton restoreSessionButton;
|
||||
private javax.swing.JComboBox tableComboBox;
|
||||
private net.sf.jailer.ui.JComboBox tableComboBox;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@@ -39,7 +40,8 @@ public class MDSchema extends MDObject {
|
||||
public final boolean isDefaultSchema;
|
||||
private List<MDTable> tables;
|
||||
private static final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
||||
|
||||
private boolean valid = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -80,30 +82,27 @@ public class MDSchema extends MDObject {
|
||||
MetaDataSource metaDataSource = getMetaDataSource();
|
||||
synchronized (metaDataSource.getSession().getMetaData()) {
|
||||
ResultSet rs = metaDataSource.readTables(getName());
|
||||
queue.add(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
Map<String, Runnable> loadJobs = new TreeMap<String, Runnable>();
|
||||
while (rs.next()) {
|
||||
String tableName = metaDataSource.getQuoting().quote(rs.getString(3));
|
||||
final MDTable table = new MDTable(tableName, this, "VIEW".equalsIgnoreCase(rs.getString(4)), "SYNONYM".equalsIgnoreCase(rs.getString(4)));
|
||||
tables.add(table);
|
||||
queue.add(new Runnable() {
|
||||
loadJobs.put(tableName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
table.getColumns();
|
||||
} catch (SQLException e) {
|
||||
if (valid) {
|
||||
try {
|
||||
table.getColumns();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
rs.close();
|
||||
for (Runnable loadJob: loadJobs.values()) {
|
||||
queue.add(loadJob);
|
||||
}
|
||||
}
|
||||
Collections.sort(tables, new Comparator<MDTable>() {
|
||||
@Override
|
||||
@@ -118,6 +117,10 @@ public class MDSchema extends MDObject {
|
||||
return tables;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return tables != null;
|
||||
}
|
||||
|
||||
private final Map<String, MDTable> tablePerUnquotedNameUC = new HashMap<String, MDTable>();
|
||||
|
||||
/**
|
||||
@@ -135,4 +138,8 @@ public class MDSchema extends MDObject {
|
||||
return tablePerUnquotedNameUC.get(Quoting.staticUnquote(tableName.toUpperCase(Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
public synchronized void setValid(boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ import java.awt.event.MouseListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -135,6 +137,11 @@ public abstract class MetaDataPanel extends javax.swing.JPanel {
|
||||
public void run() {
|
||||
onSelectTable();
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTablesCombobox();
|
||||
}
|
||||
});
|
||||
add(searchButton, gridBagConstraints);
|
||||
|
||||
@@ -343,12 +350,32 @@ public abstract class MetaDataPanel extends javax.swing.JPanel {
|
||||
updateTreeModel(metaDataSource);
|
||||
}
|
||||
|
||||
private Map<String, MDTable> tablesComboboxMDTablePerName = new HashMap<String, MDTable>();
|
||||
|
||||
private void updateTablesCombobox() {
|
||||
List<String> tables = new ArrayList<String>();
|
||||
Set<String> tableSet = new HashSet<String>();
|
||||
|
||||
for (Table table: dataModel.getTables()) {
|
||||
tables.add(dataModel.getDisplayName(table));
|
||||
String displayName = dataModel.getDisplayName(table);
|
||||
tableSet.add(displayName);
|
||||
}
|
||||
for (MDSchema schema: metaDataSource.getSchemas()) {
|
||||
if (schema.isLoaded()) {
|
||||
for (MDTable table: schema.getTables()) {
|
||||
if (metaDataSource.toTable(table) == null) {
|
||||
String name;
|
||||
if (!schema.isDefaultSchema) {
|
||||
name = schema.getName() + "." + table.getName();
|
||||
} else {
|
||||
name = table.getName();
|
||||
}
|
||||
tableSet.add(name);
|
||||
tablesComboboxMDTablePerName.put(name, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> tables = new ArrayList<String>(tableSet);
|
||||
Collections.sort(tables);
|
||||
ComboBoxModel model = new DefaultComboBoxModel(new Vector(tables));
|
||||
|
||||
@@ -597,6 +624,11 @@ public abstract class MetaDataPanel extends javax.swing.JPanel {
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(parent, "Table \"" + dataModel.getDisplayName(table) + "\" does not exist in the database");
|
||||
}
|
||||
} else {
|
||||
MDTable mdTable = tablesComboboxMDTablePerName.get(item);
|
||||
if (mdTable != null) {
|
||||
select(mdTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,11 +70,30 @@ public class MetaDataSource {
|
||||
this.dataSourceName = dataSourceName;
|
||||
this.quoting = new Quoting(session);
|
||||
|
||||
initTableMapping(dataModel);
|
||||
readSchemas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param metaDataSource to copy
|
||||
* @param dataModel different data model
|
||||
*/
|
||||
public MetaDataSource(MetaDataSource metaDataSource, DataModel dataModel) throws SQLException {
|
||||
this.session = metaDataSource.session;
|
||||
this.dataSourceName = metaDataSource.dataSourceName;
|
||||
this.quoting = metaDataSource.quoting;
|
||||
this.schemas = metaDataSource.schemas;
|
||||
|
||||
initTableMapping(dataModel);
|
||||
}
|
||||
|
||||
private void initTableMapping(DataModel dataModel) {
|
||||
for (Table table: dataModel.getTables()) {
|
||||
tablePerUnquotedName.put(unquotedTableName(table), table);
|
||||
tablePerUnquotedNameUC.put(unquotedTableName(table).toUpperCase(Locale.ENGLISH), table);
|
||||
}
|
||||
readSchemas();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,6 +156,9 @@ public class MetaDataSource {
|
||||
* Removes all chached data.
|
||||
*/
|
||||
public void clear() {
|
||||
for (MDSchema mdSchema: schemas) {
|
||||
mdSchema.setValid(false);
|
||||
}
|
||||
schemas.clear();
|
||||
mDTableToTable.clear();
|
||||
tableToMDTable.clear();
|
||||
|
||||
@@ -696,7 +696,7 @@ public abstract class SQLConsole extends javax.swing.JPanel {
|
||||
consoleContainerPanel = new javax.swing.JPanel();
|
||||
jPanel5 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
limitComboBox = new javax.swing.JComboBox();
|
||||
limitComboBox = new net.sf.jailer.ui.JComboBox();
|
||||
cancelButton = new javax.swing.JButton();
|
||||
runSQLButton = new javax.swing.JButton();
|
||||
runnAllButton = new javax.swing.JButton();
|
||||
@@ -887,7 +887,7 @@ public abstract class SQLConsole extends javax.swing.JPanel {
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JSplitPane jSplitPane2;
|
||||
private javax.swing.JTabbedPane jTabbedPane1;
|
||||
private javax.swing.JComboBox limitComboBox;
|
||||
private net.sf.jailer.ui.JComboBox limitComboBox;
|
||||
private javax.swing.JButton runSQLButton;
|
||||
private javax.swing.JButton runnAllButton;
|
||||
private javax.swing.JLabel statusLabel;
|
||||
|
||||
Reference in New Issue
Block a user