forked from j62/ctbrec
Save column order in tables
This commit is contained in:
parent
dc30f7da51
commit
915be1d4fc
|
@ -34,6 +34,7 @@ import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
|
import ctbrec.Settings;
|
||||||
import ctbrec.StringUtil;
|
import ctbrec.StringUtil;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import ctbrec.sites.mfc.MyFreeCams;
|
import ctbrec.sites.mfc.MyFreeCams;
|
||||||
|
@ -106,9 +107,9 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
setText("Tabular");
|
setText("Tabular");
|
||||||
setClosable(false);
|
setClosable(false);
|
||||||
createGui();
|
createGui();
|
||||||
|
restoreState();
|
||||||
loadData();
|
loadData();
|
||||||
initUpdateService();
|
initUpdateService();
|
||||||
restoreState();
|
|
||||||
filter(filterInput.getText());
|
filter(filterInput.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,38 +213,47 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
popup.hide();
|
popup.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
table.getColumns().addListener((ListChangeListener<TableColumn<?, ?>>)(e -> saveState()));
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
TableColumn<ModelTableRow, Number> uid = createTableColumn("UID", 65, idx++);
|
TableColumn<ModelTableRow, Number> uid = createTableColumn("UID", 65, idx++);
|
||||||
|
uid.setId("uid");
|
||||||
uid.setCellValueFactory(cdf -> cdf.getValue().uidProperty());
|
uid.setCellValueFactory(cdf -> cdf.getValue().uidProperty());
|
||||||
addTableColumnIfEnabled(uid);
|
addTableColumnIfEnabled(uid);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> name = createTableColumn("Name", 200, idx++);
|
TableColumn<ModelTableRow, String> name = createTableColumn("Name", 200, idx++);
|
||||||
|
name.setId("name");
|
||||||
name.setCellValueFactory(cdf -> cdf.getValue().nameProperty());
|
name.setCellValueFactory(cdf -> cdf.getValue().nameProperty());
|
||||||
addTableColumnIfEnabled(name);
|
addTableColumnIfEnabled(name);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> state = createTableColumn("State", 130, idx++);
|
TableColumn<ModelTableRow, String> state = createTableColumn("State", 130, idx++);
|
||||||
|
state.setId("state");
|
||||||
state.setCellValueFactory(cdf -> cdf.getValue().stateProperty());
|
state.setCellValueFactory(cdf -> cdf.getValue().stateProperty());
|
||||||
addTableColumnIfEnabled(state);
|
addTableColumnIfEnabled(state);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, Boolean> hd = createTableColumn("HD", 130, idx++);
|
TableColumn<ModelTableRow, Boolean> hd = createTableColumn("HD", 130, idx++);
|
||||||
|
hd.setId("hd");
|
||||||
hd.setCellValueFactory(cdf -> cdf.getValue().hdProperty());
|
hd.setCellValueFactory(cdf -> cdf.getValue().hdProperty());
|
||||||
addTableColumnIfEnabled(hd);
|
addTableColumnIfEnabled(hd);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, Boolean> webrtc = createTableColumn("webrtc", 130, idx++);
|
TableColumn<ModelTableRow, Boolean> webrtc = createTableColumn("webrtc", 130, idx++);
|
||||||
|
webrtc.setId("webrtc");
|
||||||
webrtc.setCellValueFactory(cdf -> cdf.getValue().webrtcProperty());
|
webrtc.setCellValueFactory(cdf -> cdf.getValue().webrtcProperty());
|
||||||
addTableColumnIfEnabled(webrtc);
|
addTableColumnIfEnabled(webrtc);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, Number> flags = createTableColumn("Flags", 75, idx++);
|
TableColumn<ModelTableRow, Number> flags = createTableColumn("Flags", 75, idx++);
|
||||||
|
flags.setId("flags");
|
||||||
flags.setCellValueFactory(cdf -> cdf.getValue().flagsProperty());
|
flags.setCellValueFactory(cdf -> cdf.getValue().flagsProperty());
|
||||||
addTableColumnIfEnabled(flags);
|
addTableColumnIfEnabled(flags);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, Number> camscore = createTableColumn("Score", 75, idx++);
|
TableColumn<ModelTableRow, Number> camscore = createTableColumn("Score", 75, idx++);
|
||||||
|
camscore.setId("camscore");
|
||||||
camscore.setCellValueFactory(cdf -> cdf.getValue().camScoreProperty());
|
camscore.setCellValueFactory(cdf -> cdf.getValue().camScoreProperty());
|
||||||
addTableColumnIfEnabled(camscore);
|
addTableColumnIfEnabled(camscore);
|
||||||
|
|
||||||
// this is always 0, use https://api.myfreecams.com/missmfc and https://api.myfreecams.com/missmfc/online
|
// this is always 0, use https://api.myfreecams.com/missmfc and https://api.myfreecams.com/missmfc/online
|
||||||
// TableColumn<SessionState, Number> missMfc = createTableColumn("Miss MFC", 75, idx++);
|
// TableColumn<SessionState, Number> missMfc = createTableColumn("Miss MFC", 75, idx++);
|
||||||
|
// missMfc.setId("missMfc");
|
||||||
// missMfc.setCellValueFactory(cdf -> {
|
// missMfc.setCellValueFactory(cdf -> {
|
||||||
// Integer mmfc = Optional.ofNullable(cdf.getValue().getM()).map(m -> m.getMissmfc()).orElse(-1);
|
// Integer mmfc = Optional.ofNullable(cdf.getValue().getM()).map(m -> m.getMissmfc()).orElse(-1);
|
||||||
// return new SimpleIntegerProperty(mmfc);
|
// return new SimpleIntegerProperty(mmfc);
|
||||||
|
@ -251,34 +261,42 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
// addTableColumnIfEnabled(missMfc);
|
// addTableColumnIfEnabled(missMfc);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> newModel = createTableColumn("New", 60, idx++);
|
TableColumn<ModelTableRow, String> newModel = createTableColumn("New", 60, idx++);
|
||||||
|
newModel.setId("newModel");
|
||||||
newModel.setCellValueFactory(cdf -> cdf.getValue().newModelProperty());
|
newModel.setCellValueFactory(cdf -> cdf.getValue().newModelProperty());
|
||||||
addTableColumnIfEnabled(newModel);
|
addTableColumnIfEnabled(newModel);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> ethnic = createTableColumn("Ethnicity", 130, idx++);
|
TableColumn<ModelTableRow, String> ethnic = createTableColumn("Ethnicity", 130, idx++);
|
||||||
|
ethnic.setId("ethnic");
|
||||||
ethnic.setCellValueFactory(cdf -> cdf.getValue().ethnicityProperty());
|
ethnic.setCellValueFactory(cdf -> cdf.getValue().ethnicityProperty());
|
||||||
addTableColumnIfEnabled(ethnic);
|
addTableColumnIfEnabled(ethnic);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> country = createTableColumn("Country", 160, idx++);
|
TableColumn<ModelTableRow, String> country = createTableColumn("Country", 160, idx++);
|
||||||
|
country.setId("country");
|
||||||
country.setCellValueFactory(cdf -> cdf.getValue().countryProperty());
|
country.setCellValueFactory(cdf -> cdf.getValue().countryProperty());
|
||||||
addTableColumnIfEnabled(country);
|
addTableColumnIfEnabled(country);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> continent = createTableColumn("Continent", 100, idx++);
|
TableColumn<ModelTableRow, String> continent = createTableColumn("Continent", 100, idx++);
|
||||||
|
continent.setId("continent");
|
||||||
continent.setCellValueFactory(cdf -> cdf.getValue().continentProperty());
|
continent.setCellValueFactory(cdf -> cdf.getValue().continentProperty());
|
||||||
addTableColumnIfEnabled(continent);
|
addTableColumnIfEnabled(continent);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> occupation = createTableColumn("Occupation", 160, idx++);
|
TableColumn<ModelTableRow, String> occupation = createTableColumn("Occupation", 160, idx++);
|
||||||
|
occupation.setId("occupation");
|
||||||
occupation.setCellValueFactory(cdf -> cdf.getValue().occupationProperty());
|
occupation.setCellValueFactory(cdf -> cdf.getValue().occupationProperty());
|
||||||
addTableColumnIfEnabled(occupation);
|
addTableColumnIfEnabled(occupation);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> tags = createTableColumn("Tags", 300, idx++);
|
TableColumn<ModelTableRow, String> tags = createTableColumn("Tags", 300, idx++);
|
||||||
|
tags.setId("tags");
|
||||||
tags.setCellValueFactory(cdf -> cdf.getValue().tagsProperty());
|
tags.setCellValueFactory(cdf -> cdf.getValue().tagsProperty());
|
||||||
addTableColumnIfEnabled(tags);
|
addTableColumnIfEnabled(tags);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> blurp = createTableColumn("Blurp", 300, idx++);
|
TableColumn<ModelTableRow, String> blurp = createTableColumn("Blurp", 300, idx++);
|
||||||
|
blurp.setId("blurp");
|
||||||
blurp.setCellValueFactory(cdf -> cdf.getValue().blurpProperty());
|
blurp.setCellValueFactory(cdf -> cdf.getValue().blurpProperty());
|
||||||
addTableColumnIfEnabled(blurp);
|
addTableColumnIfEnabled(blurp);
|
||||||
|
|
||||||
TableColumn<ModelTableRow, String> topic = createTableColumn("Topic", 600, idx);
|
TableColumn<ModelTableRow, String> topic = createTableColumn("Topic", 600, idx);
|
||||||
|
topic.setId("topic");
|
||||||
topic.setCellValueFactory(cdf -> cdf.getValue().topicProperty());
|
topic.setCellValueFactory(cdf -> cdf.getValue().topicProperty());
|
||||||
addTableColumnIfEnabled(topic);
|
addTableColumnIfEnabled(topic);
|
||||||
|
|
||||||
|
@ -534,6 +552,7 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
File file = new File(Config.getInstance().getConfigDir(), "mfc-models.json");
|
File file = new File(Config.getInstance().getConfigDir(), "mfc-models.json");
|
||||||
Files.write(file.toPath(), data.toString(2).getBytes(UTF_8), CREATE, WRITE);
|
Files.write(file.toPath(), data.toString(2).getBytes(UTF_8), CREATE, WRITE);
|
||||||
|
saveState();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("Couldn't write mfc models table data: {}", e.getMessage());
|
LOG.debug("Couldn't write mfc models table data: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -574,19 +593,32 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveState() {
|
private void saveState() {
|
||||||
|
Settings settings = Config.getInstance().getSettings();
|
||||||
if (!table.getSortOrder().isEmpty()) {
|
if (!table.getSortOrder().isEmpty()) {
|
||||||
TableColumn<ModelTableRow, ?> col = table.getSortOrder().get(0);
|
TableColumn<ModelTableRow, ?> col = table.getSortOrder().get(0);
|
||||||
Config.getInstance().getSettings().mfcModelsTableSortColumn = col.getText();
|
settings.mfcModelsTableSortColumn = col.getText();
|
||||||
Config.getInstance().getSettings().mfcModelsTableSortType = col.getSortType().toString();
|
settings.mfcModelsTableSortType = col.getSortType().toString();
|
||||||
}
|
}
|
||||||
double[] columnWidths = new double[table.getColumns().size()];
|
int size = table.getColumns().size();
|
||||||
|
double[] columnWidths = new double[size];
|
||||||
|
String[] columnIds = new String[size];
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
columnWidths[i] = table.getColumns().get(i).getWidth();
|
columnWidths[i] = table.getColumns().get(i).getWidth();
|
||||||
|
columnIds[i] = table.getColumns().get(i).getId();
|
||||||
}
|
}
|
||||||
Config.getInstance().getSettings().mfcModelsTableColumnWidths = columnWidths;
|
settings.mfcModelsTableColumnWidths = columnWidths;
|
||||||
|
settings.mfcModelsTableColumnIds = columnIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
private void restoreState() {
|
||||||
|
restoreColumnOrder();
|
||||||
|
restoreColumnWidths();
|
||||||
|
restoreSorting();
|
||||||
|
|
||||||
|
filterInput.setText(Config.getInstance().getSettings().mfcModelsTableFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreSorting() {
|
||||||
String sortCol = Config.getInstance().getSettings().mfcModelsTableSortColumn;
|
String sortCol = Config.getInstance().getSettings().mfcModelsTableSortColumn;
|
||||||
if (StringUtil.isNotBlank(sortCol)) {
|
if (StringUtil.isNotBlank(sortCol)) {
|
||||||
for (TableColumn<ModelTableRow, ?> col : table.getColumns()) {
|
for (TableColumn<ModelTableRow, ?> col : table.getColumns()) {
|
||||||
|
@ -598,15 +630,29 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnOrder() {
|
||||||
|
String[] columnIds = Config.getInstance().getSettings().mfcModelsTableColumnIds;
|
||||||
|
ObservableList<TableColumn<ModelTableRow,?>> tableColumns = table.getColumns();
|
||||||
|
for (int i = 0; i < columnIds.length; i++) {
|
||||||
|
for (int j = 0; j < table.getColumns().size(); j++) {
|
||||||
|
if(Objects.equals(columnIds[i], tableColumns.get(j).getId())) {
|
||||||
|
TableColumn<ModelTableRow, ?> col = tableColumns.get(j);
|
||||||
|
tableColumns.remove(j); // NOSONAR
|
||||||
|
tableColumns.add(i, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnWidths() {
|
||||||
double[] columnWidths = Config.getInstance().getSettings().mfcModelsTableColumnWidths;
|
double[] columnWidths = Config.getInstance().getSettings().mfcModelsTableColumnWidths;
|
||||||
if (columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
if (columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
table.getColumns().get(i).setPrefWidth(columnWidths[i]);
|
table.getColumns().get(i).setPrefWidth(columnWidths[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterInput.setText(Config.getInstance().getSettings().mfcModelsTableFilter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListChangeListener<TableColumn<ModelTableRow, ?>> createSortOrderChangedListener() {
|
private ListChangeListener<TableColumn<ModelTableRow, ?>> createSortOrderChangedListener() {
|
||||||
|
|
|
@ -155,26 +155,31 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
name.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("displayName"));
|
name.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("displayName"));
|
||||||
name.setCellFactory(new ClickableCellFactory<>());
|
name.setCellFactory(new ClickableCellFactory<>());
|
||||||
name.setEditable(false);
|
name.setEditable(false);
|
||||||
|
name.setId("name");
|
||||||
TableColumn<JavaFxModel, String> url = new TableColumn<>("URL");
|
TableColumn<JavaFxModel, String> url = new TableColumn<>("URL");
|
||||||
url.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("url"));
|
url.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("url"));
|
||||||
url.setCellFactory(new ClickableCellFactory<>());
|
url.setCellFactory(new ClickableCellFactory<>());
|
||||||
url.setPrefWidth(400);
|
url.setPrefWidth(400);
|
||||||
url.setEditable(false);
|
url.setEditable(false);
|
||||||
|
url.setId("url");
|
||||||
TableColumn<JavaFxModel, Boolean> online = new TableColumn<>("Online");
|
TableColumn<JavaFxModel, Boolean> online = new TableColumn<>("Online");
|
||||||
online.setCellValueFactory(cdf -> cdf.getValue().getOnlineProperty());
|
online.setCellValueFactory(cdf -> cdf.getValue().getOnlineProperty());
|
||||||
online.setCellFactory(CheckBoxTableCell.forTableColumn(online));
|
online.setCellFactory(CheckBoxTableCell.forTableColumn(online));
|
||||||
online.setPrefWidth(100);
|
online.setPrefWidth(100);
|
||||||
online.setEditable(false);
|
online.setEditable(false);
|
||||||
|
online.setId("online");
|
||||||
TableColumn<JavaFxModel, Boolean> recording = new TableColumn<>("Recording");
|
TableColumn<JavaFxModel, Boolean> recording = new TableColumn<>("Recording");
|
||||||
recording.setCellValueFactory(cdf -> cdf.getValue().getRecordingProperty());
|
recording.setCellValueFactory(cdf -> cdf.getValue().getRecordingProperty());
|
||||||
recording.setCellFactory(CheckBoxTableCell.forTableColumn(recording));
|
recording.setCellFactory(CheckBoxTableCell.forTableColumn(recording));
|
||||||
recording.setPrefWidth(100);
|
recording.setPrefWidth(100);
|
||||||
recording.setEditable(false);
|
recording.setEditable(false);
|
||||||
|
recording.setId("recording");
|
||||||
TableColumn<JavaFxModel, Boolean> paused = new TableColumn<>("Paused");
|
TableColumn<JavaFxModel, Boolean> paused = new TableColumn<>("Paused");
|
||||||
paused.setCellValueFactory(cdf -> cdf.getValue().getPausedProperty());
|
paused.setCellValueFactory(cdf -> cdf.getValue().getPausedProperty());
|
||||||
paused.setCellFactory(CheckBoxTableCell.forTableColumn(paused));
|
paused.setCellFactory(CheckBoxTableCell.forTableColumn(paused));
|
||||||
paused.setPrefWidth(100);
|
paused.setPrefWidth(100);
|
||||||
paused.setEditable(true);
|
paused.setEditable(true);
|
||||||
|
paused.setId("paused");
|
||||||
TableColumn<JavaFxModel, Number> priority = new TableColumn<>("Priority");
|
TableColumn<JavaFxModel, Number> priority = new TableColumn<>("Priority");
|
||||||
priority.setCellValueFactory(param -> param.getValue().getPriorityProperty());
|
priority.setCellValueFactory(param -> param.getValue().getPriorityProperty());
|
||||||
priority.setCellFactory(new PriorityCellFactory());
|
priority.setCellFactory(new PriorityCellFactory());
|
||||||
|
@ -183,16 +188,19 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
priority.setOnEditStart(e -> cellEditing = true);
|
priority.setOnEditStart(e -> cellEditing = true);
|
||||||
priority.setOnEditCommit(this::onUpdatePriority);
|
priority.setOnEditCommit(this::onUpdatePriority);
|
||||||
priority.setOnEditCancel(e -> cellEditing = false);
|
priority.setOnEditCancel(e -> cellEditing = false);
|
||||||
|
priority.setId("priority");
|
||||||
TableColumn<JavaFxModel, Instant> lastSeen = new TableColumn<>("last seen");
|
TableColumn<JavaFxModel, Instant> lastSeen = new TableColumn<>("last seen");
|
||||||
lastSeen.setCellValueFactory(cdf -> cdf.getValue().lastSeenProperty());
|
lastSeen.setCellValueFactory(cdf -> cdf.getValue().lastSeenProperty());
|
||||||
lastSeen.setCellFactory(new DateTimeCellFactory<JavaFxModel>());
|
lastSeen.setCellFactory(new DateTimeCellFactory<JavaFxModel>());
|
||||||
lastSeen.setPrefWidth(150);
|
lastSeen.setPrefWidth(150);
|
||||||
lastSeen.setEditable(false);
|
lastSeen.setEditable(false);
|
||||||
|
lastSeen.setId("lastSeen");
|
||||||
TableColumn<JavaFxModel, Instant> lastRecorded = new TableColumn<>("last recorded");
|
TableColumn<JavaFxModel, Instant> lastRecorded = new TableColumn<>("last recorded");
|
||||||
lastRecorded.setCellValueFactory(cdf -> cdf.getValue().lastRecordedProperty());
|
lastRecorded.setCellValueFactory(cdf -> cdf.getValue().lastRecordedProperty());
|
||||||
lastRecorded.setCellFactory(new DateTimeCellFactory<JavaFxModel>());
|
lastRecorded.setCellFactory(new DateTimeCellFactory<JavaFxModel>());
|
||||||
lastRecorded.setPrefWidth(150);
|
lastRecorded.setPrefWidth(150);
|
||||||
lastRecorded.setEditable(false);
|
lastRecorded.setEditable(false);
|
||||||
|
lastRecorded.setId("lastRecorded");
|
||||||
TableColumn<JavaFxModel, String> notes = new TableColumn<>("Notes");
|
TableColumn<JavaFxModel, String> notes = new TableColumn<>("Notes");
|
||||||
notes.setCellValueFactory(cdf -> {
|
notes.setCellValueFactory(cdf -> {
|
||||||
JavaFxModel m = cdf.getValue();
|
JavaFxModel m = cdf.getValue();
|
||||||
|
@ -216,6 +224,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
});
|
});
|
||||||
notes.setPrefWidth(400);
|
notes.setPrefWidth(400);
|
||||||
notes.setEditable(false);
|
notes.setEditable(false);
|
||||||
|
notes.setId("notes");
|
||||||
table.getColumns().addAll(preview, name, url, online, recording, paused, priority, lastSeen, lastRecorded, notes);
|
table.getColumns().addAll(preview, name, url, online, recording, paused, priority, lastSeen, lastRecorded, notes);
|
||||||
table.setItems(observableModels);
|
table.setItems(observableModels);
|
||||||
table.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
|
table.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
|
||||||
|
@ -729,14 +738,24 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
Config.getInstance().getSettings().recordedModelsSortColumn = col.getText();
|
Config.getInstance().getSettings().recordedModelsSortColumn = col.getText();
|
||||||
Config.getInstance().getSettings().recordedModelsSortType = col.getSortType().toString();
|
Config.getInstance().getSettings().recordedModelsSortType = col.getSortType().toString();
|
||||||
}
|
}
|
||||||
double[] columnWidths = new double[table.getColumns().size()];
|
int columns = table.getColumns().size();
|
||||||
|
double[] columnWidths = new double[columns];
|
||||||
|
String[] columnIds = new String[columns];
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
columnWidths[i] = table.getColumns().get(i).getWidth();
|
columnWidths[i] = table.getColumns().get(i).getWidth();
|
||||||
|
columnIds[i] = table.getColumns().get(i).getId();
|
||||||
}
|
}
|
||||||
Config.getInstance().getSettings().recordedModelsColumnWidths = columnWidths;
|
Config.getInstance().getSettings().recordedModelsColumnWidths = columnWidths;
|
||||||
|
Config.getInstance().getSettings().recordedModelsColumnIds = columnIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
private void restoreState() {
|
||||||
|
restoreColumnOrder();
|
||||||
|
restoreColumnWidths();
|
||||||
|
restoreSorting();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreSorting() {
|
||||||
String sortCol = Config.getInstance().getSettings().recordedModelsSortColumn;
|
String sortCol = Config.getInstance().getSettings().recordedModelsSortColumn;
|
||||||
if (StringUtil.isNotBlank(sortCol)) {
|
if (StringUtil.isNotBlank(sortCol)) {
|
||||||
for (TableColumn<JavaFxModel, ?> col : table.getColumns()) {
|
for (TableColumn<JavaFxModel, ?> col : table.getColumns()) {
|
||||||
|
@ -748,7 +767,23 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnOrder() {
|
||||||
|
String[] columnIds = Config.getInstance().getSettings().recordedModelsColumnIds;
|
||||||
|
ObservableList<TableColumn<JavaFxModel,?>> columns = table.getColumns();
|
||||||
|
for (int i = 0; i < columnIds.length; i++) {
|
||||||
|
for (int j = 0; j < table.getColumns().size(); j++) {
|
||||||
|
if(Objects.equals(columnIds[i], columns.get(j).getId())) {
|
||||||
|
TableColumn<JavaFxModel, ?> col = columns.get(j);
|
||||||
|
columns.remove(j); // NOSONAR
|
||||||
|
columns.add(i, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnWidths() {
|
||||||
double[] columnWidths = Config.getInstance().getSettings().recordedModelsColumnWidths;
|
double[] columnWidths = Config.getInstance().getSettings().recordedModelsColumnWidths;
|
||||||
if (columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
if (columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
|
|
|
@ -125,9 +125,11 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
||||||
table.setEditable(false);
|
table.setEditable(false);
|
||||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
TableColumn<JavaFxRecording, String> name = new TableColumn<>("Model");
|
TableColumn<JavaFxRecording, String> name = new TableColumn<>("Model");
|
||||||
|
name.setId("name");
|
||||||
name.setPrefWidth(200);
|
name.setPrefWidth(200);
|
||||||
name.setCellValueFactory(cdf -> new SimpleStringProperty(cdf.getValue().getModel().getName()));
|
name.setCellValueFactory(cdf -> new SimpleStringProperty(cdf.getValue().getModel().getName()));
|
||||||
TableColumn<JavaFxRecording, Instant> date = new TableColumn<>("Date");
|
TableColumn<JavaFxRecording, Instant> date = new TableColumn<>("Date");
|
||||||
|
date.setId("date");
|
||||||
date.setCellValueFactory(cdf -> {
|
date.setCellValueFactory(cdf -> {
|
||||||
Instant instant = cdf.getValue().getStartDate();
|
Instant instant = cdf.getValue().getStartDate();
|
||||||
return new SimpleObjectProperty<Instant>(instant);
|
return new SimpleObjectProperty<Instant>(instant);
|
||||||
|
@ -135,12 +137,15 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
||||||
date.setCellFactory(new DateTimeCellFactory<JavaFxRecording>());
|
date.setCellFactory(new DateTimeCellFactory<JavaFxRecording>());
|
||||||
date.setPrefWidth(200);
|
date.setPrefWidth(200);
|
||||||
TableColumn<JavaFxRecording, String> status = new TableColumn<>("Status");
|
TableColumn<JavaFxRecording, String> status = new TableColumn<>("Status");
|
||||||
|
status.setId("status");
|
||||||
status.setCellValueFactory(cdf -> cdf.getValue().getStatusProperty());
|
status.setCellValueFactory(cdf -> cdf.getValue().getStatusProperty());
|
||||||
status.setPrefWidth(300);
|
status.setPrefWidth(300);
|
||||||
TableColumn<JavaFxRecording, String> progress = new TableColumn<>("Progress");
|
TableColumn<JavaFxRecording, String> progress = new TableColumn<>("Progress");
|
||||||
|
progress.setId("progress");
|
||||||
progress.setCellValueFactory(cdf -> cdf.getValue().getProgressProperty());
|
progress.setCellValueFactory(cdf -> cdf.getValue().getProgressProperty());
|
||||||
progress.setPrefWidth(100);
|
progress.setPrefWidth(100);
|
||||||
TableColumn<JavaFxRecording, Number> size = new TableColumn<>("Size");
|
TableColumn<JavaFxRecording, Number> size = new TableColumn<>("Size");
|
||||||
|
size.setId("size");
|
||||||
size.setStyle("-fx-alignment: CENTER-RIGHT;");
|
size.setStyle("-fx-alignment: CENTER-RIGHT;");
|
||||||
size.setPrefWidth(100);
|
size.setPrefWidth(100);
|
||||||
size.setCellValueFactory(cdf -> cdf.getValue().getSizeProperty());
|
size.setCellValueFactory(cdf -> cdf.getValue().getSizeProperty());
|
||||||
|
@ -696,14 +701,24 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
||||||
Config.getInstance().getSettings().recordingsSortColumn = col.getText();
|
Config.getInstance().getSettings().recordingsSortColumn = col.getText();
|
||||||
Config.getInstance().getSettings().recordingsSortType = col.getSortType().toString();
|
Config.getInstance().getSettings().recordingsSortType = col.getSortType().toString();
|
||||||
}
|
}
|
||||||
double[] columnWidths = new double[table.getColumns().size()];
|
int columns = table.getColumns().size();
|
||||||
|
double[] columnWidths = new double[columns];
|
||||||
|
String[] columnIds = new String[columns];
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
columnWidths[i] = table.getColumns().get(i).getWidth();
|
columnWidths[i] = table.getColumns().get(i).getWidth();
|
||||||
|
columnIds[i] = table.getColumns().get(i).getId();
|
||||||
}
|
}
|
||||||
Config.getInstance().getSettings().recordingsColumnWidths = columnWidths;
|
Config.getInstance().getSettings().recordingsColumnWidths = columnWidths;
|
||||||
|
Config.getInstance().getSettings().recordingsColumnIds = columnIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
private void restoreState() {
|
||||||
|
restoreColumnOrder();
|
||||||
|
restoreColumnWidths();
|
||||||
|
restoreSorting();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreSorting() {
|
||||||
String sortCol = Config.getInstance().getSettings().recordingsSortColumn;
|
String sortCol = Config.getInstance().getSettings().recordingsSortColumn;
|
||||||
if(StringUtil.isNotBlank(sortCol)) {
|
if(StringUtil.isNotBlank(sortCol)) {
|
||||||
for (TableColumn<JavaFxRecording, ?> col : table.getColumns()) {
|
for (TableColumn<JavaFxRecording, ?> col : table.getColumns()) {
|
||||||
|
@ -715,7 +730,23 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnOrder() {
|
||||||
|
String[] columnIds = Config.getInstance().getSettings().recordingsColumnIds;
|
||||||
|
ObservableList<TableColumn<JavaFxRecording,?>> columns = table.getColumns();
|
||||||
|
for (int i = 0; i < columnIds.length; i++) {
|
||||||
|
for (int j = 0; j < table.getColumns().size(); j++) {
|
||||||
|
if(Objects.equals(columnIds[i], columns.get(j).getId())) {
|
||||||
|
TableColumn<JavaFxRecording, ?> col = columns.get(j);
|
||||||
|
columns.remove(j); // NOSONAR
|
||||||
|
columns.add(i, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreColumnWidths() {
|
||||||
double[] columnWidths = Config.getInstance().getSettings().recordingsColumnWidths;
|
double[] columnWidths = Config.getInstance().getSettings().recordingsColumnWidths;
|
||||||
if(columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
if(columnWidths != null && columnWidths.length == table.getColumns().size()) {
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class Settings {
|
||||||
public String mfcBaseUrl = "https://www.myfreecams.com";
|
public String mfcBaseUrl = "https://www.myfreecams.com";
|
||||||
public List<String> mfcDisabledModelsTableColumns = new ArrayList<>();
|
public List<String> mfcDisabledModelsTableColumns = new ArrayList<>();
|
||||||
public boolean mfcIgnoreUpscaled = false;
|
public boolean mfcIgnoreUpscaled = false;
|
||||||
|
public String[] mfcModelsTableColumnIds = new String[0];
|
||||||
public double[] mfcModelsTableColumnWidths = new double[0];
|
public double[] mfcModelsTableColumnWidths = new double[0];
|
||||||
public String mfcModelsTableFilter = "";
|
public String mfcModelsTableFilter = "";
|
||||||
public String mfcModelsTableSortColumn = "";
|
public String mfcModelsTableSortColumn = "";
|
||||||
|
@ -98,9 +99,11 @@ public class Settings {
|
||||||
public ProxyType proxyType = ProxyType.DIRECT;
|
public ProxyType proxyType = ProxyType.DIRECT;
|
||||||
public String proxyUser;
|
public String proxyUser;
|
||||||
public double[] recordedModelsColumnWidths = new double[0];
|
public double[] recordedModelsColumnWidths = new double[0];
|
||||||
|
public String[] recordedModelsColumnIds = new String[0];
|
||||||
public String recordedModelsSortColumn = "";
|
public String recordedModelsSortColumn = "";
|
||||||
public String recordedModelsSortType = "";
|
public String recordedModelsSortType = "";
|
||||||
public double[] recordingsColumnWidths = new double[0];
|
public double[] recordingsColumnWidths = new double[0];
|
||||||
|
public String[] recordingsColumnIds = new String[0];
|
||||||
public String recordingsDir = System.getProperty("user.home") + File.separator + "ctbrec";
|
public String recordingsDir = System.getProperty("user.home") + File.separator + "ctbrec";
|
||||||
public DirectoryStructure recordingsDirStructure = DirectoryStructure.FLAT;
|
public DirectoryStructure recordingsDirStructure = DirectoryStructure.FLAT;
|
||||||
public String recordingsSortColumn = "";
|
public String recordingsSortColumn = "";
|
||||||
|
|
Loading…
Reference in New Issue