Пример #1
0
 StockpileItem showEdit(final StockpileItem addStockpileItem) {
   updateData();
   this.stockpileItem = addStockpileItem;
   this.getDialog().setTitle(TabsStockpile.get().editStockpileItem());
   Item item = StaticData.get().getItems().get(addStockpileItem.getTypeID());
   jItems.setSelectedItem(item);
   jCopy.setSelected(addStockpileItem.isBPC());
   jCountMinimum.setText(String.valueOf(addStockpileItem.getCountMinimum()));
   show();
   return stockpileItem;
 }
Пример #2
0
 private StockpileItem getExistingItem() {
   Item typeItem = (Item) jItems.getSelectedItem();
   boolean copy = jCopy.isSelected();
   if (getStockpile() != null && typeItem != null) {
     for (StockpileItem item : getStockpile().getItems()) {
       if (item.getTypeID() == typeItem.getTypeID() && (copy == item.isBPC())) {
         return item;
       }
     }
   }
   return null;
 }
Пример #3
0
 private Stockpile getStockpile() {
   if (stockpile != null) {
     return stockpile;
   } else if (stockpileItem != null) {
     return stockpileItem.getStockpile();
   } else {
     return null;
   }
 }
Пример #4
0
 @Override
 protected void save() {
   Settings.lock("Stockpile (Items Dialog)"); // Lock for Stockpile (Items Dialog)
   if (stockpileItem != null) { // EDIT
     if (itemExist()) { // EDIT + UPDATING (Editing to an existing item)
       StockpileItem existingItem = getExistingItem();
       existingItem.getStockpile().remove(existingItem);
       program.getStockpileTool().removeItem(existingItem);
     }
     stockpileItem.update(getStockpileItem());
   } else if (itemExist()) { // UPDATING (Adding an existing item)
     stockpileItem = getExistingItem();
     stockpileItem.update(getStockpileItem());
   } else { // ADD
     stockpileItem = getStockpileItem();
     stockpile.add(stockpileItem);
   }
   Settings.unlock("Stockpile (Items Dialog)"); // Unlock for Stockpile (Items Dialog)
   program.saveSettings("Stockpile (Items Dialog)"); // Save Stockpile (Items Dialog)
   super.setVisible(false);
 }