-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ExportFormats: Use FileExtension enum #3565
Conversation
There was a problem hiding this comment.
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.
@@ -82,7 +82,7 @@ public void actionPerformed(ActionEvent e) { | |||
|
|||
ExportFileFilter eff = (ExportFileFilter) ff; | |||
String path = file.getPath(); | |||
if (!path.endsWith(eff.getExtension())) { | |||
if (!path.endsWith(eff.getExtension().toString())) { |
There was a problem hiding this comment.
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.
@@ -38,7 +39,7 @@ public boolean accept(File file) { | |||
if (file.isDirectory()) { | |||
return true; | |||
} else { | |||
return file.getPath().toLowerCase(Locale.ROOT).endsWith(extension); | |||
return file.getPath().toLowerCase(Locale.ROOT).endsWith(extension.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remark as above
@@ -78,7 +79,7 @@ public ExportFormat(String displayName, String consoleName, String lfFileName, S | |||
*/ | |||
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); |
There was a problem hiding this comment.
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 provided
extension`?
@@ -42,7 +42,9 @@ | |||
CLASS(Localization.lang("%0 file", "CLASS"), "class"), | |||
JAR(Localization.lang("%0 file", "JAR"), "jar"), | |||
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"), |
There was a problem hiding this comment.
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.
*/ | ||
public static IExportFormat getExportFormat(String consoleName) { | ||
return ExportFormats.EXPORT_FORMATS.get(consoleName); | ||
} | ||
|
||
public static FileExtensions getFileExtension(String consoleName) { | ||
ExportFormat exportFormat = (ExportFormat) EXPORT_FORMATS.get(consoleName); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
* 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
gradle localizationUpdate
?