Skip to content

Commit

Permalink
Don't use IFileInfo.toString() in UI, use IFileStore.toString()
Browse files Browse the repository at this point in the history
The `IFileInfo.toString()` isn't intended to be shown to user, it has no
information interesting for users.

The `IFileStore.toString()` should be used in cases if information about
deleted resources need to be shown in UI.

Additionally changed dialog wording to not use "location" and be more
clear about what's going on.

Fixes eclipse-platform/eclipse.platform#1404
  • Loading branch information
iloveeclipse committed Jun 6, 2024
1 parent 1f3c3e1 commit 1af7f4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
package org.eclipse.ui.actions;

import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceRuleFactory;
Expand Down Expand Up @@ -113,11 +115,13 @@ void checkLocationDeleted(IProject project) throws CoreException {
if (!project.exists()) {
return;
}
IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI());
URI locationURI = project.getLocationURI();
IFileInfo location = IDEResourceInfoUtils.getFileInfo(locationURI);
if (!location.exists()) {
String displayedProjectPath = toDisplayPath(locationURI);
String message = NLS.bind(
IDEWorkbenchMessages.RefreshAction_locationDeletedMessage,
project.getName(), location.toString());
project.getName(), displayedProjectPath);

final MessageDialog dialog = new MessageDialog(getShell(),
IDEWorkbenchMessages.RefreshAction_dialogTitle, // dialog
Expand All @@ -143,6 +147,11 @@ protected int getShellStyle() {
}
}

private static String toDisplayPath(URI locationURI) {
IFileStore fileStore = IDEResourceInfoUtils.getFileStore(locationURI);
return fileStore != null ? fileStore.toString() : locationURI.toString();
}

@Override
protected String getOperationMessage() {
return IDEWorkbenchMessages.RefreshAction_progressMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ RefreshAction_toolTip = Refresh
RefreshAction_progressMessage = Refreshing...
RefreshAction_problemTitle = Refresh Problems
RefreshAction_problemMessage = Problems occurred refreshing the selected resources.
RefreshAction_locationDeletedMessage = The location for project ''{0}'' ({1}) has been deleted.\nDelete ''{0}'' from the workspace?
RefreshAction_dialogTitle = Project location has been deleted
RefreshAction_locationDeletedMessage = Directory ''{1}'' has been deleted.\nDelete also project ''{0}'' from the workspace?
RefreshAction_dialogTitle = Project has been deleted on file system

SelectWorkingSetAction_text= Select &Working Set...

Expand Down

0 comments on commit 1af7f4d

Please sign in to comment.