Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/fudaa/ebli/impression/EbliMiseEnPageDialog.java


1   /*
2    * @file         EbliPreferencesEntetePiedPage.java
3    * @creation     2001-10-02
4    * @modification $Date: 2003/01/17 11:12:24 $
5    * @license      GNU General Public License 2
6    * @copyright    (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne
7    * @mail         devel@fudaa.org
8    */
9   
10  package org.fudaa.ebli.impression;
11  
12  import java.awt.event.ActionEvent;
13  import java.awt.FlowLayout;
14  
15  import javax.swing.DefaultComboBoxModel;
16  import javax.swing.JComponent;
17  
18  import com.memoire.bu.BuInformationsDocument;
19  import com.memoire.bu.BuInformationsSoftware;
20  import com.memoire.bu.BuCommonInterface;
21  import com.memoire.bu.BuButton;
22  import com.memoire.bu.BuResource;
23  import com.memoire.bu.BuDialog;
24  import com.memoire.bu.BuComboBox;
25  import com.memoire.bu.BuPanel;
26  import com.memoire.bu.BuLabel;
27  import com.memoire.bu.BuGridLayout;
28  import com.memoire.bu.BuBorderLayout;
29  
30  import org.fudaa.ebli.commun.EbliPreferences;
31  import org.fudaa.ebli.ressource.EbliResource;
32  
33  /**
34   * Dialogue modifiant la mise en page d'une interface <code>EbliPageable</code>.
35   * L'interface doit etre un <code>JComponent</code> pour que les changements
36   * soient pris en compte et enregistres dans les ClientPorperty de ce
37   * <code>JComponent</code>. La classe <code>EblIpageableDelegate</code>
38   * gere ce type de modification.
39   *
40   * @version      $Id: EbliMiseEnPageDialog.java,v 1.6 2003/01/17 11:12:24 deniger Exp $
41   * @author       Fred Deniger
42   * @see          org.fudaa.ebli.impression.EbliPageable
43   */
44  public class EbliMiseEnPageDialog extends BuDialog
45  {
46  
47    /**
48     * Le panel principal de ce dialog
49     */
50    BuPanel panelPrincipal_;
51  
52    /**
53     * Le panel charge de l'edition du EbliPageFormat.
54     */
55    EbliMiseEnPagePanel panelMiseEnPage_;
56  
57    /**
58     * L'interface concernee par ce diaogue.
59     */
60    EbliPageable target_;
61  
62    /**
63     * instancie tous les elements du dialogue.
64     *
65     * @param _app l'application generant ce dialogue. Peut etre nul.
66     * @param _is les infos utilisees pour le dialogue.Peut etre nul.
67     * @param _target L'interface a modifier. Ne doit pas etre nul.
68     */
69    public EbliMiseEnPageDialog(
70      EbliPageable _target,
71      BuCommonInterface _app,
72      BuInformationsSoftware _is)
73    {
74      super(_app, _is, EbliResource.EBLI.getString("Entete/Pied de page"), null);
75      if (_target == null)
76        System.err.println("EbliPageable null");
77      else
78      {
79        target_ = _target;
80        if (panelMiseEnPage_ == null)
81          getComponent();
82        panelMiseEnPage_.setEbliPageFormatInit(
83          target_.getDefaultEbliPageFormat());
84        panelMiseEnPage_.setEbliPageablePrevisualisation(target_);
85      }
86    }
87  
88    /**
89     * Renvoie le panel principal de ce dialogue.
90     */
91    public JComponent getComponent()
92    {
93      if (panelPrincipal_ == null)
94      {
95        panelPrincipal_ = new BuPanel();
96        panelPrincipal_.setLayout(new BuBorderLayout());
97        panelMiseEnPage_ = new EbliMiseEnPagePanel(null, null);
98        panelPrincipal_.add(panelMiseEnPage_, BuBorderLayout.CENTER);
99  
100       BuPanel panelBt = new BuPanel();
101       panelBt.setLayout(new FlowLayout(FlowLayout.RIGHT));
102       BuButton btAnnuler = new BuButton(BuResource.BU.getString("Annuler"));
103       btAnnuler.setIcon(BuResource.BU.getIcon("annuler"));
104       btAnnuler.setActionCommand("ANNULER");
105       btAnnuler.addActionListener(this);
106       panelBt.add(btAnnuler, 0);
107 
108       BuButton btAppliquer = new BuButton(BuResource.BU.getString("Appliquer"));
109       btAppliquer.setActionCommand("APPLIQUER");
110       btAppliquer.setIcon(BuResource.BU.getIcon("appliquer"));
111       btAppliquer.addActionListener(this);
112       panelBt.add(btAppliquer, 1);
113 
114       BuButton btValider = new BuButton(BuResource.BU.getString("Valider"));
115       btValider.setIcon(BuResource.BU.getIcon("valider"));
116       btValider.setActionCommand("VALIDER");
117       btValider.addActionListener(this);
118       panelBt.add(btValider, 2);
119       panelPrincipal_.add(panelBt, BuBorderLayout.SOUTH);
120     }
121     return panelPrincipal_;
122   }
123 
124 
125   private void majPageFormat()
126   {
127     EbliPageFormat pageFormatTarget = target_.getDefaultEbliPageFormat();
128     EbliPageFormat pageFormatModif =
129       panelMiseEnPage_.getEbliPageFormatModifie();
130     pageFormatTarget.setPiedVisible(pageFormatModif.isPiedVisible());
131     pageFormatTarget.setEnteteVisible(pageFormatModif.isEnteteVisible());
132     pageFormatTarget.setPageFormat(pageFormatModif.getPageFormat());
133     String[] temp = pageFormatModif.getEntete();
134     pageFormatTarget.setEntete(temp[0], temp[1], temp[2]);
135     temp = pageFormatModif.getPied();
136     pageFormatTarget.setPied(temp[0], temp[1], temp[2]);
137     if (target_ instanceof JComponent)
138     {
139       ((JComponent) target_).revalidate();
140     }
141   }
142 
143   /**
144    *
145    */
146   public void actionPerformed(ActionEvent _ae)
147   {
148     String commande = _ae.getActionCommand();
149     if ("APPLIQUER".equals(commande))
150     {
151       majPageFormat();
152     }
153     if ("ANNULER".equals(commande))
154     {
155       panelMiseEnPage_.setEbliPageFormatInit(
156         target_.getDefaultEbliPageFormat());
157     }
158     if ("VALIDER".equals(commande))
159     {
160       majPageFormat();
161       dispose();
162     }
163   }
164 }