Skip to content

ExportFormats: Use FileExtension enum#3565

Merged
LinusDietz merged 6 commits into
JabRef:masterfrom
PJozeph:master
Dec 22, 2017
Merged

ExportFormats: Use FileExtension enum#3565
LinusDietz merged 6 commits into
JabRef:masterfrom
PJozeph:master

Conversation

@PJozeph

@PJozeph PJozeph commented Dec 21, 2017

Copy link
Copy Markdown
Contributor

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@tobiasdiez tobiasdiez 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.

I'm glad you were able to solve your compile problems! Thanks for your contribution. The current code still needs a bit of work before we can merge it. See below for further details.

ExportFileFilter eff = (ExportFileFilter) ff;
String path = file.getPath();
if (!path.endsWith(eff.getExtension())) {
if (!path.endsWith(eff.getExtension().toString())) {

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.

This will not work: the FileExtensions.toString method will return the default java string serialization and not the extension stored internally. You should use FileExtensions.getExtensionsAsList() instead.

return true;
} else {
return file.getPath().toLowerCase(Locale.ROOT).endsWith(extension);
return file.getPath().toLowerCase(Locale.ROOT).endsWith(extension.toString());

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.

same remark as above

public ExportFormat(String displayName, String consoleName, String lfFileName, String directory, String extension,
LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences) {
this(displayName, consoleName, lfFileName, directory, extension);
this(displayName, consoleName, lfFileName, directory, FileExtensions.AUX);

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 use ̀ AUXhere instead of the providedextension`?

XML(Localization.lang("%0 file", "XML"), "xml"),
ZIP(Localization.lang("%0 file", "ZIP"), "zip");
ZIP(Localization.lang("%0 file", "ZIP"), "zip"),
ODS(Localization.lang("%0 file", "ZIP"), "ods"),

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.

Please correct the description for ods and sxc.

@koppor koppor added this to the v4.1 milestone Dec 22, 2017
}

public static FileExtensions getFileExtension(String consoleName) {
ExportFormat exportFormat = (ExportFormat) EXPORT_FORMATS.get(consoleName);

@Siedlerchr Siedlerchr Dec 22, 2017

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.

What happens if no ExportFormat is not found for that console Name?
Then the exportFormat.getExtension will throw an NPE

@Siedlerchr Siedlerchr 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.

I think you need to add a default/check for null in that case

@LinusDietz LinusDietz 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.

Thanks for your contribution!

@LinusDietz LinusDietz merged commit d9644d0 into JabRef:master Dec 22, 2017
Siedlerchr added a commit that referenced this pull request Dec 28, 2017
* upstream/master: (121 commits)
  Fix fetcher tests (#3583)
  Convert entry preview panel to JavaFX (#3574)
  Remove dependency for JUnit4 (#3580)
  Update tracis cache config as recommned by the docs (#3575)
  fix typo
  Show development information
  Release v4.1
  Add new authors to mailMap (#3567)
  Fix build
  Really fix changelog
  Fix changelog
  Minor changes
  Disable the autocompletion as default (#3569)
  Add update exception for applicationinsights 2.0.0-BETA (#3571)
  Install4j jres 152 (#3570)
  Fix grammar mistake
  Downgrade applicationinsights. Fixes #3561
  Adapt scripts/prepare-install4j.sh to JRE1.8.0_152 (#3568)
  ExportFormats: Use FileExtension enum (#3565)
  Update guava from 23.5-jre -> 23.6-jre
  ...

# Conflicts:
#	build.gradle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants