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 (-3 / +4 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-87 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
    public int compareTo(DBColumn refObj) {
85
        if (refObj == null) {
86
        if (refObj == null) {
86
            return -1;
87
            return -1;
87
        }
88
        }
Lines 98-104 Link Here
98
            return -1;
99
            return -1;
99
        }
100
        }
100
101
101
        DBColumn refColumn = (DBColumn) refObj;
102
        DBColumn refColumn = refObj;
102
        refName = refColumn.getName();
103
        refName = refColumn.getName();
103
104
104
        // compare primary keys
105
        // compare primary keys
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactory.java (-1 / +1 lines)
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 / +1 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());
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java (-2 / +2 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 410-416 Link Here
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
412
                    // Check for Constant e.g <NULL>, <DEFAULT>, <CURRENT_TIMESTAMP> etc
413
                    if (DataViewUtils.isSQLConstantString(val)) {
413
                    if (DataViewUtils.isSQLConstantString(val, rsTable.getDBColumn(pos - 1))) {
414
                        continue;
414
                        continue;
415
                    }
415
                    }
416
416
(-)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 (-1 / +1 lines)
Lines 105-111 Link Here
105
105
106
    @Override
106
    @Override
107
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
107
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
108
        if (DataViewUtils.isSQLConstantString(value)) {
108
        if (DataViewUtils.isSQLConstantString(value, null)) {
109
            value = "";
109
            value = "";
110
        }
110
        }
111
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
111
        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/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/util/BasicDateTimePickerUI.java (-11 / +10 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 755-765 Link Here
755
            oldEditor.putClientProperty("doNotCancelPopup", null);
752
            oldEditor.putClientProperty("doNotCancelPopup", null);
756
        }
753
        }
757
        datePicker.add(datePicker.getEditor());
754
        datePicker.add(datePicker.getEditor());
758
        // this is a trick to get hold of the client prop which
755
        datePicker.getEditor().putClientProperty("doNotCancelPopup", 
759
        // prevents closing of the popup
756
                createDoNotCancelPopupClientProperty());
760
        JComboBox box = new JComboBox();
761
        Object preventHide = box.getClientProperty("doNotCancelPopup");
762
        datePicker.getEditor().putClientProperty("doNotCancelPopup", preventHide);
763
757
764
        updateEditorValue();
758
        updateEditorValue();
765
        if (updateListeners) {
759
        if (updateListeners) {
Lines 1606-1610 Link Here
1606
    
1600
    
1607
//------------ utility methods
1601
//------------ utility methods
1608
1602
1609
1603
    private Object createDoNotCancelPopupClientProperty() {
1604
        // this is a trick to get hold of the client prop which
1605
        // prevents closing of the popup
1606
        JComboBox box = new JComboBox();
1607
        return box.getClientProperty("doNotCancelPopup");
1610
}
1608
}
1609
}
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/DataViewUtils.java (-9 / +6 lines)
Lines 277-294 Link Here
277
        String refString = column.getName() + " --> "; // NOI18N
277
        String refString = column.getName() + " --> "; // NOI18N
278
        StringBuilder str = new StringBuilder(refString);
278
        StringBuilder str = new StringBuilder(refString);
279
        DBTable table = column.getParentObject();
279
        DBTable table = column.getParentObject();
280
        List list = table.getForeignKeys();
280
        boolean firstReferencedColumn = false;
281
281
282
        Iterator it = list.iterator();
