add warning icon. Showed, if need fill station or system
This commit is contained in:
@@ -3,6 +3,7 @@ package ru.trader.controllers;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.input.MouseButton;
|
import javafx.scene.input.MouseButton;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -66,6 +67,8 @@ public class OffersController {
|
|||||||
private CheckBox cbLargeLandpad;
|
private CheckBox cbLargeLandpad;
|
||||||
@FXML
|
@FXML
|
||||||
private TitledPane stationPane;
|
private TitledPane stationPane;
|
||||||
|
@FXML
|
||||||
|
private Node warningIcon;
|
||||||
|
|
||||||
private final List<OfferModel> sells = FXCollections.observableArrayList();
|
private final List<OfferModel> sells = FXCollections.observableArrayList();
|
||||||
private final List<OfferModel> buys = FXCollections.observableArrayList();
|
private final List<OfferModel> buys = FXCollections.observableArrayList();
|
||||||
@@ -171,6 +174,7 @@ public class OffersController {
|
|||||||
sells.addAll(station.getSells());
|
sells.addAll(station.getSells());
|
||||||
buys.addAll(station.getBuys());
|
buys.addAll(station.getBuys());
|
||||||
}
|
}
|
||||||
|
updateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sort(){
|
private void sort(){
|
||||||
@@ -199,6 +203,20 @@ public class OffersController {
|
|||||||
return station;
|
return station;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIcons(){
|
||||||
|
SystemModel s = getSystem();
|
||||||
|
if (!s.isCorrect()){
|
||||||
|
warningIcon.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StationModel st = getStation();
|
||||||
|
if (!st.isCorrect()){
|
||||||
|
warningIcon.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
warningIcon.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void currentSystem(){
|
private void currentSystem(){
|
||||||
ProfileModel profile = MainController.getProfile();
|
ProfileModel profile = MainController.getProfile();
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import javafx.beans.binding.Bindings;
|
|||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
import ru.trader.Main;
|
import ru.trader.Main;
|
||||||
import ru.trader.ServicesManager;
|
import ru.trader.ServicesManager;
|
||||||
import ru.trader.core.Engine;
|
import ru.trader.core.Engine;
|
||||||
@@ -55,6 +57,8 @@ public class ProfileController {
|
|||||||
private ToggleButton btnHelper;
|
private ToggleButton btnHelper;
|
||||||
@FXML
|
@FXML
|
||||||
private ToggleButton btnEDCE;
|
private ToggleButton btnEDCE;
|
||||||
|
@FXML
|
||||||
|
private Node warningIcon;
|
||||||
|
|
||||||
private AutoCompletion<SystemModel> system;
|
private AutoCompletion<SystemModel> system;
|
||||||
private ProfileModel profile;
|
private ProfileModel profile;
|
||||||
@@ -74,6 +78,7 @@ public class ProfileController {
|
|||||||
profile.setStation(ModelFabric.NONE_STATION);
|
profile.setStation(ModelFabric.NONE_STATION);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
system.valueProperty().addListener(i -> updateIcons());
|
||||||
engine.setItems(FXCollections.observableList(Engine.getEngines()));
|
engine.setItems(FXCollections.observableList(Engine.getEngines()));
|
||||||
engine.setConverter(new EngineStringConverter());
|
engine.setConverter(new EngineStringConverter());
|
||||||
btnAddSystem.setOnAction(e -> {
|
btnAddSystem.setOnAction(e -> {
|
||||||
@@ -185,11 +190,29 @@ public class ProfileController {
|
|||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StationModel getStation(){
|
||||||
|
return getStation(station.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
private StationModel getStation(String name){
|
private StationModel getStation(String name){
|
||||||
SystemModel s = system.getValue();
|
SystemModel s = system.getValue();
|
||||||
return s == null ? ModelFabric.NONE_STATION : s.get(name);
|
return s == null ? ModelFabric.NONE_STATION : s.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIcons(){
|
||||||
|
SystemModel s = system.getValue();
|
||||||
|
if (!s.isCorrect()){
|
||||||
|
warningIcon.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StationModel st = getStation();
|
||||||
|
if (!st.isCorrect()){
|
||||||
|
warningIcon.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
warningIcon.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void bind(){
|
private void bind(){
|
||||||
profile.nameProperty().addListener(nameListener);
|
profile.nameProperty().addListener(nameListener);
|
||||||
profile.balanceProperty().addListener(balanceListener);
|
profile.balanceProperty().addListener(balanceListener);
|
||||||
|
|||||||
@@ -215,6 +215,46 @@ public class ModelFabric {
|
|||||||
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FACTION getFaction() {
|
||||||
|
return FACTION.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFaction(FACTION faction) {
|
||||||
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GOVERNMENT getGovernment() {
|
||||||
|
return GOVERNMENT.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGovernment(GOVERNMENT government) {
|
||||||
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public POWER getPower() {
|
||||||
|
return POWER.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPower(POWER power) {
|
||||||
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public POWER_STATE getPowerState() {
|
||||||
|
return POWER_STATE.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPowerState(POWER_STATE powerState) {
|
||||||
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StationModel get(String name) {
|
public StationModel get(String name) {
|
||||||
return ModelFabric.NONE_STATION;
|
return ModelFabric.NONE_STATION;
|
||||||
@@ -240,6 +280,16 @@ public class ModelFabric {
|
|||||||
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCorrect() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "";
|
return "";
|
||||||
@@ -267,9 +317,39 @@ public class ModelFabric {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public STATION_TYPE getType() {
|
||||||
|
return STATION_TYPE.STARPORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(STATION_TYPE type) {
|
||||||
|
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ECONOMIC_TYPE getEconomic() {
|
||||||
|
return ECONOMIC_TYPE.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEconomic(ECONOMIC_TYPE economic) {
|
||||||
|
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ECONOMIC_TYPE getSubEconomic() {
|
||||||
|
return ECONOMIC_TYPE.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSubEconomic(ECONOMIC_TYPE economic) {
|
||||||
|
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FACTION getFaction() {
|
public FACTION getFaction() {
|
||||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
return FACTION.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -279,7 +359,7 @@ public class ModelFabric {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GOVERNMENT getGovernment() {
|
public GOVERNMENT getGovernment() {
|
||||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
return GOVERNMENT.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -362,6 +442,12 @@ public class ModelFabric {
|
|||||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCorrect(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -178,6 +178,12 @@ public class StationModel {
|
|||||||
return station.getModifiedTime();
|
return station.getModifiedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCorrect(){
|
||||||
|
return !station.getName().isEmpty() && station.getType() != null && station.getDistance() > 0
|
||||||
|
&& station.getFaction() != null && station.getGovernment() != null
|
||||||
|
&& station.getEconomic() != null && station.getSubEconomic() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (LOG.isTraceEnabled()){
|
if (LOG.isTraceEnabled()){
|
||||||
|
|||||||
@@ -160,6 +160,14 @@ public class SystemModel {
|
|||||||
return system.isEmpty();
|
return system.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCorrect(){
|
||||||
|
return !system.getName().isEmpty() && (system.getX() != 0 || system.getY() != 0 || system.getZ() != 0 )
|
||||||
|
&& system.getFaction() != null && system.getGovernment() != null
|
||||||
|
&& system.getPower() != null && system.getPowerState() != null
|
||||||
|
&& (system.getFaction() == FACTION.NONE || !system.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (LOG.isTraceEnabled()){
|
if (LOG.isTraceEnabled()){
|
||||||
|
|||||||
@@ -13,6 +13,18 @@
|
|||||||
<fx:define><Insets fx:id="stationsMargin" left="5" right="5" /></fx:define>
|
<fx:define><Insets fx:id="stationsMargin" left="5" right="5" /></fx:define>
|
||||||
<fx:define><Insets fx:id="stationsPadding" left="12" right="10" /></fx:define>
|
<fx:define><Insets fx:id="stationsPadding" left="12" right="10" /></fx:define>
|
||||||
|
|
||||||
|
<fx:define>
|
||||||
|
<ContextMenu fx:id="editMenu">
|
||||||
|
<items>
|
||||||
|
<MenuItem text="%main.menu.edit.editSystem" onAction="#editSystem" />
|
||||||
|
<SeparatorMenuItem />
|
||||||
|
<MenuItem text="%main.menu.edit.addStation" onAction="#addStation" />
|
||||||
|
<MenuItem text="%main.menu.edit.editStation" onAction="#editStation" />
|
||||||
|
<MenuItem text="%main.menu.edit.removeStation" onAction="#removeStation" />
|
||||||
|
</items>
|
||||||
|
</ContextMenu>
|
||||||
|
</fx:define>
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints minWidth="270" maxWidth="270"/>
|
<ColumnConstraints minWidth="270" maxWidth="270"/>
|
||||||
<ColumnConstraints fillWidth="true"/>
|
<ColumnConstraints fillWidth="true"/>
|
||||||
@@ -24,17 +36,7 @@
|
|||||||
</TitledPane>
|
</TitledPane>
|
||||||
<TitledPane VBox.vgrow="ALWAYS" text="%market.stations" collapsible="false">
|
<TitledPane VBox.vgrow="ALWAYS" text="%market.stations" collapsible="false">
|
||||||
<ListView fx:id="stationsList">
|
<ListView fx:id="stationsList">
|
||||||
<contextMenu>
|
<contextMenu><fx:reference source="editMenu"/></contextMenu>
|
||||||
<ContextMenu>
|
|
||||||
<items>
|
|
||||||
<MenuItem text="%main.menu.edit.editSystem" onAction="#editSystem" />
|
|
||||||
<SeparatorMenuItem />
|
|
||||||
<MenuItem text="%main.menu.edit.addStation" onAction="#addStation" />
|
|
||||||
<MenuItem text="%main.menu.edit.editStation" onAction="#editStation" />
|
|
||||||
<MenuItem text="%main.menu.edit.removeStation" onAction="#removeStation" />
|
|
||||||
</items>
|
|
||||||
</ContextMenu>
|
|
||||||
</contextMenu>
|
|
||||||
</ListView>
|
</ListView>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
</VBox>
|
</VBox>
|
||||||
@@ -47,7 +49,8 @@
|
|||||||
<ColumnConstraints minWidth="100" />
|
<ColumnConstraints minWidth="100" />
|
||||||
<ColumnConstraints minWidth="140" />
|
<ColumnConstraints minWidth="140" />
|
||||||
<ColumnConstraints minWidth="110" />
|
<ColumnConstraints minWidth="110" />
|
||||||
<ColumnConstraints minWidth="140" hgrow="ALWAYS" />
|
<ColumnConstraints minWidth="140" />
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<Label text="%label.station.type" />
|
<Label text="%label.station.type" />
|
||||||
<Label fx:id="type" GridPane.columnIndex="1"/>
|
<Label fx:id="type" GridPane.columnIndex="1"/>
|
||||||
@@ -55,6 +58,12 @@
|
|||||||
<Label fx:id="faction" GridPane.columnIndex="3" />
|
<Label fx:id="faction" GridPane.columnIndex="3" />
|
||||||
<Label text="%label.government" GridPane.columnIndex="4" />
|
<Label text="%label.government" GridPane.columnIndex="4" />
|
||||||
<Label fx:id="government" GridPane.columnIndex="5" />
|
<Label fx:id="government" GridPane.columnIndex="5" />
|
||||||
|
<HBox GridPane.columnIndex="6" GridPane.rowSpan="2" alignment="TOP_RIGHT">
|
||||||
|
<Label fx:id="warningIcon" styleClass="icon-warning" prefWidth="30" prefHeight="30" visible="false">
|
||||||
|
<graphic><Glyph text="FontAwesome|WARNING" /></graphic>
|
||||||
|
</Label>
|
||||||
|
</HBox>
|
||||||
|
|
||||||
<Label text="%label.station.distance" GridPane.rowIndex="1" />
|
<Label text="%label.station.distance" GridPane.rowIndex="1" />
|
||||||
<Label fx:id="distance" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
<Label fx:id="distance" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||||
<Label text="%label.economic" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
<Label text="%label.economic" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
||||||
@@ -62,7 +71,7 @@
|
|||||||
<Label fx:id="subeconomic" GridPane.rowIndex="1" GridPane.columnIndex="4" GridPane.columnSpan="2"/>
|
<Label fx:id="subeconomic" GridPane.rowIndex="1" GridPane.columnIndex="4" GridPane.columnSpan="2"/>
|
||||||
|
|
||||||
<Label text="%label.station.services" GridPane.rowIndex="2"/>
|
<Label text="%label.station.services" GridPane.rowIndex="2"/>
|
||||||
<TilePane GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.columnSpan="5" GridPane.hgrow="ALWAYS"
|
<TilePane GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.columnSpan="6" GridPane.hgrow="ALWAYS"
|
||||||
hgap="5" vgap="5" prefColumns="5" tileAlignment="BASELINE_LEFT">
|
hgap="5" vgap="5" prefColumns="5" tileAlignment="BASELINE_LEFT">
|
||||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||||
@@ -75,6 +84,7 @@
|
|||||||
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
||||||
</TilePane>
|
</TilePane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<contextMenu><fx:reference source="editMenu"/></contextMenu>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
<Accordion GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
<Accordion GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||||
<panes>
|
<panes>
|
||||||
|
|||||||
@@ -21,12 +21,12 @@
|
|||||||
<NumberField fx:id="balance" />
|
<NumberField fx:id="balance" />
|
||||||
<Label text="%profile.system" />
|
<Label text="%profile.system" />
|
||||||
<HBox>
|
<HBox>
|
||||||
<TextField fx:id="systemText" />
|
<TextField fx:id="systemText" minWidth="100"/>
|
||||||
<Button fx:id="btnAddSystem" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
<Button fx:id="btnAddSystem" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label text="%profile.station" />
|
<Label text="%profile.station" />
|
||||||
<HBox>
|
<HBox>
|
||||||
<ComboBox fx:id="station" />
|
<ComboBox fx:id="station" minWidth="100"/>
|
||||||
<Button fx:id="btnAddStation" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
<Button fx:id="btnAddStation" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label text="%profile.docked" />
|
<Label text="%profile.docked" />
|
||||||
@@ -52,4 +52,9 @@
|
|||||||
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<ToggleButton fx:id="btnEDCE" text="EDCE"/>
|
<ToggleButton fx:id="btnEDCE" text="EDCE"/>
|
||||||
|
<HBox HBox.hgrow="ALWAYS" alignment="CENTER_RIGHT">
|
||||||
|
<Label fx:id="warningIcon" styleClass="icon-warning" prefWidth="30" prefHeight="30" visible="false">
|
||||||
|
<graphic><Glyph text="FontAwesome|WARNING" /></graphic>
|
||||||
|
</Label>
|
||||||
|
</HBox>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
@@ -238,4 +238,10 @@ HBox.fields-group hbox-margin{
|
|||||||
|
|
||||||
.service-warning {
|
.service-warning {
|
||||||
-fx-text-fill: red;
|
-fx-text-fill: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-warning {
|
||||||
|
-fx-light-text-color: orange;
|
||||||
|
-fx-mid-text-color: orange;
|
||||||
|
-fx-dark-text-color: orange;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user