In the second seminar, you are going to explore a new GUI application called Employee Records. The application is intended for storing data about employees (their basic data including department).

Throughout this seminar, you will work in cooperation with your project teammates. Please, group together so that all of you sit nearby for better coordination and collaboration. This time both pairs will work with the same code without changing branches. All pairs are required to go through each task (except Task 0, which is intended do be done in the context of the team to create the initial setup).

Task 0: Prepare the repository

Every team needs only a single repository for this seminar and the following ones.

Choose a teammate who forks the repository and sets it up for the benefit of the whole team. As stated above, both pairs will work with the same fork of the repository.

Task 0.1: Fork the repository and make it private

  • Fork the Employee Records as a private repository into your personal namespace.
  • If you forgot to make it private, you can still change it as described bellow:

    Go to Settings > General and expand Visibility, project features, permissions. Then change the Project visibility and scroll down (to be able) to click on Save changes.

Task 0.2: Make the repository accessible for designated people

  • Add all your team members under the Maintainer role.

    Go to Manage > Members and click on Invite Members. Fill in the FI login names of your teammates and choose Maintainer in Select a role. Finally, click on Invite.

  • Add both your seminar tutors under the Reporter role.

    You can find the FI login names of your seminar group tutors in Seminars page.

Note: You do not need to add PMs into the forked repository. PMs will be interacting only with the project you will be working on outside of these seminars, during the semester - the project assigned by the PM.

Task 0.3: Clone the repository and create branch for your work

Each pair clones the repository into a single computer as they are working together as one person during the seminar.

Pair 1 creates a new branch seminar02-pair1:

git switch -c seminar02-pair1

Pair 2 creates 1 new branch seminar02-pair2:

git switch -c seminar02-pair2

Task 1: Modify the application to fully support Add, Edit, and Delete operations

The application in its initial version is inconsistent in navigation ability throughout various operations via the GUI. Your task is to make it consistent and make all available actions available in their relevant contexts.

Task 1.1: Add missing operations to the applications menu

image

The application menu supports only the Add operation so far. Add the missing operations: Delete and Edit. For each operation, add it’s label, icon, keyboard shortcut, tooltip, and mnemonics.

Task 1.2: Add missing operations to the context menu

The application also supports a context menu displayed after performing a right click on a record in the table:

image

Add the missing Add operation to the context menu. Again, add its label, icon, keyboard shortcut, tooltip, and mnemonics.

Task 1.3: Add all operations to Toolbar

So far, the application’s toolbar contains only the Quit button.

image

Add all three operations (Add, Edit and Delete) to the toolbar. This time add only icon and tooltip for each operation.

Task 1.4: Commit and push your implementation

Once you finish adding all the operations to all places, please commit your work and push it to the remote repository (within the same branch you are working on).

Task 2: Add new columns

The table with employees contains three columns, some of which are editable. In this task, you will modify the application to support two new columns (both as NOT editable). You will need to update the Employee class to add support for storing data for the newly added columns.

Hints:

  1. Once you add new attributes to the Employee class, you will also need to modify the TestDataGenerator#createTestEmployee() method, which is responsible for test data generation.
  2. For simplicity, you can set the same value for all generated employees in the new columns if you fail to come up with anything better. Anyway, you don’t need to worry about a random selection of values for the new attributes you just added.
  3. New attributes should be not editable. However, you will probably want to let them be specified, when you are creating a new entry. After that, these should not be editable. If you find it too difficult to fulfill the requirement, do not spend too much on it. You can take for granted there will be some random value set for these fields.

Task 2.1: Add Gender column

Add 4th column with the information about employee’s gender. Take for granted that our customer comes from an ultra-conservative society considering only male and female genders. Moreover, they told us this is not going to change in the future.

Task 2.2: Add Age column

Add 5th column with information about employee’s age.

Task 2.3: Commit and push your implementation

Once you finish making modifications, please commit all changes, and push them to the remote repository.

Task 3: Change the order of columns

Task 3.1: Change the order

Modify the application to display columns in this exact order: Gender, Age, Last Name, First Name, Department

Task 3.2: Commit and push your changes

Once you finish making modifications, please commit all changes, and push them to the remote repository.

Task 4: Disable/Enable operations based on the number of selected rows

Let’s get back to toolbar buttons and menu items. The Edit and Delete buttons can be clicked at any time. However, this doesn’t make sense if, for example, no row is selected.

In this task, you will modify the application to enable/disable operations in menus based on the current context, e.g. if some row is selected.

Hints:

  1. Take a look at the MainWindow#rowSelectionChanged() method, which is executed whenever the selection changes. This is the primary place for your intervention.
  2. Check the ListSelectionEvent#getSource method - what does it return?
    • Since we are using JTable, all selection events are handled by ListSelectionModel.
    • Therefore, it safe to cast the source to ListSelectionModel.
  3. Enabling or disabling a menu item or a toolbar button can easily be done by calling the setEnabled() method on it.

Task 4.1: Disable/Enable Add operation

Modify the application to enable the Add operation in the context menu if and only if no row is selected. For all other menus, the operation should stay enabled at all times.

Task 4.2: Disable/Enable Edit operation

Modify the application to enable the Edit operation if and only if exactly one row is selected. Otherwise, editing should be disabled.

Task 4.3: Disable/Enable Delete operation

Modify the application to enable the Delete operation if and only if at least one row is selected. Otherwise, deleting should be disabled.

Task 4.4: Commit and push your implementation

Once you finish making modifications, please commit all changes, and push them to the remote repository.