/*
 * Copyright 2017 Matthieu Casanova
 *
 * 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.kpouer.eosphoros.light;

import com.kpouer.eosphoros.Eosphoros;
import com.kpouer.eosphoros.message.*;
import com.philips.lighting.hue.sdk.PHHueSDK;
import com.philips.lighting.model.PHLight;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author Matthieu Casanova
 */
public class SelectLight
{
  private static final Logger logger = LoggerFactory.getLogger(SelectLight.class);
  public ListView<Light> lightList;

  @FXML
  public void initialize()
  {
    lightList.setCellFactory(lightDefinition -> new LightCell());
    lightList.setEditable(true);
    lightList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    refresh(null);
  }

  /**
   * Refresh the lights list
   * @param actionEvent
   */
  public void refresh(ActionEvent actionEvent)
  {
    logger.info("refresh");
    PHHueSDK phHueSDK = PHHueSDK.getInstance();
    List<PHLight> allLights = phHueSDK.getSelectedBridge().getResourceCache().getAllLights();
    lightList.getItems()
        .setAll(allLights.stream()
            .filter(PHLight::supportsColor)
            .map(Light::new)
            .toArray(Light[]::new));
  }

  public void select(ActionEvent actionEvent)
  {
    logger.info("select");
    lightList.getItems().filtered(Light::isSelected).toArray();
    LightDefinition[] selectedItems = lightList.getItems().stream()
        .filter(Light::isSelected)
        .map(light -> light.getDefinition())
        .toArray(LightDefinition[]::new);
    Eosphoros.eventBus.post(new SelectedAmbiantLight(selectedItems));
  }

  public void close(ActionEvent actionEvent)
  {
    logger.info("close");
    Eosphoros.eventBus.post(new StartAmbiant());
  }
}

@@ -1168,22 +1168,31 @@
 ass);%0A  
-public
+@FXML%0A  private
  ListVie
@@ -1903,32 +1903,40 @@
 %5B%5D::new));%0A  %7D%0A%0A
+  @FXML%0A
   public void se
@@ -2180,23 +2180,15 @@
 map(
-light -%3E l
+L
 ight
-.
+::
 getD
@@ -2196,18 +2196,16 @@
 finition
-()
 )%0A      
@@ -2315,16 +2315,24 @@
 );%0A  %7D%0A%0A
+  @FXML%0A
   public

Add @FXML annotations