Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added the option to enable the language server in the preferences. [#13697](https://github.com/JabRef/jabref/pull/13697)
- We introduced an option in Preferences under (under Linked files -> Linked file name conventions) to automatically rename linked files when an entry data changes. [#11316](https://github.com/JabRef/jabref/issues/11316)
- We added tooltips (on hover) for 'Library-specific file directory', 'User-specific file directory' and 'LaTeX file directory' fields of the library properties window. [#12269](https://github.com/JabRef/jabref/issues/12269)
- A space is now added by default after citations inserted via the Libre/OpenOffice integration. [#13559](https://github.com/JabRef/jabref/issues/13559)
Expand Down
5 changes: 3 additions & 2 deletions jabgui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ dependencies {
// implementation("org.openjfx:javafx-fxml")
// implementation("org.openjfx:javafx-graphics")

implementation(project(":jabls"))
implementation(project(":jabsrv"))

implementation("org.openjfx:javafx-swing")
implementation("org.openjfx:javafx-web")

implementation(project(":jabsrv"))

implementation("com.pixelduke:fxthemes")

// From JavaFX25 onwards
Expand Down
2 changes: 1 addition & 1 deletion jabgui/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open module org.jabref {
requires org.jabref.jablib;

requires org.jabref.jabls;
requires org.jabref.jabsrv;

// Swing
Expand Down
17 changes: 16 additions & 1 deletion jabgui/src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jabref.gui.util.UiTaskExecutor;
import org.jabref.gui.util.WebViewStore;
import org.jabref.http.manager.HttpServerManager;
import org.jabref.languageserver.controller.LanguageServerController;
import org.jabref.logic.UiCommand;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.citation.SearchCitationsRelationsService;
Expand Down Expand Up @@ -86,6 +87,7 @@ public class JabRefGUI extends Application {

private static RemoteListenerServerManager remoteListenerServerManager;
private static HttpServerManager httpServerManager;
private static LanguageServerController languageServerController;

private Stage mainStage;

Expand Down Expand Up @@ -156,8 +158,9 @@ public void initialize() {
Injector.setModelOrService(DirectoryMonitor.class, directoryMonitor);

BibEntryTypesManager entryTypesManager = preferences.getCustomEntryTypesRepository();
JournalAbbreviationRepository journalAbbreviationRepository = JournalAbbreviationLoader.loadRepository(preferences.getJournalAbbreviationPreferences());
Injector.setModelOrService(BibEntryTypesManager.class, entryTypesManager);
Injector.setModelOrService(JournalAbbreviationRepository.class, JournalAbbreviationLoader.loadRepository(preferences.getJournalAbbreviationPreferences()));
Injector.setModelOrService(JournalAbbreviationRepository.class, journalAbbreviationRepository);
Injector.setModelOrService(ProtectedTermsLoader.class, new ProtectedTermsLoader(preferences.getProtectedTermsPreferences()));

IndexManager.clearOldSearchIndices();
Expand All @@ -168,6 +171,9 @@ public void initialize() {
JabRefGUI.httpServerManager = new HttpServerManager();
Injector.setModelOrService(HttpServerManager.class, JabRefGUI.httpServerManager);

JabRefGUI.languageServerController = new LanguageServerController(preferences, journalAbbreviationRepository);
Injector.setModelOrService(LanguageServerController.class, JabRefGUI.languageServerController);

JabRefGUI.stateManager = new JabRefGuiStateManager();
Injector.setModelOrService(StateManager.class, stateManager);

Expand Down Expand Up @@ -424,6 +430,9 @@ public void startBackgroundTasks() {
if (remotePreferences.enableHttpServer()) {
httpServerManager.start(stateManager, remotePreferences.getHttpServerUri());
}
if (remotePreferences.enableLanguageServer()) {
languageServerController.start(remotePreferences.getLanguageServerPort());
}
}

@Override
Expand Down Expand Up @@ -467,6 +476,12 @@ public void stop() {
LOGGER.trace("HttpServerManager shut down");
});

executor.submit(() -> {
LOGGER.trace("Shutting down language server controller");
languageServerController.stop();
LOGGER.trace("LanguageServerController shut down");
});

executor.submit(() -> {
LOGGER.trace("Stopping background tasks");
Unirest.shutDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> i
@FXML private TextField remotePort;
@FXML private CheckBox enableHttpServer;
@FXML private TextField httpServerPort;
@FXML private CheckBox enableLanguageServer;
@FXML private TextField languageServerPort;
@FXML private Button remoteHelp;
@Inject private FileUpdateMonitor fileUpdateMonitor;
@Inject private BibEntryTypesManager entryTypesManager;
Expand Down Expand Up @@ -147,6 +149,7 @@ public void initialize() {
Platform.runLater(() -> {
validationVisualizer.initVisualization(viewModel.remotePortValidationStatus(), remotePort);
validationVisualizer.initVisualization(viewModel.httpPortValidationStatus(), httpServerPort);
validationVisualizer.initVisualization(viewModel.languageServerPortValidationStatus(), languageServerPort);
validationVisualizer.initVisualization(viewModel.fontSizeValidationStatus(), fontSize);
validationVisualizer.initVisualization(viewModel.customPathToThemeValidationStatus(), customThemePath);
});
Expand All @@ -158,6 +161,10 @@ public void initialize() {
enableHttpServer.selectedProperty().bindBidirectional(viewModel.enableHttpServerProperty());
httpServerPort.textProperty().bindBidirectional(viewModel.httpPortProperty());
httpServerPort.disableProperty().bind(enableHttpServer.selectedProperty().not());

enableLanguageServer.selectedProperty().bindBidirectional(viewModel.enableLanguageServerProperty());
languageServerPort.textProperty().bindBidirectional(viewModel.languageServerPortProperty());
languageServerPort.disableProperty().bind(enableLanguageServer.selectedProperty().not());
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.http.manager.HttpServerManager;
import org.jabref.languageserver.controller.LanguageServerController;
import org.jabref.logic.FilePreferences;
import org.jabref.logic.LibraryPreferences;
import org.jabref.logic.l10n.Language;
Expand Down Expand Up @@ -112,6 +113,9 @@ public class GeneralTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty enableHttpServerProperty = new SimpleBooleanProperty();
private final StringProperty httpPortProperty = new SimpleStringProperty("");
private final Validator httpPortValidator;
private final Validator languageServerPortValidator;
private final BooleanProperty enableLanguageServerProperty = new SimpleBooleanProperty();
private final StringProperty languageServerPortProperty = new SimpleStringProperty("");
private final TrustStoreManager trustStoreManager;

private final FileUpdateMonitor fileUpdateMonitor;
Expand Down Expand Up @@ -149,29 +153,22 @@ public GeneralTabViewModel(DialogService dialogService, GuiPreferences preferenc

remotePortValidator = new FunctionBasedValidator<>(
remotePortProperty,
input -> {
try {
int portNumber = Integer.parseInt(remotePortProperty().getValue());
return RemoteUtil.isUserPort(portNumber);
} catch (NumberFormatException ex) {
return false;
}
},
RemoteUtil::isStringUserPort,
ValidationMessage.error("%s > %s %n %n %s".formatted(
Localization.lang("Network"),
Localization.lang("Remote operation"),
Localization.lang("You must enter an integer value in the interval 1025-65535"))));

httpPortValidator = new FunctionBasedValidator<>(
httpPortProperty,
input -> {
try {
int portNumber = Integer.parseInt(httpPortProperty().getValue());
return RemoteUtil.isUserPort(portNumber);
} catch (NumberFormatException ex) {
return false;
}
},
RemoteUtil::isStringUserPort,
ValidationMessage.error("%s".formatted(Localization.lang("You must enter an integer value in the interval 1025-65535"))));

languageServerPortValidator = new FunctionBasedValidator<>(
languageServerPortProperty,
RemoteUtil::isStringUserPort,
ValidationMessage.error(Localization.lang("You must enter an integer value in the interval 1025-65535")));

this.trustStoreManager = new TrustStoreManager(Path.of(preferences.getSSLPreferences().getTruststorePath()));
}

Expand All @@ -183,6 +180,10 @@ public ValidationStatus httpPortValidationStatus() {
return httpPortValidator.getValidationStatus();
}

public ValidationStatus languageServerPortValidationStatus() {
return languageServerPortValidator.getValidationStatus();
}

@Override
public void setValues() {
selectedLanguageProperty.setValue(workspacePreferences.getLanguage());
Expand Down Expand Up @@ -227,6 +228,9 @@ public void setValues() {

enableHttpServerProperty.setValue(remotePreferences.enableHttpServer());
httpPortProperty.setValue(String.valueOf(remotePreferences.getHttpPort()));

enableLanguageServerProperty.setValue(remotePreferences.enableLanguageServer());
languageServerPortProperty.setValue(String.valueOf(remotePreferences.getLanguageServerPort()));
}

@Override
Expand Down Expand Up @@ -300,6 +304,12 @@ public void storeSettings() {
}
});

getPortAsInt(languageServerPortProperty.getValue()).ifPresent(newPort -> {
if (remotePreferences.isDifferentLanguageServerPort(newPort)) {
remotePreferences.setLanguageServerPort(newPort);
}
});

HttpServerManager httpServerManager = Injector.instantiateModelOrService(HttpServerManager.class);
// stop in all cases, because the port might have changed
httpServerManager.stop();
Expand All @@ -312,6 +322,17 @@ public void storeSettings() {
httpServerManager.stop();
}

LanguageServerController languageServerController = Injector.instantiateModelOrService(LanguageServerController.class);
// stop in all cases, because the port might have changed (or other settings that can't be easily tracked https://github.com/JabRef/jabref/pull/13697#discussion_r2285997003)
languageServerController.stop();
if (enableLanguageServerProperty.getValue()) {
remotePreferences.setEnableLanguageServer(true);
languageServerController.start(remotePreferences.getLanguageServerPort());
} else {
remotePreferences.setEnableLanguageServer(false);
languageServerController.stop();
}

trustStoreManager.flush();
}

Expand All @@ -335,6 +356,10 @@ public boolean validateSettings() {
validator.addValidators(httpPortValidator);
}

if (enableLanguageServerProperty.getValue()) {
validator.addValidators(languageServerPortValidator);
}

if (fontOverrideProperty.getValue()) {
validator.addValidators(fontSizeValidator);
}
Expand Down Expand Up @@ -477,6 +502,14 @@ public StringProperty httpPortProperty() {
return httpPortProperty;
}

public BooleanProperty enableLanguageServerProperty() {
return enableLanguageServerProperty;
}

public StringProperty languageServerPortProperty() {
return languageServerPortProperty;
}

public void openBrowser() {
String url = "https://themes.jabref.org";
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
<TextField fx:id="httpServerPort" maxWidth="100.0" HBox.hgrow="ALWAYS" />
</HBox>

<Label styleClass="sectionHeader" text="%Language Server" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
<CheckBox fx:id="enableLanguageServer" text="%Enable Language Server on port" />
<TextField fx:id="languageServerPort" maxWidth="100.0" HBox.hgrow="ALWAYS" />
</HBox>

<Label styleClass="sectionHeader" text="%Libraries"/>
<GridPane hgap="10.0" vgap="4.0">
<columnConstraints>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ public class JabRefCliPreferences implements CliPreferences {
private static final String REMOTE_SERVER_PORT = "remoteServerPort";
private static final String HTTP_SERVER_PORT = "httpServerPort";
private static final String ENABLE_HTTP_SERVER = "enableHttpServer";
private static final String ENABLE_LANGUAGE_SERVER = "enableLanguageServer";
private static final String LANGUAGE_SERVER_PORT = "languageServerPort";

private static final String AI_ENABLED = "aiEnabled";
private static final String AI_AUTO_GENERATE_EMBEDDINGS = "aiAutoGenerateEmbeddings";
Expand Down Expand Up @@ -673,6 +675,8 @@ public JabRefCliPreferences() {
defaults.put(REMOTE_SERVER_PORT, 6050);
defaults.put(ENABLE_HTTP_SERVER, Boolean.FALSE);
defaults.put(HTTP_SERVER_PORT, 23119);
defaults.put(ENABLE_LANGUAGE_SERVER, Boolean.FALSE);
defaults.put(LANGUAGE_SERVER_PORT, 2087);

defaults.put(EXTERNAL_JOURNAL_LISTS, "");
defaults.put(USE_AMS_FJOURNAL, true);
Expand Down Expand Up @@ -1384,12 +1388,16 @@ public RemotePreferences getRemotePreferences() {
getInt(REMOTE_SERVER_PORT),
getBoolean(USE_REMOTE_SERVER),
getInt(HTTP_SERVER_PORT),
getBoolean(ENABLE_HTTP_SERVER));
getBoolean(ENABLE_HTTP_SERVER),
getBoolean(ENABLE_LANGUAGE_SERVER),
getInt(LANGUAGE_SERVER_PORT));

EasyBind.listen(remotePreferences.portProperty(), (_, _, newValue) -> putInt(REMOTE_SERVER_PORT, newValue));
EasyBind.listen(remotePreferences.useRemoteServerProperty(), (_, _, newValue) -> putBoolean(USE_REMOTE_SERVER, newValue));
EasyBind.listen(remotePreferences.httpPortProperty(), (_, _, newValue) -> putInt(HTTP_SERVER_PORT, newValue));
EasyBind.listen(remotePreferences.enableHttpServerProperty(), (_, _, newValue) -> putBoolean(ENABLE_HTTP_SERVER, newValue));
EasyBind.listen(remotePreferences.languageServerPortProperty(), (_, _, newValue) -> putInt(LANGUAGE_SERVER_PORT, newValue));
EasyBind.listen(remotePreferences.enableLanguageServerProperty(), (_, _, newValue) -> putBoolean(ENABLE_LANGUAGE_SERVER, newValue));

return remotePreferences;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ public class RemotePreferences {
private final IntegerProperty httpPort;
private final BooleanProperty enableHttpServer;

public RemotePreferences(int port, boolean useRemoteServer, int httpPort, boolean enableHttpServer) {
private final BooleanProperty enableLanguageServer;
private final IntegerProperty languageServerPort;

public RemotePreferences(int port, boolean useRemoteServer, int httpPort, boolean enableHttpServer, boolean enableLanguageServer, int languageServerPort) {
this.port = new SimpleIntegerProperty(port);
this.useRemoteServer = new SimpleBooleanProperty(useRemoteServer);
this.httpPort = new SimpleIntegerProperty(httpPort);
this.enableHttpServer = new SimpleBooleanProperty(enableHttpServer);
this.enableLanguageServer = new SimpleBooleanProperty(enableLanguageServer);
this.languageServerPort = new SimpleIntegerProperty(languageServerPort);
}

public int getPort() {
Expand Down Expand Up @@ -90,6 +95,34 @@ public void setEnableHttpServer(boolean enableHttpServer) {
this.enableHttpServer.setValue(enableHttpServer);
}

public int getLanguageServerPort() {
return languageServerPort.getValue();
}

public IntegerProperty languageServerPortProperty() {
return languageServerPort;
}

public void setLanguageServerPort(int languageServerPort) {
this.languageServerPort.setValue(languageServerPort);
}

public boolean isDifferentLanguageServerPort(int otherLanguageServerPort) {
return getLanguageServerPort() != otherLanguageServerPort;
}

public boolean enableLanguageServer() {
return enableLanguageServer.getValue();
}

public BooleanProperty enableLanguageServerProperty() {
return enableLanguageServer;
}

public void setEnableLanguageServer(boolean enableLanguageServer) {
this.enableLanguageServer.setValue(enableLanguageServer);
}

/// Gets the IP address where both the remote server and the http server are listening.
public static InetAddress getIpAddress() throws UnknownHostException {
return InetAddress.getByName("localhost");
Expand Down
9 changes: 9 additions & 0 deletions jablib/src/main/java/org/jabref/logic/remote/RemoteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ private RemoteUtil() {
public static boolean isUserPort(int portNumber) {
return (portNumber >= 1024) && (portNumber <= 65535);
}

public static boolean isStringUserPort(String portString) {
try {
int portNumber = Integer.parseInt(portString);
return isUserPort(portNumber);
} catch (NumberFormatException e) {
return false;
}
}
}
4 changes: 4 additions & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@ Connect=Connect
Connection\ error=Connection error
Connection\ to\ %0\ server\ established.=Connection to %0 server established.
Required\ field\ "%0"\ is\ empty.=Required field "%0" is empty.
Optional\ field\ "%0"\ is\ empty.=Optional field "%0" is empty.
%0\ driver\ not\ available.=%0 driver not available.
The\ connection\ to\ the\ server\ has\ been\ terminated.=The connection to the server has been terminated.
Reconnect=Reconnect
Expand Down Expand Up @@ -1857,6 +1858,9 @@ Cannot\ use\ port\ %0\ for\ remote\ operation;\ another\ application\ may\ be\ u
Enable\ HTTP\ Server\ (e.g.,\ for\ JabMap)\ on\ port=Enable HTTP Server (e.g., for JabMap) on port
HTTP\ Server=HTTP Server

Enable\ Language\ Server\ on\ port=Enable Language Server on port
Language\ Server=Language Server

Grobid\ URL=Grobid URL
Allow\ sending\ PDF\ files\ and\ raw\ citation\ strings\ to\ a\ JabRef\ online\ service\ (Grobid)\ to\ determine\ Metadata.\ This\ produces\ better\ results.=Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results.
Send\ to\ Grobid=Send to Grobid
Expand Down
Loading
Loading