--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="XEMELIOS-auth-std-db" default="usage" basedir=".">
+ <import file="../../common-tasks.xml"/>
+ <description>Builds, tests, and runs the project XEMELIOS_3 auth-std-db</description>
+ <property file="${user.home}/.ant.properties"/>
+
+ <target name="usage">
+ <echo>
+ Using ${ant.version}
+
+ These are targets supported by this ANT build script:
+
+ compile - compile all .java files, except
+ thoses in ./tmp folder.
+ clean - deletes all compiled and generated
+ files and resources.
+ jars - build jar files.
+
+ Do not call this script directly, use the one located
+ at root of projet (in ../..) instead.
+ </echo>
+ </target>
+
+ <target name="compile" depends="mk-output-dirs,define-compile-debug,prepare">
+ <javac srcdir="java" destdir="build/classes" debug="${compile.debug}" encoding="ISO-8859-1">
+ <classpath>
+ <pathelement path="../core/build/classes"/>
+ <pathelement path="../auth-dgcp/build/classes"/>
+ <pathelement path="../swing-utils/build/classes"/>
+ <pathelement path="../starter/build/classes"/>
+ <fileset dir="../core/lib" includes="*.jar"/>
+ <fileset dir="../swing-utils/lib" includes="*.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="build/classes">
+ <fileset dir="java">
+ <include name="**/*"/>
+ <exclude name="**/*.class"/>
+ <exclude name="**/*.java"/>
+ <exclude name="**/*.form"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="jars" depends="prepare">
+ <copy file="manifest/manifest.txt" tofile="build/manifest.txt">
+ <filterset>
+ <filter token="version" value="${component.release}"/>
+ <filter token="name" value="${component.name}"/>
+ </filterset>
+ </copy>
+ <jar destfile="build/jars/${component.name}.jar" basedir="build/classes" manifest="build/manifest.txt"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+ <target name="config" depends="get-configuration,prepare">
+ <property name="component.dir" value="build/config/source/${component.name}/${component.release}"/>
+ <copy file="component-definition-properties.xml" tofile="build/config/source/component-definition-properties.xml"/>
+ <mkdir dir="${component.dir}"/>
+ <copy todir="${component.dir}">
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ <antcall target="generate-update"/>
+ </target>
+
+ <target name="setup">
+ <copy todir="../../build/setup/root/lib">
+ <fileset dir="build/jars" includes="*.jar"/>
+ </copy>
+ </target>
+
+ <target name="mk-output-dirs">
+ <mkdir dir="build/classes"/>
+ <mkdir dir="build/jars"/>
+ </target>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../../defs/technical-component-definition.xsd">
+ <name>auth-std-db</name>
+ <description>Authentification avancée permettant de gérer les droits finement</description>
+ <release>5.0.0.5</release>
+ <url>http://xemelios.org/updatesV5/auth-std-db</url>
+ <type>COMPOSANT</type>
+ <destination>
+ <base>${xemelios.root}/lib</base>
+ </destination>
+ <requires>
+ <component-ref url="http://xemelios.org/updatesV5/core" release="5.0.0.12"/>
+ <component-ref url="http://xemelios.org/updatesV5/mysql-persistence" release="5.0.0.0"/>
+ <component-ref url="http://xemelios.org/updatesV5/swing-utils" release="5.0.0.0"/>
+ </requires>
+ <release-notes>
+ <release v="5.0.0.5">
+ <note visibility="dev">Déplacement de SimpleXemeliosUserImpl</note>
+ </release>
+ <release v="5.0.0.4">
+ <note visibility="dev">Correction de la création de l'administrateur au premier lancement</note>
+ </release>
+ <release v="5.0.0.3">
+ <note>Correction des ordres de création de table</note>
+ </release>
+ <release v="5.0.0.2">
+ <note>Standardisation des Factory XML</note>
+ </release>
+ </release-notes>
+</component>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth;
+
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui.DlgConfigAuthentication;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.util.Properties;
+
+/**
+ * Permet de configurer l'authentification
+ * @author chm
+ */
+public class CfgAuth {
+ private static final Class[] PARAMETERS = new Class[] { URL.class };
+
+ public static void main(String args[]) {
+ try {
+ File localDir = new File(System.getProperty("user.dir"));
+ // chargement des jars pour reconstituer le classpath
+ File[] jars = localDir.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getName().toLowerCase().endsWith(".jar") && !"auth-std-db.jar".equals(pathname.getName());
+ }
+ });
+ for(File f:jars) addFile(f);
+
+ // dans le cas du swing, il y a des jars dans le repertoire parent
+ jars = localDir.getParentFile().listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getName().toLowerCase().endsWith(".jar") && !"auth-std-db.jar".equals(pathname.getName());
+ }
+ });
+ for(File f:jars) addFile(f);
+
+ StringBuffer notFoundLocations = new StringBuffer();
+ File propertyFile = new File(localDir.getParentFile(),"mysql.properties");
+ if(!propertyFile.exists()) {
+ notFoundLocations.append(propertyFile.getAbsolutePath()).append(",");
+ // dans le cas du batch web, il peut être dans ../conf/mysql.properties
+ propertyFile = new File(new File(localDir.getParentFile(),"conf"),"mysql.properties");
+ }
+ if(!propertyFile.exists()) {
+ notFoundLocations.append(propertyFile.getAbsolutePath()).append(",");
+ notFoundLocations.deleteCharAt(notFoundLocations.length()-1);
+ throw new RuntimeException("Can not find mysql.properties in ("+notFoundLocations.toString()+")");
+ }
+ Properties props = new Properties();
+ Connection con = null;
+ try {
+ props.load(new FileInputStream(propertyFile));
+ PoolManager.getInstance().init(props);
+ Class.forName("fr.gouv.finances.cp.xemelios.data.impl.MySqlDataLayer");
+ con = PoolManager.getInstance().getConnection();
+ ResultSet rs = con.createStatement().executeQuery("SELECT PARAM_VALUE FROM PARAMETERS WHERE PARAM_NAME='authEngineClassName'");
+ String initialEngineName = null;
+ if(rs.next()) {
+ initialEngineName = rs.getString(1);
+ }
+ DlgConfigAuthentication dlg = new DlgConfigAuthentication(null, true,initialEngineName);
+ dlg.run();
+ dlg.dispose();
+ } catch(Exception ex) {
+ throw new RuntimeException(ex);
+ } finally {
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ } catch(Throwable t) {
+ t.printStackTrace();
+ System.exit(1);
+ }
+ }
+ public static void addFile(File f) throws IOException {
+ addURL(f.toURI().toURL());
+ }
+
+ // bitonio trouvé sur le net
+ public static void addURL(URL u) throws IOException {
+ URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+ Class sysclass = URLClassLoader.class;
+
+ try {
+ Method method = sysclass.getDeclaredMethod("addURL", PARAMETERS);
+ method.setAccessible(true); // voyou
+ method.invoke(sysloader, new Object[] { u });
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new IOException("Error, could not add URL to system classloader");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright
+ * 2008 axYus - www.axyus.com
+ * 2008 C.Bosquet - charles.bosquet@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth;
+
+//import fr.gouv.finances.cp.xemelios.auth.dgcp.NewAdmin;
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.common.Crypter;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
+import fr.gouv.finances.dgfip.xemelios.data.utils.jdbc.JdbcUtils;
+import fr.gouv.finances.dgfip.xemelios.data.utils.jdbc.PStmtBinder.SimplePStmtBinderBuilder;
+import fr.gouv.finances.dgfip.xemelios.data.utils.jdbc.RowMapper;
+import fr.gouv.finances.dgfip.xemelios.data.utils.jdbc.RowMapper.ColToIntegerRowMapper;
+import fr.gouv.finances.dgfip.xemelios.data.utils.jdbc.RowMapper.ColToLongRowMapper;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.log4j.Logger;
+
+/**
+ * @author CBO
+ */
+public class DbAuthEngineHelper {
+ private static final transient Logger logger = Logger.getLogger(DbAuthEngineHelper.class);
+
+ static public void checkDBStruct(boolean createAdmin) throws SQLException {
+ Connection connection = null;
+ long count = 0;
+ try {
+ connection = PoolManager.getInstance().getConnection();
+ connection.setAutoCommit(false);
+ // Création des tables :
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_COLLECTIVITE (TID_CODE varchar(20) not null, COL_CLEF varchar(50) not null, COL_LIBELLE varchar(100) not null, primary key (TID_CODE, COL_CLEF)) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_FONCTIONNALITE (FCT_CODE varchar(20) not null, FCT_LIBELLE varchar(100), primary key (FCT_CODE)) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_HAB_COL (UTI_ID int not null, TID_CODE varchar(20) not null, COL_CLEF varchar(50) not null, primary key (TID_CODE, UTI_ID, COL_CLEF), index AUTH_HAB_COL_UTI_FK(UTI_ID), index AUTH_HAB_COL_COL_FK(TID_CODE, COL_CLEF)) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_HAB_DOC (UTI_ID int not null, DOC_CODE varchar(100) not null, primary key (UTI_ID, DOC_CODE), index AUTH_HAB_DOC_UTI_FK(UTI_ID)) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_PRF_FCT (PRF_CODE varchar(20) not null, FCT_CODE varchar(20) not null, primary key (PRF_CODE, FCT_CODE), index AUTH_PRF_FCT_PRF_FK(PRF_CODE), index AUTH_PRF_FCT_FCT_FK(FCT_CODE) ) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_PROFIL (PRF_CODE varchar(20) not null, PRF_LIBELLE varchar(100) not null, primary key (PRF_CODE)) ENGINE MYISAM");
+ count = ((Long)JdbcUtils.queryObject(connection, "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = schema() and upper(table_name) = 'AUTH_UTILISATEUR'", new ColToLongRowMapper()));
+ boolean tableUtilisateurExist = count > 0;
+ if (! tableUtilisateurExist) {
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_UTILISATEUR (UTI_ID int not null AUTO_INCREMENT, UTI_LOGIN varchar(50) not null, UTI_PASSWORD varchar(50), UTI_PRENOM varchar(50), UTI_NOM varchar(50), UTI_ACTIF int not null, UTI_ALL_FONC int not null, UTI_ALL_DOC int not null, UTI_ALL_COL int not null, primary key (UTI_ID), index AUTH_UTI_LOGIN_IDX(UTI_LOGIN)) ENGINE MYISAM");
+ JdbcUtils.executeUpdate(connection, "ALTER TABLE AUTH_UTILISATEUR AUTO_INCREMENT = 10");
+ }
+ JdbcUtils.executeUpdate(connection, "CREATE TABLE IF NOT EXISTS AUTH_UTI_PRF( UTI_ID int not null, PRF_CODE varchar(20) not null, primary key (UTI_ID, PRF_CODE), index AUTH_UTI_PRF_UTI_FK(UTI_ID), index AUTH_UTI_PRF_PRF_FK(PRF_CODE)) ENGINE MYISAM");
+ // Création des fonctionnalités si besoin :
+ long fonctionnaliteCount = (Long)JdbcUtils.queryObject(connection, "SELECT COUNT(*) FROM AUTH_FONCTIONNALITE", new ColToLongRowMapper());
+ if (fonctionnaliteCount <= 0) {
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("CONNECT").add("Connexion").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("SEARCH").add("Recherche").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("BROWSE").add("Navigation").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("IMPORT").add("Import").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("EXPORT").add("Export").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("CLEAN").add("Suppression").toPStmtBinder());
+ JdbcUtils.executeUpdate(connection, "INSERT INTO AUTH_FONCTIONNALITE (FCT_CODE, FCT_LIBELLE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add("USER_ADMIN").add("Administration utilisateurs").toPStmtBinder());
+ }
+ count = ((Long)JdbcUtils.queryObject(connection, "SELECT COUNT(*) FROM AUTH_UTILISATEUR", new ColToLongRowMapper()));
+ connection.commit();
+ } finally {
+ PoolManager.getInstance().releaseConnection(connection);
+ }
+ if(count==0 && createAdmin) {
+ // il faut créer un admin
+ Object na = null;
+ Method run = null;
+ Method getNewLogin = null;
+ Method getNewPassword = null;
+ Object splash = null;
+ Method setVisible = null;
+ try {
+ Class newAdminClass = Class.forName("fr.gouv.finances.cp.xemelios.auth.dgcp.NewAdmin");
+ Constructor cc = newAdminClass.getConstructor(javax.swing.JFrame.class);
+ Object[] parameters = new Object[1];
+ parameters[0] = null;
+ na = cc.newInstance(parameters);
+// NewAdmin na = new NewAdmin(null);
+ run = newAdminClass.getMethod("run");
+ getNewLogin = newAdminClass.getMethod("getNewLogin");
+ getNewPassword = newAdminClass.getMethod("getNewPassword");
+
+ Class clazz = Class.forName("fr.gouv.finances.cp.xemelios.Splash");
+ Field fld = clazz.getField("instance");
+ splash = fld.get(null);
+ if(splash!=null) {
+ Method[] m = clazz.getMethods();
+ for(Method mm:m) {
+ if(mm.getName().equals("setVisible")) {
+ setVisible = mm;
+ break;
+ }
+ }
+ setVisible.invoke(splash, false);
+ }
+ Object ret = run.invoke(na);
+ if(((Boolean)ret).booleanValue()) {
+ String login = (String)getNewLogin.invoke(na);
+ String password = (String)getNewPassword.invoke(na);
+ DataHelper.Profil profil = new DataHelper.Profil("USER_ADMIN", "Administrateur utilisateurs");
+ profil.addFonctionnalite("CONNECT");
+ profil.addFonctionnalite("USER_ADMIN");
+ DataHelper.createProfil(profil);
+ DataHelper.saveProfil(profil);
+ DataHelper.StdUser user = new DataHelper.StdUser();
+ user.setLogin(login);
+ user.setNom(login);
+ ArrayList<Pair> profils = new ArrayList<Pair>();
+ profils.add(new Pair(profil.getCode(),profil.getLibelle()));
+ user.setProfils(profils);
+ DataHelper.saveUser(user, Crypter.cryptPassword(password));
+ DataHelper.saveUserProfils(user);
+ }
+ setVisible.invoke(splash, true);
+ } catch(Throwable t) {
+ logger.error("Impossible de créer un nouvel administrateur", t);
+ }
+ } else {
+ logger.debug("pas de demande de création d'administrateur ou count="+count);
+ }
+ }
+
+ static public void createProfil(Connection connection, String codeProfil, String libelleProfil, String codesFonctionnalite[]) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement("SELECT 1 FROM AUTH_PROFIL WHERE PRF_CODE=?");
+ ps.setString(1, codeProfil);
+ ResultSet rs = ps.executeQuery();
+ if(!rs.next()) {
+ JdbcUtils.executeUpdate(connection,
+ "INSERT INTO AUTH_PROFIL(PRF_CODE, PRF_LIBELLE) VALUES(?, ?)",
+ new SimplePStmtBinderBuilder().add(codeProfil).add(libelleProfil).toPStmtBinder());
+ if (codesFonctionnalite != null) {
+ for (String codeFonctionnalite : codesFonctionnalite) {
+ JdbcUtils.executeUpdate(connection,
+ "INSERT INTO AUTH_PRF_FCT(PRF_CODE, FCT_CODE) VALUES(?, ?)",
+ new SimplePStmtBinderBuilder().add(codeProfil).add(codeFonctionnalite).toPStmtBinder());
+ }
+ }
+ }
+ }
+
+ static public void createUser(Connection connection, long id, String login, String password, String prenom, String nom, boolean allowedToAllFonctionnalites, boolean allowedToAllDocuments, boolean allowedToAllCollectivites, String codesProfil[]) throws SQLException {
+ JdbcUtils.executeUpdate(connection,
+ "INSERT INTO AUTH_UTILISATEUR (UTI_ID, UTI_LOGIN, UTI_PASSWORD, UTI_PRENOM, UTI_NOM, UTI_ALL_FONC, UTI_ALL_DOC, UTI_ALL_COL, UTI_ACTIF) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ new SimplePStmtBinderBuilder().add(id).add(login).add(password).add(prenom).add(nom).add(allowedToAllFonctionnalites).add(allowedToAllDocuments).add(allowedToAllCollectivites).add(1).toPStmtBinder());
+ if (codesProfil != null) {
+ for (String codeProfil : codesProfil) {
+ JdbcUtils.executeUpdate(connection,
+ "INSERT INTO AUTH_UTI_PRF (UTI_ID, PRF_CODE) VALUES (?, ?)",
+ new SimplePStmtBinderBuilder().add(id).add(codeProfil).toPStmtBinder());
+ }
+ }
+ }
+
+ static public boolean userExists(Connection connection, String login) throws SQLException {
+ return ((Integer)JdbcUtils.queryObject(connection, "SELECT COUNT(*) FROM AUTH_UTILISATEUR WHERE UTI_LOGIN = ?", new ColToIntegerRowMapper(), new SimplePStmtBinderBuilder().add(login).toPStmtBinder())).intValue() == 1;
+ }
+
+ static public boolean userHasAllFonctionnalites(Connection connection, String login) throws SQLException {
+ return ((Integer)JdbcUtils.queryObject(connection, "SELECT UTI_ALL_FONC FROM AUTH_UTILISATEUR WHERE UTI_LOGIN = ?", new ColToIntegerRowMapper(), new SimplePStmtBinderBuilder().add(login).toPStmtBinder())).intValue() == 1;
+ }
+
+ static public Collection<String> getFonctionnalitesByLogin(Connection connection, String login) throws SQLException {
+ return JdbcUtils.queryObjects(connection,
+ "SELECT PF.FCT_CODE FROM AUTH_UTILISATEUR U INNER JOIN AUTH_UTI_PRF UP ON U.UTI_ID = UP.UTI_ID INNER JOIN AUTH_PRF_FCT PF ON UP.PRF_CODE = PF.PRF_CODE WHERE U.UTI_LOGIN = ?",
+ new RowMapper.ColToStringRowMapper(),
+ new SimplePStmtBinderBuilder().add(login).toPStmtBinder());
+ }
+
+ static public boolean userHasAllCollectivites(Connection connection, String login) throws SQLException {
+ return ((Integer)JdbcUtils.queryObject(connection, "SELECT UTI_ALL_COL FROM AUTH_UTILISATEUR WHERE UTI_LOGIN = ?", new ColToIntegerRowMapper(), new SimplePStmtBinderBuilder().add(login).toPStmtBinder())).intValue() == 1;
+ }
+
+ static public Collection<Collectivite> getCollectivitesByLogin(Connection connection, String login) throws SQLException {
+ return JdbcUtils.queryObjects(connection,
+ "SELECT DISTINCT HB.TID_CODE, HB.COL_CLEF FROM AUTH_HAB_COL HB INNER JOIN AUTH_UTILISATEUR U ON HB.UTI_ID = U.UTI_ID WHERE U.UTI_LOGIN = ?",
+ new RowMapper() {
+
+ @Override
+ public Object map(ResultSet rs) throws SQLException {
+ return new Collectivite(rs.getString(1),rs.getString(2));
+ }
+ },
+ new SimplePStmtBinderBuilder().add(login).toPStmtBinder());
+ }
+
+ static public boolean userHasAllDocuments(Connection connection, String login) throws SQLException {
+ return ((Integer)JdbcUtils.queryObject(connection, "SELECT UTI_ALL_DOC FROM AUTH_UTILISATEUR WHERE UTI_LOGIN = ?", new ColToIntegerRowMapper(), new SimplePStmtBinderBuilder().add(login).toPStmtBinder())).intValue() == 1;
+ }
+
+ static public Collection<String> getDocumentsByLogin(Connection connection, String login) throws SQLException {
+ return JdbcUtils.queryObjects(connection,
+ "SELECT DISTINCT HD.DOC_CODE FROM AUTH_HAB_DOC HD INNER JOIN AUTH_UTILISATEUR U ON HD.UTI_ID = U.UTI_ID WHERE U.UTI_LOGIN = ?",
+ new RowMapper.ColToStringRowMapper(),
+ new SimplePStmtBinderBuilder().add(login).toPStmtBinder());
+ }
+
+ static public String getDisplayName(Connection connection, String login) throws SQLException {
+ return (String)JdbcUtils.queryObject(connection,
+ "SELECT UTI_LOGIN, UTI_PRENOM, UTI_NOM AUTH_UTILISATEUR WHERE U.UTI_LOGIN = ?",
+ new RowMapper() {
+
+ @Override
+ public Object map(ResultSet rs) throws SQLException {
+ if (rs.getString("UTI_PRENOM") != null && rs.getString("UTI_NOM") != null) {
+ return rs.getString("UTI_PRENOM") + " " + rs.getString("UTI_NOM");
+ } else if (rs.getString("UTI_PRENOM") != null) {
+ return rs.getString("UTI_PRENOM");
+ } else if (rs.getString("UTI_NOM") != null) {
+ return rs.getString("UTI_NOM");
+ } else {
+ return rs.getString("UTI_LOGIN");
+ }
+ }
+
+ },
+ new SimplePStmtBinderBuilder().add(login).toPStmtBinder());
+ }
+
+ static public boolean authenticate(Connection connection, String login, String password) throws SQLException {
+ return JdbcUtils.queryObject(connection,
+ "SELECT 'OK' FROM AUTH_UTILISATEUR WHERE UTI_LOGIN = ? AND UTI_PASSWORD = ? AND UTI_ACTIF = ?",
+ new RowMapper.ColToStringRowMapper(),
+ new SimplePStmtBinderBuilder().add(login).add(Crypter.cryptPassword(password)).add(1).toPStmtBinder()) != null;
+ }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db;
+
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.xemelios.auth.Collectivite;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.log4j.Logger;
+/**
+ *
+ * @author chm
+ */
+public class DataHelper {
+ private static final Logger logger = Logger.getLogger(DataHelper.class);
+
+ public static ArrayList<Profil> getProfils() {
+ ArrayList<Profil> ret = new ArrayList<Profil>();
+ Connection con = null;
+ Statement st = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ st = con.createStatement();
+ ResultSet rs1 = st.executeQuery("SELECT PRF_CODE, PRF_LIBELLE FROM AUTH_PROFIL");
+ ps = con.prepareStatement("SELECT FCT_CODE FROM AUTH_PRF_FCT WHERE PRF_CODE=?");
+ while(rs1.next()) {
+ Profil p = new Profil(rs1.getString(1),rs1.getString(2));
+ ps.setString(1, p.getCode());
+ ResultSet rs2 = ps.executeQuery();
+ while(rs2.next()) p.addFonctionnalite(rs2.getString(1));
+ rs2.close();
+ ret.add(p);
+ }
+ rs1.close();
+ } catch(SQLException sqlEx) {
+ logger.error("getProfils()",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+ public static List<Pair> getProfilsAsPair() {
+ ArrayList<Pair> ret = new ArrayList<Pair>();
+ Connection con = null;
+ Statement st = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ st = con.createStatement();
+ ResultSet rs1 = st.executeQuery("SELECT PRF_CODE, PRF_LIBELLE FROM AUTH_PROFIL");
+ while(rs1.next()) {
+ Pair p = new Pair(rs1.getString(1),rs1.getString(2));
+ ret.add(p);
+ }
+ rs1.close();
+ } catch(SQLException sqlEx) {
+ logger.error("getProfilsAsPair()",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+
+ public static void saveProfil(Profil profil) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("DELETE FROM AUTH_PRF_FCT WHERE PRF_CODE=?");
+ ps.setString(1, profil.getCode());
+ ps.executeUpdate();
+ ps = con.prepareStatement("INSERT INTO AUTH_PRF_FCT (PRF_CODE, FCT_CODE) VALUES (?,?)");
+ ps.setString(1,profil.getCode());
+ for(String fonct:profil.getFonctionnalites()) {
+ ps.setString(2,fonct);
+ ps.executeUpdate();
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("saveProfil(Profil)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static boolean removeProfil(Profil profil) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT * FROM AUTH_UTI_PRF WHERE PRF_CODE=?");
+ ps.setString(1, profil.getCode());
+ ResultSet rs = ps.executeQuery();
+ if(rs.next()) {
+ return false;
+ }
+ ps = con.prepareStatement("DELETE FROM AUTH_UTI_PRF WHERE PRF_CODE=?");
+ ps.setString(1,profil.getCode());
+ ps.executeUpdate();
+ ps = con.prepareStatement("DELETE FROM AUTH_PRF_FCT WHERE PRF_CODE=?");
+ ps.setString(1,profil.getCode());
+ ps.executeUpdate();
+ ps = con.prepareStatement("DELETE FROM AUTH_PROFIL WHERE PRF_CODE=?");
+ ps.setString(1,profil.getCode());
+ ps.executeUpdate();
+ } catch(SQLException sqlEx) {
+ logger.error("saveProfil(Profil)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return true;
+ }
+ public static boolean createProfil(Profil profil) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT * FROM AUTH_PROFIL WHERE PRF_CODE=?");
+ ps.setString(1, profil.getCode());
+ ResultSet rs = ps.executeQuery();
+ if(rs.next()) {
+ return false;
+ }
+ ps = con.prepareStatement("INSERT INTO AUTH_PROFIL (PRF_CODE,PRF_LIBELLE) VALUES (?,?)");
+ ps.setString(1,profil.getCode());
+ ps.setString(2,profil.getLibelle());
+ ps.executeUpdate();
+ } catch(SQLException sqlEx) {
+ logger.error("createProfil(Profil)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return true;
+ }
+ public static ArrayList<StdUser> getUsers(String pattern) {
+ ArrayList<StdUser> ret = new ArrayList<StdUser>();
+ String liker = transformPatternToSql(pattern);
+ Connection con = null;
+ Statement st = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT UTI_LOGIN, UTI_NOM, UTI_PRENOM,UTI_ALL_FONC,UTI_ALL_DOC, UTI_ALL_COL, UTI_ID FROM AUTH_UTILISATEUR WHERE UTI_LOGIN LIKE ? OR UTI_NOM LIKE ? OR UTI_PRENOM LIKE ?");
+ ps.setString(1,liker);
+ ps.setString(2,liker);
+ ps.setString(3,liker);
+ ResultSet rs = ps.executeQuery();
+ while(rs.next()) {
+ StdUser p = new StdUser(rs.getString(1),rs.getString(2),rs.getString(3),rs.getBoolean(4),rs.getBoolean(5),rs.getBoolean(6), rs.getInt(7));
+ ret.add(p);
+ }
+ rs.close();
+ } catch(SQLException sqlEx) {
+ logger.error("getUsers()",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+ public static void saveUser(StdUser user) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("UPDATE AUTH_UTILISATEUR SET UTI_LOGIN=?, UTI_NOM=?, UTI_PRENOM=?, UTI_ALL_FONC=?, UTI_ALL_DOC=?, UTI_ALL_COL=? WHERE UTI_ID=?");
+ ps.setString(1, user.getLogin());
+ ps.setString(2, user.getNom());
+ ps.setString(3,user.getPrenom());
+ ps.setInt(4, user.isAllFonctionalities()?1:0);
+ ps.setInt(5, user.isAlldocuments()?1:0);
+ ps.setInt(6, user.isAllCollectivites()?1:0);
+ ps.setLong(7,user.getId());
+ ps.executeUpdate();
+ } catch(SQLException sqlEx) {
+ logger.error("saveUser(StdUser)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static void saveUser(StdUser user, String password) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ if(user.getId()>-1) {
+ ps = con.prepareStatement("UPDATE AUTH_UTILISATEUR SET UTI_LOGIN=?, UTI_NOM=?, UTI_PRENOM=?, UTI_ALL_FONC=?, UTI_ALL_DOC=?, UTI_ALL_COL=?, UTI_PASSWORD=? WHERE UTI_ID=?");
+ ps.setString(1, user.getLogin());
+ ps.setString(2, user.getNom());
+ ps.setString(3,user.getPrenom());
+ ps.setInt(4, user.isAllFonctionalities()?1:0);
+ ps.setInt(5, user.isAlldocuments()?1:0);
+ ps.setInt(6, user.isAllCollectivites()?1:0);
+ ps.setString(7, password);
+ ps.setLong(8,user.getId());
+ ps.executeUpdate();
+ } else {
+ ps = con.prepareStatement("INSERT INTO AUTH_UTILISATEUR (UTI_LOGIN,UTI_NOM,UTI_PRENOM,UTI_ALL_FONC,UTI_ALL_DOC,UTI_ALL_COL,UTI_PASSWORD,UTI_ACTIF) VALUES (?,?,?,?,?,?,?,1)");
+ ps.setString(1, user.getLogin());
+ ps.setString(2, user.getNom());
+ ps.setString(3,user.getPrenom());
+ ps.setInt(4, user.isAllFonctionalities()?1:0);
+ ps.setInt(5, user.isAlldocuments()?1:0);
+ ps.setInt(6, user.isAllCollectivites()?1:0);
+ ps.setString(7, password);
+ ps.executeUpdate();
+ ps.close();
+ ps = con.prepareStatement("SELECT MAX(UTI_ID) FROM AUTH_UTILISATEUR WHERE UTI_LOGIN=?");
+ ps.setString(1,user.getLogin());
+ ResultSet rs = ps.executeQuery();
+ if(rs.next()) user.setId(rs.getLong(1));
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("saveUser(StdUser,String)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static void removeUser(StdUser user) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("DELETE FROM AUTH_UTI_PRF WHERE UTI_ID=?");
+ ps.setLong(1,user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("DELETE FROM AUTH_HAB_COL WHERE UTI_ID=?");
+ ps.setLong(1,user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("DELETE FROM AUTH_HAB_DOC WHERE UTI_ID=?");
+ ps.setLong(1,user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("DELETE FROM AUTH_UTILISATEUR WHERE UTI_ID=?");
+ ps.setLong(1,user.getId());
+ ps.executeUpdate();
+ } catch(SQLException sqlEx) {
+ logger.error("removeUser(StdUser)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static List<Pair> getUserProfils(long userId) {
+ ArrayList<Pair> ret = new ArrayList<Pair>();
+ Connection con = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT UTI.PRF_CODE, PRF.PRF_LIBELLE FROM AUTH_UTI_PRF UTI LEFT JOIN AUTH_PROFIL PRF ON UTI.PRF_CODE=PRF.PRF_CODE WHERE UTI.UTI_ID=?");
+ ps.setLong(1,userId);
+ ResultSet rs = ps.executeQuery();
+ while(rs.next()) {
+ ret.add(new Pair(rs.getString(1),rs.getString(2)));
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("getUserProfils(String)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+ public static List<Pair> getUserDocuments(long userId) {
+ ArrayList<Pair> ret = new ArrayList<Pair>();
+ Connection con = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT DOC_CODE FROM AUTH_HAB_DOC WHERE UTI_ID=?");
+ ps.setLong(1,userId);
+ ResultSet rs = ps.executeQuery();
+ while(rs.next()) {
+ ret.add(new Pair(rs.getString(1),rs.getString(1)));
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("getUserDocuments(String)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+ public static ArrayList<CollectiviteLib> getUserCollectivites(long userId) {
+ ArrayList<CollectiviteLib> ret = new ArrayList<CollectiviteLib>();
+ Connection con = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT HAB.TID_CODE, HAB.COL_CLEF, COLL.COL_LIBELLE FROM AUTH_HAB_COL HAB LEFT JOIN AUTH_COLLECTIVITE COLL ON HAB.TID_CODE=COLL.TID_CODE AND HAB.COL_CLEF=COLL.COL_CLEF WHERE UTI_ID=?");
+ ps.setLong(1,userId);
+ ResultSet rs = ps.executeQuery();
+ while(rs.next()) {
+ ret.add(new CollectiviteLib(rs.getString(1),rs.getString(2),rs.getString(3)));
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("getUserCollectivites(long)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return ret;
+ }
+ public static void createCollectivite(CollectiviteLib coll) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("INSERT INTO AUTH_COLLECTIVITE (TID_CODE,COL_CLEF,COL_LIBELLE) VALUES (?,?,?)");
+ ps.setString(1,coll.getNatureIdentifiant());
+ ps.setString(2,coll.getClef());
+ ps.setString(3,coll.getLibelle());
+ ps.executeUpdate();
+ } catch(SQLException sqlEx) {
+ logger.error("createCollectivite(CollectiviteLib)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+
+ }
+ public static void updateCollectivite(CollectiviteLib coll) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ ResultSet rs;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT 1 FROM AUTH_COLLECTIVITE WHERE TID_CODE=? AND COL_CLEF=?");
+ ps.setString(1,coll.getNatureIdentifiant());
+ ps.setString(2,coll.getClef());
+ rs = ps.executeQuery();
+ if(rs.next()) {
+ ps = con.prepareStatement("UPDATE AUTH_COLLECTIVITE SET COL_LIBELLE=? WHERE TID_CODE=? AND COL_CLEF=?");
+ ps.setString(1,coll.getLibelle());
+ ps.setString(2,coll.getNatureIdentifiant());
+ ps.setString(3,coll.getClef());
+ ps.executeUpdate();
+ } else {
+ ps = con.prepareStatement("INSERT INTO AUTH_COLLECTIVITE (TID_CODE,COL_CLEF,COL_LIBELLE) VALUES (?,?,?)");
+ ps.setString(1,coll.getNatureIdentifiant());
+ ps.setString(2,coll.getClef());
+ ps.setString(3,coll.getLibelle());
+ ps.executeUpdate();
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("updateCollectivite(CollectiviteLib)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+
+ }
+ public static CollectiviteResponse searchCollectivites(String natureIdentifiant, String code, String libelle, int page, int rowsPerPage) {
+ ArrayList<DataHelper.CollectiviteLib> ret = new ArrayList<DataHelper.CollectiviteLib>();
+ Connection con = null;
+ PreparedStatement ps = null;
+ int foundRows = 0;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ StringBuffer sb = new StringBuffer();
+ sb.append("SELECT SQL_CALC_FOUND_ROWS TID_CODE, COL_CLEF, COL_LIBELLE FROM AUTH_COLLECTIVITE WHERE");
+ if(!"*".equals(natureIdentifiant)) {
+ sb.append(" TID_CODE=? AND");
+ }
+ if(code!=null) {
+ sb.append(" COL_CLEF LIKE ? AND");
+ }
+ if(libelle!=null) {
+ sb.append(" COL_LIBELLE LIKE ? AND");
+ }
+ if(sb.toString().endsWith(" AND")) {
+ sb.delete(sb.length()-4, sb.length());
+ }
+ if(sb.toString().endsWith(" WHERE")) {
+ sb.delete(sb.length()-6, sb.length());
+ }
+ sb.append(" ORDER BY 1, 2, 3 LIMIT ").append(page*rowsPerPage).append(", ").append(rowsPerPage);
+ logger.debug(sb.toString());
+ ps = con.prepareStatement(sb.toString());
+ int pos = 1;
+ if(!"*".equals(natureIdentifiant)) {
+ ps.setString(pos++,natureIdentifiant);
+ }
+ if(code!=null) {
+ ps.setString(pos++,transformPatternToSql(code));
+ }
+ if(libelle!=null) {
+ ps.setString(pos++,transformPatternToSql(libelle));
+ }
+ ResultSet rs = ps.executeQuery();
+ while(rs.next()) {
+ ret.add(new CollectiviteLib(rs.getString(1),rs.getString(2),rs.getString(3)));
+ }
+ rs = rs.getStatement().getConnection().createStatement().executeQuery("SELECT FOUND_ROWS()");
+ rs.next();
+ foundRows = rs.getInt(1);
+ } catch(SQLException sqlEx) {
+ logger.error("searchCollectivites(String,String,String,int,int)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ return new CollectiviteResponse(ret,foundRows);
+ }
+ public static void saveUserProfils(StdUser user) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("DELETE FROM AUTH_UTI_PRF WHERE UTI_ID=?");
+ ps.setLong(1, user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("INSERT INTO AUTH_UTI_PRF (UTI_ID, PRF_CODE) VALUES (?,?)");
+ ps.setLong(1,user.getId());
+ for(Pair p:user.getProfils()) {
+ ps.setString(2,p.key);
+ ps.executeUpdate();
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("saveUserProfil(StdUser)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static void saveUserDocuments(StdUser user) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("DELETE FROM AUTH_HAB_DOC WHERE UTI_ID=?");
+ ps.setLong(1, user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("INSERT INTO AUTH_HAB_DOC (UTI_ID, DOC_CODE) VALUES (?,?)");
+ ps.setLong(1,user.getId());
+ for(Pair p:user.getDocuments()) {
+ ps.setString(2,p.key);
+ ps.executeUpdate();
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("saveUserDocuments(StdUser)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ public static void saveUserCollectivites(StdUser user) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ Statement st = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("DELETE FROM AUTH_HAB_COL WHERE UTI_ID=?");
+ ps.setLong(1, user.getId());
+ ps.executeUpdate();
+ ps = con.prepareStatement("INSERT INTO AUTH_HAB_COL (UTI_ID, TID_CODE, COL_CLEF) VALUES (?,?,?)");
+ ps.setLong(1,user.getId());
+ for(CollectiviteLib col:user.getCollectivites()) {
+ ps.setString(2,col.natureIdentifiant);
+ ps.setString(3,col.clef);
+ ps.executeUpdate();
+ }
+ } catch(SQLException sqlEx) {
+ logger.error("saveUserCollectivites(StdUser)",sqlEx);
+ } finally {
+ if(ps!=null) {
+ try {
+ ps.clearParameters();
+ ps.close();
+ } catch(Throwable t) {}
+ }
+ if(st!=null) {
+ try {
+ st.close();
+ } catch(Throwable t) {}
+ }
+ if(con!=null) PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+
+ public static class Profil implements Comparable {
+ private String code, libelle;
+ private ArrayList<String> fonctionnalites;
+
+ public Profil(String code, String libelle) {
+ super();
+ this.code=code;
+ this.libelle=libelle;
+ fonctionnalites = new ArrayList<String>();
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public ArrayList<String> getFonctionnalites() {
+ return fonctionnalites;
+ }
+
+ public void addFonctionnalite(String fonct) {
+ this.fonctionnalites.add(fonct);
+ }
+
+ public String getLibelle() {
+ return libelle;
+ }
+
+ public void setLibelle(String libelle) {
+ this.libelle = libelle;
+ }
+ @Override
+ public String toString() {
+ return libelle.concat(" (").concat(code).concat(")");
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ if(o instanceof Profil) {
+ return getCode().compareTo(((Profil)o).getCode());
+ }
+ return -1;
+ }
+ }
+
+ public static class StdUser implements Comparable {
+ private String login, prenom, nom;
+ private boolean allFonctionalities, alldocuments, allCollectivites;
+ private long id = -1;
+ private List<Pair> profils = null;
+ private ArrayList<CollectiviteLib> collectivites = null;
+ private List<Pair> documents = null;
+ public StdUser() {
+ super();
+ }
+ public StdUser(String login, String nom, String prenom, boolean allFonctionnalities, boolean allDocuments, boolean allCollectivites, long id) {
+ this();
+ this.login=login;
+ this.prenom=prenom;
+ this.nom=nom;
+ this.allCollectivites=allCollectivites;
+ this.allFonctionalities=allFonctionnalities;
+ this.alldocuments=allDocuments;
+ this.id=id;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return login.compareTo(((StdUser)o).login);
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer ret = new StringBuffer();
+ if(prenom!=null) ret.append(prenom).append(" ");
+ if(nom!=null) ret.append(nom).append(" ");
+ if(login!=null) {
+ if(prenom!=null || nom!=null) ret.append("(");
+ ret.append(login);
+ if(prenom!=null || nom!=null) ret.append(")");
+ } else {
+ ret.append("<non définit>");
+ }
+ return ret.toString();
+ }
+
+ public boolean isAllCollectivites() {
+ return allCollectivites;
+ }
+
+ public void setAllCollectivites(boolean allCollectivites) {
+ this.allCollectivites = allCollectivites;
+ }
+
+ public boolean isAllFonctionalities() {
+ return allFonctionalities;
+ }
+
+ public void setAllFonctionalities(boolean allFonctionalities) {
+ this.allFonctionalities = allFonctionalities;
+ }
+
+ public boolean isAlldocuments() {
+ return alldocuments;
+ }
+
+ public void setAlldocuments(boolean alldocuments) {
+ this.alldocuments = alldocuments;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public String getNom() {
+ return nom;
+ }
+
+ public void setNom(String nom) {
+ this.nom = nom;
+ }
+
+ public String getPrenom() {
+ return prenom;
+ }
+
+ public void setPrenom(String prenom) {
+ this.prenom = prenom;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public ArrayList<CollectiviteLib> getCollectivites() {
+ if(collectivites==null) {
+ setCollectivites(getUserCollectivites(id));
+ }
+ return collectivites;
+ }
+
+ public void setCollectivites(ArrayList<CollectiviteLib> collectivites) {
+ this.collectivites = collectivites;
+ }
+
+ public List<Pair> getDocuments() {
+ if(documents==null) {
+ documents = getUserDocuments(getId());
+ }
+ return documents;
+ }
+
+ public void setDocuments(List<Pair> documents) {
+ this.documents = documents;
+ }
+
+ public List<Pair> getProfils() {
+ if(profils==null) {
+ profils = getUserProfils(getId());
+ }
+ return profils;
+ }
+
+ public void setProfils(List<Pair> profils) {
+ this.profils = profils;
+ }
+ }
+ public static class CollectiviteLib implements Comparable {
+ private String natureIdentifiant;
+ private String clef;
+ private String libelle;
+
+ public CollectiviteLib (String natureIdentifiant, String clef, String libelle) {
+ super();
+ this.natureIdentifiant=natureIdentifiant;
+ this.clef=clef;
+ this.libelle=libelle;
+ }
+
+ public String getClef() {
+ return clef;
+ }
+
+ public String getLibelle() {
+ return libelle;
+ }
+
+ public String getNatureIdentifiant() {
+ return natureIdentifiant;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ if(o instanceof CollectiviteLib) {
+ CollectiviteLib other = (CollectiviteLib) o;
+ return other.natureIdentifiant.compareTo(natureIdentifiant) + other.clef.compareTo(clef);
+ } else if(o instanceof Collectivite) {
+ Collectivite other = (Collectivite)o;
+ return other.getNatureIdentifiant().compareTo(natureIdentifiant) + other.getCollectivite().compareTo(clef);
+ } else return -1;
+ }
+ }
+ public static class CollectiviteResponse {
+ private ArrayList<CollectiviteLib> data;
+ private int foundRecords;
+ public CollectiviteResponse(ArrayList<CollectiviteLib> data, int foundRows) {
+ super();
+ this.data=data;
+ this.foundRecords=foundRows;
+ }
+
+ public ArrayList<CollectiviteLib> getData() {
+ return data;
+ }
+
+ public int getFoundRecords() {
+ return foundRecords;
+ }
+ }
+ private static String transformPatternToSql(String pattern) {
+ StringBuilder sb = new StringBuilder();
+ boolean containsMatcher = false;
+ for(char c:pattern.toCharArray()) {
+ switch(c) {
+ case '\'': {
+ sb.append("''");
+ break;
+ }
+ case '*': {
+ sb.append("%");
+ containsMatcher = true;
+ break;
+ }
+ case '_': {
+ sb.append("\\_");
+ break;
+ }
+ case '?': {
+ sb.append("_");
+ containsMatcher=true;
+ break;
+ }
+ case '%': {
+ sb.append("\\%");
+ break;
+ }
+ case '\\': {
+ sb.append("\\\\");
+ break;
+ }
+ default: sb.append(c);
+ }
+ }
+ //return pattern.replaceAll("'", "''").replaceAll("*", "%").replaceAll("?", "_");
+ if(!containsMatcher) {
+ sb.insert(0, "%").append("%");
+ }
+ return sb.toString();
+ }
+}
--- /dev/null
+/*
+ * Copyright
+ * 2008 axYus - www.axyus.com
+ * 2008 C.Bosquet - charles.bosquet@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.AuthEngine;
+import fr.gouv.finances.dgfip.xemelios.auth.DbAuthEngineHelper;
+import fr.gouv.finances.dgfip.xemelios.auth.XemeliosUser;
+import fr.gouv.finances.dgfip.xemelios.auth.SimpleXemeliosUserImpl;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui.DlgAdmin;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.SQLRuntimeException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+
+/**
+ * @author CBO
+ */
+public class StdDbAuthEngineImpl implements AuthEngine {
+
+ public static final String ROLE_ADMIN = "USER_ADMIN";
+
+ public StdDbAuthEngineImpl(boolean createAdmin) throws SQLException {
+ DbAuthEngineHelper.checkDBStruct(createAdmin);
+ }
+ public StdDbAuthEngineImpl() throws SQLException {
+ DbAuthEngineHelper.checkDBStruct(true);
+ }
+
+ @Override
+ public boolean isLoginRequired() {
+ return true;
+ }
+
+ @Override
+ public boolean isPasswordRequired() {
+ return true;
+ }
+
+ @Override
+ public XemeliosUser createUser(String login, String password) {
+ Connection connection = null;
+ try {
+ connection = PoolManager.getInstance().getConnection();
+ if (DbAuthEngineHelper.authenticate(connection, login, password)) {
+ XemeliosUser ret = doCreateUser(connection, login);
+
+ return ret;
+ } else {
+ return null;
+ }
+ } catch (SQLException sqle) {
+ throw new SQLRuntimeException(sqle);
+ } finally {
+ PoolManager.getInstance().releaseConnection(connection);
+ }
+ }
+
+ protected XemeliosUser doCreateUser(Connection connection, String login) throws SQLException {
+ if(!DbAuthEngineHelper.userExists(connection, login) ) {
+ return null;
+ }
+
+
+ XemeliosUser ret = new SimpleXemeliosUserImpl(login, login,
+ DbAuthEngineHelper.userHasAllFonctionnalites(connection, login),
+ DbAuthEngineHelper.getFonctionnalitesByLogin(connection, login),
+ DbAuthEngineHelper.userHasAllDocuments(connection, login),
+ DbAuthEngineHelper.getDocumentsByLogin(connection, login),
+ DbAuthEngineHelper.userHasAllCollectivites(connection, login),
+ DbAuthEngineHelper.getCollectivitesByLogin(connection, login));
+
+ if (ret !=null && ret.hasRole(XemeliosUser.ROLE_CONNECT) && ret.hasRole(ROLE_ADMIN)) {
+ insertAdminMenu();
+ }
+ return ret;
+
+
+
+ }
+
+ protected void insertAdminMenu() {
+ boolean doNotStop = false;
+ Class clazz = null;
+ Object instance = null;
+ try {
+ clazz = Class.forName("fr.gouv.finances.cp.xemelios.ui.MainWindow");
+ Method meth = clazz.getMethod("getInstance");
+ instance = meth.invoke(null);
+ doNotStop = (instance != null);
+ } catch (Throwable t) {
+ }
+ if (doNotStop) {
+ final Object inst = instance;
+ Object obj = null;
+ try {
+ Method meth = clazz.getMethod("getEnvProperties");
+ obj = meth.invoke(inst);
+ } catch(NoSuchMethodException nsEx) {
+ throw new RuntimeException(nsEx);
+ } catch(IllegalAccessException iaEx) {
+ throw new RuntimeException(iaEx);
+ } catch(InvocationTargetException itEx) {
+ throw new RuntimeException(itEx);
+ }
+ final PropertiesExpansion applicationProperties = (PropertiesExpansion)obj;
+ JMenu adminMenu = new JMenu("Administration");
+ JMenuItem item = new JMenuItem("Gestion des utlisateurs...");
+ item.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ DlgAdmin dlg = new DlgAdmin((JFrame) inst, applicationProperties);
+ dlg.setVisible(true);
+ }
+ });
+ adminMenu.add(item);
+ JMenuBar mBar = null;
+ try {
+ Method meth2 = clazz.getMethod("getJMenuBar");
+ mBar = (JMenuBar) meth2.invoke(inst);
+ } catch (Throwable t) {
+ }
+ if (mBar != null) {
+ int mnuCount = mBar.getMenuCount();
+ JMenu helpMenu = mBar.getMenu(mnuCount - 1);
+ mBar.add(adminMenu);
+ mBar.add(helpMenu);
+ try {
+ Method meth2 = clazz.getMethod("setJMenuBar", JMenuBar.class);
+ meth2.invoke(inst, mBar);
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="tab" alignment="0" pref="519" max="32767" attributes="0"/>
+ <Component id="pbClose" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="tab" min="-2" pref="358" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbClose" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JTabbedPane" name="tab">
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbClose">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Fermer"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCloseActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.auth.XemeliosUser;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.lang.reflect.Method;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgAdmin extends javax.swing.JDialog {
+ private XemeliosUser connectedUser = null;
+ private PropertiesExpansion applicationProperties;
+
+ /** Creates new form DlgAdmin */
+ public DlgAdmin(java.awt.Frame parent, PropertiesExpansion applicationProperties) {
+ super(parent, "Gestion des utilisateurs", true);
+ this.applicationProperties = applicationProperties;
+ initComponents();
+ setLocationRelativeTo(getParent());
+ tab.add("Profils", new PnlProfils(this,DataHelper.getProfils()));
+ tab.add("Utilisateurs",new PnlUsers(this, applicationProperties));
+ }
+ public XemeliosUser getConnectedUser() {
+ XemeliosUser ret = connectedUser;
+ Class clazz = null;
+ Object instance = null;
+ if(connectedUser==null) {
+ try {
+ clazz = Class.forName("fr.gouv.finances.cp.xemelios.ui.MainWindow");
+ Method meth = clazz.getMethod("getInstance");
+ instance = meth.invoke(null);
+ if(instance!=null) {
+ meth = clazz.getMethod("getConnectedUser");
+ ret = (XemeliosUser)meth.invoke(instance);
+ }
+ connectedUser = ret;
+ } catch(Throwable t) {}
+ }
+ return ret;
+ }
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt) {
+ pbCloseActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ tab = new javax.swing.JTabbedPane();
+ pbClose = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ pbClose.setText("Fermer");
+ pbClose.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCloseActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(tab, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbClose))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(tab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 358, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbClose)
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCloseActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbCloseActionPerformed
+
+ /**
+ * @param args the command line arguments
+ */
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton pbClose;
+ private javax.swing.JTabbedPane tab;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="jScrollPane1" pref="328" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="pbRemoveCollectivite" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbAddCollectivite" alignment="1" pref="32" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Component id="lblHeader" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="lblHeader" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pbAddCollectivite" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveCollectivite" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="jScrollPane1" pref="241" max="32767" attributes="2"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="org.jdesktop.swingx.JXTable" name="tblCollectivitesUser">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="collectivitesUserModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ <Property name="toolTipText" type="java.lang.String" value=""/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblHeader">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code=""Collectivités de "+user.toString()" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbAddCollectivite">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/add.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Ajouter une collectivité"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddCollectiviteActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveCollectivite">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Supprimer cette collectivité"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveCollectiviteActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.Collectivite;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper.CollectiviteLib;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Hashtable;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgCollectivitesUtilisateur extends javax.swing.JDialog {
+ public static final Hashtable<String,String> naturesIdentifiants;
+ static {
+ naturesIdentifiants = new Hashtable<String,String>();
+ naturesIdentifiants.put("SIRET","SIRET");
+ naturesIdentifiants.put("IDCOLL","Identifiant DGFiP");
+ naturesIdentifiants.put("CODIC","Poste comptable");
+ naturesIdentifiants.put("VARIABLE", "Divers");
+ }
+
+ private DataHelper.StdUser user;
+ private TableCollectivitesModel collectivitesUserModel;
+ private boolean bRet;
+
+ private PropertiesExpansion applicationProperties;
+
+ /** Creates new form DlgCollectivitesUtilisateur */
+ public DlgCollectivitesUtilisateur(java.awt.Dialog parent, DataHelper.StdUser user, PropertiesExpansion applicationProperties) {
+ super(parent, "Collectivités", true);
+ this.user=user;
+ this.applicationProperties = applicationProperties;
+ collectivitesUserModel = new TableCollectivitesModel(user.getCollectivites());
+ initComponents();
+ tblCollectivitesUser.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ pbRemoveCollectivite.setEnabled(tblCollectivitesUser.getSelectedRowCount()>0);
+ }
+ });
+ tblCollectivitesUser.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ setLocationRelativeTo(parent);
+ }
+ public boolean run() {
+ bRet = false;
+ setVisible(true);
+ return bRet;
+ }
+
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tblCollectivitesUser = new org.jdesktop.swingx.JXTable();
+ pbCancel = new javax.swing.JButton();
+ pbOk = new javax.swing.JButton();
+ lblHeader = new javax.swing.JLabel();
+ pbAddCollectivite = new javax.swing.JButton();
+ pbRemoveCollectivite = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ tblCollectivitesUser.setModel(collectivitesUserModel);
+ jScrollPane1.setViewportView(tblCollectivitesUser);
+
+ pbCancel.setText("Annuler");
+ pbCancel.setToolTipText("");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ lblHeader.setText("Collectivités de "+user.toString());
+
+ pbAddCollectivite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/add.png"))); // NOI18N
+ pbAddCollectivite.setToolTipText("Ajouter une collectivité");
+ pbAddCollectivite.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddCollectiviteActionPerformed(evt);
+ }
+ });
+
+ pbRemoveCollectivite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"))); // NOI18N
+ pbRemoveCollectivite.setToolTipText("Supprimer cette collectivité");
+ pbRemoveCollectivite.setEnabled(false);
+ pbRemoveCollectivite.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveCollectiviteActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(pbRemoveCollectivite, 0, 0, Short.MAX_VALUE)
+ .add(pbAddCollectivite, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, Short.MAX_VALUE)))
+ .add(lblHeader)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(lblHeader)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(pbAddCollectivite)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveCollectivite))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ setVisible(false);
+}//GEN-LAST:event_pbCancelActionPerformed
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ DataHelper.saveUserCollectivites(user);
+ bRet = true;
+ setVisible(false);
+}//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbAddCollectiviteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddCollectiviteActionPerformed
+ DlgSelectCollectivite dlg = new DlgSelectCollectivite(this, this.applicationProperties);
+ if(dlg.run()) {
+ for(CollectiviteLib coll: dlg.getSelectedData()) {
+ collectivitesUserModel.addCollectivite(coll);
+ }
+
+ }
+}//GEN-LAST:event_pbAddCollectiviteActionPerformed
+
+ private void pbRemoveCollectiviteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveCollectiviteActionPerformed
+ int[] rows = tblCollectivitesUser.getSelectedRows();
+ Arrays.sort(rows);
+ for(int i=rows.length-1;i>=0;i--) {
+ collectivitesUserModel.removeRow(rows[i]);
+ }
+}//GEN-LAST:event_pbRemoveCollectiviteActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JLabel lblHeader;
+ private javax.swing.JButton pbAddCollectivite;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ private javax.swing.JButton pbRemoveCollectivite;
+ private org.jdesktop.swingx.JXTable tblCollectivitesUser;
+ // End of variables declaration//GEN-END:variables
+
+ @Override
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ public static class TableCollectivitesModel extends AbstractTableModel {
+ public static final long serialVersionUID = 1L;
+ private ArrayList<CollectiviteLib> data;
+
+ public TableCollectivitesModel(ArrayList<CollectiviteLib> data) {
+ super();
+ this.data=data;
+ }
+
+ public int getRowCount() {
+ return data.size();
+ }
+
+ public int getColumnCount() {
+ return 3;
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ CollectiviteLib coll = data.get(rowIndex);
+ switch(columnIndex) {
+ case 0: return getTypIdLib(coll.getNatureIdentifiant());
+ case 1: return coll.getClef();
+ default: return coll.getLibelle();
+ }
+ }
+ public void addCollectivite(CollectiviteLib coll) {
+ data.add(coll);
+ fireTableRowsInserted(data.size()-1, data.size());
+ }
+ public CollectiviteLib getElementAt(int pos) {
+ return data.get(pos);
+ }
+ public Collectivite removeCollectivite(Collectivite coll) {
+ int pos = data.indexOf(coll);
+ if(pos>=0) {
+ data.remove(pos);
+ fireTableRowsDeleted(pos, pos);
+ }
+ return coll;
+ }
+ public CollectiviteLib removeRow(int row) {
+ CollectiviteLib ret = data.remove(row);
+ fireTableRowsDeleted(row, row);
+ return ret;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ switch(column) {
+ case 0: return "Nature identifiant";
+ case 1: return "Identifiant";
+ default: return "Libellé";
+ }
+ }
+
+ public void setData(ArrayList<CollectiviteLib> data) {
+ this.data=data;
+ fireTableDataChanged();
+ }
+
+ }
+
+ public static String getTypIdLib(String natureIdentifiant) {
+ return naturesIdentifiants.get(natureIdentifiant);
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="title" type="java.lang.String" value="Paramétrage de l'authentification"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="innerPnl" alignment="0" pref="414" max="32767" attributes="0"/>
+ <Component id="jLabel1" alignment="0" pref="414" max="32767" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="innerPnl" pref="335" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JPanel" name="innerPnl">
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="MSG" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+
+/**
+ * Affiche un panneau de parametrage de l'authentification
+ * @author chm
+ */
+public class DlgConfigAuthentication extends javax.swing.JDialog {
+ private static final long serialVersionUID = 4100970141481513500L;
+ private boolean returnStatus;
+ private String initialEngineName;
+ private static final String MSG = "<html>Ceci est votre premier lancement de Xemelios.<br/>Vous devez choisir le mode d'authentification qui sera utilisé<br/>par tous vos utilisateurs. Une fois configuré, il serait souhaitable<br/>de ne plus le modifier, à moins d'être parfaitement certain de ce<br/>que vous faites.<br/>Vous pourrez toujours accéder à ce paramétrage depuis le menu<br/>Fichier / Configuration.</html>";
+ private PnlConfigAuthentication authPanel = null;
+ /**
+ * Creates new form DlgConfigAuthentication
+ * @param parent
+ * @param modal
+ * @param initialAuthenticationEngine
+ */
+ public DlgConfigAuthentication(java.awt.Frame parent, boolean modal, String initialAuthenticationEngine) {
+ super(parent, modal);
+ this.initialEngineName = initialAuthenticationEngine;
+ initComponents();
+ authPanel = new PnlConfigAuthentication(initialEngineName);
+ innerPnl.add(authPanel);
+ setLocationRelativeTo(parent);
+ }
+ public boolean run() {
+ returnStatus = false;
+ setVisible(true);
+ return returnStatus;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ pbOk = new javax.swing.JButton();
+ pbCancel = new javax.swing.JButton();
+ innerPnl = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Paramétrage de l'authentification");
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ pbCancel.setText("Annuler");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ jLabel1.setText(MSG);
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, innerPnl, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
+ .add(layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(innerPnl, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ saveData();
+ setVisible(false);
+ }//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbCancelActionPerformed
+
+ protected void saveData() {
+ returnStatus = authPanel.saveData();
+ }
+
+ @Override
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel innerPnl;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ // End of variables declaration//GEN-END:variables
+
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblCode" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblLibelle" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="dfLibelle" pref="257" max="32767" attributes="2"/>
+ <Component id="dfCode" alignment="0" pref="257" max="32767" attributes="2"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblCode" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfCode" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblLibelle" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfLibelle" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblCode">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Code"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblLibelle">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Libellé"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfCode">
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfLibelle">
+ </Component>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.utils.Pair;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgCreateCodeLib extends javax.swing.JDialog {
+ private String objectName;
+ private boolean accepted = false;
+ private Pair ret;
+
+ /** Creates new form DlgCreateCodeLib */
+ public DlgCreateCodeLib(java.awt.Frame parent,String title,String objectName) {
+ super(parent, true);
+ setTitle(title);
+ this.objectName=objectName;
+ initComponents();
+ setLocationRelativeTo(getParent());
+ }
+ public DlgCreateCodeLib(java.awt.Dialog parent,String title,String objectName) {
+ super(parent, true);
+ setTitle(title);
+ this.objectName=objectName;
+ initComponents();
+ setLocationRelativeTo(getParent());
+ }
+
+ public boolean run() {
+ accepted = false;
+ dfCode.setText("");
+ dfLibelle.setText("");
+ setVisible(true);
+ return accepted;
+ }
+ public Pair getRet() { return ret; }
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblCode = new javax.swing.JLabel();
+ lblLibelle = new javax.swing.JLabel();
+ dfCode = new javax.swing.JTextField();
+ dfLibelle = new javax.swing.JTextField();
+ pbOk = new javax.swing.JButton();
+ pbCancel = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ lblCode.setText("Code");
+
+ lblLibelle.setText("Libellé");
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ pbCancel.setText("Annuler");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblCode)
+ .add(lblLibelle))
+ .add(9, 9, 9)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(dfLibelle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
+ .add(dfCode, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblCode)
+ .add(dfCode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblLibelle)
+ .add(dfLibelle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ String code = dfCode.getText();
+ String libelle = dfLibelle.getText();
+ if(code!=null && code.length()>0 && libelle!=null && libelle.length()>0) {
+ ret = new Pair(code,libelle);
+ accepted = true;
+ setVisible(false);
+ } else {
+ JOptionPane.showMessageDialog(this, "Le code et le libellé doivent être renseignés");
+ }
+ }//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ setVisible(false);
+ }//GEN-LAST:event_pbCancelActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField dfCode;
+ private javax.swing.JTextField dfLibelle;
+ private javax.swing.JLabel lblCode;
+ private javax.swing.JLabel lblLibelle;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="jScrollPane1" min="-2" pref="135" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
+ <Component id="pbAddOne" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbAddAll" alignment="0" min="-2" pref="22" max="-2" attributes="1"/>
+ </Group>
+ <Group type="103" alignment="1" groupAlignment="0" max="-2" attributes="0">
+ <Component id="pbRemoveAll" alignment="1" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbRemoveOne" alignment="1" min="-2" pref="22" max="-2" attributes="1"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
+ <Component id="jScrollPane2" pref="143" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="jScrollPane2" alignment="0" max="32767" attributes="1"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pbAddAll" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbAddOne" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveOne" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveAll" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Component id="jScrollPane1" alignment="0" pref="212" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code=""Documents de "+user.toString()" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstDocumentsUser">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="documentsUserModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbAddAll">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/addAll.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Tout ajouter"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddAllActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbAddOne">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/addOne.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Ajouter"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddOneActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveOne">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/removeOne.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Supprimer"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveOneActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveAll">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/removeAll.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Tout supprimer"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveAllActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstDocuments">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="documentsModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ <Property name="toolTipText" type="java.lang.String" value=""/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.xemelios.common.config.DocumentModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.DocumentsModel;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgDocumentsUtilisateur extends javax.swing.JDialog {
+ private DataHelper.StdUser user;
+ private DlgProfilsUtilisateur.PairListModel documentsUserModel;
+ private DlgProfilsUtilisateur.PairListModel documentsModel;
+
+ /** Creates new form DlgDocumentsUtilisateur */
+ public DlgDocumentsUtilisateur(java.awt.Dialog parent, DataHelper.StdUser user, DocumentsModel docs) {
+ super(parent, "Documents", true);
+ this.user=user;
+ List<Pair> documentsUser = user.getDocuments();
+ for(Pair p: documentsUser) {
+ p.libelle=docs.getDocumentById(p.key).getTitre();
+ }
+ List<Pair> documents = new ArrayList<Pair>();
+ for(DocumentModel dm:docs.getDocuments()) {
+ Pair p = new Pair(dm.getId(),dm.getTitre());
+ if(!documentsUser.contains(p)) documents.add(p);
+ }
+ documentsUserModel = new DlgProfilsUtilisateur.PairListModel(documentsUser);
+ documentsModel = new DlgProfilsUtilisateur.PairListModel(documents);
+ initComponents();
+ documentsUserModel.setList(lstDocumentsUser);
+ documentsModel.setList(lstDocuments);
+ lstDocumentsUser.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ JList lst = (JList)e.getSource();
+ boolean selected = lst.getSelectedIndices().length>0;
+ pbRemoveOne.setEnabled(selected);
+ }
+ });
+ lstDocuments.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ JList lst = (JList)e.getSource();
+ boolean selected = lst.getSelectedIndices().length>0;
+ pbAddOne.setEnabled(selected);
+ }
+ });
+ setLocationRelativeTo(parent);
+ }
+ public void run() {
+ setVisible(true);
+ }
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ lstDocumentsUser = new javax.swing.JList();
+ pbAddAll = new javax.swing.JButton();
+ pbAddOne = new javax.swing.JButton();
+ pbRemoveOne = new javax.swing.JButton();
+ pbRemoveAll = new javax.swing.JButton();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ lstDocuments = new javax.swing.JList();
+ pbOk = new javax.swing.JButton();
+ pbCancel = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ jLabel1.setText("Documents de "+user.toString());
+
+ lstDocumentsUser.setModel(documentsUserModel);
+ jScrollPane1.setViewportView(lstDocumentsUser);
+
+ pbAddAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/addAll.png"))); // NOI18N
+ pbAddAll.setToolTipText("Tout ajouter");
+ pbAddAll.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddAllActionPerformed(evt);
+ }
+ });
+
+ pbAddOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/addOne.png"))); // NOI18N
+ pbAddOne.setToolTipText("Ajouter");
+ pbAddOne.setEnabled(false);
+ pbAddOne.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddOneActionPerformed(evt);
+ }
+ });
+
+ pbRemoveOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/removeOne.png"))); // NOI18N
+ pbRemoveOne.setToolTipText("Supprimer");
+ pbRemoveOne.setEnabled(false);
+ pbRemoveOne.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveOneActionPerformed(evt);
+ }
+ });
+
+ pbRemoveAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/removeAll.png"))); // NOI18N
+ pbRemoveAll.setToolTipText("Tout supprimer");
+ pbRemoveAll.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveAllActionPerformed(evt);
+ }
+ });
+
+ lstDocuments.setModel(documentsModel);
+ jScrollPane2.setViewportView(lstDocuments);
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ pbCancel.setText("Annuler");
+ pbCancel.setToolTipText("");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel1)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 135, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, pbAddOne, 0, 0, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, pbAddAll, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbRemoveAll, 0, 0, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbRemoveOne, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ .add(6, 6, 6)
+ .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(pbAddAll)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbAddOne)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveOne)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveAll))
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbAddAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddAllActionPerformed
+ while(documentsModel.getSize()>0) {
+ Pair p = (Pair)documentsModel.getElementAt(0);
+ documentsUserModel.addPair(p);
+ documentsModel.removePair(p);
+ }
+}//GEN-LAST:event_pbAddAllActionPerformed
+
+ private void pbAddOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddOneActionPerformed
+ int[] indices = lstDocuments.getSelectedIndices();
+ Vector<Pair> toRemove = new Vector<Pair>();
+ for(int pos:indices) {
+ Pair p = (Pair)documentsModel.getElementAt(pos);
+ documentsUserModel.addPair(p);
+ toRemove.add(p);
+ }
+ for(Pair p:toRemove) documentsModel.removePair(p);
+}//GEN-LAST:event_pbAddOneActionPerformed
+
+ private void pbRemoveOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveOneActionPerformed
+ int[] indices = lstDocumentsUser.getSelectedIndices();
+ Vector<Pair> toRemove = new Vector<Pair>();
+ for(int pos:indices) {
+ Pair p = (Pair)documentsUserModel.getElementAt(pos);
+ documentsModel.addPair(p);
+ toRemove.add(p);
+ }
+ for(Pair p:toRemove) documentsUserModel.removePair(p);
+}//GEN-LAST:event_pbRemoveOneActionPerformed
+
+ private void pbRemoveAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveAllActionPerformed
+ while(documentsUserModel.getSize()>0) {
+ Pair p = (Pair)documentsUserModel.getElementAt(0);
+ documentsModel.addPair(p);
+ documentsUserModel.removePair(p);
+ }
+}//GEN-LAST:event_pbRemoveAllActionPerformed
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ DataHelper.saveUserDocuments(user);
+ setVisible(false);
+}//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ user.setDocuments(null);
+ setVisible(false);
+}//GEN-LAST:event_pbCancelActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JList lstDocuments;
+ private javax.swing.JList lstDocumentsUser;
+ private javax.swing.JButton pbAddAll;
+ private javax.swing.JButton pbAddOne;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ private javax.swing.JButton pbRemoveAll;
+ private javax.swing.JButton pbRemoveOne;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblHeader" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jScrollPane1" min="-2" pref="145" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="pbAddOne" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbAddAll" alignment="0" pref="22" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="103" alignment="1" groupAlignment="0" max="-2" attributes="0">
+ <Component id="pbRemoveAll" alignment="1" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbRemoveOne" alignment="1" pref="22" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane2" pref="156" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="lblHeader" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pbAddAll" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbAddOne" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveOne" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveAll" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane2" pref="217" max="32767" attributes="1"/>
+ <Component id="jScrollPane1" alignment="0" min="-2" pref="217" max="-2" attributes="1"/>
+ </Group>
+ <EmptySpace pref="19" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblHeader">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code=""Profils de "+user.toString()" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstProfilsUser">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="profilsUserModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstProfils">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="profilsModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ <Property name="toolTipText" type="java.lang.String" value=""/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbAddAll">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/addAll.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Tout ajouter"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddAllActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbAddOne">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/addOne.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Ajouter"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddOneActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveOne">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/removeOne.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Supprimer"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveOneActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveAll">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/removeAll.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Tout supprimer"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveAllActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.utils.Pair;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.AbstractAction;
+import javax.swing.AbstractListModel;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgProfilsUtilisateur extends javax.swing.JDialog {
+ private DataHelper.StdUser user;
+ private PairListModel profilsUserModel;
+ private PairListModel profilsModel;
+
+ /** Creates new form DlgProfilsUtilisateur */
+ public DlgProfilsUtilisateur(java.awt.Dialog parent, DataHelper.StdUser user) {
+ super(parent, "Profils", true);
+ this.user=user;
+ List<Pair> userProfiles = user.getProfils();
+ List<Pair> profils = DataHelper.getProfilsAsPair();
+ for(Pair p:userProfiles) profils.remove(p);
+ profilsUserModel = new PairListModel(userProfiles);
+ profilsModel = new PairListModel(profils);
+ initComponents();
+ profilsUserModel.setList(lstProfilsUser);
+ profilsModel.setList(lstProfils);
+ lstProfilsUser.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ JList lst = (JList)e.getSource();
+ boolean selected = lst.getSelectedIndices().length>0;
+ pbRemoveOne.setEnabled(selected);
+ }
+ });
+ lstProfils.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ JList lst = (JList)e.getSource();
+ boolean selected = lst.getSelectedIndices().length>0;
+ pbAddOne.setEnabled(selected);
+ }
+ });
+ setLocationRelativeTo(parent);
+ }
+ public void run() {
+ setVisible(true);
+ }
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblHeader = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ lstProfilsUser = new javax.swing.JList();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ lstProfils = new javax.swing.JList();
+ pbOk = new javax.swing.JButton();
+ pbCancel = new javax.swing.JButton();
+ pbAddAll = new javax.swing.JButton();
+ pbAddOne = new javax.swing.JButton();
+ pbRemoveOne = new javax.swing.JButton();
+ pbRemoveAll = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ lblHeader.setText("Profils de "+user.toString());
+
+ lstProfilsUser.setModel(profilsUserModel);
+ jScrollPane1.setViewportView(lstProfilsUser);
+
+ lstProfils.setModel(profilsModel);
+ jScrollPane2.setViewportView(lstProfils);
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ pbCancel.setText("Annuler");
+ pbCancel.setToolTipText("");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ pbAddAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/addAll.png"))); // NOI18N
+ pbAddAll.setToolTipText("Tout ajouter");
+ pbAddAll.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddAllActionPerformed(evt);
+ }
+ });
+
+ pbAddOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/addOne.png"))); // NOI18N
+ pbAddOne.setToolTipText("Ajouter");
+ pbAddOne.setEnabled(false);
+ pbAddOne.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddOneActionPerformed(evt);
+ }
+ });
+
+ pbRemoveOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/removeOne.png"))); // NOI18N
+ pbRemoveOne.setToolTipText("Supprimer");
+ pbRemoveOne.setEnabled(false);
+ pbRemoveOne.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveOneActionPerformed(evt);
+ }
+ });
+
+ pbRemoveAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/removeAll.png"))); // NOI18N
+ pbRemoveAll.setToolTipText("Tout supprimer");
+ pbRemoveAll.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveAllActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblHeader)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk))
+ .add(layout.createSequentialGroup()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, pbAddOne, 0, 0, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, pbAddAll, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, Short.MAX_VALUE)))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbRemoveAll, 0, 0, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbRemoveOne, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, Short.MAX_VALUE)))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(lblHeader)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(pbAddAll)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbAddOne)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveOne)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveAll))
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 217, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 19, Short.MAX_VALUE)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ user.setProfils(null);
+ setVisible(false);
+ }//GEN-LAST:event_pbCancelActionPerformed
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ DataHelper.saveUserProfils(user);
+ setVisible(false);
+ }//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbAddOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddOneActionPerformed
+ int[] indices = lstProfils.getSelectedIndices();
+ Vector<Pair> toRemove = new Vector<Pair>();
+ for(int pos:indices) {
+ Pair p = (Pair)profilsModel.getElementAt(pos);
+ profilsUserModel.addPair(p);
+ toRemove.add(p);
+ }
+ for(Pair p:toRemove) profilsModel.removePair(p);
+ }//GEN-LAST:event_pbAddOneActionPerformed
+
+ private void pbAddAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddAllActionPerformed
+ while(profilsModel.getSize()>0) {
+ Pair p = (Pair)profilsModel.getElementAt(0);
+ profilsUserModel.addPair(p);
+ profilsModel.removePair(p);
+ }
+ }//GEN-LAST:event_pbAddAllActionPerformed
+
+ private void pbRemoveOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveOneActionPerformed
+ int[] indices = lstProfilsUser.getSelectedIndices();
+ Vector<Pair> toRemove = new Vector<Pair>();
+ for(int pos:indices) {
+ Pair p = (Pair)profilsUserModel.getElementAt(pos);
+ profilsModel.addPair(p);
+ toRemove.add(p);
+ }
+ for(Pair p:toRemove) profilsUserModel.removePair(p);
+ }//GEN-LAST:event_pbRemoveOneActionPerformed
+
+ private void pbRemoveAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveAllActionPerformed
+ while(profilsUserModel.getSize()>0) {
+ Pair p = (Pair)profilsUserModel.getElementAt(0);
+ profilsModel.addPair(p);
+ profilsUserModel.removePair(p);
+ }
+ }//GEN-LAST:event_pbRemoveAllActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JLabel lblHeader;
+ private javax.swing.JList lstProfils;
+ private javax.swing.JList lstProfilsUser;
+ private javax.swing.JButton pbAddAll;
+ private javax.swing.JButton pbAddOne;
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ private javax.swing.JButton pbRemoveAll;
+ private javax.swing.JButton pbRemoveOne;
+ // End of variables declaration//GEN-END:variables
+
+ static class PairListModel extends AbstractListModel {
+ private List<Pair> data;
+ private JList list;
+ public PairListModel(List<Pair> data) {
+ super();
+ this.data=data;
+ }
+ public void setList(JList list) {
+ this.list=list;
+ }
+ public Object getElementAt(int index) {
+ return data.get(index);
+ }
+
+ public void addPair(Pair p) {
+ data.add(p);
+ fireIntervalAdded(list, data.size()-1, data.size()-1);
+ }
+ public Pair removePair(Pair p) {
+ int pos = data.indexOf(p);
+ if(pos>=0) {
+ data.remove(pos);
+ fireIntervalRemoved(list, pos, pos);
+ }
+ return p;
+ }
+ public int getSize() {
+ return data.size();
+ }
+ public List<Pair> getData() { return data; }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="tabs" alignment="0" pref="640" max="32767" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbOk" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="tabs" pref="400" max="32767" attributes="0"/>
+ <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbOk" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JTabbedPane" name="tabs">
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbOk">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbOkActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Annuler"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbCancelActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.swing.InfiniteGlassPane;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+
+/**
+ *
+ * @author chm
+ */
+public class DlgSelectCollectivite extends javax.swing.JDialog {
+ private PnlSearchCollectivite pnlSearch;
+ private PnlCreateCollectivite pnlCreate;
+ private boolean ret = false;
+ private ArrayList<DataHelper.CollectiviteLib> selectedData;
+ private PropertiesExpansion applicationProperties;
+
+ /** Creates new form DlgSelectCollectivite */
+ public DlgSelectCollectivite(java.awt.Dialog parent, PropertiesExpansion applicationProperties) {
+ super(parent, "Ajouter des collectivités", true);
+ this.applicationProperties = applicationProperties;
+ initComponents();
+ pnlSearch = new PnlSearchCollectivite();
+ tabs.add("Recherche", pnlSearch);
+ pnlCreate = new PnlCreateCollectivite(this, applicationProperties);
+ tabs.add("Création",pnlCreate);
+ setGlassPane(new InfiniteGlassPane());
+ setLocationRelativeTo(parent);
+ }
+
+ public boolean run() {
+ ret = false;
+ setVisible(true);
+ return ret;
+ }
+
+ public ArrayList<DataHelper.CollectiviteLib> getSelectedData() { return selectedData; }
+ @Override
+ protected JRootPane createRootPane() {
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ AbstractAction escapeAction = new AbstractAction("Annuler") {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ };
+ rp.registerKeyboardAction(escapeAction,"TOTOTOTO",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ tabs = new javax.swing.JTabbedPane();
+ pbOk = new javax.swing.JButton();
+ pbCancel = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ pbOk.setText("Ok");
+ pbOk.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbOkActionPerformed(evt);
+ }
+ });
+
+ pbCancel.setText("Annuler");
+ pbCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbCancelActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(tabs, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(pbCancel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbOk)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(tabs, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
+ .add(12, 12, 12)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbOk)
+ .add(pbCancel))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbOkActionPerformed
+ ret = true;
+ // TODO: a finaliser
+ selectedData = new ArrayList<DataHelper.CollectiviteLib>();
+ selectedData.addAll(pnlSearch.getSelectedData());
+ selectedData.addAll(pnlCreate.getSelectedData());
+ setVisible(false);
+ }//GEN-LAST:event_pbOkActionPerformed
+
+ private void pbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbCancelActionPerformed
+ ret = false;
+ setVisible(false);
+ }//GEN-LAST:event_pbCancelActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton pbCancel;
+ private javax.swing.JButton pbOk;
+ private javax.swing.JTabbedPane tabs;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+ <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane2" alignment="0" pref="376" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" alignment="0" pref="376" max="32767" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="cbxEngine" pref="205" max="32767" attributes="0"/>
+ </Group>
+ <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="332" max="32767" attributes="0"/>
+ <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="cbxEngine" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane1" min="-2" pref="117" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane2" pref="108" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Moteur d'authentification"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="cbxEngine">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="0"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbxEngineActionPerformed"/>
+ </Events>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox(engines)"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Description"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea" name="txtDesc">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="lineWrap" type="boolean" value="true"/>
+ <Property name="rows" type="int" value="5"/>
+ <Property name="wrapStyleWord" type="boolean" value="true"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Propriétés complémentaires"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTable" name="tblProperties">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="model" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2010 axYus - http://www.axyus.com
+ * 2010 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.xemelios.auth.AuthEngine;
+import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeSet;
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+import javax.swing.table.AbstractTableModel;
+import org.apache.log4j.Logger;
+
+/**
+ * Cette classe permet de choisir et de configurer le moteur d'authentification.
+ * La liste des moteurs d'authentification est statique ; tout auteur de
+ * moteur d'authentification doit donc déclarer aux auteurs de XEMELIOS
+ * son moteur et les paramètres qu'il utilise pour que celui-ci se trouve listé
+ * dans cette classe.
+ * @author cmarchand
+ */
+public class PnlConfigAuthentication extends javax.swing.JPanel {
+ private static final Logger logger = Logger.getLogger(PnlConfigAuthentication.class);
+ private static EngineListModel engines;
+ private Engine currentEngine = null;
+ private PropsTableModel model = null;
+ static {
+ engines = new EngineListModel();
+ // Pas d'authentification à mettre en pos 1
+ engines.add(new Engine("fr.gouv.finances.dgfip.xemelios.auth.impl.noauth.NoAuthEngine",
+ "Pas d'authentification",
+ "Permet d'accéder à XeMeLios sans authentification, avec tous les droits.",
+ new Properties()));
+ // mettre en pos 2
+ Properties dgcpProps = new Properties();
+ try {
+ String sTmp = getParameterValue("auth.ldap.service.provider");
+ dgcpProps.put("auth.ldap.service.provider",sTmp!=null?sTmp:"com.sun.jndi.ldap.LdapCtxFactory");
+ sTmp = getParameterValue("auth.ldap.server.url");
+ dgcpProps.put("auth.ldap.server.url",sTmp!=null?sTmp:"ldap://ldap.bercy.cp/");
+ sTmp = getParameterValue("auth.ldap.userDn");
+ dgcpProps.put("auth.ldap.userDn",sTmp!=null?sTmp:"uid=%LOGIN%,ou=personnes,ou=dgcp,ou=mefi,o=gouv,c=fr");
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ engines.add(new Engine(
+ "fr.gouv.finances.cp.xemelios.auth.dgcp.DgcpAuthEngine",
+ "Authentification DGFiP",
+ "Authentification spécifique à la DGFiP",
+ dgcpProps));
+ // mettre en pos 3
+ engines.add(new Engine(
+ "fr.gouv.finances.dgfip.xemelios.auth.impl.basic.BasicAuthEngineImpl",
+ "Authentification basique",
+ "Authentification basique.\nElle définit un utilisateur unique avec tous les droits, identifié par un mot de passe. L'utilisateur possède tous les droits nécessaires à l'utilisation complète de XeMeLios.",
+ new Properties()));
+ engines.add(new Engine(
+ "fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.StdDbAuthEngineImpl",
+ "Authentification avancée",
+ "Authentification paramétrable, s'appuyant entièrement sur la base de donnée.\nElle permet de gérer des profils d'utilisateurs, de limiter les accès à certains types de documents et à certaines collectivités.\n",
+ new Properties()));
+ Properties aphmProps = new Properties();
+ try {
+ String sTmp = getParameterValue("auth.ldap.baseUrl");
+ aphmProps.put("auth.ldap.baseUrl",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.adminLogin");
+ aphmProps.put("auth.ldap.adminLogin",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.adminPassword");
+ aphmProps.put("auth.ldap.adminPassword",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.searchPath");
+ aphmProps.put("auth.ldap.searchPath",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.searchField");
+ aphmProps.put("auth.ldap.searchField",sTmp!=null?sTmp:"");
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ engines.add(new Engine(
+ "fr.gouv.finances.cp.xemelios.auth.ldapAphm.LdapAuthEngineImpl",
+ "Authentification spécifique à l'APHM",
+ "Authentification spécifique à l'APHM.\nEllel vérifie le mot de passe de l'utilisateur dans l'annuaire LDAP de l'APHM, et les droits des utilisateurs dans la base de donnée.",
+ aphmProps));
+ Properties ldapProps = new Properties();
+ try {
+ String sTmp = getParameterValue("auth.ldap.baseUrl");
+ ldapProps.put("auth.ldap.baseUrl",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.userDN");
+ ldapProps.put("auth.ldap.userDN",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.readAccessDN");
+ ldapProps.put("auth.ldap.readAccessDN",sTmp!=null?sTmp:"");
+ sTmp = getParameterValue("auth.ldap.writeAccessDN");
+ ldapProps.put("auth.ldap.writeAccessDN",sTmp!=null?sTmp:"");
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ engines.add(new Engine(
+ "fr.gouv.finances.cp.xemelios.auth.ldap.LdapAuthEngineImpl",
+ "Authentification LDAP",
+ "Authentification entièrement basée sur un annuaire LDAP.\nLe mot de passe et les droits des utilisateurs sont gérés par l'annuaire LDAP.",
+ ldapProps));
+
+ }
+
+ /**
+ * Crée un nouveau panneau de configuration de l'authentification
+ * @param initialAuthenticationEngine
+ */
+ public PnlConfigAuthentication(String initialAuthenticationEngine) {
+ Engine initialEngine = null;
+ if(initialAuthenticationEngine!=null) {
+ for(Engine eng:engines) {
+ if(eng.getClassName().compareTo(initialAuthenticationEngine)==0) {
+ initialEngine=eng;
+ break;
+ }
+ }
+ }
+ if(initialEngine==null) initialEngine = engines.get(0);
+ model = new PropsTableModel(currentEngine!=null ? currentEngine.getProps() : new Properties());
+ initComponents();
+ cbxEngine.setSelectedItem(initialEngine);
+ Connection con = PoolManager.getInstance().getConnection();
+ if(!isLocalComputerServer(con)) {
+ cbxEngine.setEnabled(false);
+ }
+ PoolManager.getInstance().releaseConnection(con);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ cbxEngine = new javax.swing.JComboBox(engines);
+ jLabel2 = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ txtDesc = new javax.swing.JTextArea();
+ jLabel3 = new javax.swing.JLabel();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ tblProperties = new javax.swing.JTable();
+
+ jLabel1.setText("Moteur d'authentification");
+
+ cbxEngine.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cbxEngineActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setText("Description");
+
+ txtDesc.setColumns(20);
+ txtDesc.setEditable(false);
+ txtDesc.setLineWrap(true);
+ txtDesc.setRows(5);
+ txtDesc.setWrapStyleWord(true);
+ jScrollPane1.setViewportView(txtDesc);
+
+ jLabel3.setText("Propriétés complémentaires");
+
+ tblProperties.setModel(model);
+ jScrollPane2.setViewportView(tblProperties);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 400, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+ .addComponent(jLabel1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cbxEngine, 0, 205, Short.MAX_VALUE))
+ .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING))
+ .addContainerGap()))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 332, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(cbxEngine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
+ .addContainerGap()))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void cbxEngineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxEngineActionPerformed
+ currentEngine = (Engine)cbxEngine.getSelectedItem();
+ txtDesc.setEnabled(currentEngine!=null);
+ tblProperties.setEnabled(currentEngine!=null);
+ if(currentEngine!=null) {
+ txtDesc.setText(currentEngine.getDescription());
+ model.setProps(currentEngine.getProps());
+ }
+}//GEN-LAST:event_cbxEngineActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JComboBox cbxEngine;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JTable tblProperties;
+ private javax.swing.JTextArea txtDesc;
+ // End of variables declaration//GEN-END:variables
+
+ private static class Engine implements Comparable {
+ private String className;
+ private String libelle;
+ private String description;
+ private Properties props;
+
+ public Engine(String className, String libelle, String description, Properties props) {
+ super();
+ this.className=className;
+ this.libelle=libelle;
+ this.description=description;
+ this.props=props;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getLibelle() {
+ return libelle;
+ }
+
+ public void setLibelle(String libelle) {
+ this.libelle = libelle;
+ }
+
+ public Properties getProps() {
+ return props;
+ }
+
+ public void setProps(Properties props) {
+ this.props = props;
+ }
+ @Override
+ public String toString() {
+ return libelle;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return className.compareTo(((Engine)o).getClassName());
+ }
+ }
+ private static class PropsTableModel extends AbstractTableModel {
+ public static final long serialVersionUID = 0L;
+ private Properties props;
+ TreeSet<String> keys;
+
+ public PropsTableModel(Properties props) {
+ super();
+ init(props);
+ }
+ private void init(Properties props) {
+ this.props = props;
+ keys = new TreeSet<String>();
+ for(Object key:props.keySet()) {
+ keys.add((String)key);
+ }
+ fireTableDataChanged();
+ }
+ public void setProps(Properties props) {
+ init(props);
+ }
+
+ @Override
+ public int getRowCount() {
+ return props.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ switch(columnIndex) {
+ case 0: return keyAt(rowIndex);
+ default: return props.getProperty(keyAt(rowIndex));
+ }
+ }
+ private String keyAt(int rowIndex) {
+ Iterator<String> it = keys.iterator();
+ for(int i=0;i<keys.size();i++) {
+ String s = it.next();
+ if(i==rowIndex) return s;
+ }
+ return null;
+ }
+
+ public Properties getProps() {
+ return props;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ if(column==0) return "Propriété";
+ else return "Valeur";
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return String.class;
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return columnIndex==1;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ props.setProperty(keyAt(rowIndex), (String)aValue);
+ }
+
+
+ }
+ public static String getParameterValue(final String paramName) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ ResultSet rs = null;
+ String ret = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ ps = con.prepareStatement("SELECT PARAM_VALUE FROM PARAMETERS WHERE PARAM_NAME=?");
+ ps.setString(1, paramName);
+ rs = ps.executeQuery();
+ if (rs.next()) {
+ ret = rs.getString(1);
+ }
+ } catch (SQLException sqlEx) {
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Throwable t) {
+ }
+ }
+ if (ps != null) {
+ try {
+ ps.close();
+ } catch (Throwable t) {
+ }
+ }
+ if (con != null) {
+ PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ return ret;
+ }
+ public static void setParameterValue(final String paramName, final String paramValue) {
+ Connection con = null;
+ PreparedStatement ps = null;
+ try {
+ con = PoolManager.getInstance().getConnection();
+ String ret = getParameterValue(paramName);
+ if (ret == null) {
+ ps = con.prepareStatement("INSERT INTO PARAMETERS (PARAM_VALUE, PARAM_NAME) VALUES (?, ?)");
+ } else {
+ ps = con.prepareStatement("UPDATE PARAMETERS SET PARAM_VALUE=? WHERE PARAM_NAME=?");
+ }
+ ps.setString(1, paramValue);
+ ps.setString(2, paramName);
+ ps.executeUpdate();
+ } catch (SQLException sqlEx) {
+ } finally {
+ if (ps != null) {
+ try {
+ ps.close();
+ } catch (Throwable t) {
+ }
+ }
+ if (con != null) {
+ PoolManager.getInstance().releaseConnection(con);
+ }
+ }
+ }
+ private static class EngineListModel extends ArrayList<Engine> implements ComboBoxModel {
+ private Engine currentItem;
+ private ArrayList<ListDataListener> dataListeners = new ArrayList<ListDataListener>();
+ @Override
+ public void setSelectedItem(Object anItem) {
+ if(anItem instanceof Engine) {
+ Engine anEngine = (Engine)anItem;
+ if(contains(anEngine)) {
+ currentItem = anEngine;
+ }
+ }
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return currentItem;
+ }
+
+ @Override
+ public int getSize() {
+ return size();
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ return get(index);
+ }
+
+ @Override
+ public void addListDataListener(ListDataListener l) {
+ dataListeners.add(l);
+ }
+
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+ dataListeners.remove(l);
+ }
+ }
+ public static boolean isLocalComputerServer(Connection con) {
+ try {
+ String url = con.getMetaData().getURL();
+ // url is jdbc:mysql://localhost/xemelios or jdbc:mysql://localhost:3307/xemelios
+ url = url.substring(13);
+ int pipePos = url.indexOf(':');
+ int slashPos = url.indexOf('/');
+ if (pipePos < 0) {
+ pipePos = 10000;
+ }
+ if (slashPos < 0) {
+ slashPos = 10000;
+ }
+ int pos = Math.min(pipePos, slashPos);
+ if (pos > url.length()) {
+ pos = url.length();
+ }
+ String server = url.substring(0, pos);
+ if(server.indexOf(":")>=0) {
+ // cas de la présence d'un port
+ server = server.substring(0, server.indexOf(":"));
+ }
+ if("localhost".equals(server)) {
+ logger.debug("localhost is local computer");
+ return true;
+ }
+ InetAddress serverAddress = InetAddress.getByName(server);
+ InetAddress localAddress = InetAddress.getLocalHost();
+ String localHostAddress = localAddress.getHostAddress();
+ String serverHostAddress = serverAddress.getHostAddress();
+ logger.debug("comparing "+localAddress.getHostAddress()+" to "+serverAddress.getHostAddress());
+ return localAddress.getHostAddress().equals(serverAddress.getHostAddress());
+ } catch (Exception uhEx) {
+ return false;
+ }
+ }
+
+ public boolean saveData() {
+ try {
+ String className = (((Engine)cbxEngine.getSelectedItem()).className);
+ ClassLoader cl = new URLClassLoader(new URL[]{},this.getClass().getClassLoader());
+ ClassChecker cc = new ClassChecker(className, cl);
+ if(cc.check()) {
+ setParameterValue(AuthEngine.Holder.DEFAULT_AUTH_ENGINE_SWING_CLASS_NAME_PROPERTY,className);
+ Properties props = model.getProps();
+ for(String key:props.stringPropertyNames()) {
+ setParameterValue(key, props.getProperty(key));
+ }
+ return true;
+ } else {
+ return false;
+ }
+ } catch(Exception ex) {
+ return false;
+ }
+ }
+
+ private class ClassChecker extends Thread {
+ private String className;
+ private ClassLoader cl;
+ private boolean returnStatus = true;
+ ClassChecker(String className, ClassLoader cl) {
+ super();
+ this.className=className;
+ this.cl=cl;
+ }
+ @Override
+ public void run() {
+ try {
+ Class.forName(className,false, cl);
+ } catch(Throwable t) {
+ returnStatus = false;
+ }
+ }
+ private boolean check() {
+ run();
+ try { join(); } catch( InterruptedException iEx) { returnStatus = false; }
+ return returnStatus;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jPanel2" alignment="0" max="32767" attributes="1"/>
+ <Component id="jPanel1" alignment="0" min="-2" max="-2" attributes="1"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="18" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Créer une nouvelle collectivité"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="lblNatId" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="cbxNatId" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblClef" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblLibelle" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="56" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="dfIdentifiant" max="32767" attributes="1"/>
+ <Component id="dfLibelle" alignment="0" min="-2" pref="357" max="-2" attributes="1"/>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace pref="106" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblNatId" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="cbxNatId" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblClef" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfIdentifiant" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblLibelle" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfLibelle" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="14" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblNatId">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Nature Identifiant"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="cbxNatId">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="0"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox(natIds);"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblClef">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Identifiant"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfIdentifiant">
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblLibelle">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Libellé"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfLibelle">
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Importer le référentiel de Collectivités / Budgets"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pbLoadRef" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbLoadRef" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="13" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="<html>
<p>Permet de charger le référentiel de collectivités / budgets maintenu par la DGFiP pour Helios.</p>
<p>Ce référentiel est disponible sous la forme d'un unique fichier déposé sur www.xemelios.org.</p>

<p>Ce référentiel est maintenu à jour et republié régulièrement.</p>
<p>L'installation du référentiel peut être longue et bloquer Xemelios pendant longtemps.</p>
</html>"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbLoadRef">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Installer le référentiel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbLoadRefActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.utils.xml.FactoryProvider;
+import fr.gouv.finances.dgfip.xemelios.common.Constants;
+import fr.gouv.finances.dgfip.xemelios.common.NetAccess;
+import fr.gouv.finances.dgfip.xemelios.data.DataLayerManager;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+import java.util.zip.GZIPInputStream;
+import javax.swing.JOptionPane;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author chm
+ */
+public class PnlCreateCollectivite extends javax.swing.JPanel {
+ private static final Logger logger = Logger.getLogger(PnlCreateCollectivite.class);
+ private Vector<Pair> natIds;
+ private DlgSelectCollectivite parent;
+ private PropertiesExpansion applicationProperties;
+
+ /** Creates new form PnlCreateCollectivite */
+ public PnlCreateCollectivite(DlgSelectCollectivite parent, PropertiesExpansion applicationProperties) {
+ super();
+ this.parent=parent;
+ this.applicationProperties = applicationProperties;
+ natIds = new Vector<Pair>();
+ for(String key:DlgCollectivitesUtilisateur.naturesIdentifiants.keySet()) {
+ natIds.add(new Pair(key,DlgCollectivitesUtilisateur.naturesIdentifiants.get(key)));
+ }
+ initComponents();
+ }
+
+ public List<DataHelper.CollectiviteLib> getSelectedData() {
+ ArrayList<DataHelper.CollectiviteLib> ret = new ArrayList<DataHelper.CollectiviteLib>();
+ if(dfIdentifiant.getText().length()>0 && dfLibelle.getText().length()>0) {
+ DataHelper.CollectiviteLib coll = new DataHelper.CollectiviteLib(((Pair)cbxNatId.getSelectedItem()).key, dfIdentifiant.getText(), dfLibelle.getText());
+ DataHelper.createCollectivite(coll);
+ ret.add(coll);
+ }
+ return ret;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ lblNatId = new javax.swing.JLabel();
+ cbxNatId = new javax.swing.JComboBox(natIds);
+ lblClef = new javax.swing.JLabel();
+ dfIdentifiant = new javax.swing.JTextField();
+ lblLibelle = new javax.swing.JLabel();
+ dfLibelle = new javax.swing.JTextField();
+ jPanel2 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ pbLoadRef = new javax.swing.JButton();
+
+ jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Créer une nouvelle collectivité"));
+
+ lblNatId.setText("Nature Identifiant");
+
+ lblClef.setText("Identifiant");
+
+ lblLibelle.setText("Libellé");
+
+ org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(lblNatId)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(cbxNatId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblClef)
+ .add(lblLibelle))
+ .add(56, 56, 56)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(dfIdentifiant)
+ .add(dfLibelle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 357, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
+ .addContainerGap(106, Short.MAX_VALUE))
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblNatId)
+ .add(cbxNatId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblClef)
+ .add(dfIdentifiant, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblLibelle)
+ .add(dfLibelle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(14, Short.MAX_VALUE))
+ );
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Importer le référentiel de Collectivités / Budgets"));
+
+ jLabel1.setText("<html>\n<p>Permet de charger le référentiel de collectivités / budgets maintenu par la DGFiP pour Helios.</p>\n<p>Ce référentiel est disponible sous la forme d'un unique fichier déposé sur www.xemelios.org.</p>\n\n<p>Ce référentiel est maintenu à jour et republié régulièrement.</p>\n<p>L'installation du référentiel peut être longue et bloquer Xemelios pendant longtemps.</p>\n</html>");
+
+ pbLoadRef.setText("Installer le référentiel");
+ pbLoadRef.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbLoadRefActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel2Layout.createSequentialGroup()
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
+ .add(pbLoadRef)
+ .addContainerGap())))
+ );
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbLoadRef)
+ .addContainerGap(13, Short.MAX_VALUE))
+ );
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbLoadRefActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbLoadRefActionPerformed
+ DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ parent.getGlassPane().setVisible(true);
+ try {
+ String actualDate = DataLayerManager.getImplementation().getParameterValue("referentiel.collectivite.last.update");
+ Date actualRefDate = actualDate!=null ? sdf.parse(actualDate) : new Date(0);
+ HttpClient client = NetAccess.getHttpClient(applicationProperties);
+ URL refUrl = new URL(applicationProperties.getProperty(Constants.SYS_PROP_AUTH_REF_URL,"http://www.xemelios.org/collectivites/referentiel.xml"));
+ GetMethod meth = new GetMethod(refUrl.toURI().toString());
+ int httpRet = client.executeMethod(meth);
+ if(httpRet>300) throw new Exception(meth.getStatusText());
+ InputStream is = meth.getResponseBodyAsStream();
+ DocumentBuilderFactory domFactory = FactoryProvider.getDocumentBuilderFactory();
+ DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
+ Document refColls = domBuilder.parse(is);
+ XPathFactory xpf = FactoryProvider.getXPathFactory();
+ XPath xp = xpf.newXPath();
+ String fileToLoad = null;
+ Date updateDate = actualRefDate;
+ NodeList nl = (NodeList)xp.evaluate("/ref-collectivites/referentiel", refColls, XPathConstants.NODESET);
+ for(int i=0;i<nl.getLength();i++) {
+ Element el = (Element)nl.item(i);
+ String fileName = (String)xp.evaluate("./file/text()",el);
+ Date date = sdf.parse((String)xp.evaluate("./date/text()",el));
+ if(date.after(updateDate)) {
+ fileToLoad = fileName;
+ updateDate = date;
+ }
+ }
+ if(fileToLoad==null) {
+ JOptionPane.showMessageDialog(this, "Votre référentiel est à jour.");
+ } else {
+ URL url = new URL(refUrl,fileToLoad);
+ meth = new GetMethod(url.toURI().toString());
+ httpRet = client.executeMethod(meth);
+ if(httpRet>300) throw new Exception(meth.getStatusText());
+ is = meth.getResponseBodyAsStream();
+ GZIPInputStream gzis = new GZIPInputStream(is);
+ BufferedReader br = new BufferedReader(new InputStreamReader(gzis));
+ String l = null;
+ while((l=br.readLine()) != null) {
+ saveLine(l);
+ }
+ br.close();
+ DataLayerManager.getImplementation().setParameterValue("referentiel.collectivite.last.update", sdf.format(updateDate));
+ }
+ } catch(Exception ex) {
+ logger.error("loadRef",ex);
+ } finally {
+ parent.getGlassPane().setVisible(false);
+ }
+ }//GEN-LAST:event_pbLoadRefActionPerformed
+
+ private void saveLine(String line) {
+ String[] vals = line.split(";");
+ String siret = vals[5];
+ String idColl = vals[1]+vals[3]+vals[4];
+ String libelle = vals[7];
+ String codic = vals[1];
+ String libCodic = vals[2];
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("SIRET",siret,libelle));
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("IDCOLL",idColl,libelle));
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("CODIC",codic,libCodic));
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("VARIABLE",siret,libelle));
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("VARIABLE",idColl,libelle));
+ DataHelper.updateCollectivite(new DataHelper.CollectiviteLib("VARIABLE",codic,libCodic));
+
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JComboBox cbxNatId;
+ private javax.swing.JTextField dfIdentifiant;
+ private javax.swing.JTextField dfLibelle;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JLabel lblClef;
+ private javax.swing.JLabel lblLibelle;
+ private javax.swing.JLabel lblNatId;
+ private javax.swing.JButton pbLoadRef;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="jScrollPane1" pref="266" max="32767" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="pbRemoveProfil" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbAddProfil" alignment="0" min="-2" pref="32" max="-2" attributes="1"/>
+ </Group>
+ <EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="chkImport" min="-2" max="-2" attributes="0"/>
+ <Component id="chkConnect" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="chkDelete" min="-2" max="-2" attributes="0"/>
+ <Component id="chkSearch" min="-2" max="-2" attributes="0"/>
+ <Component id="chkNavigate" min="-2" max="-2" attributes="0"/>
+ <Component id="chkExport" min="-2" max="-2" attributes="0"/>
+ <Component id="chkAdminUser" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pbAddProfil" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveProfil" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="chkConnect" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkImport" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkDelete" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkSearch" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkNavigate" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkExport" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="chkAdminUser" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Component id="jScrollPane1" pref="255" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Profils"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstProfils">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
+ <StringArray count="0"/>
+ </Property>
+ <Property name="selectionMode" type="int" value="0"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JList(lm)"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbAddProfil">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/add.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Nouveau profil..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddProfilActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveProfil">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Supprimer ce profil..."/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveProfilActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkConnect">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Connection"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkConnect" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkImport">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Import"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkImport" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkDelete">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Suppression"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkDelete" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkSearch">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Recherche"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkSearch" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkNavigate">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Navigation"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkNavigate" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkExport">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Export"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkExport" noResource="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkAdminUser">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Administration utilisateurs"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="name" type="java.lang.String" value="chkAdminUser" noResource="true"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.xemelios.auth.XemeliosUser;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.StdDbAuthEngineImpl;
+import java.util.ArrayList;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper.Profil;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+import java.util.TreeSet;
+import javax.swing.AbstractListModel;
+import javax.swing.JCheckBox;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author chm
+ */
+public class PnlProfils extends javax.swing.JPanel {
+ private ArrayList<Profil> profils;
+ private ProfilListModel lm;
+ private DlgAdmin dlgAdmin;
+
+ /** Creates new form PnlProfils */
+ public PnlProfils(DlgAdmin dlgAdmin, ArrayList<Profil> profils) {
+ super();
+ this.dlgAdmin=dlgAdmin;
+ this.profils = profils;
+ lm = new ProfilListModel(profils);
+ initComponents();
+ lstProfils.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ boolean hasSelected = lstProfils.getSelectedIndex() >= -1;
+ chkConnect.setEnabled(hasSelected);
+ chkDelete.setEnabled(hasSelected);
+ chkExport.setEnabled(hasSelected);
+ chkImport.setEnabled(hasSelected);
+ chkNavigate.setEnabled(hasSelected);
+ chkSearch.setEnabled(hasSelected);
+ chkAdminUser.setEnabled(hasSelected);
+ if(hasSelected) {
+ Profil p = (Profil)lstProfils.getSelectedValue();
+ if(p!=null) {
+ chkConnect.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_CONNECT));
+ chkDelete.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_CLEAN));
+ chkExport.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_EXPORT));
+ chkImport.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_IMPORT));
+ chkNavigate.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_BROWSE));
+ chkSearch.setSelected(p.getFonctionnalites().contains(XemeliosUser.ROLE_SEARCH));
+ chkAdminUser.setSelected(p.getFonctionnalites().contains(StdDbAuthEngineImpl.ROLE_ADMIN));
+ } else {
+ chkConnect.setEnabled(false);
+ chkDelete.setEnabled(false);
+ chkExport.setEnabled(false);
+ chkImport.setEnabled(false);
+ chkNavigate.setEnabled(false);
+ chkSearch.setEnabled(false);
+ chkAdminUser.setEnabled(false);
+ }
+ } else {
+ pbRemoveProfil.setEnabled(false);
+ }
+ pbRemoveProfil.setEnabled(hasSelected);
+ }
+ });
+ chkAdminUser.addActionListener(new ChkActionListener(StdDbAuthEngineImpl.ROLE_ADMIN));
+ chkConnect.addActionListener(new ChkActionListener(XemeliosUser.ROLE_CONNECT));
+ chkDelete.addActionListener(new ChkActionListener(XemeliosUser.ROLE_CLEAN));
+ chkExport.addActionListener(new ChkActionListener(XemeliosUser.ROLE_EXPORT));
+ chkImport.addActionListener(new ChkActionListener(XemeliosUser.ROLE_IMPORT));
+ chkNavigate.addActionListener(new ChkActionListener(XemeliosUser.ROLE_BROWSE));
+ chkSearch.addActionListener(new ChkActionListener(XemeliosUser.ROLE_SEARCH));
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ lstProfils = new javax.swing.JList(lm);
+ pbAddProfil = new javax.swing.JButton();
+ pbRemoveProfil = new javax.swing.JButton();
+ chkConnect = new javax.swing.JCheckBox();
+ chkImport = new javax.swing.JCheckBox();
+ chkDelete = new javax.swing.JCheckBox();
+ chkSearch = new javax.swing.JCheckBox();
+ chkNavigate = new javax.swing.JCheckBox();
+ chkExport = new javax.swing.JCheckBox();
+ chkAdminUser = new javax.swing.JCheckBox();
+
+ jLabel1.setText("Profils");
+
+ lstProfils.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ jScrollPane1.setViewportView(lstProfils);
+
+ pbAddProfil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/add.png"))); // NOI18N
+ pbAddProfil.setToolTipText("Nouveau profil...");
+ pbAddProfil.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddProfilActionPerformed(evt);
+ }
+ });
+
+ pbRemoveProfil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"))); // NOI18N
+ pbRemoveProfil.setToolTipText("Supprimer ce profil...");
+ pbRemoveProfil.setEnabled(false);
+ pbRemoveProfil.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveProfilActionPerformed(evt);
+ }
+ });
+
+ chkConnect.setText("Connection");
+ chkConnect.setEnabled(false);
+ chkConnect.setName("chkConnect"); // NOI18N
+
+ chkImport.setText("Import");
+ chkImport.setEnabled(false);
+ chkImport.setName("chkImport"); // NOI18N
+
+ chkDelete.setText("Suppression");
+ chkDelete.setEnabled(false);
+ chkDelete.setName("chkDelete"); // NOI18N
+
+ chkSearch.setText("Recherche");
+ chkSearch.setEnabled(false);
+ chkSearch.setName("chkSearch"); // NOI18N
+
+ chkNavigate.setText("Navigation");
+ chkNavigate.setEnabled(false);
+ chkNavigate.setName("chkNavigate"); // NOI18N
+
+ chkExport.setText("Export");
+ chkExport.setEnabled(false);
+ chkExport.setName("chkExport"); // NOI18N
+
+ chkAdminUser.setText("Administration utilisateurs");
+ chkAdminUser.setEnabled(false);
+ chkAdminUser.setName("chkAdminUser"); // NOI18N
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(pbRemoveProfil, 0, 0, Short.MAX_VALUE)
+ .add(pbAddProfil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(18, 18, 18)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(chkImport)
+ .add(chkConnect)
+ .add(chkDelete)
+ .add(chkSearch)
+ .add(chkNavigate)
+ .add(chkExport)
+ .add(chkAdminUser))
+ .addContainerGap())
+ .add(layout.createSequentialGroup()
+ .add(jLabel1)
+ .addContainerGap(484, Short.MAX_VALUE))))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(pbAddProfil)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveProfil))
+ .add(layout.createSequentialGroup()
+ .add(chkConnect)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkImport)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkDelete)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkSearch)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkNavigate)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkExport)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(chkAdminUser))
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbAddProfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddProfilActionPerformed
+ DlgCreateCodeLib dlg = new DlgCreateCodeLib(dlgAdmin, "Nouveau profil", "Profil");
+ if(dlg.run()) {
+ Pair ret = dlg.getRet();
+ Profil profil = new Profil(ret.key,ret.libelle);
+ if(DataHelper.createProfil(profil)) {
+ lm.addProfil(profil);
+ }
+ }
+ }//GEN-LAST:event_pbAddProfilActionPerformed
+
+ private void pbRemoveProfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveProfilActionPerformed
+ Profil profil = (Profil)lstProfils.getSelectedValue();
+ if(JOptionPane.showConfirmDialog(this, "Etes-vous bien sûr de vouloir supprimer le profil "+profil.getLibelle()+" ?")==JOptionPane.YES_OPTION) {
+ if(DataHelper.removeProfil(profil)) {
+ lm.removeProfil(profil);
+ }
+ }
+ }//GEN-LAST:event_pbRemoveProfilActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JCheckBox chkAdminUser;
+ private javax.swing.JCheckBox chkConnect;
+ private javax.swing.JCheckBox chkDelete;
+ private javax.swing.JCheckBox chkExport;
+ private javax.swing.JCheckBox chkImport;
+ private javax.swing.JCheckBox chkNavigate;
+ private javax.swing.JCheckBox chkSearch;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JList lstProfils;
+ private javax.swing.JButton pbAddProfil;
+ private javax.swing.JButton pbRemoveProfil;
+ // End of variables declaration//GEN-END:variables
+
+ private class ProfilListModel extends AbstractListModel {
+ private TreeSet<Profil> data;
+
+ public ProfilListModel(ArrayList<Profil> data) {
+ this.data = new TreeSet<Profil>();
+ this.data.addAll(data);
+ }
+
+ public Object getElementAt(int index) {
+ Iterator<Profil> it = data.iterator();
+ for(int i=0;i<index;i++) {
+ it.next();
+ }
+ return it.next();
+ }
+
+ public int getSize() {
+ return this.data.size();
+ }
+
+ protected int getIndexOf(Profil profil) {
+ Iterator<Profil> it = data.iterator();
+ for(int i=0;i<data.size();i++) {
+ Profil p = it.next();
+ if(p.equals(profil)) return i;
+ }
+ return -1;
+ }
+ public void addProfil(Profil profil) {
+ if(!data.contains(profil)) {
+ data.add(profil);
+ int pos = getIndexOf(profil);
+ fireIntervalAdded(lstProfils, pos, pos);
+ lstProfils.setSelectedIndex(pos);
+ }
+ }
+
+ public void removeProfil(Profil profil) {
+ int pos = getIndexOf(profil);
+ data.remove(profil);
+ fireIntervalRemoved(lstProfils, pos, pos);
+ }
+
+ }
+ private class ChkActionListener implements ActionListener {
+ private String fonctionnalite;
+ public ChkActionListener(String fonctionnalite) {
+ super();
+ this.fonctionnalite=fonctionnalite;
+ }
+ public void actionPerformed(ActionEvent e) {
+ JCheckBox chk = (JCheckBox)e.getSource();
+ boolean selected = chk.isSelected();
+ Profil p = (Profil)lstProfils.getSelectedValue();
+ if(selected) p.getFonctionnalites().add(fonctionnalite);
+ else p.getFonctionnalites().remove(fonctionnalite);
+ DataHelper.saveProfil(p);
+ }
+
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane1" alignment="0" pref="389" max="32767" attributes="0"/>
+ <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <Component id="jPanel2" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jScrollPane1" pref="174" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Critères"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblNatId" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblId" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblLib" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="cbxNatIds" min="-2" pref="115" max="-2" attributes="0"/>
+ <EmptySpace pref="90" max="32767" attributes="0"/>
+ <Component id="pbSearch" min="-2" pref="28" max="-2" attributes="0"/>
+ </Group>
+ <Component id="dfId" alignment="0" pref="233" max="32767" attributes="1"/>
+ <Component id="dfLib" alignment="1" pref="233" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblNatId" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="cbxNatIds" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbSearch" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblId" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfId" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblLib" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfLib" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblNatId">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Nature Identifiant"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblId">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Identifiant"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblLib">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Libellé"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfLib">
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfId">
+ </Component>
+ <Component class="javax.swing.JComboBox" name="cbxNatIds">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="0"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox(natIds)"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbSearch">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/search.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Chercher"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbSearchActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="org.jdesktop.swingx.JXTable" name="tblCollectivite">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="model" type="code"/>
+ </Property>
+ <Property name="columnControlVisible" type="boolean" value="true"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
+ <Property name="horizontalGap" type="int" value="0"/>
+ <Property name="verticalGap" type="int" value="0"/>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="pbFirstPage">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/page-first.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Première page"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 0, 2, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbFirstPageActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbPreviousPage">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/page-previous.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Page précédente"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 0, 2, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbPreviousPageActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblPages">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="0 / 0"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbNextPage">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/page-next.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Page suivante"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 0, 2, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbNextPageActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbLastPage">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/page-last.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Dernière page"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[2, 0, 2, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbLastPageActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.utils.Pair;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ *
+ * @author chm
+ */
+public class PnlSearchCollectivite extends javax.swing.JPanel {
+ private static final int PAGE_SIZE = 100;
+ private String lastNatId;
+ private String lastCode;
+ private String lastLibelle;
+ private int currentPage;
+ private int foundRecords = 0;
+ private int lastPage;
+ private DlgCollectivitesUtilisateur.TableCollectivitesModel model;
+ private ArrayList<DataHelper.CollectiviteLib> selectedCollectivites;
+ private Vector<Pair> natIds;
+
+ /** Creates new form PnlSearchCollectivite */
+ public PnlSearchCollectivite() {
+ model = new DlgCollectivitesUtilisateur.TableCollectivitesModel(new ArrayList<DataHelper.CollectiviteLib>());
+ natIds = new Vector<Pair>();
+ natIds.add(new Pair("*","Tous"));
+ for(String key: DlgCollectivitesUtilisateur.naturesIdentifiants.keySet()) {
+ natIds.add(new Pair(key,DlgCollectivitesUtilisateur.naturesIdentifiants.get(key)));
+ }
+ initComponents();
+ }
+ public ArrayList<DataHelper.CollectiviteLib> getSelectedData() {
+ selectedCollectivites = new ArrayList<DataHelper.CollectiviteLib>();
+ int [] rows = tblCollectivite.getSelectedRows();
+ for(int i:rows) {
+ DataHelper.CollectiviteLib coll = model.getElementAt(i);
+ selectedCollectivites.add(coll);
+ }
+ return selectedCollectivites;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ lblNatId = new javax.swing.JLabel();
+ lblId = new javax.swing.JLabel();
+ lblLib = new javax.swing.JLabel();
+ dfLib = new javax.swing.JTextField();
+ dfId = new javax.swing.JTextField();
+ cbxNatIds = new javax.swing.JComboBox(natIds);
+ pbSearch = new javax.swing.JButton();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tblCollectivite = new org.jdesktop.swingx.JXTable();
+ jPanel2 = new javax.swing.JPanel();
+ pbFirstPage = new javax.swing.JButton();
+ pbPreviousPage = new javax.swing.JButton();
+ lblPages = new javax.swing.JLabel();
+ pbNextPage = new javax.swing.JButton();
+ pbLastPage = new javax.swing.JButton();
+
+ jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Critères"));
+
+ lblNatId.setText("Nature Identifiant");
+
+ lblId.setText("Identifiant");
+
+ lblLib.setText("Libellé");
+
+ pbSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/search.png"))); // NOI18N
+ pbSearch.setToolTipText("Chercher");
+ pbSearch.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbSearchActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblNatId)
+ .add(lblId)
+ .add(lblLib))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(cbxNatIds, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 115, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 90, Short.MAX_VALUE)
+ .add(pbSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(dfId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, dfLib, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblNatId)
+ .add(cbxNatIds, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(pbSearch))
+ .add(7, 7, 7)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblId)
+ .add(dfId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblLib)
+ .add(dfLib, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ );
+
+ tblCollectivite.setModel(model);
+ tblCollectivite.setColumnControlVisible(true);
+ jScrollPane1.setViewportView(tblCollectivite);
+
+ jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));
+
+ pbFirstPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/page-first.png"))); // NOI18N
+ pbFirstPage.setToolTipText("Première page");
+ pbFirstPage.setEnabled(false);
+ pbFirstPage.setMargin(new java.awt.Insets(2, 0, 2, 0));
+ pbFirstPage.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbFirstPageActionPerformed(evt);
+ }
+ });
+ jPanel2.add(pbFirstPage);
+
+ pbPreviousPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/page-previous.png"))); // NOI18N
+ pbPreviousPage.setToolTipText("Page précédente");
+ pbPreviousPage.setEnabled(false);
+ pbPreviousPage.setMargin(new java.awt.Insets(2, 0, 2, 0));
+ pbPreviousPage.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbPreviousPageActionPerformed(evt);
+ }
+ });
+ jPanel2.add(pbPreviousPage);
+
+ lblPages.setText("0 / 0");
+ jPanel2.add(lblPages);
+
+ pbNextPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/page-next.png"))); // NOI18N
+ pbNextPage.setToolTipText("Page suivante");
+ pbNextPage.setEnabled(false);
+ pbNextPage.setMargin(new java.awt.Insets(2, 0, 2, 0));
+ pbNextPage.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbNextPageActionPerformed(evt);
+ }
+ });
+ jPanel2.add(pbNextPage);
+
+ pbLastPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/page-last.png"))); // NOI18N
+ pbLastPage.setToolTipText("Dernière page");
+ pbLastPage.setEnabled(false);
+ pbLastPage.setMargin(new java.awt.Insets(2, 0, 2, 0));
+ pbLastPage.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbLastPageActionPerformed(evt);
+ }
+ });
+ jPanel2.add(pbLastPage);
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+ .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbSearchActionPerformed
+ lastNatId = ((Pair)cbxNatIds.getSelectedItem()).key;
+ lastCode = dfId.getText().length()>0?dfId.getText():null;
+ lastLibelle = dfLib.getText().length()>0?dfLib.getText():null;
+
+ DataHelper.CollectiviteResponse resp = DataHelper.searchCollectivites(
+ lastNatId,
+ lastCode,
+ lastLibelle,
+ 0, PAGE_SIZE);
+ model.setData(resp.getData());
+ foundRecords = resp.getFoundRecords();
+ pbFirstPage.setEnabled(false);
+ pbPreviousPage.setEnabled(false);
+ pbNextPage.setEnabled(resp.getFoundRecords()>PAGE_SIZE);
+ pbLastPage.setEnabled(resp.getFoundRecords()>PAGE_SIZE);
+ currentPage = 0;
+ lastPage = foundRecords / PAGE_SIZE;
+ updatePageDisplay();
+ }//GEN-LAST:event_pbSearchActionPerformed
+
+ private void updatePageDisplay () {
+ lblPages.setText((currentPage+1)+" / "+(lastPage+1));
+ }
+ private void pbFirstPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbFirstPageActionPerformed
+ DataHelper.CollectiviteResponse resp = DataHelper.searchCollectivites(
+ lastNatId,
+ lastCode,
+ lastLibelle,
+ 0, PAGE_SIZE);
+ model.setData(resp.getData());
+ foundRecords = resp.getFoundRecords();
+ pbFirstPage.setEnabled(false);
+ pbPreviousPage.setEnabled(false);
+ pbNextPage.setEnabled(resp.getFoundRecords()>PAGE_SIZE);
+ pbLastPage.setEnabled(resp.getFoundRecords()>PAGE_SIZE);
+ currentPage = 0;
+ updatePageDisplay();
+ }//GEN-LAST:event_pbFirstPageActionPerformed
+
+ private void pbPreviousPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbPreviousPageActionPerformed
+ DataHelper.CollectiviteResponse resp = DataHelper.searchCollectivites(
+ lastNatId,
+ lastCode,
+ lastLibelle,
+ (currentPage--), PAGE_SIZE);
+ model.setData(resp.getData());
+ foundRecords = resp.getFoundRecords();
+ pbFirstPage.setEnabled(currentPage>0);
+ pbPreviousPage.setEnabled(currentPage>0);
+ pbNextPage.setEnabled(lastPage > currentPage);
+ pbLastPage.setEnabled(lastPage > currentPage);
+ updatePageDisplay();
+ }//GEN-LAST:event_pbPreviousPageActionPerformed
+
+ private void pbNextPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbNextPageActionPerformed
+ DataHelper.CollectiviteResponse resp = DataHelper.searchCollectivites(
+ lastNatId,
+ lastCode,
+ lastLibelle,
+ (currentPage++), PAGE_SIZE);
+ model.setData(resp.getData());
+ foundRecords = resp.getFoundRecords();
+ pbFirstPage.setEnabled(currentPage>0);
+ pbPreviousPage.setEnabled(currentPage>0);
+ pbNextPage.setEnabled(lastPage > currentPage);
+ pbLastPage.setEnabled(lastPage > currentPage);
+ updatePageDisplay();
+ }//GEN-LAST:event_pbNextPageActionPerformed
+
+ private void pbLastPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbLastPageActionPerformed
+ DataHelper.CollectiviteResponse resp = DataHelper.searchCollectivites(
+ lastNatId,
+ lastCode,
+ lastLibelle,
+ (currentPage = lastPage), PAGE_SIZE);
+ model.setData(resp.getData());
+ foundRecords = resp.getFoundRecords();
+ pbFirstPage.setEnabled(currentPage>0);
+ pbPreviousPage.setEnabled(currentPage>0);
+ pbNextPage.setEnabled(lastPage > currentPage);
+ pbLastPage.setEnabled(lastPage > currentPage);
+ updatePageDisplay();
+ }//GEN-LAST:event_pbLastPageActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JComboBox cbxNatIds;
+ private javax.swing.JTextField dfId;
+ private javax.swing.JTextField dfLib;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JLabel lblId;
+ private javax.swing.JLabel lblLib;
+ private javax.swing.JLabel lblNatId;
+ private javax.swing.JLabel lblPages;
+ private javax.swing.JButton pbFirstPage;
+ private javax.swing.JButton pbLastPage;
+ private javax.swing.JButton pbNextPage;
+ private javax.swing.JButton pbPreviousPage;
+ private javax.swing.JButton pbSearch;
+ private org.jdesktop.swingx.JXTable tblCollectivite;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jScrollPane1" alignment="0" pref="136" max="32767" attributes="2"/>
+ <Component id="dfUser" alignment="1" pref="136" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="pbRemoveUser" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbAddUser" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="pbSearch" alignment="0" pref="22" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="lblLogin" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="281" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblPrenom" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblNom" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblPassword" min="-2" max="-2" attributes="0"/>
+ <Component id="lblPwd2" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="dfLogin" pref="229" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="dfNom" alignment="0" min="-2" pref="209" max="-2" attributes="0"/>
+ <Component id="dfPrenom" alignment="1" pref="229" max="32767" attributes="0"/>
+ <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
+ <Component id="dfPassword2" alignment="0" max="32767" attributes="1"/>
+ <Component id="dfPassword1" alignment="0" pref="131" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="chkAllCollectivites" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="chkAllDocuments" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="chkAllFonctionalities" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="pbSave" alignment="1" pref="151" max="32767" attributes="0"/>
+ <Component id="pbChooseCollectivites" alignment="1" pref="151" max="32767" attributes="1"/>
+ <Component id="pbChooseDocuments" alignment="1" pref="151" max="32767" attributes="1"/>
+ <Component id="pbChooseProfils" alignment="0" pref="151" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="dfUser" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pbSearch" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="lblLogin" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfLogin" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblNom" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfNom" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="lblPrenom" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="dfPrenom" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="dfPassword1" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="dfPassword2" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="lblPwd2" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="pbSave" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="35" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbChooseProfils" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="chkAllFonctionalities" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbChooseDocuments" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="chkAllDocuments" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pbChooseCollectivites" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="chkAllCollectivites" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <Component id="jScrollPane1" pref="275" max="32767" attributes="0"/>
+ <Group type="102" attributes="0">
+ <Component id="pbAddUser" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pbRemoveUser" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Chercher des utilisateurs"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfUser">
+ </Component>
+ <Component class="javax.swing.JButton" name="pbSearch">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/search.png"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbSearchActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JList" name="lstUsers">
+ <Properties>
+ <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
+ <StringArray count="0"/>
+ </Property>
+ <Property name="selectionMode" type="int" value="0"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="pbAddUser">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/add.png"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbAddUserActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbRemoveUser">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"/>
+ </Property>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbRemoveUserActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblLogin">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="dfLogin"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Login"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfLogin">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblNom">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="dfNom"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Nom"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfNom">
+ <Properties>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="dfNomCaretUpdate"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblPrenom">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="dfPrenom"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Prénom"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="dfPrenom">
+ <Properties>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="dfPrenomCaretUpdate"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblPassword">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="dfPassword1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Mot de passe"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JPasswordField" name="dfPassword1">
+ <Properties>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="dfPassword1CaretUpdate"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblPwd2">
+ <Properties>
+ <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="dfPassword2"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Répéter"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JPasswordField" name="dfPassword2">
+ <Properties>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="dfPassword2CaretUpdate"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkAllFonctionalities">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Toutes fonctionnalités"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkAllFonctionalitiesActionPerformed"/>
+ <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="chkAllFonctionalitiesStateChanged"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbChooseProfils">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Profils..."/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbChooseProfilsActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkAllDocuments">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Tous documents"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkAllDocumentsActionPerformed"/>
+ <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="chkAllDocumentsStateChanged"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbChooseDocuments">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Documents..."/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbChooseDocumentsActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="chkAllCollectivites">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Toutes collectivités"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkAllCollectivitesActionPerformed"/>
+ <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="chkAllCollectivitesStateChanged"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbChooseCollectivites">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Collectivités..."/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbChooseCollectivitesActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="pbSave">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Enregistrer"/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pbSaveActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * Copyright
+ * 2009 axYus - www.axyus.com
+ * 2009 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS 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.
+ *
+ * XEMELIOS 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 XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.DataHelper;
+import fr.gouv.finances.dgfip.xemelios.common.Crypter;
+import fr.gouv.finances.dgfip.xemelios.common.config.DocumentsModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.Loader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import javax.swing.JOptionPane;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author chm
+ */
+public class PnlUsers extends javax.swing.JPanel {
+ private static final Logger logger = Logger.getLogger(PnlUsers.class);
+ private DlgAdmin dlgAdmin;
+ private DataHelper.StdUser currentUser;
+ private DataHelper.StdUser[] users;
+ private PropertiesExpansion applicationProperties;
+
+ /** Creates new form PnlUsers */
+ public PnlUsers(DlgAdmin dlgAdmin, PropertiesExpansion applicationProperties) {
+ this.dlgAdmin=dlgAdmin;
+ this.applicationProperties = applicationProperties;
+ initComponents();
+ lstUsers.addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ boolean hasSelectedItem = (lstUsers.getSelectedIndex()>=0);
+ chkAllFonctionalities.setEnabled(hasSelectedItem);
+ chkAllDocuments.setEnabled(hasSelectedItem);
+ chkAllCollectivites.setEnabled(hasSelectedItem);
+ dfNom.setEnabled(hasSelectedItem);
+ dfPassword1.setEnabled(hasSelectedItem);
+ dfPassword1.setText("");
+ dfPassword2.setEnabled(hasSelectedItem);
+ dfPassword2.setText("");
+ dfPrenom.setEnabled(hasSelectedItem);
+ pbSave.setEnabled(false);
+ if(hasSelectedItem) {
+ currentUser = (DataHelper.StdUser)lstUsers.getSelectedValue();
+ pbRemoveUser.setEnabled(!PnlUsers.this.dlgAdmin.getConnectedUser().getId().equals(currentUser.getLogin()));
+ dfLogin.setText(currentUser.getLogin());
+ dfNom.setText(currentUser.getNom());
+ dfPrenom.setText(currentUser.getPrenom());
+ chkAllCollectivites.setSelected(currentUser.isAllCollectivites());
+ chkAllDocuments.setSelected(currentUser.isAlldocuments());
+ chkAllFonctionalities.setSelected(currentUser.isAllFonctionalities());
+ if(currentUser.getId()==-1) {
+ dfLogin.setEnabled(true);
+ dfLogin.setEditable(true);
+ } else {
+ dfLogin.setEnabled(false);
+ dfLogin.setEditable(false);
+ }
+ } else {
+ pbRemoveUser.setEnabled(false);
+ dfLogin.setText("");
+ dfNom.setText("");
+ dfPrenom.setText("");
+ dfPassword1.setText("");
+ dfPassword2.setText("");
+ chkAllCollectivites.setSelected(false);
+ chkAllDocuments.setSelected(false);
+ chkAllFonctionalities.setSelected(false);
+ pbChooseCollectivites.setEnabled(false);
+ pbChooseDocuments.setEnabled(false);
+ pbChooseProfils.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ dfUser = new javax.swing.JTextField();
+ pbSearch = new javax.swing.JButton();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ lstUsers = new javax.swing.JList();
+ pbAddUser = new javax.swing.JButton();
+ pbRemoveUser = new javax.swing.JButton();
+ lblLogin = new javax.swing.JLabel();
+ dfLogin = new javax.swing.JTextField();
+ lblNom = new javax.swing.JLabel();
+ dfNom = new javax.swing.JTextField();
+ lblPrenom = new javax.swing.JLabel();
+ dfPrenom = new javax.swing.JTextField();
+ lblPassword = new javax.swing.JLabel();
+ dfPassword1 = new javax.swing.JPasswordField();
+ lblPwd2 = new javax.swing.JLabel();
+ dfPassword2 = new javax.swing.JPasswordField();
+ chkAllFonctionalities = new javax.swing.JCheckBox();
+ pbChooseProfils = new javax.swing.JButton();
+ chkAllDocuments = new javax.swing.JCheckBox();
+ pbChooseDocuments = new javax.swing.JButton();
+ chkAllCollectivites = new javax.swing.JCheckBox();
+ pbChooseCollectivites = new javax.swing.JButton();
+ pbSave = new javax.swing.JButton();
+
+ jLabel1.setText("Chercher des utilisateurs");
+
+ pbSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/search.png"))); // NOI18N
+ pbSearch.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbSearchActionPerformed(evt);
+ }
+ });
+
+ lstUsers.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ jScrollPane1.setViewportView(lstUsers);
+
+ pbAddUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/add.png"))); // NOI18N
+ pbAddUser.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbAddUserActionPerformed(evt);
+ }
+ });
+
+ pbRemoveUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fr/gouv/finances/cp/xemelios/ui/resources/deleteRow.png"))); // NOI18N
+ pbRemoveUser.setEnabled(false);
+ pbRemoveUser.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbRemoveUserActionPerformed(evt);
+ }
+ });
+
+ lblLogin.setLabelFor(dfLogin);
+ lblLogin.setText("Login");
+
+ dfLogin.setEditable(false);
+
+ lblNom.setLabelFor(dfNom);
+ lblNom.setText("Nom");
+
+ dfNom.setEnabled(false);
+ dfNom.addCaretListener(new javax.swing.event.CaretListener() {
+ public void caretUpdate(javax.swing.event.CaretEvent evt) {
+ dfNomCaretUpdate(evt);
+ }
+ });
+
+ lblPrenom.setLabelFor(dfPrenom);
+ lblPrenom.setText("Prénom");
+
+ dfPrenom.setEnabled(false);
+ dfPrenom.addCaretListener(new javax.swing.event.CaretListener() {
+ public void caretUpdate(javax.swing.event.CaretEvent evt) {
+ dfPrenomCaretUpdate(evt);
+ }
+ });
+
+ lblPassword.setLabelFor(dfPassword1);
+ lblPassword.setText("Mot de passe");
+
+ dfPassword1.setEnabled(false);
+ dfPassword1.addCaretListener(new javax.swing.event.CaretListener() {
+ public void caretUpdate(javax.swing.event.CaretEvent evt) {
+ dfPassword1CaretUpdate(evt);
+ }
+ });
+
+ lblPwd2.setLabelFor(dfPassword2);
+ lblPwd2.setText("Répéter");
+
+ dfPassword2.setEnabled(false);
+ dfPassword2.addCaretListener(new javax.swing.event.CaretListener() {
+ public void caretUpdate(javax.swing.event.CaretEvent evt) {
+ dfPassword2CaretUpdate(evt);
+ }
+ });
+
+ chkAllFonctionalities.setText("Toutes fonctionnalités");
+ chkAllFonctionalities.setEnabled(false);
+ chkAllFonctionalities.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ chkAllFonctionalitiesActionPerformed(evt);
+ }
+ });
+ chkAllFonctionalities.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ chkAllFonctionalitiesStateChanged(evt);
+ }
+ });
+
+ pbChooseProfils.setText("Profils...");
+ pbChooseProfils.setEnabled(false);
+ pbChooseProfils.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbChooseProfilsActionPerformed(evt);
+ }
+ });
+
+ chkAllDocuments.setText("Tous documents");
+ chkAllDocuments.setEnabled(false);
+ chkAllDocuments.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ chkAllDocumentsActionPerformed(evt);
+ }
+ });
+ chkAllDocuments.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ chkAllDocumentsStateChanged(evt);
+ }
+ });
+
+ pbChooseDocuments.setText("Documents...");
+ pbChooseDocuments.setEnabled(false);
+ pbChooseDocuments.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbChooseDocumentsActionPerformed(evt);
+ }
+ });
+
+ chkAllCollectivites.setText("Toutes collectivités");
+ chkAllCollectivites.setEnabled(false);
+ chkAllCollectivites.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ chkAllCollectivitesActionPerformed(evt);
+ }
+ });
+ chkAllCollectivites.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ chkAllCollectivitesStateChanged(evt);
+ }
+ });
+
+ pbChooseCollectivites.setText("Collectivités...");
+ pbChooseCollectivites.setEnabled(false);
+ pbChooseCollectivites.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbChooseCollectivitesActionPerformed(evt);
+ }
+ });
+
+ pbSave.setText("Enregistrer");
+ pbSave.setEnabled(false);
+ pbSave.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pbSaveActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
+ .add(dfUser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(pbRemoveUser, 0, 0, Short.MAX_VALUE)
+ .add(pbAddUser, 0, 0, Short.MAX_VALUE)
+ .add(pbSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, Short.MAX_VALUE))
+ .add(8, 8, 8)))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(lblLogin)
+ .add(281, 281, 281))
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblPrenom)
+ .add(lblNom)
+ .add(lblPassword)
+ .add(lblPwd2))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(dfLogin, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
+ .addContainerGap())
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(dfNom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 209, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(dfPrenom, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, dfPassword2)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, dfPassword1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)))
+ .add(12, 12, 12))))
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(chkAllCollectivites)
+ .add(22, 22, 22))
+ .add(chkAllDocuments))
+ .add(2, 2, 2))
+ .add(layout.createSequentialGroup()
+ .add(chkAllFonctionalities)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbSave, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbChooseCollectivites, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pbChooseDocuments, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
+ .add(pbChooseProfils, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE))
+ .addContainerGap())))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(dfUser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(pbSearch)
+ .add(lblLogin)
+ .add(dfLogin, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblNom)
+ .add(dfNom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lblPrenom)
+ .add(dfPrenom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(dfPassword1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblPassword))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(dfPassword2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblPwd2))
+ .add(18, 18, 18)
+ .add(pbSave)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbChooseProfils)
+ .add(chkAllFonctionalities))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbChooseDocuments)
+ .add(chkAllDocuments))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(pbChooseCollectivites)
+ .add(chkAllCollectivites)))
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
+ .add(layout.createSequentialGroup()
+ .add(pbAddUser)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pbRemoveUser)))
+ .addContainerGap())
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void pbSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbSearchActionPerformed
+ if(dfUser.getText()==null || dfUser.getText().length()==0) {
+ JOptionPane.showMessageDialog(this, "Vous devez saisir un critère de recherche.\nPar exemple * pour chercher tous les utilisateurs");
+ return;
+ }
+ ArrayList<DataHelper.StdUser> __users = DataHelper.getUsers(dfUser.getText());
+ users = new DataHelper.StdUser[__users.size()];
+ __users.toArray(users);
+ lstUsers.removeAll();
+ lstUsers.setListData(users);
+ }//GEN-LAST:event_pbSearchActionPerformed
+
+ private void dfNomCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_dfNomCaretUpdate
+ if(!dfNom.isEnabled()) return;
+ if(!dfNom.getText().equals(currentUser.getNom()) && (dfNom.getText().length()!=0 || currentUser.getNom()!=null)) pbSave.setEnabled(true);
+ }//GEN-LAST:event_dfNomCaretUpdate
+
+ private void dfPrenomCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_dfPrenomCaretUpdate
+ if(!dfPrenom.isEnabled()) return;
+ if(!dfPrenom.getText().equals(currentUser.getPrenom()) && (dfPrenom.getText().length()!=0 || currentUser.getNom()!=null)) pbSave.setEnabled(true);
+ }//GEN-LAST:event_dfPrenomCaretUpdate
+
+ private void dfPassword1CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_dfPassword1CaretUpdate
+ if(!dfPassword1.isEnabled()) return;
+ if(dfPassword1.getText().length()!=0) pbSave.setEnabled(true);
+ }//GEN-LAST:event_dfPassword1CaretUpdate
+
+ private void dfPassword2CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_dfPassword2CaretUpdate
+ if(!dfPassword2.isEnabled()) return;
+ if(dfPassword2.getText().length()!=0) pbSave.setEnabled(true);
+ }//GEN-LAST:event_dfPassword2CaretUpdate
+
+ private void chkAllFonctionalitiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAllFonctionalitiesActionPerformed
+ if(!chkAllFonctionalities.isEnabled()) return;
+ pbSave.setEnabled(true);
+ }//GEN-LAST:event_chkAllFonctionalitiesActionPerformed
+
+ private void chkAllCollectivitesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAllCollectivitesActionPerformed
+ if(!chkAllCollectivites.isEnabled()) return;
+ pbSave.setEnabled(true);
+ }//GEN-LAST:event_chkAllCollectivitesActionPerformed
+
+ private void chkAllDocumentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAllDocumentsActionPerformed
+ if(!chkAllDocuments.isEnabled()) return;
+ pbSave.setEnabled(true);
+ }//GEN-LAST:event_chkAllDocumentsActionPerformed
+
+ private void chkAllDocumentsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_chkAllDocumentsStateChanged
+ boolean selected = chkAllDocuments.isSelected();
+ pbChooseDocuments.setEnabled(!selected);
+ }//GEN-LAST:event_chkAllDocumentsStateChanged
+
+ private void chkAllFonctionalitiesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_chkAllFonctionalitiesStateChanged
+ boolean selected = chkAllFonctionalities.isSelected();
+ pbChooseProfils.setEnabled(!selected);
+ }//GEN-LAST:event_chkAllFonctionalitiesStateChanged
+
+ private void chkAllCollectivitesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_chkAllCollectivitesStateChanged
+ boolean selected = chkAllCollectivites.isSelected();
+ pbChooseCollectivites.setEnabled(!selected);
+ }//GEN-LAST:event_chkAllCollectivitesStateChanged
+
+ private void pbSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbSaveActionPerformed
+ if(!pbSave.isEnabled()) return;
+ if(dfLogin.isEnabled() && dfPassword1.getPassword().length==0) {
+ JOptionPane.showMessageDialog(this,"Les deux mots de passe sont obligatoires pour créer un utilisateur.", "Erreur", JOptionPane.ERROR_MESSAGE);
+ }
+ if(dfLogin.getText()==null || dfLogin.getText().length()==0) {
+ JOptionPane.showMessageDialog(this,"Le login est obligatoire pour créer un utilisateur.", "Erreur", JOptionPane.ERROR_MESSAGE);
+ }
+ if((dfPassword1.getPassword()!=null || dfPassword2.getPassword()!=null) && !Arrays.equals(dfPassword1.getPassword(), dfPassword2.getPassword())) {
+ JOptionPane.showMessageDialog(this,"Les deux mots de passe doivent être identiques.", "Erreur", JOptionPane.ERROR_MESSAGE);
+ }
+ currentUser.setLogin(dfLogin.getText());
+ currentUser.setNom(dfNom.getText());
+ currentUser.setPrenom(dfPrenom.getText());
+ currentUser.setAllCollectivites(chkAllCollectivites.isSelected());
+ currentUser.setAllFonctionalities(chkAllFonctionalities.isSelected());
+ currentUser.setAlldocuments(chkAllDocuments.isSelected());
+ if(dfPassword1.getPassword().length>0) {
+ char[] clearPass = dfPassword1.getPassword();
+ String cryptedPass = Crypter.cryptPassword(new String(clearPass));
+ DataHelper.saveUser(currentUser,cryptedPass);
+ } else {
+ DataHelper.saveUser(currentUser);
+ }
+ dfLogin.setEditable(false);
+
+ for(ListSelectionListener lsl:lstUsers.getListSelectionListeners()) {
+ lsl.valueChanged(null);
+ }
+ }//GEN-LAST:event_pbSaveActionPerformed
+
+ private void pbAddUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbAddUserActionPerformed
+ DataHelper.StdUser user = new DataHelper.StdUser();
+ DataHelper.StdUser[] tmpUsers = new DataHelper.StdUser[users!=null?users.length+1:1];
+ if(users!=null)
+ System.arraycopy(users, 0, tmpUsers, 0, users.length);
+ tmpUsers[tmpUsers.length-1] = user;
+ users=tmpUsers;
+ lstUsers.setListData(users);
+ lstUsers.setSelectedIndex(users.length-1);
+ }//GEN-LAST:event_pbAddUserActionPerformed
+
+ private void pbRemoveUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbRemoveUserActionPerformed
+ if(JOptionPane.showConfirmDialog(this, "Etes-vous sur de vouloir supprimer cet utilisateur : "+currentUser.toString()+" ?")==JOptionPane.YES_OPTION) {
+ DataHelper.removeUser(currentUser);
+ DataHelper.StdUser[] tmpUsers = new DataHelper.StdUser[users.length-1];
+ int pos = lstUsers.getSelectedIndex();
+ if(pos>0)
+ System.arraycopy(users, 0, tmpUsers, 0, pos);
+ if(pos<users.length-1)
+ System.arraycopy(users, pos+1, tmpUsers, pos, users.length-pos-1);
+ users=tmpUsers;
+ lstUsers.setListData(users);
+ }
+ }//GEN-LAST:event_pbRemoveUserActionPerformed
+
+ private void pbChooseProfilsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbChooseProfilsActionPerformed
+ if(currentUser==null) return;
+ if(!pbChooseProfils.isEnabled()) return;
+ if(currentUser.getId()==-1) {
+ JOptionPane.showMessageDialog(this,"Vous devez enregistrer l'utilisateur avant\nde pouvoir lui définir ses profils.");
+ return;
+ }
+ DlgProfilsUtilisateur dlg = new DlgProfilsUtilisateur(dlgAdmin, currentUser);
+ dlg.run();
+ }//GEN-LAST:event_pbChooseProfilsActionPerformed
+
+ private void pbChooseDocumentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbChooseDocumentsActionPerformed
+ try {
+ DocumentsModel dm = Loader.getDocumentsInfos(null);
+ DlgDocumentsUtilisateur dlg = new DlgDocumentsUtilisateur(dlgAdmin, currentUser, dm);
+ dlg.run();
+ } catch(Exception ex) {
+ logger.error("pbChooseDocuemntsActionPerformed",ex);
+ }
+ }//GEN-LAST:event_pbChooseDocumentsActionPerformed
+
+ private void pbChooseCollectivitesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pbChooseCollectivitesActionPerformed
+ try {
+ DlgCollectivitesUtilisateur dlg = new DlgCollectivitesUtilisateur(dlgAdmin, currentUser, applicationProperties);
+ dlg.run();
+ } catch(Exception ex) {
+ logger.error("pbChooseCollectivitesActionPerformed",ex);
+ }
+ }//GEN-LAST:event_pbChooseCollectivitesActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JCheckBox chkAllCollectivites;
+ private javax.swing.JCheckBox chkAllDocuments;
+ private javax.swing.JCheckBox chkAllFonctionalities;
+ private javax.swing.JTextField dfLogin;
+ private javax.swing.JTextField dfNom;
+ private javax.swing.JPasswordField dfPassword1;
+ private javax.swing.JPasswordField dfPassword2;
+ private javax.swing.JTextField dfPrenom;
+ private javax.swing.JTextField dfUser;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JLabel lblLogin;
+ private javax.swing.JLabel lblNom;
+ private javax.swing.JLabel lblPassword;
+ private javax.swing.JLabel lblPrenom;
+ private javax.swing.JLabel lblPwd2;
+ private javax.swing.JList lstUsers;
+ private javax.swing.JButton pbAddUser;
+ private javax.swing.JButton pbChooseCollectivites;
+ private javax.swing.JButton pbChooseDocuments;
+ private javax.swing.JButton pbChooseProfils;
+ private javax.swing.JButton pbRemoveUser;
+ private javax.swing.JButton pbSave;
+ private javax.swing.JButton pbSearch;
+ // End of variables declaration//GEN-END:variables
+
+}
--- /dev/null
+Manifest-version: 1.0
+Jar-Version: @version@
+Jar-Content: @name@
+Main-Class: fr.gouv.finances.dgfip.xemelios.auth.CfgAuth
+
--- /dev/null
+Class-Path: core-xemelios.jar mysql-connector-java-5.0.6-bin.jar log4j.jar commons-dbcp-1.2.2.jar commons-pool-1.3.jar ../xemelios.jar mysql-data-impl.jar xml-marshall.jar swing-layout-1.0.jar