/*
*Copyright 2007, 2011 CCLS Columbia University (USA), LIFO University of Orl��ans (France), BRGM (France)
*
*Authors: Cyril Nortet, Xiangrong Kong, Ansaf Salleb-Aouissi, Christel Vrain, Daniel Cassard
*
*This file is part of QuantMiner.
*
*QuantMiner 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 3 of the License, or any later version.
*
*QuantMiner 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 QuantMiner. If not, see <http://www.gnu.org/licenses/>.
*/
package src.graphicalInterface;
import javax.swing.*;
import src.solver.*;
import java.awt.*;
public class DatabasePanelAssistant extends DatabasePanel {//set window background color, next previous button
protected ResolutionContext m_contexteResolution = null;
private int m_iPanneauPrecedent = MainWindow.PANNEAU_AUCUN;
private int m_iPanneauSuivant = MainWindow.PANNEAU_AUCUN;
private int m_iNumeroEtape = 0;
private String m_sIntituleEtape = null;
private String m_sFichierAide = null;
private JIndicateSteps m_indicateurEtape = null;
// D�finit la zone dans laquelle les contr�les sp�cifiques aux assistants devraient se trouver :
public Rectangle m_zoneControles = null;
/** Creates new form PanneauBase */
public DatabasePanelAssistant(ResolutionContext contexteResolution) {
m_contexteResolution = contexteResolution;
m_iPanneauPrecedent = MainWindow.PANNEAU_AUCUN;
m_iPanneauSuivant = MainWindow.PANNEAU_AUCUN;
m_zoneControles = new Rectangle(0, 0, 0, 0);
}
// Initialize panel de base � partir d'un autre panel (le panel fils) :
public void initBaseComponents() {
// Initialization standard component :
initComponents(); //basic initial components are "previous" and "next" button
setBackground( new Color(192,192,192) ); //background color
// Display step/aid part of that panel :
m_indicateurEtape = new JIndicateSteps(m_iNumeroEtape, m_sIntituleEtape);
m_indicateurEtape.SpecifierFichierAide(m_sFichierAide);
add(m_indicateurEtape);
// previous/next button if visible:
if (m_iPanneauPrecedent == MainWindow.PANNEAU_AUCUN) //if no previous panel, then there is no previous step button
jButtonPrecedent.setVisible(false);
if (m_iPanneauSuivant == MainWindow.PANNEAU_AUCUN)
jButtonSuivant.setVisible(false);
RecalculerZoneControles();
}
private void RecalculerZoneControles() {
Rectangle rectElement = null;
int iHauteurPanneau = 0; //Hauteur means height
iHauteurPanneau = getHeight();
rectElement = new Rectangle( m_indicateurEtape.getBounds() );
m_zoneControles.x = rectElement.x;
m_zoneControles.width = rectElement.width;
m_zoneControles.y = rectElement.y + rectElement.height + 20;
m_zoneControles.height = iHauteurPanneau - m_zoneControles.y - 20;
if (m_iPanneauPrecedent != MainWindow.PANNEAU_AUCUN)
m_zoneControles.height -= (iHauteurPanneau - jButtonPrecedent.getY());
else if (m_iPanneauSuivant != MainWindow.PANNEAU_AUCUN)
m_zoneControles.height -= (iHauteurPanneau - jButtonSuivant.getY());
}
public void DefinirEtape(int iNumeroEtape, String sIntituleEtape, String sFichierAide) {
m_iNumeroEtape = iNumeroEtape; //the order of that step e.g. first step, second step
m_sIntituleEtape = sIntituleEtape; //title of step
m_sFichierAide = sFichierAide; //file aid
}
public void DefinirPanneauPrecedent(int iPanneau) {
m_iPanneauPrecedent = iPanneau;
}
//Define the next panel
public void DefinirPanneauSuivant(int iPanneau) {
m_iPanneauSuivant = iPanneau;
}
/** 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.
*/
private void initComponents() {//GEN-BEGIN:initComponents
jButtonPrecedent = new javax.swing.JButton(); //previous step
jButtonSuivant = new javax.swing.JButton(); //next step
setLayout(null);
//previous button
jButtonPrecedent.setText("Previous");
jButtonPrecedent.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonPrecedentActionPerformed(evt);
}
});
add(jButtonPrecedent);
jButtonPrecedent.setBounds(30, 84, 120, 26);
//next button
jButtonSuivant.setText("Next");
jButtonSuivant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSuivantActionPerformed(evt);
}
});
add(jButtonSuivant);
jButtonSuivant.setBounds(180, 84, 120, 26);
}//GEN-END:initComponents
private void jButtonSuivantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSuivantActionPerformed
// On effectue les traitements sp�cifiques n�cessaires :
// preprocess before going to next step
if (!TraitementsSpecifiquesAvantSuivant())
return;
// Go to subsequent panel :
if (m_contexteResolution != null) {
m_contexteResolution.m_fenetreProprietaire.ActiverPanneau(m_iPanneauSuivant);
}
}//GEN-LAST:event_jButtonSuivantActionPerformed
private void jButtonPrecedentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrecedentActionPerformed
if (!TraitementsSpecifiquesAvantPrecedent())
return;
// On retourne au panneau pr�c�dent :
if (m_contexteResolution != null) {
m_contexteResolution.m_fenetreProprietaire.ActiverPanneau(m_iPanneauPrecedent);
}
}//GEN-LAST:event_jButtonPrecedentActionPerformed
// Redispose certains champs en fonction de la taille du panneau :
void ArrangerDisposition() {
Dimension dimensionPanneauFils = null;
Dimension dimensionBouton = null;
Point positionBouton = null;
super.ArrangerDisposition();
dimensionPanneauFils = getSize();
positionBouton = new Point();
// Optimisation de la largeur de l'intitul� :
m_indicateurEtape.RedimensionnerSelonLargeur( getWidth() );
// Repositionnement des boutons :
if (m_iPanneauPrecedent != MainWindow.PANNEAU_AUCUN) {
dimensionBouton = jButtonPrecedent.getSize();
positionBouton.x = 5;
positionBouton.y = dimensionPanneauFils.height - dimensionBouton.height - 5;
jButtonPrecedent.setLocation(positionBouton);
}
if (m_iPanneauSuivant != MainWindow.PANNEAU_AUCUN) {
dimensionBouton = jButtonSuivant.getSize();
positionBouton.x = dimensionPanneauFils.width - dimensionBouton.width - 5;
positionBouton.y = dimensionPanneauFils.height - dimensionBouton.height - 5;
jButtonSuivant.setLocation(positionBouton);
}
RecalculerZoneControles();
}
// M�thode � outrepasser dans la classe fille pour effectuer certains traitements avant de passer au panneau suivant :
protected boolean TraitementsSpecifiquesAvantSuivant() {
return SychroniserDonneesInternesSelonAffichage();
}
// M�thode � outrepasser dans la classe fille pour effectuer certains traitements avant de retourner au panneau pr�c�dent :
protected boolean TraitementsSpecifiquesAvantPrecedent() {
return SychroniserDonneesInternesSelonAffichage();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonPrecedent;
private javax.swing.JButton jButtonSuivant;
// End of variables declaration//GEN-END:variables
public void SimulerAppuiSuivant() {
if (jButtonSuivant.isVisible())
jButtonSuivant.doClick();
}
public void SimulerAppuiPrecedent() {
if (jButtonPrecedent.isVisible())
jButtonPrecedent.doClick();
}
}