Package com.datasquad.task
Class SecondPanel
- java.lang.Object
-
- com.datasquad.task.SecondPanel
-
class SecondPanel extends java.lang.ObjectThis class allows the management of the secondary panel located on the right of the graphical interface. It is in this panel that we set up a form to provide all the values of the tasks (Title, type of task, description, priority and deadline). There are also three buttons to manipulate the software data, such as saving or modifying tasks, but also a button to cancel the entry.- Author:
- CADOUL Michael AND VERY-GRIETTE Milan
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JButtonabortBtnDelete a task buttonprivate intactualTaskDisplayed when nothing is selectedprivate javax.swing.JButtonaddTypeInput for the dateprivate javax.swing.JComboBoxboxTypeType JLabelprivate javax.swing.JPanelbuttonsPanelJPanel component for the SecondPanelprivate static java.lang.StringDATE_FORMATClose a task buttonprivate javax.swing.JButtondeleteBtnSave a task buttonprivate javax.swing.JLabellabelDateInput with slider for the priorityprivate javax.swing.JLabellabelDescInput for the type of taskprivate javax.swing.JLabellabelPriorityInput for the descriptionprivate javax.swing.JLabellabelTitreJPanel in order to organize easily in a layoutprivate javax.swing.JLabellabelTypeJTextField, input for the titleprivate javax.swing.JLabelmWelcomePattern to check the dateprivate javax.swing.JButtonrmTypeAdd a type buttonprivate javax.swing.JButtonsaveBtnRemove a type buttonprivate javax.swing.JPanelsecondPanelprivate javax.swing.JSlidersliderPriorityPriority JLabelprivate javax.swing.JTextFieldtextDateDate JLabelprivate javax.swing.JTextAreatextDescDescription JLabelprivate javax.swing.JTextFieldtextTitreTitle JLabel
-
Constructor Summary
Constructors Constructor Description SecondPanel(MainPanel mainPanel)Class constructor
-
Method Summary
Modifier and Type Method Description private booleancheckTaskExist(MainPanel mainPanel)Used to check if a task already exists in order to prevent data duplication (based on the title of the tasks)private booleancheckTypeExist(MainPanel context, int i)Used to check if the type already exists, in order to prevent deleting a used type of task.private booleancheckTypeExist(MainPanel mainPanel, java.lang.String input)Used to check if a type already exists, in order to prevent data duplication(package private) voidemptyPanel()Function that empty the content of all the components in this SecondPanel.(package private) intgetActualTask()Getter(package private) javax.swing.JPanelgetSecondPanel()Getter(package private) voidhideComponents()Used to hide all the components of the SecondPanel.private static booleanisDateValid(java.lang.String date)Used to check if the date exists and in a valid format.(package private) voidloadTask(int index, MainPanel context)Used to load a task in the second panel, when selected in the JList for example, with a specific index in the array of TaskStorage, with the current "context".private voidproceedSave(MainPanel mainPanel)Used to save a task.(package private) voidrefreshBoxType(MainPanel mainPanel)Used to refresh the JComboBox, in order to display all the types of task if something was added or deleted.(package private) voidsetActualTask(int actualTask)Setterprivate voidsetConstraints(javax.swing.SpringLayout layout)Used to set all the constraints for a "responsive" layout (SpringLayout).(package private) voidshowComponent(boolean boolContext)Used to show some components, according to a specific context (eg.private intshowDialog(MainPanel mainPanel, java.lang.String message)Used to display a dynamic confirmation message JOptionPane.
-
-
-
Field Detail
-
secondPanel
private javax.swing.JPanel secondPanel
-
buttonsPanel
private javax.swing.JPanel buttonsPanel
JPanel component for the SecondPanel
-
labelTitre
private javax.swing.JLabel labelTitre
JPanel in order to organize easily in a layout
-
textTitre
private javax.swing.JTextField textTitre
Title JLabel
-
labelType
private javax.swing.JLabel labelType
JTextField, input for the title
-
boxType
private javax.swing.JComboBox boxType
Type JLabel
-
labelDesc
private javax.swing.JLabel labelDesc
Input for the type of task
-
textDesc
private javax.swing.JTextArea textDesc
Description JLabel
-
labelPriority
private javax.swing.JLabel labelPriority
Input for the description
-
sliderPriority
private javax.swing.JSlider sliderPriority
Priority JLabel
-
labelDate
private javax.swing.JLabel labelDate
Input with slider for the priority
-
textDate
private javax.swing.JTextField textDate
Date JLabel
-
addType
private javax.swing.JButton addType
Input for the date
-
rmType
private javax.swing.JButton rmType
Add a type button
-
saveBtn
private javax.swing.JButton saveBtn
Remove a type button
-
deleteBtn
private javax.swing.JButton deleteBtn
Save a task button
-
abortBtn
private javax.swing.JButton abortBtn
Delete a task button
-
DATE_FORMAT
private static final java.lang.String DATE_FORMAT
Close a task button- See Also:
- Constant Field Values
-
mWelcome
private javax.swing.JLabel mWelcome
Pattern to check the date
-
actualTask
private int actualTask
Displayed when nothing is selected
-
-
Constructor Detail
-
SecondPanel
SecondPanel(MainPanel mainPanel)
Class constructor- Parameters:
mainPanel- Reference to the MainPanel. This is useful if we want to access and modify all the UI. Sometimes, we call this reference, a "context".
-
-
Method Detail
-
getActualTask
int getActualTask()
Getter- Returns:
- The value of the ActualTask (index of the array located in TaskStorage). If the value is -1, then the task is new.
-
setActualTask
void setActualTask(int actualTask)
Setter- Parameters:
actualTask- A new value
-
refreshBoxType
void refreshBoxType(MainPanel mainPanel)
Used to refresh the JComboBox, in order to display all the types of task if something was added or deleted.- Parameters:
mainPanel- Using the reference to the MainPanel.
-
checkTypeExist
private boolean checkTypeExist(MainPanel context, int i)
Used to check if the type already exists, in order to prevent deleting a used type of task.- Parameters:
context- Using the reference to the MainPanel.i- Index of the type, stored in the TaskStorage (or the index of the JComboBox, that's the same)- Returns:
- Boolean value, TRUE if it exists, FALSE if not.
-
proceedSave
private void proceedSave(MainPanel mainPanel)
Used to save a task. But Firstly, checks if there's some important (and valid) data to set in the fields of the SecondPanel.- Parameters:
mainPanel- Using the reference to the MainPanel.- Throws:
java.lang.IllegalArgumentException- Threw if some entries are not valid or empty.
-
emptyPanel
void emptyPanel()
Function that empty the content of all the components in this SecondPanel.
-
checkTaskExist
private boolean checkTaskExist(MainPanel mainPanel)
Used to check if a task already exists in order to prevent data duplication (based on the title of the tasks)- Parameters:
mainPanel- Using the reference to the MainPanel.- Returns:
- Boolean value, TRUE if it exists, FALSE if not.
-
checkTypeExist
private boolean checkTypeExist(MainPanel mainPanel, java.lang.String input)
Used to check if a type already exists, in order to prevent data duplication- Parameters:
mainPanel- Using the reference to the MainPanel.input- The user input that we want to check.- Returns:
- Boolean value, TRUE if it exists, FALSE if not.
-
showDialog
private int showDialog(MainPanel mainPanel, java.lang.String message)
Used to display a dynamic confirmation message JOptionPane.- Parameters:
mainPanel- Using the reference to the MainPanel.message- The message that we want to display- Returns:
- Integer value (the user answer, YES or NO)
-
showComponent
void showComponent(boolean boolContext)
Used to show some components, according to a specific context (eg. Delete button for a task that doesn't exist doesn't make any sense.)- Parameters:
boolContext- IF false THEN createTaskContext, IF true THEN modifyTaskContext.
-
hideComponents
void hideComponents()
Used to hide all the components of the SecondPanel.
-
isDateValid
private static boolean isDateValid(java.lang.String date)
Used to check if the date exists and in a valid format.- Parameters:
date- The date that we want to check.- Returns:
- Boolean value, TRUE if the date is valid, FALSE if not.
-
setConstraints
private void setConstraints(javax.swing.SpringLayout layout)
Used to set all the constraints for a "responsive" layout (SpringLayout). All the objects in a SpringLayout is organised with several constraints. All we have to do is to define which components have a constraint in which side of the object A constraint must have a component, the side of a component, with another component with a specific side and the "distance" between the two objects- Parameters:
layout- The layout that we want to organize.
-
getSecondPanel
javax.swing.JPanel getSecondPanel()
Getter- Returns:
- The JPanel element.
-
loadTask
void loadTask(int index, MainPanel context)Used to load a task in the second panel, when selected in the JList for example, with a specific index in the array of TaskStorage, with the current "context".- Parameters:
index- The index of the task in TaskStoragecontext- Using the reference to the MainPanel.
-
-