/* Planning (Thierry Brouard V1.2 Jul 10 2001) email : thierry.brouard@free.fr To use it: . Replace the extention with ".java" . Compile this code with your Java compiler (>javac Planning.java). . Create a new form "Planning". . In this form insert 2 fields "Jour" and "Echelle". The field "Jour" is a DateTime Field and Scale is a ListBox Field with 3 items (24 hours|1,15 hours|2, 11 hours|3.) . Create an Applet object in this form and include these files *.class made by your Java compiler inside your Applet Objet. . Select your Applet object and define 2 parameters "Jour" and "Echelle" to transmit like arguments to Applet object. . Save your form. . Launch it. Don't forget to do reservations before to see them to the display. To save some reservations, I create a form named "fiches" with 4 fields : "Jour"(day), "Heure_d"(starttime), "Heure_f"(endtime), "salle"(room) You can also update this program to manage human resources in a project. have a nice java day. */ import lotus.domino.*; import java.awt.*; import java.text.SimpleDateFormat; import java.applet.Applet; import java.util.Vector; public class Planning extends AppletBase { Session s = null; Database db = null; View vw = null; DocumentCollection dc = null; int debug = 0; Vector resa = new Vector(); String jour; String echelle; String[] salle; int nbr_salles; int appWidth = 0; int appHeight = 0; int horaire_d = 0; int horaire_f = 0; public void notesAppletInit() { jour = getParameter("jour"); echelle = getParameter("echelle"); switch (Integer.parseInt(echelle)) { case 1: horaire_d = 0; horaire_f = 24; break; case 2: horaire_d = 6; horaire_f = 22; break; case 3: horaire_d = 8; horaire_f = 20; break; } setLayout(null); appWidth = getSize().width; appHeight = getSize().height; if (debug!=0) System.out.println( "jour = " + jour + "\nechelle = " + echelle + "\ntaille = " + appHeight + "H x " + appWidth + "L" ); } public void notesAppletStart() { int i; try { getDatabaseConnection(); } catch(Exception e) { System.err.println("Erreur AppletStart. "+e); } try { ViewEntryCollection vec; try { vec = vw.getAllEntries(); nbr_salles = vec.getCount(); if (debug!=0) System.out.println( "Nombre de salles trouvées : " + nbr_salles ); salle = new String[nbr_salles]; } catch(NotesException ne) { System.err.println("Echec lors de la recuperation des entrees. "+ne); throw ne; } if (debug!=0) System.out.println( "Récupération des dates." ); Document doc; for( i=0; i " ); try { String formula = "form=\"fiches\" & jour=["+jour+"] & salle=\""+salle[i]+"\""; dc = db.search(formula); int matches = dc.getCount(); if (debug!=0) System.out.println( formula + " ok " + matches + " résultats." ); Document searchdoc = dc.getFirstDocument(); while (searchdoc != null) { Vector ddeb = searchdoc.getItemValue("heure_d"); Vector dfin = searchdoc.getItemValue("heure_f"); DateTime dt1 = (DateTime)ddeb.elementAt(0); DateTime dt2 = (DateTime)dfin.elementAt(0); resa.addElement(new Reservations(i,dt1,dt2)); searchdoc = dc.getNextDocument(); } } catch(NotesException ne) { System.err.println("err "+ne); throw ne; } } } catch(Exception e) { System.err.println("Echec lors du dessin composant. "+e); } } private Database getDatabaseConnection() throws Exception { if(s==null) { s = this.getSession(); if (s == null) { throw new Exception("Impossible d'obtenir la session notes."); } else { if (debug!=0) System.out.println("Récupération de la session réussie"); } } if(db==null) { try { NotesAppletContext ap = getContext(s); db = ap.getDatabase(); if (db == null) { throw new Exception("Impossible d'obtenir le db."); } if (debug!=0) System.out.println("Connection réussie"); } catch(Exception e) { System.err.println("Echec de connection. "+e); e.printStackTrace(System.err); } } if(vw==null) { try { vw = db.getView("Ressources"); if (vw == null) { throw new Exception("Impossible de récupérer la vue."); } else { if (debug!=0) System.out.println("Récupération de la vue réussie"); } } catch(NotesException ne) { System.err.println("Echec lors de l'initialisation de la vue. "+ne); throw ne; } } return db; } public void notesAppletStop() { if(db!=null) { try { db.recycle(); s.recycle(); } catch(Exception e) { System.err.println("Echec lors de la fermeture de la connection. "+e); e.printStackTrace(); } finally { s = null; db = null; } } } public String getAppletInfo() { return "Planning Thierry B. (10/7/2001)"; } public void update(Graphics g) { paint(g); } public void paint( Graphics g ) { super.paint(g); if (debug!=0) System.out.println("paint"); double x_offset; int y_offset; int nbr_heures; int marge_gauche = 80; int marge_haut = 40; double x_pos; double l_pos; int y_pos; int i; String t; try { nbr_heures = horaire_f-horaire_d; x_offset = (appWidth-marge_gauche)/nbr_heures; y_offset = 40; if (debug!=0) System.out.println("x_offset="+x_offset); // on dessine le décor. g.setColor(Color.black); g.drawLine(0,20,appWidth,20); g.drawLine(marge_gauche,0,marge_gauche,(nbr_salles*y_offset)+20); for( i=0; i