Author: echatellier Date: 2013-05-29 16:28:43 +0200 (Wed, 29 May 2013) New Revision: 120 Url: http://forge.codelutin.com/projects/jmexico/repository/revisions/120 Log: fixes #2519 : Add listener to be able to add behaviour before and after scenarios import Added: trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/ImportScenarioListener.java Modified: trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java Added: trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/ImportScenarioListener.java =================================================================== --- trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/ImportScenarioListener.java (rev 0) +++ trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/ImportScenarioListener.java 2013-05-29 14:28:43 UTC (rev 120) @@ -0,0 +1,43 @@ +/* + * #%L + * JMexico :: Swing Editor + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2013 Réseau Mexico, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.reseaumexico.editor; + +/** + * Import scenario listener. + * + * @author echatellier + */ +public interface ImportScenarioListener { + + /** + * Called before scenario import. + */ + void beforeImportScenario(); + + /** + * Called after scenario import. + */ + void afterImportScenario(); +} Property changes on: trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/ImportScenarioListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java =================================================================== --- trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java 2013-05-15 12:29:06 UTC (rev 119) +++ trunk/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java 2013-05-29 14:28:43 UTC (rev 120) @@ -32,6 +32,7 @@ import java.io.File; import java.io.IOException; import java.util.Collection; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -73,6 +74,8 @@ private final InputDesignEditor ui; + protected Collection<ImportScenarioListener> importScenarioListeners = new LinkedList<ImportScenarioListener>(); + public InputDesignEditorHandler(InputDesignEditor ui) { this.ui = ui; } @@ -204,8 +207,20 @@ } } + public void addScenarioImportListener(ImportScenarioListener l) { + importScenarioListeners.add(l); + } + + public void removeScenarioImportListener(ImportScenarioListener l) { + importScenarioListeners.remove(l); + } + public void importScenario() { + for (ImportScenarioListener l : importScenarioListeners) { + l.beforeImportScenario(); + } + InputDesign inputDesign = ui.getInputDesign(); ImportScenarioModel model = new ImportScenarioModel(); @@ -234,6 +249,10 @@ importXMLScenario(factors, importFile, scenarioName); } } + + for (ImportScenarioListener l : importScenarioListeners) { + l.afterImportScenario(); + } } protected void importCSVScenario(List<Factor> factors, File importFile, String scenarioName) {