From f06cdde9ded9a4521c962b1def4e01e228bfbdda Mon Sep 17 00:00:00 2001
From: piquerez <corentin.piquerez1@etu.univ-lorraine.fr>
Date: Sun, 21 May 2023 17:23:27 +0200
Subject: [PATCH] =?UTF-8?q?d=C3=A9but=20fenetre=20double=20click?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 data/2223_S2/version.txt                      |  2 +-
 .../data/2223_S2/version.txt                  |  2 +-
 shukan/ShukanController.java                  |  5 +++-
 shukan/ShukanData.java                        |  4 +++
 shukan/ShukanView.java                        | 26 ++++++++++++++-----
 5 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/data/2223_S2/version.txt b/data/2223_S2/version.txt
index 3a5c980..5616f06 100644
--- a/data/2223_S2/version.txt
+++ b/data/2223_S2/version.txt
@@ -1,2 +1,2 @@
-11
+14
 230520
diff --git a/out/production/sae2.01-developpement-application/data/2223_S2/version.txt b/out/production/sae2.01-developpement-application/data/2223_S2/version.txt
index 3a5c980..5616f06 100644
--- a/out/production/sae2.01-developpement-application/data/2223_S2/version.txt
+++ b/out/production/sae2.01-developpement-application/data/2223_S2/version.txt
@@ -1,2 +1,2 @@
-11
+14
 230520
diff --git a/shukan/ShukanController.java b/shukan/ShukanController.java
index 4c02726..3ede257 100644
--- a/shukan/ShukanController.java
+++ b/shukan/ShukanController.java
@@ -156,10 +156,13 @@ public class ShukanController
         canvas.repaint ();
       }
     }
+
     // Manage the double click to open a new window
     if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
-        System.out.println("double clicked");
+      canvas.SpecWeekModuleWindow();
+
     }
+
     if (e.getButton () == MouseEvent.BUTTON3)
     {
       if (e.isShiftDown ())
diff --git a/shukan/ShukanData.java b/shukan/ShukanData.java
index 70a0230..2091f70 100644
--- a/shukan/ShukanData.java
+++ b/shukan/ShukanData.java
@@ -143,6 +143,10 @@ public class ShukanData
   {
     return (curs[selCur]);
   }
+  /** Returns the number of a cursus */
+  public int cursusNumber(){
+    return selCur;
+  }
 
   /** Returns the name of a cursus */
   public String cursusName (int num)
diff --git a/shukan/ShukanView.java b/shukan/ShukanView.java
index d23431b..80f03b1 100644
--- a/shukan/ShukanView.java
+++ b/shukan/ShukanView.java
@@ -1,10 +1,6 @@
 package shukan;
-import javax.swing.JPanel;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
+import javax.swing.*;
+import java.awt.*;
 
 
 /** Graphical view for Shukan planner.
@@ -376,4 +372,22 @@ public class ShukanView extends JPanel
       posy -= fontHeight;
     }
   }
+  /** creates a new Window with the specification of a selected week and module */
+  public void SpecWeekModuleWindow(){
+    int num_module = data.selectedModule();
+    int num_cursus = data.cursusNumber();
+    int num_semaine = data.selectedWeek()+data.startWeekNumber();
+    int debut = data.moduleStart(num_cursus, num_module);
+    int fin = data.moduleEnd(num_cursus, num_module);
+
+    // affiche la fenetre si il y a cours pendant cette periode
+    if(num_semaine>=debut && (num_semaine<=fin || fin == 0))
+    {
+      JFrame spec = new JFrame(data.cursusName(num_cursus) + " - Semaine" + (num_semaine) + " - " + data.moduleNames(num_cursus)[num_module]);
+      int[] a = data.scheduleInWeek(num_module, num_semaine);
+      for (int i = 0; i<a.length; i++)System.out.println(a[i]);
+      spec.setSize(new Dimension(300, 150));
+      spec.setVisible(true);
+    }
+  }
 }
-- 
GitLab