diff --git a/src/ser/ui/GUI/AdminGUI.java b/src/ser/ui/GUI/AdminGUI.java index 71c332c..a2bd228 100644 --- a/src/ser/ui/GUI/AdminGUI.java +++ b/src/ser/ui/GUI/AdminGUI.java @@ -20,11 +20,19 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; -import java.awt.*; +import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.util.Date; import ser.admin.IntAdmin; import ser.ui.IntUI; import java.util.List; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.scene.control.DatePicker; /** * @@ -32,20 +40,32 @@ */ public class AdminGUI extends JFrame implements IntUI,ActionListener{ - JFrame f1; + //JFrame f1; JButton[] jb1=new JButton[6]; JButton[] jb2; JLabel[] jl; + JTextField jtf; LocalDate date; final IntAdmin ia; public AdminGUI(IntAdmin ia){ + new JFrame("Software-Monitor"); + setLayout(new GridLayout(3, 2)); this.ia=ia; - List abc = ia.getAllUname(LocalDate.MIN); + jtf=new JTextField(); + String sdate=jtf.getText(); + try { + date = LocalDate.of(new Integer(sdate.substring(0, 4)).intValue(), new Integer(sdate.substring(5, 7)).intValue(), new Integer(sdate.substring(8)).intValue()); + } catch (Exception ex) { + Logger.getLogger(AdminGUI.class.getName()).log(Level.SEVERE, null, ex); + } + List abc = ia.getAllUname(date); jl = new JLabel[abc.size()]; jb2 = new JButton[abc.size()]; int i = 0; - JPanel p1=new JPanel(new FlowLayout()); - JPanel p2=new JPanel(new GridLayout(300, 2)); + JPanel p1=new JPanel(new GridLayout(2, 4)); + JPanel p2=new JPanel(new GridLayout(abc.size(), 2)); + final DatePicker dp = new DatePicker(); + for(String username:abc) { jl[i] = new JLabel(username); @@ -58,6 +78,7 @@ public void actionPerformed(ActionEvent e) { ListPage lp=new ListPage(ia,username,date); } }); + i++; } jb1[1]=new JButton("Update"); @@ -103,10 +124,8 @@ public void actionPerformed(ActionEvent e) { ia.stopSer(); } }); - f1 = new JFrame("Software-Monitor"); - f1.setLayout(new GridLayout(3, 2)); - f1.add(p1); - f1.add(p2); + add(p1); + add(p2); p1.add(jb1[1]); p1.add(jb1[5]); p1.add(jb1[6]); @@ -117,10 +136,11 @@ public void actionPerformed(ActionEvent e) { jb1[2].setEnabled(true); jb1[3].setEnabled(false); jb1[4].setEnabled(false); - - f1.setVisible(false); - f1.setSize(500, 400); - f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setExtendedState(JFrame.MAXIMIZED_BOTH); + setUndecorated(true); + setVisible(false); + setSize(500, 400); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @@ -155,7 +175,7 @@ public String showPrompt(String msg) { @Override public void start() { - f1.setVisible(true); + setVisible(true); } @Override @@ -163,8 +183,12 @@ public void actionPerformed(ActionEvent e) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - public static void main(String[] args) { - AdminGUI ag=new AdminGUI(null); + @Override + public void close() throws IOException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + public static void main(String[] args) { + AdminGUI ag=new AdminGUI(); + } } \ No newline at end of file diff --git a/src/ser/ui/GUI/ListPage.java b/src/ser/ui/GUI/ListPage.java index 4ec0d65..27cedce 100644 --- a/src/ser/ui/GUI/ListPage.java +++ b/src/ser/ui/GUI/ListPage.java @@ -17,6 +17,7 @@ package ser.ui.GUI; import com.dataBean.IntDataBean; +import com.dataBean.IntDataTuple; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; @@ -31,31 +32,49 @@ * @author Parth Doshi */ -class ListPage extends JFrame implements ActionListener{ +class ListPage extends JFrame { final IntAdmin ia; JLabel[] jl; + JLabel[] sname; + JLabel[] ver; + JLabel[] idate; + JPanel p1,p2; + public ListPage(IntAdmin ia,String uname,LocalDate dt){ - p1=new JPanel(new FlowLayout()); - List abc = ia.getUserDetail(uname, dt); - p2=new JPanel(new GridLayout(abc.size(), 3)); this.ia=ia; + p1=new JPanel(new GridLayout(3, 2)); + List abc = ia.getUserDetail(uname, dt); jl[1]=new JLabel("Username : "+uname); - //jl[2]=new JLabel("IP Address : "+ia.getIp); - //jl[3]=new JLabel("Mac Address : "+ia.getMac); + jl[2]=new JLabel("IP Address : "+abc.get(0).getIP()); + jl[3]=new JLabel("Mac Address : "+abc.get(0).getMac()); p1.add(jl[1]); p1.add(jl[2]); p1.add(jl[3]); + //Panel 1 ends jl[4]=new JLabel("Software Name"); jl[5]=new JLabel("Version"); jl[6]=new JLabel("Installed Date"); + p2=new JPanel(new GridLayout(abc.size(), 3)); p2.add(jl[4]); p2.add(jl[5]); p2.add(jl[6]); - } - - @Override - public void actionPerformed(ActionEvent e) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + int i = 1; + for(IntDataBean p:abc){ + for(IntDataTuple idt:p.getSoftDetail()){ + sname[i]=new JLabel(idt.getSoftName()); + ver[i]=new JLabel(idt.getVersion()); + idate[i]=new JLabel(idt.getDate().toString()); + p2.add(sname[i]); + p2.add(ver[i]); + p2.add(idate[i]); + i++; + } + } + //Panel 2 ends + setExtendedState(JFrame.MAXIMIZED_BOTH); + setUndecorated(true); + setVisible(true); + setDefaultCloseOperation(EXIT_ON_CLOSE); } }