Skip to content

Added Clear group option#15017

Merged
koppor merged 16 commits into
JabRef:mainfrom
ZiadAbdElFatah:fix-for-issue-15001
Feb 3, 2026
Merged

Added Clear group option#15017
koppor merged 16 commits into
JabRef:mainfrom
ZiadAbdElFatah:fix-for-issue-15001

Conversation

@ZiadAbdElFatah

@ZiadAbdElFatah ZiadAbdElFatah commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator

User description

Closes #15001

Added clear group option that lets user to clear the entries in Explicit Groups.

Steps to test

First open example library, then Go to group "Used", then Open context menu, now you can see clear group option.
image

Select clear group. Now the group is empty.
image

To double check that it works with Explicit Groups only go to any other group try to clear it.
image

It will stay the same.
image

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

PR Type

Enhancement


Description

  • Added "Clear group" context menu option for explicit groups

  • Removes all entries from explicit groups with single action

  • Option only appears for explicit groups, not other group types

  • Updated localization strings and changelog documentation


Diagram Walkthrough

flowchart LR
  A["User right-clicks group"] -- "context menu" --> B["Clear group option"]
  B -- "checks if explicit group" --> C["Remove all entries"]
  C -- "refresh view" --> D["Empty group"]
Loading

File Walkthrough

Relevant files
Enhancement
StandardActions.java
Add GROUP_ENTRIES_CLEAR standard action                                   

jabgui/src/main/java/org/jabref/gui/actions/StandardActions.java

  • Added new GROUP_ENTRIES_CLEAR action enum with localized label
  • Defines the "Clear group" action for use in context menus
+1/-0     
GroupTreeView.java
Integrate clear group action into context menu                     

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeView.java

  • Added "Clear group" menu item to group context menu
  • Added GROUP_ENTRIES_CLEAR case to visibility condition check
  • Added GROUP_ENTRIES_CLEAR case to execute method to call clearGroup()
  • Ensures option only visible for groups that can add entries
+6/-2     
GroupTreeViewModel.java
Implement clearGroup method for explicit groups                   

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java

  • Implemented new clearGroup() method that clears explicit groups
  • Checks if group is instance of ExplicitGroup before clearing
  • Retrieves all entries in group and removes them
  • Prevents clearing of non-explicit group types
+8/-0     
Documentation
CHANGELOG.md
Document clear group feature in changelog                               

CHANGELOG.md

  • Added entry documenting new clear groups feature
  • References issue Add "Clear group" #15001 and links to documentation
  • Describes feature as clearing groups with explicitly selected entries
+1/-0     
Localization
JabRef_en.properties
Add English localization for clear group                                 

jablib/src/main/resources/l10n/JabRef_en.properties

  • Added English localization string for "Clear group" action
  • Placed in appropriate location with other group-related strings
+1/-0     

@github-actions github-actions Bot added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Feb 3, 2026
@github-actions github-actions Bot mentioned this pull request Feb 3, 2026
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Feb 3, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Feb 3, 2026
}

