Skip to content

Commit

Permalink
Merge branch 'main' into native
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenGnu committed Oct 30, 2024
2 parents 1dea0bb + 92f55c5 commit cff6f1e
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/nikr/eve/jeveasset/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import net.nikr.eve.jeveasset.gui.shared.components.JLockWindow;
import net.nikr.eve.jeveasset.gui.shared.components.JLockWindow.LockWorkerAdaptor;
import net.nikr.eve.jeveasset.gui.shared.components.JMainTab;
import net.nikr.eve.jeveasset.gui.shared.filter.FilterMatcher;
import net.nikr.eve.jeveasset.gui.sounds.SoundPlayer;
import net.nikr.eve.jeveasset.gui.tabs.assets.AssetsTab;
import net.nikr.eve.jeveasset.gui.tabs.contracts.ContractsTab;
Expand Down Expand Up @@ -606,6 +607,7 @@ public final void updateEventLists() {

private synchronized void updateEventLists(Set<Long> itemIDs, Set<Long> locationIDs, Set<Integer> typeIDs, OutbidProcesserOutput output) {
LOG.info("Updating EventList");
FilterMatcher.clearColumnValueCache();
for (JMainTab jMainTab : mainWindow.getTabs()) {
ensureEDT(new Runnable() {
@Override
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/net/nikr/eve/jeveasset/data/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public static enum SettingFlag {
FLAG_SHOW_SUBPILE_TREE,
FLAG_INDUSTRY_JOBS_HISTORY,
FLAG_ASSETS_CONTRACTS_OWNER_CORP,
FLAG_ASSETS_CONTRACTS_OWNER_BOTH
FLAG_ASSETS_CONTRACTS_OWNER_BOTH,
FLAG_CELL_VALUE_CACHE
}

public static enum TransactionProfitPrice {
Expand Down Expand Up @@ -231,7 +232,8 @@ public String toString() {
private Boolean highlightSelectedRows = null; //Assets
private Boolean reprocessColors = null; //Assets
private Boolean stockpileHalfColors = null; //Stockpile
private Boolean containersShowItemID = null; //Stockpile
private Boolean containersShowItemID = null; //Container ItemID
private Boolean cellValueCache = null; //Cell value cache
//Table settings
//Filters Saved by ExportFilterControl.saveSettings()
//Lock OK
Expand Down Expand Up @@ -308,6 +310,7 @@ protected Settings() {
flags.put(SettingFlag.FLAG_INDUSTRY_JOBS_HISTORY, true);
flags.put(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_CORP, false);
flags.put(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_BOTH, false);
flags.put(SettingFlag.FLAG_CELL_VALUE_CACHE, true);
cacheFlags();
//Default Filters
List<Filter> filter;
Expand Down Expand Up @@ -491,6 +494,7 @@ public final void cacheFlags() {
reprocessColors = flags.get(SettingFlag.FLAG_REPROCESS_COLORS);
stockpileHalfColors = flags.get(SettingFlag.FLAG_STOCKPILE_HALF_COLORS);
containersShowItemID = flags.get(SettingFlag.FLAG_CONTAINERS_SHOW_ITEM_ID);
cellValueCache = flags.get(SettingFlag.FLAG_CELL_VALUE_CACHE);
}

public ReprocessSettings getReprocessSettings() {
Expand Down Expand Up @@ -735,9 +739,6 @@ public void setTransactionProfitMargin(int transactionProfitMargin) {
}

public boolean isFilterOnEnter() {
if (filterOnEnter == null) {
filterOnEnter = flags.get(SettingFlag.FLAG_FILTER_ON_ENTER);
}
return filterOnEnter;
}

Expand Down Expand Up @@ -934,6 +935,15 @@ public void setAssetsContractsOwnerBoth(final boolean assetsContractsOwnerBoth)
flags.put(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_BOTH, assetsContractsOwnerBoth);
}

public boolean isColumnValueCache() {
return cellValueCache;
}

public void setCellValueCache(final boolean cellValueCache) {
flags.put(SettingFlag.FLAG_CELL_VALUE_CACHE, cellValueCache);
this.cellValueCache = cellValueCache;
}

public boolean isMarketOrderHistory() {
return flags.get(SettingFlag.FLAG_MARKET_ORDER_HISTORY);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2009-2024 Contributors (see credits.txt)
*
* This file is part of jEveAssets.
*
* jEveAssets is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* jEveAssets is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with jEveAssets; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

package net.nikr.eve.jeveasset.gui.dialogs.settings;

import javax.swing.GroupLayout;
import javax.swing.JCheckBox;
import net.nikr.eve.jeveasset.Program;
import net.nikr.eve.jeveasset.data.settings.Settings;
import net.nikr.eve.jeveasset.gui.images.Images;


public class ExperimentalSettingsPanel extends JSettingsPanel {

private final JCheckBox jCellValueCache;

public ExperimentalSettingsPanel(final Program program, final SettingsDialog settingsDialog) {
super(program, settingsDialog, "Experimental", Images.JOBS_INVENTION_SUCCESS.getIcon());
jCellValueCache = new JCheckBox("Filter cell value cache");

layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jCellValueCache)
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(jCellValueCache, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
);
}

@Override
public UpdateType save() {
Settings.get().setCellValueCache(jCellValueCache.isSelected());
return UpdateType.NONE;
}

@Override
public void load() {
jCellValueCache.setSelected(Settings.get().isColumnValueCache());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public SettingsDialog(final Program program) {
GeneralSettingsPanel generalSettingsPanel = new GeneralSettingsPanel(program, this);
add(generalSettingsPanel);

add(new ExperimentalSettingsPanel(program, this));

DefaultMutableTreeNode toolNode = addGroup(DialoguesSettings.get().tools(), Images.SETTINGS_TOOLS.getIcon());

add(toolNode, new ShowToolSettingsPanel(program, this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import java.text.ParsePosition;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
Expand All @@ -46,6 +48,8 @@ public class FilterMatcher<E> implements Matcher<E> {
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(LOCALE);
private static final NumberFormat PERCENT_FORMAT = NumberFormat.getPercentInstance(LOCALE);
private static final Calendar CALENDAR = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
private static final Map<Object, String> CELL_VALUE_CACHE = new HashMap<>();
private static boolean cellValueCache = false; //Cell value cache

private final SimpleTableFormat<E> tableFormat;
private final ColumnCache<E> columnCache;
Expand Down Expand Up @@ -482,7 +486,27 @@ private static String formatData(final Object object, final boolean userInput) {
return format(object, userInput).toLowerCase();
}

public static void clearColumnValueCache() {
CELL_VALUE_CACHE.clear();
cellValueCache = Settings.get().isColumnValueCache();
}

private static String format(final Object object, final boolean userInput) {
if (cellValueCache) {
String value = CELL_VALUE_CACHE.get(object);
if (value != null) {
return value;
} else {
value = createFormat(object, userInput);
CELL_VALUE_CACHE.put(object, value);
return value;
}
} else {
return createFormat(object, userInput);
}
}

private static String createFormat(final Object object, final boolean userInput) {
if (object == null) {
return null;
}
Expand Down

0 comments on commit cff6f1e

Please sign in to comment.