--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 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
+ *
+ */
+
+/*
+ * Perme de rechercher un budget
+ *
+ * Created on 8 déc. 2011, 10:15:50
+ */
+
+package fr.gouv.finances.dgfip.xemelios.auth.impl.std.db.ui;
+
+import fr.gouv.finances.cp.utils.PropertiesExpansion;
+import fr.gouv.finances.cp.xemelios.ui.resulttable.EtatResultTableModel;
+import fr.gouv.finances.cp.xemelios.ui.search.PnlSearch;
+import fr.gouv.finances.dgfip.utils.Pair;
+import fr.gouv.finances.dgfip.xemelios.auth.XemeliosUser;
+import fr.gouv.finances.dgfip.xemelios.common.config.DocumentModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.ElementModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.EtatModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.HiddenModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.Loader;
+import fr.gouv.finances.dgfip.xemelios.data.DataHandler;
+import fr.gouv.finances.dgfip.xemelios.swing.InfiniteGlassPane;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import org.jdesktop.swingx.JXTable;
+
+/**
+ *
+ * @author cmarchand
+ */
+public class DlgBrowseReferentiel extends javax.swing.JDialog {
+ private PnlSearch searchPanel;
+ private AbstractAction closeAction;
+ private Pair collectivite;
+
+ /** Creates new form DlgBrowseReferentiel */
+ public DlgBrowseReferentiel(JDialog parent, XemeliosUser user, PropertiesExpansion applicationProperties) {
+ super(parent, "Choix du Budget", true);
+ DocumentModel __ref = null;
+ try {
+ __ref = Loader.getConfigurationFromLoadedFiles().getDocumentById("ref-collec-spl");
+ } catch(Exception ex) {
+ return;
+ }
+ final DocumentModel referentielDocumentModel = __ref;
+ final EtatModel etatModel = referentielDocumentModel.getEtatById("Referentiel");
+ ElementModel elementModel = etatModel.getElementById("Collectivite");
+ PnlSearch.DisplayParameters displayParameters = new PnlSearch.DisplayParameters();
+ displayParameters.setWidgetsVisible(false);
+ try {
+ searchPanel = new PnlSearch(referentielDocumentModel, etatModel, elementModel, displayParameters, user, applicationProperties) {
+ @Override
+ public void resizeParent(Rectangle bounds) { }
+ @Override
+ public void actionOnRowPerformed(MouseEvent evt, int row) {
+ row=((JXTable)getTable()).convertRowIndexToModel(row);
+ EtatResultTableModel etrm = (EtatResultTableModel)getTable().getModel();
+ DataHandler dh = etrm.getRowAt(row,0);
+ String id=null, libelle=null;
+ for(int pos=0;pos<etrm.getHiddens().size();pos++) {
+ HiddenModel hm = etrm.getHiddens().get(pos);
+ if(hm.getName().equals("idColl")) {
+ id = dh.getValueAtColumn(etrm.getListeChamps().size()+pos).toString();
+ } else if("libelle".equals(hm.getName())) {
+ libelle = dh.getValueAtColumn(etrm.getListeChamps().size()+pos).toString();
+ }
+ }
+ DlgBrowseReferentiel.this.collectivite = new Pair(id, libelle);
+ DlgBrowseReferentiel.this.setVisible(false);
+ }
+ @Override
+ public String getTitle() {
+ return etatModel.getTitre();
+ }
+ @Override
+ public void notifyParentStateChanged() { }
+ @Override
+ public void iconify(boolean iconified) { }
+ @Override
+ public void setTitle(String newTitle) { }
+ @Override
+ public void redisplayTitle() { }
+ @Override
+ public void startWaiter() {
+ getGlassPane().setVisible(true);
+ }
+ @Override
+ public void stopWaiter() {
+ getGlassPane().setVisible(false);
+ }
+ @Override
+ public boolean canExport() {
+ return false;
+ }
+ };
+ } catch(Exception tEx) {
+ // qu'est-ce qu'on en fait ?
+ }
+ initComponents();
+ setGlassPane(new InfiniteGlassPane());
+ pnl.add(searchPanel);
+ pack();
+ setLocationRelativeTo(getParent());
+ }
+
+ public Pair run() {
+ setVisible(true);
+ return collectivite;
+ }
+
+ /** 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() {
+
+ pnl = new javax.swing.JPanel();
+ pbClose = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ pnl.setLayout(new java.awt.BorderLayout());
+
+ pbClose.setAction(closeAction);
+ pbClose.setText("Fermer");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(pnl, javax.swing.GroupLayout.DEFAULT_SIZE, 991, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(pbClose))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(pnl, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(pbClose)
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ @Override
+ protected JRootPane createRootPane() {
+ closeAction = new AbstractAction("Fermer") {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ collectivite=null;
+ setVisible(false);
+ }
+ };
+ KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
+ JRootPane rp = new JRootPane();
+ rp.registerKeyboardAction(closeAction,"CLOSE",ks,JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return rp;
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton pbClose;
+ private javax.swing.JPanel pnl;
+ // End of variables declaration//GEN-END:variables
+
+}