public Client() throws ConnectException, IOException, ClassNotFoundException { setTitle("Calendar"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sigve = User.getUser(1); // new User("sigveseb", "Sigve Sebastian", "Farstad", "*****@*****.**"); new Thread( new Runnable() { @Override public void run() { while (true) { Client.setCurrentTime(new GregorianCalendar()); try { Thread.sleep(1000); } catch (InterruptedException e) { } } } }) .start(); new Thread( new Runnable() { @Override public void run() { while (true) { Client.setNotifications(Message.getMessages(Client.user)); try { Thread.sleep(15000); } catch (InterruptedException e) { } } } }) .start(); inv1 = new Invitation(sigve, app1); inv2 = new Invitation(sigve, app2); app1 = new Appointment( "Testappointment", "Utendørs", "Dette er en test for å teste testen", new GregorianCalendar(2012, 3, 23, 10, 30), new GregorianCalendar(2012, 3, 23, 11, 30)); app2 = new Appointment( "Testappointment nummer 2", f1, "Dette er en test for å teste testen", new GregorianCalendar(2012, 3, 26, 12, 0), new GregorianCalendar(2012, 3, 26, 14, 45)); f1 = new Room("F1", 12, 300, false); }
/** * Logs in user, eventually * * @param username * @param password */ public static Boolean login(String username, String password) { Boolean status; if (username.equals("sigve") && password.equals("1337")) { setUser(User.getUser(1)); // get user 1 for now GregorianCalendar now = new GregorianCalendar(2012, 3, 23); // arbitrary date for now System.out.println("User logged in"); pushView(new CalendarView()); Client.setNotifications(Message.getMessages(Client.user)); Client.setActiveWeek( now.get(GregorianCalendar.YEAR), now.get(GregorianCalendar.MONTH), now.get(GregorianCalendar.DATE)); status = true; } else { System.out.println("Wrong username and/or password"); status = false; } return status; }