add multiple select checked systems
This commit is contained in:
@@ -9,7 +9,6 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.util.converter.NumberStringConverter;
|
||||
import org.controlsfx.control.CheckComboBox;
|
||||
import org.controlsfx.control.MasterDetailPane;
|
||||
import org.slf4j.Logger;
|
||||
@@ -89,6 +88,8 @@ public class PowerPlayController {
|
||||
init();
|
||||
profile = MainController.getProfile();
|
||||
|
||||
historySystems.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
|
||||
cbCurrentPower.setConverter(new PowerStringConverter());
|
||||
cbCurrentPower.setItems(FXCollections.observableArrayList(POWER.values()));
|
||||
cbPower.setConverter(new PowerStringConverter());
|
||||
@@ -180,18 +181,17 @@ public class PowerPlayController {
|
||||
}
|
||||
});
|
||||
tblDetail.setOnDragDetected(new StarSystemDragDetect(tblDetail));
|
||||
NumberStringConverter converter = new NumberStringConverter("#,##0.##");
|
||||
result.addListener((InvalidationListener) i -> {
|
||||
resultCCSumm.setText(getCCSummText(result, getCheckedSystem()));
|
||||
resultCCSumm.setText(getCCSummText(result, getSelectedSystems()));
|
||||
}
|
||||
);
|
||||
detail.addListener((InvalidationListener) i -> {
|
||||
detailCCSumm.setText(getCCSummText(detail, detailSystem));
|
||||
detailCCSumm.setText(getCCSummText(detail, detailSystem != null ? Collections.singleton(detailSystem) : null));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private String getCCSummText(Collection<ResultEntry> collection, Place starSystem){
|
||||
private String getCCSummText(Collection<ResultEntry> collection, Collection<Place> starSystems){
|
||||
String ccFormat = Localization.getString("powerplay.label.summcc");
|
||||
String pwCCFormat = Localization.getString("powerplay.label.cc");
|
||||
PowerStringConverter converter = new PowerStringConverter();
|
||||
@@ -229,8 +229,10 @@ public class PowerPlayController {
|
||||
}
|
||||
}
|
||||
double upkeep = 0;
|
||||
if (hq != null && starSystem != null){
|
||||
upkeep = starSystem.computeUpkeep(hq);
|
||||
if (hq != null && starSystems != null){
|
||||
for (Place starSystem : starSystems) {
|
||||
upkeep += starSystem.computeUpkeep(hq);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -259,6 +261,17 @@ public class PowerPlayController {
|
||||
return ModelFabric.get(checkedSystem.getValue());
|
||||
}
|
||||
|
||||
private Collection<Place> getSelectedSystems() {
|
||||
Collection<Place> places = historySystems.getSelectionModel().getSelectedItems().stream().map(ModelFabric::get).collect(Collectors.toSet());
|
||||
if (places.isEmpty()){
|
||||
Place starSystem = getCheckedSystem();
|
||||
if (starSystem != null){
|
||||
return Collections.singleton(starSystem);
|
||||
}
|
||||
}
|
||||
return places;
|
||||
}
|
||||
|
||||
private void getIntersects(){
|
||||
Place starSystem = getCheckedSystem();
|
||||
Collection<Place> controlls = getControlSystems();
|
||||
@@ -271,9 +284,11 @@ public class PowerPlayController {
|
||||
|
||||
private void getControlling(){
|
||||
final Place starSystem = getCheckedSystem();
|
||||
final Collection<Place> selectedSystems = getSelectedSystems();
|
||||
result.clear();
|
||||
if (starSystem != null){
|
||||
Collection<PowerPlayAnalyzator.IntersectData> controllings = analyzator.getControlling(starSystem);
|
||||
if (starSystem != null || !selectedSystems.isEmpty()){
|
||||
Collection<PowerPlayAnalyzator.IntersectData> controllings =
|
||||
selectedSystems.isEmpty() ? analyzator.getControlling(starSystem) : analyzator.getControlling(selectedSystems);
|
||||
controllings.add(new PowerPlayAnalyzator.IntersectData(starSystem));
|
||||
result.addAll(BindingsHelper.observableList(controllings,d -> new ResultEntry(d, starSystem)));
|
||||
}
|
||||
|
||||
@@ -31,8 +31,12 @@ public class PowerPlayAnalyzator {
|
||||
}
|
||||
|
||||
public Collection<IntersectData> getControlling(Place starSystem){
|
||||
return getControlling(Collections.singleton(starSystem));
|
||||
}
|
||||
|
||||
public Collection<IntersectData> getControlling(Collection<Place> starSystems){
|
||||
Stream<Place> candidates = market.get().stream().filter(Place::isPopulated);
|
||||
return getControlling(starSystem, candidates, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
||||
return getControlling(starSystems, candidates, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Collection<IntersectData> getIntersects(Collection<Place> starSystems){
|
||||
@@ -63,12 +67,12 @@ public class PowerPlayAnalyzator {
|
||||
return getNearExpansions(market.get(), starSystems, Market.CONTROLLING_RADIUS * 2);
|
||||
}
|
||||
|
||||
public static Collection<IntersectData> getControlling(Place starSystem, Collection<Place> starSystems, double radius){
|
||||
return getControlling(starSystem, starSystems.stream(), radius).collect(Collectors.toList());
|
||||
public static Collection<IntersectData> getControlling(Collection<Place> checkedSystems, Collection<Place> starSystems, double radius){
|
||||
return getControlling(checkedSystems, starSystems.stream(), radius).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Stream<IntersectData> getControlling(Place starSystem, Stream<Place> starSystems, double radius){
|
||||
IntersectsMapper controllingMapper = new IntersectsMapper(Collections.singleton(starSystem), radius, true, true);
|
||||
public static Stream<IntersectData> getControlling(Collection<Place> checkedSystems, Stream<Place> starSystems, double radius){
|
||||
IntersectsMapper controllingMapper = new IntersectsMapper(checkedSystems, radius, true, true);
|
||||
return starSystems
|
||||
.map(controllingMapper)
|
||||
.filter(IntersectData::isIntersect);
|
||||
|
||||
Reference in New Issue
Block a user