Skip to content

Jump to entry from cli#10578

Merged
calixtus merged 52 commits into
JabRef:mainfrom
u7282852:issue541-jump-to-entry-cli
Feb 4, 2024
Merged

Jump to entry from cli#10578
calixtus merged 52 commits into
JabRef:mainfrom
u7282852:issue541-jump-to-entry-cli

Conversation

@u7282852

@u7282852 u7282852 commented Oct 25, 2023

Copy link
Copy Markdown
Contributor

Fixes JabRef#540

Command line now supports option "jumpToEntryKey" or "-j" folowed by one entrykey argument.
Upon start up, jabref will search the imported files (BibTex files given as command line arguments) for the entrykey and focus this library and select this entry. Recently opened files will not be searched for this key, as it may be out of the scope of my knowledge of the repository to handle this gracefully.

As mentioned by @calixtus refactoring is likely necessary to create a better way to mix the cli commands into the UI. Though functionality works as expected.

If this change is merged user documentation at https://docs.jabref.org/advanced/commandline may need to add this feature.

Feature demonstration
image
image

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.

@calixtus

Copy link
Copy Markdown
Member

Hi, thanks for your Pull Request.
Although this functionality is fine, I am not convinced that it is the right way to mix in commands to the gui into the ParserResult, which is as mere model/logic only class. So I think this has to be implemented differently. Maybe there needs to be a whole different apprach to send ui commands from the command line to the gui.

@calixtus

Copy link
Copy Markdown
Member

What I immediately imagine would be a List of sth like JumpToEntry implements UiCommand, OpenDatabase implements UiCommand or InsertBibEntries implements UiCommands. This could be handled inside JabRefGUI. I sense this could be some training on cutting edge java pattern matching stuff. Actually implementing this could be fun! 😄

@u7282852

Copy link
Copy Markdown
Contributor Author

@calixtus Thank you for the feedback! I assume UiCommand is some interface that I would create, however I am not sure exactly what would be included in this interface. Unless you are referring to https://docs.oracle.com/javaee/7/api/javax/faces/component/UICommand.html. I also not familiar with Java pattern matching so I am not sure where to apply pattern matching to this problem.

Considering my current approach does not easily allow me to check for the argument citation key in recently opened databases, I was thinking of adding a String field to JabRefFrame storing the key which gets passed from the Launcher class. Then during the openDatabase() method I could check all databases for the key and open the respective library and entry. Would this approach be too simplistic or even applicable given it woud require changing multiple Constructors and class fields to pass this string to the JabRef.
I might continue with this approach and refactor where necessary :)

@calixtus

Copy link
Copy Markdown
Member

I made UiCommand up when i was commenting, I did not know there is already a idk class the same name.

Give me some days, I will try to support you with this, although I'm a bit of a very tight schedule the next days.

@u7282852

Copy link
Copy Markdown
Contributor Author

@calixtus Thank ou again. If my changes are useful I could submit a PR and someone else could pick this up where I left off. Otherwise I can also continue working on this in the coming weeks, however I also am very busy the next few weeks.

@ThiloteE ThiloteE changed the title Issue541 jump to entry cli (WIP) Jump to entry cli (WIP) Oct 28, 2023
@ThiloteE ThiloteE changed the title Jump to entry cli (WIP) [WIP] Jump to entry cli Oct 28, 2023
@koppor

koppor commented Nov 6, 2023

Copy link
Copy Markdown
Member
  • Remote messages should be logged (visible through the menu)
  • Opening in running JabRef (whith library opened) does not work
  • Opening a file in running JabRef does not work (JabRef does not have library opened)
  • Opening a file in new JabRef instance does not work.

Test setting:

@Article{test,
}

@Article{lala,
}

@Article{coverpage,
  title = {YEAH},
}

@Comment{jabref-meta: databaseType:bibtex;}

gradle run configuration

run --args="-j coverpage C:\temp\b.bib"

@koppor

koppor commented Nov 6, 2023

Copy link
Copy Markdown
Member

The functionality is WRONG.

I have OPENED LIBRARIES. The jump-to-entry should search in the OPENED LIBRARIES!

It is OK if additionally one can jump to an entry of a library which is given by the command line. However, the idea is just to call jabref.bat -j entryId23 and then JabRef searches entryId23 first in the current library. If not found, it searches the other libraries.

@Siedlerchr

Copy link
Copy Markdown
Member

