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

Rename "Remote" to "Tele" #9270

Merged
merged 6 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 5 additions & 10 deletions src/main/java/org/jabref/cli/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.jabref.gui.Globals;
import org.jabref.gui.MainApplication;
import org.jabref.gui.remote.JabRefMessageHandler;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.l10n.Localization;
Expand All @@ -21,8 +20,8 @@
import org.jabref.logic.net.ssl.SSLPreferences;
import org.jabref.logic.net.ssl.TrustStoreManager;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.RemotePreferences;
import org.jabref.logic.remote.client.RemoteClient;
import org.jabref.logic.tele.TelePreferences;
import org.jabref.logic.tele.client.TeleClient;
import org.jabref.logic.util.BuildInfo;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.database.BibDatabaseContext;
Expand Down Expand Up @@ -118,10 +117,10 @@ private static void initializeLogger() {
}

private static boolean handleMultipleAppInstances(String[] args, PreferencesService preferences) {
RemotePreferences remotePreferences = preferences.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
TelePreferences telePreferences = preferences.getTelePreferences();
if (telePreferences.shouldUseTeleServer()) {
// Try to contact already running JabRef
RemoteClient remoteClient = new RemoteClient(remotePreferences.getPort());
TeleClient remoteClient = new TeleClient(telePreferences.getPort());
if (remoteClient.ping()) {
// We are not alone, there is already a server out there, send command line
// arguments to other instance
Expand All @@ -132,10 +131,6 @@ private static boolean handleMultipleAppInstances(String[] args, PreferencesServ
} else {
LOGGER.warn("Could not communicate with other running JabRef instance.");
}
} else {
// We are alone, so we start the server
Globals.REMOTE_LISTENER.openAndStart(new JabRefMessageHandler(), remotePreferences.getPort(),
preferences);
}
}
return true;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/jabref/gui/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.tele.CLIMessageHandler;
import org.jabref.gui.theme.ThemeManager;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.DefaultFileUpdateMonitor;
Expand All @@ -16,7 +17,8 @@
import org.jabref.logic.importer.ImportFormatReader;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.server.RemoteListenerServerLifecycle;
import org.jabref.logic.tele.TelePreferences;
import org.jabref.logic.tele.server.TeleServerManager;
import org.jabref.logic.util.BuildInfo;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.strings.StringUtil;
Expand All @@ -41,8 +43,7 @@ public class Globals {
*/
public static final BuildInfo BUILD_INFO = new BuildInfo();

// Remote listener
public static final RemoteListenerServerLifecycle REMOTE_LISTENER = new RemoteListenerServerLifecycle();
public static final TeleServerManager TELE_SERVER = new TeleServerManager();

/**
* Manager for the state of the GUI.
Expand Down Expand Up @@ -118,6 +119,10 @@ public static void startBackgroundTasks() {
/* if (Globals.prefs.getTelemetryPreferences().shouldCollectTelemetry() && !GraphicsEnvironment.isHeadless()) {
startTelemetryClient();
} */
TelePreferences telePreferences = prefs.getTelePreferences();
if (telePreferences.shouldUseTeleServer()) {
Globals.TELE_SERVER.openAndStart(new CLIMessageHandler(prefs), telePreferences.getPort());
}
}

private static void stopTelemetryClient() {
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/org/jabref/gui/JabRefExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class JabRefExecutorService {

private final Timer timer = new Timer("timer", true);

private Thread remoteThread;
private Thread teleThread;

private JabRefExecutorService() {
}
Expand Down Expand Up @@ -117,19 +117,19 @@ public void executeInterruptableTaskAndWait(Runnable runnable) {
}
}

public void manageRemoteThread(Thread thread) {
if (this.remoteThread != null) {
public void startTeleThread(Thread thread) {
if (this.teleThread != null) {
throw new IllegalStateException("Remote thread is already attached");
} else {
this.remoteThread = thread;
remoteThread.start();
this.teleThread = thread;
teleThread.start();
}
}

public void stopRemoteThread() {
if (remoteThread != null) {
remoteThread.interrupt();
remoteThread = null;
public void stopTeleThread() {
if (teleThread != null) {
teleThread.interrupt();
teleThread = null;
}
}

Expand All @@ -141,8 +141,7 @@ public void submit(TimerTask timerTask, long millisecondsDelay) {
* Shuts everything down. After termination, this method returns.
*/
public void shutdownEverything() {
// kill the remote thread
stopRemoteThread();
stopTeleThread();

gracefullyShutdown(this.executorService);
gracefullyShutdown(this.lowPriorityExecutorService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.Globals;
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.gui.remote.JabRefMessageHandler;
import org.jabref.gui.tele.CLIMessageHandler;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyPreferences;
Expand All @@ -30,8 +30,8 @@
import org.jabref.logic.net.ssl.SSLCertificate;
import org.jabref.logic.net.ssl.SSLPreferences;
import org.jabref.logic.net.ssl.TrustStoreManager;
import org.jabref.logic.remote.RemotePreferences;
import org.jabref.logic.remote.RemoteUtil;
import org.jabref.logic.tele.TelePreferences;
import org.jabref.logic.tele.TeleUtil;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.PreferencesService;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class NetworkTabViewModel implements PreferenceTabViewModel {

private final DialogService dialogService;
private final PreferencesService preferences;
private final RemotePreferences remotePreferences;
private final TelePreferences remotePreferences;
private final ProxyPreferences proxyPreferences;
private final ProxyPreferences backupProxyPreferences;
private final SSLPreferences sslPreferences;
Expand All @@ -78,7 +78,7 @@ public class NetworkTabViewModel implements PreferenceTabViewModel {
public NetworkTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
this.remotePreferences = preferences.getRemotePreferences();
this.remotePreferences = preferences.getTelePreferences();
this.proxyPreferences = preferences.getProxyPreferences();
this.sslPreferences = preferences.getSSLPreferences();

Expand All @@ -95,7 +95,7 @@ public NetworkTabViewModel(DialogService dialogService, PreferencesService prefe
input -> {
try {
int portNumber = Integer.parseInt(remotePortProperty().getValue());
return RemoteUtil.isUserPort(portNumber);
return TeleUtil.isUserPort(portNumber);
} catch (NumberFormatException ex) {
return false;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public NetworkTabViewModel(DialogService dialogService, PreferencesService prefe
}

public void setValues() {
remoteServerProperty.setValue(remotePreferences.useRemoteServer());
remoteServerProperty.setValue(remotePreferences.shouldUseTeleServer());
remotePortProperty.setValue(String.valueOf(remotePreferences.getPort()));

setProxyValues();
Expand Down Expand Up @@ -188,7 +188,7 @@ public void storeSettings() {
}

private void storeRemoteSettings() {
RemotePreferences newRemotePreferences = new RemotePreferences(
TelePreferences newRemotePreferences = new TelePreferences(
remotePreferences.getPort(),
remoteServerProperty.getValue()
);
Expand All @@ -200,11 +200,11 @@ private void storeRemoteSettings() {
});

if (remoteServerProperty.getValue()) {
remotePreferences.setUseRemoteServer(true);
Globals.REMOTE_LISTENER.openAndStart(new JabRefMessageHandler(), remotePreferences.getPort(), preferences);
remotePreferences.setShouldUseTeleServer(true);
Globals.TELE_SERVER.openAndStart(new CLIMessageHandler(preferences), remotePreferences.getPort());
} else {
remotePreferences.setUseRemoteServer(false);
Globals.REMOTE_LISTENER.stop();
remotePreferences.setShouldUseTeleServer(false);
Globals.TELE_SERVER.stop();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.gui.remote;
package org.jabref.gui.tele;

import java.util.List;

Expand All @@ -7,18 +7,24 @@
import org.jabref.cli.ArgumentProcessor;
import org.jabref.gui.JabRefGUI;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.remote.server.MessageHandler;
import org.jabref.logic.tele.server.TeleMessageHandler;
import org.jabref.preferences.PreferencesService;

import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JabRefMessageHandler implements MessageHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefMessageHandler.class);
public class CLIMessageHandler implements TeleMessageHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(CLIMessageHandler.class);

private final PreferencesService preferencesService;

public CLIMessageHandler(PreferencesService preferencesService) {
this.preferencesService = preferencesService;
}

@Override
public void handleCommandLineArguments(String[] message, PreferencesService preferencesService) {
public void handleCommandLineArguments(String[] message) {
try {
ArgumentProcessor argumentProcessor = new ArgumentProcessor(message, ArgumentProcessor.Mode.REMOTE_START, preferencesService);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jabref.logic.remote.shared;
package org.jabref.logic.tele;

public enum RemoteMessage {
public enum TeleMessage {
/**
* Send command line arguments. The message content is of type {@code String[]}.
*/
Expand Down
Loading