Archived
0

modify track route screen

This commit is contained in:
iMoHax
2016-03-03 15:33:30 +03:00
parent df87b9e95f
commit 32e6408856
2 changed files with 88 additions and 58 deletions

View File

@@ -19,6 +19,7 @@ import ru.trader.view.support.autocomplete.CachedSuggestionProvider;
import ru.trader.view.support.autocomplete.SystemsProvider; import ru.trader.view.support.autocomplete.SystemsProvider;
import ru.trader.view.support.cells.OrderListCell; import ru.trader.view.support.cells.OrderListCell;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -28,7 +29,7 @@ public class RouteTrackController {
@FXML @FXML
private Node editGroup; private Node editGroup;
@FXML @FXML
private Node infoGroup; private Node missionsGroup;
@FXML @FXML
private Node refuelGroup; private Node refuelGroup;
@FXML @FXML
@@ -58,6 +59,9 @@ public class RouteTrackController {
private AutoCompletion<SystemModel> newEntrySystem; private AutoCompletion<SystemModel> newEntrySystem;
@FXML @FXML
private ComboBox<String> newEntryStation; private ComboBox<String> newEntryStation;
@FXML
private ToggleButton tbMissionsEdit;
private RouteModel route; private RouteModel route;
private Track trackNode; private Track trackNode;
@@ -163,13 +167,13 @@ public class RouteTrackController {
} }
@FXML @FXML
private void toggleEdit(){ private void toggleMissionsEdit(){
if (editGroup.isVisible()){ if (editGroup.isVisible()){
editGroup.setVisible(false); editGroup.setVisible(false);
infoGroup.setVisible(true); missionsGroup.setVisible(true);
} else { } else {
editGroup.setVisible(true); editGroup.setVisible(true);
infoGroup.setVisible(false); missionsGroup.setVisible(false);
} }
} }
@@ -203,6 +207,8 @@ public class RouteTrackController {
newRoute.addAll(startIndex, notAdded); newRoute.addAll(startIndex, notAdded);
newRoute.addAll(startIndex, oldMissions); newRoute.addAll(startIndex, oldMissions);
updateRoute(newRoute); updateRoute(newRoute);
clearMissions();
tbMissionsEdit.fire();
} }
}); });
} else { } else {
@@ -231,7 +237,26 @@ public class RouteTrackController {
@FXML @FXML
private void clearMissions(){ private void clearMissions(){
missionsController.clear(); missionsController.clear();
}
@FXML
private void removeMissionFromTrack(){
if (route != null){
MissionModel mission = missionsList.getSelectionModel().getSelectedItem();
if (mission != null){
route.remove(mission);
}
}
}
@FXML
private void removeAllMissionsFromTrack(){
if (route != null){
Collection<MissionModel> missions = new ArrayList<>(missionsList.getItems());
if (!missions.isEmpty()){
route.removeAll(missions);
}
}
} }
@FXML @FXML

View File

@@ -4,59 +4,65 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import org.controlsfx.glyphfont.Glyph?> <?import org.controlsfx.glyphfont.Glyph?>
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" <?import javafx.geometry.Insets?>
fx:controller="ru.trader.controllers.RouteTrackController" <GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
spacing="4" > fx:controller="ru.trader.controllers.RouteTrackController"
<VBox> vgap="4" hgap="4">
<ToggleButton minWidth="30" onAction="#toggleEdit"> <padding>
<graphic><Glyph text="FontAwesome|EDIT"/></graphic> <Insets left="5" right="5" top="5" bottom="5"/>
</ToggleButton> </padding>
<StackPane>
<VBox fx:id="editGroup"> <columnConstraints>
<fx:include fx:id="missions" source="missions.fxml"/> <ColumnConstraints minWidth="300" maxWidth="300"/>
<HBox> <ColumnConstraints minWidth="300" maxWidth="300"/>
<ListView fx:id="addMissionsList" maxHeight="150"/> <ColumnConstraints minWidth="30" maxWidth="40"/>
<VBox spacing="4" alignment="TOP_RIGHT"> <ColumnConstraints minWidth="220" />
<Button prefWidth="30" onAction="#addMission"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button> </columnConstraints>
<Button prefWidth="30" onAction="#removeMission"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearMissions"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button> <VBox GridPane.rowIndex="0" GridPane.columnIndex="0" GridPane.columnSpan="3">
</VBox> <HBox><Label text="Система:" /><Label fx:id="system" /></HBox>
<VBox> <HBox><Label text="Станция:" /><Label fx:id="station" /></HBox>
<Button prefWidth="80" text="Добавить" onAction="#addMissionsToTrack" /> <HBox><Label text="Время:" /><Label fx:id="time" /></HBox>
<Button prefWidth="80" text="Добавить все" onAction="#addAllMissionsToTrack" /> <HBox fx:id="refuelGroup"><Label text="Заправить:" /><Label fx:id="refuel" /></HBox>
</VBox>
</HBox>
</VBox>
<VBox fx:id="infoGroup">
<HBox><Label text="Система:" /><Label fx:id="system" /></HBox>
<HBox><Label text="Станция:" /><Label fx:id="station" /></HBox>
<HBox><Label text="Время:" /><Label fx:id="time" /></HBox>
<HBox fx:id="refuelGroup"><Label text="Заправить:" /><Label fx:id="refuel" /></HBox>
<HBox fx:id="ordersGroup" maxHeight="120">
<VBox>
<Label text="Продать:" />
<ListView fx:id="sellOrders"/>
</VBox>
<VBox>
<Label text="Купить:" />
<HBox spacing="4">
<ListView fx:id="buyOrders"/>
<VBox spacing="4" alignment="TOP_RIGHT">
<Button prefWidth="30" onAction="#addOrder"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeOrder"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearOrders"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
</HBox>
</VBox>
</HBox>
<VBox fx:id="missionsGroup" maxHeight="120">
<Label text="Сдать миссии:" />
<ListView fx:id="missionsList" maxHeight="150"/>
</VBox>
</VBox>
</StackPane>
</VBox> </VBox>
<ScrollPane minWidth="220" fitToHeight="true">
<Label GridPane.rowIndex="1" GridPane.columnIndex="0" text="Продать:" />
<ListView GridPane.rowIndex="2" GridPane.columnIndex="0" fx:id="sellOrders" maxHeight="150"/>
<Label GridPane.rowIndex="1" GridPane.columnIndex="1" text="Купить:" />
<ListView GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="buyOrders" maxHeight="150"/>
<VBox GridPane.rowIndex="2" GridPane.columnIndex="2" spacing="4" alignment="TOP_RIGHT">
<Button prefWidth="30" onAction="#addOrder"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeOrder"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearOrders"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
<Label GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2" text="Миссии:" />
<StackPane GridPane.rowIndex="4" GridPane.columnIndex="0" GridPane.columnSpan="2" maxHeight="150">
<HBox fx:id="missionsGroup">
<ListView fx:id="missionsList" HBox.hgrow="ALWAYS"/>
</HBox>
<HBox fx:id="editGroup" spacing="4">
<fx:include fx:id="missions" source="missions.fxml"/>
<ListView fx:id="addMissionsList"/>
<VBox spacing="4">
<Button prefWidth="30" onAction="#addMission"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeMission"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearMissions"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
<VBox VBox.vgrow="ALWAYS" alignment="BOTTOM_LEFT">
<Button prefWidth="30" onAction="#addAllMissionsToTrack"><graphic><Glyph text="FontAwesome|CHECK"/><Glyph text="FontAwesome|CHECK"/></graphic></Button>
</VBox>
</VBox>
</HBox>
</StackPane>
<VBox GridPane.rowIndex="4" GridPane.columnIndex="2" alignment="TOP_RIGHT" spacing="4">
<ToggleButton fx:id="tbMissionsEdit" prefWidth="30" onAction="#toggleMissionsEdit"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></ToggleButton>
<Button prefWidth="30" onAction="#removeMissionFromTrack"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeAllMissionsFromTrack"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
<ScrollPane GridPane.rowIndex="0" GridPane.columnIndex="3" GridPane.rowSpan="5" GridPane.fillHeight="true">
<VBox> <VBox>
<AnchorPane fx:id="track"/> <AnchorPane fx:id="track"/>
<VBox> <VBox>
@@ -71,5 +77,4 @@
</VBox> </VBox>
</VBox> </VBox>
</ScrollPane> </ScrollPane>
</GridPane>
</HBox>