# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/NetBeansProjects/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: db.core/src/org/netbeans/modules/db/sql/loader/Bundle.properties --- db.core/src/org/netbeans/modules/db/sql/loader/Bundle.properties Base (BASE) +++ db.core/src/org/netbeans/modules/db/sql/loader/Bundle.properties Locally Modified (Based On LOCAL) @@ -84,5 +84,7 @@ CLOSE_OTHER_TABS_ACTION=Close Other CLOSE_ALL_TABS_ACTION=Close All CLOSE_PREVIOUS_TABS_ACTION=Close Tabs From Previous Executions +LBL_Console={0} +LBL_ConsoleWithConnection={0} [{1}] SQLResolver=SQL Files Index: db.core/src/org/netbeans/modules/db/sql/loader/SQLCloneableEditor.java --- db.core/src/org/netbeans/modules/db/sql/loader/SQLCloneableEditor.java Base (BASE) +++ db.core/src/org/netbeans/modules/db/sql/loader/SQLCloneableEditor.java Locally Modified (Based On LOCAL) @@ -104,7 +104,6 @@ preferredID = "sql.source", position = 1) public final class SQLCloneableEditor extends CloneableEditor implements MultiViewElement { - private transient JSplitPane splitter; private transient JTabbedPane resultComponent; private transient JPopupMenu resultPopupMenu; @@ -483,6 +482,9 @@ @Override public void setMultiViewCallback(MultiViewElementCallback callback) { this.callback = callback; + // Needed as Title and Tooltip could be calculated from currently set + // jdbc connection - which changes after deserialization (none is set) + updateName(); } @Messages({ Index: db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java --- db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java Base (BASE) +++ db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java Locally Modified (Based On LOCAL) @@ -41,13 +41,13 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.db.sql.loader; import java.awt.BorderLayout; import java.awt.Component; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.io.CharConversionException; import java.io.File; import java.io.IOException; import java.sql.Connection; @@ -86,6 +86,8 @@ import org.openide.util.*; import org.openide.windows.CloneableOpenSupport; import org.openide.windows.CloneableTopComponent; +import org.openide.windows.IOContainer; +import org.openide.xml.XMLUtil; /** * Editor support for SQL data objects. There can be two "kinds" of SQL editors: one for normal @@ -140,12 +142,13 @@ @Override protected boolean notifyModified () { - if (!super.notifyModified()) + if (!super.notifyModified()) { return false; + } if (!isConsole()) { // Add the save cookie to the data object - SQLDataObject obj = (SQLDataObject)getDataObject(); + SQLDataObject obj = (SQLDataObject) getDataObject(); if (obj.getLookup().lookup(SaveCookie.class) == null) { obj.addCookie(saveCookie); obj.setModified(true); @@ -163,7 +166,8 @@ @Override protected Pane createPane() { - Pane pane = (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(SQLDataLoader.SQL_MIME_TYPE, getDataObject()); + Pane pane = (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView( + SQLDataLoader.SQL_MIME_TYPE, getDataObject()); return pane; } @@ -173,11 +177,11 @@ } @Override - protected void notifyUnmodified () { + protected void notifyUnmodified() { super.notifyUnmodified(); // Remove the save cookie from the data object - SQLDataObject obj = (SQLDataObject)getDataObject(); + SQLDataObject obj = (SQLDataObject) getDataObject(); Cookie cookie = obj.getLookup().lookup(SaveCookie.class); if (cookie != null && cookie.equals(saveCookie)) { obj.removeCookie(saveCookie); @@ -188,19 +192,44 @@ @Override protected String messageToolTip() { if (isConsole()) { + DatabaseConnection dc = getDatabaseConnection(); + if (dc != null) { + try { + return String.format( + "%s
%s
JDBC-URL: %s", + XMLUtil.toAttributeValue( + getDataObject().getPrimaryFile().getName()), + XMLUtil.toAttributeValue(dc.getDisplayName()), + XMLUtil.toAttributeValue(dc.getDatabaseURL())); + } catch (CharConversionException ex) { + LOGGER.log(Level.WARNING, "", ex); return getDataObject().getPrimaryFile().getName(); + } } else { + return getDataObject().getPrimaryFile().getName(); + } + } else { return super.messageToolTip(); } } @Override protected String messageName() { - if (!isValid()) return ""; // NOI18N - + if (!isValid()) { + return ""; // NOI18N + } if (isConsole()) { - // just the name, no modified or r/o flags - return getDataObject().getName(); + if (getDatabaseConnection() != null) { + String connectionName = getDatabaseConnection().getDisplayName(); + if (connectionName.length() > 25) { + connectionName = connectionName.substring(0, 25) + "\u2026"; + } + return NbBundle.getMessage(SQLEditorSupport.class, "LBL_ConsoleWithConnection", + getDataObject().getName(), + connectionName); + } + return NbBundle.getMessage(SQLEditorSupport.class, "LBL_Console", + getDataObject().getName()); } else { return super.messageName(); } @@ -208,11 +237,12 @@ @Override protected String messageHtmlName() { - if (!isValid()) return ""; // NOI18N - + if (!isValid()) { + return ""; // NOI18N + } if (isConsole()) { // just the name, no modified or r/o flags - String name = getDataObject().getName(); + String name = messageName(); if (name != null) { if (!name.startsWith("")) { // NOI18N name = "" + name; // NOI18N @@ -250,7 +280,7 @@ } boolean isConsole() { - return ((SQLDataObject)getDataObject()).isConsole(); + return ((SQLDataObject) getDataObject()).isConsole(); } boolean isValid() { @@ -292,7 +322,9 @@ @Override public synchronized void setDatabaseConnection(DatabaseConnection dbconn) { this.dbconn = dbconn; - sqlPropChangeSupport.firePropertyChange(SQLExecution.PROP_DATABASE_CONNECTION, null, null); + sqlPropChangeSupport.firePropertyChange( + SQLExecution.PROP_DATABASE_CONNECTION, null, null); + updateTitles(); } @Override @@ -318,13 +350,15 @@ } @Override - public void saveAs( FileObject folder, String fileName ) throws IOException { + public void saveAs(FileObject folder, String fileName) throws IOException { String fn = FileUtil.getFileDisplayName(folder) + File.separator + fileName; File existingFile = FileUtil.normalizeFile(new File(fn)); if (existingFile.exists()) { NotifyDescriptor confirm = new NotifyDescriptor.Confirmation( - NbBundle.getMessage(SQLEditorSupport.class, "MSG_ConfirmReplace", fileName), - NbBundle.getMessage(SQLEditorSupport.class, "MSG_ConfirmReplaceFileTitle"), + NbBundle.getMessage(SQLEditorSupport.class, + "MSG_ConfirmReplace", fileName), + NbBundle.getMessage(SQLEditorSupport.class, + "MSG_ConfirmReplaceFileTitle"), NotifyDescriptor.YES_NO_OPTION); DialogDisplayer.getDefault().notify(confirm); if (!confirm.getValue().equals(NotifyDescriptor.YES_OPTION)) { @@ -366,7 +400,6 @@ task.removeTaskListener(this); refresh(); } - }); } } @@ -439,7 +472,7 @@ private void refresh() { if (dbconn == null) { - return ; + return; } ConnectionManager.getDefault().refreshConnectionInExplorer(dbconn); } @@ -538,7 +571,9 @@ return; } - ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutingStatements"), this); + ProgressHandle handle = ProgressHandleFactory.createHandle( + NbBundle.getMessage(SQLEditorSupport.class, + "LBL_ExecutingStatements"), this); handle.start(); try { handle.switchToIndeterminate(); @@ -546,7 +581,8 @@ setStatusText(""); // NOI18N if (LOG) { - LOGGER.log(Level.FINE, "Closing the old execution result"); // NOI18N + LOGGER.log(Level.FINE, + "Closing the old execution result"); // NOI18N } int pageSize = -1; if (parent.executionResults != null && parent.executionResults.size() > 0) { @@ -561,7 +597,8 @@ parent.closeExecutionResult(); SQLExecutionLoggerImpl logger = parent.createLogger(); - SQLExecutionResults executionResults = SQLExecuteHelper.execute(sql, startOffset, endOffset, dbconn, logger, pageSize); + SQLExecutionResults executionResults = SQLExecuteHelper.execute( + sql, startOffset, endOffset, dbconn, logger, pageSize); handleExecutionResults(executionResults, logger); } finally { handle.finish(); @@ -574,7 +611,8 @@ private void handleExecutionResults(SQLExecutionResults executionResults, SQLExecutionLoggerImpl logger) { if (executionResults == null) { // execution cancelled - setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutionCancelled")); + setStatusText(NbBundle.getMessage(SQLEditorSupport.class, + "LBL_ExecutionCancelled")); return; } @@ -582,7 +620,8 @@ if (executionResults.size() <= 0) { // no results, but successfull - setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutedSuccessfully")); + setStatusText(NbBundle.getMessage(SQLEditorSupport.class, + "LBL_ExecutedSuccessfully")); return; } @@ -590,9 +629,11 @@ if (executionResults.hasExceptions()) { // there was at least one exception - setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutionFinishedWithErrors")); + setStatusText(NbBundle.getMessage(SQLEditorSupport.class, + "LBL_ExecutionFinishedWithErrors")); } else { - setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutedSuccessfully")); + setStatusText(NbBundle.getMessage(SQLEditorSupport.class, + "LBL_ExecutedSuccessfully")); } } @@ -607,8 +648,9 @@ } /** - * Environment for this support. Ensures that getDataObject().setModified(true) - * is not called if this support's editor was opened as a console. + * Environment for this support. Ensures that + * getDataObject().setModified(true) is not called if this support's editor + * was opened as a console. */ static final class Environment extends DataEditorSupport.Env { @@ -629,7 +671,7 @@ @Override protected FileLock takeLock() throws IOException { - MultiDataObject obj = (MultiDataObject)getDataObject(); + MultiDataObject obj = (MultiDataObject) getDataObject(); fileLock = obj.getPrimaryEntry().takeLock(); return fileLock; } Index: db.sql.editor/src/org/netbeans/modules/db/sql/editor/Bundle.properties --- db.sql.editor/src/org/netbeans/modules/db/sql/editor/Bundle.properties Base (BASE) +++ db.sql.editor/src/org/netbeans/modules/db/sql/editor/Bundle.properties Locally Modified (Based On LOCAL) @@ -44,8 +44,8 @@ #SQLEditorProviderImpl #{0} = command number -#PARTI18N - only localize "SQL Command" and do not add anything after ".sql" -LBL_SQLCommandFileName=SQL Command {0}.sql +#PARTI18N - only localize "SQL Command" and do not add anything after ".sql" - keep it short! +LBL_SQLCommandFileName=SQL CON {0}.sql #options NAME_coloring_sql-whitespace=White Space