Author: tchemit Date: 2008-01-18 01:51:33 +0000 (Fri, 18 Jan 2008) New Revision: 182 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/SimExplorerMainUI.java Log: surcharge de l'ui principale TODO la gestion du panel content Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/SimExplorerMainUI.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/SimExplorerMainUI.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/SimExplorerMainUI.java 2008-01-18 01:51:33 UTC (rev 182) @@ -0,0 +1,61 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* 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 Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* \#\#% */ +package fr.cemagref.simexplorer.is; + +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUI; +import fr.cemagref.simexplorer.is.ui.swing.actions.ChangeI18nAction; +import org.codelutin.i18n.CountryEnum; +import org.codelutin.i18n.LanguageEnum; + +import javax.swing.AbstractButton; +import java.util.regex.Matcher; + +/** @author tony */ +public class SimExplorerMainUI extends SimExplorerUI { + + public SimExplorerMainUI() { + super(); + + // chargement des classes d'implantations des actions d'ui + SimExplorerActionManager.init(); + + // chargement dans l'ui des actions + SimExplorerActionManager.loadActions(this); + + // repaint i18n actions + repaintI18nActions(); + } + + public void repaintI18nActions() { + LanguageEnum language = SimExplorer.getContext().getConfig().getLanguage(); + CountryEnum country = SimExplorer.getContext().getConfig().getCountry(); + String[] actions = SimExplorerActionManager.getActionNames(); + for (String actionName : actions) { + Matcher matcher = ChangeI18nAction.PATTERN_NAME.matcher(actionName); + if (!matcher.matches()) { + continue; + } + AbstractButton button = (AbstractButton) getObjectById(actionName); + ChangeI18nAction action = (ChangeI18nAction) button.getAction(); + boolean enable = !action.equalsLocale(language, country); + button.setEnabled(enable); + } + } +}