Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trash refactor #3342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SusanRatiLane
Copy link
Contributor

General items:

For all other changes:

  • I branched from master
  • My pull request has master as the base

What does this PR accomplish?

Previously, the trash can only accepted projects, and it was impossible to delete folders. This change refactors the trash/restore/delete system to behave more like the trash system from an OS. Project can be moved to trash individually, and folders can be trashed with their nested contents of projects and folders. All of these things can be restored or deleted permanently

Fixes #3222

Sorry, something went wrong.

@SusanRatiLane SusanRatiLane requested a review from a team January 21, 2025 22:31
@ewpatton ewpatton self-assigned this Jan 22, 2025
@SusanRatiLane SusanRatiLane changed the title Feature/trash refactor Trash refactor Jan 22, 2025
@ewpatton ewpatton added this to the nb201 milestone Feb 12, 2025
Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

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

A few minor things.

Comment on lines +90 to +93
// Ode.getInstance().getFolderManager().addFolderManagerEventListener(this);

// It is important to listen to project manager events as soon as possible.
Ode.getInstance().getProjectManager().addProjectManagerEventListener(this);
// Ode.getInstance().getProjectManager().addProjectManagerEventListener(this);
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure commenting these out is the correct thing to be doing?

folder.removeProject(project);
Ode.getInstance().getFolderManager().saveAllFolders();
refresh();

Copy link
Member

Choose a reason for hiding this comment

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

Could remove this blank line entirely.

project.restoreFromTrash();
}
List<ProjectFolder> selectedFolders = ProjectListBox.getProjectListBox().getProjectList()
.getSelectedFolders();
Copy link
Member

Choose a reason for hiding this comment

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

Indentation should just be +4 here.

List<ProjectFolder> selectedFolders = ProjectListBox.getProjectListBox().getProjectList()
.getSelectedFolders();
if (!selectedProjects.isEmpty() || !selectedFolders.isEmpty()) {
Ode.getInstance().getFolderManager().moveItemsToFolder(selectedProjects, selectedFolders,
Copy link
Member

Choose a reason for hiding this comment

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

You could cache the call to Ode.getInstance() and reuse it.

Comment on lines +83 to +88
for (ProjectFolder child : folder.getChildFolders()) {
if (!"*trash*".equals(child.getName()) && !selectedFolders.contains(child)) {
FolderTreeItem childItem = renderFolder(child);
childItem.setState(true);
treeItem.addItem(childItem);
}
Copy link
Member

Choose a reason for hiding this comment

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

Why was the indentation changed here?

Project currentProject = Ode.getInstance().getProjectManager().getProject(Ode.getInstance().getCurrentYoungAndroidProjectId());
selectedProjects.add(currentProject);
if (deleteConfirmation(selectedProjects)) {
if (deleteConfirmation(true, selectedProjects, new ArrayList<>())) {
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to use Collections.emptyList() if GWT supports it in order to not have to result a new list every time this gets called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When empty folders are sent to trash, they are not removed from the project list
2 participants