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.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import org.slf4j.Logger;
|
||||
@@ -66,6 +67,8 @@ public class OffersController {
|
||||
private CheckBox cbLargeLandpad;
|
||||
@FXML
|
||||
private TitledPane stationPane;
|
||||
@FXML
|
||||
private Node warningIcon;
|
||||
|
||||
private final List<OfferModel> sells = FXCollections.observableArrayList();
|
||||
private final List<OfferModel> buys = FXCollections.observableArrayList();
|
||||
@@ -171,6 +174,7 @@ public class OffersController {
|
||||
sells.addAll(station.getSells());
|
||||
buys.addAll(station.getBuys());
|
||||
}
|
||||
updateIcons();
|
||||
}
|
||||
|
||||
private void sort(){
|
||||
@@ -199,6 +203,20 @@ public class OffersController {
|
||||
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
|
||||
private void currentSystem(){
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
|
||||
@@ -5,9 +5,11 @@ import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.util.StringConverter;
|
||||
import org.controlsfx.glyphfont.Glyph;
|
||||
import ru.trader.Main;
|
||||
import ru.trader.ServicesManager;
|
||||
import ru.trader.core.Engine;
|
||||
@@ -55,6 +57,8 @@ public class ProfileController {
|
||||
private ToggleButton btnHelper;
|
||||
@FXML
|
||||
private ToggleButton btnEDCE;
|
||||
@FXML
|
||||
private Node warningIcon;
|
||||
|
||||
private AutoCompletion<SystemModel> system;
|
||||
private ProfileModel profile;
|
||||
@@ -74,6 +78,7 @@ public class ProfileController {
|
||||
profile.setStation(ModelFabric.NONE_STATION);
|
||||
});
|
||||
});
|
||||
system.valueProperty().addListener(i -> updateIcons());
|
||||
engine.setItems(FXCollections.observableList(Engine.getEngines()));
|
||||
engine.setConverter(new EngineStringConverter());
|
||||
btnAddSystem.setOnAction(e -> {
|
||||
@@ -185,11 +190,29 @@ public class ProfileController {
|
||||
bind();
|
||||
}
|
||||
|
||||
private StationModel getStation(){
|
||||
return getStation(station.getValue());
|
||||
}
|
||||
|
||||
private StationModel getStation(String name){
|
||||
SystemModel s = system.getValue();
|
||||
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(){
|
||||
profile.nameProperty().addListener(nameListener);
|
||||
profile.balanceProperty().addListener(balanceListener);
|
||||
|
||||
@@ -215,6 +215,46 @@ public class ModelFabric {
|
||||
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
|
||||
public StationModel get(String name) {
|
||||
return ModelFabric.NONE_STATION;
|
||||
@@ -240,6 +280,16 @@ public class ModelFabric {
|
||||
throw new UnsupportedOperationException("Is fake system, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCorrect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
@@ -267,9 +317,39 @@ public class ModelFabric {
|
||||
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
|
||||
public FACTION getFaction() {
|
||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||
return FACTION.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,7 +359,7 @@ public class ModelFabric {
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||
return GOVERNMENT.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -362,6 +442,12 @@ public class ModelFabric {
|
||||
throw new UnsupportedOperationException("Is fake station, unsupported");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCorrect(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
|
||||
@@ -178,6 +178,12 @@ public class StationModel {
|
||||
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
|
||||
public String toString() {
|
||||
if (LOG.isTraceEnabled()){
|
||||
|
||||
@@ -160,6 +160,14 @@ public class SystemModel {
|
||||
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
|
||||
public String toString() {
|
||||
if (LOG.isTraceEnabled()){
|
||||
|
||||
@@ -13,6 +13,18 @@
|
||||
<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>
|
||||
<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 minWidth="270" maxWidth="270"/>
|
||||
<ColumnConstraints fillWidth="true"/>
|
||||
@@ -24,17 +36,7 @@
|
||||
</TitledPane>
|
||||
<TitledPane VBox.vgrow="ALWAYS" text="%market.stations" collapsible="false">
|
||||
<ListView fx:id="stationsList">
|
||||
<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>
|
||||
<contextMenu><fx:reference source="editMenu"/></contextMenu>
|
||||
</ListView>
|
||||
</TitledPane>
|
||||
</VBox>
|
||||
@@ -47,7 +49,8 @@
|
||||
<ColumnConstraints minWidth="100" />
|
||||
<ColumnConstraints minWidth="140" />
|
||||
<ColumnConstraints minWidth="110" />
|
||||
<ColumnConstraints minWidth="140" hgrow="ALWAYS" />
|
||||
<ColumnConstraints minWidth="140" />
|
||||
<ColumnConstraints hgrow="ALWAYS" />
|
||||
</columnConstraints>
|
||||
<Label text="%label.station.type" />
|
||||
<Label fx:id="type" GridPane.columnIndex="1"/>
|
||||
@@ -55,6 +58,12 @@
|
||||
<Label fx:id="faction" GridPane.columnIndex="3" />
|
||||
<Label text="%label.government" GridPane.columnIndex="4" />
|
||||
<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 fx:id="distance" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||
<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 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">
|
||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||
@@ -75,6 +84,7 @@
|
||||
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
||||
</TilePane>
|
||||
</GridPane>
|
||||
<contextMenu><fx:reference source="editMenu"/></contextMenu>
|
||||
</TitledPane>
|
||||
<Accordion GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||
<panes>
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
<NumberField fx:id="balance" />
|
||||
<Label text="%profile.system" />
|
||||
<HBox>
|
||||
<TextField fx:id="systemText" />
|
||||
<TextField fx:id="systemText" minWidth="100"/>
|
||||
<Button fx:id="btnAddSystem" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
||||
</HBox>
|
||||
<Label text="%profile.station" />
|
||||
<HBox>
|
||||
<ComboBox fx:id="station" />
|
||||
<ComboBox fx:id="station" minWidth="100"/>
|
||||
<Button fx:id="btnAddStation" minWidth="30"><graphic><Glyph text="FontAwesome|EDIT"/></graphic></Button>
|
||||
</HBox>
|
||||
<Label text="%profile.docked" />
|
||||
@@ -52,4 +52,9 @@
|
||||
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
||||
</ToggleButton>
|
||||
<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>
|
||||
|
||||
@@ -238,4 +238,10 @@ HBox.fields-group hbox-margin{
|
||||
|
||||
.service-warning {
|
||||
-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