* Shortcut F8: Checkout * Shortcut F1-F4: Navigasi Tab * Bug Fix: Styling Add Class tertambahkan berulang kali sehingga isi class menjadi memiliki duplikatpull/1/head
| @@ -4,4 +4,5 @@ public class FormConstanta { | |||
| //daftarkan halaman disini | |||
| public static final String TRANSAKSI = "Transaksi"; | |||
| public static final String BAYAR = "Bayar"; | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package id.amigogroup.posterminal; | |||
| import id.amigogroup.posterminal.bayar.FormBayarController; | |||
| import id.amigogroup.posterminal.pos.FormTransaksiController; | |||
| import java.io.IOException; | |||
| import java.util.logging.Level; | |||
| @@ -17,14 +18,16 @@ public class FormFactory { | |||
| //daftarkan halaman yang implement mainContenInterface disini | |||
| case FormConstanta.TRANSAKSI: | |||
| loader.setLocation(getClass().getResource("/fxml/FormTransaksi.fxml")); | |||
| { | |||
| node = loader.load(); | |||
| } | |||
| node = loader.load(); | |||
| FormTransaksiController fetc = loader.getController(); | |||
| // fetc.initData(parent); | |||
| break; | |||
| case FormConstanta.BAYAR: | |||
| loader.setLocation(getClass().getResource("/fxml/FormBayar.fxml")); | |||
| node = loader.load(); | |||
| FormBayarController fbc = loader.getController(); | |||
| // fetc.initData(parent); | |||
| break; | |||
| } | |||
| } catch (IOException ex) { | |||
| Logger.getLogger(FormFactory.class.getName()).log(Level.SEVERE, null, ex); | |||
| @@ -1,32 +1,58 @@ | |||
| package id.amigogroup.posterminal; | |||
| import java.net.URL; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import java.util.ResourceBundle; | |||
| import java.util.logging.Level; | |||
| import java.util.logging.Logger; | |||
| import javafx.application.Platform; | |||
| import javafx.fxml.FXML; | |||
| import javafx.fxml.Initializable; | |||
| import javafx.scene.Node; | |||
| import javafx.scene.control.ScrollPane; | |||
| import javafx.scene.input.KeyCode; | |||
| import javafx.scene.input.KeyCodeCombination; | |||
| import javafx.scene.input.KeyCombination; | |||
| import javafx.scene.layout.BorderPane; | |||
| public class FormUtamaController implements Initializable { | |||
| @FXML | |||
| private BorderPane bpMain; | |||
| @FXML | |||
| private ScrollPane spMainContent; | |||
| private FormFactory formFactory = new FormFactory(); | |||
| /** | |||
| * Initializes the controller class. | |||
| */ | |||
| @Override | |||
| public void initialize(URL url, ResourceBundle rb) { | |||
| setContent(formFactory.getForm(FormConstanta.TRANSAKSI, this)); | |||
| initShorcuts(); | |||
| } | |||
| public void initShorcuts() { | |||
| Map<KeyCombination,Runnable> listShortcuts = new HashMap<>(); | |||
| KeyCombination kcCheckout = new KeyCodeCombination(KeyCode.F8); | |||
| Runnable rnCheckout = () -> System.out.println("Checkout"); | |||
| listShortcuts.put(kcCheckout, rnCheckout); | |||
| Platform.runLater(() -> { | |||
| bpMain.getScene().getAccelerators().putAll(listShortcuts); | |||
| }); | |||
| } | |||
| public void setContent(Node node) { | |||
| try { | |||
| spMainContent.setContent(node); | |||
| } catch (NullPointerException npe) { | |||
| Logger.getLogger(FormUtamaController.class.getName()).log(Level.SEVERE, null, npe); | |||
| Logger.getLogger(FormUtamaController.class | |||
| .getName()).log(Level.SEVERE, null, npe); | |||
| // AlertGenerate.getAlert(AlertGenerate.FXML_FAIL).show(); | |||
| } | |||
| } | |||
| @@ -7,14 +7,19 @@ package id.amigogroup.posterminal.pos; | |||
| import java.net.URL; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.ResourceBundle; | |||
| import javafx.application.Platform; | |||
| import javafx.event.ActionEvent; | |||
| import javafx.fxml.FXML; | |||
| import javafx.fxml.Initializable; | |||
| import javafx.scene.control.Button; | |||
| import javafx.scene.control.TextField; | |||
| import javafx.scene.input.KeyCode; | |||
| import javafx.scene.input.KeyCodeCombination; | |||
| import javafx.scene.input.KeyCombination; | |||
| import javafx.scene.input.KeyEvent; | |||
| import javafx.scene.text.Text; | |||
| @@ -42,6 +47,7 @@ public class FormTransaksiController implements Initializable { | |||
| private final String BTN_BAWA_DULU = "bawa dulu"; | |||
| private final String BTN_BON = "bon"; | |||
| private final String BTN_RETUR = "retur"; | |||
| private String tableState = BTN_TUNAI; | |||
| private List<Button> navigasi = new ArrayList<>(); | |||
| @@ -54,44 +60,80 @@ public class FormTransaksiController implements Initializable { | |||
| navigasi.add(btnBawaDulu); | |||
| navigasi.add(btnBon); | |||
| navigasi.add(btnRetur); | |||
| initShortcuts(); | |||
| } | |||
| public void initShortcuts() { | |||
| Map<KeyCombination, Runnable> listShortcuts = new HashMap<>(); | |||
| KeyCombination kcBtnTunai = new KeyCodeCombination(KeyCode.S); | |||
| Runnable rnBtnTunai = () -> btnTunai.fire(); | |||
| listShortcuts.put(kcBtnTunai, rnBtnTunai); | |||
| KeyCombination kcBtnBawa = new KeyCodeCombination(KeyCode.F2); | |||
| Runnable rnBtnBawa = () -> btnBawaDulu.fire(); | |||
| listShortcuts.put(kcBtnBawa, rnBtnBawa); | |||
| KeyCombination kcBon = new KeyCodeCombination(KeyCode.F3); | |||
| Runnable rnBon = () -> btnBon.fire(); | |||
| listShortcuts.put(kcBon, rnBon); | |||
| KeyCombination kcRetur = new KeyCodeCombination(KeyCode.F4); | |||
| Runnable rnRetur = () -> btnRetur.fire(); | |||
| listShortcuts.put(kcRetur, rnRetur); | |||
| Platform.runLater(() -> { | |||
| fldScan.getScene().getAccelerators().putAll(listShortcuts); | |||
| }); | |||
| } | |||
| @FXML | |||
| void btnNavigasiOnAction(ActionEvent event) { | |||
| Button buttonSource = (Button) event.getSource(); | |||
| switch (buttonSource.getText().toLowerCase()) { | |||
| case BTN_TUNAI: | |||
| //ambil data tunai | |||
| System.out.println("ambil data tunai"); | |||
| break; | |||
| case BTN_BAWA_DULU: | |||
| //ambil data bawa dulu | |||
| System.out.println("ambil data bawa dulu"); | |||
| break; | |||
| case BTN_BON: | |||
| //ambil data bon | |||
| System.out.println("ambil data bon"); | |||
| break; | |||
| case BTN_RETUR: | |||
| //ambil data retur | |||
| System.out.println("ambil data retur"); | |||
| break; | |||
| if (!tableState.equals(buttonSource.getText().toLowerCase())) { | |||
| switch (buttonSource.getText().toLowerCase()) { | |||
| case BTN_TUNAI: | |||
| //ambil data tunai | |||
| tableState = BTN_TUNAI; | |||
| System.out.println("ambil data tunai"); | |||
| break; | |||
| case BTN_BAWA_DULU: | |||
| //ambil data bawa dulu | |||
| tableState = BTN_BAWA_DULU; | |||
| System.out.println("ambil data bawa dulu"); | |||
| break; | |||
| case BTN_BON: | |||
| //ambil data bon | |||
| tableState = BTN_BON; | |||
| System.out.println("ambil data bon"); | |||
| break; | |||
| case BTN_RETUR: | |||
| //ambil data retur | |||
| tableState = BTN_RETUR; | |||
| System.out.println("ambil data retur"); | |||
| break; | |||
| } | |||
| } | |||
| for (Button button : navigasi) { | |||
| if (button.equals(buttonSource)) { | |||
| button.getStyleClass().add("button-navigasi-transaksi-selected"); | |||
| if (!button.getStyleClass().contains("button-navigasi-transaksi-selected")) { | |||
| button.getStyleClass().add("button-navigasi-transaksi-selected"); | |||
| } | |||
| } else { | |||
| button.getStyleClass().remove("button-navigasi-transaksi-selected"); | |||
| if (button.getStyleClass().contains("button-navigasi-transaksi-selected")) { | |||
| button.getStyleClass().remove("button-navigasi-transaksi-selected"); | |||
| } | |||
| } | |||
| } | |||
| fldScan.requestFocus(); | |||
| } | |||
| @FXML | |||
| void fldScanOnKeyPressed(KeyEvent event) { | |||
| if(event.getCode() == KeyCode.ENTER){ | |||
| if (event.getCode() == KeyCode.ENTER) { | |||
| //proses scan | |||
| System.out.println("Scan"); | |||
| } | |||
| @@ -5,6 +5,10 @@ | |||
| */ | |||
| package id.amigogroup.posterminal.util; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import javafx.scene.input.KeyCodeCombination; | |||
| /** | |||
| * | |||
| * @author ronal | |||
| @@ -15,4 +19,5 @@ public class Fucout { | |||
| //IMAGES URL | |||
| public static final String APP_ICON = "/assets/logo-mini-squared.png"; | |||
| } | |||
| @@ -16,7 +16,7 @@ | |||
| <?import javafx.scene.layout.VBox?> | |||
| <?import javafx.scene.text.Font?> | |||
| <BorderPane prefHeight="550.0" prefWidth="1000.0" stylesheets="@../styles/pos_styles.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.amigogroup.posterminal.FormUtamaController"> | |||
| <BorderPane fx:id="bpMain" prefHeight="550.0" prefWidth="1000.0" stylesheets="@../styles/pos_styles.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.amigogroup.posterminal.FormUtamaController"> | |||
| <top> | |||
| <AnchorPane id="header" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="750.0"> | |||
| <children> | |||