Completata l'interfaccia utente e buon avanzamento per l'admin. Mancano da definire le politiche nei menu settando i giusti metodi global e modificando i valori fissi nei prezziscontati delle singole classi. Mancano le implementazioni dell'aggiungi prodotto,rimozione.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package it.unisa.info13d.Articoli;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class PrestazioniDopera extends Utilizzabile {
|
||||
|
||||
|
||||
@@ -90,4 +92,9 @@ public class PrestazioniDopera extends Utilizzabile {
|
||||
private String Localita;
|
||||
private String Descrizione;
|
||||
private String Fornitore;
|
||||
private GregorianCalendar scadenza = new GregorianCalendar(99999,0,1);
|
||||
|
||||
public GregorianCalendar getScadenza() {
|
||||
return scadenza;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class AdminSession {
|
||||
//catalogo.offerteAttive(username);
|
||||
break;
|
||||
case "4":
|
||||
catalogo.offerteScadute(username);
|
||||
//catalogo.offerteScadute(username);
|
||||
break;
|
||||
case "5":
|
||||
r.reshow = false;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ public class ClientSession {
|
||||
//catalogo.acquistaProdotto(username);
|
||||
break;
|
||||
case "4":
|
||||
catalogo.visualizzaStorico(username);
|
||||
//catalogo.visualizzaStorico(username);
|
||||
break;
|
||||
case "5":
|
||||
// r.reshow = false;
|
||||
|
||||
@@ -1,12 +1,350 @@
|
||||
package it.unisa.info13d.Gui;
|
||||
|
||||
import it.unisa.info13d.Articoli.Utilizzabile;
|
||||
import it.unisa.info13d.GestioneCatalogo.Catalogo;
|
||||
import it.unisa.info13d.Login.Access;
|
||||
import it.unisa.info13d.Login.LoginData;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* Created with MONSTER.
|
||||
* User: xgiovio
|
||||
* Date: 19/01/14
|
||||
* Time: 19.05
|
||||
* Time: 19.19
|
||||
*/
|
||||
public class AdminInterface extends JFrame {
|
||||
public class AdminInterface extends JFrame{
|
||||
|
||||
|
||||
public AdminInterface(LoginWindow in_login_window, Catalogo in_load_catalogo, LoginData in_login_data) throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||
|
||||
login_window = in_login_window;
|
||||
load_catalogo= in_load_catalogo;
|
||||
login_data = in_login_data;
|
||||
|
||||
//////////////////////////////////////////////////// begin main menu and balance
|
||||
|
||||
JPanel mainWindow = new JPanel();
|
||||
mainWindow.setLayout(new BorderLayout());
|
||||
add(mainWindow);
|
||||
|
||||
|
||||
JPanel north = new JPanel();
|
||||
north.setLayout(new BorderLayout() );
|
||||
|
||||
|
||||
JMenuBar mainmenu = new JMenuBar();
|
||||
north.add(mainmenu,BorderLayout.NORTH);
|
||||
|
||||
JMenu filemenu = new JMenu("File");
|
||||
JMenuItem logout_menu_item = new JMenuItem("Logout");
|
||||
class logout_action implements ActionListener {
|
||||
|
||||
|
||||
public logout_action (AdminInterface in_location){
|
||||
location= in_location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
|
||||
location.setVisible(false);
|
||||
login_window.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private AdminInterface location;
|
||||
}
|
||||
logout_menu_item.addActionListener(new logout_action(this));
|
||||
JMenuItem quit_menu_item = new JMenuItem("Quit");
|
||||
class exit_action implements ActionListener {
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
quit_menu_item.addActionListener(new exit_action());
|
||||
|
||||
JMenu searchmenu = new JMenu("Cerca");
|
||||
JMenuItem tutti_gli_articoli_attivi_id = new JMenuItem("Tutti gli articoli Attivi per ID");
|
||||
class tutti_gli_articoli_attivi_id_action implements ActionListener {
|
||||
|
||||
|
||||
public tutti_gli_articoli_attivi_id_action (AdminInterface in_location, JTextArea in_offers,String in_choice){
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
choice = in_choice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
load_catalogo.offerteAttive(login_data.getUsername(),offers,choice);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private AdminInterface location;
|
||||
private JTextArea offers;
|
||||
private String choice;
|
||||
}
|
||||
//action listner added at offers declaration
|
||||
|
||||
JMenuItem tutti_gli_articoli_attivi_costo = new JMenuItem("Tutti gli articoli Attivi per Costo");
|
||||
class tutti_gli_articoli_attivi_costo_action implements ActionListener {
|
||||
|
||||
|
||||
public tutti_gli_articoli_attivi_costo_action (AdminInterface in_location, JTextArea in_offers,String in_choice){
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
choice = in_choice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
load_catalogo.offerteAttive(login_data.getUsername(),offers,choice);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private AdminInterface location;
|
||||
private JTextArea offers;
|
||||
private String choice;
|
||||
}
|
||||
//action listner added at offers declaration
|
||||
|
||||
JMenuItem tutti_gli_articoli_scaduti = new JMenuItem("Tutti gli articoli Scaduti");
|
||||
class tutti_gli_articoli_scaduti_action implements ActionListener {
|
||||
|
||||
|
||||
public tutti_gli_articoli_scaduti_action (AdminInterface in_location, JTextArea in_offers){
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
load_catalogo.offerteScadute(login_data.getUsername(), offers);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private AdminInterface location;
|
||||
private JTextArea offers;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
JMenu politicamenu = new JMenu("Politiche Sconto");
|
||||
JMenuItem sconto_totale_articoli = new JMenuItem("Sconto sul Totale Articoli");
|
||||
JMenuItem sconto_articoli_ultima_settimana = new JMenuItem("Sconto su Articoli Ultima Settimana");
|
||||
JMenuItem sconto_cene_50_ultima_settimana = new JMenuItem("Sconto per >50% Cene Vendute Ultima Settimana");
|
||||
|
||||
|
||||
mainmenu.add(filemenu);
|
||||
mainmenu.add(searchmenu);
|
||||
mainmenu.add(politicamenu);
|
||||
|
||||
filemenu.add(logout_menu_item);
|
||||
filemenu.add(quit_menu_item);
|
||||
|
||||
searchmenu.add(tutti_gli_articoli_attivi_id);
|
||||
searchmenu.add(tutti_gli_articoli_attivi_costo);
|
||||
searchmenu.add(tutti_gli_articoli_scaduti);
|
||||
|
||||
|
||||
|
||||
politicamenu.add(sconto_totale_articoli);
|
||||
politicamenu.add(sconto_articoli_ultima_settimana);
|
||||
politicamenu.add(sconto_cene_50_ultima_settimana);
|
||||
|
||||
|
||||
|
||||
|
||||
JPanel AggiungiProdottiPanel = new JPanel();
|
||||
JLabel add_product_label = new JLabel("Aggiungi un nuovo Prodotto" );
|
||||
add_product_label.setPreferredSize(new Dimension(180,60));
|
||||
JButton aggiungi_bene = new JButton("Bene");
|
||||
JButton aggiungi_cena = new JButton("Cena");
|
||||
JButton aggiungi_vacanza = new JButton("Viaggio");
|
||||
JButton aggiungi_prestazione = new JButton("Prestazione");
|
||||
|
||||
|
||||
AggiungiProdottiPanel.add(add_product_label);
|
||||
AggiungiProdottiPanel.add(aggiungi_bene);
|
||||
AggiungiProdottiPanel.add(aggiungi_cena);
|
||||
AggiungiProdottiPanel.add(aggiungi_vacanza);
|
||||
AggiungiProdottiPanel.add(aggiungi_prestazione);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
north.add(AggiungiProdottiPanel,BorderLayout.CENTER);
|
||||
|
||||
mainWindow.add(north,BorderLayout.NORTH);
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////// begin center area for all offers
|
||||
|
||||
|
||||
JTextArea offers = new JTextArea(500,200);
|
||||
offers.setText("Utilizza il menu Cerca per popolare questa lista");
|
||||
mainWindow.add(offers,BorderLayout.CENTER);
|
||||
tutti_gli_articoli_attivi_id.addActionListener(new tutti_gli_articoli_attivi_id_action(this,offers,"0"));
|
||||
tutti_gli_articoli_attivi_costo.addActionListener(new tutti_gli_articoli_attivi_costo_action(this,offers,"1"));
|
||||
tutti_gli_articoli_scaduti.addActionListener(new tutti_gli_articoli_scaduti_action(this,offers));
|
||||
|
||||
|
||||
|
||||
|
||||
JPanel acquista_panel = new JPanel();
|
||||
|
||||
JLabel idlabel = new JLabel("ID");
|
||||
JTextField id = new JTextField(5);
|
||||
JButton rimuovi_prodotto = new JButton("Rimuovi Prodotto");
|
||||
|
||||
|
||||
/////old class to replace with rimuovi prodotto
|
||||
class aggiungi_al_carrello_action implements ActionListener {
|
||||
|
||||
|
||||
public aggiungi_al_carrello_action (AdminInterface in_location, JTextField in_id, JTextArea in_offers, JLabel in_count){
|
||||
id = in_id;
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
count = in_count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
|
||||
if (offers.getText().isEmpty()){
|
||||
JOptionPane.showMessageDialog(location,
|
||||
"Dovresti prima aggiornare l'elenco delle offerte attive ",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} else{
|
||||
|
||||
if (Integer.parseInt(id.getText()) >= 0 ){
|
||||
int found = load_catalogo.search_product_id(login_data.getUsername(),id.getText());
|
||||
if (found > -1){
|
||||
Carrello.add(load_catalogo.getCatalogo().get(found));
|
||||
count.setText(" Corrello: " + Carrello.size() + " Prodotti");
|
||||
|
||||
}else{
|
||||
JOptionPane.showMessageDialog(location,
|
||||
"Impossibile aggiungere il prodotto indicato ",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
JOptionPane.showMessageDialog(location,
|
||||
"Input Non valido ",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
catch (NumberFormatException err){
|
||||
JOptionPane.showMessageDialog(location,
|
||||
"Input Non valido ",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (NullPointerException err){
|
||||
JOptionPane.showMessageDialog(location,
|
||||
"Input Non valido ",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private JTextField id;
|
||||
private AdminInterface location;
|
||||
private JTextArea offers;
|
||||
private JLabel count;
|
||||
}
|
||||
rimuovi_prodotto.addActionListener(new aggiungi_al_carrello_action(this,id,offers,idlabel));
|
||||
|
||||
|
||||
|
||||
acquista_panel.add(idlabel);
|
||||
acquista_panel.add(id);
|
||||
acquista_panel.add(rimuovi_prodotto);
|
||||
|
||||
|
||||
|
||||
mainWindow.add(acquista_panel,BorderLayout.SOUTH);
|
||||
|
||||
|
||||
|
||||
|
||||
setSize(600, 400);
|
||||
setLocation(login_window.getLocation());
|
||||
setTitle("Admin Logged");
|
||||
setVisible(true);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
ArrayList<Utilizzabile> Carrello = new ArrayList<Utilizzabile>();
|
||||
LoginWindow login_window;
|
||||
Catalogo load_catalogo;
|
||||
LoginData login_data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class LoginWindow extends JFrame {
|
||||
Catalogo load_catalogo = new Catalogo();
|
||||
if (login.getType().equals("Admin")){
|
||||
actual.setVisible(false);
|
||||
//AdminInterface a = new AdminInterface(actual,load_catalogo,login);
|
||||
AdminInterface a = new AdminInterface(actual,load_catalogo,login);
|
||||
}else{
|
||||
actual.setVisible(false);
|
||||
UserInterface c = new UserInterface(actual,load_catalogo,login);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.awt.event.ActionListener;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,7 @@ public class UserInterface extends JFrame{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
load_catalogo.offerteAttive(login_data.getUsername(),offers);
|
||||
load_catalogo.offerteAttive(login_data.getUsername(),offers,"0");
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
@@ -107,12 +108,176 @@ public class UserInterface extends JFrame{
|
||||
private UserInterface location;
|
||||
private JTextArea offers;
|
||||
}
|
||||
//action listner for tutti_gli_articoli_attivi added at offers declaration
|
||||
//action listner added at offers declaration
|
||||
|
||||
JMenuItem articoli_con_scadenza_menu_item = new JMenuItem("Articoli con Scadenza");
|
||||
class tutti_gli_articoli_con_scadenza_action implements ActionListener {
|
||||
|
||||
|
||||
public tutti_gli_articoli_con_scadenza_action (UserInterface in_location, JTextArea in_offers){
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
|
||||
|
||||
JPanel showInput = new JPanel();
|
||||
JLabel field1l = new JLabel("Data Start");
|
||||
JTextField field1 = new JTextField(10);
|
||||
field1.setText("GG/MM/AAAA");
|
||||
JLabel field2l = new JLabel("Data Fine");
|
||||
JTextField field2 = new JTextField(10);
|
||||
field2.setText("GG/MM/AAAA");
|
||||
showInput.add(field1l);
|
||||
showInput.add(field1);
|
||||
showInput.add(field2l);
|
||||
showInput.add(field2);
|
||||
JOptionPane.showMessageDialog(location, showInput);
|
||||
|
||||
String marcatore="/";
|
||||
String data = field1.getText();
|
||||
String temp[];
|
||||
temp = data.split(marcatore);
|
||||
GregorianCalendar dataPartenza = new GregorianCalendar((Integer.parseInt(temp[2])),(Integer.parseInt(temp[1]))-1,(Integer.parseInt(temp[0])));
|
||||
|
||||
String data2 = field2.getText();
|
||||
String temp2[];
|
||||
temp2 = data2.split(marcatore);
|
||||
GregorianCalendar dataScad = new GregorianCalendar((Integer.parseInt(temp2[2])),(Integer.parseInt(temp2[1]))-1,(Integer.parseInt(temp2[0])));
|
||||
|
||||
|
||||
|
||||
load_catalogo.offerteAttiveConScadenza(login_data.getUsername(), offers, "0",dataPartenza,dataScad);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private UserInterface location;
|
||||
private JTextArea offers;
|
||||
}
|
||||
//action listner added at offers declaration
|
||||
|
||||
JMenuItem articoli_senza_scadenza_menu_item = new JMenuItem("Articoli senza Scadenza");
|
||||
class tutti_gli_articoli_senza_scadenza_action implements ActionListener {
|
||||
|
||||
|
||||
public tutti_gli_articoli_senza_scadenza_action (UserInterface in_location, JTextArea in_offers){
|
||||
location= in_location;
|
||||
offers = in_offers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
offers.setText("");
|
||||
|
||||
|
||||
int valutazione = Integer.parseInt(
|
||||
JOptionPane.showInputDialog(
|
||||
location, "Inserire valutazione fornitore","Valutazione"));
|
||||
|
||||
|
||||
|
||||
load_catalogo.offerteAttiveSenzaScadenza(login_data.getUsername(), offers, "0", valutazione);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private UserInterface location;
|
||||
private JTextArea offers;
|
||||
}
|
||||
//action listner added at offers declaration
|
||||
JMenu visualizzamenu = new JMenu("Visualizza");
|
||||
JMenuItem storico_menu_item = new JMenuItem("Storico Utente");
|
||||
JMenuItem storico_data_menu_item = new JMenuItem("Storico Utente per Data");
|
||||
class storico_data_menu_item_action implements ActionListener {
|
||||
|
||||
|
||||
public storico_data_menu_item_action (UserInterface in_location){
|
||||
location= in_location;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
|
||||
|
||||
|
||||
JPanel show_storico = new JPanel();
|
||||
JTextArea area_storico = new JTextArea(10,15);
|
||||
|
||||
|
||||
show_storico.add(area_storico);
|
||||
load_catalogo.visualizzaStorico(login_data.getUsername(),"1",area_storico);
|
||||
|
||||
JOptionPane.showMessageDialog(location, show_storico);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private UserInterface location;
|
||||
|
||||
}
|
||||
storico_data_menu_item.addActionListener(new storico_data_menu_item_action(this));
|
||||
JMenuItem storico_costo_menu_item = new JMenuItem("Storico Utente per Costo");
|
||||
class storico_costo_menu_item_action implements ActionListener {
|
||||
|
||||
|
||||
public storico_costo_menu_item_action (UserInterface in_location){
|
||||
location= in_location;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try{
|
||||
|
||||
|
||||
|
||||
JPanel show_storico = new JPanel();
|
||||
JTextArea area_storico = new JTextArea(10,15);
|
||||
|
||||
|
||||
show_storico.add(area_storico);
|
||||
load_catalogo.visualizzaStorico(login_data.getUsername(),"2",area_storico);
|
||||
|
||||
JOptionPane.showMessageDialog(location, show_storico);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (FileNotFoundException err){}
|
||||
catch (IOException err){}
|
||||
catch (ClassNotFoundException err){}
|
||||
|
||||
}
|
||||
|
||||
private UserInterface location;
|
||||
|
||||
}
|
||||
storico_costo_menu_item.addActionListener(new storico_costo_menu_item_action(this));
|
||||
|
||||
mainmenu.add(filemenu);
|
||||
mainmenu.add(searchmenu);
|
||||
@@ -126,7 +291,8 @@ public class UserInterface extends JFrame{
|
||||
searchmenu.add(articoli_senza_scadenza_menu_item);
|
||||
|
||||
|
||||
visualizzamenu.add(storico_menu_item);
|
||||
visualizzamenu.add(storico_data_menu_item);
|
||||
visualizzamenu.add(storico_costo_menu_item);
|
||||
|
||||
|
||||
|
||||
@@ -203,6 +369,8 @@ public class UserInterface extends JFrame{
|
||||
offers.setText("Utilizza il menu Cerca per popolare questa lista");
|
||||
mainWindow.add(offers,BorderLayout.CENTER);
|
||||
tutti_gli_articoli_attivi.addActionListener(new tutti_gli_articoli_attivi_action(this,offers));
|
||||
articoli_con_scadenza_menu_item.addActionListener(new tutti_gli_articoli_con_scadenza_action(this,offers));
|
||||
articoli_senza_scadenza_menu_item.addActionListener(new tutti_gli_articoli_senza_scadenza_action(this,offers));
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user