Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//java public class TicketGUI extends JFrame { // TODO complete the instructions at the end line of this code protected JPanel mainPanel ; // Components

//java

 public class TicketGUI extends JFrame { // TODO complete the instructions at the end line of this code   protected JPanel mainPanel; // Components for adding tickets  protected JPanel addTicketPanel; protected JTextField descriptionTextField; protected JTextField reporterTextField; protected JComboBox priorityComboBox; protected JButton addButton; // Components for displaying ticket list  protected JPanel ticketListPanel; protected JList ticketList; protected JLabel ticketListStatusDescription; // Components for searching  protected JPanel searchPanel; protected JTextField descriptionSearchTextBox; protected JTextField idSearchTextBox; protected JButton searchDescriptionButton; protected JButton searchIdButton; protected JButton showAllTicketsButton; // Saving and quit  protected JPanel controlsPanel; protected JButton saveAndQuitButton; // Deleting  protected JButton deleteSelectedButton; // Messages for showing in ticketListStatusDescription  // Use these instead of your own Strings, the tests expect you to use these variables  static final String ALL_TICKETS = "Showing all tickets"; static final String TICKETS_MATCHING_DESCRIPTION = "Tickets matching search description"; static final String TICKET_MATCHING_ID = "Ticket matching ID"; static final String NO_TICKETS_FOUND = "No matching tickets"; static final String INVALID_TICKET_ID = "Invalid ticket ID"; // A reference to the SupportTicketManagerWithGUI object  // The GUI will call the methods in this class to add, search for, and delete tickets.  // See example in quitProgram method.  TicketProgram manager; TicketGUI(TicketProgram manager) { this.manager = manager; setContentPane(mainPanel); pack(); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } // Call this method to quit the program. The tests expect you to use it.  protected void quitProgram() { manager.quitProgram(); this.dispose(); } // Use this method to show message dialogs displaying the message given.  // Otherwise tests for code that shows alert dialogs will time out and fail.  protected void showMessageDialog(String message) { JOptionPane.showMessageDialog(this, message); } // Use this method to show input dialogs asking the given question.  // Otherwise tests for code that shows input dialogs will time out and fail.  // If user presses the cancel button, this method will return null.  protected String showInputDialog(String question) { return JOptionPane.showInputDialog(this, question); }} ========================================================================================================= 

//instructions

### Task 1: TicketGUI, Set up priorityComboBox  Configure `priorityComboBox` so it contains the choices 1, 2, 3, 4, 5. ### Task 2: Configure TicketGUI ticketList JList  Configure `ticketList` so it will be able to display a list of Ticket objects. Use generic types. The Ticket objects should be shown in priority order, most urgent first. TicketStore should already be returning Ticket lists in the correct order. The selection model should be `SINGLE_SELECTION`. `ticketList` will be able to show any list of Tickets, for example, all the open Tickets, or only Tickets that match a search. ### Task 3: Get all the open tickets for ticketList JList  Ensure that you have provided the methods to read in open Ticket data from `open_tickets.txt`. In TicketGUI, use the manager object to request all the current open Tickets. Configure the `ticketList` JList to display this list of open Ticket objects when the GUI first opens. Add a listener to `showAllTicketsButton` to show all of the current open tickets in `ticketList`. The user may click this after searching for tickets. ### Task 4: Add Ticket  Implement the add ticket feature in TicketGUI. Add a listener to addButton which reads data from `descriptionTextField` and `reporterTextField` and `priorityComboBox`. Ensure that all the data needed has been entered. If so, create a new Ticket and call `manager.addTicket(newTicket)` to request that the new ticket is added to the Ticket store. The ticketList JList should then update to show all the open Tickets, including the new Ticket. If data (reporter, or description, or priority) is missing, display a message dialog to warn the user. Do not create a new Ticket. Use the `showMessageDialog` method in TicketGUI to show the message dialog. ### Task 5: Search by ID  Implement a listener for the `searchIdButton`. When this button is clicked, read the text in `idSearchTextBox`. Verify data has been entered, and that it is a positive integer. If there is no data or the data is invalid (not an integer, or a negative integer) the `ticketList` should show an empty list, and set the `ticketListStatusDescription` JLabel to the String `INVALID_TICKET_ID`  If the ID is a positive integer then use `manager` to search for the matching ticket. If a ticket with this ID is found, display it in `ticketList` and set the `ticketListStatusDescription` to `TICKET_MATCHING_ID`  If a ticket with this ID is not found, `ticketList` should not show any Tickets and `ticketListStatusDescription` should be set to `NO_TICKETS_FOUND`  Do not show any message dialogs. ### Task 6: Search by Description  Implement a listener for the `searchDescriptionButton`. When this button is clicked, read the text in `descriptionSearchTextBox`. Verify data has been entered. If there is no search data, `ticketList` should be empty, and set the `ticketListStatusDescription` JLabel to the String `NO_TICKETS_FOUND`  If there is search data, then use `manager` to search for the matching tickets. If a tickets containing the description are found (remember the search should not be case sensitive), display all the matching Tickets in `ticketList` and set `ticketListStatusDescription` to `TICKETS_MATCHING_DESCRIPTION`. The search method you wrote in the previous version of this lab should work for this lab too. If no tickets matching this description are found, `ticketList` should not show any Tickets and `ticketListStatusDescription` should be set to `NO_TICKETS_FOUND`  Do not show any message dialogs. ### Task 7: Delete Ticket  To delete Tickets, the user will select one Ticket in `ticketList` and click the `deleteSelectedButton` button. Add a listener to `deleteSelectedButton` that checks if a Ticket is selected. Show a message dialog with an appropriate message if no Ticket is selected in `ticketList`. If a Ticket is selected in `ticketList`, then use TicketGUI's `showInputDialog` method to show an JOptionPane input dialog. The user will be able to click the Cancel button, if they don't want to delete/resolve the ticket. `showInputDialog` returns null if the user clicks cancel. In this case, you should not delete the selected Ticket. The `ticketList` should not change. Or, the user will type in a resolution String and click the OK button. Do the following tasks: * Use the String entered to set the resolution of the ticket. * Set the date it was resolved to the current date/time * Call manager's `resolveTicket` method to remove this Ticket from the ticket store, and add it to the resolved tickets store. * Display a message dialog with a confirmation message. * You'll need to implement TicketProgram's `resolveTicket(Ticket ticket)` method. * The GUI should update `ticketList` so the deleted Ticket is no longer in the list. Display all the remaining open Tickets. * `ticketListStatusDescription` should show the String `ALL_TICKETS`. ### Task 8: Save and Quit  Add a listener to `saveAndQuitButton`. This should call the `manager.quitProgram()` method, which will use TicketFileIO to to save all current open and resolved Tickets to files, as implemented in the previous lab. As before, save all program data in a directory called TicketData. Your program should use the `ticketDataDirectory` variable for the directory name, so the tests can replace this name with a test directory and avoid overwriting your data. You should be able to use the same code written in the previous version of this program. The TicketGUI should close itself by calling `dispose()`. This is the only task running so will cause the program to exit. You need not save tickets to file until the user quits the program. Use the same filenames as Lab 7. ### Task 9: Load Open Tickets on Relaunch  When your program opens, it should read in open Ticket information from `TicketData/open_tickets.txt`, if this file exists. Your program should provide these to the GUI so all open Tickets are shown in `ticketList` when the program opens. You should be able to use the same code written in the previous version of this program. You don't need to read in the previous resolved tickets. As before, what happens to ticket IDs when the program is closed and opened? Make sure they don't reset to 1 when the user restarts the program. Every ticket created should always have a unique positive integer ID, (excluding 0) no matter how many times the program is used*. Save the counter information in a file with the name given by `TicketProgram.ticketCounterFile`. You will need to use a second constructor for creating a tickets when the ID is already known. Make sure you don't break your mechanism for ensuring unique IDs. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions