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

(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBColumn.java (-8 / +7 lines)
Lines 48-54 Link Here
48
 * 
48
 * 
49
 * @author Ahimanikya Satapathy
49
 * @author Ahimanikya Satapathy
50
 */
50
 */
51
public final class DBColumn extends DBObject<DBTable> implements Comparable {
51
public final class DBColumn extends DBObject<DBTable> implements Comparable<DBColumn> {
52
52
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
54
    private boolean foreignKey;
54
    private boolean foreignKey;
Lines 81-105 Link Here
81
        editable = (!table.getName().equals("") && !isGenerated);
81
        editable = (!table.getName().equals("") && !isGenerated);
82
    }
82
    }
83
83
84
    public int compareTo(Object refObj) {
84
    @Override
85
        if (refObj == null) {
85
    public int compareTo(DBColumn refColumn) {
86
        if (refColumn == null) {
86
            return -1;
87
            return -1;
87
        }
88
        }
88
89
89
        if (refObj == this) {
90
        if (refColumn == this) {
90
            return 0;
91
            return 0;
91
        }
92
        }
92
93
93
        String myName = getDisplayName();
94
        String myName = getDisplayName();
94
        myName = (myName == null) ? columnName : myName;
95
        myName = (myName == null) ? columnName : myName;
95
96
96
        String refName = null;
97
        if (!(refColumn instanceof DBColumn)) {
97
        if (!(refObj instanceof DBColumn)) {
98
            return -1;
98
            return -1;
99
        }
99
        }
100
100
101
        DBColumn refColumn = (DBColumn) refObj;
101
        String refName = refColumn.getName();
102
        refName = refColumn.getName();
103
102
104
        // compare primary keys
103
        // compare primary keys
105
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
104
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactory.java (-2 / +2 lines)
Lines 114-120 Link Here
114
    }
114
    }
115
115
116
    private static int getDBTypeFromURL(String url) {
116
    private static int getDBTypeFromURL(String url) {
117
        int dbtype = -1;
117
        int dbtype;
118
118
119
        // get the database type based on the product name converted to lowercase
119
        // get the database type based on the product name converted to lowercase
120
        url = url.toLowerCase();
120
        url = url.toLowerCase();
Lines 237-243 Link Here
237
                        nfe);
237
                        nfe);
238
            }
238
            }
239
239
240
            boolean isNullable = (rsMeta.isNullable(i) == rsMeta.columnNullable);
240
            boolean isNullable = (rsMeta.isNullable(i) == ResultSetMetaData.columnNullable);
241
            String displayName = rsMeta.getColumnLabel(i);
241
            String displayName = rsMeta.getColumnLabel(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewDBTable.java (-1 / +2 lines)
Lines 114-120 Link Here
114
        return columns.size();
114
        return columns.size();
115
    }
115
    }
116
116
117
    public synchronized Map getColumns() {
117
    public synchronized Map<String,DBColumn> getColumns() {
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
119
        for (DBTable tbl : dbTables) {
119
        for (DBTable tbl : dbTables) {
120
            colMap.putAll(tbl.getColumns());
120
            colMap.putAll(tbl.getColumns());
Lines 138-143 Link Here
138
        private ColumnOrderComparator() {
138
        private ColumnOrderComparator() {
139
        }
139
        }
140
140
141
        @Override
141
        public int compare(DBColumn col1, DBColumn col2) {
142
        public int compare(DBColumn col1, DBColumn col2) {
142
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
        }
144
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java (-12 / +7 lines)
Lines 207-213 Link Here
207
            }
207
            }
208
        }
208
        }
209
        Loader l = new Loader();
209
        Loader l = new Loader();
210
        Future f = rp.submit(l);
210
        Future<?> f = rp.submit(l);
211
        try {
211
        try {
212
            f.get();
212
            f.get();
213
        } catch (InterruptedException ex) {
213
        } catch (InterruptedException ex) {
Lines 409-419 Link Here
409
                pstmt = conn.prepareStatement(updateStmt);
409
                pstmt = conn.prepareStatement(updateStmt);
410
                int pos = 1;
410
                int pos = 1;
411
                for (Object val : values) {
411
                for (Object val : values) {
412
                    // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
413
                    if (DataViewUtils.isSQLConstantString(val)) {
414
                        continue;
415
                    }
416
417
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
412
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
418
                    pos++;
413
                    pos++;
419
                }
414
                }
Lines 654-660 Link Here
654
                }
649
                }
655
            }
650
            }
656
        } catch (SQLException ex) {
651
        } catch (SQLException ex) {
657
            LOGGER.log(Level.SEVERE, "Could not get total row count " + ex); // NOI18N
652
            LOGGER.log(Level.SEVERE, "Could not get total row count ", ex); // NOI18N
658
        }
653
        }
659
    }
654
    }
660
655
Lines 682-688 Link Here
682
                stmt.setFetchSize(pageSize);
677
                stmt.setFetchSize(pageSize);
683
            } catch (SQLException e) {
678
            } catch (SQLException e) {
684
                // ignore -  used only as a hint to the driver to optimize
679
                // ignore -  used only as a hint to the driver to optimize
685
                LOGGER.log(Level.WARNING, "Unable to set Fetch size" + e); // NOI18N
680
                LOGGER.log(Level.WARNING, "Unable to set Fetch size", e); // NOI18N
686
            }
681
            }
687
682
688
            try {
683
            try {
Lines 692-698 Link Here
692
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
687
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
693
                }
688
                }
694
            } catch (SQLException exc) {
689
            } catch (SQLException exc) {
695
                LOGGER.log(Level.WARNING, "Unable to set Max row size" + exc); // NOI18N
690
                LOGGER.log(Level.WARNING, "Unable to set Max row size", exc); // NOI18N
696
            }
691
            }
697
        } else {
692
        } else {
698
            stmt = conn.createStatement();
693
            stmt = conn.createStatement();
Lines 701-707 Link Here
701
    }
696
    }
702
697
703
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
698
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
704
        LOGGER.log(Level.FINE, "Statement: " + sql); // NOI18N
699
        LOGGER.log(Level.FINE, "Statement: {0}", sql); // NOI18N
705
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
700
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
706
701
707
        long startTime = System.currentTimeMillis();
702
        long startTime = System.currentTimeMillis();
Lines 712-724 Link Here
712
            try {
707
            try {
713
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
708
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
714
            } catch (NullPointerException ex) {
709
            } catch (NullPointerException ex) {
715
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + ex);
710
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, ex});
716
                throw new SQLException(ex);
711
                throw new SQLException(ex);
717
            } catch (SQLException sqlExc) {
712
            } catch (SQLException sqlExc) {
718
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
713
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
719
                    isResultSet = stmt.execute(sql);
714
                    isResultSet = stmt.execute(sql);
720
                } else {
715
                } else {
721
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + sqlExc);
716
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, sqlExc});
722
                    throw sqlExc;
717
                    throw sqlExc;
723
                }
718
                }
724
            }
719
            }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java (-3 / +3 lines)
Lines 101-107 Link Here
101
        });
101
        });
102
    }
102
    }
103
103
104
    public ResultSetCellRenderer(ComponentProvider componentProvider) {
104
    public ResultSetCellRenderer(ComponentProvider<? extends JComponent> componentProvider) {
105
        super(componentProvider);
105
        super(componentProvider);
106
    }
106
    }
107
107
Lines 119-125 Link Here
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
120
        } else if (value instanceof Number) {
120
        } else if (value instanceof Number) {
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
122
        } else if (DataViewUtils.isSQLConstantString(value)) {
122
        } else if (DataViewUtils.isSQLConstantString(value, null)) {
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
124
            setTableCellToolTip(c, value);
124
            setTableCellToolTip(c, value);
125
            return c;            
125
            return c;            
Lines 256-259 Link Here
256
            return super.getTableCellRendererComponent(table, "<CLOB of unkown size>", isSelected, hasFocus, row, column);
256
            return super.getTableCellRendererComponent(table, "<CLOB of unkown size>", isSelected, hasFocus, row, column);
257
        }
257
        }
258
    }
258
    }
259
}
259
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java (-5 / +4 lines)
Lines 39-45 Link Here
39
 * 
39
 * 
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table;
43
43
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.awt.event.MouseEvent;
45
import java.awt.event.MouseEvent;
Lines 51-57 Link Here
51
import javax.swing.UIManager;
51
import javax.swing.UIManager;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
54
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
55
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
54
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
56
import org.netbeans.modules.db.dataview.util.DataViewUtils;
55
import org.netbeans.modules.db.dataview.util.DataViewUtils;
57
import org.openide.awt.StatusDisplayer;
56
import org.openide.awt.StatusDisplayer;
Lines 61-67 Link Here
61
    protected Object val;
60
    protected Object val;
62
    protected boolean editable = true;
61
    protected boolean editable = true;
63
    protected JTable table;
62
    protected JTable table;
64
    static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
63
    protected static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
65
64
66
    public ResultSetTableCellEditor(final JTextField textField) {
65
    public ResultSetTableCellEditor(final JTextField textField) {
67
        super(textField);
66
        super(textField);
Lines 105-111 Link Here
105
104
106
    @Override
105
    @Override
107
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
106
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
108
        if (DataViewUtils.isSQLConstantString(value)) {
107
        if (DataViewUtils.isSQLConstantString(value, null)) {
109
            value = "";
108
            value = "";
110
        }
109
        }
111
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
110
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
Lines 161-164 Link Here
161
            ((JComponent) c).setEnabled(editable);
160
            ((JComponent) c).setEnabled(editable);
162
        }
161
        }
163
    }
162
    }
164
}
163
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableModel.java (-2 / +4 lines)
Lines 64-70 Link Here
64
    private Class[] collumnClasses;
64
    private Class[] collumnClasses;
65
    protected ResultSetJXTable table;
65
    protected ResultSetJXTable table;
66
66
67
    public static Class getTypeClass(DBColumn col) {
67
    public static Class<? extends Object> getTypeClass(DBColumn col) {
68
        int colType = col.getJdbcType();
68
        int colType = col.getJdbcType();
69
69
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
Lines 116-121 Link Here
116
        }
116
        }
117
    }
117
    }
118
118
119
    @SuppressWarnings("rawtypes")
119
    public ResultSetTableModel(ResultSetJXTable table) {
120
    public ResultSetTableModel(ResultSetJXTable table) {
120
        super();
121
        super();
121
        this.table = table;
122
        this.table = table;
Lines 155-161 Link Here
155
    }
156
    }
156
157
157
    @Override
158
    @Override
158
    public Class getColumnClass(int columnIndex) {
159
    @SuppressWarnings("unchecked")
160
    public Class<? extends Object> getColumnClass(int columnIndex) {
159
        if (collumnClasses[columnIndex] == null) {
161
        if (collumnClasses[columnIndex] == null) {
160
            return super.getColumnClass(columnIndex);
162
            return super.getColumnClass(columnIndex);
161
        } else {
163
        } else {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java (+1 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table.celleditor;
43
43
44
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
44
import java.awt.Component;
45
import java.awt.Component;
45
import javax.swing.BorderFactory;
46
import javax.swing.BorderFactory;
46
import javax.swing.JComponent;
47
import javax.swing.JComponent;
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (-1 / +2 lines)
Lines 79-85 Link Here
79
                }
79
                }
80
            });
80
            });
81
            charsetSelect = new JComboBox();
81
            charsetSelect = new JComboBox();
82
            charsetSelect.setModel(new DefaultComboBoxModel(charset.toArray()));
82
            charsetSelect.setModel(new DefaultComboBoxModel(
83
                    charset.toArray(new Charset[charset.size()])));
83
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            this.add(charsetSelect);
85
            this.add(charsetSelect);
85
        }
86
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java (-2 / +2 lines)
Lines 137-143 Link Here
137
    }
137
    }
138
138
139
    protected Timestamp getValueAsTimestamp(Object value) {
139
    protected Timestamp getValueAsTimestamp(Object value) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value)) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value, null)) {
141
            return new Timestamp(System.currentTimeMillis());
141
            return new Timestamp(System.currentTimeMillis());
142
        }
142
        }
143
143
Lines 227-230 Link Here
227
    public void addKeyListener(KeyListener kl) {
227
    public void addKeyListener(KeyListener kl) {
228
        datePicker.addKeyListener(kl);
228
        datePicker.addKeyListener(kl);
229
    }
229
    }
230
}
230
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/NumberFieldEditor.java (+1 lines)
Lines 46-51 Link Here
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import javax.swing.JTable;
47
import javax.swing.JTable;
48
import javax.swing.JTextField;
48
import javax.swing.JTextField;
49
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
49
50
50
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
52
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java (+1 lines)
Lines 63-68 Link Here
63
import javax.swing.table.TableCellEditor;
63
import javax.swing.table.TableCellEditor;
64
import org.jdesktop.swingx.JXButton;
64
import org.jdesktop.swingx.JXButton;
65
import org.jdesktop.swingx.JXPanel;
65
import org.jdesktop.swingx.JXPanel;
66
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
66
import org.openide.windows.WindowManager;
67
import org.openide.windows.WindowManager;
67
68
68
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
69
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java (-25 / +52 lines)
Lines 166-176 Link Here
166
        
166
        
167
        popupButton = createPopupButton();
167
        popupButton = createPopupButton();
168
        if (popupButton != null) {
168
        if (popupButton != null) {
169
            // this is a trick to get hold of the client prop which
169
            popupButton.putClientProperty("doNotCancelPopup", 
170
            // prevents closing of the popup
170
                    createDoNotCancelPopupClientProperty());
171
            JComboBox box = new JComboBox();
172
            Object preventHide = box.getClientProperty("doNotCancelPopup");
173
            popupButton.putClientProperty("doNotCancelPopup", preventHide);
174
            datePicker.add(popupButton);
171
            datePicker.add(popupButton);
175
        }
172
        }
176
            updateChildLocale(datePicker.getLocale());
173
            updateChildLocale(datePicker.getLocale());
Lines 252-259 Link Here
252
     * PRE: keybindings installed on picker.
249
     * PRE: keybindings installed on picker.
253
     */
250
     */
254
    protected void installLinkPanelKeyboardActions() {
251
    protected void installLinkPanelKeyboardActions() {
255
        if (datePicker.getLinkPanel() == null)
252
        if (datePicker.getLinkPanel() == null)  {
256
            return;
253
            return;
254
        }
257
        ActionMap map = datePicker.getLinkPanel().getActionMap();
255
        ActionMap map = datePicker.getLinkPanel().getActionMap();
258
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
256
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
259
                JXDateTimePicker.HOME_COMMIT_KEY));
257
                JXDateTimePicker.HOME_COMMIT_KEY));
Lines 277-283 Link Here
277
     * 
275
     * 
278
     */
276
     */
279
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
277
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
280
        if (panel == null) return;
278
        if (panel == null) {
279
            return;
280
        }
281
        ActionMap map = panel.getActionMap();
281
        ActionMap map = panel.getActionMap();
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
Lines 705-711 Link Here
705
     *    is intermediate
705
     *    is intermediate
706
     */
706
     */
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
708
        if (adjusting) return;
708
        if (adjusting) {
709
            return;
710
        }
709
        updateEditorValue();
711
        updateEditorValue();
710
    }
712
    }
711
713
Lines 755-765 Link Here
755
            oldEditor.putClientProperty("doNotCancelPopup", null);
757
            oldEditor.putClientProperty("doNotCancelPopup", null);
756
        }
758
        }
757
        datePicker.add(datePicker.getEditor());
759
        datePicker.add(datePicker.getEditor());
758
        // this is a trick to get hold of the client prop which
760
        datePicker.getEditor().putClientProperty("doNotCancelPopup", 
759
        // prevents closing of the popup
761
                createDoNotCancelPopupClientProperty());
760
        JComboBox box = new JComboBox();
761
        Object preventHide = box.getClientProperty("doNotCancelPopup");
762
        datePicker.getEditor().putClientProperty("doNotCancelPopup", preventHide);
763
762
764
        updateEditorValue();
763
        updateEditorValue();
