use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.
the class CustomerSearchController method buildContextMenu.
/**
* Build a ContextMenu for ListView of the search results for a better navigation
*
* @return ContextMenu the filled ContextMenu
*/
private ContextMenu buildContextMenu() {
// Create a ContextMenu
ContextMenu contextMenu = new ContextMenu();
MenuItem viewCustomer = new MenuItem("Detailansicht");
MenuItem viewCompleteCustomer = new MenuItem("Detailansicht inc. aller Mandatendetails");
MenuItem editCustomer = new MenuItem("Bearbeiten");
// adding actions to the context menu
viewCustomer.setOnAction((ActionEvent event) -> {
// open toHtml(String matchcode, DefaultCustomerSalesdata defaults)
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Ui.build(statusHbox).title("Kunde mit Mandant").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsMandatorHtml(selectedCustomer.getId())), () -> new HtmlPane());
});
});
viewCompleteCustomer.setOnAction((ActionEvent event) -> {
// open toHtml(String salesRow, String comment)
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Ui.build(statusHbox).title("Kunden Ansicht").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsHtml(selectedCustomer.getId())), () -> new HtmlPane());
});
});
editCustomer.setOnAction((ActionEvent event) -> {
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer picoCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Customer customer = Ui.progress().call(() -> AGENT.findByIdEager(Customer.class, picoCustomer.getId()));
if (!customer.isValid()) {
Ui.build(resultListView).title("Fehlerhafter Datensatz").alert().message("Kundendaten sind invalid (aktuell normal): " + customer.getViolationMessage()).show(AlertType.WARNING);
} else if (customer.isSimple()) {
L.info("Edit Simple Customer {}", customer.getId());
Optional<CustomerContinue> result = Ui.build(resultListView).fxml().eval(() -> customer, CustomerSimpleController.class).opt();
if (!result.isPresent())
return;
Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
if (!Ui.failure().handle(reply))
return;
if (!result.get().continueEnhance)
return;
Ui.build(statusHbox).fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
} else if (customer.isBusiness()) {
L.info("Edit (Complex) Customer {}", customer.getId());
Ui.build(statusHbox).fxml().eval(() -> customer, CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
}
});
});
// add MenuItemes to ContextMenu
contextMenu.getItems().addAll(viewCustomer, viewCompleteCustomer, editCustomer);
return contextMenu;
}
use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.
the class CustomerSimpleController method saveAndCloseButtonHandling.
@FXML
private void saveAndCloseButtonHandling() {
try {
SimpleCustomer simpleCustomer = getSimpleCustomer();
result = new CustomerContinue(getSimpleCustomer(), false);
Ui.closeWindowOf(kid);
} catch (IllegalStateException e) {
Alert alert = new Alert(javafx.scene.control.Alert.AlertType.ERROR, e.getMessage(), OK);
alert.show();
}
}
use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.
the class CustomerSimpleTryout method main.
public static void main(String[] args) {
// stub for the new Costumer modell with generator needed
Dl.remote().add(CustomerAgent.class, new CustomerAgentStub());
JButton close = new JButton("Schliessen");
close.addActionListener(e -> Ui.closeWindowOf(close));
JButton consumerCustomerButton = new JButton("Consumer Customer");
consumerCustomerButton.addActionListener(ev -> {
Customer consumerCustomer = makeValidCustomer();
System.out.println("IS simple: " + consumerCustomer.getSimpleViolationMessage());
System.out.println("Consumer Customer: " + consumerCustomer.isConsumer());
Ui.exec(() -> {
Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(() -> consumerCustomer, CustomerSimpleController.class).opt();
if (!result.isPresent())
return;
Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
if (!Ui.failure().handle(reply))
return;
if (!result.get().continueEnhance)
return;
Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
});
});
JButton bussinesCustomer = new JButton("Bussines Customer");
bussinesCustomer.addActionListener(ev -> {
Customer bussnisCustomer = makeValidCustomer();
Contact tempcon = bussnisCustomer.getContacts().get(0);
Company company = gen.makeCompany();
company.getContacts().clear();
company.getContacts().add(tempcon);
company.getCommunications().clear();
bussnisCustomer.getContacts().clear();
bussnisCustomer.getCompanies().add(company);
System.out.println("IS simple: " + bussnisCustomer.getSimpleViolationMessage());
System.out.println("Bussines Customer: " + bussnisCustomer.isBusiness());
Ui.exec(() -> {
Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(() -> bussnisCustomer, CustomerSimpleController.class).opt();
if (!result.isPresent())
return;
Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
if (!Ui.failure().handle(reply))
return;
if (!result.get().continueEnhance)
return;
Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
});
});
JButton nullCustomer = new JButton(" Create SimpleCustomer");
nullCustomer.addActionListener(ev -> {
Ui.exec(() -> {
Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(CustomerSimpleController.class).opt();
if (!result.isPresent())
return;
Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
if (!Ui.failure().handle(reply))
return;
if (!result.get().continueEnhance)
return;
Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
});
});
JPanel p = new JPanel();
p.add(consumerCustomerButton);
p.add(bussinesCustomer);
p.add(nullCustomer);
p.add(close);
UiCore.startSwing(() -> p);
}
use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.
the class CustomerSimpleController method saveAndEnhanceUIButtonHandling.
@FXML
private void saveAndEnhanceUIButtonHandling() {
try {
SimpleCustomer simpleCustomer = getSimpleCustomer();
result = new CustomerContinue(getSimpleCustomer(), true);
Ui.closeWindowOf(kid);
} catch (IllegalStateException e) {
Alert alert = new Alert(javafx.scene.control.Alert.AlertType.ERROR, e.getMessage(), OK);
alert.show();
}
}
Aggregations