- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3k
Right click create group #11476
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
Right click create group #11476
Changes from all commits
910c857
              cbc0d7d
              f126974
              e4c2281
              9b4d2db
              9631067
              d4222a7
              faca154
              ca5e69f
              3a6037e
              8dd474a
              12dedd4
              2c87cda
              f3011ed
              53f1544
              ec9b081
              aabb4a3
              f654aba
              d772aaa
              d3e1f1e
              e4ec775
              fd088d1
              e2ad784
              cf33b73
              85d42b9
              ea49e46
              00de24b
              a1dfe75
              77f927b
              f80e515
              c5241f0
              bba0522
              1912281
              4931eac
              f928a36
              93f2df5
              0367f7b
              e87af8e
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -2,12 +2,12 @@ | |
|  | ||
| import java.io.IOException; | ||
| import java.nio.file.Path; | ||
| import java.util.Collections; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
| import java.util.function.Supplier; | ||
| import java.util.stream.Collectors; | ||
|  | ||
| import javafx.collections.FXCollections; | ||
| import javafx.stage.FileChooser; | ||
| import javafx.util.Duration; | ||
|  | ||
|  | @@ -111,7 +111,7 @@ private void export(Path file, FileChooser.ExtensionFilter selectedExtensionFilt | |
| // All entries | ||
| entries = stateManager.getActiveDatabase() | ||
| .map(BibDatabaseContext::getEntries) | ||
| .orElse(Collections.emptyList()); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change needed? I checked the caller - and it seems it is passed to  I would even try to use  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe I just did this because the function signature changed (from  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will just revert and see if the CI is green. Reason: BibDatbase context code:     public List<BibEntry> getEntries() {
        return database.getEntries();
    }There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did my revert go through, because I did not see it? Please double check that this file is not changed! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per my earlier comment - 
 | ||
| .orElse(FXCollections.emptyObservableList()); | ||
| } | ||
|  | ||
| List<Path> fileDirForDatabase = stateManager.getActiveDatabase() | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -25,6 +25,7 @@ | |
|  | ||
| import org.jabref.gui.DialogService; | ||
| import org.jabref.gui.icon.IconTheme; | ||
| import org.jabref.gui.maintable.Selection; | ||
| import org.jabref.gui.util.FileDialogConfiguration; | ||
| import org.jabref.logic.auxparser.DefaultAuxParser; | ||
| import org.jabref.logic.groups.DefaultGroupsFactory; | ||
|  | @@ -33,6 +34,7 @@ | |
| import org.jabref.logic.util.io.FileUtil; | ||
| import org.jabref.model.database.BibDatabase; | ||
| import org.jabref.model.database.BibDatabaseContext; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.Keyword; | ||
| import org.jabref.model.entry.field.FieldFactory; | ||
| import org.jabref.model.groups.AbstractGroup; | ||
|  | @@ -77,6 +79,10 @@ public class GroupDialogViewModel { | |
| private final BooleanProperty typeAutoProperty = new SimpleBooleanProperty(); | ||
| private final BooleanProperty typeTexProperty = new SimpleBooleanProperty(); | ||
|  | ||
| // Explicit Groups | ||
| private final BooleanProperty explicitIncludeSelectedProperty = new SimpleBooleanProperty(false); | ||
| private final BooleanProperty editingGroupProperty = new SimpleBooleanProperty(false); | ||
|  | ||
| // Option Groups | ||
| private final StringProperty keywordGroupSearchTermProperty = new SimpleStringProperty(""); | ||
| private final StringProperty keywordGroupSearchFieldProperty = new SimpleStringProperty(""); | ||
|  | @@ -112,24 +118,42 @@ public class GroupDialogViewModel { | |
| private final AbstractGroup editedGroup; | ||
| private final GroupTreeNode parentNode; | ||
| private final FileUpdateMonitor fileUpdateMonitor; | ||
| private final List<BibEntry> selectedEntries; | ||
| private final Selection includeSelectedEntries; | ||
|  | ||
| public GroupDialogViewModel(DialogService dialogService, | ||
| BibDatabaseContext currentDatabase, | ||
| PreferencesService preferencesService, | ||
| @Nullable AbstractGroup editedGroup, | ||
| @Nullable GroupTreeNode parentNode, | ||
| FileUpdateMonitor fileUpdateMonitor) { | ||
| FileUpdateMonitor fileUpdateMonitor, | ||
| List<BibEntry> selectedEntries, | ||
| Selection includeSelectedEntries | ||
| ) { | ||
| this.dialogService = dialogService; | ||
| this.preferencesService = preferencesService; | ||
| this.currentDatabase = currentDatabase; | ||
| this.editedGroup = editedGroup; | ||
| this.parentNode = parentNode; | ||
| this.fileUpdateMonitor = fileUpdateMonitor; | ||
| this.selectedEntries = selectedEntries; | ||
| this.includeSelectedEntries = includeSelectedEntries; | ||
|  | ||
| setupValidation(); | ||
| setValues(); | ||
| } | ||
|  | ||
| public GroupDialogViewModel( | ||
| DialogService dialogService, | ||
| BibDatabaseContext currentDatabase, | ||
| PreferencesService preferencesService, | ||
| @Nullable AbstractGroup editedGroup, | ||
| @Nullable GroupTreeNode parentNode, | ||
| FileUpdateMonitor fileUpdateMonitor | ||
| ) { | ||
| this(dialogService, currentDatabase, preferencesService, editedGroup, parentNode, fileUpdateMonitor, new ArrayList<>(), Selection.IGNORE_SELECTED_ENTRIES); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. USe  | ||
| } | ||
|  | ||
| private void setupValidation() { | ||
| validator = new CompositeValidator(); | ||
|  | ||
|  | @@ -246,7 +270,7 @@ private void setupValidation() { | |
| return false; | ||
| } | ||
| return FileUtil.getFileExtension(input) | ||
| .map(extension -> "aux".equalsIgnoreCase(extension)) | ||
| .map("aux"::equalsIgnoreCase) | ||
| .orElse(false); | ||
| } | ||
| }, | ||
|  | @@ -311,9 +335,13 @@ public AbstractGroup resultConverter(ButtonType button) { | |
| String groupName = nameProperty.getValue().trim(); | ||
| if (typeExplicitProperty.getValue()) { | ||
| resultingGroup = new ExplicitGroup( | ||
| groupName, | ||
| groupHierarchySelectedProperty.getValue(), | ||
| preferencesService.getBibEntryPreferences().getKeywordSeparator()); | ||
| groupName, | ||
| groupHierarchySelectedProperty.getValue(), | ||
| preferencesService.getBibEntryPreferences().getKeywordSeparator() | ||
| ); | ||
| if (explicitIncludeSelectedProperty.getValue()) { | ||
| ((ExplicitGroup) resultingGroup).add(selectedEntries); | ||
| } | ||
| } else if (typeKeywordsProperty.getValue()) { | ||
| if (keywordGroupRegexProperty.getValue()) { | ||
| resultingGroup = new RegexKeywordGroup( | ||
|  | @@ -372,7 +400,6 @@ public AbstractGroup resultConverter(ButtonType button) { | |
| fileUpdateMonitor, | ||
| currentDatabase.getMetaData()); | ||
| } | ||
|  | ||
| if (resultingGroup != null) { | ||
| preferencesService.getGroupsPreferences().setDefaultHierarchicalContext(groupHierarchySelectedProperty.getValue()); | ||
|  | ||
|  | @@ -391,7 +418,7 @@ public AbstractGroup resultConverter(ButtonType button) { | |
|  | ||
| public void setValues() { | ||
| groupHierarchyListProperty.setValue(FXCollections.observableArrayList(GroupHierarchyType.values())); | ||
|  | ||
| explicitIncludeSelectedProperty.setValue(includeSelectedEntries == Selection.INCLUDE_SELECTED_ENTRIES || preferencesService.getGroupsPreferences().shouldAutoIncludeSelected()); | ||
| if (editedGroup == null) { | ||
| // creating new group -> defaults! | ||
| // TODO: Create default group (via org.jabref.logic.groups.DefaultGroupsFactory) and use values | ||
|  | @@ -415,6 +442,7 @@ public void setValues() { | |
| descriptionProperty.setValue(editedGroup.getDescription().orElse("")); | ||
| iconProperty.setValue(editedGroup.getIconName().orElse("")); | ||
| groupHierarchySelectedProperty.setValue(editedGroup.getHierarchicalContext()); | ||
| editingGroupProperty.setValue(true); | ||
|  | ||
| if (editedGroup.getClass() == WordKeywordGroup.class) { | ||
| typeKeywordsProperty.setValue(true); | ||
|  | @@ -454,11 +482,6 @@ public void setValues() { | |
| autoGroupPersonsOptionProperty.setValue(Boolean.TRUE); | ||
| autoGroupPersonsFieldProperty.setValue(group.getField().getName()); | ||
| } | ||
| } else if (editedGroup.getClass() == TexGroup.class) { | ||
| typeTexProperty.setValue(true); | ||
|  | ||
| TexGroup group = (TexGroup) editedGroup; | ||
| texGroupFilePathProperty.setValue(group.getFilePath().toString()); | ||
| } | ||
| } | ||
| } | ||
|  | @@ -492,7 +515,7 @@ public void texGroupBrowse() { | |
| } | ||
|  | ||
| private List<Path> getFileDirectoriesAsPaths() { | ||
| List<Path> fileDirs = new ArrayList<>(); | ||
| List<Path> fileDirs = List.of(); | ||
| MetaData metaData = currentDatabase.getMetaData(); | ||
| metaData.getLatexFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).ifPresent(fileDirs::add); | ||
|  | ||
|  | @@ -535,7 +558,7 @@ public ValidationStatus keywordSearchTermEmptyValidationStatus() { | |
| return keywordSearchTermEmptyValidator.getValidationStatus(); | ||
| } | ||
|  | ||
| public ValidationStatus texGroupFilePathValidatonStatus() { | ||
| public ValidationStatus texGroupFilePathValidationStatus() { | ||
| return texGroupFilePathValidator.getValidationStatus(); | ||
| } | ||
|  | ||
|  | @@ -587,6 +610,14 @@ public BooleanProperty typeTexProperty() { | |
| return typeTexProperty; | ||
| } | ||
|  | ||
| public BooleanProperty explicitIncludeSelectedProperty() { | ||
| return explicitIncludeSelectedProperty; | ||
| } | ||
|  | ||
| public BooleanProperty editingGroupProperty() { | ||
| return editingGroupProperty; | ||
| } | ||
|  | ||
| public StringProperty keywordGroupSearchTermProperty() { | ||
| return keywordGroupSearchTermProperty; | ||
| } | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.