This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 195880
Collapse All | Expand All

(-)db.core/src/org/netbeans/modules/db/sql/loader/Bundle.properties (+2 lines)
Lines 84-88 Link Here
84
CLOSE_OTHER_TABS_ACTION=Close Other
84
CLOSE_OTHER_TABS_ACTION=Close Other
85
CLOSE_ALL_TABS_ACTION=Close All
85
CLOSE_ALL_TABS_ACTION=Close All
86
CLOSE_PREVIOUS_TABS_ACTION=Close Tabs From Previous Executions
86
CLOSE_PREVIOUS_TABS_ACTION=Close Tabs From Previous Executions
87
LBL_Console={0}
88
LBL_ConsoleWithConnection={0} [{1}]
87
89
88
SQLResolver=SQL Files
90
SQLResolver=SQL Files
(-)db.core/src/org/netbeans/modules/db/sql/loader/SQLCloneableEditor.java (-1 / +3 lines)
Lines 104-110 Link Here
104
preferredID = "sql.source",
104
preferredID = "sql.source",
105
position = 1)
105
position = 1)
106
public final class SQLCloneableEditor extends CloneableEditor implements MultiViewElement {
106
public final class SQLCloneableEditor extends CloneableEditor implements MultiViewElement {
107
108
    private transient JSplitPane splitter;
107
    private transient JSplitPane splitter;
109
    private transient JTabbedPane resultComponent;
108
    private transient JTabbedPane resultComponent;
110
    private transient JPopupMenu resultPopupMenu;
109
    private transient JPopupMenu resultPopupMenu;
Lines 483-488 Link Here
483
    @Override
482
    @Override
484
    public void setMultiViewCallback(MultiViewElementCallback callback) {
483
    public void setMultiViewCallback(MultiViewElementCallback callback) {
485
        this.callback = callback;
484
        this.callback = callback;
485
        // Needed as Title and Tooltip could be calculated from currently set
486
        // jdbc connection - which changes after deserialization (none is set)
487
        updateName();
486
    }
488
    }
487
489
488
    @Messages({
490
    @Messages({
(-)db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java (-30 / +72 lines)
Lines 41-53 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
45
package org.netbeans.modules.db.sql.loader;
44
package org.netbeans.modules.db.sql.loader;
46
45
47
import java.awt.BorderLayout;
46
import java.awt.BorderLayout;
48
import java.awt.Component;
47
import java.awt.Component;
49
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
50
import java.beans.PropertyChangeSupport;
49
import java.beans.PropertyChangeSupport;
50
import java.io.CharConversionException;
51
import java.io.File;
51
import java.io.File;
52
import java.io.IOException;
52
import java.io.IOException;
53
import java.sql.Connection;
53
import java.sql.Connection;
Lines 86-91 Link Here
86
import org.openide.util.*;
86
import org.openide.util.*;
87
import org.openide.windows.CloneableOpenSupport;
87
import org.openide.windows.CloneableOpenSupport;
88
import org.openide.windows.CloneableTopComponent;
88
import org.openide.windows.CloneableTopComponent;
89
import org.openide.windows.IOContainer;
90
import org.openide.xml.XMLUtil;
89
91
90
/** 
92
/** 
91
 * Editor support for SQL data objects. There can be two "kinds" of SQL editors: one for normal
93
 * Editor support for SQL data objects. There can be two "kinds" of SQL editors: one for normal
Lines 140-151 Link Here
140
    
142
    
141
    @Override
143
    @Override
142
    protected boolean notifyModified () {
144
    protected boolean notifyModified () {
143
        if (!super.notifyModified()) 
145
        if (!super.notifyModified()) {
144
            return false;
146
            return false;
147
        }
145
        
148
        
146
        if (!isConsole()) {
149
        if (!isConsole()) {
147
            // Add the save cookie to the data object
150
            // Add the save cookie to the data object
148
            SQLDataObject obj = (SQLDataObject)getDataObject();
151
            SQLDataObject obj = (SQLDataObject) getDataObject();
149
            if (obj.getLookup().lookup(SaveCookie.class) == null) {
152
            if (obj.getLookup().lookup(SaveCookie.class) == null) {
150
                obj.addCookie(saveCookie);
153
                obj.addCookie(saveCookie);
151
                obj.setModified(true);
154
                obj.setModified(true);
Lines 163-169 Link Here
163
    
166
    
164
    @Override
167
    @Override
165
    protected Pane createPane() {
168
    protected Pane createPane() {
166
        Pane pane = (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(SQLDataLoader.SQL_MIME_TYPE, getDataObject());
169
        Pane pane = (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(
170
                SQLDataLoader.SQL_MIME_TYPE, getDataObject());
167
        return pane;
171
        return pane;
168
    }
172
    }
169
    
173
    
Lines 173-183 Link Here
173
    }
177
    }
174
178
175
    @Override
179
    @Override
176
    protected void notifyUnmodified () {
180
    protected void notifyUnmodified() {
177
        super.notifyUnmodified();
181
        super.notifyUnmodified();
178
182
179
        // Remove the save cookie from the data object
183
        // Remove the save cookie from the data object
180
        SQLDataObject obj = (SQLDataObject)getDataObject();
184
        SQLDataObject obj = (SQLDataObject) getDataObject();
181
        Cookie cookie = obj.getLookup().lookup(SaveCookie.class);
185
        Cookie cookie = obj.getLookup().lookup(SaveCookie.class);
182
        if (cookie != null && cookie.equals(saveCookie)) {
186
        if (cookie != null && cookie.equals(saveCookie)) {
183
            obj.removeCookie(saveCookie);
187
            obj.removeCookie(saveCookie);
Lines 188-206 Link Here
188
    @Override
192
    @Override
189
    protected String messageToolTip() {
193
    protected String messageToolTip() {
190
        if (isConsole()) {
194
        if (isConsole()) {
195
            DatabaseConnection dc = getDatabaseConnection();
196
            if (dc != null) {
197
                try {
198
                    return String.format(
199
                            "<html>%s<br>%s<br>JDBC-URL: %s</html>",
200
                            XMLUtil.toAttributeValue(
201
                            getDataObject().getPrimaryFile().getName()),
202
                            XMLUtil.toAttributeValue(dc.getDisplayName()),
203
                            XMLUtil.toAttributeValue(dc.getDatabaseURL()));
204
                } catch (CharConversionException ex) {
205
                    LOGGER.log(Level.WARNING, "", ex);
191
            return getDataObject().getPrimaryFile().getName();
206
            return getDataObject().getPrimaryFile().getName();
207
                }
192
        } else {
208
        } else {
209
                return getDataObject().getPrimaryFile().getName();
210
            }
211
        } else {
193
            return super.messageToolTip();
212
            return super.messageToolTip();
194
        }
213
        }
195
    }
214
    }
196
    
215
    
197
    @Override
216
    @Override
198
    protected String messageName() {
217
    protected String messageName() {
199
        if (!isValid()) return ""; // NOI18N
218
        if (!isValid()) {
200
        
219
            return ""; // NOI18N
220
        }
201
        if (isConsole()) {
221
        if (isConsole()) {
202
            // just the name, no modified or r/o flags
222
            if (getDatabaseConnection() != null) {
203
            return getDataObject().getName();
223
                String connectionName = getDatabaseConnection().getDisplayName();
224
                if (connectionName.length() > 25) {
225
                    connectionName = connectionName.substring(0, 25) + "\u2026";
226
                }
227
                return NbBundle.getMessage(SQLEditorSupport.class, "LBL_ConsoleWithConnection",
228
                    getDataObject().getName(),
229
                    connectionName);
230
            }
231
            return NbBundle.getMessage(SQLEditorSupport.class, "LBL_Console",
232
                    getDataObject().getName());
204
        } else {
233
        } else {
205
            return super.messageName();
234
            return super.messageName();
206
        }
235
        }
Lines 208-218 Link Here
208
    
237
    
209
    @Override
238
    @Override
210
    protected String messageHtmlName() {
239
    protected String messageHtmlName() {
211
        if (!isValid()) return ""; // NOI18N
240
        if (!isValid()) {
212
        
241
            return ""; // NOI18N
242
        }
213
        if (isConsole()) {
243
        if (isConsole()) {
214
            // just the name, no modified or r/o flags
244
            // just the name, no modified or r/o flags
215
            String name = getDataObject().getName();
245
            String name = messageName();
216
            if (name != null) {
246
            if (name != null) {
217
                if (!name.startsWith("<html>")) { // NOI18N
247
                if (!name.startsWith("<html>")) { // NOI18N
218
                    name = "<html>" + name; // NOI18N
248
                    name = "<html>" + name; // NOI18N
Lines 250-256 Link Here
250
    }
280
    }
251
    
281
    
252
    boolean isConsole() {
282
    boolean isConsole() {
253
        return ((SQLDataObject)getDataObject()).isConsole();
283
        return ((SQLDataObject) getDataObject()).isConsole();
254
    }
284
    }
255
    
285
    
256
    boolean isValid() {
286
    boolean isValid() {
Lines 292-298 Link Here
292
    @Override
322
    @Override
293
    public synchronized void setDatabaseConnection(DatabaseConnection dbconn) {
323
    public synchronized void setDatabaseConnection(DatabaseConnection dbconn) {
294
        this.dbconn = dbconn;
324
        this.dbconn = dbconn;
295
        sqlPropChangeSupport.firePropertyChange(SQLExecution.PROP_DATABASE_CONNECTION, null, null);
325
        sqlPropChangeSupport.firePropertyChange(
326
                SQLExecution.PROP_DATABASE_CONNECTION, null, null);
327
        updateTitles();
296
    }
328
    }
297
    
329
    
298
    @Override
330
    @Override
Lines 318-330 Link Here
318
    }
350
    }
319
351
320
    @Override
352
    @Override
321
    public void saveAs( FileObject folder, String fileName ) throws IOException {
353
    public void saveAs(FileObject folder, String fileName) throws IOException {
322
        String fn = FileUtil.getFileDisplayName(folder) + File.separator + fileName; 
354
        String fn = FileUtil.getFileDisplayName(folder) + File.separator + fileName; 
323
        File existingFile = FileUtil.normalizeFile(new File(fn));
355
        File existingFile = FileUtil.normalizeFile(new File(fn));
324
        if (existingFile.exists()) {
356
        if (existingFile.exists()) {
325
            NotifyDescriptor confirm = new NotifyDescriptor.Confirmation(
357
            NotifyDescriptor confirm = new NotifyDescriptor.Confirmation(
326
                    NbBundle.getMessage(SQLEditorSupport.class, "MSG_ConfirmReplace", fileName),
358
                    NbBundle.getMessage(SQLEditorSupport.class,
327
                    NbBundle.getMessage(SQLEditorSupport.class, "MSG_ConfirmReplaceFileTitle"),
359
                    "MSG_ConfirmReplace", fileName),
360
                    NbBundle.getMessage(SQLEditorSupport.class,
361
                    "MSG_ConfirmReplaceFileTitle"),
328
                    NotifyDescriptor.YES_NO_OPTION);
362
                    NotifyDescriptor.YES_NO_OPTION);
329
            DialogDisplayer.getDefault().notify(confirm);
363
            DialogDisplayer.getDefault().notify(confirm);
330
            if (!confirm.getValue().equals(NotifyDescriptor.YES_OPTION)) {
364
            if (!confirm.getValue().equals(NotifyDescriptor.YES_OPTION)) {
Lines 366-372 Link Here
366
                    task.removeTaskListener(this);
400
                    task.removeTaskListener(this);
367
                    refresh();
401
                    refresh();
368
                }
402
                }
369
370
            });
403
            });
371
        }
404
        }
372
    }
405
    }
Lines 439-445 Link Here
439
    
472
    
440
    private void refresh() {
473
    private void refresh() {
441
        if (dbconn == null) {
474
        if (dbconn == null) {
442
            return ;
475
            return;
443
        }
476
        }
444
        ConnectionManager.getDefault().refreshConnectionInExplorer(dbconn);
477
        ConnectionManager.getDefault().refreshConnectionInExplorer(dbconn);
445
    }
478
    }
Lines 538-544 Link Here
538
                    return;
571
                    return;
539
                }
572
                }
540
573
541
                ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutingStatements"), this);
574
                ProgressHandle handle = ProgressHandleFactory.createHandle(
575
                        NbBundle.getMessage(SQLEditorSupport.class,
576
                        "LBL_ExecutingStatements"), this);
542
                handle.start();
577
                handle.start();
543
                try {
578
                try {
544
                    handle.switchToIndeterminate();
579
                    handle.switchToIndeterminate();
Lines 546-552 Link Here
546
                    setStatusText(""); // NOI18N
581
                    setStatusText(""); // NOI18N
547
582
548
                    if (LOG) {
583
                    if (LOG) {
549
                        LOGGER.log(Level.FINE, "Closing the old execution result"); // NOI18N
584
                        LOGGER.log(Level.FINE,
585
                                "Closing the old execution result"); // NOI18N
550
                    }
586
                    }
551
                    int pageSize = -1;
587
                    int pageSize = -1;
552
                    if (parent.executionResults != null && parent.executionResults.size() > 0) {
588
                    if (parent.executionResults != null && parent.executionResults.size() > 0) {
Lines 561-567 Link Here
561
                    parent.closeExecutionResult();
597
                    parent.closeExecutionResult();
562
598
563
                    SQLExecutionLoggerImpl logger = parent.createLogger();
599
                    SQLExecutionLoggerImpl logger = parent.createLogger();
564
                    SQLExecutionResults executionResults = SQLExecuteHelper.execute(sql, startOffset, endOffset, dbconn, logger, pageSize);
600
                    SQLExecutionResults executionResults = SQLExecuteHelper.execute(
601
                            sql, startOffset, endOffset, dbconn, logger, pageSize);
565
                    handleExecutionResults(executionResults, logger);
602
                    handleExecutionResults(executionResults, logger);
566
                } finally {
603
                } finally {
567
                    handle.finish();
604
                    handle.finish();
Lines 574-580 Link Here
574
        private void handleExecutionResults(SQLExecutionResults executionResults, SQLExecutionLoggerImpl logger) {
611
        private void handleExecutionResults(SQLExecutionResults executionResults, SQLExecutionLoggerImpl logger) {
575
            if (executionResults == null) {
612
            if (executionResults == null) {
576
                // execution cancelled
613
                // execution cancelled
577
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutionCancelled"));
614
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class,
615
                        "LBL_ExecutionCancelled"));
578
                return;
616
                return;
579
            }
617
            }
580
618
Lines 582-588 Link Here
582
            
620
            
583
            if (executionResults.size() <= 0) {
621
            if (executionResults.size() <= 0) {
584
                // no results, but successfull
622
                // no results, but successfull
585
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutedSuccessfully"));
623
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class,
624
                        "LBL_ExecutedSuccessfully"));
586
                return;
625
                return;
587
            }
626
            }
588
627
Lines 590-598 Link Here
590
629
591
            if (executionResults.hasExceptions()) {
630
            if (executionResults.hasExceptions()) {
592
                // there was at least one exception
631
                // there was at least one exception
593
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutionFinishedWithErrors"));
632
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class,
633
                        "LBL_ExecutionFinishedWithErrors"));
594
            } else {
634
            } else {
595
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class, "LBL_ExecutedSuccessfully"));
635
                setStatusText(NbBundle.getMessage(SQLEditorSupport.class,
636
                        "LBL_ExecutedSuccessfully"));
596
            }
637
            }
597
        }
638
        }
598
        
639
        
Lines 607-614 Link Here
607
    }
648
    }
608
649
609
    /** 
650
    /** 
610
     * Environment for this support. Ensures that getDataObject().setModified(true)
651
     * Environment for this support. Ensures that
611
     * is not called if this support's editor was opened as a console.
652
     * getDataObject().setModified(true) is not called if this support's editor
653
     * was opened as a console.
612
     */
654
     */
613
    static final class Environment extends DataEditorSupport.Env {
655
    static final class Environment extends DataEditorSupport.Env {
614
656
Lines 629-635 Link Here
629
671
630
        @Override
672
        @Override
631
        protected FileLock takeLock() throws IOException {
673
        protected FileLock takeLock() throws IOException {
632
            MultiDataObject obj = (MultiDataObject)getDataObject();
674
            MultiDataObject obj = (MultiDataObject) getDataObject();
633
            fileLock = obj.getPrimaryEntry().takeLock();
675
            fileLock = obj.getPrimaryEntry().takeLock();
634
            return fileLock;
676
            return fileLock;
635
        }
677
        }
(-)db.sql.editor/src/org/netbeans/modules/db/sql/editor/Bundle.properties (-2 / +2 lines)
Lines 44-51 Link Here
44
44
45
#SQLEditorProviderImpl
45
#SQLEditorProviderImpl
46
#{0} = command number
46
#{0} = command number
47
#PARTI18N - only localize "SQL Command" and do not add anything after ".sql"
47
#PARTI18N - only localize "SQL Command" and do not add anything after ".sql" - keep it short!
48
LBL_SQLCommandFileName=SQL Command {0}.sql
48
LBL_SQLCommandFileName=SQL CON {0}.sql
49
49
50
#options
50
#options
51
NAME_coloring_sql-whitespace=White Space
51
NAME_coloring_sql-whitespace=White Space

Return to bug 195880