-
-
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
javafx replacement for file dialog #3005
Conversation
* upstream/master: (30 commits) Add preference migration for keybdingings (#3007) Shutdown previus AutosaveManager and BackupManager during SaveAs (#2994) Run Checkstyle task after Test task (#3010) Mark LibraryOfCongressTest as a fetcher test (#3012) When browsing through the MainTable remember which EntryEditor tab was open (#3011) Improve performance of journal abbreviation loader (#3009) Update checkstyle 7.6.1 -> 8.0 Don't abort build when there are checkstyle violations (#3006) Reimplement content selectors (#3003) Only do a back up for bigger changes or if a different field is edited (#3004) Listen to change events for setting dirty status of database (#3001) Fix #2967: MathSciNet tab works again Fix #2902: Tab in entry editor moves to next text area Fix #2946: external changes are now correctly shown in the entry editor Fix #2998: improve auto completion (#3002) Fix mac keybinding by replacing ctrl it with meta key (#3000) Less backups (#2995) [WIP] Complete rework of the auto completion (#2965) Eclipse J Add switch indentation for Eclipse and add some new missing formatting options ...
* upstream/master: (41 commits) update xmlunit from 2.3.0 -> 2.4.0 update wiremock from 2.6.0 -> 2.7.0 update controlsfx from 8.40.12 -> 8.40.13 Fix group freeze by running markBasechange in swing thread (#3058) Localization: French: translation of new entries (#3050) Fix ads fetcher (#3048) Update translation (#3041) Translate new strings (#3040) Fix navigation in entry editor increases modifies font size (#3037) Initial idea for architectural decision records (#3033) Readd comment Readd comment Fix keybdining in entry editor in localized installation (#3030) Structuring Upgrade shadowJar Modernizer improvements Replace Reimplement MappedList.kt (#3032) Use https for the maven ej-technologies repo Upgrade modernizer plugin Remove separator next to search bar ...
* upstream/master: Add warning message if group with same name is already present (#3077) Fix #3062: Ctrl + F works again Fix del/copy/paste key trigger main table action in search bar (#3070) Fix markdown Update gradle from 4.0.1 to 4.0.2 Fix #3045 Update Transformer plugin Reimplement MappedList using a backigList (#3069) Fix importing preferences after resetting without restarting (#3065) Fix some spotbugs issues (#3060) Import dialog when fetch (#3025) Adapt CircleCI build Adapt CI script Closes #3027 and updates install4j to v7
open dialog with attach file action
* upstream/master: (188 commits) Show file description only if not empty Add file description to gui and fix sync bug (#3210) Don't highlight odd rows in file list editor (#3223) Fix assertion by removing typo (#3220) Update assertion to change of online reference (#3221) Put in null return Reformatted code, renamed method, added try/catch Add tests for removal changes Improve telemetry (#3218) Real test linking real other entry (#3214) Check for explicit group at different location Update java-string-similarity from 0.24 -> 1.0.0 Only remove ExplicitGroups from entries, but not keyword-based groups Localization: French: Translation of a new string (#3212) Fix null return Changed from Path to Optional<Path> Fix #2775: Hyphens in last names are properly parsed (#3209) Followup to Issue #3167 (#3202) Remove unused import in GroupTreeNode Move getEntriesInGroup to GroupTreeNode ...
if (REMOTE_LINK_PATTERN.matcher(tfLink.getText()).matches()) { | ||
Optional<ExternalFileType> type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("html"); | ||
if (type.isPresent()) { | ||
cmbFileType.getSelectionModel().select(type.get()); |
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.
@tobiasdiez
I would like to move this method and some others to the view Model, but I don't know how/or if I should expose the selection model of the combobox to the view model.
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.
You have a few options here:
-
Create a property in the view model and bind the selected item property to it, similar to the following code:
jabref/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogController.java
Lines 37 to 41 in cbd6844
viewModel.selectedKeyBindingProperty().bind( EasyBind.monadic(keyBindingsTable.selectionModelProperty()) .flatMap(SelectionModel::selectedItemProperty) .selectProperty(TreeItem::valueProperty) );
But I'm not sure if using a bidirectional binding works here out of the box, probably you need to usepublic static <A, B> void bindBidirectional(Property<A> propertyA, Property<B> propertyB, Function<A, B> mapAtoB, Function<B, A> mapBtoA) { -
Just return the to-be-selected item from the method in the view model and then really select it here in the controller.
Option 1 is definitely the cleaner solution but maybe a bit harder to setup (but definitely worth the initial effort since a similar problem might appear in the future).
|
||
private void setBindings() { | ||
|
||
cmbFileType.itemsProperty().bindBidirectional(viewModel.externalFileTypeProperty()); |
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.
@tobiasdiez Here the binding is created, a simple list property for the combobox
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 looks good! (a one-directional binding should suffice I think since it looks like the itemsProperty
is never changed directly.)
* upstream/master: (79 commits) Update richtext and flowless (#3386) Source tab: hide notification pane when code is correct again (#3387) Titles are optional at crossref (#3378) Update entry for every change in the source panel (#3366) Rework AutoSetFileLinks (#3368) revert wrongly commited changes Refactorings (#3370) Fix freezing when running cleanup file operations like rename (#3315) This additional style setting for IDEA (#3355) Fix checkstyle Add proper equals to content selector Source tab entry duplication (#3360) Use CITE_COMMENT not only for external latex editors but also for cop… (#3351) Updating with new translations (#3348) Upgrade error-prone (#3350) Jabref_pt_BR partially updated (#3349) Delete unused code Extract difference finder from gui to logic Used late initialization for context menus (#3340) Fix NPE when calling with bib file as cmd argument (#3343) ...
* upstream/master: Improve SyncLang.py (#3184) Config intellj code style to adhere to empty lines checkstyle rule (#3365) Don't list same look and feels more than once (#3393) progessdialog and result table are now shown correclty on copy files Export pdf/linked files (#3147) Added checking integrity dialog (#3388)
* upstream/master: (30 commits) Add Hint for checking master version (#3439) Replace LinkedFiles backslashes with forward slashes (#3403) fix isbn result from chimbori (#3442) Feature java version check again (#3428) Fix test for quoted lang messages (#3424) Update gradle from 4.3 to 4.3.1 Fix #3411: ordering of fields in customized entry types works again (#3422) Backport of syncLang to python2 (#3420) Remove Versioneye badge Fix some error prone warnings Fix for issue #2721 append to a field (#3395) Fix travis - hopefully Remove 3.x changelog (#3250) Try to use hint of https://github.com/TheBoegl/shadow-log4j-transformer#usage-as-library Try to enable LGTM Update guava from 23.2 -> 23.3 (#3409) Update wiremock from 2.8.0 -> 2.10.1 Move groups field from others to general (#3407) Fix checkstyle issues to repair build Fix #3046: No longer allow duplicate fields in customized entry types (#3405) ...
Discussion @Siedlerchr with @tobiasdiez required. |
* upstream/master: (234 commits) Fix checkstyle Fix tests 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) ...
panel.getBibDatabaseContext()); | ||
editor.setVisible(true, true); | ||
|
||
if (editor.okPressed()) { |
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.
@tobiasdiez How do I handle such cases in javafx? The check for a return value? Should I do a showAndWait?
My initial idea would be to pass the UndoManager to the javafx view model (state manager? or other injection)
There are some other clases in which a similar stuff is executed which seems to a bit more complicated, e.g. the
DownloadExternalFile class
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.
Good question. I think the return value should be accessed per getters of the FileListDialogView
(this seems to be the most flexible and easiest solution - you don't need to create "Dialog return value classes" for more complex scenarios). These getters in the view should ask the view model of the dialog about the values. You can get the controller with
private Optional<AbstractController> getController() { |
(just change the visibility) and then the view model with
public T getViewModel() { |
For parameter injection, have a look at CopyFilesDialogView
.
…esDlg * upstream/maintable-beta: (35 commits) Load all field editors using ViewLoader Use JabRef icons in FXML Move icon stuff to new package gui.icon Load EntryEditor using new ViewLoader Improve tooltip tests Fix import thread problem Don't use null as parameter in DialogService Make it easier to create FXML dialogs (#3880) update slf4j from 1.8.0-beta1 -> 1.8.0-beta2 New translations JabRef_en.properties (Tagalog) New translations JabRef_en.properties (Italian) New translations Menu_en.properties (Italian) New translations JabRef_en.properties (Indonesian) New translations JabRef_en.properties (Greek) New translations Menu_en.properties (Greek) New translations JabRef_en.properties (Japanese) New translations JabRef_en.properties (German) New translations JabRef_en.properties (Dutch) New translations JabRef_en.properties (Danish) New translations JabRef_en.properties (Chinese Simplified) ... # Conflicts: # CHANGELOG.md # src/main/java/org/jabref/gui/AbstractView.java # src/main/java/org/jabref/gui/desktop/JabRefDesktop.java # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java # src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java # src/main/java/org/jabref/gui/protectedterms/ProtectedTermsDialog.java
still some NPEs
@tobiasdiez I tried to convert the EditfileDialog to the new dialog structure from #3880 but I do still get an NPE on loading the dialog:
|
And what is null there? If line 54 runs without any problems, then the setup seems to be fine and the FXML nodes are injected. Maybe the |
@tobiasdiez No, it fails directly in the initalize, The viewModel which gets initialized in the ctor is null. |
ok, this makes sense since the |
Works now. I just additionally had to add a close/cancel button to the dialogPane, for the copyFiles because otherwise the dialog is not closeable: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Dialog.html |
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 the hard work over so many years 🍡
The code looks in general very good. I have a few smaller remarks. And let me add one general comment: These code reformattings make it very very hard to review the PR. For example, some files appearntly only contain formatting changes, without any actual changes to the code. This is confusing. Does eclipse provide an option to reformat only code that is actually changed instead reformatting everything once you open the file (I guess this is what happenend).
CHANGELOG.md
Outdated
@@ -41,8 +41,10 @@ The new default removes the linked file from the entry instead of deleting the f | |||
- Pressing <kbd>ESC</kbd> while searching will clear the search field and select the first entry, if available, in the table. [koppor#293](https://github.com/koppor/jabref/issues/293) | |||
- We changed the metadata reading and writing. DublinCore is now the only metadata format, JabRef supports. (https://github.com/JabRef/jabref/pull/3710) | |||
- We added another CLI functionality for reading and writing metadata to pdfs. (see https://github.com/JabRef/jabref/pull/3756 and see http://help.jabref.org/en/CommandLine) | |||
- We improved the layout of the Edit file layout and made it resizable. We also tweaked the workflow for attaching files from the contextmenu, see https://github.com/JabRef/jabref/pull/3005 |
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.
None of the changes in maintable-beta is currently in the changelog. Thus, for consistency, I would say remove it for the moment and add it to the list in #3621.
Localization.lang("Cancel"), | ||
Localization.lang("Disable this confirmation dialog"), | ||
optOut -> Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, !optOut)); | ||
boolean overwriteKeysPressed = dialogService.showConfirmationDialogWithOptOutAndWait( |
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.
Are the changes in this file once again one of the strange eclipse formatting rules?
@@ -28,11 +29,14 @@ public CopyFilesDialogView(BibDatabaseContext bibDatabaseContext, CopyFilesResul | |||
this.setTitle(Localization.lang("Result")); | |||
this.setResizable(true); | |||
|
|||
this.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE); |
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.
The original button was labeled OK
and I think this makes more sense than Close
. Moreover, the close
method in this class can now be removed, right?
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.
The problem was that with an only OK button I was not able to close the dialog neither via the X in the corner nor via the OK button. It needs to have at least a button with Type CANCEL_CLOSE
Read the last paragraph: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Dialog.html
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.
The Problem was that the OK button was not at the Dialog Pane, but inside the content and therefore did not work
import org.jabref.model.entry.LinkedFile; | ||
|
||
/** | ||
* Workaround to inject {@link LinkedFile} into javafx controller |
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 should no longer be necessary.
|
||
LinkedFilesWrapper wrapper = new LinkedFilesWrapper(); | ||
wrapper.setLinkedFile(newLinkedFile); | ||
LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(wrapper); |
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.
Do we really want to show the linked file editor dialog here? In my experience, I just click "OK" anyway and would expect that this is the case for most users (recall how long it took until somebody complained that the description was not shown in the file list). At least, I would add a preferences that controls the appearance of the dialog.
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.
Previously there wasn't event he FileChooser shown .Instead it only showed the LinkedFilesEditor in which I then had to click open
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.
Ok, then was the previous behavior even worse. What advantage do you see in displaying the dialog every time?
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.
You can add a description and or choose a different file.
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.
If you really think that the majority of users wants to add a description, then keep the current behavior....
|
||
FileDirectoryPreferences getFileDirectoryPreferences(); | ||
|
||
String get(String key); |
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 don't add generic methods like this! The idea was that the PreferencesService
provides a typed interface for the preferences. Thus here it would be set/getWorkingDirectory
with nio.path
as argument/return value.
@@ -0,0 +1,53 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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 add this file in the java
folder and not resource
</Label> | ||
</children> | ||
</GridPane> | ||
</content> |
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.
You can also add buttontypes
here in the FXML file.
</rowConstraints> | ||
<children> | ||
<Label minWidth="95.0" text="%Link"> | ||
<padding> |
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.
padding and layout stuff should be controlled using css and not in the fxml file.
<GridPane> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0" /> | ||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="200.0" /> |
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.
maxWidth = infinity ?
.withInitialDirectory(workingDir) | ||
.withInitialFileName(fileName) | ||
.build(); | ||
.withInitialDirectory(workingDir) |
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.
@tobiasdiez this is how the indentation at column level works: As I said before it's not possible to align it at the dot position. So when I use indencation on column all things are then wrapped after Builder (Github doesn't show it that wide).
move fxml to java package remove wrapper class pass externalFileType to viewModel renammings
Add ok button to dialog pane
@@ -102,19 +102,19 @@ public void setValues(LinkedFile entry) { | |||
} | |||
} | |||
|
|||
public StringProperty linkProperty() { | |||
public StringProperty link() { | |||
return linkProperty; |
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.
Sorry, I wasn't clear enough. The private field should be called link
with public methods linkProperty()
and get/setLink
, with the latter optional.
…esDlg * upstream/maintable-beta: Reenable closing of entry preview by pressing Esc (#3883) # Conflicts: # src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java
I fixed all things open and did the renamings. So I merge this now |
…drop * upstream/maintable-beta: (48 commits) Clean unused imports Fix missing icons and wrong package for custom icons Consistent FX color scheme for JabRef (#3839) javafx replacement for file dialog (#3005) Reenable closing of entry preview by pressing Esc (#3883) Load all field editors using ViewLoader Use JabRef icons in FXML Move icon stuff to new package gui.icon Load EntryEditor using new ViewLoader Improve tooltip tests Fix import thread problem Don't use null as parameter in DialogService Make it easier to create FXML dialogs (#3880) update slf4j from 1.8.0-beta1 -> 1.8.0-beta2 New translations JabRef_en.properties (Tagalog) New translations JabRef_en.properties (Italian) New translations Menu_en.properties (Italian) New translations JabRef_en.properties (Indonesian) New translations JabRef_en.properties (Greek) New translations Menu_en.properties (Greek) ... # Conflicts: # src/main/java/org/jabref/gui/actions/CleanupAction.java # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java # src/main/java/org/jabref/gui/groups/GroupTreeController.java # src/main/java/org/jabref/gui/maintable/MainTable.java # src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java # src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java # src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java # src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java
…gsjavafx * upstream/maintable-beta: (188 commits) Fix checkstyle Exchange Ignore by Disabled (#3912) Remove all @author comments and empty method/class comments Clean unused imports Fix missing icons and wrong package for custom icons Consistent FX color scheme for JabRef (#3839) javafx replacement for file dialog (#3005) Reenable closing of entry preview by pressing Esc (#3883) Load all field editors using ViewLoader Use JabRef icons in FXML Move icon stuff to new package gui.icon Load EntryEditor using new ViewLoader Improve tooltip tests Fix import thread problem Don't use null as parameter in DialogService Make it easier to create FXML dialogs (#3880) update slf4j from 1.8.0-beta1 -> 1.8.0-beta2 New translations JabRef_en.properties (Tagalog) New translations JabRef_en.properties (Italian) New translations Menu_en.properties (Italian) ... # Conflicts: # src/main/java/org/jabref/gui/JabRefFrame.java
Fixes #2970
The open functionality has been removed -> Directly possible in the entry editor
Contextmenu on maintable ->attach file now opens a file chooser dialog and afterwards this dialog for editing, e.g. adding a description
Only resizable to max screen size: (on my 24" with 1920x1200)
gradle localizationUpdate
?