|  | @@ -163,12 +163,6 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 163 | 163 |              }
 | 
		
	
		
			
			| 164 | 164 |          });
 | 
		
	
		
			
			| 165 | 165 |  
 | 
		
	
		
			
			| 166 |  | -        _listStoredProcedure.addListSelectionListener(e -> {
 | 
		
	
		
			
			| 167 |  | -            if (!e.getValueIsAdjusting()) {
 | 
		
	
		
			
			| 168 |  | -                updateSpSelection();
 | 
		
	
		
			
			| 169 |  | -            }
 | 
		
	
		
			
			| 170 |  | -        });
 | 
		
	
		
			
			| 171 |  | -
 | 
		
	
		
			
			| 172 | 166 |          setupTextField(_textModels, null, true, "Models");
 | 
		
	
		
			
			| 173 | 167 |          setupTextField(_textDataSource, null, false, "Data Source");
 | 
		
	
		
			
			| 174 | 168 |          setupTextField(_textDataSourceTemplate, null, false, "Data Source Template");
 | 
		
	
	
		
			
			|  | @@ -217,19 +211,19 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 217 | 211 |              }
 | 
		
	
		
			
			| 218 | 212 |          });
 | 
		
	
		
			
			| 219 | 213 |  
 | 
		
	
		
			
			| 220 |  | -        _listStoredProcedure.setCellRenderer(new ColoredListCellRenderer() {
 | 
		
	
		
			
			| 221 |  | -            @Override
 | 
		
	
		
			
			| 222 |  | -            protected void customizeCellRenderer(@NotNull JList jList, Object o, int i, boolean b, boolean b1) {
 | 
		
	
		
			
			| 223 |  | -                StoredProcedureSelection spSelection = _options.getSelection().getStoredProcedures().get(i);
 | 
		
	
		
			
			| 224 |  | -                if (spSelection.isSelected()) {
 | 
		
	
		
			
			| 225 |  | -                    setBackground(JBColor.GREEN);
 | 
		
	
		
			
			| 226 |  | -                }
 | 
		
	
		
			
			| 227 |  | -                else {
 | 
		
	
		
			
			| 228 |  | -                    setBackground(JBColor.RED);
 | 
		
	
		
			
			| 229 |  | -                }
 | 
		
	
		
			
			| 230 |  | -                append(spSelection.getStoredProcedure().getText());
 | 
		
	
		
			
			| 231 |  | -            }
 | 
		
	
		
			
			| 232 |  | -        });
 | 
		
	
		
			
			|  | 214 | +//        _listStoredProcedure.setCellRenderer(new ColoredListCellRenderer() {
 | 
		
	
		
			
			|  | 215 | +//            @Override
 | 
		
	
		
			
			|  | 216 | +//            protected void customizeCellRenderer(@NotNull JList jList, Object o, int i, boolean b, boolean b1) {
 | 
		
	
		
			
			|  | 217 | +//                StoredProcedureSelection spSelection = _options.getSelection().getStoredProcedures().get(i);
 | 
		
	
		
			
			|  | 218 | +//                if (spSelection.isSelected()) {
 | 
		
	
		
			
			|  | 219 | +//                    setBackground(JBColor.GREEN);
 | 
		
	
		
			
			|  | 220 | +//                }
 | 
		
	
		
			
			|  | 221 | +//                else {
 | 
		
	
		
			
			|  | 222 | +//                    setBackground(JBColor.RED);
 | 
		
	
		
			
			|  | 223 | +//                }
 | 
		
	
		
			
			|  | 224 | +//                append(spSelection.getStoredProcedure().getText());
 | 
		
	
		
			
			|  | 225 | +//            }
 | 
		
	
		
			
			|  | 226 | +//        });
 | 
		
	
		
			
			| 233 | 227 |  
 | 
		
	
		
			
			| 234 | 228 |          if (dataSources.size() > 0) {
 | 
		
	
		
			
			| 235 | 229 |              _listDatasources.setSelectedIndices(new int[]{0});
 | 
		
	
	
		
			
			|  | @@ -273,7 +267,11 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 273 | 267 |  
 | 
		
	
		
			
			| 274 | 268 |      private void showSource(DataSourceSelection source)
 | 
		
	
		
			
			| 275 | 269 |      {
 | 
		
	
		
			
			|  | 270 | +        for (ListSelectionListener e : _listStoredProcedure.getListSelectionListeners()) {
 | 
		
	
		
			
			|  | 271 | +            _listStoredProcedure.removeListSelectionListener(e);
 | 
		
	
		
			
			|  | 272 | +        }
 | 
		
	
		
			
			| 276 | 273 |          if (source != null) {
 | 
		
	
		
			
			|  | 274 | +
 | 
		
	
		
			
			| 277 | 275 |              List<String> tables = source.getTables().stream().map(t -> t.getTable().getName()).collect(Collectors.toList());
 | 
		
	
		
			
			| 278 | 276 |              _listTables.setListData(tables.toArray(new String[tables.size()]));
 | 
		
	
		
			
			| 279 | 277 |              if (tables.size() > 0) {
 | 
		
	
	
		
			
			|  | @@ -284,6 +282,16 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 284 | 282 |              }
 | 
		
	
		
			
			| 285 | 283 |              List<String> sps = source.getStoredProcedures().stream().map(t -> t.getStoredProcedure().getText()).collect(Collectors.toList());
 | 
		
	
		
			
			| 286 | 284 |              _listStoredProcedure.setListData(sps.toArray(new String[sps.size()]));
 | 
		
	
		
			
			|  | 285 | +            int[] indices = getSpSelectedIndices(source);
 | 
		
	
		
			
			|  | 286 | +            _listStoredProcedure.setSelectedIndices(indices);
 | 
		
	
		
			
			|  | 287 | +
 | 
		
	
		
			
			|  | 288 | +
 | 
		
	
		
			
			|  | 289 | +            _listStoredProcedure.addListSelectionListener(e -> {
 | 
		
	
		
			
			|  | 290 | +                if (!e.getValueIsAdjusting()) {
 | 
		
	
		
			
			|  | 291 | +                    _listStoredProcedure.updateUI();
 | 
		
	
		
			
			|  | 292 | +                    updateSpSelection();
 | 
		
	
		
			
			|  | 293 | +                }
 | 
		
	
		
			
			|  | 294 | +            });
 | 
		
	
		
			
			| 287 | 295 |          }
 | 
		
	
		
			
			| 288 | 296 |          else {
 | 
		
	
		
			
			| 289 | 297 |              _listTables.setListData(new String[]{});
 | 
		
	
	
		
			
			|  | @@ -292,7 +300,19 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 292 | 300 |          }
 | 
		
	
		
			
			| 293 | 301 |      }
 | 
		
	
		
			
			| 294 | 302 |  
 | 
		
	
		
			
			| 295 |  | -    private int[] getSelectedIndices(final TableSelection table)
 | 
		
	
		
			
			|  | 303 | +    private int[] getSpSelectedIndices(final DataSourceSelection dataSource)
 | 
		
	
		
			
			|  | 304 | +    {
 | 
		
	
		
			
			|  | 305 | +        List<StoredProcedureSelection> columns = dataSource.getStoredProcedures();
 | 
		
	
		
			
			|  | 306 | +        List<Integer> indices = new Vector<>();
 | 
		
	
		
			
			|  | 307 | +        for (int i = 0; i < columns.size(); ++i) {
 | 
		
	
		
			
			|  | 308 | +            if (columns.get(i).isSelected()) {
 | 
		
	
		
			
			|  | 309 | +                indices.add(i);
 | 
		
	
		
			
			|  | 310 | +            }
 | 
		
	
		
			
			|  | 311 | +        }
 | 
		
	
		
			
			|  | 312 | +        return indices.stream().mapToInt(Integer::intValue).toArray();
 | 
		
	
		
			
			|  | 313 | +    }
 | 
		
	
		
			
			|  | 314 | +
 | 
		
	
		
			
			|  | 315 | +    private int[] getColumnsSelectedIndices(final TableSelection table)
 | 
		
	
		
			
			| 296 | 316 |      {
 | 
		
	
		
			
			| 297 | 317 |          List<ColumnSelection> columns = table.getColumns();
 | 
		
	
		
			
			| 298 | 318 |          List<Integer> indices = new Vector<>();
 | 
		
	
	
		
			
			|  | @@ -327,7 +347,7 @@ public class GenerateDialog extends DialogWrapper {
 | 
		
	
		
			
			| 327 | 347 |          }
 | 
		
	
		
			
			| 328 | 348 |          if (table != null) {
 | 
		
	
		
			
			| 329 | 349 |              _listColumns.setListData(table.getColumns().stream().map(c -> c.getColumn().getName()).toArray(String[]::new));
 | 
		
	
		
			
			| 330 |  | -            int[] indices = getSelectedIndices(table);
 | 
		
	
		
			
			|  | 350 | +            int[] indices = getColumnsSelectedIndices(table);
 | 
		
	
		
			
			| 331 | 351 |              _listColumns.setSelectedIndices(indices);
 | 
		
	
		
			
			| 332 | 352 |              _listColumns.addListSelectionListener(e -> {
 | 
		
	
		
			
			| 333 | 353 |                  if (!e.getValueIsAdjusting()) {
 |