Replace Find/Replace slider with two CheckBoxes
This commit is contained in:
parent
fabed02f55
commit
6dbf88bea9
|
@ -792,7 +792,7 @@ public class WorldsTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VBox getFindPane() {
|
private VBox getFindPane() {
|
||||||
Console.print("Initializing FindPane", 1, ConsoleType.INFO);
|
Console.print("Showing FindPane", 1, ConsoleType.INFO);
|
||||||
Text findText = new Text("Find Text");
|
Text findText = new Text("Find Text");
|
||||||
findText.setFont(Font.font("Verdana", FontWeight.NORMAL, FontPosture.REGULAR, 12));
|
findText.setFont(Font.font("Verdana", FontWeight.NORMAL, FontPosture.REGULAR, 12));
|
||||||
TextField findInput = new TextField();
|
TextField findInput = new TextField();
|
||||||
|
@ -801,16 +801,13 @@ public class WorldsTab {
|
||||||
replText.setFont(Font.font("Verdana", FontWeight.NORMAL, FontPosture.REGULAR, 12));
|
replText.setFont(Font.font("Verdana", FontWeight.NORMAL, FontPosture.REGULAR, 12));
|
||||||
TextField replInput = new TextField();
|
TextField replInput = new TextField();
|
||||||
|
|
||||||
Slider selSlider = new Slider(-1,1,0);
|
CheckBox nameCheck = new CheckBox("Name");
|
||||||
selSlider.setMajorTickUnit(1);
|
nameCheck.setSelected(true);
|
||||||
selSlider.setMinorTickCount(0);
|
CheckBox valueCheck = new CheckBox("Value");
|
||||||
selSlider.setSnapToTicks(true);
|
valueCheck.setSelected(false);
|
||||||
Text labelTxt = new Text("Label");
|
|
||||||
Text valueTxt = new Text("Value");
|
|
||||||
|
|
||||||
HBox.setHgrow(selSlider, Priority.ALWAYS);
|
HBox.setHgrow(nameCheck, Priority.ALWAYS);
|
||||||
HBox.setHgrow(labelTxt, Priority.ALWAYS);
|
HBox.setHgrow(valueCheck, Priority.ALWAYS);
|
||||||
HBox.setHgrow(valueTxt, Priority.ALWAYS);
|
|
||||||
|
|
||||||
GridPane findBar = new GridPane();
|
GridPane findBar = new GridPane();
|
||||||
|
|
||||||
|
@ -834,7 +831,8 @@ public class WorldsTab {
|
||||||
|
|
||||||
WorldList replaced;
|
WorldList replaced;
|
||||||
final int index = ((TableView<WorldList>)content).getSelectionModel().getSelectedIndex();
|
final int index = ((TableView<WorldList>)content).getSelectionModel().getSelectedIndex();
|
||||||
final double slider = selSlider.getValue();
|
final boolean isName = nameCheck.isSelected();
|
||||||
|
final boolean isValue = valueCheck.isSelected();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
@ -842,9 +840,9 @@ public class WorldsTab {
|
||||||
WorldList item = ((TableView<WorldList>)content).getSelectionModel().getSelectedItem();
|
WorldList item = ((TableView<WorldList>)content).getSelectionModel().getSelectedItem();
|
||||||
if (item.getName().contains(findInput.getCharacters()) || item.getValue().contains(findInput.getCharacters())) {
|
if (item.getName().contains(findInput.getCharacters()) || item.getValue().contains(findInput.getCharacters())) {
|
||||||
WorldTableItem tableItem = new WorldTableItem(((TableView) content).getItems().indexOf(item), item.getName(), item.getValue());
|
WorldTableItem tableItem = new WorldTableItem(((TableView) content).getItems().indexOf(item), item.getName(), item.getValue());
|
||||||
if (selSlider.getValue() >= 0)
|
if (isValue)
|
||||||
item.setValue(item.getValue().replace(findInput.getCharacters(), replInput.getCharacters()));
|
item.setValue(item.getValue().replace(findInput.getCharacters(), replInput.getCharacters()));
|
||||||
if (selSlider.getValue() <= 0)
|
if (isName)
|
||||||
item.setName(item.getName().replace(findInput.getCharacters(), replInput.getCharacters()));
|
item.setName(item.getName().replace(findInput.getCharacters(), replInput.getCharacters()));
|
||||||
Main.setStatusText("Replaced item");
|
Main.setStatusText("Replaced item");
|
||||||
replaced = tableItem;
|
replaced = tableItem;
|
||||||
|
@ -856,8 +854,8 @@ public class WorldsTab {
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
WorldList item = (WorldList)((TableView) content).getItems().get(index);
|
WorldList item = (WorldList)((TableView) content).getItems().get(index);
|
||||||
if (slider >= 0) item.setValue(replaced.getValue());
|
if (isValue) item.setValue(replaced.getValue());
|
||||||
if (slider <= 0) item.setName(replaced.getName());
|
if (isName) item.setName(replaced.getName());
|
||||||
((TableView) content).refresh();
|
((TableView) content).refresh();
|
||||||
setSaved(false);
|
setSaved(false);
|
||||||
}
|
}
|
||||||
|
@ -869,7 +867,8 @@ public class WorldsTab {
|
||||||
commandStack.doCommand(new Command() {
|
commandStack.doCommand(new Command() {
|
||||||
|
|
||||||
final List<WorldTableItem> replaced = new ArrayList<>();
|
final List<WorldTableItem> replaced = new ArrayList<>();
|
||||||
final double slider = selSlider.getValue();
|
final boolean isName = nameCheck.isSelected();
|
||||||
|
final boolean isValue = valueCheck.isSelected();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
@ -879,8 +878,8 @@ public class WorldsTab {
|
||||||
if (item.getName().contains(findInput.getCharacters()) || item.getValue().contains(findInput.getCharacters())) {
|
if (item.getName().contains(findInput.getCharacters()) || item.getValue().contains(findInput.getCharacters())) {
|
||||||
count++;
|
count++;
|
||||||
WorldTableItem tableItem = new WorldTableItem(((TableView)content).getItems().indexOf(item), item.getName(), item.getValue());
|
WorldTableItem tableItem = new WorldTableItem(((TableView)content).getItems().indexOf(item), item.getName(), item.getValue());
|
||||||
if (selSlider.getValue() >= 0) item.setValue(item.getValue().replace(findInput.getCharacters(), replInput.getCharacters()));
|
if (isValue) item.setValue(item.getValue().replace(findInput.getCharacters(), replInput.getCharacters()));
|
||||||
if (selSlider.getValue() <= 0) item.setName(item.getName().replace(findInput.getCharacters(), replInput.getCharacters()));
|
if (isName) item.setName(item.getName().replace(findInput.getCharacters(), replInput.getCharacters()));
|
||||||
replaced.add(tableItem);
|
replaced.add(tableItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -893,8 +892,8 @@ public class WorldsTab {
|
||||||
public void undo() {
|
public void undo() {
|
||||||
for (WorldTableItem tableItem : replaced) {
|
for (WorldTableItem tableItem : replaced) {
|
||||||
WorldList item = (WorldList)((TableView)content).getItems().get(tableItem.getIndex());
|
WorldList item = (WorldList)((TableView)content).getItems().get(tableItem.getIndex());
|
||||||
if (slider >= 0) item.setValue(tableItem.getValue());
|
if (valueCheck.isSelected()) item.setValue(tableItem.getValue());
|
||||||
if (slider <= 0) item.setName(tableItem.getName());
|
if (nameCheck.isSelected()) item.setName(tableItem.getName());
|
||||||
}
|
}
|
||||||
((TableView) content).refresh();
|
((TableView) content).refresh();
|
||||||
setSaved(false);
|
setSaved(false);
|
||||||
|
@ -912,7 +911,7 @@ public class WorldsTab {
|
||||||
findBar.add(replText, 0, 1);
|
findBar.add(replText, 0, 1);
|
||||||
findBar.add(replInput, 1, 1);
|
findBar.add(replInput, 1, 1);
|
||||||
|
|
||||||
findBar.add(new HBox(labelTxt, selSlider, valueTxt), 0, 2);
|
findBar.add(new HBox(nameCheck, valueCheck), 0, 2);
|
||||||
findBar.add(btns, 1, 2);
|
findBar.add(btns, 1, 2);
|
||||||
|
|
||||||
GridPane.setHgrow(findInput, Priority.ALWAYS);
|
GridPane.setHgrow(findInput, Priority.ALWAYS);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user