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

Convert some fields to TextArea #11886

Merged
merged 13 commits into from
Oct 13, 2024
Merged

Conversation

juliusalberto
Copy link
Contributor

@juliusalberto juliusalberto commented Oct 6, 2024

I have changed some fields from TextArea to TextField in some fields: URL, identifier, owner, and ISSN.
Closes #11785

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Nice work.

Small comments inside.

Optional follow-ups:

  • Tab in the last text field in a tab should focus the next tab in the tabs of the entry editor.
  • Tab in empty text area field should focus the next field
  • Consistency check

Consistency check:

There should be an automatic checker (JUnit) test case. JabRef has org.jabref.model.entry.field.FieldProperty#MULTILINE_TEXT. All of these fields should be offered as TextArea, all others (!) as TextField

I think, this is a hard one, but much to learn.

The "only" way is maybe to use Refaster template recipes and check if OpenRewrite would change anything.

Maybe, this also does not work and one would need to use JavaParser to check the constructor at org.jabref.gui.fieldeditors.FieldEditorFX, whether all new X get a field passed matching the X (X instanceof TextArea <=> fieldProperties.contains(MULTILINE_TEXT))


If you can do any of these, I would be happy. Otherwise, I will open follow-up issues. Initally, all of these ideas look hard to implement.

@Siedlerchr Siedlerchr changed the title Fix for issue 11785 Convert some fields to TextArea Oct 7, 2024
@Siedlerchr Siedlerchr added the status: changes required Pull requests that are not yet complete label Oct 7, 2024
@juliusalberto
Copy link
Contributor Author

juliusalberto commented Oct 7, 2024

Optional follow-ups:

  • Tab in the last text field in a tab should focus the next tab in the tabs of the entry editor.
  • Tab in empty text area field should focus the next field
  • Consistency check

Hi @koppor, can I do the second one (Tab in empty text area field should focus on the next field)? Thanks!

I'd like to do the first one please (Tab in the last text field in a tab should focus the next tab in the tabs of the entry editor). One of my friend @yeonissa would like to be assigned with the second one. We are doing this as part of university course in ANU.

Also, I've already made the changes you requested. Let me know if you need anything else.

@koppor
Copy link
Member

koppor commented Oct 10, 2024

I'd like to do the first one please (Tab in the last text field in a tab should focus the next tab in the tabs of the entry editor).

Do you need a seperate issue for that be created?

One of my friend @yeonissa would like to be assigned with the second one.

Do you need a seperate issue for that be created?

@koppor koppor removed the status: changes required Pull requests that are not yet complete label Oct 10, 2024
koppor
koppor previously approved these changes Oct 10, 2024
@koppor
Copy link
Member

koppor commented Oct 10, 2024

The changes need a second review and thus this PR awaits a second review.

@juliusalberto
Copy link
Contributor Author

@koppor yes please - can you make separate issues for that? Thanks a lot.

Comment on lines 23 to 25
private PasteActionHandler additionalPasteActionHandler = () -> {
// No additional paste behavior
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to create an interface; you can use java.lang.Runnable instead. Please also update in org.jabref.gui.fieldeditors.EditorTextArea, or remove it if it's not being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think using Runnable here would be semantically inappropriate, since it's typically used for thread-related tasks. Sticking with a more specific interface or lambda for paste handling keeps the intent clearer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

About Runnables. I also thought it's only for threading, but no.

It's a general and accepted way to have a function type that accepts to arguments and returns no type

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think using Runnable here would be semantically inappropriate, since it's typically used for thread-related tasks. Sticking with a more specific interface or lambda for paste handling keeps the intent clearer.

Reading the documentation for Runnable, I don’t see any threading-related tasks mentioned.

The interface is similar to how you implemented PasteActionHandler. (https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Runnable.java).

Copy link
Member

Choose a reason for hiding this comment

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

This is a general code style question. Does one want to have strong typing or not. - Seeing that the setting of this is very generic, I also don't see the need for an additional class type.

() -> textField.setText(new CleanupUrlFormatter().format(new TrimWhitespaceFormatter().format(textField.getText())))

Just changing to Runnable should fix it?

Regarding the intention of runnable:

Represents an operation that does not return a result.

This is excactly the thing we are looking for here, isn't it?


Source of Runnable:

package java.lang;

/**
 * Represents an operation that does not return a result.
 *
 * <p> This is a {@linkplain java.util.function functional interface}
 * whose functional method is {@link #run()}.
 *
 * @author  Arthur van Hoff
 * @see     java.util.concurrent.Callable
 * @since   1.0
 */
@FunctionalInterface
public interface Runnable {
    /**
     * Runs this operation.
     */
    void run();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to Runnable in my latest commit. Thanks.

return menuItems;
};
}

/**
* The default context menu with a specific menu item to cleanup URL.
*
* @param textArea text-area that this menu will be connected to
* @param textField text-area that this menu will be connected to
Copy link
Collaborator

@InAnYan InAnYan Oct 11, 2024

Choose a reason for hiding this comment

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

text-area there in the doc string. Should be text-field, I think

InAnYan
InAnYan previously approved these changes Oct 11, 2024
@koppor koppor dismissed stale reviews from InAnYan and themself via bc46f87 October 11, 2024 07:08
koppor
koppor previously approved these changes Oct 11, 2024
InAnYan
InAnYan previously approved these changes Oct 11, 2024
@koppor
Copy link
Member

koppor commented Oct 12, 2024

@koppor yes please - can you make separate issues for that? Thanks a lot.

#11937 and #11938. @juliusalberto Please comment there so that I can assign you (or your colleague)

@koppor koppor dismissed stale reviews from InAnYan and themself via ddcbe20 October 12, 2024 11:20
Comment on lines 23 to 25
private PasteActionHandler additionalPasteActionHandler = () -> {
// No additional paste behavior
};
Copy link
Member

Choose a reason for hiding this comment

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

This is a general code style question. Does one want to have strong typing or not. - Seeing that the setting of this is very generic, I also don't see the need for an additional class type.

() -> textField.setText(new CleanupUrlFormatter().format(new TrimWhitespaceFormatter().format(textField.getText())))

Just changing to Runnable should fix it?

Regarding the intention of runnable:

Represents an operation that does not return a result.

This is excactly the thing we are looking for here, isn't it?


Source of Runnable:

package java.lang;

/**
 * Represents an operation that does not return a result.
 *
 * <p> This is a {@linkplain java.util.function functional interface}
 * whose functional method is {@link #run()}.
 *
 * @author  Arthur van Hoff
 * @see     java.util.concurrent.Callable
 * @since   1.0
 */
@FunctionalInterface
public interface Runnable {
    /**
     * Runs this operation.
     */
    void run();
}

@koppor koppor enabled auto-merge October 13, 2024 04:45
@koppor koppor added this pull request to the merge queue Oct 13, 2024
Merged via the queue into JabRef:main with commit 8404312 Oct 13, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use tab to jump to next field in some single-line fields
5 participants