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 227588
Collapse All | Expand All

(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetJXTable.java (+3 lines)
Lines 301-306 Link Here
301
301
302
    @Override
302
    @Override
303
    public boolean isCellEditable(int row, int column) {
303
    public boolean isCellEditable(int row, int column) {
304
        if(getCellEditor(row, column) instanceof AlwaysEnable) {
305
            return true;
306
        }
304
        if(getModel() != null) {
307
        if(getModel() != null) {
305
            int modelRow = convertRowIndexToModel(row);
308
            int modelRow = convertRowIndexToModel(row);
306
            int modelColumn = convertColumnIndexToModel(column);
309
            int modelColumn = convertColumnIndexToModel(column);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/AlwaysEnable.java (+54 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
43
44
/**
45
 * Marker interface for CellEditors that should be enabled even if TableModel is
46
 * not editable.
47
 * 
48
 * It is expected that the CellEditor handles unmodifiable models itself
49
 * 
50
 * @author Matthias Bläsing
51
 */
52
public interface AlwaysEnable {
53
    
54
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java (-11 / +16 lines)
Lines 71-77 Link Here
71
71
72
public class BlobFieldTableCellEditor extends AbstractCellEditor
72
public class BlobFieldTableCellEditor extends AbstractCellEditor
73
        implements TableCellEditor,
73
        implements TableCellEditor,
74
        ActionListener {
74
        ActionListener, AlwaysEnable {
75
    private static final Logger LOG = Logger.getLogger(
75
    private static final Logger LOG = Logger.getLogger(
76
            BlobFieldTableCellEditor.class.getName());
76
            BlobFieldTableCellEditor.class.getName());
77
77
Lines 82-87 Link Here
82
    protected JTable table;
82
    protected JTable table;
83
    protected JMenuItem saveContentMenuItem;
83
    protected JMenuItem saveContentMenuItem;
84
    protected JMenuItem miOpenImageMenuItem;
84
    protected JMenuItem miOpenImageMenuItem;
85
    protected JMenuItem miLobLoadAction;
86
    protected JMenuItem miLobNullAction;
85
87
86
    @SuppressWarnings("LeakingThisInConstructor")
88
    @SuppressWarnings("LeakingThisInConstructor")
87
    public BlobFieldTableCellEditor() {
89
    public BlobFieldTableCellEditor() {
Lines 97-104 Link Here
97
        button.setFont(new Font(button.getFont().getFamily(), Font.ITALIC, 9));
99
        button.setFont(new Font(button.getFont().getFamily(), Font.ITALIC, 9));
98
100
99
        popup = new JPopupMenu();
101
        popup = new JPopupMenu();
100
        final JMenuItem miLobSaveAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "saveLob.title"));
102
        saveContentMenuItem = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "saveLob.title"));
101
        miLobSaveAction.addActionListener(new ActionListener() {
103
        saveContentMenuItem.addActionListener(new ActionListener() {
102
104
103
            @Override
105
            @Override
104
            public void actionPerformed(ActionEvent e) {
106
            public void actionPerformed(ActionEvent e) {
Lines 106-116 Link Here
106
                fireEditingCanceled();
108
                fireEditingCanceled();
107
            }
109
            }
108
        });
110
        });
109
        saveContentMenuItem = miLobSaveAction;
111
        popup.add(saveContentMenuItem);
110
        popup.add(miLobSaveAction);
111
112
112
        final JMenuItem miOpenImageAction = new JMenuItem("Open as Image");
113
        miOpenImageMenuItem = new JMenuItem("Open as Image");
113
        miOpenImageAction.addActionListener(new ActionListener() {
114
        miOpenImageMenuItem.addActionListener(new ActionListener() {
114
115
115
            @Override
116
            @Override
116
            public void actionPerformed(ActionEvent e) {
117
            public void actionPerformed(ActionEvent e) {
Lines 118-127 Link Here
118
                fireEditingCanceled();
119
                fireEditingCanceled();
119
            }
120
            }
120
        });
121
        });
121
        miOpenImageMenuItem = miOpenImageAction;
122
        popup.add(miOpenImageMenuItem);
122
        popup.add(miOpenImageAction);
123
123
124
        final JMenuItem miLobLoadAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "loadLob.title"));
124
        miLobLoadAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "loadLob.title"));
125
        miLobLoadAction.addActionListener(new ActionListener() {
125
        miLobLoadAction.addActionListener(new ActionListener() {
126
126
127
            @Override
127
            @Override
Lines 134-140 Link Here
134
            }
134
            }
135
        });
135
        });
136
        popup.add(miLobLoadAction);
136
        popup.add(miLobLoadAction);
137
        final JMenuItem miLobNullAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "nullLob.title"));
137
        miLobNullAction = new JMenuItem(NbBundle.getMessage(BlobFieldTableCellEditor.class, "nullLob.title"));
138
        miLobNullAction.addActionListener(new ActionListener() {
138
        miLobNullAction.addActionListener(new ActionListener() {
139
139
140
            @Override
140
            @Override
Lines 157-162 Link Here
157
    @Override
157
    @Override
158
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
158
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
159
        currentValue = (java.sql.Blob) value;
159
        currentValue = (java.sql.Blob) value;
160
        int modelRow = table.convertRowIndexToModel(row);
161
        int modelColumn = table.convertColumnIndexToModel(column);
162
        boolean editable = table.getModel().isCellEditable(modelRow, modelColumn);
160
        if (currentValue != null) {
163
        if (currentValue != null) {
161
            saveContentMenuItem.setEnabled(true);
164
            saveContentMenuItem.setEnabled(true);
162
            miOpenImageMenuItem.setEnabled(true);
165
            miOpenImageMenuItem.setEnabled(true);
Lines 181-186 Link Here
181
            miOpenImageMenuItem.setEnabled(false);
184
            miOpenImageMenuItem.setEnabled(false);
182
            button.setText("<NULL>");
185
            button.setText("<NULL>");
183
        }
186
        }
187
        miLobLoadAction.setEnabled(editable);
188
        miLobNullAction.setEnabled(editable);
184
        this.table = table;
189
        this.table = table;
185
        return button;
190
        return button;
186
    }
191
    }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/Bundle.properties (+1 lines)
Lines 42-47 Link Here
42
saveLob.title=Save to file
42
saveLob.title=Save to file
43
loadLob.title=Read from file
43
loadLob.title=Read from file
44
editClob.title=Edit data
44
editClob.title=Edit data
45
editClobReadOnly.title=Show data
45
loadLob.sourceNotReadable=Source file can't be read.\nCheck file/directory permissions.
46
loadLob.sourceNotReadable=Source file can't be read.\nCheck file/directory permissions.
46
saveLob.unknownFormat=Unknown Format for Lob-Handling
47
saveLob.unknownFormat=Unknown Format for Lob-Handling
47
saveLob.targetNotWriteable=Target file can't be written.\nCheck file/directory permissions.
48
saveLob.targetNotWriteable=Target file can't be written.\nCheck file/directory permissions.
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (-18 / +36 lines)
Lines 65-71 Link Here
65
65
66
public class ClobFieldTableCellEditor extends AbstractCellEditor
66
public class ClobFieldTableCellEditor extends AbstractCellEditor
67
        implements TableCellEditor,
67
        implements TableCellEditor,
68
        ActionListener {
68
        ActionListener, AlwaysEnable {
69
    
69
    
70
    private class CharsetSelector extends JPanel {
70
    private class CharsetSelector extends JPanel {
71
        private JComboBox charsetSelect;
71
        private JComboBox charsetSelect;
Lines 102-108 Link Here
102
    protected JTable table;
102
    protected JTable table;
103
    protected int currentRow;
103
    protected int currentRow;
104
    protected int currentColumn;
104
    protected int currentColumn;
105
    protected int currentModelRow;
106
    protected int currentModelColumn;
105
    protected JMenuItem saveContentMenuItem;
107
    protected JMenuItem saveContentMenuItem;
108
    protected JMenuItem editContentMenuItem;
109
    protected JMenuItem loadContentMenuItem;
110
    protected JMenuItem nullContentMenuItem;
106
    
111
    
107
    @SuppressWarnings("LeakingThisInConstructor")
112
    @SuppressWarnings("LeakingThisInConstructor")
108
    public ClobFieldTableCellEditor() {
113
    public ClobFieldTableCellEditor() {
Lines 118-125 Link Here
118
        button.setFont(new Font(button.getFont().getFamily(), Font.ITALIC, 9));
123
        button.setFont(new Font(button.getFont().getFamily(), Font.ITALIC, 9));
119
        
124
        
120
        popup = new JPopupMenu();
125
        popup = new JPopupMenu();
121
        final JMenuItem miLobSaveAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "saveLob.title"));
126
        saveContentMenuItem = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "saveLob.title"));
122
        miLobSaveAction.addActionListener(new ActionListener() {
127
        saveContentMenuItem.addActionListener(new ActionListener() {
123
            
128
            
124
            @Override
129
            @Override
125
            public void actionPerformed(ActionEvent e) {
130
            public void actionPerformed(ActionEvent e) {
Lines 127-136 Link Here
127
                fireEditingCanceled();
132
                fireEditingCanceled();
128
            }
133
            }
129
        });
134
        });
130
        saveContentMenuItem = miLobSaveAction;
135
        popup.add(saveContentMenuItem);
131
        popup.add(miLobSaveAction);
136
        editContentMenuItem = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClob.title"));
132
        final JMenuItem miLobEditAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClob.title"));
137
        editContentMenuItem.addActionListener(new ActionListener() {
133
        miLobEditAction.addActionListener(new ActionListener() {
134
            
138
            
135
            @Override
139
            @Override
136
            public void actionPerformed(ActionEvent e) {
140
            public void actionPerformed(ActionEvent e) {
Lines 138-146 Link Here
138
                editCell();
142
                editCell();
139
            }
143
            }
140
        });
144
        });
141
        popup.add(miLobEditAction);                
145
        popup.add(editContentMenuItem);                
142
        final JMenuItem miLobLoadAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "loadLob.title"));
146
        loadContentMenuItem = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "loadLob.title"));
