/*
 * Copyright 2014 Codenvy, S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.codenvy.ide.ext.datasource.client.editdatasource;

import com.codenvy.ide.ext.datasource.client.DatasourceManager;
import com.codenvy.ide.ext.datasource.shared.DatabaseConfigurationDTO;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionModel;
import com.google.inject.Inject;
import com.google.inject.name.Named;

/**
 * The presenter for the datasource edit/delete datasources dialog.
 * 
 * @author "Mickaël Leduque"
 */
public class EditDatasourcesPresenter implements EditDatasourcesView.ActionDelegate {

    /** The view component. */
    private final EditDatasourcesView                        view;

    /** The component that stores datasources. */
    private final DatasourceManager                          datasourceManager;

    /** the datasource list model component. */
    private final ListDataProvider<DatabaseConfigurationDTO> dataProvider = new ListDataProvider<>();
    private final SelectionModel<DatabaseConfigurationDTO>   selectionModel;

    @Inject
    public EditDatasourcesPresenter(final EditDatasourcesView view,
                                    final DatasourceManager datasourceManager,
                                    final @Named(DatasourceKeyProvider.NAME) DatasourceKeyProvider keyProvider) {
        this.view = view;
        this.datasourceManager = datasourceManager;
        this.view.bindDatasourceModel(dataProvider);
        this.view.setDelegate(this);
        this.selectionModel = new MultiSelectionModel<>(keyProvider);
        this.view.bindSelectionModel(this.selectionModel);
    }

    /** Show dialog. */
    public void showDialog() {
        setupDatasourceList();
        this.view.showDialog();
    }

    @Override
    public void closeDialog() {
        this.view.closeDialog();

    }

    /** Sets the content of the datasource widget. */
    private void setupDatasourceList() {
        this.dataProvider.getList().clear();
        for (DatabaseConfigurationDTO datasource : this.datasourceManager) {
            this.dataProvider.getList().add(datasource);
        }
        this.dataProvider.flush();
    }

    @Override
    public void deleteSelectedDatasources() {
    }

    @Override
    public void editSelectedDatasource() {
    }
}

@@ -900,58 +900,8 @@
 el;%0A
-import com.google.gwt.view.client.SelectionModel;%0A
 impo
@@ -1255,16 +1255,19 @@
         
+   
 view;%0A%0A 
@@ -1376,16 +1376,19 @@
         
+   
 datasour
@@ -1507,16 +1507,19 @@
 tionDTO%3E
+   
  dataPro
@@ -1570,16 +1570,21 @@
 e final 
+Multi
 Selectio
@@ -1615,18 +1615,16 @@
 tionDTO%3E
-  
  selecti

Change known type of selection model in the presenter - #21