Author: tchemit Date: 2008-02-14 15:31:17 +0000 (Thu, 14 Feb 2008) New Revision: 962 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/entities/ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/entities/EntitiesAction.java Log: introduction enum?\195?\169ration pour d?\195?\169finir les diff?\195?\169rentes actions possibles pour chaque type d'objet de l'application Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/entities/EntitiesAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/entities/EntitiesAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/entities/EntitiesAction.java 2008-02-14 15:31:17 UTC (rev 962) @@ -0,0 +1,76 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* 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.entities; + +import fr.cemagref.simexplorer.is.entities.data.Component; +import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication; +import fr.cemagref.simexplorer.is.entities.data.ExplorationData; +import fr.cemagref.simexplorer.is.entities.data.Library; +import fr.cemagref.simexplorer.is.entities.data.Result; +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Une énumération pour définir les actions possibles sur les entités du projet. + * + * @author chemit + */ +public enum EntitiesAction { + + DOWNLOAD(ExplorationApplication.class, Result.class, Library.class), + EXPORT(ExplorationApplication.class, Result.class, Library.class), + IMPORT(ExplorationApplication.class, Library.class), + DELETE(ExplorationApplication.class, ExplorationData.class, Component.class); + + private List<Class<?>> classes; + private List<String> types; + + private EntitiesAction(Class<?>... classes) { + this.classes = Arrays.asList(classes); + this.types = new ArrayList<String>(classes.length); + for (Class<?> aClass : classes) { + this.types.add(aClass.getSimpleName()); + } + } + + public boolean accept(LoggableElementTreeNode node) { + return node != null && node.getUserObject() != null && accept(node.getUserObject().getClass()); + } + + public boolean accept(LoggableElement sNode) { + return sNode!=null && accept(sNode.getClass()); + } + + public boolean accept(MetaData metaData) { + return metaData!=null && accept(metaData.getType()); + } + + public boolean accept(Class<?> klass) { + return klass != null && classes.contains(klass); + } + + public boolean accept(String type) { + return type != null && types.contains(type); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org