Class ProjectFormPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ProjectFormPanel extends JPanel
Panel for entering and submitting new 3D print project data. Includes fields for name, type, tags, notes, dates, and folder selection. Features date picker and form clearing after successful submission. Extend this class to add more fields or validation logic.
See Also:
  • Field Details

    • projectNameField

      private JTextField projectNameField
      Project name input field.
    • projectTypeComboBox

      private JComboBox<String> projectTypeComboBox
      Project type dropdown.
    • lastPrintedDateField

      private JFormattedTextField lastPrintedDateField
      Date input field for last printed date (format yyyy-MM-dd).
    • projectNotesArea

      private JTextArea projectNotesArea
      Notes input area for additional project information.
    • addDateButton

      private JButton addDateButton
      Button to add the entered date to the list of last printed dates.
    • datePickerButton

      private JButton datePickerButton
      Button to open a date picker dialog.
    • removeDateButton

      private JButton removeDateButton
      Button to remove the selected date from the date list.
    • projectPathField

      private JTextField projectPathField
      Read-only field showing the selected project folder path.
    • browseButton

      private JButton browseButton
      Button to open a folder chooser for selecting the project folder.
    • addProjectButton

      private JButton addProjectButton
      Button to submit a new project to the database.
    • searchProjectsButton

      private JButton searchProjectsButton
      Button to open the search dialog for projects.
    • selectedFolder

      private File selectedFolder
      Currently selected project folder on disk (may be null).
    • dateListModel

      private DefaultListModel<String> dateListModel
      List model holding last-printed date strings.
    • lastPrintedDatesList

      private JList<String> lastPrintedDatesList
      UI list showing last-printed dates.
    • projectRecipientField

      private JTextField projectRecipientField
      Input field for the project recipient.
    • projectTagsList

      private JList<String> projectTagsList
      Multi-selection list of project tags/categories.
    • loadProjectButton

      private JButton loadProjectButton
      Button to load an existing project into the form.
    • updateProjectButton

      private JButton updateProjectButton
      Button to update an existing project's details.
  • Constructor Details

    • ProjectFormPanel

      public ProjectFormPanel()
      Constructs the project form panel and lays out all fields and buttons. All fields are mandatory for submission.
  • Method Details

    • browseForFolder

      private void browseForFolder(ActionEvent e)
      Opens a folder chooser dialog for selecting the project folder. Updates the projectPathField with the selected folder path.
      Parameters:
      e - Action event from browse button
    • addDateToList

      private void addDateToList(ActionEvent e)
      Adds the entered date to the list of last printed dates.
      Parameters:
      e - Action event from add date button
    • openDatePicker

      private void openDatePicker(ActionEvent e)
      Opens a date picker dialog for selecting a date.
      Parameters:
      e - Action event from date picker button
    • removeSelectedDate

      private void removeSelectedDate(ActionEvent e)
      Removes the selected date from the list of last printed dates.
      Parameters:
      e - Action event from remove date button
    • clearForm

      private void clearForm()
      Clears all form fields and resets to default values without altering layout.
    • validateProjectName

      private boolean validateProjectName(String name)
      Validates the project name for length and invalid characters.
      Parameters:
      name - The project name to validate.
      Returns:
      True if valid, false otherwise.
    • validateDate

      private boolean validateDate(String date)
      Validates the date format and ensures it is not in the future.
      Parameters:
      date - The date string to validate.
      Returns:
      True if valid, false otherwise.
    • validateFilePath

      private boolean validateFilePath(String path)
      Validates the file path for existence and accessibility.
      Parameters:
      path - The file path to validate.
      Returns:
      True if valid, false otherwise.
    • validateTextLengths

      private boolean validateTextLengths(String name, String description)
      Validates the length of the project name and description.
      Parameters:
      name - The project name to validate.
      description - The project description to validate.
      Returns:
      True if both are valid, false otherwise.
    • addNewProject

      private void addNewProject(ActionEvent e)
      Validates all fields and submits the new project to the database. Copies the project folder, inserts project data, and adds print dates. Clears the form after successful submission. Shows error dialogs if any step fails.
      Parameters:
      e - Action event from add project button
    • filterProjects

      public void filterProjects(String query)
      Filters the projects displayed in the panel based on the search query.
      Parameters:
      query - The search query to filter projects.
    • loadProjectData

      private void loadProjectData(ActionEvent e)
      Prompt for a project ID and load its data into the form fields.
      Parameters:
      e - the ActionEvent that triggered loading a project
    • updateProjectData

      private void updateProjectData(ActionEvent e)
      Prompt for a project ID and update the project's details in the database using the values currently set in the form.
      Parameters:
      e - the ActionEvent that triggered the update
    • setProjectDetails

      public void setProjectDetails(String name, String type, String description, String filePath)
      Sets the project details in the form fields.
      Parameters:
      name - Project name
      type - Project type
      description - Project description
      filePath - File path of the project