-
-
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
Double click on citation opens LaTeX editor #12044
Changes from 6 commits
066bbab
b0821bf
87b5750
84fdf95
7f95c8b
a41d5dd
677c604
52158ee
eef355e
998659c
1c22c56
0a655ff
8294e73
45c6777
ac62f2d
0731c36
1387c4b
6bf9f30
1372e2a
7944ee3
85fa67e
d120835
6afaaef
b7b2312
b5040b3
5d0bbfb
ac33148
2d456a5
f48766b
b6bbf06
e117247
551b074
61395fa
aeedbb4
3b9fbac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+0 −2 | .gitattributes | |
+0 −6 | .github/dependabot.yml | |
+2 −2 | .github/workflows/checks.yml | |
+15 −0 | .github/workflows/keep-alive.yml | |
+12 −13 | .github/workflows/refresh-journal-lists.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,16 @@ | |
import javafx.beans.property.StringProperty; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.scene.input.MouseButton; | ||
import javafx.scene.input.MouseEvent; | ||
|
||
import org.jabref.gui.AbstractViewModel; | ||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.gui.push.PushToApplication; | ||
import org.jabref.gui.push.PushToApplications; | ||
import org.jabref.gui.push.PushToEmacs; | ||
import org.jabref.gui.texparser.CitationsDisplay; | ||
import org.jabref.gui.util.DirectoryDialogConfiguration; | ||
import org.jabref.gui.util.UiTaskExecutor; | ||
import org.jabref.logic.l10n.Localization; | ||
|
@@ -154,6 +160,26 @@ public void onDirectoryDelete(File directory) { | |
}; | ||
} | ||
|
||
// Handle mouse click event | ||
public void handleMouseClick(MouseEvent event, CitationsDisplay citationsDisplay) { | ||
// Get the currently selected item | ||
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. Remove obsolete comment - next line states the same |
||
Citation selectedItem = citationsDisplay.getSelectionModel().getSelectedItem(); | ||
|
||
// Check if the left mouse button was double-clicked | ||
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. Remove obsolete comment - next line states the same |
||
if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2 && selectedItem != null) { | ||
// Perform a jump or other actions | ||
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. Remove obsolete comment - next line states the same |
||
String applicationName = preferences.getPushToApplicationPreferences() | ||
.getActiveApplicationName(); | ||
PushToApplication application = PushToApplications.getApplicationByName( | ||
applicationName, | ||
dialogService, | ||
preferences) | ||
.orElse(new PushToEmacs(dialogService, preferences)); | ||
preferences.getPushToApplicationPreferences().setActiveApplicationName(application.getDisplayName()); | ||
application.publicJumpToLine(selectedItem.path(), selectedItem.line(), selectedItem.colStart()); | ||
} | ||
} | ||
|
||
public void bindToEntry(BibEntry entry) { | ||
checkAndUpdateDirectory(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.jabref.gui.push; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
|
@@ -181,4 +182,40 @@ public Optional<KeyBinding> getKeyBinding() { | |
return Optional.of(KeyBinding.PUSH_TO_APPLICATION); | ||
} | ||
} | ||
|
||
/** | ||
* This function is to jump to a specific line due to different editor. | ||
* | ||
*/ | ||
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. Remove obsolete comment - next line states the same |
||
protected void jumpToLine(Path fileName, int line, int column) { | ||
commandPath = preferences.getPushToApplicationPreferences().getCommandPaths().get(this.getDisplayName()); | ||
|
||
// Check if a path to the command has been specified | ||
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. Please remove these kinds of comments - there are clear form the code. |
||
if (StringUtil.isNullOrEmpty(commandPath)) { | ||
notDefined = true; | ||
return; | ||
} | ||
|
||
// Execute the command | ||
String[] command = jumpString(fileName, line, column); | ||
|
||
try { | ||
ProcessBuilder processBuilder = new ProcessBuilder(command); | ||
processBuilder.start(); | ||
} catch (IOException e) { | ||
// Use robust logging instead of printStackTrace() | ||
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. Remove comment |
||
LOGGER.error("Could not open TeXstudio at the specified location.", e); | ||
|
||
// Show an error dialog to the user | ||
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. This is clear from the line below - remove comment |
||
dialogService.showErrorDialogAndWait("Error", "Could not open TeXstudio at the specified location."); | ||
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 localization. Paramterize the tool using |
||
} | ||
} | ||
|
||
protected String[] jumpString(Path fileName, int line, int column) { | ||
koppor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return new String[0]; | ||
} | ||
|
||
public void publicJumpToLine(Path fileName, int line, int column) { | ||
jumpToLine(fileName, line, column); | ||
} | ||
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. What are these methods for? I think, they can be deleted? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,4 +142,8 @@ private void pushEntries() { | |
BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); | ||
application.pushEntries(database, stateManager.getSelectedEntries(), getKeyString(stateManager.getSelectedEntries(), application.getDelimiter())); | ||
} | ||
// private void jump(Path fileName, int line, int column) { | ||
// BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null")); | ||
// application.publicJumpToLine(database, stateManager.getSelectedEntries(), getKeyString(stateManager.getSelectedEntries(), application.getDelimiter())); | ||
// } | ||
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 commented-out code needed? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package org.jabref.gui.push; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.icon.IconTheme; | ||
import org.jabref.gui.icon.JabRefIcon; | ||
|
@@ -27,4 +29,13 @@ public JabRefIcon getApplicationIcon() { | |
protected String[] getCommandLine(String keyString) { | ||
return new String[] {commandPath, "--insert-cite", "%s%s%s".formatted(getCitePrefix(), keyString, getCiteSuffix())}; | ||
} | ||
|
||
/** | ||
* Method to open TeXstudio at the given line number in the specified LaTeX file. | ||
*/ | ||
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. Remove obsolete comment - next line states the same |
||
@Override | ||
public String[] jumpString(Path fileName, int line, int column) { | ||
// Construct the TeXstudio command | ||
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. Remvoe comment. It is clear from the context. |
||
return new String[] {commandPath, "--line", Integer.toString(line), fileName.toString()}; | ||
} | ||
} |
+4 −7 | anesthesiology.csl | |
+14 −3 | cultural-geographies.csl | |
+0 −196 | enfances-familles-generations.csl | |
+95 −86 | hochschule-bonn-rhein-sieg.csl | |
+2 −2 | organization-studies.csl | |
+21 −25 | pacific-conservation-biology.csl | |
+1 −1 | parasite.csl |
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.
Remove obsolete comment - next line states the same