/**
  * Update settings with new price data
  *
  * @param task UpdateTask to update progress on
  * @param updateAll if true update all prices, if false only update new/missing prices
  * @return true if OK or false if FAILED
  */
 private boolean processUpdate(final UpdateTask task, final boolean updateAll) {
   Map<Integer, PriceData> priceData =
       processUpdate(
           task,
           updateAll,
           new DefaultPricingOptions(),
           profileData.getPriceTypeIDs(),
           Settings.get().getPriceDataSettings().getSource());
   if (priceData != null) {
     Settings.get().setPriceData(priceData);
     return true;
   } else {
     return false;
   }
 }
 /**
  * Load price data from cache. Don't update missing prices
  *
  * @return
  */
 public boolean load() {
   Map<Integer, PriceData> priceData = processLoad(profileData.getPriceTypeIDs());
   if (priceData != null) {
     Settings.get().setPriceData(priceData);
     return true;
   } else {
     return false;
   }
 }
 public static String getOwnerName(final long ownerID) {
   if (ownerID == 0) { // 0 (zero) is valid, but, should return empty string
     return "";
   }
   String owner = Settings.get().getOwners().get(ownerID);
   if (owner != null) {
     return owner;
   }
   return "!" + String.valueOf(ownerID);
 }
Beispiel #4
0
 @Override
 public void actionPerformed(final ActionEvent e) {
   if (FilterPanelAction.REMOVE.name().equals(e.getActionCommand())) {
     gui.remove(getThis());
     gui.addEmpty();
     refilter();
   }
   if (FilterPanelAction.FILTER.name().equals(e.getActionCommand())) {
     processFilterAction(e);
   }
   if (FilterPanelAction.FILTER_TIMER.name().equals(e.getActionCommand())) {
     if (!Settings.get().isFilterOnEnter()) {
       processFilterAction(e);
     }
   }
 }
 public static double getPriceReprocessed(Item item) {
   double priceReprocessed = 0;
   int portionSize = 0;
   for (ReprocessedMaterial material : item.getReprocessedMaterial()) {
     // Calculate reprocessed price
     portionSize = material.getPortionSize();
     double price = ApiIdConverter.getPriceReprocessed(material.getTypeID(), false);
     priceReprocessed =
         priceReprocessed
             + (price
                 * Settings.get()
                     .getReprocessSettings()
                     .getLeft(material.getQuantity(), item.isOre()));
   }
   if (priceReprocessed > 0 && portionSize > 0) {
     priceReprocessed = priceReprocessed / portionSize;
   }
   return priceReprocessed;
 }
  private static double getPriceType(
      final int typeID, final boolean isBlueprintCopy, boolean reprocessed) {
    UserItem<Integer, Double> userPrice;
    if (isBlueprintCopy) { // Blueprint Copy
      userPrice = Settings.get().getUserPrices().get(-typeID);
    } else { // All other
      userPrice = Settings.get().getUserPrices().get(typeID);
    }
    if (userPrice != null) {
      return userPrice.getValue();
    }

    // Blueprint Copy (Default Zero)
    if (isBlueprintCopy) {
      return 0;
    }

    // Blueprints Base Price
    Item item = getItem(typeID);
    // Tech 1
    if (item.isBlueprint()) {
      if (Settings.get().isBlueprintBasePriceTech1()
          && !item.getTypeName().toLowerCase().contains("ii")) {
        return item.getPriceBase();
      }
      // Tech 2
      if (Settings.get().isBlueprintBasePriceTech2()
          && item.getTypeName().toLowerCase().contains("ii")) {
        return item.getPriceBase();
      }
    }

    // Price data
    PriceData priceData = Settings.get().getPriceData().get(typeID);
    if (priceData != null && priceData.isEmpty()) {
      priceData = null;
    }
    if (reprocessed) {
      return Settings.get().getPriceDataSettings().getDefaultPriceReprocessed(priceData);
    } else {
      return Settings.get().getPriceDataSettings().getDefaultPrice(priceData);
    }
  }
 @Override
 public void load() {
   jSaveHistory.setSelected(Settings.get().isMarketOrderHistory());
 }
 @Override
 public boolean save() {
   Settings.get().setMarketOrderHistory(jSaveHistory.isSelected());
   return false;
 }
  public IndustryJobsTab(final Program program) {
    super(program, TabsJobs.get().industry(), Images.TOOL_INDUSTRY_JOBS.getIcon(), true);

    ListenerClass listener = new ListenerClass();
    // Table Format
    tableFormat =
        new EnumTableFormatAdaptor<IndustryJobTableFormat, MyIndustryJob>(
            IndustryJobTableFormat.class);
    // Backend
    eventList = program.getProfileData().getIndustryJobsEventList();
    // Sorting (per column)
    eventList.getReadWriteLock().readLock().lock();
    SortedList<MyIndustryJob> sortedList = new SortedList<MyIndustryJob>(eventList);
    eventList.getReadWriteLock().readLock().unlock();

    // Filter
    eventList.getReadWriteLock().readLock().lock();
    filterList = new FilterList<MyIndustryJob>(sortedList);
    eventList.getReadWriteLock().readLock().unlock();
    filterList.addListEventListener(listener);
    // Table Model
    tableModel = EventModels.createTableModel(filterList, tableFormat);
    // Table
    jTable = new JAutoColumnTable(program, tableModel);
    jTable.setCellSelectionEnabled(true);
    PaddingTableCellRenderer.install(jTable, 1);
    // Sorting
    TableComparatorChooser.install(
        jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
    // Selection Model
    selectionModel = EventModels.createSelectionModel(filterList);
    selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE);
    jTable.setSelectionModel(selectionModel);
    // Listeners
    installTable(jTable, NAME);
    // Scroll
    JScrollPane jTableScroll = new JScrollPane(jTable);
    // Table Filter
    Map<String, List<Filter>> defaultFilters = new HashMap<String, List<Filter>>();
    List<Filter> filter;
    filter = new ArrayList<Filter>();
    filter.add(
        new Filter(
            LogicType.AND,
            IndustryJobTableFormat.STATE,
            CompareType.EQUALS_NOT,
            IndustryJobState.STATE_DELIVERED.toString()));
    defaultFilters.put(TabsJobs.get().active(), filter);
    filter = new ArrayList<Filter>();
    filter.add(
        new Filter(
            LogicType.AND,
            IndustryJobTableFormat.STATE,
            CompareType.EQUALS,
            IndustryJobState.STATE_DELIVERED.toString()));
    defaultFilters.put(TabsJobs.get().completed(), filter);
    filterControl =
        new IndustryJobsFilterControl(
            program.getMainWindow().getFrame(),
            tableFormat,
            sortedList,
            filterList,
            Settings.get().getTableFilters(NAME),
            defaultFilters);

    // Menu
    installMenu(program, new JobsTableMenu(), jTable, MyIndustryJob.class);

    jInventionSuccess =
        StatusPanel.createLabel(
            TabsJobs.get().inventionSuccess(), Images.JOBS_INVENTION_SUCCESS.getIcon());
    this.addStatusbarLabel(jInventionSuccess);

    jManufactureOutputValue =
        StatusPanel.createLabel(
            TabsJobs.get().manufactureJobsValue(), Images.TOOL_VALUES.getIcon());
    this.addStatusbarLabel(jManufactureOutputValue);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup()
            .addComponent(filterControl.getPanel())
            .addComponent(jTableScroll, 700, 700, Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(filterControl.getPanel())
            .addComponent(jTableScroll, 100, 400, Short.MAX_VALUE));
  }
 @Override
 public Proxy getProxy() {
   return Settings.get().getProxy();
 }
 @Override
 public List<Long> getLocations() {
   return Settings.get().getPriceDataSettings().getLocations();
 }
 @Override
 public LocationType getLocationType() {
   return Settings.get().getPriceDataSettings().getLocationType();
 }
 @Override
 public PricingFetch getPricingFetchImplementation() {
   return Settings.get().getPriceDataSettings().getSource().getPricingFetch();
 }