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

Dialogstojavafx #3801

Merged
merged 24 commits into from
Mar 5, 2018
Merged

Dialogstojavafx #3801

merged 24 commits into from
Mar 5, 2018

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Mar 2, 2018

I have converted a lot of dialogs to javafx.
I did not test each one.

Some of them are going to be replaced in the near future (e.g. the Strings dialog and the import of files/drag and drop stuff), so I did not convert them.

Dialogs which need special treatment are marked with TODO statements.
Some of the candidates are the ones that integrate html or the preview pane


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 2, 2018
Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having a look at this! This is a huge step to make the maintable-branch usable without dialogs hiding behind the main window. I have a few comments, but these are generally only minor ones.

@@ -525,7 +525,7 @@ public void update() {

actions.put(Actions.OPEN_URL, new OpenURLAction());

actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this));
actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this, frame));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please pass the DialogService directly, instead of the frame (makes the dependency clearer).

fup.scanResultsResolved(true);
}
}

private void storeTempDatabase() {
JabRefExecutorService.INSTANCE.execute(() -> {
try {
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withMakeBackup(false)
.withEncoding(panel.getBibDatabaseContext().getMetaData().getEncoding()
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code style settings still seem to be off. The dots are not aligned (if this is not an artifact of the way github displays the code)

@@ -657,7 +657,7 @@ public void update() {
actions.put(Actions.REMOVE_FROM_GROUP, new GroupAddRemoveDialog(this, false, false));
actions.put(Actions.MOVE_TO_GROUP, new GroupAddRemoveDialog(this, true, true));

actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(this));
actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(frame, this));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

@@ -101,7 +100,7 @@ private void initGui() {
List<String> entryTypes = new ArrayList<>();
entryTypes.addAll(EntryTypes.getAllTypes(bibDatabaseMode));

typeComp = new EntryTypeList(entryTypes, bibDatabaseMode);
typeComp = new EntryTypeList(frame, entryTypes, bibDatabaseMode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here also

LOGGER.info("Error while downloading " + "'" + res + "'", ex);
frame.getDialogService().showErrorDialogAndWait(Localization.lang("Download file"), Localization.lang("Invalid URL") + ": " + ex.getMessage(), ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should display the error message twice if I'm not mistaken.

Localization.lang("You must enter an integer value in the interval 1025-65535 in the text field for")
+ " '" + Localization.lang("Remote server port") + '\'',
Localization.lang("Remote server port"), JOptionPane.ERROR_MESSAGE);
ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the exception as an argument is unneeded here, since the stack trace is not helpful at all in this situation: the user entered data in the wrong format and this is said already in the error message.

@@ -64,8 +67,8 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
}
}


public GeneralTab(JabRefPreferences prefs) {
public GeneralTab(JabRefFrame frame, JabRefPreferences prefs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directly pass the dialogservice pls

(null, Localization.lang("The chosen date format for new entries is not valid"),
Localization.lang("Invalid date format"),
JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, Localization.lang("The chosen date format for new entries is not valid"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you missed this one ;-)

tabs.add(new NetworkTab(prefs));
tabs.add(new AdvancedTab(prefs));
tabs.add(new AppearancePrefsTab(prefs));
tabs.add(new NetworkTab(frame, prefs));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dialogservice everywhere

@@ -127,13 +130,17 @@ private void setupLogic() {
testPane.setEntry(TestEntry.getTestEntry());
JFXPanel container = CustomJFXPanel.wrap(new Scene(testPane));
container.setPreferredSize(new Dimension(800, 350));

//TODO: Add dialog for showing pane
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be easy using

/**
* This will create and display a new dialog showing a custom {@link DialogPane}
* and using custom {@link ButtonType}s.
*
* @return Optional with the pressed Button as ButtonType
*/
Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane contentPane, ButtonType... buttonTypes);

Siedlerchr and others added 9 commits March 3, 2018 19:10
…javafx

* upstream/maintable-beta:
  Change open last edited dialgo to javafx (#3800)
convert some more dialogs
Fix index out of bounds in Entry Table columns Pref Tab
Display charsets in  Choices dialog
Extend choice dialog with cancel button and ok button label
}
if (answer == JOptionPane.NO_OPTION) {

// return dialogService.showConfirmationDialogWithOptOutAndWait(title, message,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these comments

Localization.lang("Are you sure you want to remove the style?"),
Localization.lang("Remove style"),
Localization.lang("Cancel"));
if (!style.isFromResource() && removeStylePressed) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously the dialog was only shown if style.isFromResource returned false. Is this change of behavior desirable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah shit, I oversaw that condiation

@@ -254,10 +253,12 @@ private void setupPopupMenu() {
// Create action listener for removing a term file, also used for the remove button
removeAction = actionEvent -> getSelectedTermsList().ifPresent(list -> {

if (!list.isInternalList() && (JOptionPane.showConfirmDialog(diag,
boolean removeProctedTermsFilePressed = frame.getDialogService().showConfirmationDialogAndWait(Localization.lang("Remove protected terms file"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -68,7 +68,7 @@ private static FXDialog createDialog(AlertType type, String title, String conten
}

private static FXDialog createDialogWithOptOut(AlertType type, String title, String content,
String optOutMessage, Consumer<Boolean> optOutAction) {
String optOutMessage, Consumer<Boolean> optOutAction) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be another inconsistency between eclipse and intellj style

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will investigate that

Localization.lang("You are already connected to a database using entered connection details."),
Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);

frame.getDialogService().showWarningDialogAndWait(Localization.lang("Warning"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a better title?

@@ -61,11 +63,12 @@ protected void initSettingsPanel() {
}

@Override
public void pushEntries(BibDatabase database, List<BibEntry> entries, String keys, MetaData metaData) {
public void pushEntries(BibDatabase database, List<BibEntry> entries, String keys, MetaData metaData, DialogService dialogService) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dialogService makes more sense as a constructor argument, I think. Probably push it even to AbstractPushToApplication

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so, too, but the concrete subclass of PushToEntries (operation) is just passed as constructur argument as a dependency, so it is not possible

Copy link
Member

@tobiasdiez tobiasdiez Mar 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what you mean. The push to application action of course only gets the PushToApplicaiton instance without knowing which concrete subclass it is. But this is not a problem as far as I can see since upon initialization each subclass would get a DialogService as a constructor argument.

Copy link
Member Author

@Siedlerchr Siedlerchr Mar 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is: PushToApplicationAction already gets an instance of the concrete push operation and only calls pushEntries.
And these push-Operations are defined and instantiated here. I can't just pass the DialogService as Constructor arg.
The only thing I could do is to create an additional setter for the Dialog Service

applications = new ArrayList<>();
applications.add(new PushToEmacs());
applications.add(new PushToLyx());
applications.add(new PushToTexmaker());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you pass the dialog service as a constructor argument to PushToApplications? It seems the only place where this class is initiated is

pushApplications = new PushToApplications();

where you have a dialog service at your disposal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

and convert some open office dlgs, too
+ "</html>",
"", JOptionPane.ERROR_MESSAGE);

frame.getDialogService().showErrorDialogAndWait(Localization.lang("Undefined paragraph format"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove todo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were a second too early ;)

…javafx

* upstream/maintable-beta:
  Remove unused import
  Add group coloring in maintable as replacement for marked entries (#3769)

# Conflicts:
#	src/main/resources/l10n/JabRef_en.properties
@tobiasdiez
Copy link
Member

Let's merge this before the size escalates ;-). Thanks a lot for your time and good work @Siedlerchr!

@tobiasdiez tobiasdiez merged commit 21355ab into maintable-beta Mar 5, 2018
@tobiasdiez tobiasdiez deleted the dialogstojavafx branch March 5, 2018 15:11
Siedlerchr added a commit that referenced this pull request Mar 9, 2018
…drop

* upstream/maintable-beta: (24 commits)
  Fixes #3796: Pretend that we have every translation for every key (#3820)
  adjust line wrapping on column
  replace open office install selection dialog with choice dialog Wrap error messages in fx executor (because abstract worker is swing thread)
  Convert swing error dialog in save db action to custom fx dialog
  Replace swing export dialog in ExportToClipboardAction with fx choices dlg
  run find fulltext dialog in fx thread
  fix cut, copy & paste action from toolbar
  Set resizable for custom dialog with dialog pane convert merge entries dlg to javafx and make action working again
  checkstyle argh!
  Update test order -> Execute checkstyle first (#3807)
  embed cleanup dialog in javafx
  Fix some non FX Thread issues Main drawback: Cleanup panel is in backgroung due to swing thread)
  Allow search field to be smaller
  Fix Codacy Unused Params, Fields (#3753)
  Dialogstojavafx (#3801)
  Remove unused import
  Add group coloring in maintable as replacement for marked entries (#3769)
  Enable travis build for maintable-beta (#3804)
  Remove setting of tooltip manually
  Change open last edited dialgo to javafx (#3800)
  ...

# Conflicts:
#	src/main/java/org/jabref/gui/maintable/MainTable.java
Siedlerchr added a commit that referenced this pull request Mar 10, 2018
…tomjfx

* upstream/maintable-beta: (28 commits)
  Fixes #3796: Pretend that we have every translation for every key (#3820)
  adjust line wrapping on column
  replace open office install selection dialog with choice dialog Wrap error messages in fx executor (because abstract worker is swing thread)
  Convert swing error dialog in save db action to custom fx dialog
  Replace swing export dialog in ExportToClipboardAction with fx choices dlg
  run find fulltext dialog in fx thread
  fix cut, copy & paste action from toolbar
  Set resizable for custom dialog with dialog pane convert merge entries dlg to javafx and make action working again
  checkstyle argh!
  Update test order -> Execute checkstyle first (#3807)
  embed cleanup dialog in javafx
  Fix some non FX Thread issues Main drawback: Cleanup panel is in backgroung due to swing thread)
  Allow search field to be smaller
  Fix Codacy Unused Params, Fields (#3753)
  Dialogstojavafx (#3801)
  Remove unused import
  Add group coloring in maintable as replacement for marked entries (#3769)
  Enable travis build for maintable-beta (#3804)
  Remove setting of tooltip manually
  Change open last edited dialgo to javafx (#3800)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants