daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public final class DeliveryTopComponent
  2.         extends TopComponent
  3.         implements TableModelListener,
  4.         BeanAware<Delivery>,
  5.         MomentumModelEventListener,
  6.         BasicServicesAware<Delivery, DeliveryInfo>,
  7.         SaveObservable,
  8.         SaveAllowable {
  9.  
  10.     private static final String PREFERRED_ID = "DeliveryTopComponent";
  11.     private final PresentationModel<Delivery> pm = new PresentationModel<Delivery>(new ValueHolder(null, true));
  12.     private DeliveryEditorService deliveryEditorService;
  13.     private DeliveryCreationService deliveryCreationService;
  14.     private TruckEditorService truckEditorService;
  15.     private DriverEditorService driverEditorService;
  16.     private TruckInquiryService truckInquiryService;
  17.     private DriverInquiryService driverInquiryService;
  18.     private BuyerInquiryService buyerInquiryService;
  19.     private InventorySelectorDelegate selectorDelegate;
  20.     private InventoryInquiryService inventoryInquiryService;
  21.     private SaleOrderKeyDAO saleOrderKeyDAO;
  22.     private final EventList<Buyer> buyers = new BasicEventList<Buyer>();
  23.     private final EventList<Truck> trucks = new BasicEventList<Truck>();
  24.     private final EventList<Driver> drivers = new BasicEventList<Driver>();
  25.     private final EventList<SaleOrderKey> orderKeys = new BasicEventList<SaleOrderKey>();
  26.     private final EventList<Currency> currencies = new BasicEventList<Currency>();
  27.     private final EventList<Location> locations = new BasicEventList<Location>();
  28.     private final EventList<Inventory> allInventories = new BasicEventList<Inventory>();
  29.     private final FilterList<Inventory> inventories = new FilterList<Inventory>(allInventories);
  30.     private final DeliveryForm form = new DeliveryForm();
  31.     private final Executor executor = new SwingWorkerExecutor();
  32.     private InventoryFinder inventoryFinder;
  33.     private static final Logger log = Logger.getLogger(DeliveryForm.class.getPackage().getName());
  34.     private final ProsperPreferences prosperPreferences;
  35.     private SessionFacade sessionFacade;
  36.     private InventoryComboDelegate inventoryComboDelegate;
  37.     private FlowTableModel<DeliveryFlow> flowTableModel;
  38.     private ListTableModel listFlowTableModel;
  39.     private boolean locationEnabled = true;
  40.     private CurrencyProvider currencyProvider = new DefaultCurrencyProvider();
  41.     private final InventoryUnitSupport inventoryUnitSupport = new InventoryUnitSupport();
  42.     private final TableConfigSupport tableConfigSupport = new TableConfigSupport("Delivery", form.getFlowTable());
  43.     private final PresentationModel<Inventory> inventoryInfoPm = new PresentationModel<Inventory>(
  44.             new ValueHolder(
  45.                     null, true));
  46.     private final BasicSaveAction<Delivery, DeliveryInfo> saveAction = new BasicSaveAction<Delivery, DeliveryInfo>(
  47.             this,
  48.             this,
  49.             this);
  50.     private final SaveCookieSupport<Delivery, DeliveryInfo> saveCookieSupport;
  51.  
  52.     public DeliveryTopComponent (){this(SpringSingleton.getBean(ProsperPreferences.class));}
  53.  
  54.     public DeliveryTopComponent(ProsperPreferences prosperPreferences) {
  55.         this.prosperPreferences = prosperPreferences;
  56.         initComponents();
  57.         setName(NbBundle.getMessage(DeliveryTopComponent.class, "CTL_DeliveryTopComponent"));
  58.         setToolTipText(NbBundle.getMessage(DeliveryTopComponent.class, "HINT_DeliveryTopComponent"));
  59.         initBindings();
  60.         initEventHandling();
  61.         saveCookieSupport = SaveCookieSupport.bind(pm, saveAction);
  62.         AbstractNode node = new AbstractNode(Children.LEAF) {
  63.             {
  64.                 getCookieSet().add(new FlowSelectionCookie(flowTableModel, form.getFlowTable()));
  65.             }
  66.         };
  67.         associateLookup(
  68.                 new ProxyLookup(
  69.                         node.getLookup(),
  70.                         new SaveXlsNode(form.getFlowTable()).getLookup(), saveCookieSupport
  71.                         .getLookup()));
  72.         TableModelWrapperUtils.getActualTableModel(form.getFlowTable().getModel()).addTableModelListener(
  73.                 new TableModelListener() {
  74.                     @Override
  75.                     public void tableChanged(TableModelEvent e) {
  76.                         saveCookieSupport.setChanged();
  77.                     }
  78.                 });
  79.     }
  80.  
  81.     private void initComponents() {
  82.         setLayout(new BorderLayout());
  83.         add(form, BorderLayout.CENTER);
  84.  
  85.         AutoSelect autoSelect = new AutoSelect();
  86.         autoSelect.install(form.getTransactionDateField().getFormattedTextField());
  87.  
  88.         AutoCompleteSupportExt.install(form.getTruckComboBox(), trucks).setFilterMode(TextMatcherEditor.CONTAINS);
  89.         AutoCompleteSupportExt.install(form.getBuyerComboBox(), buyers).setFilterMode(TextMatcherEditor.CONTAINS);
  90.         AutoCompleteSupportExt.install(form.getDriverComboBox(), drivers).setFilterMode(TextMatcherEditor.CONTAINS);
  91.         AutoCompleteSupportExt.install(form.getSaleOrderKeyComboBox(), orderKeys).setFilterMode(TextMatcherEditor.CONTAINS);
  92.  
  93.         boolean useScan = prosperPreferences.isUseScan();
  94.         form.getScanField().setVisible(useScan);
  95.         form.getScanField().setVisible(useScan);
  96.  
  97.         flowTableModel = new DeliveryFlowTableModel();
  98.         listFlowTableModel = new ListTableModel(flowTableModel);
  99.         listFlowTableModel.addTableModelListener(this);
  100.         form.getFlowTable().setModel(listFlowTableModel);
  101.  
  102.         TableColumnModel columnModel = form.getFlowTable().getColumnModel();
  103.         int nameIndex = flowTableModel.getColumns().indexOf(FlowColumn.INVENTORY_NAME);
  104.         if (nameIndex >= 0 && nameIndex < columnModel.getColumnCount()) {
  105.             TableColumn nameColumn = columnModel.getColumn(nameIndex);
  106.             nameColumn.setPreferredWidth(300);
  107.         }
  108.         int typeIndex = flowTableModel.getColumns().indexOf(FlowColumn.INVENTORY_TYPE);
  109.         if (typeIndex >= 0 && typeIndex < columnModel.getColumnCount()) {
  110.             TableColumn typeColumn = columnModel.getColumn(typeIndex);
  111.             typeColumn.setCellRenderer(new ColorHashCellRenderer());
  112.         }
  113.  
  114.         DeleteFlowAction deleteFlowAction = new DeleteFlowAction(
  115.                 flowTableModel, form.getFlowTable());
  116.         form.getFlowTable().getInputMap()
  117.                 .put(
  118.                         KeyStroke.getKeyStroke(
  119.                                 KeyEvent.VK_DELETE, InputEvent.CTRL_MASK),
  120.                         "flow_delete");
  121.         form.getFlowTable().getActionMap()
  122.                 .put("flow_delete", deleteFlowAction);
  123.  
  124.         form.getFlowTable().setDefaultRenderer(String.class, new MultilineStringCellRenderer());
  125.  
  126.         JPopupMenu flowMenu = new JPopupMenu();
  127.         flowMenu.add(new JMenuItem(deleteFlowAction));
  128.         form.getFlowTable().addMouseListener(new ComponentPopupListener(flowMenu));
  129.  
  130.         form.getFlowTable().putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  131.  
  132.         FlowTableColumnChooserUtil.setupTable(form.getFlowTable());
  133.  
  134.         InventoryInfoListener inventoryInfoListener = new InventoryInfoListener();
  135.         form.getFlowTable().getSelectionModel()
  136.                 .addListSelectionListener(inventoryInfoListener);
  137.         form.getFlowTable().getModel()
  138.                 .addTableModelListener(inventoryInfoListener);
  139.         float fontSizeRatio = prosperPreferences.getFontSizeRatio();
  140.         form.getFlowTable().setRowHeight(
  141.                 Math.round(
  142.                         form.getFlowTable().getRowHeight() * fontSizeRatio));
  143.  
  144.         form.getFlowTable().setDefaultEditor(
  145.                 Location.class,
  146.                 AutoCompleteSupportExt.createContainsTableCellEditor(locations));
  147.  
  148.         inventoryComboDelegate = InventoryComboDelegate.install(form.getFlowTable(), flowTableModel, true, null);
  149.  
  150.         form.getFlowTable().setDefaultEditor(
  151.                 InventoryUnit.class,
  152.                 AutoCompleteSupportExt.createContainsTableCellEditor(inventoryUnitSupport.getUnits()));
  153.         currencies.addAll(currencyProvider.getInstalledCurrencies());
  154.         form.getFlowTable().setDefaultEditor(
  155.                 Currency.class, AutoCompleteSupportExt.createContainsTableCellEditor(currencies));
  156.         setInventoryFinder(new InventoryFinderCollectionImpl(Collections.<Inventory>emptyList(), false));
  157.     }
  158.  
  159.     private void initBindings() {
  160.         Bindings.bind(
  161.                 form.getTransactionDateField().getFormattedTextField(),
  162.                 new SqlDateConverter(pm.getModel(Usage.PROPERTYNAME_TRANSACTION_DATE)));
  163.         AbstractValueModel buyerModel = pm.getModel(Delivery.PROPERTYNAME_BUYER);
  164.         ComboBoxBinding.bind(form.getBuyerComboBox(), buyerModel, Buyer.class)
  165.                 .setChoices(buyers);
  166.         ComboBoxBinding.bind(form.getDriverComboBox(), pm.getModel(Delivery.PROPERTYNAME_DRIVER), Driver.class)
  167.                 .setChoices(drivers);
  168.         ComboBoxBinding.bind(form.getTruckComboBox(), pm.getModel(Delivery.PROPERTYNAME_TRUCK), Truck.class)
  169.                 .setChoices(trucks);
  170.         ComboBoxBinding.bind(form.getSaleOrderKeyComboBox(), pm.getModel(Delivery.PROPERTYNAME_SALE_ORDER_KEY), SaleOrderKey.class)
  171.                 .setChoices(orderKeys);
  172.     }
  173.  
  174.     private void initEventHandling() {
  175.         form.getAddTruckButton().addActionListener(
  176.                 new ActionListener() {
  177.                     public void actionPerformed(ActionEvent e) {
  178.                         new TruckPresenter(
  179.                                 truckEditorService,
  180.                                 pm.getModel(Weigh.PROPERTYNAME_TRUCK)).display();
  181.                     }
  182.                 });
  183.         form.getAddDriverButton().addActionListener(
  184.                 new ActionListener() {
  185.                     public void actionPerformed(ActionEvent e) {
  186.                         new DriverPresenter(
  187.                                 driverEditorService,
  188.                                 pm.getModel(Weigh.PROPERTYNAME_DRIVER)).display();
  189.                     }
  190.                 });
  191.         form.getSaveButton().setAction(saveAction);
  192.         form.getCancelButton().setAction(
  193.                 new BasicCancelAction<Delivery, DeliveryInfo>(
  194.                         this, this, this
  195.                 ));
  196.     }
  197.  
  198.     // Variables declaration - do not modify//GEN-BEGIN:variables
  199.     // End of variables declaration//GEN-END:variables
  200.     /**
  201.      * Gets default instance. Do not use directly: reserved for *.settings files only,
  202.      * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
  203.      * To obtain the singleton instance, use {@link #findInstance}.
  204.      */
  205.     public static DeliveryTopComponent getDefault() {
  206.         return new DeliveryTopComponent();
  207.     }
  208.  
  209.     /**
  210.      * Obtain the DeliveryTopComponent instance. Never call {@link #getDefault} directly!
  211.      */
  212.     public static DeliveryTopComponent findInstance() {
  213.         TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
  214.         if (win == null) {
  215.             Logger.getLogger(DeliveryTopComponent.class.getName()).warning(
  216.                     "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
  217.             return getDefault();
  218.         }
  219.         if (win instanceof DeliveryTopComponent) {
  220.             return (DeliveryTopComponent) win;
  221.         }
  222.         Logger.getLogger(DeliveryTopComponent.class.getName()).warning(
  223.                 "There seem to be multiple components with the '" + PREFERRED_ID
  224.                 + "' ID. That is a potential source of errors and unexpected behavior.");
  225.         return getDefault();
  226.     }
  227.  
  228.     public void setSessionFacade(SessionFacade sessionFacade) {
  229.         this.sessionFacade = sessionFacade;
  230.         flowTableModel.setSessionFacade(sessionFacade);
  231.         inventoryUnitSupport.setSessionFacade(sessionFacade);
  232.         selectorDelegate = new InventorySelectorDelegate(
  233.                 sessionFacade, new InventorySelectorDelegate.Callback() {
  234.             @Nullable
  235.             @Override
  236.             public Location getCurrentLocation() {
  237.                 return null;
  238.             }
  239.         }, true, null);
  240.         if (inventoryFinder != null) {
  241.             selectorDelegate.setFinder(inventoryFinder);
  242.         }
  243.  
  244.         selectorDelegate.setEnableSerialNumberList(false);
  245.         selectorDelegate.setScanField(form.getScanField());
  246.         selectorDelegate.prepare();
  247.         selectorDelegate.addSelectorListener(new DeliverySelectorListener());
  248.     }
  249.  
  250.     // harus menggunakan inventory finder yang Collection karena ada filter supplier
  251.     private void setInventoryFinder(InventoryFinder inventoryFinder) {
  252.         this.inventoryFinder = inventoryFinder;
  253.         flowTableModel.setInventoryFinder(inventoryFinder);
  254.         inventoryComboDelegate.setFinder(inventoryFinder);
  255.     }
  256.  
  257.     /**
  258.      * Get the inventories for this frame.
  259.      *
  260.      * @return the inventories
  261.      */
  262.     public List<Inventory> getInventories() {
  263.         return inventories;
  264.     }
  265.  
  266.     public void setAllowUpdateDate(boolean allowUpdateDate) {
  267.         form.getTransactionDateField().setEnabled(allowUpdateDate);
  268.     }
  269.  
  270.     public void setInventoryInquiryService(InventoryInquiryService inventoryInquiryService) {
  271.         this.inventoryInquiryService = inventoryInquiryService;
  272.     }
  273.  
  274.     public void setDeliveryEditorService(DeliveryEditorService deliveryEditorService) {
  275.         this.deliveryEditorService = deliveryEditorService;
  276.     }
  277.  
  278.     public void setDeliveryCreationService(DeliveryCreationService deliveryCreationService) {
  279.         this.deliveryCreationService = deliveryCreationService;
  280.     }
  281.  
  282.     public void setBuyerInquiryService(BuyerInquiryService buyerInquiryService) {
  283.         this.buyerInquiryService = buyerInquiryService;
  284.     }
  285.  
  286.     public void setTruckEditorService(TruckEditorService truckEditorService) {
  287.         this.truckEditorService = truckEditorService;
  288.     }
  289.  
  290.     public void setDriverEditorService(DriverEditorService driverEditorService) {
  291.         this.driverEditorService = driverEditorService;
  292.     }
  293.  
  294.     public void setTruckInquiryService(TruckInquiryService truckInquiryService) {
  295.         this.truckInquiryService = truckInquiryService;
  296.     }
  297.  
  298.     public void setDriverInquiryService(DriverInquiryService driverInquiryService) {
  299.         this.driverInquiryService = driverInquiryService;
  300.     }
  301.  
  302.     public void setCurrencyProvider(CurrencyProvider currencyProvider) {
  303.         this.currencyProvider = currencyProvider;
  304.     }
  305.  
  306.     public void setLocationEnabled(boolean locationEnabled) {
  307.         this.locationEnabled = locationEnabled;
  308.     }
  309.  
  310.     public void setSaleOrderKeyDAO(SaleOrderKeyDAO saleOrderKeyDAO) {
  311.         this.saleOrderKeyDAO = saleOrderKeyDAO;
  312.     }
  313.  
  314.     @Override
  315.     public int getPersistenceType() {
  316.         return TopComponent.PERSISTENCE_ALWAYS;
  317.     }
  318.  
  319.     @Override
  320.     protected Object writeReplace() {
  321.         return new PersistentResolvableHelper<Delivery, DeliveryTopComponent>(
  322.                 getBean(), new NewInstanceAutowireFactory<DeliveryTopComponent>(DeliveryTopComponent.class));
  323.     }
  324.  
  325.     @Override
  326.     protected void componentShowing() {
  327.         executor.execute(new DriverFindWorker(driverInquiryService, drivers));
  328.         executor.execute(new TruckFindWorker(truckInquiryService, trucks));
  329.         executor.execute(new BuyerFindWorker(buyerInquiryService, buyers));
  330.         executor.execute(new SaleOrderKeyFindWorker(orderKeys, saleOrderKeyDAO));
  331.         refreshInventories();
  332.         super.componentShowing();
  333.     }
  334.  
  335.     @Override
  336.     public void componentOpened() {
  337.         tableConfigSupport.load();
  338.         super.componentOpened();
  339.     }
  340.  
  341.     @Override
  342.     public void componentClosed() {
  343.         tableConfigSupport.save();
  344.         super.componentClosed();
  345.     }
  346.  
  347.     @Override
  348.     public void momentumCommitted(MomentumModelEvent event) {}
  349.  
  350.     @Override
  351.     public void momentumReverted(MomentumModelEvent event) {
  352.         bindFromModel();
  353.     }
  354.  
  355.     @Override
  356.     public void momentumAdded(MomentumModelEvent event) {}
  357.  
  358.     @Override
  359.     public void momentumRemoved(MomentumModelEvent event) {}
  360.  
  361.     @Override
  362.     public void modelDestroyed() {}
  363.  
  364.     @Override
  365.     protected String preferredID() {
  366.         return PREFERRED_ID;
  367.     }
  368.  
  369.     @Override
  370.     public BasicEditorService<Delivery, DeliveryInfo> getBasicEditorService() {
  371.         return deliveryEditorService;
  372.     }
  373.  
  374.     @Override
  375.     public BasicCreationService<Delivery> getBasicCreationService() {
  376.         return deliveryCreationService;
  377.     }
  378.  
  379.     @Override
  380.     public void setBean(Delivery t) {
  381.         pm.setBean(t);
  382.         bindFromModel();
  383.         FlowAwareFocus focus = prosperPreferences.getFlowAwareFocus();
  384.         if (focus != null) {
  385.             switch (focus) {
  386.                 case SCAN:
  387.                     form.getScanField().requestFocusInWindow();
  388.                     break;
  389.                 case NAME:
  390.                 case TABLE:
  391.                     form.getFlowTable().requestFocusInWindow();
  392.                     break;
  393.                 case DEFAULT:
  394.                     break;
  395.             }
  396.         }
  397.  
  398.         pm.resetChanged();
  399.     }
  400.  
  401.     @Override
  402.     public Delivery getBean() {
  403.         return pm.getBean();
  404.     }
  405.  
  406.     @Override
  407.     public void setAllowSave(boolean allowSave) {
  408.         saveAction.setEnabled(allowSave);
  409.     }
  410.  
  411.     @Override
  412.     public void addSaveListener(ActionListener listener) {
  413.         saveAction.addSaveListener(listener);
  414.     }
  415.  
  416.     @Override
  417.     public void removeSaveListener(ActionListener listener) {
  418.         saveAction.removeSaveListener(listener);
  419.     }
  420.  
  421.     @Override
  422.     public void tableChanged(TableModelEvent e) {}
  423.  
  424.     List<FlowColumn> getColumns() {return new ArrayList<FlowColumn>(flowTableModel.getColumns());}
  425.  
  426.     private void bindFromModel() {
  427.         Delivery delivery = pm.getBean();
  428.         if (delivery != null) {
  429.             if (log.isLoggable(Level.FINE)) {
  430.                 log.fine(
  431.                         "The current supplier is ");
  432.             }
  433.  
  434.             flowTableModel.setFlows(delivery.getFlows());
  435.             listFlowTableModel.setList(delivery.getFlows());
  436.  
  437.         } else {
  438.             flowTableModel.setFlows(null);
  439.             listFlowTableModel.setList(null);
  440.  
  441.             disableEditor();
  442.         }
  443.     }
  444.  
  445.     private void disableEditor() {
  446.         form.getCancelButton().setEnabled(false);
  447.     }
  448.  
  449.     private void refreshInventories() {
  450.         if (!prosperPreferences.isUseHugeInventory()) {
  451.             executor.execute(
  452.                     new InventoryPurchaseFindWorker(allInventories, inventoryInquiryService) {
  453.                         @Override
  454.                         protected void setObjects(List<Inventory> t) {
  455.                             super.setObjects(t);
  456.                             setInventoryFinder(new InventoryFinderCollectionImpl(t, false));
  457.                         }
  458.                     });
  459.         }
  460.     }
  461.  
  462.     private void updateInventoryInfo(Inventory inventory) {
  463.         inventoryInfoPm.setBean(inventory);
  464.     }
  465.  
  466.     class DeliveryFlowTableModel
  467.             extends FlowTableModel<DeliveryFlow>
  468.             implements Creative {
  469.         private static final long serialVersionUID = 1L;
  470.  
  471.         DeliveryFlowTableModel() {
  472.             super(
  473.                     sessionFacade, prosperPreferences, currencyProvider,
  474.                     FlowColumnsFactory.build(prosperPreferences));
  475.             setCanPurchase(true);
  476.         }
  477.  
  478.         @Override
  479.         public boolean isCellEditable(int rowIndex, int columnIndex) {
  480.             if (getColumns().get(columnIndex) == FlowColumn.LOCATION) {
  481.                 return locationEnabled;
  482.             }
  483.  
  484.             return super.isCellEditable(rowIndex, columnIndex);
  485.         }
  486.  
  487.         @Override
  488.         public Object create() {
  489.             DeliveryFlow flow = new DeliveryFlow();
  490.             flow.setDelivery(pm.getBean());
  491.             flow.setNormalQuantity(1);
  492.             return flow;
  493.         }
  494.  
  495.         @Override
  496.         public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  497.             super.setValueAt(aValue, rowIndex, columnIndex);
  498.  
  499.             Delivery delivery = pm.getBean();
  500.  
  501.             if (delivery != null) {
  502.                 List<DeliveryFlow> flows = delivery.getFlows();
  503.  
  504.                 if ((rowIndex < flows.size()) && (rowIndex >= 0)) {
  505.                     FlowColumn column = getColumns().get(columnIndex);
  506.                     // not all cases are handled
  507.                     //noinspection EnumSwitchStatementWhichMissesCases
  508.                     switch (column) {
  509.                         case INVENTORY_NAME:
  510.                         case INVENTORY_CODE:
  511.                         case INVENTORY_TYPE:
  512.                         default:
  513.  
  514.                             // ignore
  515.                     }
  516.                 }
  517.             }
  518.         }
  519.  
  520.     }
  521.  
  522.     private class InventoryInfoListener
  523.             implements ListSelectionListener, TableModelListener {
  524.  
  525.         @Override
  526.         public void tableChanged(TableModelEvent e) {
  527.             handle();
  528.         }
  529.  
  530.  
  531.         @Override
  532.         public void valueChanged(ListSelectionEvent e) {
  533.             if (!e.getValueIsAdjusting()) {
  534.                 handle();
  535.             }
  536.         }
  537.  
  538.         private void handle() {
  539.             Inventory inventory = null;
  540.             Delivery delivery = pm.getBean();
  541.  
  542.             if (delivery != null) {
  543.                 int row = form.getFlowTable().getSelectedRow();
  544.                 List<DeliveryFlow> flows = delivery.getFlows();
  545.  
  546.                 if ((row >= 0) && (row < flows.size())) {
  547.                     DeliveryFlow flow = flows.get(row);
  548.                     inventory = flow.getInventory();
  549.                 }
  550.             }
  551.  
  552.             updateInventoryInfo(inventory);
  553.             inventoryUnitSupport.updateInventoryUnits(inventory);
  554.         }
  555.     }
  556.  
  557.     private class DeliverySelectorListener
  558.             extends AbstractInventorySelectorListener<Delivery, DeliveryFlow> {
  559.  
  560.         @Override
  561.         protected void requestFocusAfterAdd() {
  562.         }
  563.  
  564.         @Override
  565.         protected void updatePrice(InventorySelectorDelegate.AddEvent event, DeliveryFlow flow) {
  566.             flow.setUnitPrice(event.getPrice());
  567.         }
  568.  
  569.         @Override
  570.         protected List<DeliveryFlow> getChildren(Delivery t) {return t.getFlows();}
  571.  
  572.         @Override
  573.         protected void fireTableRowsInserted(int firstRow) {flowTableModel.fireTableRowsInserted(firstRow, firstRow);}
  574.  
  575.         @Override
  576.         protected void fireTableRowsUpdated(int i) {flowTableModel.fireTableRowsUpdated(i, i);}
  577.  
  578.         @Override
  579.         protected Delivery getBean() {return pm.getBean();}
  580.  
  581.         @Override
  582.         protected void updateInventoryInfo(Inventory inventory, @Nullable Location location) {
  583.             DeliveryTopComponent.this.updateInventoryInfo(inventory);
  584.         }
  585.  
  586.         @Override
  587.         protected void updateSelectorPrice(double qty, Inventory inventory) {
  588.             if (inventory != null && inventory.getId() != null) {
  589.                 Double unitPrice = sessionFacade.getLatestPurchasePrice(inventory);
  590.                 selectorDelegate.setUnitPrice(unitPrice);
  591.             }
  592.         }
  593.  
  594.         @Override
  595.         protected void updateInventoryUnits(Inventory inventory) {inventoryUnitSupport.updateInventoryUnits(inventory);}
  596.  
  597.         @Override
  598.         protected void updateFlowPrice(DeliveryFlow flow, double price) {
  599.             flow.setUnitPrice(price);
  600.         }
  601.  
  602.         @Override
  603.         protected void updateTotal() {}
  604.  
  605.         @Override
  606.         protected void updateLocation(Delivery sale, DeliveryFlow flow) {}
  607.  
  608.         @Override
  609.         protected JTable getFlowTable() {
  610.             return form.getFlowTable();
  611.         }
  612.  
  613.         @Override
  614.         protected JFormattedTextField getAddPriceField() {
  615.             return null;
  616.         }
  617.  
  618.         @Override
  619.         protected DeliveryFlow createChildren(Delivery t) {
  620.             return new DeliveryFlow(t);
  621.         }
  622.  
  623.         protected void addFlow(Delivery t, DeliveryFlow flow) {t.getFlows().add(flow);}
  624.  
  625.         protected boolean decideEqual(InventorySelectorDelegate.AddEvent event, DeliveryFlow existingFlow) {
  626.             return InventorySelectorPriceDecider.decideEqual(event, existingFlow);
  627.         }
  628.     }
  629. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top