Skip to content

Commit

Permalink
#164 Add ending path separator in saved relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauddieumegard authored and pdulth committed Jul 21, 2022
1 parent cedb0c3 commit 3f5ca5b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ImageImportingDialog extends TitleAreaDialog {
private Text relativePathText;
private ImageImporter imageImporter;
private IProject currentProject;
private String separator = System.getProperty("file.separator");

protected ImageImportingDialog(Shell parentShell, ImageImporter imageImporter, IProject currentProject) {
super(parentShell);
Expand Down Expand Up @@ -68,7 +69,7 @@ protected void setUpRelPathUI(Composite container, Composite importingModesCompo
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(relativePathTextChoice);

relativePathText = new Text(importingModesComposite, SWT.SINGLE | SWT.BORDER);
relativePathText.setText(currentProject.getName() + "/");
relativePathText.setText(currentProject.getName() + separator);
relativePathText.addModifyListener(e -> {
String currentProjectParentLocation = currentProject.getLocation().removeLastSegments(1).toString();
Path currentProjectParentPath = Paths.get(currentProjectParentLocation);
Expand Down Expand Up @@ -110,7 +111,11 @@ public void widgetSelected(SelectionEvent e) {
protected void enableFinishForRelPath() {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(true);
imageImporter.setRelPath(relativePathText.getText());
String path = relativePathText.getText();
if (!path.endsWith("/") && !path.endsWith("\\")) {
path = path + separator;
}
imageImporter.setRelPath(path);
}

protected void disableFinish() {
Expand Down

0 comments on commit 3f5ca5b

Please sign in to comment.