public void clearGroup(GroupNodeViewModel group) {
if (group.getGroupNode().getGroup() instanceof ExplicitGroup) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use instanceof pattern matching - see diff of #15013

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that was nice to know about instanceof pattern matching, it's my first time to know it.
but why is it important for this solution?


Remove=Remove

Remove\ subgroups=Remove subgroups

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you go pack to the state before #15005 ?

you can do git checkout upstream/main jablib/src/main/resources/l10n/JabRef_en.properties - and then add your key again.

Do not destroy work of others at merge conflict resoluiton.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that it was by fault.

Comment thread CHANGELOG.md Outdated
- REST-API: Added the possibility to trigger the import dialog. [#14855](https://github.com/JabRef/jabref/pull/14855)
- REST-API: Allow import of supported formats via `POST http://localhost:23119/libraries/current/entries`. [#14896](https://github.com/JabRef/jabref/pull/14896)
- We added the ability to update bibliographic information based on the existing entry data. [#14185](https://github.com/JabRef/jabref/issues/14185)
- We added Clear group option to easily clear explicits groups. [#15001](https://github.com/JabRef/jabref/issues/15001)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- We added Clear group option to easily clear explicits groups. [#15001](https://github.com/JabRef/jabref/issues/15001)
- We added an option to easily clear explicits groups. [#15001](https://github.com/JabRef/jabref/issues/15001)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have clicked on "Commit suggestion" - then GitHub would have just made a commit :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow 😮
This is so cool.

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Feb 3, 2026

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpicks 😇

Comment thread jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java Outdated

public void clearGroup(GroupNodeViewModel group) {
if (group.getGroupNode().getGroup() instanceof ExplicitGroup explicitGroup) {
List<BibEntry> entriesInGroup = group.getGroupNode().getEntriesInGroup(this.currentDatabase.get().getEntries());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group.getGroupNode() apprearing three times - extract variable please.

Comment thread CHANGELOG.md Outdated
ZiadAbdElFatah and others added 2 commits February 3, 2026 15:15
…java

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Feb 3, 2026
@ZiadAbdElFatah

Copy link
Copy Markdown
Collaborator Author

Small nitpicks 😇

Hope they will be the last ones 🫠

@ZiadAbdElFatah ZiadAbdElFatah requested a review from koppor February 3, 2026 13:27
@koppor koppor marked this pull request as ready for review February 3, 2026 13:38
Comment thread jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java Outdated
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #15001
🟢 Add a "Clear group" option in the context menu for groups
The feature should only work for groups with "Explicit selection"
The option should appear below "remove selected entries from the group"
The feature should make it easy to clear groups like "imported entries" that collect
automatically imported entries
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing error handling: The clearGroup() method silently does nothing when called on non-explicit groups without
logging or user feedback

Referred Code
public void clearGroup(GroupNodeViewModel group) {
    GroupTreeNode groupNode = group.getGroupNode();
    if (groupNode.getGroup() instanceof ExplicitGroup explicitGroup) {
        List<BibEntry> entriesInGroup = groupNode.getEntriesInGroup(this.currentDatabase.get().getEntries());
        groupNode.removeEntriesFromGroup(entriesInGroup);
    }
}

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Add undo support for clear group

Add undo/redo support to the clearGroup method. To do this, create an
UndoableEdit and add it to the UndoManager before removing the entries.

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java [727-733]

 public void clearGroup(GroupNodeViewModel group) {
     GroupTreeNode groupNode = group.getGroupNode();
     if (groupNode.getGroup() instanceof ExplicitGroup explicitGroup) {
         List<BibEntry> entriesInGroup = groupNode.getEntriesInGroup(this.currentDatabase.get().getEntries());
-        groupNode.removeEntriesFromGroup(entriesInGroup);
+        if (!entriesInGroup.isEmpty()) {
+            var undo = new UndoableChangeEntriesOfGroup(groupNode, entriesInGroup, UndoableChangeEntriesOfGroup.Modification.REMOVE);
+            stateManager.getUndoManager().addEdit(undo);
+            groupNode.removeEntriesFromGroup(entriesInGroup);
+        }
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: This suggestion correctly identifies that the new clearGroup action lacks undo support, which is a significant feature gap for a destructive operation and inconsistent with other similar actions in the class that do support it.

High
High-level
Add a confirmation dialog before clearing

To prevent accidental data loss, add a confirmation dialog before executing the
"Clear group" action. This makes it consistent with other destructive operations
like group removal.

Examples:

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java [727-733]
    public void clearGroup(GroupNodeViewModel group) {
        GroupTreeNode groupNode = group.getGroupNode();
        if (groupNode.getGroup() instanceof ExplicitGroup explicitGroup) {
            List<BibEntry> entriesInGroup = groupNode.getEntriesInGroup(this.currentDatabase.get().getEntries());
            groupNode.removeEntriesFromGroup(entriesInGroup);
        }
    }

Solution Walkthrough:

Before:

// in GroupTreeViewModel.java
public void clearGroup(GroupNodeViewModel group) {
    GroupTreeNode groupNode = group.getGroupNode();
    if (groupNode.getGroup() instanceof ExplicitGroup explicitGroup) {
        List<BibEntry> entriesInGroup = groupNode.getEntriesInGroup(this.currentDatabase.get().getEntries());
        groupNode.removeEntriesFromGroup(entriesInGroup);
    }
}

After:

// in GroupTreeViewModel.java
public void clearGroup(GroupNodeViewModel group) {
    if (!(group.getGroupNode().getGroup() instanceof ExplicitGroup)) {
        return;
    }

    Optional<ButtonType> choice = dialogService.showConfirmationDialogAndWait(
            Localization.lang("Clear group"),
            Localization.lang("Are you sure you want to clear the group \"%0\"?", group.getDisplayName()),
            Localization.lang("Clear group"),
            Localization.lang("Cancel"));

    if (choice.isPresent() && choice.get() == ButtonType.OK) {
        GroupTreeNode groupNode = group.getGroupNode();
        List<BibEntry> entriesInGroup = groupNode.getEntriesInGroup(...);
        groupNode.removeEntriesFromGroup(entriesInGroup);
    }
}
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a missing confirmation dialog for a destructive action, which is inconsistent with similar actions in the component and could lead to accidental loss of user work.

Medium
  • More

@ZiadAbdElFatah ZiadAbdElFatah requested a review from koppor February 3, 2026 14:01

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's get this in.

Maybe, someone will say that

Remove all entries from this group

is a better string.

I think, its good to have a significant other string to say that it is a dangerous operation.

@koppor koppor enabled auto-merge February 3, 2026 14:13
@koppor koppor added this pull request to the merge queue Feb 3, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Feb 3, 2026
Merged via the queue into JabRef:main with commit 4fc0843 Feb 3, 2026
52 checks passed
@ZiadAbdElFatah ZiadAbdElFatah deleted the fix-for-issue-15001 branch February 3, 2026 15:16
Siedlerchr added a commit to Jalina2007/jabref that referenced this pull request Feb 5, 2026
…4902

* upstream/main: (23 commits)
  Some more recipes from OpenRewrite (JabRef#15030)
  feat: Add PDF Upload endpoint to EntryResource (JabRef#14963)
  Heuristics also used at batch (JabRef#15025)
  Fix cleanup-pr.yml
  New Crowdin updates (JabRef#15035)
  Use patched Gradle version (JabRef#15034)
  Add OpenAlex-based Citation Fetcher (JabRef#15023)
  Update null annotaitons at EntryBasedFetcher (JabRef#15024)
  Fix CHANGELOG.md test
  Use _ for unused variables (JabRef#15028)
  Use ubuntu-latest for checkstyle and javadoc
  Update Gradle Wrapper from 9.3.0-jabref-2 to 9.3.1 (JabRef#15021)
  Use "ubuntu-slim" for most workflows (JabRef#15019)
  Refine GroupsTree (JabRef#15013)
  New Crowdin updates (JabRef#15018)
  Added Clear group option (JabRef#15017)
  Chore(deps): Bump com.uber.nullaway:nullaway from 0.12.15 to 0.13.1 in /versions (JabRef#15006)
  Chore(deps): Bump tools.jackson:jackson-bom in /versions (JabRef#15007)
  No rush in Docker building
  Yaml issue workaround
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue An issue intended for project-newcomers. Varies in difficulty. Review effort 2/5 status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Clear group"

2 participants