diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c646ff2..9d4a62f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -12,7 +12,9 @@
-
+
+
+
@@ -61,19 +63,29 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
@@ -176,7 +188,6 @@
-
@@ -188,11 +199,12 @@
-
-
+
+
+
@@ -238,7 +250,6 @@
-
@@ -262,7 +273,7 @@
-
+
@@ -290,6 +301,7 @@
+
@@ -303,7 +315,7 @@
-
+
@@ -510,7 +522,8 @@
-
+
+
1545280618093
@@ -778,11 +791,18 @@
1546980519704
-
+
+ 1546980639033
+
+
+
+ 1546980639033
+
+
-
+
@@ -795,8 +815,9 @@
+
-
+
@@ -805,7 +826,7 @@
-
+
@@ -886,7 +907,6 @@
-
@@ -911,7 +931,8 @@
-
+
+
@@ -1427,30 +1448,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1464,19 +1461,42 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index e91af24..43f1c8b 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/src/danielcortes/xyz/controllers/InformesController.java b/src/danielcortes/xyz/controllers/InformesController.java
index 5647a0c..fec9c92 100644
--- a/src/danielcortes/xyz/controllers/InformesController.java
+++ b/src/danielcortes/xyz/controllers/InformesController.java
@@ -30,7 +30,9 @@ import danielcortes.xyz.views.InformesView;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
+import java.awt.*;
import java.io.File;
+import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@@ -55,13 +57,15 @@ public class InformesController {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM YYYY");
String formatedName = month.format(formatter);
String capitalized = formatedName.substring(0, 1).toUpperCase() + formatedName.substring(1);
- File saveFile = askForFile("Informe "+ capitalized);
+ File saveFile = askForFile("Informe " + capitalized);
if (saveFile == null) {
return;
}
InformeMensual informeMensual = new InformeMensual(month, saveFile);
- informeMensual.generarInforme();
+ File generatedFile = informeMensual.generarInforme();
+
+ this.showConfirmation(generatedFile);
}
private LocalDate askForMonth() {
@@ -76,7 +80,7 @@ public class InformesController {
private File askForFile(String suggestedName) {
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(JFileChooser.SAVE_DIALOG);
- chooser.setSelectedFile(new File(suggestedName+".xls"));
+ chooser.setSelectedFile(new File(suggestedName + ".xls"));
chooser.setFileFilter(new FileNameExtensionFilter("Excel 2007", "xls"));
if (chooser.showSaveDialog(this.view.getContentPanel()) == JFileChooser.APPROVE_OPTION) {
@@ -90,4 +94,22 @@ public class InformesController {
}
}
+ private void showConfirmation(File file) {
+ int result = JOptionPane.showConfirmDialog(
+ this.view.getContentPanel(),
+ "El informe se a generado\n" +
+ "¿Desea abrirlo?",
+ "Confirmacion",
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE
+ );
+ if (result == 0) {
+ try {
+ Desktop.getDesktop().open(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
}
diff --git a/src/danielcortes/xyz/informes/InformeMensual.java b/src/danielcortes/xyz/informes/InformeMensual.java
index 7e0c2f0..8cd4325 100644
--- a/src/danielcortes/xyz/informes/InformeMensual.java
+++ b/src/danielcortes/xyz/informes/InformeMensual.java
@@ -133,16 +133,18 @@ public class InformeMensual {
}
}
- public void generarInforme(){
+ public File generarInforme(){
fillData();
fillHeaders();
setStyles();
try (OutputStream fileOut = new FileOutputStream(this.saveFile)) {
wb.write(fileOut);
+ return this.saveFile;
} catch (IOException e) {
e.printStackTrace();
}
+ return null;
}