<commit_before>package controllers;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;

import data.Favourites;
import data.SampServer;
import entities.Player;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TextInputDialog;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import query.SampQuery;
import util.GTA;

public abstract class ServerListControllerMain implements ViewController
{

	@FXML
	private TextField						addressTextField;

	@FXML
	protected TableView<SampServer>			tableView;

	@FXML
	private TableColumn<SampServer, String>	columnPlayers;

	@FXML
	private TableView<Player>				playerTable;

	@FXML
	protected Label							playerCount;

	@FXML
	protected Label							slotCount;

	@FXML
	protected Label							serverCount;

	@FXML
	private TextField						serverAddress;

	@FXML
	private Label							serverLagcomp;

	@FXML
	private Label							serverPing;

	@FXML
	private Label							serverPassword;

	private static Thread					threadGetPlayers;

	/**
	 * The menu that will be dsiplayed, when a user selects 1 .. n servers and right clicks the table
	 */
	protected ContextMenu					menu;

	protected MenuItem						addToFavourites;

	protected MenuItem						removeFromFavourites;

	private MenuItem						connectItem;

	private MenuItem						copyIpAddressAndPort;

	@FXML
	private TextField						nameFilter;

	@FXML
	private TextField						modeFilter;

	@FXML
	private TextField						languageFilter;

	@FXML
	private ComboBox<String>				versionFilter;

	protected int							playersPlaying	= 0;

	protected int							maxSlots		= 0;

	/* HACK(MSC) This is a little hacky, because it needs 3 lists in order to
	 * keep all data, make sorting possible and make filtering possible. */
	protected ObservableList<SampServer>	servers			= FXCollections.observableArrayList();

	protected FilteredList<SampServer>		filteredServers	= new FilteredList<>(servers);

	protected ObservableList<SampServer>	sortedServers	= FXCollections.observableArrayList();

	@Override
	public void init()
	{
		// TODO(MSC) Improve by including MaxPlayers as Secondary sorting
		// condition
		columnPlayers.setComparator((o1, o2) ->
		{
			final int p1 = Integer.parseInt(o1.replaceAll("[/](.*)", ""));
			final int p2 = Integer.parseInt(o2.replaceAll("[/](.*)", ""));
			return p1 < p2 ? -1 : p1 == p2 ? 0 : 1;
		});
<commit_msg>Remembering address value accross views<commit_after>package controllers;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;

import data.Favourites;
import data.SampServer;
import entities.Player;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TextInputDialog;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import query.SampQuery;
import util.GTA;

public abstract class ServerListControllerMain implements ViewController
{

	@FXML
	private TextField						addressTextField;

	private static SimpleStringProperty		serverAddressProperty	= new SimpleStringProperty();

	@FXML
	protected TableView<SampServer>			tableView;

	@FXML
	private TableColumn<SampServer, String>	columnPlayers;

	@FXML
	private TableView<Player>				playerTable;

	@FXML
	protected Label							playerCount;

	@FXML
	protected Label							slotCount;

	@FXML
	protected Label							serverCount;

	@FXML
	private TextField						serverAddress;

	@FXML
	private Label							serverLagcomp;

	@FXML
	private Label							serverPing;

	@FXML
	private Label							serverPassword;

	private static Thread					threadGetPlayers;

	/**
	 * The menu that will be dsiplayed, when a user selects 1 .. n servers and right clicks the table
	 */
	protected ContextMenu					menu;

	protected MenuItem						addToFavourites;

	protected MenuItem						removeFromFavourites;

	private MenuItem						connectItem;

	private MenuItem						copyIpAddressAndPort;

	@FXML
	private TextField						nameFilter;

	@FXML
	private TextField						modeFilter;

	@FXML
	private TextField						languageFilter;

	@FXML
	private ComboBox<String>				versionFilter;

	protected int							playersPlaying			= 0;

	protected int							maxSlots				= 0;

	/* HACK(MSC) This is a little hacky, because it needs 3 lists in order to
	 * keep all data, make sorting possible and make filtering possible. */
	protected ObservableList<SampServer>	servers					= FXCollections.observableArrayList();

	protected FilteredList<SampServer>		filteredServers			= new FilteredList<>(servers);

	protected ObservableList<SampServer>	sortedServers			= FXCollections.observableArrayList();

	@Override
	public void init()
	{
		addressTextField.textProperty().bindBidirectional(serverAddressProperty);

		// TODO(MSC) Improve by including MaxPlayers as Secondary sorting
		// condition
		columnPlayers.setComparator((o1, o2) ->
		{
			final int p1 = Integer.parseInt(o1.replaceAll("[/](.*)", ""));
			final int p2 = Integer.parseInt(o2.replaceAll("[/](.*)", ""));
			return p1 < p2 ? -1 : p1 == p2 ? 0 : 1;
		});

{'fraction_non_alphanumeric': 0.08644486415807061, 'fraction_numerical': 0.005230277495278221, 'mean_word_length': 4.472178060413355, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5999080', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2100, 'n_words': 521}