282
        for(DBForeignKey fk: table.getForeignKeys()) {
283
        while (it.hasNext()) {
284
            DBForeignKey fk = (DBForeignKey) it.next();
285
            if (fk.contains(column)) {
283
            if (fk.contains(column)) {
286
                List pkColumnList = fk.getPKColumnNames();
284
                for(String pkColName: fk.getPKColumnNames()) {
287
                Iterator it1 = pkColumnList.iterator();
288
                while (it1.hasNext()) {
289
                    String pkColName = (String) it1.next();
290
                    str.append(pkColName);
285
                    str.append(pkColName);
291
                    if (it1.hasNext()) {
286
                    if (firstReferencedColumn) {
287
                        firstReferencedColumn = false;
288
                    } else {
292
                        str.append(", "); // NOI18N
289
                        str.append(", "); // NOI18N
293
                    }
290
                    }
294
                }
291
                }
(-)a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java (+1 lines)
Lines 916-921 Link Here
916
        private TodayAction todayAction;
916
        private TodayAction todayAction;
917
        private JXHyperlink todayLink;
917
        private JXHyperlink todayLink;
918
918
919
        @SuppressWarnings("rawtypes")
919
        TodayPanel() {
920
        TodayPanel() {
920
            super(new FlowLayout());
921
            super(new FlowLayout());
921
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
922
            setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, new Color(238, 238, 238), 0, 1, Color.WHITE)));
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java (-4 / +4 lines)
Lines 110-122 Link Here
110
110
111
            TestCaseContext context = DbUtil.getContext();
111
            TestCaseContext context = DbUtil.getContext();
112
            File[] jars = context.getJars();
112
            File[] jars = context.getJars();
113
            ArrayList list = new java.util.ArrayList();
113
            ArrayList<URL> list = new java.util.ArrayList<URL>();
114
            for (int i = 0; i < jars.length; i++) {
114
            for (int i = 0; i < jars.length; i++) {
115
                list.add((URL)jars[i].toURI().toURL());
115
                list.add(jars[i].toURI().toURL());
116
            }
116
            }
117
            URL[] driverURLs = (URL[]) list.toArray(new URL[0]);
117
            URL[] driverURLs = list.toArray(new URL[0]);
118
            URLClassLoader l = new URLClassLoader(driverURLs);
118
            URLClassLoader l = new URLClassLoader(driverURLs);
119
            Class c = Class.forName(driver, true, l);
119
            Class<?> c = Class.forName(driver, true, l);
120
            Driver drv = (Driver) c.newInstance();
120
            Driver drv = (Driver) c.newInstance();
121
            Connection con = drv.connect(url, prop);
121
            Connection con = drv.connect(url, prop);
122
            return con;
122
            return con;
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java (-7 / +7 lines)
Lines 68-85 Link Here
68
    public static String USER = "user";
68
    public static String USER = "user";
69
    public static String PASSWORD = "password";
69
    public static String PASSWORD = "password";
70
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
70
    public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
71
    private static List localConnectionList = new ArrayList();
71
    private static List<Connection> localConnectionList = new ArrayList<Connection>();
72
72
73
    public static DatabaseConnection getDBConnection() {
73
    public static DatabaseConnection getDBConnection() {
74
        try {
74
        try {
75
            TestCaseContext context = getContext();
75
            TestCaseContext context = getContext();
76
            Properties prop = context.getProperties();
76
            Properties prop = context.getProperties();
77
            File[] jars = context.getJars();
77
            File[] jars = context.getJars();
78
            ArrayList list = new java.util.ArrayList();
78
            ArrayList<URL> list = new java.util.ArrayList<URL>();
79
            for (int i = 0; i < jars.length; i++) {
79
            for (int i = 0; i < jars.length; i++) {
80
                list.add((URL)jars[i].toURI().toURL());
80
                list.add(jars[i].toURI().toURL());
81
            }
81
            }
82
            URL[] urls = (URL[]) list.toArray(new URL[0]);
82
            URL[] urls = list.toArray(new URL[0]);
83
            Class.forName(AXION_DRIVER);
83
            Class.forName(AXION_DRIVER);
84
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
84
            JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
85
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
85
            DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
Lines 284-294 Link Here
284
            // if axion db driver not available in db explorer, add it.
284
            // if axion db driver not available in db explorer, add it.
285
            //URL[] url = new URL[1];
285
            //URL[] url = new URL[1];
286
            File[] jars = cxt.getJars();
286
            File[] jars = cxt.getJars();
287
            ArrayList list = new java.util.ArrayList();
287
            ArrayList<URL> list = new java.util.ArrayList<URL>();
288
            for (int i = 0; i < jars.length; i++) {
288
            for (int i = 0; i < jars.length; i++) {
289
                list.add((URL)jars[i].toURI().toURL());
289
                list.add(jars[i].toURI().toURL());
290
            }
290
            }
291
            URL[] url = (URL[]) list.toArray(new URL[0]);
291
            URL[] url = list.toArray(new URL[0]);
292
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
292
            driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
293
            JDBCDriverManager.getDefault().addDriver(driver);
293
            JDBCDriverManager.getDefault().addDriver(driver);
294
        }
294
        }
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java (-4 / +4 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 150-163 Link Here
150
    
150
    
151
    private String[] parseContent(File f) throws  Exception{
151
    private String[] parseContent(File f) throws  Exception{
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
152
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f.getAbsolutePath())));
153
        List array=new ArrayList();
153
        List<String> array=new ArrayList<String>();
154
        String s=null;
154
        String s=null;
155
        while((s=br.readLine())!=null){
155
        while((s=br.readLine())!=null){
156
          array.add(s);
156
          array.add(s);
157
        }
157
        }
158
        if(array.size()==0)
158
        if(array.size()==0)
159
            throw new RuntimeException(name+": File "+f.getName()+" doesn't containt the data !");
159
            throw new RuntimeException(name+": File "+f.getName()+" doesn't containt the data !");
160
        return (String[])array.toArray(new String[0]);
160
        return array.toArray(new String[0]);
161
    }
161
    }
162
    
162
    
163
    private  String getContent(File f) throws Exception{
163
    private  String getContent(File f) throws Exception{
(-)a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java (-3 / +3 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 122-128 Link Here
122
                });
122
                });
123
                if(s.length==0)
123
                if(s.length==0)
124
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
124
                    throw new RuntimeException("the driver doesn't  extist for test case called: "+dir_name);
125
                ArrayList drivers=new ArrayList();
125
                ArrayList<File> drivers=new ArrayList<File>();
126
                for(int myint=0;myint<s.length;myint++){
126
                for(int myint=0;myint<s.length;myint++){
127
                   File file=new File(path+File.separator+s[myint]);
127
                   File file=new File(path+File.separator+s[myint]);
128
                   drivers.add(file);
128
                   drivers.add(file);

Return to bug 214887