143
        miLobLoadAction.addActionListener(new ActionListener() {
147
        loadContentMenuItem.addActionListener(new ActionListener() {
144
            
148
            
145
            @Override
149
            @Override
146
            public void actionPerformed(ActionEvent e) {
150
            public void actionPerformed(ActionEvent e) {
Lines 151-159 Link Here
151
                fireEditingStopped();
155
                fireEditingStopped();
152
            }
156
            }
153
        });
157
        });
154
        popup.add(miLobLoadAction);
158
        popup.add(loadContentMenuItem);
155
        final JMenuItem miLobNullAction = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "nullLob.title"));
159
        nullContentMenuItem = new JMenuItem(NbBundle.getMessage(ClobFieldTableCellEditor.class, "nullLob.title"));
156
        miLobNullAction.addActionListener(new ActionListener() {
160
        nullContentMenuItem.addActionListener(new ActionListener() {
157
            
161
            
158
            @Override
162
            @Override
159
            public void actionPerformed(ActionEvent e) {
163
            public void actionPerformed(ActionEvent e) {
Lines 161-167 Link Here
161
                fireEditingStopped();
165
                fireEditingStopped();
162
            }
166
            }
163
        });
167
        });
164
        popup.add(miLobNullAction);
168
        popup.add(nullContentMenuItem);
165
        
169
        
166
    }
170
    }
167
    
171
    
Lines 175-180 Link Here
175
    @Override
179
    @Override
176
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
180
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
177
        currentValue = (java.sql.Clob) value;
181
        currentValue = (java.sql.Clob) value;
182
        this.currentColumn = column;
183
        this.currentRow = row;
184
        this.table = table;
185
        this.currentModelColumn = table.convertColumnIndexToModel(column);
186
        this.currentModelRow = table.convertRowIndexToModel(row);
187
        boolean editable = table.getModel().isCellEditable(currentModelRow, currentModelColumn);
178
        if (currentValue != null) {
188
        if (currentValue != null) {
179
            saveContentMenuItem.setEnabled(true);
189
            saveContentMenuItem.setEnabled(true);
180
            try {
190
            try {
Lines 197-205 Link Here
197
            saveContentMenuItem.setEnabled(false);
207
            saveContentMenuItem.setEnabled(false);
198
            button.setText("<NULL>");
208
            button.setText("<NULL>");
199
        }
209
        }
200
        this.currentColumn = column;
210
        loadContentMenuItem.setEnabled(editable);
201
        this.currentRow = row;
211
        nullContentMenuItem.setEnabled(editable);
202
        this.table = table;
212
        if (editable) {
213
            editContentMenuItem.setEnabled(true);
214
            editContentMenuItem.setText(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClob.title"));
215
        } else {
216
            editContentMenuItem.setEnabled(currentValue != null);
217
            editContentMenuItem.setText(NbBundle.getMessage(ClobFieldTableCellEditor.class, "editClobReadOnly.title"));
218
        }
203
        return button;
219
        return button;
204
    }
220
    }
205
    
221
    
Lines 354-362 Link Here
354
        }
370
        }
355
        
371
        
356
        JTextArea textArea = new JTextArea(20, 80);
372
        JTextArea textArea = new JTextArea(20, 80);
373
        // Work around: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7100524
374
        textArea.setDropTarget(null);
357
        textArea.setText(stringVal);
375
        textArea.setText(stringVal);
358
        textArea.setCaretPosition(0);
376
        textArea.setCaretPosition(0);
359
        textArea.setEditable(table.isCellEditable(currentRow, currentColumn));
377
        textArea.setEditable(table.getModel().isCellEditable(currentModelRow, currentModelColumn));
360
        
378
        
361
        JScrollPane pane = new JScrollPane(textArea);
379
        JScrollPane pane = new JScrollPane(textArea);
362
        pane.addHierarchyListener(
380
        pane.addHierarchyListener(

Return to bug 227588