765
        if (updateListeners) {
764
        if (updateListeners) {
Lines 942-948 Link Here
942
     * control popup visibility?
941
     * control popup visibility?
943
     */
942
     */
944
    public void hidePopup() {
943
    public void hidePopup() {
945
        if (popup != null) popup.setVisible(false);
944
        if (popup != null) {
945
            popup.setVisible(false);
946
        }
946
    }
947
    }
947
948
948
    public boolean isPopupVisible() {
949
    public boolean isPopupVisible() {
Lines 980-986 Link Here
980
     */
981
     */
981
    private Action createCommitAction() {
982
    private Action createCommitAction() {
982
        Action action = new AbstractAction() {
983
        Action action = new AbstractAction() {
983
984
            @Override
984
            public void actionPerformed(ActionEvent e) {
985
            public void actionPerformed(ActionEvent e) {
985
                commit();
986
                commit();
986
            }
987
            }
Lines 997-1003 Link Here
997
     */
998
     */
998
    private Action createCancelAction() {
999
    private Action createCancelAction() {
999
        Action action = new AbstractAction() {
1000
        Action action = new AbstractAction() {
1000
1001
            @Override
1001
            public void actionPerformed(ActionEvent e) {
1002
            public void actionPerformed(ActionEvent e) {
1002
                cancel();
1003
                cancel();
1003
            }
1004
            }
Lines 1008-1014 Link Here
1008
1009
1009
    private Action createHomeAction(final boolean commit) {
1010
    private Action createHomeAction(final boolean commit) {
1010
        Action action = new AbstractAction( ) {
1011
        Action action = new AbstractAction( ) {
1011
1012
            @Override
1012
            public void actionPerformed(ActionEvent e) {
1013
            public void actionPerformed(ActionEvent e) {
1013
                home(commit);
1014
                home(commit);
1014
                
1015
                
Lines 1054-1059 Link Here
1054
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
        }
1056
        }
1056
        
1057
        
1058
        @Override
1057
        public void actionPerformed(ActionEvent e) {
1059
        public void actionPerformed(ActionEvent e) {
1058
            cancelAction.actionPerformed(null);
1060
            cancelAction.actionPerformed(null);
1059
            cancel();
1061
            cancel();
Lines 1088-1093 Link Here
1088
            datePicker.getEditor().requestFocusInWindow();
1090
            datePicker.getEditor().requestFocusInWindow();
1089
//            datePicker.requestFocusInWindow();
1091
//            datePicker.requestFocusInWindow();
1090
            SwingUtilities.invokeLater(new Runnable() {
1092
            SwingUtilities.invokeLater(new Runnable() {
1093
                @Override
1091
                public void run() {
1094
                public void run() {
1092
                    popup.show(datePicker,
1095
                    popup.show(datePicker,
1093
                            0, datePicker.getHeight());
1096
                            0, datePicker.getHeight());
Lines 1114-1119 Link Here
1114
            super("TogglePopup");
1117
            super("TogglePopup");
1115
        }
1118
        }
1116
1119
1120
        @Override
1117
        public void actionPerformed(ActionEvent ev) {
1121
        public void actionPerformed(ActionEvent ev) {
1118
            toggleShowPopup();
1122
            toggleShowPopup();
1119
        }
1123
        }
Lines 1165-1173 Link Here
1165
//------------- implement Mouse/MotionListener        
1169
//------------- implement Mouse/MotionListener        
1166
        private boolean _forwardReleaseEvent = false;
1170
        private boolean _forwardReleaseEvent = false;
1167
1171
1172
        @Override
1168
        public void mouseClicked(MouseEvent ev) {
1173
        public void mouseClicked(MouseEvent ev) {
1169
        }
1174
        }
1170
1175
1176
        @Override
1171
        public void mousePressed(MouseEvent ev) {
1177
        public void mousePressed(MouseEvent ev) {
1172
            if (!datePicker.isEnabled()) {
1178
            if (!datePicker.isEnabled()) {
1173
                return;
1179
                return;
Lines 1181-1186 Link Here
1181
            toggleShowPopup();
1187
            toggleShowPopup();
1182
        }
1188
        }
1183
1189
1190
        @Override
1184
        public void mouseReleased(MouseEvent ev) {
1191
        public void mouseReleased(MouseEvent ev) {
1185
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1192
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1186
                return;
1193
                return;
Lines 1196-1207 Link Here
1196
            }
1203
            }
1197
        }
1204
        }
1198
1205
1206
        @Override
1199
        public void mouseEntered(MouseEvent ev) {
1207
        public void mouseEntered(MouseEvent ev) {
1200
        }
1208
        }
1201
1209
1210
        @Override
1202
        public void mouseExited(MouseEvent ev) {
1211
        public void mouseExited(MouseEvent ev) {
1203
        }
1212
        }
1204
1213
1214
        @Override
1205
        public void mouseDragged(MouseEvent ev) {
1215
        public void mouseDragged(MouseEvent ev) {
1206
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1216
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1207
                return;
1217
                return;
Lines 1219-1228 Link Here
1219
            monthView.dispatchEvent(ev);
1229
            monthView.dispatchEvent(ev);
1220
        }
1230
        }
1221
1231
1232
        @Override
1222
        public void mouseMoved(MouseEvent ev) {
1233
        public void mouseMoved(MouseEvent ev) {
1223
        }
1234
        }
1224
//------------------ implement DateSelectionListener
1235
//------------------ implement DateSelectionListener
1225
        
1236
        @Override
1226
        public void valueChanged(DateSelectionEvent ev) {
1237
        public void valueChanged(DateSelectionEvent ev) {
1227
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1238
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1228
        }
1239
        }
Lines 1231-1236 Link Here
1231
        /**
1242
        /**
1232
         * {@inheritDoc}
1243
         * {@inheritDoc}
1233
         */
1244
         */
1245
        @Override
1234
        public void propertyChange(PropertyChangeEvent e) {
1246
        public void propertyChange(PropertyChangeEvent e) {
1235
            if (e.getSource() == datePicker) {
1247
            if (e.getSource() == datePicker) {
1236
                datePickerPropertyChange(e);
1248
                datePickerPropertyChange(e);
Lines 1259-1266 Link Here
1259
         */
1271
         */
1260
        private void editorPropertyChange(PropertyChangeEvent evt) {
1272
        private void editorPropertyChange(PropertyChangeEvent evt) {
1261
            if ("value".equals(evt.getPropertyName())) {
1273
            if ("value".equals(evt.getPropertyName())) {
1262
                ;
1274
1263
                
1264
                Object oldVal = evt.getOldValue();
1275
                Object oldVal = evt.getOldValue();
1265
                Object newVal = evt.getNewValue();
1276
                Object newVal = evt.getNewValue();
1266
                
1277
                
Lines 1353-1371 Link Here
1353
        }
1364
        }
1354
1365
1355
//-------------- implement LayoutManager
1366
//-------------- implement LayoutManager
1356
        
1367
        @Override
1357
        public void addLayoutComponent(String name, Component comp) { }
1368
        public void addLayoutComponent(String name, Component comp) { }
1358
1369
1370
        @Override
1359
        public void removeLayoutComponent(Component comp) { }
1371
        public void removeLayoutComponent(Component comp) { }
1360
1372
1373
        @Override
1361
        public Dimension preferredLayoutSize(Container parent) {
1374
        public Dimension preferredLayoutSize(Container parent) {
1362
            return parent.getPreferredSize();
1375
            return parent.getPreferredSize();
1363
        }
1376
        }
1364
1377
1378
        @Override
1365
        public Dimension minimumLayoutSize(Container parent) {
1379
        public Dimension minimumLayoutSize(Container parent) {
1366
            return parent.getMinimumSize();
1380
            return parent.getMinimumSize();
1367
        }
1381
        }
1368
1382
1383
        @Override
1369
        public void layoutContainer(Container parent) {
1384
        public void layoutContainer(Container parent) {
1370
            Insets insets = datePicker.getInsets();
1385
            Insets insets = datePicker.getInsets();
1371
            int width = datePicker.getWidth() - insets.left - insets.right;
1386
            int width = datePicker.getWidth() - insets.left - insets.right;
Lines 1389-1397 Link Here
1389
        }
1404
        }
1390
1405
1391
// ------------- implement actionListener (listening to monthView actionEvent)
1406
// ------------- implement actionListener (listening to monthView actionEvent)
1392
        
1407
        @Override
1393
        public void actionPerformed(ActionEvent e) {
1408
        public void actionPerformed(ActionEvent e) {
1394
            if (e == null) return;
1409
            if (e == null) {
1410
                return;
1411
            }
1395
            if (e.getSource() == datePicker.getMonthView()) {
1412
            if (e.getSource() == datePicker.getMonthView()) {
1396
                monthViewActionPerformed(e);
1413
                monthViewActionPerformed(e);
1397
            } else if (e.getSource() == datePicker.getEditor()) {
1414
            } else if (e.getSource() == datePicker.getEditor()) {
Lines 1430-1437 Link Here
1430
         * Do the same as combo: manually pass-on the focus to the editor.
1447
         * Do the same as combo: manually pass-on the focus to the editor.
1431
         * 
1448
         * 
1432
         */
1449
         */
1450
        @Override
1433
        public void focusGained(FocusEvent e) {
1451
        public void focusGained(FocusEvent e) {
1434
            if (e.isTemporary()) return;
1452
            if (e.isTemporary()) {
1453
                return;
1454
            }
1435
            popupRemover.load();
1455
            popupRemover.load();
1436
            if (e.getSource() == datePicker) {
1456
            if (e.getSource() == datePicker) {
1437
               datePicker.getEditor().requestFocusInWindow(); 
1457
               datePicker.getEditor().requestFocusInWindow(); 
Lines 1460-1465 Link Here
1460
         * 
1480
         * 
1461
         * listen to keyboardFocusManager?
1481
         * listen to keyboardFocusManager?
1462
         */
1482
         */
1483
        @Override
1463
        public void focusLost(FocusEvent e) {
1484
        public void focusLost(FocusEvent e) {
1464
            
1485
            
1465
        }
1486
        }
Lines 1498-1503 Link Here
1498
            unload(true);
1519
            unload(true);
1499
        }
1520
        }
1500
        
1521
        
1522
        @Override
1501
        public void propertyChange(PropertyChangeEvent evt) {
1523
        public void propertyChange(PropertyChangeEvent evt) {
1502
            if (!isPopupVisible()) {
1524
            if (!isPopupVisible()) {
1503
                unload(false);
1525
                unload(false);
Lines 1606-1610 Link Here
1606
    
1628
    
1607
//------------ utility methods
1629
//------------ utility methods
1608
1630
1609
1631
    private Object createDoNotCancelPopupClientProperty() {
1632
        // this is a trick to get hold of the client prop which
1633
        // prevents closing of the popup
1634
        JComboBox box = new JComboBox();
1635
        return box.getClientProperty("doNotCancelPopup");
1610
}
1636
}
1637
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/DataViewUtils.java (-15 / +7 lines)
Lines 43-58 Link Here
43
 */
43
 */
44
package org.netbeans.modules.db.dataview.util;
44
package org.netbeans.modules.db.dataview.util;
45
45
46
import java.sql.Date;
47
import java.sql.PreparedStatement;
46
import java.sql.PreparedStatement;
48
import java.sql.ResultSet;
47
import java.sql.ResultSet;
49
import java.sql.SQLException;
48
import java.sql.SQLException;
50
import java.sql.Statement;
49
import java.sql.Statement;
51
import java.sql.Time;
52
import java.sql.Timestamp;
53
import java.sql.Types;
50
import java.sql.Types;
54
import java.util.Iterator;
55
import java.util.List;
56
import org.netbeans.modules.db.dataview.meta.DBColumn;
51
import org.netbeans.modules.db.dataview.meta.DBColumn;
57
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
52
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
58
import org.netbeans.modules.db.dataview.meta.DBTable;
53
import org.netbeans.modules.db.dataview.meta.DBTable;
Lines 277-294 Link Here
277
        String refString = column.getName() + " --> "; // NOI18N
272
        String refString = column.getName() + " --> "; // NOI18N
278
        StringBuilder str = new StringBuilder(refString);
273
        StringBuilder str = new StringBuilder(refString);
279
        DBTable table = column.getParentObject();
274
        DBTable table = column.getParentObject();
280
        List list = table.getForeignKeys();
275
        boolean firstReferencedColumn = false;
281
276
282
        Iterator it = list.iterator();
277
        for(DBForeignKey fk: table.getForeignKeys()) {
283
        while (it.hasNext()) {
284
            DBForeignKey fk = (DBForeignKey) it.next();
285
            if (fk.contains(column)) {
278
            if (fk.contains(column)) {
286
                List pkColumnList = fk.getPKColumnNames();
279
                for(String pkColName: fk.getPKColumnNames()) {
287
                Iterator it1 = pkColumnList.iterator();
288
                while (it1.hasNext()) {
289
                    String pkColName = (String) it1.next();
290
                    str.append(pkColName);
280
                    str.append(pkColName);
291
                    if (it1.hasNext()) {
281
                    if (firstReferencedColumn) {
282
                        firstReferencedColumn = false;
283
                    } else {
292
                        str.append(", "); // NOI18N
284
                        str.append(", "); // NOI18N
293
                    }
285
                    }
294
                }
286
                }
Lines 305-311 Link Here
305
    }
297
    }
306
298
307
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
299
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
308
        StringBuffer resultBuffer = new StringBuffer();
300
        StringBuilder resultBuffer = new StringBuilder();
309
        boolean bReplaced = false;
301
        boolean bReplaced = false;
310
302
311
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
303
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java (-7 / +10 lines)
Lines 46-63 Link Here
46
import java.util.Locale;
46
import java.util.Locale;
47
import java.util.TimeZone;
47
import java.util.TimeZone;
48
import java.util.logging.Logger;
48
import java.util.logging.Logger;
49
50
import javax.swing.AbstractAction;
49
import javax.swing.AbstractAction;
51
import javax.swing.Action;
50
import javax.swing.Action;
52
import javax.swing.JComponent;
51
import javax.swing.JComponent;
53
import javax.swing.JFormattedTextField;
52
import javax.swing.JFormattedTextField;
53
import javax.swing.JFormattedTextField.AbstractFormatter;
54
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
54
import javax.swing.JPanel;
55
import javax.swing.JPanel;
55
import javax.swing.JPopupMenu;
56
import javax.swing.JPopupMenu;
56
import javax.swing.UIManager;
57
import javax.swing.UIManager;
57
import javax.swing.JFormattedTextField.AbstractFormatter;
58
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
59
import javax.swing.text.DefaultFormatterFactory;
58
import javax.swing.text.DefaultFormatterFactory;
60
61
import org.jdesktop.swingx.JXHyperlink;
59
import org.jdesktop.swingx.JXHyperlink;
62
import org.jdesktop.swingx.JXMonthView;
60
import org.jdesktop.swingx.JXMonthView;
63
import org.jdesktop.swingx.JXPanel;
61
import org.jdesktop.swingx.JXPanel;
Lines 318-324 Link Here
318
    }
316
    }
319
317
320
    protected class SelectedValuesComparator implements Comparator<Calendar> {
318
    protected class SelectedValuesComparator implements Comparator<Calendar> {
321
319
        @Override
322
        public int compare(Calendar cal1, Calendar cal2) {
320
        public int compare(Calendar cal1, Calendar cal2) {
323
321
324
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
322
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
Lines 372-378 Link Here
372
    private PropertyChangeListener getMonthViewListener() {
370
    private PropertyChangeListener getMonthViewListener() {
373
        if (monthViewListener == null) {
371
        if (monthViewListener == null) {
374
            monthViewListener = new PropertyChangeListener() {
372
            monthViewListener = new PropertyChangeListener() {
375
373
                @Override
376
                public void propertyChange(PropertyChangeEvent evt) {
374
                public void propertyChange(PropertyChangeEvent evt) {
377
                    if ("timeZone".equals(evt.getPropertyName())) {
375
                    if ("timeZone".equals(evt.getPropertyName())) {
378
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
376
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
Lines 849-854 Link Here
849
     * @param height Height of the component to determine baseline for.
847
     * @param height Height of the component to determine baseline for.
850
     * @return baseline for the specified component
848
     * @return baseline for the specified component
851
     */
849
     */
850
    @Override
852
    public int getBaseline(int width, int height) {
851
    public int getBaseline(int width, int height) {
853
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
852
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
854
    }
853
    }
Lines 916-921 Link Here
916
        private TodayAction todayAction;
915
        private TodayAction todayAction;
917
        private JXHyperlink todayLink;
916
        private JXHyperlink todayLink;
918
917
918
        @SuppressWarnings("rawtypes")
919
        TodayPanel() {
919
        TodayPanel() {
920
            super(new FlowLayout());
920
            super(new FlowLayout());
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
Lines 936-942 Link Here
936
936
937
                @Override
937
                @Override
938
                public void mousePressed(MouseEvent e) {
938
                public void mousePressed(MouseEvent e) {
939
                    if (e.getClickCount() != 2) return;
939
                    if (e.getClickCount() != 2) {
940
                        return;
941
                    }
940
                    todayAction.select = true;
942
                    todayAction.select = true;
941
                }
943
                }
942
                
944
                
Lines 973-978 Link Here
973
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
975
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
974
            }
976
            }
975
977
978
            @Override
976
            public void actionPerformed(ActionEvent ae) {
979
            public void actionPerformed(ActionEvent ae) {
977
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
980
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
978
                select = false;
981
                select = false;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java (-5 / +7 lines)
Lines 63-69 Link Here
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
65
65
66
/** Creates a new instance of DBConnectionProviderImpl */
66
    /** Creates a new instance of DBConnectionProviderImpl */
67
    public DBConnectionProviderImpl() {
67
    public DBConnectionProviderImpl() {
68
    }
68
    }
69
    
69
    
Lines 80-85 Link Here
80
        return null;
80
        return null;
81
    }
81
    }
82
82
83
    @Override
83
    public void closeConnection(Connection con) {
84
    public void closeConnection(Connection con) {
84
        try {
85
        try {
85
            if(con != null) {
86
            if(con != null) {
Lines 98-103 Link Here
98
        }
99
        }
99
    }
100
    }
100
101
102
    @Override
101
    public Connection getConnection(DatabaseConnection dbConn) {
103
    public Connection getConnection(DatabaseConnection dbConn) {
102
        try {
104
        try {
103
            String driver = dbConn.getDriverClass();
105
            String driver = dbConn.getDriverClass();
Lines 110-122 Link Here
110
112
111
            TestCaseContext context = DbUtil.getContext();
113
            TestCaseContext context = DbUtil.getContext();
112
            File[] jars = context.getJars();
114
            File[] jars = context.getJars();
113
            ArrayList list = new java.util.ArrayList();
115
            ArrayList<URL> list = new java.util.ArrayList<URL>();
114
            for (int i = 0; i < jars.length; i++) {
116
            for (int i = 0; i < jars.length; i++) {
115
                list.add((URL)jars[i].toURI().toURL());
117
                list.add(jars[i].toURI().toURL());
116
            }
118
            }
117
            URL[] driverURLs = (URL[]) list.toArray(new URL[0]);
119
            URL[] driverURLs = list.toArray(new URL[0]);
118
            URLClassLoader l = new URLClassLoader(driverURLs);
120
            URLClassLoader l = new URLClassLoader(driverURLs);
119
            Class c = Class.forName(driver, true, l);
121
            Class<?> c = Class.forName(driver, true, l);
120
            Driver drv = (Driver) c.newInstance();
122
            Driver drv = (Driver) c.newInstance();
121
            Connection con = drv.connect(url, prop);
123
            Connection con = drv.connect(url, prop);
122
            return con;
124
            return con;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java (-16 / +13 lines)
Lines 57-62 Link Here
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
59
import org.openide.util.Exceptions;
59
import org.openide.util.Exceptions;
60
import org.openide.util.Utilities;
60
61
61
/**
62
/**
62
 *
63
 *
Lines 68-85 Link Here
68
    public static String USER = "user";
69
    public static String USER = "user";
69
    public static String PASSWORD = "password";
70
    public static String PASSWORD = "password";
70
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    private static List localConnectionList = new ArrayList();
72
    private static List<Connection> localConnectionList = new ArrayList<Connection>();
72
73
73
    public static DatabaseConnection getDBConnection() {
74
    public static DatabaseConnection getDBConnection() {
74
        try {
75
        try {
75
            TestCaseContext context = getContext();
76
            TestCaseContext context = getContext();
76
            Properties prop = context.getProperties();
77
            Properties prop = context.getProperties();
77
            File[] jars = context.getJars();
78
            File[] jars = context.getJars();
78
            ArrayList list = new java.util.ArrayList();
79
            ArrayList<URL> list = new java.util.ArrayList<URL>();
79
            for (int i = 0; i < jars.length; i++) {
80
            for (int i = 0; i < jars.length; i++) {
80
                list.add((URL)jars[i].toURI().toURL());
81
                list.add(Utilities.toURI(jars[i]).toURL());
81
            }
82
            }
82
            URL[] urls = (URL[]) list.toArray(new URL[0]);
83
            URL[] urls = list.toArray(new URL[0]);
83
            Class.forName(AXION_DRIVER);
84
            Class.forName(AXION_DRIVER);
84
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
86
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
Lines 153-164 Link Here
153
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // It may pop up a window asking for password.
156
        // It may pop up a window asking for password.
156
        JDBCDriver drv = null;
157
        Connection conn = null;
157
        Connection conn = null;
158
        try {
158
        try {
159
           
159
            //url = adjustDatabaseURL(url);
160
                //url = adjustDatabaseURL(url);
160
            JDBCDriver drv  = registerDriver(driverName);
161
            drv = registerDriver(driverName);
162
161
163
            conn = getConnection(drv, driverName, url, username, password);
162
            conn = getConnection(drv, driverName, url, username, password);
164
            if (conn == null) { // get from db explorer
163
            if (conn == null) { // get from db explorer
Lines 208-219 Link Here
208
207
209
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
208
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
210
        DatabaseConnection dbconn = null;
209
        DatabaseConnection dbconn = null;
211
        JDBCDriver drv = null;
212
        String schema = null;
213
        try {
210
        try {
214
            
211
            //url = adjustDatabaseURL(url);
215
                //url = adjustDatabaseURL(url);
212
            JDBCDriver drv = registerDriver(driverName);
216
            drv = registerDriver(driverName);
217
213
218
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
214
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
219
215
Lines 227-232 Link Here
227
223
228
            // dont add instance db and monitor db and local dbs connections to db explorer.
224
            // dont add instance db and monitor db and local dbs connections to db explorer.
229
            if (dbconn == null) {
225
            if (dbconn == null) {
226
                String schema;
230
                if (url.startsWith(AXION_URL_PREFIX)) {
227
                if (url.startsWith(AXION_URL_PREFIX)) {
231
                    schema = "";
228
                    schema = "";
232
                } else {
229
                } else {
Lines 284-294 Link Here
284
            // if axion db driver not available in db explorer, add it.
281
            // if axion db driver not available in db explorer, add it.
285
            //URL[] url = new URL[1];
282
            //URL[] url = new URL[1];
286
            File[] jars = cxt.getJars();
283
            File[] jars = cxt.getJars();
287
            ArrayList list = new java.util.ArrayList();
284
            ArrayList<URL> list = new java.util.ArrayList<URL>();
288
            for (int i = 0; i < jars.length; i++) {
285
            for (int i = 0; i < jars.length; i++) {
289
                list.add((URL)jars[i].toURI().toURL());
286
                list.add(Utilities.toURI(jars[i]).toURL());
290
            }
287
            }
291
            URL[] url = (URL[]) list.toArray(new URL[0]);
288
            URL[] url = list.toArray(new URL[0]);
292
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
289
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
293
            JDBCDriverManager.getDefault().addDriver(driver);
290
            JDBCDriverManager.getDefault().addDriver(driver);
294
        }
291
        }
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java (-17 / +6 lines)
Lines 69-75 Link Here
69
    private File[] jars;
69
    private File[] jars;
70
    private String name;
70
    private String name;
71
    
71
    
72
    public TestCaseContext(HashMap map,String name)  throws Exception{
72
    public TestCaseContext(HashMap<String,Object> map,String name)  throws Exception{
73
        this.name=name;
73
        this.name=name;
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
Lines 132-138 Link Here
132
        sql_del=getContent(f);
132
        sql_del=getContent(f);
133
    }
133
    }
134
    
134
    
135
    public Map getData(){
135
    public Properties getData(){
136
        return data;
136
        return data;
137
    }
137
    }
138
    
138
    
Lines 148-174 Link Here
148
        jars=f;
148
        jars=f;
149
    }
149
    }
150
    
150
    
151
    private String[] parseContent(File f) throws  Exception{
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
153
        List array=new ArrayList();
154
        String s=null;
155
        while((s=br.readLine())!=null){
156
          array.add(s);
157
        }
158
        if(array.size()==0)
159
            throw new RuntimeException(name+": File "+f.getName()+" doesn't containt the data !");
160
        return (String[])array.toArray(new String[0]);
161
    }
162
    
163
    private  String getContent(File f) throws Exception{
151
    private  String getContent(File f) throws Exception{
164
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
165
        StringBuffer sb=new StringBuffer();
153
        StringBuilder sb=new StringBuilder();
166
        String s=null;
154
        String s;
167
        while((s=br.readLine())!=null){
155
        while((s=br.readLine())!=null){
168
          sb.append(s);
156
          sb.append(s);
169
        }
157
        }
170
        if(sb.length()==0)
158
        if(sb.length()==0) {
171
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
159
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
160
        }
172
        return sb.toString();
161
        return sb.toString();
173
    }
162
    }
174
    
163
    
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java (-5 / +8 lines)
Lines 67-73 Link Here
67
    public static String DB_SQLDEL="dbdel.sql";
67
    public static String DB_SQLDEL="dbdel.sql";
68
    public static String DB_JARS="jar";
68
    public static String DB_JARS="jar";
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
70
    private List list=new ArrayList();
70
    private List<TestCaseContext> list=new ArrayList<TestCaseContext>();
71
    private static  TestCaseDataFactory factory;
71
    private static  TestCaseDataFactory factory;
72
    
72
    
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
Lines 101-107 Link Here
101
    
101
    
102
    private void process() throws Exception{
102
    private void process() throws Exception{
103
       File data_dir=getDataDir();
103
       File data_dir=getDataDir();
104
       HashMap map=new HashMap();
104
       HashMap<String,Object> map=new HashMap<String,Object>();
105
       String[] dir=data_dir.list();
105
       String[] dir=data_dir.list();
106
       for(int i=0;i<dir.length;i++){
106
       for(int i=0;i<dir.length;i++){
107
           String dir_name=dir[i];
107
           String dir_name=dir[i];
Lines 110-128 Link Here
110
                
110
                
111
                for(int index=0;index<FILES.length;index++){
111
                for(int index=0;index<FILES.length;index++){
112
                    File f=new File(path+File.separator+FILES[index]);
112
                    File f=new File(path+File.separator+FILES[index]);
113
                    if(!f.exists())
113
                    if(!f.exists()) {
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
115
                    }
115
                    map.put(FILES[index],f);
116
                    map.put(FILES[index],f);
116
                    
117
                    
117
                }
118
                }
118
                String[] s=new File(path).list(new FilenameFilter() {
119
                String[] s=new File(path).list(new FilenameFilter() {
120
                    @Override
119
                    public boolean accept(File dir, String name) {
121
                    public boolean accept(File dir, String name) {
120
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
122
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
121
                    }
123
                    }
122
                });
124
                });
123
                if(s.length==0)
125
                if(s.length==0) {
124
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
126
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
125
                ArrayList drivers=new ArrayList();
127
                }
128
                ArrayList<File> drivers=new ArrayList<File>();
126
                for(int myint=0;myint<s.length;myint++){
129
                for(int myint=0;myint<s.length;myint++){
127
                   File file=new File(path+File.separator+s[myint]);
130
                   File file=new File(path+File.separator+s[myint]);
128
                   drivers.add(file);
131
                   drivers.add(file);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBColumn.java (-8 / +7 lines)
Lines 48-54 Link Here
48
 * 
48
 * 
49
 * @author Ahimanikya Satapathy
49
 * @author Ahimanikya Satapathy
50
 */
50
 */
51
public final class DBColumn extends DBObject<DBTable> implements Comparable {
51
public final class DBColumn extends DBObject<DBTable> implements Comparable<DBColumn> {
52
52
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
54
    private boolean foreignKey;
54
    private boolean foreignKey;
Lines 81-105 Link Here
81
        editable = (!table.getName().equals("") && !isGenerated);
81
        editable = (!table.getName().equals("") && !isGenerated);
82
    }
82
    }
83
83
84
    public int compareTo(Object refObj) {
84
    @Override
85
        if (refObj == null) {
85
    public int compareTo(DBColumn refColumn) {
86
        if (refColumn == null) {
86
            return -1;
87
            return -1;
87
        }
88
        }
88
89
89
        if (refObj == this) {
90
        if (refColumn == this) {
90
            return 0;
91
            return 0;
91
        }
92
        }
92
93
93
        String myName = getDisplayName();
94
        String myName = getDisplayName();
94
        myName = (myName == null) ? columnName : myName;
95
        myName = (myName == null) ? columnName : myName;
95
96
96
        String refName = null;
97
        if (!(refColumn instanceof DBColumn)) {
97
        if (!(refObj instanceof DBColumn)) {
98
            return -1;
98
            return -1;
99
        }
99
        }
100
100
101
        DBColumn refColumn = (DBColumn) refObj;
101
        String refName = refColumn.getName();
102
        refName = refColumn.getName();
103
102
104
        // compare primary keys
103
        // compare primary keys
105
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
104
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactory.java (-2 / +2 lines)
Lines 114-120 Link Here
114
    }
114
    }
115
115
116
    private static int getDBTypeFromURL(String url) {
116
    private static int getDBTypeFromURL(String url) {
117
        int dbtype = -1;
117
        int dbtype;
118
118
119
        // get the database type based on the product name converted to lowercase
119
        // get the database type based on the product name converted to lowercase
120
        url = url.toLowerCase();
120
        url = url.toLowerCase();
Lines 237-243 Link Here
237
                        nfe);
237
                        nfe);
238
            }
238
            }
239
239
240
            boolean isNullable = (rsMeta.isNullable(i) == rsMeta.columnNullable);
240
            boolean isNullable = (rsMeta.isNullable(i) == ResultSetMetaData.columnNullable);
241
            String displayName = rsMeta.getColumnLabel(i);
241
            String displayName = rsMeta.getColumnLabel(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewDBTable.java (-1 / +2 lines)
Lines 114-120 Link Here
114
        return columns.size();
114
        return columns.size();
115
    }
115
    }
116
116
117
    public synchronized Map getColumns() {
117
    public synchronized Map<String,DBColumn> getColumns() {
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
119
        for (DBTable tbl : dbTables) {
119
        for (DBTable tbl : dbTables) {
120
            colMap.putAll(tbl.getColumns());
120
            colMap.putAll(tbl.getColumns());
Lines 138-143 Link Here
138
        private ColumnOrderComparator() {
138
        private ColumnOrderComparator() {
139
        }
139
        }
140
140
141
        @Override
141
        public int compare(DBColumn col1, DBColumn col2) {
142
        public int compare(DBColumn col1, DBColumn col2) {
142
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
        }
144
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java (-12 / +7 lines)
Lines 207-213 Link Here
207
            }
207
            }
208
        }
208
        }
209
        Loader l = new Loader();
209
        Loader l = new Loader();
210
        Future f = rp.submit(l);
210
        Future<?> f = rp.submit(l);
211
        try {
211
        try {
212
            f.get();
212
            f.get();
213
        } catch (InterruptedException ex) {
213
        } catch (InterruptedException ex) {
Lines 409-419 Link Here
409
                pstmt = conn.prepareStatement(updateStmt);
409
                pstmt = conn.prepareStatement(updateStmt);
410
                int pos = 1;
410
                int pos = 1;
411
                for (Object val : values) {
411
                for (Object val : values) {
412
                    // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
413
                    if (DataViewUtils.isSQLConstantString(val)) {
414
                        continue;
415
                    }
416
417
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
412
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
418
                    pos++;
413
                    pos++;
419
                }
414
                }
Lines 654-660 Link Here
654
                }
649
                }
655
            }
650
            }
656
        } catch (SQLException ex) {
651
        } catch (SQLException ex) {
657
            LOGGER.log(Level.SEVERE, "Could not get total row count " + ex); // NOI18N
652
            LOGGER.log(Level.SEVERE, "Could not get total row count ", ex); // NOI18N
658
        }
653
        }
659
    }
654
    }
660
655
Lines 682-688 Link Here
682
                stmt.setFetchSize(pageSize);
677
                stmt.setFetchSize(pageSize);
683
            } catch (SQLException e) {
678
            } catch (SQLException e) {
684
                // ignore -  used only as a hint to the driver to optimize
679
                // ignore -  used only as a hint to the driver to optimize
685
                LOGGER.log(Level.WARNING, "Unable to set Fetch size" + e); // NOI18N
680
                LOGGER.log(Level.WARNING, "Unable to set Fetch size", e); // NOI18N
686
            }
681
            }
687
682
688
            try {
683
            try {
Lines 692-698 Link Here
692
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
687
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
693
                }
688
                }
694
            } catch (SQLException exc) {
689
            } catch (SQLException exc) {
695
                LOGGER.log(Level.WARNING, "Unable to set Max row size" + exc); // NOI18N
690
                LOGGER.log(Level.WARNING, "Unable to set Max row size", exc); // NOI18N
696
            }
691
            }
697
        } else {
692
        } else {
698
            stmt = conn.createStatement();
693
            stmt = conn.createStatement();
Lines 701-707 Link Here
701
    }
696
    }
702
697
703
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
698
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
704
        LOGGER.log(Level.FINE, "Statement: " + sql); // NOI18N
699
        LOGGER.log(Level.FINE, "Statement: {0}", sql); // NOI18N
705
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
700
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
706
701
707
        long startTime = System.currentTimeMillis();
702
        long startTime = System.currentTimeMillis();
Lines 712-724 Link Here
712
            try {
707
            try {
713
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
708
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
714
            } catch (NullPointerException ex) {
709
            } catch (NullPointerException ex) {
715
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + ex);
710
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, ex});
716
                throw new SQLException(ex);
711
                throw new SQLException(ex);
717
            } catch (SQLException sqlExc) {
712
            } catch (SQLException sqlExc) {
718
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
713
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
719
                    isResultSet = stmt.execute(sql);
714
                    isResultSet = stmt.execute(sql);
720
                } else {
715
                } else {
721
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + sqlExc);
716
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, sqlExc});
722
                    throw sqlExc;
717
                    throw sqlExc;
723
                }
718
                }
724
            }
719
            }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutor.java (-2 / +4 lines)
Lines 45-54 Link Here
45
45
46
import java.sql.Connection;
46
import java.sql.Connection;
47
import java.sql.SQLException;
47
import java.sql.SQLException;
48
import org.netbeans.modules.db.dataview.meta.DBException;
49
import org.netbeans.api.progress.ProgressHandle;
48
import org.netbeans.api.progress.ProgressHandle;
50
import org.netbeans.api.progress.ProgressHandleFactory;
49
import org.netbeans.api.progress.ProgressHandleFactory;
51
import org.netbeans.modules.db.dataview.meta.DBConnectionFactory;
50
import org.netbeans.modules.db.dataview.meta.DBConnectionFactory;
51
import org.netbeans.modules.db.dataview.meta.DBException;
52
import org.openide.DialogDisplayer;
52
import org.openide.DialogDisplayer;
53
import org.openide.NotifyDescriptor;
53
import org.openide.NotifyDescriptor;
54
import org.openide.util.Cancellable;
54
import org.openide.util.Cancellable;
Lines 81-86 Link Here
81
        this.task = task;
81
        this.task = task;
82
    }
82
    }
83
83
84
    @Override
84
    public void run() {
85
    public void run() {
85
        assert task != null;
86
        assert task != null;
86
        try {
87
        try {
Lines 95-102 Link Here
95
                dataView.disableButtons();
96
                dataView.disableButtons();
96
97
97
                conn = DBConnectionFactory.getInstance().getConnection(dataView.getDatabaseConnection());
98
                conn = DBConnectionFactory.getInstance().getConnection(dataView.getDatabaseConnection());
98
                String msg = "";
99
                if (conn == null) {
99
                if (conn == null) {
100
                    String msg;
100
                    Throwable connEx = DBConnectionFactory.getInstance().getLastException();
101
                    Throwable connEx = DBConnectionFactory.getInstance().getLastException();
101
                    if (connEx != null) {
102
                    if (connEx != null) {
102
                        msg = connEx.getMessage();
103
                        msg = connEx.getMessage();
Lines 124-129 Link Here
124
        }
125
        }
125
    }
126
    }
126
127
128
    @Override
127
    public boolean cancel() {
129
    public boolean cancel() {
128
        return task.cancel();
130
        return task.cancel();
129
    }
131
    }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLStatementGenerator.java (-11 / +19 lines)
Lines 77-84 Link Here
77
        StringBuilder insertSql = new StringBuilder();
77
        StringBuilder insertSql = new StringBuilder();
78
        insertSql.append("INSERT INTO "); // NOI18N
78
        insertSql.append("INSERT INTO "); // NOI18N
79
79
80
        String colNames = " ("; // NOI18N
80
        StringBuilder colNames = new StringBuilder(" ("); // NOI18N
81
        String values = "";     // NOI18N
81
        StringBuilder values = new StringBuilder();
82
        String commaStr = ", "; // NOI18N
82
        String commaStr = ", "; // NOI18N
83
        boolean comma = false;
83
        boolean comma = false;
84
        for (int i = 0; i < insertedRow.length; i++) {
84
        for (int i = 0; i < insertedRow.length; i++) {
Lines 94-101 Link Here
94
            }
94
            }
95
95
96
            if (comma) {
96
            if (comma) {
97
                values += commaStr;
97
                values.append(commaStr);
98
                colNames += commaStr;
98
                colNames.append(commaStr);
99
            } else {
99
            } else {
100
                comma = true;
100
                comma = true;
101
            }
101
            }
Lines 103-117 Link Here
103
            // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
103
            // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
104
            if (val != null && DataViewUtils.isSQLConstantString(val, dbcol)) {
104
            if (val != null && DataViewUtils.isSQLConstantString(val, dbcol)) {
105
                String constStr = ((String) val).substring(1, ((String) val).length() - 1);
105
                String constStr = ((String) val).substring(1, ((String) val).length() - 1);
106
                values += constStr;
106
                values.append(constStr);
107
            } else { // ELSE literals
107
            } else { // ELSE literals
108
                values += insertedRow[i] == null ? " NULL " : "?"; // NOI18N
108
                values.append(insertedRow[i] == null ? " NULL " : "?"); // NOI18N
109
            }
109
            }
110
            colNames += dbcol.getQualifiedName(true);
110
            colNames.append(dbcol.getQualifiedName(true));
111
        }
111
        }
112
112
113
        colNames += ")"; // NOI18N
113
        colNames.append(")"); // NOI18N
114
        insertSql.append(tblMeta.getFullyQualifiedName(0, true) + colNames + " Values(" + values + ")"); // NOI18N
114
        insertSql.append(tblMeta.getFullyQualifiedName(0, true));
115
        insertSql.append(colNames.toString());
116
        insertSql.append(" Values("); // NOI18N
117
        insertSql.append(values.toString());
118
        insertSql.append(")"); // NOI18N
115
119
116
        return insertSql.toString();
120
        return insertSql.toString();
117
    }
121
    }
Lines 154-160 Link Here
154
        }
158
        }
155
159
156
        rawcolNames += ")"; // NOI18N
160
        rawcolNames += ")"; // NOI18N
157
        rawInsertSql.append(tblMeta.getFullyQualifiedName(0, false) + rawcolNames + " \n\tVALUES (" + rawvalues + ")"); // NOI18N
161
        rawInsertSql.append(tblMeta.getFullyQualifiedName(0, false));
162
        rawInsertSql.append(rawcolNames);
163
        rawInsertSql.append(" \n\tVALUES (");  // NOI18N
164
        rawInsertSql.append(rawvalues);
165
        rawInsertSql.append(")"); // NOI18N
158
166
159
        return rawInsertSql.toString();
167
        return rawInsertSql.toString();
160
    }
168
    }
Lines 269-275 Link Here
269
277
270
        boolean isdb2 = table.getParentObject().getDBType() == DBMetaDataFactory.DB2 ? true : false;
278
        boolean isdb2 = table.getParentObject().getDBType() == DBMetaDataFactory.DB2 ? true : false;
271
279
272
        StringBuffer sql = new StringBuffer();
280
        StringBuilder sql = new StringBuilder();
273
        List<DBColumn> columns = table.getColumnList();
281
        List<DBColumn> columns = table.getColumnList();
274
        sql.append("CREATE TABLE ").append(table.getQualifiedName(false)).append(" ("); // NOI18N
282
        sql.append("CREATE TABLE ").append(table.getQualifiedName(false)).append(" ("); // NOI18N
275
        int count = 0;
283
        int count = 0;
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java (-2 / +2 lines)
Lines 101-107 Link Here
101
        });
101
        });
102
    }
102
    }
103
103
104
    public ResultSetCellRenderer(ComponentProvider componentProvider) {
104
    public ResultSetCellRenderer(ComponentProvider<? extends JComponent> componentProvider) {
105
        super(componentProvider);
105
        super(componentProvider);
106
    }
106
    }
107
107
Lines 119-125 Link Here
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
120
        } else if (value instanceof Number) {
120
        } else if (value instanceof Number) {
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
122
        } else if (DataViewUtils.isSQLConstantString(value)) {
122
        } else if (DataViewUtils.isSQLConstantString(value, null)) {
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
124
            setTableCellToolTip(c, value);
124
            setTableCellToolTip(c, value);
125
            return c;            
125
            return c;            
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java (-4 / +3 lines)
Lines 39-45 Link Here
39
 * 
39
 * 
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table;
43
43
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.awt.event.MouseEvent;
45
import java.awt.event.MouseEvent;
Lines 51-57 Link Here
51
import javax.swing.UIManager;
51
import javax.swing.UIManager;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
54
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
55
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
54
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
56
import org.netbeans.modules.db.dataview.util.DataViewUtils;
55
import org.netbeans.modules.db.dataview.util.DataViewUtils;
57
import org.openide.awt.StatusDisplayer;
56
import org.openide.awt.StatusDisplayer;
Lines 61-67 Link Here
61
    protected Object val;
60
    protected Object val;
62
    protected boolean editable = true;
61
    protected boolean editable = true;
63
    protected JTable table;
62
    protected JTable table;
64
    static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
63
    protected static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
65
64
66
    public ResultSetTableCellEditor(final JTextField textField) {
65
    public ResultSetTableCellEditor(final JTextField textField) {
67
        super(textField);
66
        super(textField);
Lines 105-111 Link Here
105
104
106
    @Override
105
    @Override
107
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
106
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
108
        if (DataViewUtils.isSQLConstantString(value)) {
107
        if (DataViewUtils.isSQLConstantString(value, null)) {
109
            value = "";
108
            value = "";
110
        }
109
        }
111
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
110
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableModel.java (-2 / +4 lines)
Lines 64-70 Link Here
64
    private Class[] collumnClasses;
64
    private Class[] collumnClasses;
65
    protected ResultSetJXTable table;
65
    protected ResultSetJXTable table;
66
66
67
    public static Class getTypeClass(DBColumn col) {
67
    public static Class<? extends Object> getTypeClass(DBColumn col) {
68
        int colType = col.getJdbcType();
68
        int colType = col.getJdbcType();
69
69
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
Lines 116-121 Link Here
116
        }
116
        }
117
    }
117
    }
118
118
119
    @SuppressWarnings("rawtypes")
119
    public ResultSetTableModel(ResultSetJXTable table) {
120
    public ResultSetTableModel(ResultSetJXTable table) {
120
        super();
121
        super();
121
        this.table = table;
122
        this.table = table;
Lines 155-161 Link Here
155
    }
156
    }
156
157
157
    @Override
158
    @Override
158
    public Class getColumnClass(int columnIndex) {
159
    @SuppressWarnings("unchecked")
160
    public Class<? extends Object> getColumnClass(int columnIndex) {
159
        if (collumnClasses[columnIndex] == null) {
161
        if (collumnClasses[columnIndex] == null) {
160
            return super.getColumnClass(columnIndex);
162
            return super.getColumnClass(columnIndex);
161
        } else {
163
        } else {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java (+1 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table.celleditor;
43
43
44
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
44
import java.awt.Component;
45
import java.awt.Component;
45
import javax.swing.BorderFactory;
46
import javax.swing.BorderFactory;
46
import javax.swing.JComponent;
47
import javax.swing.JComponent;
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (-1 / +2 lines)
Lines 79-85 Link Here
79
                }
79
                }
80
            });
80
            });
81
            charsetSelect = new JComboBox();
81
            charsetSelect = new JComboBox();
82
            charsetSelect.setModel(new DefaultComboBoxModel(charset.toArray()));
82
            charsetSelect.setModel(new DefaultComboBoxModel(
83
                    charset.toArray(new Charset[charset.size()])));
83
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            this.add(charsetSelect);
85
            this.add(charsetSelect);
85
        }
86
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java (-1 / +1 lines)
Lines 137-143 Link Here
137
    }
137
    }
138
138
139
    protected Timestamp getValueAsTimestamp(Object value) {
139
    protected Timestamp getValueAsTimestamp(Object value) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value)) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value, null)) {
141
            return new Timestamp(System.currentTimeMillis());
141
            return new Timestamp(System.currentTimeMillis());
142
        }
142
        }
143
143
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/NumberFieldEditor.java (-1 / +2 lines)
Lines 46-51 Link Here
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import javax.swing.JTable;
47
import javax.swing.JTable;
48
import javax.swing.JTextField;
48
import javax.swing.JTextField;
49
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
49
50
50
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
52
Lines 64-67 Link Here
64
        setEditable(column, c, table.isCellEditable(row, column));
65
        setEditable(column, c, table.isCellEditable(row, column));
65
        return c;
66
        return c;
66
    }
67
    }
67
}
68
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java (-1 / +2 lines)
Lines 63-68 Link Here
63
import javax.swing.table.TableCellEditor;
63
import javax.swing.table.TableCellEditor;
64
import org.jdesktop.swingx.JXButton;
64
import org.jdesktop.swingx.JXButton;
65
import org.jdesktop.swingx.JXPanel;
65
import org.jdesktop.swingx.JXPanel;
66
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
66
import org.openide.windows.WindowManager;
67
import org.openide.windows.WindowManager;
67
68
68
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
69
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
Lines 151-154 Link Here
151
            JOptionPane.showMessageDialog(parent, pane, table.getColumnName(column), JOptionPane.PLAIN_MESSAGE, null);
152
            JOptionPane.showMessageDialog(parent, pane, table.getColumnName(column), JOptionPane.PLAIN_MESSAGE, null);
152
        }
153
        }
153
    }
154
    }
154
}
155
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java (-25 / +52 lines)
Lines 166-176 Link Here
166
        
166
        
167
        popupButton = createPopupButton();
167
        popupButton = createPopupButton();
168
        if (popupButton != null) {
168
        if (popupButton != null) {
169
            // this is a trick to get hold of the client prop which
169
            popupButton.putClientProperty("doNotCancelPopup", 
170
            // prevents closing of the popup
170
                    createDoNotCancelPopupClientProperty());
171
            JComboBox box = new JComboBox();
172
            Object preventHide = box.getClientProperty("doNotCancelPopup");
173
            popupButton.putClientProperty("doNotCancelPopup", preventHide);
174
            datePicker.add(popupButton);
171
            datePicker.add(popupButton);
175
        }
172
        }
176
            updateChildLocale(datePicker.getLocale());
173
            updateChildLocale(datePicker.getLocale());
Lines 252-259 Link Here
252
     * PRE: keybindings installed on picker.
249
     * PRE: keybindings installed on picker.
253
     */
250
     */
254
    protected void installLinkPanelKeyboardActions() {
251
    protected void installLinkPanelKeyboardActions() {
255
        if (datePicker.getLinkPanel() == null)
252
        if (datePicker.getLinkPanel() == null)  {
256
            return;
253
            return;
254
        }
257
        ActionMap map = datePicker.getLinkPanel().getActionMap();
255
        ActionMap map = datePicker.getLinkPanel().getActionMap();
258
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
256
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
259
                JXDateTimePicker.HOME_COMMIT_KEY));
257
                JXDateTimePicker.HOME_COMMIT_KEY));
Lines 277-283 Link Here
277
     * 
275
     * 
278
     */
276
     */
279
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
277
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
280
        if (panel == null) return;
278
        if (panel == null) {
279
            return;
280
        }
281
        ActionMap map = panel.getActionMap();
281
        ActionMap map = panel.getActionMap();
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
Lines 705-711 Link Here
705
     *    is intermediate
705
     *    is intermediate
706
     */
706
     */
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
708
        if (adjusting) return;
708
        if (adjusting) {
709
            return;
710
        }
709
        updateEditorValue();
711
        updateEditorValue();
710
    }
712
    }
711
713
Lines 755-765 Link Here
755
            oldEditor.putClientProperty("doNotCancelPopup", null);
757
            oldEditor.putClientProperty("doNotCancelPopup", null);
756
        }
758
        }
757
        datePicker.add(datePicker.getEditor());
759
        datePicker.add(datePicker.getEditor());
758
        // this is a trick to get hold of the client prop which
760
        datePicker.getEditor().putClientProperty("doNotCancelPopup", 
759
        // prevents closing of the popup
761
                createDoNotCancelPopupClientProperty());
760
        JComboBox box = new JComboBox();
761
        Object preventHide = box.getClientProperty("doNotCancelPopup");
762
        datePicker.getEditor().putClientProperty("doNotCancelPopup", preventHide);
763
762
764
        updateEditorValue();
763
        updateEditorValue();
765
        if (updateListeners) {
764
        if (updateListeners) {
Lines 942-948 Link Here
942
     * control popup visibility?
941
     * control popup visibility?
943
     */
942
     */
944
    public void hidePopup() {
943
    public void hidePopup() {
945
        if (popup != null) popup.setVisible(false);
944
        if (popup != null) {
945
            popup.setVisible(false);
946
        }
946
    }
947
    }
947
948
948
    public boolean isPopupVisible() {
949
    public boolean isPopupVisible() {
Lines 980-986 Link Here
980
     */
981
     */
981
    private Action createCommitAction() {
982
    private Action createCommitAction() {
982
        Action action = new AbstractAction() {
983
        Action action = new AbstractAction() {
983
984
            @Override
984
            public void actionPerformed(ActionEvent e) {
985
            public void actionPerformed(ActionEvent e) {
985
                commit();
986
                commit();
986
            }
987
            }
Lines 997-1003 Link Here
997
     */
998
     */
998
    private Action createCancelAction() {
999
    private Action createCancelAction() {
999
        Action action = new AbstractAction() {
1000
        Action action = new AbstractAction() {
1000
1001
            @Override
1001
            public void actionPerformed(ActionEvent e) {
1002
            public void actionPerformed(ActionEvent e) {
1002
                cancel();
1003
                cancel();
1003
            }
1004
            }
Lines 1008-1014 Link Here
1008
1009
1009
    private Action createHomeAction(final boolean commit) {
1010
    private Action createHomeAction(final boolean commit) {
1010
        Action action = new AbstractAction( ) {
1011
        Action action = new AbstractAction( ) {
1011
1012
            @Override
1012
            public void actionPerformed(ActionEvent e) {
1013
            public void actionPerformed(ActionEvent e) {
1013
                home(commit);
1014
                home(commit);
1014
                
1015
                
Lines 1054-1059 Link Here
1054
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
        }
1056
        }
1056
        
1057
        
1058
        @Override
1057
        public void actionPerformed(ActionEvent e) {
1059
        public void actionPerformed(ActionEvent e) {
1058
            cancelAction.actionPerformed(null);
1060
            cancelAction.actionPerformed(null);
1059
            cancel();
1061
            cancel();
Lines 1088-1093 Link Here
1088
            datePicker.getEditor().requestFocusInWindow();
1090
            datePicker.getEditor().requestFocusInWindow();
1089
//            datePicker.requestFocusInWindow();
1091
//            datePicker.requestFocusInWindow();
1090
            SwingUtilities.invokeLater(new Runnable() {
1092
            SwingUtilities.invokeLater(new Runnable() {
1093
                @Override
1091
                public void run() {
1094
                public void run() {
1092
                    popup.show(datePicker,
1095
                    popup.show(datePicker,
1093
                            0, datePicker.getHeight());
1096
                            0, datePicker.getHeight());
Lines 1114-1119 Link Here
1114
            super("TogglePopup");
1117
            super("TogglePopup");
1115
        }
1118
        }
1116
1119
1120
        @Override
1117
        public void actionPerformed(ActionEvent ev) {
1121
        public void actionPerformed(ActionEvent ev) {
1118
            toggleShowPopup();
1122
            toggleShowPopup();
1119
        }
1123
        }
Lines 1165-1173 Link Here
1165
//------------- implement Mouse/MotionListener        
1169
//------------- implement Mouse/MotionListener        
1166
        private boolean _forwardReleaseEvent = false;
1170
        private boolean _forwardReleaseEvent = false;
1167
1171
1172
        @Override
1168
        public void mouseClicked(MouseEvent ev) {
1173
        public void mouseClicked(MouseEvent ev) {
1169
        }
1174
        }
1170
1175
1176
        @Override
1171
        public void mousePressed(MouseEvent ev) {
1177
        public void mousePressed(MouseEvent ev) {
1172
            if (!datePicker.isEnabled()) {
1178
            if (!datePicker.isEnabled()) {
1173
                return;
1179
                return;
Lines 1181-1186 Link Here
1181
            toggleShowPopup();
1187
            toggleShowPopup();
1182
        }
1188
        }
1183
1189
1190
        @Override
1184
        public void mouseReleased(MouseEvent ev) {
1191
        public void mouseReleased(MouseEvent ev) {
1185
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1192
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1186
                return;
1193
                return;
Lines 1196-1207 Link Here
1196
            }
1203
            }
1197
        }
1204
        }
1198
1205
1206
        @Override
1199
        public void mouseEntered(MouseEvent ev) {
1207
        public void mouseEntered(MouseEvent ev) {
1200
        }
1208
        }
1201
1209
1210
        @Override
1202
        public void mouseExited(MouseEvent ev) {
1211
        public void mouseExited(MouseEvent ev) {
1203
        }
1212
        }
1204
1213
1214
        @Override
1205
        public void mouseDragged(MouseEvent ev) {
1215
        public void mouseDragged(MouseEvent ev) {
1206
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1216
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1207
                return;
1217
                return;
Lines 1219-1228 Link Here
1219
            monthView.dispatchEvent(ev);
1229
            monthView.dispatchEvent(ev);
1220
        }
1230
        }
1221
1231
1232
        @Override
1222
        public void mouseMoved(MouseEvent ev) {
1233
        public void mouseMoved(MouseEvent ev) {
1223
        }
1234
        }
1224
//------------------ implement DateSelectionListener
1235
//------------------ implement DateSelectionListener
1225
        
1236
        @Override
1226
        public void valueChanged(DateSelectionEvent ev) {
1237
        public void valueChanged(DateSelectionEvent ev) {
1227
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1238
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1228
        }
1239
        }
Lines 1231-1236 Link Here
1231
        /**
1242
        /**
1232
         * {@inheritDoc}
1243
         * {@inheritDoc}
1233
         */
1244
         */
1245
        @Override
1234
        public void propertyChange(PropertyChangeEvent e) {
1246
        public void propertyChange(PropertyChangeEvent e) {
1235
            if (e.getSource() == datePicker) {
1247
            if (e.getSource() == datePicker) {
1236
                datePickerPropertyChange(e);
1248
                datePickerPropertyChange(e);
Lines 1259-1266 Link Here
1259
         */
1271
         */
1260
        private void editorPropertyChange(PropertyChangeEvent evt) {
1272
        private void editorPropertyChange(PropertyChangeEvent evt) {
1261
            if ("value".equals(evt.getPropertyName())) {
1273
            if ("value".equals(evt.getPropertyName())) {
1262
                ;
1274
1263
                
1264
                Object oldVal = evt.getOldValue();
1275
                Object oldVal = evt.getOldValue();
1265
                Object newVal = evt.getNewValue();
1276
                Object newVal = evt.getNewValue();
1266
                
1277
                
Lines 1353-1371 Link Here
1353
        }
1364
        }
1354
1365
1355
//-------------- implement LayoutManager
1366
//-------------- implement LayoutManager
1356
        
1367
        @Override
1357
        public void addLayoutComponent(String name, Component comp) { }
1368
        public void addLayoutComponent(String name, Component comp) { }
1358
1369
1370
        @Override
1359
        public void removeLayoutComponent(Component comp) { }
1371
        public void removeLayoutComponent(Component comp) { }
1360
1372
1373
        @Override
1361
        public Dimension preferredLayoutSize(Container parent) {
1374
        public Dimension preferredLayoutSize(Container parent) {
1362
            return parent.getPreferredSize();
1375
            return parent.getPreferredSize();
1363
        }
1376
        }
1364
1377
1378
        @Override
1365
        public Dimension minimumLayoutSize(Container parent) {
1379
        public Dimension minimumLayoutSize(Container parent) {
1366
            return parent.getMinimumSize();
1380
            return parent.getMinimumSize();
1367
        }
1381
        }
1368
1382
1383
        @Override
1369
        public void layoutContainer(Container parent) {
1384
        public void layoutContainer(Container parent) {
1370
            Insets insets = datePicker.getInsets();
1385
            Insets insets = datePicker.getInsets();
1371
            int width = datePicker.getWidth() - insets.left - insets.right;
1386
            int width = datePicker.getWidth() - insets.left - insets.right;
Lines 1389-1397 Link Here
1389
        }
1404
        }
1390
1405
1391
// ------------- implement actionListener (listening to monthView actionEvent)
1406
// ------------- implement actionListener (listening to monthView actionEvent)
1392
        
1407
        @Override
1393
        public void actionPerformed(ActionEvent e) {
1408
        public void actionPerformed(ActionEvent e) {
1394
            if (e == null) return;
1409
            if (e == null) {
1410
                return;
1411
            }
1395
            if (e.getSource() == datePicker.getMonthView()) {
1412
            if (e.getSource() == datePicker.getMonthView()) {
1396
                monthViewActionPerformed(e);
1413
                monthViewActionPerformed(e);
1397
            } else if (e.getSource() == datePicker.getEditor()) {
1414
            } else if (e.getSource() == datePicker.getEditor()) {
Lines 1430-1437 Link Here
1430
         * Do the same as combo: manually pass-on the focus to the editor.
1447
         * Do the same as combo: manually pass-on the focus to the editor.
1431
         * 
1448
         * 
1432
         */
1449
         */
1450
        @Override
1433
        public void focusGained(FocusEvent e) {
1451
        public void focusGained(FocusEvent e) {
1434
            if (e.isTemporary()) return;
1452
            if (e.isTemporary()) {
1453
                return;
1454
            }
1435
            popupRemover.load();
1455
            popupRemover.load();
1436
            if (e.getSource() == datePicker) {
1456
            if (e.getSource() == datePicker) {
1437
               datePicker.getEditor().requestFocusInWindow(); 
1457
               datePicker.getEditor().requestFocusInWindow(); 
Lines 1460-1465 Link Here
1460
         * 
1480
         * 
1461
         * listen to keyboardFocusManager?
1481
         * listen to keyboardFocusManager?
1462
         */
1482
         */
1483
        @Override
1463
        public void focusLost(FocusEvent e) {
1484
        public void focusLost(FocusEvent e) {
1464
            
1485
            
1465
        }
1486
        }
Lines 1498-1503 Link Here
1498
            unload(true);
1519
            unload(true);
1499
        }
1520
        }
1500
        
1521
        
1522
        @Override
1501
        public void propertyChange(PropertyChangeEvent evt) {
1523
        public void propertyChange(PropertyChangeEvent evt) {
1502
            if (!isPopupVisible()) {
1524
            if (!isPopupVisible()) {
1503
                unload(false);
1525
                unload(false);
Lines 1606-1610 Link Here
1606
    
1628
    
1607
//------------ utility methods
1629
//------------ utility methods
1608
1630
1609
1631
    private Object createDoNotCancelPopupClientProperty() {
1632
        // this is a trick to get hold of the client prop which
1633
        // prevents closing of the popup
1634
        JComboBox box = new JComboBox();
1635
        return box.getClientProperty("doNotCancelPopup");
1610
}
1636
}
1637
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/DataViewUtils.java (-15 / +7 lines)
Lines 43-58 Link Here
43
 */
43
 */
44
package org.netbeans.modules.db.dataview.util;
44
package org.netbeans.modules.db.dataview.util;
45
45
46
import java.sql.Date;
47
import java.sql.PreparedStatement;
46
import java.sql.PreparedStatement;
48
import java.sql.ResultSet;
47
import java.sql.ResultSet;
49
import java.sql.SQLException;
48
import java.sql.SQLException;
50
import java.sql.Statement;
49
import java.sql.Statement;
51
import java.sql.Time;
52
import java.sql.Timestamp;
53
import java.sql.Types;
50
import java.sql.Types;
54
import java.util.Iterator;
55
import java.util.List;
56
import org.netbeans.modules.db.dataview.meta.DBColumn;
51
import org.netbeans.modules.db.dataview.meta.DBColumn;
57
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
52
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
58
import org.netbeans.modules.db.dataview.meta.DBTable;
53
import org.netbeans.modules.db.dataview.meta.DBTable;
Lines 277-294 Link Here
277
        String refString = column.getName() + " --> "; // NOI18N
272
        String refString = column.getName() + " --> "; // NOI18N
278
        StringBuilder str = new StringBuilder(refString);
273
        StringBuilder str = new StringBuilder(refString);
279
        DBTable table = column.getParentObject();
274
        DBTable table = column.getParentObject();
280
        List list = table.getForeignKeys();
275
        boolean firstReferencedColumn = false;
281
276
282
        Iterator it = list.iterator();
277
        for(DBForeignKey fk: table.getForeignKeys()) {
283
        while (it.hasNext()) {
284
            DBForeignKey fk = (DBForeignKey) it.next();
285
            if (fk.contains(column)) {
278
            if (fk.contains(column)) {
286
                List pkColumnList = fk.getPKColumnNames();
279
                for(String pkColName: fk.getPKColumnNames()) {
287
                Iterator it1 = pkColumnList.iterator();
288
                while (it1.hasNext()) {
289
                    String pkColName = (String) it1.next();
290
                    str.append(pkColName);
280
                    str.append(pkColName);
291
                    if (it1.hasNext()) {
281
                    if (firstReferencedColumn) {
282
                        firstReferencedColumn = false;
283
                    } else {
292
                        str.append(", "); // NOI18N
284
                        str.append(", "); // NOI18N
293
                    }
285
                    }
294
                }
286
                }
Lines 305-311 Link Here
305
    }
297
    }
306
298
307
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
299
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
308
        StringBuffer resultBuffer = new StringBuffer();
300
        StringBuilder resultBuffer = new StringBuilder();
309
        boolean bReplaced = false;
301
        boolean bReplaced = false;
310
302
311
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
303
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java (-7 / +10 lines)
Lines 46-63 Link Here
46
import java.util.Locale;
46
import java.util.Locale;
47
import java.util.TimeZone;
47
import java.util.TimeZone;
48
import java.util.logging.Logger;
48
import java.util.logging.Logger;
49
50
import javax.swing.AbstractAction;
49
import javax.swing.AbstractAction;
51
import javax.swing.Action;
50
import javax.swing.Action;
52
import javax.swing.JComponent;
51
import javax.swing.JComponent;
53
import javax.swing.JFormattedTextField;
52
import javax.swing.JFormattedTextField;
53
import javax.swing.JFormattedTextField.AbstractFormatter;
54
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
54
import javax.swing.JPanel;
55
import javax.swing.JPanel;
55
import javax.swing.JPopupMenu;
56
import javax.swing.JPopupMenu;
56
import javax.swing.UIManager;
57
import javax.swing.UIManager;
57
import javax.swing.JFormattedTextField.AbstractFormatter;
58
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
59
import javax.swing.text.DefaultFormatterFactory;
58
import javax.swing.text.DefaultFormatterFactory;
60
61
import org.jdesktop.swingx.JXHyperlink;
59
import org.jdesktop.swingx.JXHyperlink;
62
import org.jdesktop.swingx.JXMonthView;
60
import org.jdesktop.swingx.JXMonthView;
63
import org.jdesktop.swingx.JXPanel;
61
import org.jdesktop.swingx.JXPanel;
Lines 318-324 Link Here
318
    }
316
    }
319
317
320
    protected class SelectedValuesComparator implements Comparator<Calendar> {
318
    protected class SelectedValuesComparator implements Comparator<Calendar> {
321
319
        @Override
322
        public int compare(Calendar cal1, Calendar cal2) {
320
        public int compare(Calendar cal1, Calendar cal2) {
323
321
324
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
322
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
Lines 372-378 Link Here
372
    private PropertyChangeListener getMonthViewListener() {
370
    private PropertyChangeListener getMonthViewListener() {
373
        if (monthViewListener == null) {
371
        if (monthViewListener == null) {
374
            monthViewListener = new PropertyChangeListener() {
372
            monthViewListener = new PropertyChangeListener() {
375
373
                @Override
376
                public void propertyChange(PropertyChangeEvent evt) {
374
                public void propertyChange(PropertyChangeEvent evt) {
377
                    if ("timeZone".equals(evt.getPropertyName())) {
375
                    if ("timeZone".equals(evt.getPropertyName())) {
378
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
376
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
Lines 849-854 Link Here
849
     * @param height Height of the component to determine baseline for.
847
     * @param height Height of the component to determine baseline for.
850
     * @return baseline for the specified component
848
     * @return baseline for the specified component
851
     */
849
     */
850
    @Override
852
    public int getBaseline(int width, int height) {
851
    public int getBaseline(int width, int height) {
853
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
852
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
854
    }
853
    }
Lines 916-921 Link Here
916
        private TodayAction todayAction;
915
        private TodayAction todayAction;
917
        private JXHyperlink todayLink;
916
        private JXHyperlink todayLink;
918
917
918
        @SuppressWarnings("rawtypes")
919
        TodayPanel() {
919
        TodayPanel() {
920
            super(new FlowLayout());
920
            super(new FlowLayout());
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
Lines 936-942 Link Here
936
936
937
                @Override
937
                @Override
938
                public void mousePressed(MouseEvent e) {
938
                public void mousePressed(MouseEvent e) {
939
                    if (e.getClickCount() != 2) return;
939
                    if (e.getClickCount() != 2) {
940
                        return;
941
                    }
940
                    todayAction.select = true;
942
                    todayAction.select = true;
941
                }
943
                }
942
                
944
                
Lines 973-978 Link Here
973
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
975
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
974
            }
976
            }
975
977
978
            @Override
976
            public void actionPerformed(ActionEvent ae) {
979
            public void actionPerformed(ActionEvent ae) {
977
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
980
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
978
                select = false;
981
                select = false;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java (-5 / +7 lines)
Lines 63-69 Link Here
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
65
65
66
/** Creates a new instance of DBConnectionProviderImpl */
66
    /** Creates a new instance of DBConnectionProviderImpl */
67
    public DBConnectionProviderImpl() {
67
    public DBConnectionProviderImpl() {
68
    }
68
    }
69
    
69
    
Lines 80-85 Link Here
80
        return null;
80
        return null;
81
    }
81
    }
82
82
83
    @Override
83
    public void closeConnection(Connection con) {
84
    public void closeConnection(Connection con) {
84
        try {
85
        try {
85
            if(con != null) {
86
            if(con != null) {
Lines 98-103 Link Here
98
        }
99
        }
99
    }
100
    }
100
101
102
    @Override
101
    public Connection getConnection(DatabaseConnection dbConn) {
103
    public Connection getConnection(DatabaseConnection dbConn) {
102
        try {
104
        try {
103
            String driver = dbConn.getDriverClass();
105
            String driver = dbConn.getDriverClass();
Lines 110-122 Link Here
110
112
111
            TestCaseContext context = DbUtil.getContext();
113
            TestCaseContext context = DbUtil.getContext();
112
            File[] jars = context.getJars();
114
            File[] jars = context.getJars();
113
            ArrayList list = new java.util.ArrayList();
115
            ArrayList<URL> list = new java.util.ArrayList<URL>();
114
            for (int i = 0; i < jars.length; i++) {
116
            for (int i = 0; i < jars.length; i++) {
115
                list.add((URL)jars[i].toURI().toURL());
117
                list.add(jars[i].toURI().toURL());
116
            }
118
            }
117
            URL[] driverURLs = (URL[]) list.toArray(new URL[0]);
119
            URL[] driverURLs = list.toArray(new URL[0]);
118
            URLClassLoader l = new URLClassLoader(driverURLs);
120
            URLClassLoader l = new URLClassLoader(driverURLs);
119
            Class c = Class.forName(driver, true, l);
121
            Class<?> c = Class.forName(driver, true, l);
120
            Driver drv = (Driver) c.newInstance();
122
            Driver drv = (Driver) c.newInstance();
121
            Connection con = drv.connect(url, prop);
123
            Connection con = drv.connect(url, prop);
122
            return con;
124
            return con;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java (-16 / +13 lines)
Lines 57-62 Link Here
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
59
import org.openide.util.Exceptions;
59
import org.openide.util.Exceptions;
60
import org.openide.util.Utilities;
60
61
61
/**
62
/**
62
 *
63
 *
Lines 68-85 Link Here
68
    public static String USER = "user";
69
    public static String USER = "user";
69
    public static String PASSWORD = "password";
70
    public static String PASSWORD = "password";
70
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    private static List localConnectionList = new ArrayList();
72
    private static List<Connection> localConnectionList = new ArrayList<Connection>();
72
73
73
    public static DatabaseConnection getDBConnection() {
74
    public static DatabaseConnection getDBConnection() {
74
        try {
75
        try {
75
            TestCaseContext context = getContext();
76
            TestCaseContext context = getContext();
76
            Properties prop = context.getProperties();
77
            Properties prop = context.getProperties();
77
            File[] jars = context.getJars();
78
            File[] jars = context.getJars();
78
            ArrayList list = new java.util.ArrayList();
79
            ArrayList<URL> list = new java.util.ArrayList<URL>();
79
            for (int i = 0; i < jars.length; i++) {
80
            for (int i = 0; i < jars.length; i++) {
80
                list.add((URL)jars[i].toURI().toURL());
81
                list.add(Utilities.toURI(jars[i]).toURL());
81
            }
82
            }
82
            URL[] urls = (URL[]) list.toArray(new URL[0]);
83
            URL[] urls = list.toArray(new URL[0]);
83
            Class.forName(AXION_DRIVER);
84
            Class.forName(AXION_DRIVER);
84
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
86
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
Lines 153-164 Link Here
153
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // It may pop up a window asking for password.
156
        // It may pop up a window asking for password.
156
        JDBCDriver drv = null;
157
        Connection conn = null;
157
        Connection conn = null;
158
        try {
158
        try {
159
           
159
            //url = adjustDatabaseURL(url);
160
                //url = adjustDatabaseURL(url);
160
            JDBCDriver drv  = registerDriver(driverName);
161
            drv = registerDriver(driverName);
162
161
163
            conn = getConnection(drv, driverName, url, username, password);
162
            conn = getConnection(drv, driverName, url, username, password);
164
            if (conn == null) { // get from db explorer
163
            if (conn == null) { // get from db explorer
Lines 208-219 Link Here
208
207
209
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
208
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
210
        DatabaseConnection dbconn = null;
209
        DatabaseConnection dbconn = null;
211
        JDBCDriver drv = null;
212
        String schema = null;
213
        try {
210
        try {
214
            
211
            //url = adjustDatabaseURL(url);
215
                //url = adjustDatabaseURL(url);
212
            JDBCDriver drv = registerDriver(driverName);
216
            drv = registerDriver(driverName);
217
213
218
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
214
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
219
215
Lines 227-232 Link Here
227
223
228
            // dont add instance db and monitor db and local dbs connections to db explorer.
224
            // dont add instance db and monitor db and local dbs connections to db explorer.
229
            if (dbconn == null) {
225
            if (dbconn == null) {
226
                String schema;
230
                if (url.startsWith(AXION_URL_PREFIX)) {
227
                if (url.startsWith(AXION_URL_PREFIX)) {
231
                    schema = "";
228
                    schema = "";
232
                } else {
229
                } else {
Lines 284-294 Link Here
284
            // if axion db driver not available in db explorer, add it.
281
            // if axion db driver not available in db explorer, add it.
285
            //URL[] url = new URL[1];
282
            //URL[] url = new URL[1];
286
            File[] jars = cxt.getJars();
283
            File[] jars = cxt.getJars();
287
            ArrayList list = new java.util.ArrayList();
284
            ArrayList<URL> list = new java.util.ArrayList<URL>();
288
            for (int i = 0; i < jars.length; i++) {
285
            for (int i = 0; i < jars.length; i++) {
289
                list.add((URL)jars[i].toURI().toURL());
286
                list.add(Utilities.toURI(jars[i]).toURL());
290
            }
287
            }
291
            URL[] url = (URL[]) list.toArray(new URL[0]);
288
            URL[] url = list.toArray(new URL[0]);
292
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
289
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
293
            JDBCDriverManager.getDefault().addDriver(driver);
290
            JDBCDriverManager.getDefault().addDriver(driver);
294
        }
291
        }
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java (-17 / +6 lines)
Lines 69-75 Link Here
69
    private File[] jars;
69
    private File[] jars;
70
    private String name;
70
    private String name;
71
    
71
    
72
    public TestCaseContext(HashMap map,String name)  throws Exception{
72
    public TestCaseContext(HashMap<String,Object> map,String name)  throws Exception{
73
        this.name=name;
73
        this.name=name;
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
Lines 132-138 Link Here
132
        sql_del=getContent(f);
132
        sql_del=getContent(f);
133
    }
133
    }
134
    
134
    
135
    public Map getData(){
135
    public Properties getData(){
136
        return data;
136
        return data;
137
    }
137
    }
138
    
138
    
Lines 148-174 Link Here
148
        jars=f;
148
        jars=f;
149
    }
149
    }
150
    
150
    
151
    private String[] parseContent(File f) throws  Exception{
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
153
        List array=new ArrayList();
154
        String s=null;
155
        while((s=br.readLine())!=null){
156
          array.add(s);
157
        }
158
        if(array.size()==0)
159
            throw new RuntimeException(name+": File "+f.getName()+" doesn't containt the data !");
160
        return (String[])array.toArray(new String[0]);
161
    }
162
    
163
    private  String getContent(File f) throws Exception{
151
    private  String getContent(File f) throws Exception{
164
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
165
        StringBuffer sb=new StringBuffer();
153
        StringBuilder sb=new StringBuilder();
166
        String s=null;
154
        String s;
167
        while((s=br.readLine())!=null){
155
        while((s=br.readLine())!=null){
168
          sb.append(s);
156
          sb.append(s);
169
        }
157
        }
170
        if(sb.length()==0)
158
        if(sb.length()==0) {
171
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
159
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
160
        }
172
        return sb.toString();
161
        return sb.toString();
173
    }
162
    }
174
    
163
    
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java (-5 / +8 lines)
Lines 67-73 Link Here
67
    public static String DB_SQLDEL="dbdel.sql";
67
    public static String DB_SQLDEL="dbdel.sql";
68
    public static String DB_JARS="jar";
68
    public static String DB_JARS="jar";
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
70
    private List list=new ArrayList();
70
    private List<TestCaseContext> list=new ArrayList<TestCaseContext>();
71
    private static  TestCaseDataFactory factory;
71
    private static  TestCaseDataFactory factory;
72
    
72
    
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
Lines 101-107 Link Here
101
    
101
    
102
    private void process() throws Exception{
102
    private void process() throws Exception{
103
       File data_dir=getDataDir();
103
       File data_dir=getDataDir();
104
       HashMap map=new HashMap();
104
       HashMap<String,Object> map=new HashMap<String,Object>();
105
       String[] dir=data_dir.list();
105
       String[] dir=data_dir.list();
106
       for(int i=0;i<dir.length;i++){
106
       for(int i=0;i<dir.length;i++){
107
           String dir_name=dir[i];
107
           String dir_name=dir[i];
Lines 110-128 Link Here
110
                
110
                
111
                for(int index=0;index<FILES.length;index++){
111
                for(int index=0;index<FILES.length;index++){
112
                    File f=new File(path+File.separator+FILES[index]);
112
                    File f=new File(path+File.separator+FILES[index]);
113
                    if(!f.exists())
113
                    if(!f.exists()) {
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
115
                    }
115
                    map.put(FILES[index],f);
116
                    map.put(FILES[index],f);
116
                    
117
                    
117
                }
118
                }
118
                String[] s=new File(path).list(new FilenameFilter() {
119
                String[] s=new File(path).list(new FilenameFilter() {
120
                    @Override
119
                    public boolean accept(File dir, String name) {
121
                    public boolean accept(File dir, String name) {
120
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
122
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
121
                    }
123
                    }
122
                });
124
                });
123
                if(s.length==0)
125
                if(s.length==0) {
124
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
126
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
125
                ArrayList drivers=new ArrayList();
127
                }
128
                ArrayList<File> drivers=new ArrayList<File>();
126
                for(int myint=0;myint<s.length;myint++){
129
                for(int myint=0;myint<s.length;myint++){
127
                   File file=new File(path+File.separator+s[myint]);
130
                   File file=new File(path+File.separator+s[myint]);
128
                   drivers.add(file);
131
                   drivers.add(file);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBColumn.java (-8 / +7 lines)
Lines 48-54 Link Here
48
 * 
48
 * 
49
 * @author Ahimanikya Satapathy
49
 * @author Ahimanikya Satapathy
50
 */
50
 */
51
public final class DBColumn extends DBObject<DBTable> implements Comparable {
51
public final class DBColumn extends DBObject<DBTable> implements Comparable<DBColumn> {
52
52
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
53
    public static final int POSITION_UNKNOWN = Integer.MIN_VALUE;
54
    private boolean foreignKey;
54
    private boolean foreignKey;
Lines 81-105 Link Here
81
        editable = (!table.getName().equals("") && !isGenerated);
81
        editable = (!table.getName().equals("") && !isGenerated);
82
    }
82
    }
83
83
84
    public int compareTo(Object refObj) {
84
    @Override
85
        if (refObj == null) {
85
    public int compareTo(DBColumn refColumn) {
86
        if (refColumn == null) {
86
            return -1;
87
            return -1;
87
        }
88
        }
88
89
89
        if (refObj == this) {
90
        if (refColumn == this) {
90
            return 0;
91
            return 0;
91
        }
92
        }
92
93
93
        String myName = getDisplayName();
94
        String myName = getDisplayName();
94
        myName = (myName == null) ? columnName : myName;
95
        myName = (myName == null) ? columnName : myName;
95
96
96
        String refName = null;
97
        if (!(refColumn instanceof DBColumn)) {
97
        if (!(refObj instanceof DBColumn)) {
98
            return -1;
98
            return -1;
99
        }
99
        }
100
100
101
        DBColumn refColumn = (DBColumn) refObj;
101
        String refName = refColumn.getName();
102
        refName = refColumn.getName();
103
102
104
        // compare primary keys
103
        // compare primary keys
105
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
104
        if (this.isPrimaryKey() && !refColumn.isPrimaryKey()) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactory.java (-2 / +2 lines)
Lines 114-120 Link Here
114
    }
114
    }
115
115
116
    private static int getDBTypeFromURL(String url) {
116
    private static int getDBTypeFromURL(String url) {
117
        int dbtype = -1;
117
        int dbtype;
118
118
119
        // get the database type based on the product name converted to lowercase
119
        // get the database type based on the product name converted to lowercase
120
        url = url.toLowerCase();
120
        url = url.toLowerCase();
Lines 237-243 Link Here
237
                        nfe);
237
                        nfe);
238
            }
238
            }
239
239
240
            boolean isNullable = (rsMeta.isNullable(i) == rsMeta.columnNullable);
240
            boolean isNullable = (rsMeta.isNullable(i) == ResultSetMetaData.columnNullable);
241
            String displayName = rsMeta.getColumnLabel(i);
241
            String displayName = rsMeta.getColumnLabel(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
242
            int displaySize = rsMeta.getColumnDisplaySize(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
243
            boolean autoIncrement = rsMeta.isAutoIncrement(i);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewDBTable.java (-1 / +2 lines)
Lines 114-120 Link Here
114
        return columns.size();
114
        return columns.size();
115
    }
115
    }
116
116
117
    public synchronized Map getColumns() {
117
    public synchronized Map<String,DBColumn> getColumns() {
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
118
        Map<String, DBColumn> colMap = new HashMap<String, DBColumn>();
119
        for (DBTable tbl : dbTables) {
119
        for (DBTable tbl : dbTables) {
120
            colMap.putAll(tbl.getColumns());
120
            colMap.putAll(tbl.getColumns());
Lines 138-143 Link Here
138
        private ColumnOrderComparator() {
138
        private ColumnOrderComparator() {
139
        }
139
        }
140
140
141
        @Override
141
        public int compare(DBColumn col1, DBColumn col2) {
142
        public int compare(DBColumn col1, DBColumn col2) {
142
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
            return col1.getOrdinalPosition() - col2.getOrdinalPosition();
143
        }
144
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java (+1 lines)
Lines 108-113 Link Here
108
    }
108
    }
109
109
110
    @Override
110
    @Override
111
    @SuppressWarnings({"unchecked", "rawtypes"})
111
    public void setModel(TableModel dataModel) {
112
    public void setModel(TableModel dataModel) {
112
        RowFilter oldFilter = getRowFilter();
113
        RowFilter oldFilter = getRowFilter();
113
        super.setModel(dataModel);
114
        super.setModel(dataModel);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java (-12 / +7 lines)
Lines 207-213 Link Here
207
            }
207
            }
208
        }
208
        }
209
        Loader l = new Loader();
209
        Loader l = new Loader();
210
        Future f = rp.submit(l);
210
        Future<?> f = rp.submit(l);
211
        try {
211
        try {
212
            f.get();
212
            f.get();
213
        } catch (InterruptedException ex) {
213
        } catch (InterruptedException ex) {
Lines 409-419 Link Here
409
                pstmt = conn.prepareStatement(updateStmt);
409
                pstmt = conn.prepareStatement(updateStmt);
410
                int pos = 1;
410
                int pos = 1;
411
                for (Object val : values) {
411
                for (Object val : values) {
412
                    // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
413
                    if (DataViewUtils.isSQLConstantString(val)) {
414
                        continue;
415
                    }
416
417
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
412
                    DBReadWriteHelper.setAttributeValue(pstmt, pos, types.get(pos - 1), val);
418
                    pos++;
413
                    pos++;
419
                }
414
                }
Lines 654-660 Link Here
654
                }
649
                }
655
            }
650
            }
656
        } catch (SQLException ex) {
651
        } catch (SQLException ex) {
657
            LOGGER.log(Level.SEVERE, "Could not get total row count " + ex); // NOI18N
652
            LOGGER.log(Level.SEVERE, "Could not get total row count ", ex); // NOI18N
658
        }
653
        }
659
    }
654
    }
660
655
Lines 682-688 Link Here
682
                stmt.setFetchSize(pageSize);
677
                stmt.setFetchSize(pageSize);
683
            } catch (SQLException e) {
678
            } catch (SQLException e) {
684
                // ignore -  used only as a hint to the driver to optimize
679
                // ignore -  used only as a hint to the driver to optimize
685
                LOGGER.log(Level.WARNING, "Unable to set Fetch size" + e); // NOI18N
680
                LOGGER.log(Level.WARNING, "Unable to set Fetch size", e); // NOI18N
686
            }
681
            }
687
682
688
            try {
683
            try {
Lines 692-698 Link Here
692
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
687
                    stmt.setMaxRows(dataView.getDataViewPageContext().getCurrentPos() + pageSize);
693
                }
688
                }
694
            } catch (SQLException exc) {
689
            } catch (SQLException exc) {
695
                LOGGER.log(Level.WARNING, "Unable to set Max row size" + exc); // NOI18N
690
                LOGGER.log(Level.WARNING, "Unable to set Max row size", exc); // NOI18N
696
            }
691
            }
697
        } else {
692
        } else {
698
            stmt = conn.createStatement();
693
            stmt = conn.createStatement();
Lines 701-707 Link Here
701
    }
696
    }
702
697
703
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
698
    private void executeSQLStatement(Statement stmt, String sql) throws SQLException {
704
        LOGGER.log(Level.FINE, "Statement: " + sql); // NOI18N
699
        LOGGER.log(Level.FINE, "Statement: {0}", sql); // NOI18N
705
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
700
        dataView.setInfoStatusText(NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_executestmt") + sql);
706
701
707
        long startTime = System.currentTimeMillis();
702
        long startTime = System.currentTimeMillis();
Lines 712-724 Link Here
712
            try {
707
            try {
713
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
708
                isResultSet = stmt.execute(appendLimitIfRequired(sql));
714
            } catch (NullPointerException ex) {
709
            } catch (NullPointerException ex) {
715
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + ex);
710
                LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, ex});
716
                throw new SQLException(ex);
711
                throw new SQLException(ex);
717
            } catch (SQLException sqlExc) {
712
            } catch (SQLException sqlExc) {
718
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
713
                if (sqlExc.getErrorCode() == 1064 && sqlExc.getSQLState().equals("37000")) {
719
                    isResultSet = stmt.execute(sql);
714
                    isResultSet = stmt.execute(sql);
720
                } else {
715
                } else {
721
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [" + sql + "], cause: " + sqlExc);
716
                    LOGGER.log(Level.SEVERE, "Failed to execute SQL Statement [{0}], cause: {1}", new Object[] {sql, sqlExc});
722
                    throw sqlExc;
717
                    throw sqlExc;
723
                }
718
                }
724
            }
719
            }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutor.java (-2 / +4 lines)
Lines 45-54 Link Here
45
45
46
import java.sql.Connection;
46
import java.sql.Connection;
47
import java.sql.SQLException;
47
import java.sql.SQLException;
48
import org.netbeans.modules.db.dataview.meta.DBException;
49
import org.netbeans.api.progress.ProgressHandle;
48
import org.netbeans.api.progress.ProgressHandle;
50
import org.netbeans.api.progress.ProgressHandleFactory;
49
import org.netbeans.api.progress.ProgressHandleFactory;
51
import org.netbeans.modules.db.dataview.meta.DBConnectionFactory;
50
import org.netbeans.modules.db.dataview.meta.DBConnectionFactory;
51
import org.netbeans.modules.db.dataview.meta.DBException;
52
import org.openide.DialogDisplayer;
52
import org.openide.DialogDisplayer;
53
import org.openide.NotifyDescriptor;
53
import org.openide.NotifyDescriptor;
54
import org.openide.util.Cancellable;
54
import org.openide.util.Cancellable;
Lines 81-86 Link Here
81
        this.task = task;
81
        this.task = task;
82
    }
82
    }
83
83
84
    @Override
84
    public void run() {
85
    public void run() {
85
        assert task != null;
86
        assert task != null;
86
        try {
87
        try {
Lines 95-102 Link Here
95
                dataView.disableButtons();
96
                dataView.disableButtons();
96
97
97
                conn = DBConnectionFactory.getInstance().getConnection(dataView.getDatabaseConnection());
98
                conn = DBConnectionFactory.getInstance().getConnection(dataView.getDatabaseConnection());
98
                String msg = "";
99
                if (conn == null) {
99
                if (conn == null) {
100
                    String msg;
100
                    Throwable connEx = DBConnectionFactory.getInstance().getLastException();
101
                    Throwable connEx = DBConnectionFactory.getInstance().getLastException();
101
                    if (connEx != null) {
102
                    if (connEx != null) {
102
                        msg = connEx.getMessage();
103
                        msg = connEx.getMessage();
Lines 124-129 Link Here
124
        }
125
        }
125
    }
126
    }
126
127
128
    @Override
127
    public boolean cancel() {
129
    public boolean cancel() {
128
        return task.cancel();
130
        return task.cancel();
129
    }
131
    }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLStatementGenerator.java (-11 / +19 lines)
Lines 77-84 Link Here
77
        StringBuilder insertSql = new StringBuilder();
77
        StringBuilder insertSql = new StringBuilder();
78
        insertSql.append("INSERT INTO "); // NOI18N
78
        insertSql.append("INSERT INTO "); // NOI18N
79
79
80
        String colNames = " ("; // NOI18N
80
        StringBuilder colNames = new StringBuilder(" ("); // NOI18N
81
        String values = "";     // NOI18N
81
        StringBuilder values = new StringBuilder();
82
        String commaStr = ", "; // NOI18N
82
        String commaStr = ", "; // NOI18N
83
        boolean comma = false;
83
        boolean comma = false;
84
        for (int i = 0; i < insertedRow.length; i++) {
84
        for (int i = 0; i < insertedRow.length; i++) {
Lines 94-101 Link Here
94
            }
94
            }
95
95
96
            if (comma) {
96
            if (comma) {
97
                values += commaStr;
97
                values.append(commaStr);
98
                colNames += commaStr;
98
                colNames.append(commaStr);
99
            } else {
99
            } else {
100
                comma = true;
100
                comma = true;
101
            }
101
            }
Lines 103-117 Link Here
103
            // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
103
            // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
104
            if (val != null && DataViewUtils.isSQLConstantString(val, dbcol)) {
104
            if (val != null && DataViewUtils.isSQLConstantString(val, dbcol)) {
105
                String constStr = ((String) val).substring(1, ((String) val).length() - 1);
105
                String constStr = ((String) val).substring(1, ((String) val).length() - 1);
106
                values += constStr;
106
                values.append(constStr);
107
            } else { // ELSE literals
107
            } else { // ELSE literals
108
                values += insertedRow[i] == null ? " NULL " : "?"; // NOI18N
108
                values.append(insertedRow[i] == null ? " NULL " : "?"); // NOI18N
109
            }
109
            }
110
            colNames += dbcol.getQualifiedName(true);
110
            colNames.append(dbcol.getQualifiedName(true));
111
        }
111
        }
112
112
113
        colNames += ")"; // NOI18N
113
        colNames.append(")"); // NOI18N
114
        insertSql.append(tblMeta.getFullyQualifiedName(0, true) + colNames + " Values(" + values + ")"); // NOI18N
114
        insertSql.append(tblMeta.getFullyQualifiedName(0, true));
115
        insertSql.append(colNames.toString());
116
        insertSql.append(" Values("); // NOI18N
117
        insertSql.append(values.toString());
118
        insertSql.append(")"); // NOI18N
115
119
116
        return insertSql.toString();
120
        return insertSql.toString();
117
    }
121
    }
Lines 154-160 Link Here
154
        }
158
        }
155
159
156
        rawcolNames += ")"; // NOI18N
160
        rawcolNames += ")"; // NOI18N
157
        rawInsertSql.append(tblMeta.getFullyQualifiedName(0, false) + rawcolNames + " \n\tVALUES (" + rawvalues + ")"); // NOI18N
161
        rawInsertSql.append(tblMeta.getFullyQualifiedName(0, false));
162
        rawInsertSql.append(rawcolNames);
163
        rawInsertSql.append(" \n\tVALUES (");  // NOI18N
164
        rawInsertSql.append(rawvalues);
165
        rawInsertSql.append(")"); // NOI18N
158
166
159
        return rawInsertSql.toString();
167
        return rawInsertSql.toString();
160
    }
168
    }
Lines 269-275 Link Here
269
277
270
        boolean isdb2 = table.getParentObject().getDBType() == DBMetaDataFactory.DB2 ? true : false;
278
        boolean isdb2 = table.getParentObject().getDBType() == DBMetaDataFactory.DB2 ? true : false;
271
279
272
        StringBuffer sql = new StringBuffer();
280
        StringBuilder sql = new StringBuilder();
273
        List<DBColumn> columns = table.getColumnList();
281
        List<DBColumn> columns = table.getColumnList();
274
        sql.append("CREATE TABLE ").append(table.getQualifiedName(false)).append(" ("); // NOI18N
282
        sql.append("CREATE TABLE ").append(table.getQualifiedName(false)).append(" ("); // NOI18N
275
        int count = 0;
283
        int count = 0;
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableRowHeader.java (-1 / +1 lines)
Lines 243-249 Link Here
243
    private final CountingTableModel ctm = new CountingTableModel();
243
    private final CountingTableModel ctm = new CountingTableModel();
244
    private final JXTable headerTable;
244
    private final JXTable headerTable;
245
    private JXTable backingTable;
245
    private JXTable backingTable;
246
    private RowSorter backingSorter;
246
    private RowSorter<?> backingSorter;
247
247
248
    /**
248
    /**
249
     * Create a row header from the given {@code JTable}. This row header will
249
     * Create a row header from the given {@code JTable}. This row header will
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java (-2 / +2 lines)
Lines 101-107 Link Here
101
        });
101
        });
102
    }
102
    }
103
103
104
    public ResultSetCellRenderer(ComponentProvider componentProvider) {
104
    public ResultSetCellRenderer(ComponentProvider<? extends JComponent> componentProvider) {
105
        super(componentProvider);
105
        super(componentProvider);
106
    }
106
    }
107
107
Lines 119-125 Link Here
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
119
            return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
120
        } else if (value instanceof Number) {
120
        } else if (value instanceof Number) {
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
121
            return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
122
        } else if (DataViewUtils.isSQLConstantString(value)) {
122
        } else if (DataViewUtils.isSQLConstantString(value, null)) {
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
123
            Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
124
            setTableCellToolTip(c, value);
124
            setTableCellToolTip(c, value);
125
            return c;            
125
            return c;            
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java (-4 / +3 lines)
Lines 39-45 Link Here
39
 * 
39
 * 
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table;
43
43
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.awt.event.MouseEvent;
45
import java.awt.event.MouseEvent;
Lines 51-57 Link Here
51
import javax.swing.UIManager;
51
import javax.swing.UIManager;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
52
import org.jdesktop.swingx.renderer.JRendererCheckBox;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
53
import org.netbeans.modules.db.dataview.meta.DBColumn;
54
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
55
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
54
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
56
import org.netbeans.modules.db.dataview.util.DataViewUtils;
55
import org.netbeans.modules.db.dataview.util.DataViewUtils;
57
import org.openide.awt.StatusDisplayer;
56
import org.openide.awt.StatusDisplayer;
Lines 61-67 Link Here
61
    protected Object val;
60
    protected Object val;
62
    protected boolean editable = true;
61
    protected boolean editable = true;
63
    protected JTable table;
62
    protected JTable table;
64
    static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
63
    protected static final boolean isGtk = "GTK".equals (UIManager.getLookAndFeel ().getID ()); //NOI18N
65
64
66
    public ResultSetTableCellEditor(final JTextField textField) {
65
    public ResultSetTableCellEditor(final JTextField textField) {
67
        super(textField);
66
        super(textField);
Lines 105-111 Link Here
105
104
106
    @Override
105
    @Override
107
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
106
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
108
        if (DataViewUtils.isSQLConstantString(value)) {
107
        if (DataViewUtils.isSQLConstantString(value, null)) {
109
            value = "";
108
            value = "";
110
        }
109
        }
111
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
110
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableModel.java (-2 / +4 lines)
Lines 64-70 Link Here
64
    private Class[] collumnClasses;
64
    private Class[] collumnClasses;
65
    protected ResultSetJXTable table;
65
    protected ResultSetJXTable table;
66
66
67
    public static Class getTypeClass(DBColumn col) {
67
    public static Class<? extends Object> getTypeClass(DBColumn col) {
68
        int colType = col.getJdbcType();
68
        int colType = col.getJdbcType();
69
69
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
70
        if (colType == Types.BIT && col.getPrecision() <= 1) {
Lines 116-121 Link Here
116
        }
116
        }
117
    }
117
    }
118
118
119
    @SuppressWarnings("rawtypes")
119
    public ResultSetTableModel(ResultSetJXTable table) {
120
    public ResultSetTableModel(ResultSetJXTable table) {
120
        super();
121
        super();
121
        this.table = table;
122
        this.table = table;
Lines 155-161 Link Here
155
    }
156
    }
156
157
157
    @Override
158
    @Override
158
    public Class getColumnClass(int columnIndex) {
159
    @SuppressWarnings("unchecked")
160
    public Class<? extends Object> getColumnClass(int columnIndex) {
159
        if (collumnClasses[columnIndex] == null) {
161
        if (collumnClasses[columnIndex] == null) {
160
            return super.getColumnClass(columnIndex);
162
            return super.getColumnClass(columnIndex);
161
        } else {
163
        } else {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java (+1 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.db.dataview.table.celleditor;
42
package org.netbeans.modules.db.dataview.table.celleditor;
43
43
44
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
44
import java.awt.Component;
45
import java.awt.Component;
45
import javax.swing.BorderFactory;
46
import javax.swing.BorderFactory;
46
import javax.swing.JComponent;
47
import javax.swing.JComponent;
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (-1 / +2 lines)
Lines 79-85 Link Here
79
                }
79
                }
80
            });
80
            });
81
            charsetSelect = new JComboBox();
81
            charsetSelect = new JComboBox();
82
            charsetSelect.setModel(new DefaultComboBoxModel(charset.toArray()));
82
            charsetSelect.setModel(new DefaultComboBoxModel(
83
                    charset.toArray(new Charset[charset.size()])));
83
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            charsetSelect.setSelectedItem(Charset.defaultCharset());
84
            this.add(charsetSelect);
85
            this.add(charsetSelect);
85
        }
86
        }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java (-1 / +1 lines)
Lines 137-143 Link Here
137
    }
137
    }
138
138
139
    protected Timestamp getValueAsTimestamp(Object value) {
139
    protected Timestamp getValueAsTimestamp(Object value) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value)) {
140
        if (isEmpty(value) || DataViewUtils.isSQLConstantString(value, null)) {
141
            return new Timestamp(System.currentTimeMillis());
141
            return new Timestamp(System.currentTimeMillis());
142
        }
142
        }
143
143
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/NumberFieldEditor.java (-1 / +2 lines)
Lines 46-51 Link Here
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import javax.swing.JTable;
47
import javax.swing.JTable;
48
import javax.swing.JTextField;
48
import javax.swing.JTextField;
49
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
49
50
50
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
public class NumberFieldEditor extends ResultSetTableCellEditor {
51
52
Lines 64-67 Link Here
64
        setEditable(column, c, table.isCellEditable(row, column));
65
        setEditable(column, c, table.isCellEditable(row, column));
65
        return c;
66
        return c;
66
    }
67
    }
67
}
68
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java (-1 / +2 lines)
Lines 63-68 Link Here
63
import javax.swing.table.TableCellEditor;
63
import javax.swing.table.TableCellEditor;
64
import org.jdesktop.swingx.JXButton;
64
import org.jdesktop.swingx.JXButton;
65
import org.jdesktop.swingx.JXPanel;
65
import org.jdesktop.swingx.JXPanel;
66
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
66
import org.openide.windows.WindowManager;
67
import org.openide.windows.WindowManager;
67
68
68
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
69
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
Lines 151-154 Link Here
151
            JOptionPane.showMessageDialog(parent, pane, table.getColumnName(column), JOptionPane.PLAIN_MESSAGE, null);
152
            JOptionPane.showMessageDialog(parent, pane, table.getColumnName(column), JOptionPane.PLAIN_MESSAGE, null);
152
        }
153
        }
153
    }
154
    }
154
}
155
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java (-25 / +52 lines)
Lines 166-176 Link Here
166
        
166
        
167
        popupButton = createPopupButton();
167
        popupButton = createPopupButton();
168
        if (popupButton != null) {
168
        if (popupButton != null) {
169
            // this is a trick to get hold of the client prop which
169
            popupButton.putClientProperty("doNotCancelPopup", 
170
            // prevents closing of the popup
170
                    createDoNotCancelPopupClientProperty());
171
            JComboBox box = new JComboBox();
172
            Object preventHide = box.getClientProperty("doNotCancelPopup");
173
            popupButton.putClientProperty("doNotCancelPopup", preventHide);
174
            datePicker.add(popupButton);
171
            datePicker.add(popupButton);
175
        }
172
        }
176
            updateChildLocale(datePicker.getLocale());
173
            updateChildLocale(datePicker.getLocale());
Lines 252-259 Link Here
252
     * PRE: keybindings installed on picker.
249
     * PRE: keybindings installed on picker.
253
     */
250
     */
254
    protected void installLinkPanelKeyboardActions() {
251
    protected void installLinkPanelKeyboardActions() {
255
        if (datePicker.getLinkPanel() == null)
252
        if (datePicker.getLinkPanel() == null)  {
256
            return;
253
            return;
254
        }
257
        ActionMap map = datePicker.getLinkPanel().getActionMap();
255
        ActionMap map = datePicker.getLinkPanel().getActionMap();
258
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
256
        map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
259
                JXDateTimePicker.HOME_COMMIT_KEY));
257
                JXDateTimePicker.HOME_COMMIT_KEY));
Lines 277-283 Link Here
277
     * 
275
     * 
278
     */
276
     */
279
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
277
    protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
280
        if (panel == null) return;
278
        if (panel == null) {
279
            return;
280
        }
281
        ActionMap map = panel.getActionMap();
281
        ActionMap map = panel.getActionMap();
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
282
        map.remove(JXDateTimePicker.HOME_COMMIT_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
283
        map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); 
Lines 705-711 Link Here
705
     *    is intermediate
705
     *    is intermediate
706
     */
706
     */
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
707
    protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
708
        if (adjusting) return;
708
        if (adjusting) {
709
            return;
710
        }
709
        updateEditorValue();
711
        updateEditorValue();
710
    }
712
    }
711
713
Lines 755-765 Link Here
755
            oldEditor.putClientProperty("doNotCancelPopup", null);
757
            oldEditor.putClientProperty("doNotCancelPopup", null);
756
        }
758
        }
757
        datePicker.add(datePicker.getEditor());
759
        datePicker.add(datePicker.getEditor());
758
        // this is a trick to get hold of the client prop which
760
        datePicker.getEditor().putClientProperty("doNotCancelPopup", 
759
        // prevents closing of the popup
761
                createDoNotCancelPopupClientProperty());
760
        JComboBox box = new JComboBox();
761
        Object preventHide = box.getClientProperty("doNotCancelPopup");
762
        datePicker.getEditor().putClientProperty("doNotCancelPopup", preventHide);
763
762
764
        updateEditorValue();
763
        updateEditorValue();
765
        if (updateListeners) {
764
        if (updateListeners) {
Lines 942-948 Link Here
942
     * control popup visibility?
941
     * control popup visibility?
943
     */
942
     */
944
    public void hidePopup() {
943
    public void hidePopup() {
945
        if (popup != null) popup.setVisible(false);
944
        if (popup != null) {
945
            popup.setVisible(false);
946
        }
946
    }
947
    }
947
948
948
    public boolean isPopupVisible() {
949
    public boolean isPopupVisible() {
Lines 980-986 Link Here
980
     */
981
     */
981
    private Action createCommitAction() {
982
    private Action createCommitAction() {
982
        Action action = new AbstractAction() {
983
        Action action = new AbstractAction() {
983
984
            @Override
984
            public void actionPerformed(ActionEvent e) {
985
            public void actionPerformed(ActionEvent e) {
985
                commit();
986
                commit();
986
            }
987
            }
Lines 997-1003 Link Here
997
     */
998
     */
998
    private Action createCancelAction() {
999
    private Action createCancelAction() {
999
        Action action = new AbstractAction() {
1000
        Action action = new AbstractAction() {
1000
1001
            @Override
1001
            public void actionPerformed(ActionEvent e) {
1002
            public void actionPerformed(ActionEvent e) {
1002
                cancel();
1003
                cancel();
1003
            }
1004
            }
Lines 1008-1014 Link Here
1008
1009
1009
    private Action createHomeAction(final boolean commit) {
1010
    private Action createHomeAction(final boolean commit) {
1010
        Action action = new AbstractAction( ) {
1011
        Action action = new AbstractAction( ) {
1011
1012
            @Override
1012
            public void actionPerformed(ActionEvent e) {
1013
            public void actionPerformed(ActionEvent e) {
1013
                home(commit);
1014
                home(commit);
1014
                
1015
                
Lines 1054-1059 Link Here
1054
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
            editor.getActionMap().put(TEXT_CANCEL_KEY, this);
1055
        }
1056
        }
1056
        
1057
        
1058
        @Override
1057
        public void actionPerformed(ActionEvent e) {
1059
        public void actionPerformed(ActionEvent e) {
1058
            cancelAction.actionPerformed(null);
1060
            cancelAction.actionPerformed(null);
1059
            cancel();
1061
            cancel();
Lines 1088-1093 Link Here
1088
            datePicker.getEditor().requestFocusInWindow();
1090
            datePicker.getEditor().requestFocusInWindow();
1089
//            datePicker.requestFocusInWindow();
1091
//            datePicker.requestFocusInWindow();
1090
            SwingUtilities.invokeLater(new Runnable() {
1092
            SwingUtilities.invokeLater(new Runnable() {
1093
                @Override
1091
                public void run() {
1094
                public void run() {
1092
                    popup.show(datePicker,
1095
                    popup.show(datePicker,
1093
                            0, datePicker.getHeight());
1096
                            0, datePicker.getHeight());
Lines 1114-1119 Link Here
1114
            super("TogglePopup");
1117
            super("TogglePopup");
1115
        }
1118
        }
1116
1119
1120
        @Override
1117
        public void actionPerformed(ActionEvent ev) {
1121
        public void actionPerformed(ActionEvent ev) {
1118
            toggleShowPopup();
1122
            toggleShowPopup();
1119
        }
1123
        }
Lines 1165-1173 Link Here
1165
//------------- implement Mouse/MotionListener        
1169
//------------- implement Mouse/MotionListener        
1166
        private boolean _forwardReleaseEvent = false;
1170
        private boolean _forwardReleaseEvent = false;
1167
1171
1172
        @Override
1168
        public void mouseClicked(MouseEvent ev) {
1173
        public void mouseClicked(MouseEvent ev) {
1169
        }
1174
        }
1170
1175
1176
        @Override
1171
        public void mousePressed(MouseEvent ev) {
1177
        public void mousePressed(MouseEvent ev) {
1172
            if (!datePicker.isEnabled()) {
1178
            if (!datePicker.isEnabled()) {
1173
                return;
1179
                return;
Lines 1181-1186 Link Here
1181
            toggleShowPopup();
1187
            toggleShowPopup();
1182
        }
1188
        }
1183
1189
1190
        @Override
1184
        public void mouseReleased(MouseEvent ev) {
1191
        public void mouseReleased(MouseEvent ev) {
1185
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1192
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1186
                return;
1193
                return;
Lines 1196-1207 Link Here
1196
            }
1203
            }
1197
        }
1204
        }
1198
1205
1206
        @Override
1199
        public void mouseEntered(MouseEvent ev) {
1207
        public void mouseEntered(MouseEvent ev) {
1200
        }
1208
        }
1201
1209
1210
        @Override
1202
        public void mouseExited(MouseEvent ev) {
1211
        public void mouseExited(MouseEvent ev) {
1203
        }
1212
        }
1204
1213
1214
        @Override
1205
        public void mouseDragged(MouseEvent ev) {
1215
        public void mouseDragged(MouseEvent ev) {
1206
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1216
            if (!datePicker.isEnabled() || !datePicker.isEditable()) {
1207
                return;
1217
                return;
Lines 1219-1228 Link Here
1219
            monthView.dispatchEvent(ev);
1229
            monthView.dispatchEvent(ev);
1220
        }
1230
        }
1221
1231
1232
        @Override
1222
        public void mouseMoved(MouseEvent ev) {
1233
        public void mouseMoved(MouseEvent ev) {
1223
        }
1234
        }
1224
//------------------ implement DateSelectionListener
1235
//------------------ implement DateSelectionListener
1225
        
1236
        @Override
1226
        public void valueChanged(DateSelectionEvent ev) {
1237
        public void valueChanged(DateSelectionEvent ev) {
1227
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1238
            updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
1228
        }
1239
        }
Lines 1231-1236 Link Here
1231
        /**
1242
        /**
1232
         * {@inheritDoc}
1243
         * {@inheritDoc}
1233
         */
1244
         */
1245
        @Override
1234
        public void propertyChange(PropertyChangeEvent e) {
1246
        public void propertyChange(PropertyChangeEvent e) {
1235
            if (e.getSource() == datePicker) {
1247
            if (e.getSource() == datePicker) {
1236
                datePickerPropertyChange(e);
1248
                datePickerPropertyChange(e);
Lines 1259-1266 Link Here
1259
         */
1271
         */
1260
        private void editorPropertyChange(PropertyChangeEvent evt) {
1272
        private void editorPropertyChange(PropertyChangeEvent evt) {
1261
            if ("value".equals(evt.getPropertyName())) {
1273
            if ("value".equals(evt.getPropertyName())) {
1262
                ;
1274
1263
                
1264
                Object oldVal = evt.getOldValue();
1275
                Object oldVal = evt.getOldValue();
1265
                Object newVal = evt.getNewValue();
1276
                Object newVal = evt.getNewValue();
1266
                
1277
                
Lines 1353-1371 Link Here
1353
        }
1364
        }
1354
1365
1355
//-------------- implement LayoutManager
1366
//-------------- implement LayoutManager
1356
        
1367
        @Override
1357
        public void addLayoutComponent(String name, Component comp) { }
1368
        public void addLayoutComponent(String name, Component comp) { }
1358
1369
1370
        @Override
1359
        public void removeLayoutComponent(Component comp) { }
1371
        public void removeLayoutComponent(Component comp) { }
1360
1372
1373
        @Override
1361
        public Dimension preferredLayoutSize(Container parent) {
1374
        public Dimension preferredLayoutSize(Container parent) {
1362
            return parent.getPreferredSize();
1375
            return parent.getPreferredSize();
1363
        }
1376
        }
1364
1377
1378
        @Override
1365
        public Dimension minimumLayoutSize(Container parent) {
1379
        public Dimension minimumLayoutSize(Container parent) {
1366
            return parent.getMinimumSize();
1380
            return parent.getMinimumSize();
1367
        }
1381
        }
1368
1382
1383
        @Override
1369
        public void layoutContainer(Container parent) {
1384
        public void layoutContainer(Container parent) {
1370
            Insets insets = datePicker.getInsets();
1385
            Insets insets = datePicker.getInsets();
1371
            int width = datePicker.getWidth() - insets.left - insets.right;
1386
            int width = datePicker.getWidth() - insets.left - insets.right;
Lines 1389-1397 Link Here
1389
        }
1404
        }
1390
1405
1391
// ------------- implement actionListener (listening to monthView actionEvent)
1406
// ------------- implement actionListener (listening to monthView actionEvent)
1392
        
1407
        @Override
1393
        public void actionPerformed(ActionEvent e) {
1408
        public void actionPerformed(ActionEvent e) {
1394
            if (e == null) return;
1409
            if (e == null) {
1410
                return;
1411
            }
1395
            if (e.getSource() == datePicker.getMonthView()) {
1412
            if (e.getSource() == datePicker.getMonthView()) {
1396
                monthViewActionPerformed(e);
1413
                monthViewActionPerformed(e);
1397
            } else if (e.getSource() == datePicker.getEditor()) {
1414
            } else if (e.getSource() == datePicker.getEditor()) {
Lines 1430-1437 Link Here
1430
         * Do the same as combo: manually pass-on the focus to the editor.
1447
         * Do the same as combo: manually pass-on the focus to the editor.
1431
         * 
1448
         * 
1432
         */
1449
         */
1450
        @Override
1433
        public void focusGained(FocusEvent e) {
1451
        public void focusGained(FocusEvent e) {
1434
            if (e.isTemporary()) return;
1452
            if (e.isTemporary()) {
1453
                return;
1454
            }
1435
            popupRemover.load();
1455
            popupRemover.load();
1436
            if (e.getSource() == datePicker) {
1456
            if (e.getSource() == datePicker) {
1437
               datePicker.getEditor().requestFocusInWindow(); 
1457
               datePicker.getEditor().requestFocusInWindow(); 
Lines 1460-1465 Link Here
1460
         * 
1480
         * 
1461
         * listen to keyboardFocusManager?
1481
         * listen to keyboardFocusManager?
1462
         */
1482
         */
1483
        @Override
1463
        public void focusLost(FocusEvent e) {
1484
        public void focusLost(FocusEvent e) {
1464
            
1485
            
1465
        }
1486
        }
Lines 1498-1503 Link Here
1498
            unload(true);
1519
            unload(true);
1499
        }
1520
        }
1500
        
1521
        
1522
        @Override
1501
        public void propertyChange(PropertyChangeEvent evt) {
1523
        public void propertyChange(PropertyChangeEvent evt) {
1502
            if (!isPopupVisible()) {
1524
            if (!isPopupVisible()) {
1503
                unload(false);
1525
                unload(false);
Lines 1606-1610 Link Here
1606
    
1628
    
1607
//------------ utility methods
1629
//------------ utility methods
1608
1630
1609
1631
    private Object createDoNotCancelPopupClientProperty() {
1632
        // this is a trick to get hold of the client prop which
1633
        // prevents closing of the popup
1634
        JComboBox box = new JComboBox();
1635
        return box.getClientProperty("doNotCancelPopup");
1610
}
1636
}
1637
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/DataViewUtils.java (-15 / +7 lines)
Lines 43-58 Link Here
43
 */
43
 */
44
package org.netbeans.modules.db.dataview.util;
44
package org.netbeans.modules.db.dataview.util;
45
45
46
import java.sql.Date;
47
import java.sql.PreparedStatement;
46
import java.sql.PreparedStatement;
48
import java.sql.ResultSet;
47
import java.sql.ResultSet;
49
import java.sql.SQLException;
48
import java.sql.SQLException;
50
import java.sql.Statement;
49
import java.sql.Statement;
51
import java.sql.Time;
52
import java.sql.Timestamp;
53
import java.sql.Types;
50
import java.sql.Types;
54
import java.util.Iterator;
55
import java.util.List;
56
import org.netbeans.modules.db.dataview.meta.DBColumn;
51
import org.netbeans.modules.db.dataview.meta.DBColumn;
57
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
52
import org.netbeans.modules.db.dataview.meta.DBForeignKey;
58
import org.netbeans.modules.db.dataview.meta.DBTable;
53
import org.netbeans.modules.db.dataview.meta.DBTable;
Lines 277-294 Link Here
277
        String refString = column.getName() + " --> "; // NOI18N
272
        String refString = column.getName() + " --> "; // NOI18N
278
        StringBuilder str = new StringBuilder(refString);
273
        StringBuilder str = new StringBuilder(refString);
279
        DBTable table = column.getParentObject();
274
        DBTable table = column.getParentObject();
280
        List list = table.getForeignKeys();
275
        boolean firstReferencedColumn = false;
281
276
282
        Iterator it = list.iterator();
277
        for(DBForeignKey fk: table.getForeignKeys()) {
283
        while (it.hasNext()) {
284
            DBForeignKey fk = (DBForeignKey) it.next();
285
            if (fk.contains(column)) {
278
            if (fk.contains(column)) {
286
                List pkColumnList = fk.getPKColumnNames();
279
                for(String pkColName: fk.getPKColumnNames()) {
287
                Iterator it1 = pkColumnList.iterator();
288
                while (it1.hasNext()) {
289
                    String pkColName = (String) it1.next();
290
                    str.append(pkColName);
280
                    str.append(pkColName);
291
                    if (it1.hasNext()) {
281
                    if (firstReferencedColumn) {
282
                        firstReferencedColumn = false;
283
                    } else {
292
                        str.append(", "); // NOI18N
284
                        str.append(", "); // NOI18N
293
                    }
285
                    }
294
                }
286
                }
Lines 305-311 Link Here
305
    }
297
    }
306
298
307
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
299
    public static String replaceInString(String originalString, String[] victims, String[] replacements) {
308
        StringBuffer resultBuffer = new StringBuffer();
300
        StringBuilder resultBuffer = new StringBuilder();
309
        boolean bReplaced = false;
301
        boolean bReplaced = false;
310
302
311
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
303
        for (int charPosition = 0; charPosition < originalString.length(); charPosition++) {
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java (-7 / +10 lines)
Lines 46-63 Link Here
46
import java.util.Locale;
46
import java.util.Locale;
47
import java.util.TimeZone;
47
import java.util.TimeZone;
48
import java.util.logging.Logger;
48
import java.util.logging.Logger;
49
50
import javax.swing.AbstractAction;
49
import javax.swing.AbstractAction;
51
import javax.swing.Action;
50
import javax.swing.Action;
52
import javax.swing.JComponent;
51
import javax.swing.JComponent;
53
import javax.swing.JFormattedTextField;
52
import javax.swing.JFormattedTextField;
53
import javax.swing.JFormattedTextField.AbstractFormatter;
54
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
54
import javax.swing.JPanel;
55
import javax.swing.JPanel;
55
import javax.swing.JPopupMenu;
56
import javax.swing.JPopupMenu;
56
import javax.swing.UIManager;
57
import javax.swing.UIManager;
57
import javax.swing.JFormattedTextField.AbstractFormatter;
58
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
59
import javax.swing.text.DefaultFormatterFactory;
58
import javax.swing.text.DefaultFormatterFactory;
60
61
import org.jdesktop.swingx.JXHyperlink;
59
import org.jdesktop.swingx.JXHyperlink;
62
import org.jdesktop.swingx.JXMonthView;
60
import org.jdesktop.swingx.JXMonthView;
63
import org.jdesktop.swingx.JXPanel;
61
import org.jdesktop.swingx.JXPanel;
Lines 318-324 Link Here
318
    }
316
    }
319
317
320
    protected class SelectedValuesComparator implements Comparator<Calendar> {
318
    protected class SelectedValuesComparator implements Comparator<Calendar> {
321
319
        @Override
322
        public int compare(Calendar cal1, Calendar cal2) {
320
        public int compare(Calendar cal1, Calendar cal2) {
323
321
324
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
322
            if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
Lines 372-378 Link Here
372
    private PropertyChangeListener getMonthViewListener() {
370
    private PropertyChangeListener getMonthViewListener() {
373
        if (monthViewListener == null) {
371
        if (monthViewListener == null) {
374
            monthViewListener = new PropertyChangeListener() {
372
            monthViewListener = new PropertyChangeListener() {
375
373
                @Override
376
                public void propertyChange(PropertyChangeEvent evt) {
374
                public void propertyChange(PropertyChangeEvent evt) {
377
                    if ("timeZone".equals(evt.getPropertyName())) {
375
                    if ("timeZone".equals(evt.getPropertyName())) {
378
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
376
                        updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
Lines 849-854 Link Here
849
     * @param height Height of the component to determine baseline for.
847
     * @param height Height of the component to determine baseline for.
850
     * @return baseline for the specified component
848
     * @return baseline for the specified component
851
     */
849
     */
850
    @Override
852
    public int getBaseline(int width, int height) {
851
    public int getBaseline(int width, int height) {
853
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
852
        return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
854
    }
853
    }
Lines 916-921 Link Here
916
        private TodayAction todayAction;
915
        private TodayAction todayAction;
917
        private JXHyperlink todayLink;
916
        private JXHyperlink todayLink;
918
917
918
        @SuppressWarnings("rawtypes")
919
        TodayPanel() {
919
        TodayPanel() {
920
            super(new FlowLayout());
920
            super(new FlowLayout());
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
Lines 936-942 Link Here
936
936
937
                @Override
937
                @Override
938
                public void mousePressed(MouseEvent e) {
938
                public void mousePressed(MouseEvent e) {
939
                    if (e.getClickCount() != 2) return;
939
                    if (e.getClickCount() != 2) {
940
                        return;
941
                    }
940
                    todayAction.select = true;
942
                    todayAction.select = true;
941
                }
943
                }
942
                
944
                
Lines 973-978 Link Here
973
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
975
                putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
974
            }
976
            }
975
977
978
            @Override
976
            public void actionPerformed(ActionEvent ae) {
979
            public void actionPerformed(ActionEvent ae) {
977
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
980
                String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
978
                select = false;
981
                select = false;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java (-5 / +7 lines)
Lines 63-69 Link Here
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
63
//@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.db.dataview.spi.DBConnectionProvider.class)
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
64
public class DBConnectionProviderImpl implements DBConnectionProvider{
65
65
66
/** Creates a new instance of DBConnectionProviderImpl */
66
    /** Creates a new instance of DBConnectionProviderImpl */
67
    public DBConnectionProviderImpl() {
67
    public DBConnectionProviderImpl() {
68
    }
68
    }
69
    
69
    
Lines 80-85 Link Here
80
        return null;
80
        return null;
81
    }
81
    }
82
82
83
    @Override
83
    public void closeConnection(Connection con) {
84
    public void closeConnection(Connection con) {
84
        try {
85
        try {
85
            if(con != null) {
86
            if(con != null) {
Lines 98-103 Link Here
98
        }
99
        }
99
    }
100
    }
100
101
102
    @Override
101
    public Connection getConnection(DatabaseConnection dbConn) {
103
    public Connection getConnection(DatabaseConnection dbConn) {
102
        try {
104
        try {
103
            String driver = dbConn.getDriverClass();
105
            String driver = dbConn.getDriverClass();
Lines 110-122 Link Here
110
112
111
            TestCaseContext context = DbUtil.getContext();
113
            TestCaseContext context = DbUtil.getContext();
112
            File[] jars = context.getJars();
114
            File[] jars = context.getJars();
113
            ArrayList list = new java.util.ArrayList();
115
            ArrayList<URL> list = new java.util.ArrayList<URL>();
114
            for (int i = 0; i < jars.length; i++) {
116
            for (int i = 0; i < jars.length; i++) {
115
                list.add((URL)jars[i].toURI().toURL());
117
                list.add(jars[i].toURI().toURL());
116
            }
118
            }
117
            URL[] driverURLs = (URL[]) list.toArray(new URL[0]);
119
            URL[] driverURLs = list.toArray(new URL[0]);
118
            URLClassLoader l = new URLClassLoader(driverURLs);
120
            URLClassLoader l = new URLClassLoader(driverURLs);
119
            Class c = Class.forName(driver, true, l);
121
            Class<?> c = Class.forName(driver, true, l);
120
            Driver drv = (Driver) c.newInstance();
122
            Driver drv = (Driver) c.newInstance();
121
            Connection con = drv.connect(url, prop);
123
            Connection con = drv.connect(url, prop);
122
            return con;
124
            return con;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java (-16 / +13 lines)
Lines 57-62 Link Here
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
57
import org.netbeans.api.db.explorer.JDBCDriverManager;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
58
import org.netbeans.modules.db.dataview.spi.DBConnectionProviderImpl;
59
import org.openide.util.Exceptions;
59
import org.openide.util.Exceptions;
60
import org.openide.util.Utilities;
60
61
61
/**
62
/**
62
 *
63
 *
Lines 68-85 Link Here
68
    public static String USER = "user";
69
    public static String USER = "user";
69
    public static String PASSWORD = "password";
70
    public static String PASSWORD = "password";
70
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    private static List localConnectionList = new ArrayList();
72
    private static List<Connection> localConnectionList = new ArrayList<Connection>();
72
73
73
    public static DatabaseConnection getDBConnection() {
74
    public static DatabaseConnection getDBConnection() {
74
        try {
75
        try {
75
            TestCaseContext context = getContext();
76
            TestCaseContext context = getContext();
76
            Properties prop = context.getProperties();
77
            Properties prop = context.getProperties();
77
            File[] jars = context.getJars();
78
            File[] jars = context.getJars();
78
            ArrayList list = new java.util.ArrayList();
79
            ArrayList<URL> list = new java.util.ArrayList<URL>();
79
            for (int i = 0; i < jars.length; i++) {
80
            for (int i = 0; i < jars.length; i++) {
80
                list.add((URL)jars[i].toURI().toURL());
81
                list.add(Utilities.toURI(jars[i]).toURL());
81
            }
82
            }
82
            URL[] urls = (URL[]) list.toArray(new URL[0]);
83
            URL[] urls = list.toArray(new URL[0]);
83
            Class.forName(AXION_DRIVER);
84
            Class.forName(AXION_DRIVER);
84
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
86
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
Lines 153-164 Link Here
153
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
    public static Connection createConnection(String driverName, String url, String username, String password) throws Exception {
154
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // Try to get the connection directly. Dont go through DB Explorer.
155
        // It may pop up a window asking for password.
156
        // It may pop up a window asking for password.
156
        JDBCDriver drv = null;
157
        Connection conn = null;
157
        Connection conn = null;
158
        try {
158
        try {
159
           
159
            //url = adjustDatabaseURL(url);
160
                //url = adjustDatabaseURL(url);
160
            JDBCDriver drv  = registerDriver(driverName);
161
            drv = registerDriver(driverName);
162
161
163
            conn = getConnection(drv, driverName, url, username, password);
162
            conn = getConnection(drv, driverName, url, username, password);
164
            if (conn == null) { // get from db explorer
163
            if (conn == null) { // get from db explorer
Lines 208-219 Link Here
208
207
209
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
208
    public static DatabaseConnection createDatabaseConnection(String driverName, String url, String username, String password) throws Exception {
210
        DatabaseConnection dbconn = null;
209
        DatabaseConnection dbconn = null;
211
        JDBCDriver drv = null;
212
        String schema = null;
213
        try {
210
        try {
214
            
211
            //url = adjustDatabaseURL(url);
215
                //url = adjustDatabaseURL(url);
212
            JDBCDriver drv = registerDriver(driverName);
216
            drv = registerDriver(driverName);
217
213
218
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
214
            // check if connection exists in DB Explorer. Else add the connection to DB Explorer.
219
215
Lines 227-232 Link Here
227
223
228
            // dont add instance db and monitor db and local dbs connections to db explorer.
224
            // dont add instance db and monitor db and local dbs connections to db explorer.
229
            if (dbconn == null) {
225
            if (dbconn == null) {
226
                String schema;
230
                if (url.startsWith(AXION_URL_PREFIX)) {
227
                if (url.startsWith(AXION_URL_PREFIX)) {
231
                    schema = "";
228
                    schema = "";
232
                } else {
229
                } else {
Lines 284-294 Link Here
284
            // if axion db driver not available in db explorer, add it.
281
            // if axion db driver not available in db explorer, add it.
285
            //URL[] url = new URL[1];
282
            //URL[] url = new URL[1];
286
            File[] jars = cxt.getJars();
283
            File[] jars = cxt.getJars();
287
            ArrayList list = new java.util.ArrayList();
284
            ArrayList<URL> list = new java.util.ArrayList<URL>();
288
            for (int i = 0; i < jars.length; i++) {
285
            for (int i = 0; i < jars.length; i++) {
289
                list.add((URL)jars[i].toURI().toURL());
286
                list.add(Utilities.toURI(jars[i]).toURL());
290
            }
287
            }
291
            URL[] url = (URL[]) list.toArray(new URL[0]);
288
            URL[] url = list.toArray(new URL[0]);
292
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
289
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
293
            JDBCDriverManager.getDefault().addDriver(driver);
290
            JDBCDriverManager.getDefault().addDriver(driver);
294
        }
291
        }
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java (-17 / +6 lines)
Lines 69-75 Link Here
69
    private File[] jars;
69
    private File[] jars;
70
    private String name;
70
    private String name;
71
    
71
    
72
    public TestCaseContext(HashMap map,String name)  throws Exception{
72
    public TestCaseContext(HashMap<String,Object> map,String name)  throws Exception{
73
        this.name=name;
73
        this.name=name;
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
74
        setProperties((File)map.get(TestCaseDataFactory.DB_PROP));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
75
        setJars((File[])map.get(TestCaseDataFactory.DB_JARS));
Lines 132-138 Link Here
132
        sql_del=getContent(f);
132
        sql_del=getContent(f);
133
    }
133
    }
134
    
134
    
135
    public Map getData(){
135
    public Properties getData(){
136
        return data;
136
        return data;
137
    }
137
    }
138
    
138
    
Lines 148-174 Link Here
148
        jars=f;
148
        jars=f;
149
    }
149
    }
150
    
150
    
151
    private String[] parseContent(File f) throws  Exception{
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
153
        List array=new ArrayList();
154
        String s=null;
155
        while((s=br.readLine())!=null){
156
          array.add(s);
157
        }
158
        if(array.size()==0)
159
            throw new RuntimeException(name+": File "+f.getName()+" doesn't containt the data !");
160
        return (String[])array.toArray(new String[0]);
161
    }
162
    
163
    private  String getContent(File f) throws Exception{
151
    private  String getContent(File f) throws Exception{
164
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
165
        StringBuffer sb=new StringBuffer();
153
        StringBuilder sb=new StringBuilder();
166
        String s=null;
154
        String s;
167
        while((s=br.readLine())!=null){
155
        while((s=br.readLine())!=null){
168
          sb.append(s);
156
          sb.append(s);
169
        }
157
        }
170
        if(sb.length()==0)
158
        if(sb.length()==0) {
171
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
159
            throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
160
        }
172
        return sb.toString();
161
        return sb.toString();
173
    }
162
    }
174
    
163
    
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java (-5 / +8 lines)
Lines 67-73 Link Here
67
    public static String DB_SQLDEL="dbdel.sql";
67
    public static String DB_SQLDEL="dbdel.sql";
68
    public static String DB_JARS="jar";
68
    public static String DB_JARS="jar";
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
69
    public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_TEXT};
70
    private List list=new ArrayList();
70
    private List<TestCaseContext> list=new ArrayList<TestCaseContext>();
71
    private static  TestCaseDataFactory factory;
71
    private static  TestCaseDataFactory factory;
72
    
72
    
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
73
    public static TestCaseDataFactory  getTestCaseFactory() throws Exception{
Lines 101-107 Link Here
101
    
101
    
102
    private void process() throws Exception{
102
    private void process() throws Exception{
103
       File data_dir=getDataDir();
103
       File data_dir=getDataDir();
104
       HashMap map=new HashMap();
104
       HashMap<String,Object> map=new HashMap<String,Object>();
105
       String[] dir=data_dir.list();
105
       String[] dir=data_dir.list();
106
       for(int i=0;i<dir.length;i++){
106
       for(int i=0;i<dir.length;i++){
107
           String dir_name=dir[i];
107
           String dir_name=dir[i];
Lines 110-128 Link Here
110
                
110
                
111
                for(int index=0;index<FILES.length;index++){
111
                for(int index=0;index<FILES.length;index++){
112
                    File f=new File(path+File.separator+FILES[index]);
112
                    File f=new File(path+File.separator+FILES[index]);
113
                    if(!f.exists())
113
                    if(!f.exists()) {
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
114
                        throw new RuntimeException("File called "+FILES[index] +"in directory "+dir_name+"doesn't exist");
115
                    }
115
                    map.put(FILES[index],f);
116
                    map.put(FILES[index],f);
116
                    
117
                    
117
                }
118
                }
118
                String[] s=new File(path).list(new FilenameFilter() {
119
                String[] s=new File(path).list(new FilenameFilter() {
120
                    @Override
119
                    public boolean accept(File dir, String name) {
121
                    public boolean accept(File dir, String name) {
120
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
122
                         return  name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
121
                    }
123
                    }
122
                });
124
                });
123
                if(s.length==0)
125
                if(s.length==0) {
124
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
126
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
125
                ArrayList drivers=new ArrayList();
127
                }
128
                ArrayList<File> drivers=new ArrayList<File>();
126
                for(int myint=0;myint<s.length;myint++){
129
                for(int myint=0;myint<s.length;myint++){
127
                   File file=new File(path+File.separator+s[myint]);
130
                   File file=new File(path+File.separator+s[myint]);
128
                   drivers.add(file);
131
                   drivers.add(file);

Return to bug 214887