Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
ajout exemple de génération de rapport
Browse files Browse the repository at this point in the history
  • Loading branch information
lduboeuf committed Jan 24, 2017
1 parent 7ce5445 commit d074ce1
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 39 deletions.
Binary file added lib/ant-commons-logging.jar
Binary file not shown.
Binary file added lib/commons-beanutils-1.9.0.jar
Binary file not shown.
Binary file added lib/commons-collections-3.2.1.jar
Binary file not shown.
Binary file added lib/commons-digester-2.1.jar
Binary file not shown.
Binary file added lib/itext-2.1.7.js5-SNAPSHOT.jar
Binary file not shown.
Binary file added lib/jasperreports-6.3.1.jar
Binary file not shown.
Binary file added lib/org-apache-commons-logging.jar
Binary file not shown.
19 changes: 14 additions & 5 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ is divided into following sections:
<condition property="have.sources">
<or>
<available file="${src.dir}"/>
<available file="${src.resources.dir}"/>
</or>
</condition>
<condition property="netbeans.home+have.tests">
Expand Down Expand Up @@ -231,6 +232,7 @@ is divided into following sections:
</target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="src.resources.dir">Must set src.resources.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
<fail unless="dist.dir">Must set dist.dir</fail>
Expand All @@ -252,7 +254,7 @@ is divided into following sections:
</target>
<target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${src.dir}" name="srcdir"/>
<attribute default="${src.dir}:${src.resources.dir}" name="srcdir"/>
<attribute default="${build.classes.dir}" name="destdir"/>
<attribute default="${javac.classpath}" name="classpath"/>
<attribute default="${javac.processorpath}" name="processorpath"/>
Expand Down Expand Up @@ -293,7 +295,7 @@ is divided into following sections:
</target>
<target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${src.dir}" name="srcdir"/>
<attribute default="${src.dir}:${src.resources.dir}" name="srcdir"/>
<attribute default="${build.classes.dir}" name="destdir"/>
<attribute default="${javac.classpath}" name="classpath"/>
<attribute default="${javac.processorpath}" name="processorpath"/>
Expand Down Expand Up @@ -326,7 +328,7 @@ is divided into following sections:
</target>
<target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
<macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${src.dir}" name="srcdir"/>
<attribute default="${src.dir}:${src.resources.dir}" name="srcdir"/>
<attribute default="${build.classes.dir}" name="destdir"/>
<attribute default="${javac.classpath}" name="classpath"/>
<sequential>
Expand Down Expand Up @@ -924,12 +926,13 @@ is divided into following sections:
<include name="*"/>
</dirset>
</pathconvert>
<j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
<j2seproject3:depend srcdir="${src.dir}:${src.resources.dir}:${build.generated.subdirs}"/>
</target>
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
<j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
<fileset dir="${src.resources.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target if="has.persistence.xml" name="-copy-persistence-xml">
Expand All @@ -950,7 +953,7 @@ is divided into following sections:
<target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<j2seproject3:force-recompile/>
<j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
<j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}:${src.resources.dir}"/>
</target>
<target name="-post-compile-single">
<!-- Empty placeholder for easier customization. -->
Expand Down Expand Up @@ -1219,6 +1222,9 @@ is divided into following sections:
<fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.resources.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
Expand All @@ -1229,6 +1235,9 @@ is divided into following sections:
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<filename name="**/doc-files/**"/>
</fileset>
<fileset dir="${src.resources.dir}" excludes="${excludes}" includes="${includes}">
<filename name="**/doc-files/**"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/doc-files/**"/>
</fileset>
Expand Down
6 changes: 3 additions & 3 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=3464dead
build.xml.data.CRC32=7a7eb84f
build.xml.script.CRC32=213b7d0d
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=3464dead
nbproject/build-impl.xml.script.CRC32=2e6f2e07
nbproject/build-impl.xml.data.CRC32=7a7eb84f
nbproject/build-impl.xml.script.CRC32=91a53dea
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
15 changes: 14 additions & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ dist.jar=${dist.dir}/GestForm.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.commons-beanutils-1.9.0.jar=lib/commons-beanutils-1.9.0.jar
file.reference.commons-collections-3.2.1.jar=lib/commons-collections-3.2.1.jar
file.reference.commons-digester-2.1.jar=lib/commons-digester-2.1.jar
file.reference.itext-2.1.7.js5-SNAPSHOT.jar=lib/itext-2.1.7.js5-SNAPSHOT.jar
file.reference.jasperreports-6.3.1.jar=lib/jasperreports-6.3.1.jar
file.reference.org-apache-commons-logging.jar=lib/org-apache-commons-logging.jar
includes=**
jar.compress=false
javac.classpath=\
${libs.MySQLDriver.classpath}
${libs.MySQLDriver.classpath}:\
${file.reference.jasperreports-6.3.1.jar}:\
${file.reference.commons-beanutils-1.9.0.jar}:\
${file.reference.commons-collections-3.2.1.jar}:\
${file.reference.commons-digester-2.1.jar}:\
${file.reference.itext-2.1.7.js5-SNAPSHOT.jar}:\
${file.reference.org-apache-commons-logging.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
Expand Down Expand Up @@ -76,4 +88,5 @@ run.test.classpath=\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
src.resources.dir=resources
test.src.dir=test
1 change: 1 addition & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<name>GestForm</name>
<source-roots>
<root id="src.dir"/>
<root id="src.resources.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
Expand Down
Binary file added resources/coffee.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/coffee_stain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 16 additions & 29 deletions resources/gestform.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 17, 2017 at 03:57 PM
-- Server version: 5.7.16-0ubuntu0.16.04.1
-- Generation Time: Jan 24, 2017 at 02:19 PM
-- Server version: 5.7.17-0ubuntu0.16.04.1
-- PHP Version: 7.0.8-0ubuntu0.16.04.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
Expand Down Expand Up @@ -37,7 +37,10 @@ CREATE TABLE `ecf` (
--

INSERT INTO `ecf` (`id`, `nom`, `formation_code`) VALUES
(1, 'Developpement Web', 'DL16');
(1, 'Developpement Web', 'DL16'),
(3, 'Interface utilisateur', 'DL16'),
(4, 'Conception BDD', 'DL16')


-- --------------------------------------------------------

Expand All @@ -57,6 +60,7 @@ CREATE TABLE `formation` (
--

INSERT INTO `formation` (`code`, `nom`, `date_debut`, `date_fin`) VALUES
('CR16', 'Crépier', '2016-10-03', '2017-05-23'),
('DL16', 'Développeur Logiciel', '2016-10-03', '2017-05-23');

-- --------------------------------------------------------
Expand All @@ -71,20 +75,7 @@ CREATE TABLE `personne` (
`prenom` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `personne`
--

INSERT INTO `personne` (`id`, `nom`, `prenom`) VALUES
(3, 'duclou', 'alfred'),
(4, 'duclou', 'alfred'),
(5, 'duclou', 'alfred'),
(6, 'duclou', 'alfred'),
(7, 'duclou', 'alfred'),
(8, 'duclou', 'alfred'),
(9, 'duclou', 'alfred'),
(13, 'duclou', 'alfred'),
(16, 'duclou', 'alfred');

-- --------------------------------------------------------

Expand All @@ -98,12 +89,7 @@ CREATE TABLE `result_ecf` (
`ecf_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `result_ecf`
--

INSERT INTO `result_ecf` (`acquis`, `stagiaire_code`, `ecf_id`) VALUES
(0, '001C0997', 1);

-- --------------------------------------------------------

Expand All @@ -117,14 +103,15 @@ CREATE TABLE `stagiaire` (
`formation_code` char(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



--
-- Dumping data for table `stagiaire`
-- Triggers `stagiaire`
--

INSERT INTO `stagiaire` (`personne_id`, `code`, `formation_code`) VALUES
(16, '001C0997', 'DL16'),
(13, '001C0998', 'DL16'),
(9, '001C0999', 'DL16');
DELIMITER $$
CREATE TRIGGER `stag_init_ecf` AFTER INSERT ON `stagiaire` FOR EACH ROW INSERT INTO result_ecf (stagiaire_code, ecf_id, acquis) SELECT new.code, id, false FROM ecf WHERE formation_code = new.formation_code
$$
DELIMITER ;

--
-- Indexes for dumped tables
Expand Down Expand Up @@ -168,12 +155,12 @@ ALTER TABLE `stagiaire`
-- AUTO_INCREMENT for table `ecf`
--
ALTER TABLE `ecf`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `personne`
--
ALTER TABLE `personne`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Binary file added resources/reports/ecf_result.jasper
Binary file not shown.
16 changes: 16 additions & 0 deletions src/org/lduboeuf/gestform/ui/Main.form
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="menuEtat">
<Properties>
<Property name="text" type="java.lang.String" value="Rapports"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuRapportResultECF">
<Properties>
<Property name="text" type="java.lang.String" value="R&#xe9;sultat ECF"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuRapportResultECFActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu3">
<Properties>
<Property name="text" type="java.lang.String" value="?"/>
Expand Down
60 changes: 59 additions & 1 deletion src/org/lduboeuf/gestform/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.swing.JRViewer;
import org.lduboeuf.gestform.model.ECF;
import org.lduboeuf.gestform.model.Formation;
import org.lduboeuf.gestform.model.Stagiaire;
import org.lduboeuf.gestform.model.dao.ConnectDB;
import org.lduboeuf.gestform.model.dao.ECFDAO;
import org.lduboeuf.gestform.model.dao.FormationDAO;
import org.lduboeuf.gestform.model.dao.StagiaireDAO;
Expand Down Expand Up @@ -92,7 +103,7 @@ private void displayFormationDetails(Formation formation){
tblECFModel.addRow(new ECF(-1, "", formation)); //ajout d'un faux ECF pour permettre l'ajout depuis la liste

btnAjoutStagiaire.setEnabled(true);
panelFormationDetails.setVisible(true);
panelFormationDetails.setEnabled(true);
}

private void clearFormationDetails(){
Expand Down Expand Up @@ -151,6 +162,8 @@ private void initComponents() {
menu = new javax.swing.JMenuBar();
menuFile = new javax.swing.JMenu();
menuFileFermer = new javax.swing.JMenuItem();
menuEtat = new javax.swing.JMenu();
menuRapportResultECF = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
MenuItemAbout = new javax.swing.JMenuItem();

Expand Down Expand Up @@ -299,6 +312,19 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

menu.add(menuFile);

menuEtat.setText("Rapports");
menuEtat.setToolTipText("");

menuRapportResultECF.setText("Résultat ECF");
menuRapportResultECF.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuRapportResultECFActionPerformed(evt);
}
});
menuEtat.add(menuRapportResultECF);

menu.add(menuEtat);

jMenu3.setText("?");

MenuItemAbout.setText("A propos");
Expand Down Expand Up @@ -374,6 +400,36 @@ private void btnAfficheECFActionPerformed(java.awt.event.ActionEvent evt) {//GEN
ecfResult.setVisible(true);
}//GEN-LAST:event_btnAfficheECFActionPerformed

private void menuRapportResultECFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRapportResultECFActionPerformed
if (tblFormations.getSelectedRow()==-1){
JOptionPane.showMessageDialog(null, "vous devez selectionner une formation afin d'afficher le rapport ", "selection stagiaire", JOptionPane.INFORMATION_MESSAGE);
return;
}

Formation form = tblFormationModel.getFormation(tblFormations.getSelectedRow());

try {
JasperReport report = (JasperReport) JRLoader.loadObject(getClass().getResource("/reports/ecf_result.jasper"));
//pour éviter l'import de fonts
report.setProperty("net.sf.jasperreports.awt.ignore.missing.font", "false");
report.setProperty("net.sf.jasperreports.default.font.name=SansSerif", "true");
HashMap<String, Object> params = new HashMap<>();
params.put("formation_code", form.getCode());

JasperPrint jPrint = JasperFillManager.fillReport(report, params, ConnectDB.getConnection());

JFrame pdfFrame = new JFrame("Rapport");
pdfFrame.getContentPane().add(new JRViewer(jPrint));
pdfFrame.pack();
pdfFrame.setSize(this.getSize());
pdfFrame.setVisible(true);


} catch (JRException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_menuRapportResultECFActionPerformed

/**
* @param args the command line arguments
*/
Expand Down Expand Up @@ -427,8 +483,10 @@ public void run() {
private javax.swing.JLabel lblDateFin;
private javax.swing.JLabel lblNom;
private javax.swing.JMenuBar menu;
private javax.swing.JMenu menuEtat;
private javax.swing.JMenu menuFile;
private javax.swing.JMenuItem menuFileFermer;
private javax.swing.JMenuItem menuRapportResultECF;
private javax.swing.JPanel panelFooter;
private javax.swing.JPanel panelFormDetailsActions;
private javax.swing.JPanel panelFormDetailsFields;
Expand Down
Loading

0 comments on commit d074ce1

Please sign in to comment.