Archived
0

fix menu items

This commit is contained in:
iMoHax
2015-11-05 17:21:03 +03:00
parent 61b46b4e49
commit 36f9a34aa5
3 changed files with 21 additions and 7 deletions

View File

@@ -222,14 +222,14 @@ public class MainController {
public void editSystem(ActionEvent actionEvent){ public void editSystem(ActionEvent actionEvent){
SystemModel system = offersController.getSystem(); SystemModel system = offersController.getSystem();
if (system != null) { if (!ModelFabric.isFake(system)) {
Screeners.showSystemsEditor(system); Screeners.showSystemsEditor(system);
} }
} }
public void removeSystem(ActionEvent actionEvent){ public void removeSystem(ActionEvent actionEvent){
SystemModel system = offersController.getSystem(); SystemModel system = offersController.getSystem();
if (system != null) { if (!ModelFabric.isFake(system)) {
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName())); Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName()));
if (res == Dialog.ACTION_YES) { if (res == Dialog.ACTION_YES) {
market.remove(system); market.remove(system);
@@ -238,22 +238,22 @@ public class MainController {
} }
public void addStation(ActionEvent actionEvent) { public void addStation(ActionEvent actionEvent) {
SystemModel system = offersController.getSystem(); SystemModel system = profile.getSystem();
if (system != null){ if (!ModelFabric.isFake(system)) {
Screeners.showAddStation(offersController.getSystem()); Screeners.showAddStation(offersController.getSystem());
} }
} }
public void editStation(ActionEvent actionEvent) { public void editStation(ActionEvent actionEvent) {
StationModel station = profile.getStation(); StationModel station = profile.getStation();
if (station != null) { if (!ModelFabric.isFake(station)) {
Screeners.showEditStation(station); Screeners.showEditStation(station);
} }
} }
public void removeStation(ActionEvent actionEvent){ public void removeStation(ActionEvent actionEvent){
StationModel station = offersController.getStation(); StationModel station = profile.getStation();
if (station != null) { if (!ModelFabric.isFake(station)) {
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName())); Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName()));
if (res == Dialog.ACTION_YES) { if (res == Dialog.ACTION_YES) {
station.getSystem().remove(station); station.getSystem().remove(station);

View File

@@ -5,6 +5,8 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ru.trader.core.SERVICE_TYPE; import ru.trader.core.SERVICE_TYPE;
@@ -13,6 +15,7 @@ import ru.trader.model.support.BindingsHelper;
import ru.trader.model.support.ChangeMarketListener; import ru.trader.model.support.ChangeMarketListener;
import ru.trader.view.support.FactionStringConverter; import ru.trader.view.support.FactionStringConverter;
import ru.trader.view.support.GovernmentStringConverter; import ru.trader.view.support.GovernmentStringConverter;
import ru.trader.view.support.Localization;
import ru.trader.view.support.ViewUtils; import ru.trader.view.support.ViewUtils;
import ru.trader.view.support.autocomplete.AutoCompletion; import ru.trader.view.support.autocomplete.AutoCompletion;
import ru.trader.view.support.autocomplete.CachedSuggestionProvider; import ru.trader.view.support.autocomplete.CachedSuggestionProvider;
@@ -204,6 +207,16 @@ public class OffersController {
} }
} }
@FXML
private void removeStation() {
StationModel s = getStation();
if (!ModelFabric.isFake(s)){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName()));
if (res == org.controlsfx.dialog.Dialog.ACTION_YES) {
s.getSystem().remove(s);
}
}
}
private void addOffer(OfferModel offer){ private void addOffer(OfferModel offer){
switch (offer.getType()){ switch (offer.getType()){

View File

@@ -28,6 +28,7 @@
<items> <items>
<MenuItem text="%main.menu.edit.addStation" onAction="#addStation" /> <MenuItem text="%main.menu.edit.addStation" onAction="#addStation" />
<MenuItem text="%main.menu.edit.editStation" onAction="#editStation" /> <MenuItem text="%main.menu.edit.editStation" onAction="#editStation" />
<MenuItem text="%main.menu.edit.removeStation" onAction="#removeStation" />
</items> </items>
</ContextMenu> </ContextMenu>
</contextMenu> </contextMenu>