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