@Override public void actionPerformed(ActionEvent e) { try { // check what action happened if (e.getActionCommand() == view.GET_WEATHER_COMMAND) { // get the current selected city from the view (from the combobox) String currentCityAndCountryCode = view.getCurrentCityAndCountryCode(); // get the city-id by using current city and country code (with hashtable) String id = citiesAndIDs.get(currentCityAndCountryCode); // get the service from the factory (singleton) IWeatherDataService service = WeatherDataServiceFactory.getWeatherDataService( WeatherDataServiceFactory.OPEN_WEATHER_MAP); // go to the internet and get the weather data (by city-id) WeatherData data = service.getWeatherData(new Location(id)); // display the weather data model on the screen. view.displayWeatherData(data); } } catch (Exception e1) { // any exception is shown on screen. view.displayError(e1.getMessage()); } }
public void control() { // only display our main window. view.displayMainWindow(); }