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

Persist OO Style choice (& Change OO Style Architecture) #7

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
432f6d4
Rename OOBibStyle to JStyle
subhramit Jul 13, 2024
8360180
Rename OOBibStyle to JStyle (Other classes)
subhramit Jul 13, 2024
8557c71
Separation of Style Type classes
subhramit Jul 13, 2024
f58cc6c
Rename OO Style file in preferences (to be replaced later)
subhramit Jul 13, 2024
2bc76b6
Undo rename preferences
subhramit Jul 13, 2024
b7f5711
Extend OO Preferences to include current style
subhramit Jul 13, 2024
fda187e
Add getPath to interface methods
subhramit Jul 13, 2024
6e63658
Use concrete object in StyleSelectDialogViewModel
subhramit Jul 13, 2024
1c28338
Separate unified and csl style seelction
subhramit Jul 13, 2024
d22c804
Attempt - Unified style
subhramit Jul 14, 2024
b9745ed
Fix Chocolate.bib (#11491)
koppor Jul 15, 2024
c56e55a
Update Gradle Wrapper from 8.8 to 8.9.
gradle-update-robot Jul 15, 2024
51aa23c
Merge pull request #11494 from JabRef/gradlew-update-8.9
Siedlerchr Jul 15, 2024
988d25d
FAQ updates (#11486)
subhramit Jul 15, 2024
41cb991
Bump org.openrewrite.recipe:rewrite-recipe-bom from 2.14.0 to 2.15.0 …
dependabot[bot] Jul 15, 2024
55c808d
Bump com.kohlschutter.junixsocket:junixsocket-mysql from 2.9.1 to 2.1…
dependabot[bot] Jul 15, 2024
eb7773d
Bump org.jsoup:jsoup from 1.17.2 to 1.18.1 (#11497)
dependabot[bot] Jul 15, 2024
a64d298
Bump commons-logging:commons-logging from 1.3.2 to 1.3.3 (#11499)
dependabot[bot] Jul 15, 2024
9dd3c54
Bump com.kohlschutter.junixsocket:junixsocket-core from 2.9.1 to 2.10…
dependabot[bot] Jul 15, 2024
24fdfc2
Bump gittools/actions from 1.1.1 to 1.2.0 (#11500)
dependabot[bot] Jul 15, 2024
ee46fe7
Bump src/main/resources/csl-styles from `b2be5ae` to `fd6cb3e` (#11501)
dependabot[bot] Jul 15, 2024
003587c
CSL4LibreOffice - A [GSoC '24] (#11477)
subhramit Jul 15, 2024
58a3bfe
Add missing issue numbers
koppor Jul 15, 2024
f859dee
Merge pull request #11503 from JabRef/koppor-patch-1
Siedlerchr Jul 15, 2024
0fef230
New Crowdin updates (#11504)
Siedlerchr Jul 16, 2024
a5e1bd6
Fix handling of relative-file storage and auto linking (#11492)
koppor Jul 16, 2024
7de6d59
Add minimal support for biblatex data annotations (#11506)
odneill Jul 16, 2024
410db8a
Save unlinked local files dialog prefs (#11493)
kataramarina Jul 16, 2024
4a8404c
Switch to stream-based loading (#11479)
koppor Jul 17, 2024
ea00fe6
Fix NPE when saving preferences (#11509)
LoayGhreeb Jul 17, 2024
03370e0
Always enable 'Check for Updates' menu button (#11485)
LoayGhreeb Jul 17, 2024
714abd1
New Crowdin updates (#11514)
Siedlerchr Jul 18, 2024
234ee2e
import PMID field in Pubmed (#11513)
Siedlerchr Jul 18, 2024
eb16c33
Add OpenAI privacy policy (#11511)
InAnYan Jul 18, 2024
120cbb0
New translations jabref_en.properties (Portuguese, Brazilian) (#11516)
Siedlerchr Jul 19, 2024
7b39010
Fix NPE when saving preferences (#11515)
LoayGhreeb Jul 19, 2024
a64bb07
Try to use "release" (made in fork) (#11517)
koppor Jul 19, 2024
e905d2f
Review changes - I
subhramit Jul 19, 2024
2e770fe
Clean unused imports
subhramit Jul 19, 2024
c7acad8
Adapt StyleSelectDialogViewModel
subhramit Jul 19, 2024
85873c2
Merge remote-tracking branch 'upstream/main' into oo-architecture
Siedlerchr Jul 19, 2024
9edcb6c
fix prefs
Siedlerchr Jul 19, 2024
a2fdf06
Fix style checks
subhramit Jul 19, 2024
b99fdb6
fix compile errors
Siedlerchr Jul 19, 2024
b9fe5bd
store prefs
Siedlerchr Jul 19, 2024
de5b9e0
fix selection of style in preferenmes
Siedlerchr Jul 19, 2024
b8fc50a
add todo
Siedlerchr Jul 19, 2024
a46b0e0
Update to javafx 22.02 (#11518)
Siedlerchr Jul 19, 2024
25dedec
Always show star for local unsaved library (#11519)
Siedlerchr Jul 20, 2024
c8a2f44
Debug phase 1
subhramit Jul 20, 2024
655e21c
Bug fixes 2 - defaulting jstyles
subhramit Jul 20, 2024
7eeaba5
Clean preference implementation, add comments
subhramit Jul 20, 2024
ad733c8
Bug fix -3, more cleanup
subhramit Jul 21, 2024
20438cf
Bug fix -4 (Failing viewloader)
subhramit Jul 21, 2024
cfa5f53
Refactoring, Documentation
subhramit Jul 21, 2024
0a5a762
Add currently set style label
subhramit Jul 21, 2024
eec4cbf
Remove unused setStyleProperty function
subhramit Jul 21, 2024
844588c
Separate blocks for JStyle and CSL
subhramit Jul 21, 2024
ec7364b
Merge branch 'main' of https://github.com/JabRef/jabref into oo-archi…
subhramit Jul 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deployment-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ jobs:
submodules: 'true'
show-progress: 'false'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
uses: gittools/actions/gitversion/setup@v1.2.0
with:
versionSpec: "5.x"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1.1.1
uses: gittools/actions/gitversion/execute@v1.2.0
- name: Setup JDK
uses: actions/setup-java@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployment-jdk-ea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ jobs:
packages: pigz
version: 1.0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
uses: gittools/actions/gitversion/setup@v1.2.0
with:
versionSpec: "5.x"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1.1.1
uses: gittools/actions/gitversion/execute@v1.2.0

# JDK
- name: 'Set up JDK ${{ matrix.jdk }}'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ jobs:
packages: pigz
version: 1.0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
uses: gittools/actions/gitversion/setup@v1.2.0
with:
versionSpec: "5.x"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1.1.1
uses: gittools/actions/gitversion/execute@v1.2.0
- name: Setup JDK
uses: actions/setup-java@v4
with:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
### Added

- We added support for selecting and using CSL Styles in JabRef's OpenOffice/LibreOffice integration for inserting bibliographic and in-text citations into a document.
- We added support for selecting and using CSL Styles in JabRef's OpenOffice/LibreOffice integration for inserting bibliographic and in-text citations into a document. [#2146](https://github.com/JabRef/jabref/issues/2146), [#8893](https://github.com/JabRef/jabref/issues/8893)
- Added minimal support for [biblatex data annotation](https://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf#subsection.3.7) fields in .layout files. [#11505](https://github.com/JabRef/jabref/issues/11505)
- Added saving of selected options in the [Lookup -> Search for unlinked local files dialog](https://docs.jabref.org/collect/findunlinkedfiles#link-the-pdfs-to-your-bib-library). [#11439](https://github.com/JabRef/jabref/issues/11439)

### Changed

- JabRef respects the [configuration for storing files relative to the .bib file](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files) in more cases. [#11492](https://github.com/JabRef/jabref/pull/11492)

### Fixed

- We fixed an issue where an exception was thrown after changing "show preview as a tab" in the preferences. [#11509](https://github.com/JabRef/jabref/pull/11509)

### Removed


Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.11.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0'
implementation 'commons-logging:commons-logging:1.3.2'
implementation 'commons-logging:commons-logging:1.3.3'
implementation 'com.h2database:h2-mvstore:2.2.224'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
Expand Down Expand Up @@ -198,8 +198,8 @@ dependencies {
implementation 'org.postgresql:postgresql:42.7.3'

// Support unix socket connection types
implementation 'com.kohlschutter.junixsocket:junixsocket-core:2.9.1'
implementation 'com.kohlschutter.junixsocket:junixsocket-mysql:2.9.1'
implementation 'com.kohlschutter.junixsocket:junixsocket-core:2.10.0'
implementation 'com.kohlschutter.junixsocket:junixsocket-mysql:2.10.0'

implementation ('com.oracle.ojdbc:ojdbc10:19.3.0.0') {
// causing module issues
Expand Down Expand Up @@ -240,7 +240,7 @@ dependencies {

implementation 'org.controlsfx:controlsfx:11.2.1'

implementation 'org.jsoup:jsoup:1.17.2'
implementation 'org.jsoup:jsoup:1.18.1'
implementation 'com.konghq:unirest-java-core:4.4.0'
implementation 'com.konghq:unirest-modules-gson:4.4.0'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
Expand Down Expand Up @@ -328,7 +328,7 @@ dependencies {
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2'
xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2'

rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.14.0"))
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.15.0"))
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
rewrite("org.openrewrite.recipe:rewrite-logging-frameworks")
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks")
Expand Down
32 changes: 27 additions & 5 deletions docs/code-howtos/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,36 @@ parent: Code Howtos

Following is a list of common errors encountered by developers which lead to failing tests, with their common solutions:

* `org.jabref.architecture.MainArchitectureTest` `restrictStandardStreams` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span> : Check if you've used ```System.out.println(...)``` (the standard output stream) to log anything into the console. This is an architectural violation, as you should use the Logger instead for logging. More details on how to log can be found [here](https://devdocs.jabref.org/code-howtos/logging.html).
* Failing <b>Checkstyle</b> tests:
* <span style="color:green">Fix</span>: JabRef follows a pre-defined style of code for uniformity and maintainability that must be adhered to during development. To set up warnings and auto-fixes conforming to these style rules in your IDE, follow [Step 3](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html) of the process to set up a local workspace in the documentation. Ideally, follow all the [set up rules](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/) in the documentation end-to-end to avoid typical set-up errors.<br> <b>Note</b>: The steps provided in the documentation are for IntelliJ, which is the preferred IDE for Java development. The `checkstyle.xml` is also available for VSCode, in the same directory as mentioned in the steps.

* `org.jabref.architecture.MainArchitectureTest` `doNotUseLogicInModel` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span> : One common case when this test fails is when you put any class purely containing business logic at some level inside the ```model``` directory (```org/jabref/model/```). To fix this, shift the class to a subdirectory within the ```logic``` directory (```org/jabref/logic/```).
* Failing <b>OpenRewrite</b> tests:
* <span style="color:green">Fix</span>: [OpenRewrite](https://docs.openrewrite.org/) is an automated refactoring ecosystem for source code. Execute the Gradle task `rewriteRun` from the `rewrite` group of the Gradle Tool window in IntelliJ to apply the automated refactoring and pass the test.<br>
![Executing Gradle task rewriteRun](../images/rewriteRun.png)<br>

* `org.jabref.logic.l10n.LocalizationConsistencyTest` `findMissingLocalizationKeys` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span> : You have probably used Strings that are visible on the UI (to the user) but not wrapped them using ```Localization.lang(...)``` and added them to the [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties).
* <span style="color:green">Fix</span>: You have probably used Strings that are visible on the UI (to the user) but not wrapped them using `Localization.lang(...)` and added them to the [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties).
Read more about the background and format of localization in JabRef [here](https://devdocs.jabref.org/code-howtos/localization.html).

* `org.jabref.logic.l10n.LocalizationConsistencyTest` `findObsoleteLocalizationKeys` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span>: There are localization keys [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties) that are not used in the code, probably due to the removal of existing code. Navigate to the unused key-value pairs in the file and remove them. You can always click on the details of the failing test to pinpoint which keys are unused.
Read more about the background and format of localization in JabRef [here](https://devdocs.jabref.org/code-howtos/localization.html).

* `org.jabref.logic.citationstyle.CitationStyle` `discoverCitationStyles` <span style="color:red">ERROR: Could not find any citation style. Tried with /ieee.csl.</span>
* <span style="color:green">Fix</span>: Check the directory `src/main/resources/csl-styles`. If it is missing or empty, run `git submodule update`. Now, check inside if `ieee.csl` exists. If it does not, run `git reset --hard` <b>inside that directory</b>.

* `java.lang.IllegalArgumentException`: Unable to load locale en-US<br> <span style="color:red">ERROR: Could not generate BibEntry citation. The CSL engine could not create a preview for your item.</span>
* <span style="color:green">Fix</span>: Check the directory `src/main/resources/csl-locales`. If it is missing or empty, run `git submodule update`. If still not fixed, run `git reset --hard` <b>inside that directory</b>.

* `org.jabref.architecture.MainArchitectureTest` `restrictStandardStreams` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span>: Check if you've used `System.out.println(...)` (the standard output stream) to log anything into the console. This is an architectural violation, as you should use the Logger instead for logging. More details on how to log can be found [here](https://devdocs.jabref.org/code-howtos/logging.html).

* `org.jabref.architecture.MainArchitectureTest` `doNotUseLogicInModel` <span style="color:red">FAILED</span>
* <span style="color:green">Fix</span>: One common case when this test fails is when you put any class purely containing business logic inside the `model` package (i.e., inside the directory `org/jabref/model/`). To fix this, shift the class to a sub-package within the `logic` package (i.e., the directory`org/jabref/logic/`). An efficient way to do this is to use IntelliJ's built-in refactoring capabilities - right-click on the file, go to "Refactor" and use "Move Class". The import statement for all the classes using this class will be automatically adjusted according to the new location.<br>
![Moving a file using refactor](../images/refactor-moving.png)<br>

* `ANTLR Tool version 4.12.0 used for code generation does not match the current runtime version 4.13.1`
* <span style="color:green">Fix</span>: Execute the Gradle task `clean` from the `build` group of the Gradle Tool Window in IntelliJ:<br>
![Executing Gradle task clean](../images/clean.png)<br>

<!-- markdownlint-disable-file MD033 -->
Binary file added docs/images/clean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/refactor-moving.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rewriteRun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=a4b4158601f8636cdeeab09bd76afb640030bb5b144aafe261a5e8af027dc612
distributionUrl=https\:https://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\:https://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.jabref.architecture;

/**
* Annotation to indicate that this logic class can use class.getResource().
* Mostly, because {@link java.nio.file.Path} is not used.
* See <a href="graal#7682">https://github.com/oracle/graal/issues/7682</a> for a longer discussion.
*/
public @interface AllowedToUseClassGetResource {
// The rationale
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Annotation to indicate that this logic class can access swing
*/
public @interface AllowedToUseSwing {

// The rationale
String value();
}
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public EntryEditor(LibraryTab libraryTab, UndoAction undoAction, RedoAction redo
activeTab.notifyAboutFocus(currentlyEditedEntry);
}
});
EasyBind.listen(preferencesService.getPreviewPreferences().showPreviewAsExtraTabProperty(),
(obs, oldValue, newValue) -> adaptVisibleTabs());
}

private void setupDragAndDrop(LibraryTab libraryTab) {
Expand Down Expand Up @@ -386,6 +384,9 @@ public void setCurrentlyEditedEntry(BibEntry currentlyEditedEntry) {
getSelectedTab().notifyAboutFocus(currentlyEditedEntry);
});

EasyBind.listen(preferencesService.getPreviewPreferences().showPreviewAsExtraTabProperty(),
(obs, oldValue, newValue) -> adaptVisibleTabs());

adaptVisibleTabs();
setupToolBar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
Expand Down Expand Up @@ -52,6 +51,7 @@ public List<IOException> getFileExceptions() {
}

private static final Logger LOGGER = LoggerFactory.getLogger(AutoSetFileLinksUtil.class);

private final List<Path> directories;
private final AutoLinkPreferences autoLinkPreferences;
private final FilePreferences filePreferences;
Expand Down Expand Up @@ -106,7 +106,9 @@ public LinkFilesResult linkAssociatedFiles(List<BibEntry> entries, NamedCompound
public List<LinkedFile> findAssociatedNotLinkedFiles(BibEntry entry) throws IOException {
List<LinkedFile> linkedFiles = new ArrayList<>();

List<String> extensions = filePreferences.getExternalFileTypes().stream().map(ExternalFileType::getExtension).collect(Collectors.toList());
List<String> extensions = filePreferences.getExternalFileTypes().stream().map(ExternalFileType::getExtension).toList();

LOGGER.debug("Searching for extensions {} in directories {}", extensions, directories);

// Run the search operation
FileFinder fileFinder = FileFinders.constructFromConfiguration(autoLinkPreferences);
Expand Down Expand Up @@ -134,6 +136,7 @@ public List<LinkedFile> findAssociatedNotLinkedFiles(BibEntry entry) throws IOEx
Path relativeFilePath = FileUtil.relativize(foundFile, directories);
LinkedFile linkedFile = new LinkedFile("", relativeFilePath, strType);
linkedFiles.add(linkedFile);
LOGGER.debug("Found file {} for entry {}", linkedFile, entry.getCitationKey());
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/main/java/org/jabref/gui/externalfiles/DateRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ public enum DateRange {

private final String dateRange;

DateRange(String dateRange) {
DateRange(String dateRange) {
this.dateRange = dateRange;
}

public static DateRange parse(String name) {
try {
return DateRange.valueOf(name);
} catch (IllegalArgumentException e) {
return ALL_TIME;
}
}

public String getDateRange() {
return dateRange;
}
return dateRange;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ public enum ExternalFileSorter {
this.sorter = sorter;
}

public static ExternalFileSorter parse(String name) {
try {
return ExternalFileSorter.valueOf(name);
} catch (IllegalArgumentException e) {
return DEFAULT;
}
}

public String getSorter() {
return sorter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@

public class FileExtensionViewModel {

private final String name;
private final String description;
private final List<String> extensions;
private final FilePreferences filePreferences;

FileExtensionViewModel(FileType fileType, FilePreferences filePreferences) {
this.name = fileType.getName();
this.description = Localization.lang("%0 file", fileType.getName());
this.extensions = fileType.getExtensionsWithAsteriskAndDot();
this.filePreferences = filePreferences;
}

public String getName() {
return this.name;
}

public String getDescription() {
return this.description + extensions.stream().collect(Collectors.joining(", ", " (", ")"));
}
Expand Down
Loading
Loading