diff --git a/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.form b/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.form index 9d8477d8a..a9cbb097e 100644 --- a/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.form +++ b/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.form @@ -215,7 +215,7 @@ - + diff --git a/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.java b/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.java index 312811245..ab7c26b3d 100644 --- a/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.java +++ b/src/main/gui/net/sf/jailer/ui/ExtractionModelFrame.java @@ -759,7 +759,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu1.add(jSeparator25); generateDDLMenuItem.setText("Generate DDL Script"); - generateDDLMenuItem.setToolTipText("Generate a DDL script that creates the database objects (CREATE TABLE, VIEW etc.)"); + generateDDLMenuItem.setToolTipText("Generate a SQL/DDL script that creates the database objects (CREATE TABLE, VIEW etc.)"); generateDDLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { generateDDLMenuItemActionPerformed(evt); diff --git a/src/main/gui/net/sf/jailer/ui/UIUtil.java b/src/main/gui/net/sf/jailer/ui/UIUtil.java index 919b21b32..d7cf524b7 100644 --- a/src/main/gui/net/sf/jailer/ui/UIUtil.java +++ b/src/main/gui/net/sf/jailer/ui/UIUtil.java @@ -2668,9 +2668,9 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - int b = 10; + int b = 12; if (c instanceof JCheckBox || c instanceof JRadioButton) { - b = 7; + b = 8; } g2d.setColor(((c instanceof JLabel) && ((JLabel) c).getIcon() == null) || c instanceof JTextField? diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.form b/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.form index a8eb7f3ec..b5566c297 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.form +++ b/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.form @@ -288,7 +288,7 @@ - + diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.java b/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.java index fc501537a..a075bd9c8 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/DataBrowser.java @@ -1116,7 +1116,7 @@ protected void openConditionEditor(BrowserContentPane browserContentPane, Point @Override protected void loadScriptFile(String fileName) { - loadSQLScriptFile(new File(fileName), false); + loadSQLScriptFile(new File(fileName), false, null); } @Override @@ -3461,7 +3461,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { menuTools.add(jSeparator25); generateDDLMenuItem.setText("Generate DDL Script"); - generateDDLMenuItem.setToolTipText("Generate a DDL script that creates the database objects (CREATE TABLE, VIEW etc.)"); + generateDDLMenuItem.setToolTipText("Generate a SQL/DDL script that creates the database objects (CREATE TABLE, VIEW etc.)"); generateDDLMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { generateDDLMenuItemActionPerformed(evt); @@ -6131,7 +6131,7 @@ protected void onContentStateChange(File file, boolean dirty) { titleLbl.setToolTipText(null); } else { title = file.getName(); - titleLbl.setToolTipText(file.getAbsolutePath()); + titleLbl.setToolTipText(alternativeToolTip == null? file.getAbsolutePath() : alternativeToolTip); } if (dirty && file != null) { titleLbl.setText("* " + title); @@ -6237,7 +6237,7 @@ private boolean closeAllSQLConsoles() { List toClose = new ArrayList(sqlConsoles); for (SQLConsoleWithTitle sqlConsole : toClose) { workbenchTabbedPane.setSelectedComponent(sqlConsole); - if (sqlConsole.getFile() != null && sqlConsole.isDirty()) { + if (sqlConsole.getFile() != null && sqlConsole.isDirty() && !sqlConsole.isTempFileBased()) { if (!closeSQLConsole(sqlConsole, true)) { return false; } @@ -6258,7 +6258,7 @@ private boolean closeSQLConsole(SQLConsole sqlConsole, boolean ask) { if (!sqlConsole.isEmpty() && !(sqlConsole.getFile() != null && !sqlConsole.isDirty())) { if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(DataBrowser.this, "Close \"" + (sqlConsole instanceof SQLConsoleWithTitle? ((SQLConsoleWithTitle) sqlConsole).getTitle() : "SQL Console") + "\"" - + (sqlConsole.getFile() == null ? "?" : " without saving?"), + + (sqlConsole.getFile() == null && !sqlConsole.isTempFileBased()? "?" : " without saving?"), "Close Console", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { return false; } @@ -6281,7 +6281,7 @@ private void updateLoadSaveScriptMenuItemsState() { if (sc instanceof SQLConsole) { sqlConsole = (SQLConsole) sc; } - saveScriptMenuItem.setEnabled(sqlConsole != null && sqlConsole.isDirty()); + saveScriptMenuItem.setEnabled(sqlConsole != null && (sqlConsole.isDirty() && !sqlConsole.isTempFileBased())); saveScriptAsMenuItem.setEnabled(sqlConsole != null && !sqlConsole.isEmpty()); if (sqlConsole != null) { goBackItem.setEnabled(false); @@ -6295,11 +6295,11 @@ private void loadScriptMenuItemActionPerformed(java.awt.event.ActionEvent evt) { String fName = UIUtil.choseFile(null, ".", "Load SQL Script", "", this, false, true); if (fName != null) { File file = new File(fName); - loadSQLScriptFile(file, false); + loadSQLScriptFile(file, false, null); } }// GEN-LAST:event_loadScriptMenuItemActionPerformed - public void loadSQLScriptFile(File file, boolean silent) { + public void loadSQLScriptFile(File file, boolean silent, String alternativeToolTip) { if (file.exists() && file.isDirectory()) { return; } @@ -6317,7 +6317,7 @@ public void loadSQLScriptFile(File file, boolean silent) { } try { UIUtil.setWaitCursor(this); - createNewSQLConsole(getMetaDataSource()).loadFromFile(file, silent); + createNewSQLConsole(getMetaDataSource()).loadFromFile(file, silent, alternativeToolTip); } catch (Throwable e) { UIUtil.showException(this, "Error", e, session); } finally { @@ -6328,7 +6328,7 @@ public void loadSQLScriptFile(File file, boolean silent) { private void saveScriptMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_saveScriptMenuItemActionPerformed SQLConsole sqlConsole = getCurrentSQLConsole(); if (sqlConsole != null) { - if (sqlConsole.getFile() == null) { + if (sqlConsole.getFile() == null && sqlConsole.isTempFileBased()) { saveScriptAsMenuItemActionPerformed(evt); } else { try { @@ -6570,7 +6570,7 @@ public void drop(DropTargetDropEvent dtde) { @SuppressWarnings("unchecked") java.util.List files = (java.util.List) tr.getTransferData(flavors[i]); for (int k = 0; k < files.size(); k++) { - loadSQLScriptFile(files.get(k), false); + loadSQLScriptFile(files.get(k), false, null); } dtde.dropComplete(true); diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.form b/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.form index 52d18a672..a5e035da3 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.form +++ b/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.form @@ -48,14 +48,25 @@ - + - + + + + + + + + + + + + diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.java b/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.java index 87ac2551d..a51023d9e 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/sqlconsole/SQLConsole.java @@ -226,6 +226,8 @@ public abstract class SQLConsole extends javax.swing.JPanel { private final ImageIcon scaledExplainIcon; private final SQLPlusSupport sqlPlusSupport = new SQLPlusSupport(); private File file; + private boolean tempFileBased; + protected String alternativeToolTip; private JMenuItem menuItemToggle; private JMenuItem menuItemToSingleLine; private JMenuItem menuItemSubstituteVariables; @@ -2600,6 +2602,7 @@ private void initComponents() { jPanel1 = new javax.swing.JPanel(); jSplitPane2 = new javax.swing.JSplitPane(); jPanel2 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); consoleContainerPanel = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); @@ -2635,6 +2638,8 @@ private void initComponents() { jPanel2.setLayout(new java.awt.GridBagLayout()); + jPanel7.setLayout(new java.awt.GridBagLayout()); + consoleContainerPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; @@ -2643,7 +2648,16 @@ private void initComponents() { gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; - jPanel2.add(consoleContainerPanel, gridBagConstraints); + jPanel7.add(consoleContainerPanel, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + jPanel2.add(jPanel7, gridBagConstraints); jPanel5.setLayout(new java.awt.GridBagLayout()); @@ -2857,6 +2871,7 @@ private void continueButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator3; @@ -4104,10 +4119,10 @@ public void setRowLimit(Integer limit) { * * @param file the file */ - public void loadFromFile(File file, boolean silent) throws IOException { - if (!silent) { - this.file = file; - } + public void loadFromFile(File file, boolean tempFileBased, String alternativeToolTip) throws IOException { + this.file = file; + this.tempFileBased = tempFileBased; + this.alternativeToolTip = alternativeToolTip; if (file.exists()) { String path = file.getPath(); Charset encoding = SqlUtil.retrieveEncoding(path); @@ -4142,20 +4157,61 @@ public void loadFromFile(File file, boolean silent) throws IOException { initialContentSize = editorPane.getDocument().getLength(); initialContentHash = editorPane.getText().hashCode(); consoleContainerPanel.setVisible(false); - UIUtil.invokeLater(new Runnable() { + UIUtil.invokeLater(4, new Runnable() { @Override public void run() { consoleContainerPanel.setVisible(true); grabFocus(); + if (file.exists()) { + startAfterLoadIndicatorTimer(); + } } }); setCaretPosition(0); - if (!silent) { - onContentStateChange(file, dirty); - } + onContentStateChange(file, dirty); UIUtil.invokeLater(2, () -> editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1))); } + private void startAfterLoadIndicatorTimer() { + final double DELTA = 0.03; + int delay = 25; + Color c0 = editorPane.getBackground(); + Color c1 = new Color(100, 255, 100); + if (c0 != null) { + Timer[] timer = new Timer[1]; + timer[0] = new Timer(delay, new ActionListener() { + double x = 0; + double delta = DELTA; + + // TODO + { delta = delta / 10; } + + private int fade(int a, int b) { + double fScaled = 1 -Math.pow(x, 4); + + double rf = Math.sin(fScaled / Math.PI); + int color = (int) (a + rf * (b - a)); + if (color < 0 || color > 255) { + throw new IllegalStateException(color + " not in color range"); + } + return color; + } + @Override + public void actionPerformed(ActionEvent e) { + if ((x += delta) > 1.0) { + editorPane.setBackground(c0); + timer[0].stop(); + } else { + editorPane.setBackground(new Color(fade(c0.getRed(), c1.getRed()), fade(c0.getGreen(), c1.getGreen()), fade(c0.getBlue(), c1.getBlue()))); + } + } + }); + timer[0].setInitialDelay(delay); + timer[0].setRepeats(true); + timer[0].start(); + } + } + /** * Stores content to file if console is dirty or new file is given. * @@ -4205,6 +4261,8 @@ public void storeToFile(File newFile) throws IOException { initialContentSize = editorPane.getDocument().getLength(); initialContentHash = editorPane.getText().hashCode(); dirty = false; + tempFileBased = false; + alternativeToolTip = null; onContentStateChange(file, dirty); } } @@ -4396,6 +4454,10 @@ public void updateConnectionType(ConnectionType connectionType) { } } + public boolean isTempFileBased() { + return tempFileBased; + } + // TODO 2 // TODO ordering per column: break down to SQL? diff --git a/src/main/gui/net/sf/jailer/ui/ddl_script_generator/DDLScriptGeneratorPanel.java b/src/main/gui/net/sf/jailer/ui/ddl_script_generator/DDLScriptGeneratorPanel.java index 7ef418b37..840c47c1c 100644 --- a/src/main/gui/net/sf/jailer/ui/ddl_script_generator/DDLScriptGeneratorPanel.java +++ b/src/main/gui/net/sf/jailer/ui/ddl_script_generator/DDLScriptGeneratorPanel.java @@ -1036,7 +1036,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jPanel1.add(includeAllButton, gridBagConstraints); includeClosureButton.setText("Tables associated with a subject table"); - includeClosureButton.setToolTipText("Generate DDL statements only for the tables that are directly or indirectly associated with a subject table. (the Closure)
Note that this excludes sequences."); + includeClosureButton.setToolTipText("Generate SQL/DDL statements only for the tables that are directly or indirectly associated with a subject table. (the Closure)
Note that this excludes sequences."); includeClosureButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { includeClosureButtonActionPerformed(evt); @@ -1141,13 +1141,17 @@ private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F } }//GEN-LAST:event_closeButtonActionPerformed + private static File silentDDLScriptFileName; + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed String fileName; if (silent) { - File tmp = Configuration.getInstance().createTempFile(); - tmp.deleteOnExit(); - fileName = tmp.getAbsolutePath(); + if (silentDDLScriptFileName == null) { + silentDDLScriptFileName = new File(Configuration.getInstance().createTempFile(), "DDL"); + silentDDLScriptFileName.deleteOnExit(); + } + fileName = silentDDLScriptFileName.getAbsolutePath(); } else { String fn = scriptFileTextField.getText().trim(); if (fn.isEmpty()) { @@ -1172,7 +1176,7 @@ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS UIUtil.invokeLater(4, () -> { try { if (owner instanceof DataBrowser) { - ((DataBrowser) owner).loadSQLScriptFile(new File(fileName), silent); + ((DataBrowser) owner).loadSQLScriptFile(new File(fileName), silent, "Generated SQL/DDL Script."); } else { new FileView(owner, owner, fileName, true); }