jumpToKey should only use the String citation key. No parser result needed

…try-cli

# Conflicts:
#	src/main/java/org/jabref/gui/MainApplication.java
…try-cli

# Conflicts:
#	src/main/java/org/jabref/gui/JabRefFrame.java
#	src/main/java/org/jabref/gui/JabRefGUI.java
#	src/main/java/org/jabref/gui/LibraryTab.java
#	src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
@calixtus

Copy link
Copy Markdown
Member

Played a little bit around with bindings:
What about this one instead of the change listener (not yet tested)?

        BooleanBinding loadingBinding = Bindings.createBooleanBinding(
                () -> loadings.stream().anyMatch(ObservableBooleanValue::get),
                loadings.toArray(Observable[]::new)
        );

        EasyBind.subscribe(loadingBinding, loading -> {
            if (!loading) {
                future.complete(null);
            }
        });

@koppor

koppor commented Jan 30, 2024

Copy link
Copy Markdown
Member

I have following output

TRACE: Waiting for all tabs beging loaded

Even if all tabs are loaded...

@koppor

koppor commented Jan 30, 2024

Copy link
Copy Markdown
Member

When a file is loaded from outside, onDatabaseLoadingSucceed is not called.

@koppor koppor marked this pull request as ready for review January 30, 2024 17:11
@calixtus calixtus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jan 30, 2024
calixtus
calixtus previously approved these changes Jan 30, 2024
@calixtus

Copy link
Copy Markdown
Member

As far as i can approve koppors changes, @Siedlerchr should also approve.

@calixtus calixtus added this pull request to the merge queue Feb 4, 2024
Merged via the queue into JabRef:main with commit 1c47af4 Feb 4, 2024
Siedlerchr added a commit that referenced this pull request Feb 6, 2024
* upstream/main:
  Bump org.apache.lucene:lucene-core from 9.9.1 to 9.9.2 (#10860)
  Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 (#10863)
  Bump org.apache.lucene:lucene-highlighter from 9.9.1 to 9.9.2 (#10861)
  Bump org.tinylog:tinylog-api from 2.6.2 to 2.7.0 (#10862)
  Bump org.apache.lucene:lucene-queryparser from 9.9.1 to 9.9.2 (#10859)
  Bump gradle/wrapper-validation-action from 1 to 2 (#10858)
  Bump codecov/codecov-action from 3 to 4 (#10857)
  Bump peter-evans/create-pull-request from 5 to 6 (#10856)
  Update Gradle Wrapper from 8.5 to 8.6. (#10854)
  Enable auto merge of gradle wrapper update
  Jump to entry from cli (#10578)
  Fix closing of JabRef in case of issues with index writer (#10840)
  Update deployment-arm64.yml
  Fix secrents presence chcek
Siedlerchr added a commit to rdsingh13/jabref that referenced this pull request Feb 11, 2024
* upstream/main: (68 commits)
  BibTeX 'Title' to MS Office 'Publicationtitle' field (JabRef#10864)
  Introduce BibliographyConsistencyCheckResultTxtWriter (JabRef#10847)
  Upgrade gradle-build-action to actions/setup-gradle (JabRef#10866)
  Bump org.apache.lucene:lucene-core from 9.9.1 to 9.9.2 (JabRef#10860)
  Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 (JabRef#10863)
  Bump org.apache.lucene:lucene-highlighter from 9.9.1 to 9.9.2 (JabRef#10861)
  Bump org.tinylog:tinylog-api from 2.6.2 to 2.7.0 (JabRef#10862)
  Bump org.apache.lucene:lucene-queryparser from 9.9.1 to 9.9.2 (JabRef#10859)
  Bump gradle/wrapper-validation-action from 1 to 2 (JabRef#10858)
  Bump codecov/codecov-action from 3 to 4 (JabRef#10857)
  Bump peter-evans/create-pull-request from 5 to 6 (JabRef#10856)
  Update Gradle Wrapper from 8.5 to 8.6. (JabRef#10854)
  Enable auto merge of gradle wrapper update
  Jump to entry from cli (JabRef#10578)
  Fix closing of JabRef in case of issues with index writer (JabRef#10840)
  Update deployment-arm64.yml
  use nio path
  fix submodules
  Fix secrents presence chcek
  Update deployment-arm64.yml
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: JabKit [cli] dev: code-quality Issues related to code or architecture decisions 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.

Add CLI option: --jump-to-entry key

5 participants