Skip to content

Commit

Permalink
New Feature: Show/Hide container ItemID in the Assets and Tree tools
Browse files Browse the repository at this point in the history
Merge Feature
  • Loading branch information
GoldenGnu committed May 2, 2024
2 parents 93f7472 + 86c608e commit 69b4dbd
Show file tree
Hide file tree
Showing 19 changed files with 233 additions and 55 deletions.
11 changes: 8 additions & 3 deletions src/main/java/net/nikr/eve/jeveasset/data/api/my/MyAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.nikr.eve.jeveasset.data.settings.types.TagsType;
import net.nikr.eve.jeveasset.gui.shared.Formatter;
import net.nikr.eve.jeveasset.gui.shared.menu.JMenuInfo.InfoItem;
import net.nikr.eve.jeveasset.gui.shared.table.containers.AssetContainer;
import net.nikr.eve.jeveasset.gui.tabs.assets.AssetsTab;
import net.nikr.eve.jeveasset.i18n.DataModelAsset;
import net.nikr.eve.jeveasset.i18n.General;
Expand All @@ -70,7 +71,7 @@ public class MyAsset extends RawAsset implements Comparable<MyAsset>, InfoItem,
//Dynamic values
private String name;
private String itemName = null;
private String container = "";
private AssetContainer container = new AssetContainer();
private PriceData priceData = new PriceData();
private UserItem<Integer, Double> userPrice;
private long typeCount = 0;
Expand Down Expand Up @@ -208,6 +209,10 @@ public List<MyAsset> getAssets() {
}

public String getContainer() {
return container.getContainer();
}

public AssetContainer getAssetContainer() {
return container;
}

Expand Down Expand Up @@ -457,8 +462,8 @@ public void setBlueprint(MyBlueprint blueprint) {
updateBlueprint();
}

public void setContainer(final String container) {
this.container = container;
public void updateContainer() {
this.container = new AssetContainer(this);
}

public void setMarketPriceData(final MarketPriceData marketPriceData) {
Expand Down
26 changes: 2 additions & 24 deletions src/main/java/net/nikr/eve/jeveasset/data/profile/ProfileData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ private void addAssets(final List<MyAsset> assets, List<MyAsset> addTo, Map<Long
asset.setMarketPriceData(transactionBuyPriceData.get(asset.getItem().getTypeID()));
//User Item Names
updateName(asset);
//Contaioner
//Container
updateContainer(asset);
//Price data
asset.setPriceData(ApiIdConverter.getPriceData(asset.getItem().getTypeID(), asset.isBPC()));
Expand Down Expand Up @@ -1369,21 +1369,7 @@ private void updateContainerChildren(List<MyAsset> found, List<MyAsset> assets)
}

private void updateContainer(MyAsset asset) {
StringBuilder builder = new StringBuilder();
if (asset.getParents().isEmpty()) {
builder.append(General.get().none());
} else {
boolean first = true;
for (MyAsset parentAsset : asset.getParents()) {
if (first) {
first = false;
} else {
builder.append(" > ");
}
builder.append(containerName(parentAsset));
}
}
asset.setContainer(builder.toString().intern());
asset.updateContainer();
}

private void updateStructureAssets(final MyAsset asset, final MyAsset structure) {
Expand All @@ -1401,14 +1387,6 @@ private void updateStructureAssets(final MyAsset asset, final MyAsset structure)
}
}

public static String containerName(MyAsset asset) {
if (!asset.isUserName()) {
return asset.getName() + " #" + asset.getItemID();
} else {
return asset.getName();
}
}

private static class Match<T> implements Comparable<Match<T>>{
private final T t;
private final double amount;
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/net/nikr/eve/jeveasset/data/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public static enum SettingFlag {
FLAG_SAVE_CONTRACT_HISTORY,
FLAG_SAVE_MINING_HISTORY,
FLAG_MANUFACTURING_DEFAULT,
FLAG_EASY_CHART_COLORS
FLAG_EASY_CHART_COLORS,
FLAG_CONTAINERS_SHOW_ITEM_ID
}

public static enum TransactionProfitPrice {
Expand Down Expand Up @@ -224,6 +225,7 @@ public String toString() {
private Boolean highlightSelectedRows = null; //Assets
private Boolean reprocessColors = null; //Assets
private Boolean stockpileHalfColors = null; //Stockpile
private Boolean containersShowItemID = null; //Stockpile
//Table settings
//Filters Saved by ExportFilterControl.saveSettings()
//Lock OK
Expand Down Expand Up @@ -294,6 +296,7 @@ protected Settings() {
flags.put(SettingFlag.FLAG_SAVE_MINING_HISTORY, true);
flags.put(SettingFlag.FLAG_MANUFACTURING_DEFAULT, true);
flags.put(SettingFlag.FLAG_EASY_CHART_COLORS, false);
flags.put(SettingFlag.FLAG_CONTAINERS_SHOW_ITEM_ID, true);
cacheFlags();
//Default Filters
List<Filter> filter;
Expand Down Expand Up @@ -474,6 +477,7 @@ public final void cacheFlags() {
filterOnEnter = flags.get(SettingFlag.FLAG_FILTER_ON_ENTER);
reprocessColors = flags.get(SettingFlag.FLAG_REPROCESS_COLORS);
stockpileHalfColors = flags.get(SettingFlag.FLAG_STOCKPILE_HALF_COLORS);
containersShowItemID = flags.get(SettingFlag.FLAG_CONTAINERS_SHOW_ITEM_ID);
}

public ReprocessSettings getReprocessSettings() {
Expand Down Expand Up @@ -852,6 +856,15 @@ public void setEasyChartColors(final boolean easyChartColors) {
flags.put(SettingFlag.FLAG_EASY_CHART_COLORS, easyChartColors);
}

public boolean isContainersShowItemID() {
return containersShowItemID;
}

public void setContainersShowItemID(final boolean containersShowItemID) {
flags.put(SettingFlag.FLAG_CONTAINERS_SHOW_ITEM_ID, containersShowItemID);
this.containersShowItemID = containersShowItemID;
}

public boolean isTransactionHistory() {
return flags.get(SettingFlag.FLAG_TRANSACTION_HISTORY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class AssetsToolSettingsPanel extends JSettingsPanel {
private final JCheckBox jBuyContracts;
private final JCheckBox jManufacturing;
private final JCheckBox jCopying;
private final JCheckBox jContainerItemID;

public AssetsToolSettingsPanel(final Program program, final SettingsDialog settingsDialog) {
super(program, settingsDialog, DialoguesSettings.get().assets(), Images.TOOL_ASSETS.getIcon());
Expand All @@ -47,6 +48,7 @@ public AssetsToolSettingsPanel(final Program program, final SettingsDialog setti
jBuyContracts = new JCheckBox(DialoguesSettings.get().includeBuyContracts());
jManufacturing = new JCheckBox(DialoguesSettings.get().includeManufacturing());
jCopying = new JCheckBox(DialoguesSettings.get().includeCopying());
jContainerItemID = new JCheckBox(DialoguesSettings.get().showContainerItemID());

layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
Expand All @@ -56,6 +58,7 @@ public AssetsToolSettingsPanel(final Program program, final SettingsDialog setti
.addComponent(jBuyContracts)
.addComponent(jManufacturing)
.addComponent(jCopying)
.addComponent(jContainerItemID)
);
layout.setVerticalGroup(
layout.createSequentialGroup()
Expand All @@ -65,25 +68,35 @@ public AssetsToolSettingsPanel(final Program program, final SettingsDialog setti
.addComponent(jBuyContracts, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jCopying, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addGap(5)
.addComponent(jContainerItemID, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
);
}

@Override
public UpdateType save() {
boolean update = jSellOrders.isSelected() != Settings.get().isIncludeSellOrders()
boolean fullUpdate = jSellOrders.isSelected() != Settings.get().isIncludeSellOrders()
|| jBuyOrders.isSelected() != Settings.get().isIncludeBuyOrders()
|| jSellContracts.isSelected() != Settings.get().isIncludeSellContracts()
|| jBuyContracts.isSelected() != Settings.get().isIncludeBuyContracts()
|| jManufacturing.isSelected() != Settings.get().isIncludeManufacturing()
|| jCopying.isSelected() != Settings.get().isIncludeCopying()
;
boolean updateContainers = jContainerItemID.isSelected() != Settings.get().isContainersShowItemID();
Settings.get().setIncludeSellOrders(jSellOrders.isSelected());
Settings.get().setIncludeBuyOrders(jBuyOrders.isSelected());
Settings.get().setIncludeSellContracts(jSellContracts.isSelected());
Settings.get().setIncludeBuyContracts(jBuyContracts.isSelected());
Settings.get().setIncludeManufacturing(jManufacturing.isSelected());
Settings.get().setIncludeCopying(jCopying.isSelected());
return update ? UpdateType.FULL_UPDATE : UpdateType.NONE;
Settings.get().setContainersShowItemID(jContainerItemID.isSelected());
if (fullUpdate) {
return UpdateType.FULL_UPDATE;
} else if (updateContainers) {
return UpdateType.UPDATE_ASSET_TABLES;
} else {
return UpdateType.NONE;
}
}

@Override
Expand All @@ -94,6 +107,7 @@ public void load() {
jBuyContracts.setSelected(Settings.get().isIncludeBuyContracts());
jManufacturing.setSelected(Settings.get().isIncludeManufacturing());
jCopying.setSelected(Settings.get().isIncludeCopying());
jContainerItemID.setSelected(Settings.get().isContainersShowItemID());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static enum UpdateType {
FULL_UPDATE,
UPDATE_OVERVIEW,
UPDATE_TAGS,
UPDATE_ASSET_TABLES,
FULL_REPAINT,
REPAINT_MARKET_ORDERS_TABLE,
REPAINT_STOCKPILE_TABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ private void save(boolean hideWindow) {
program.getStockpileTab().repaintTable();
}
}
if (updates.contains(UpdateType.UPDATE_ASSET_TABLES)) {
program.getAssetsTab().tableDataChanged();
program.getTreeTab().tableDataChanged();
}
if (updates.contains(UpdateType.UPDATE_OVERVIEW)) {
program.getOverviewTab().updateData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ public void tableStructureChanged() {
}
}

public void tableDataChanged() {
beforeUpdateDataKeepCache();
if (eventTableModel != null) {
eventTableModel.fireTableDataChanged();
}
afterUpdateData();
}

public void repaintTable() {
if (jTable != null) {
jTable.repaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public JMenu getMenu(final JTable jTable, final List<E> items) {
column = tableFormat.getShownColumns().get(columnIndex);
isNumeric = isNumeric(column);
isDate = isDate(column);
text = FilterMatcher.format(tableFormat.getColumnValue(items.get(0), column.name()), false);
text = FilterMatcher.formatFilter(tableFormat.getColumnValue(items.get(0), column.name()));
}
return new FilterMenu<>(gui, column, text, isNumeric, isDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static net.nikr.eve.jeveasset.gui.shared.filter.Filter.CompareType.NEXT_DAYS;
import net.nikr.eve.jeveasset.gui.shared.filter.Filter.LogicType;
import net.nikr.eve.jeveasset.gui.shared.table.EnumTableColumn;
import net.nikr.eve.jeveasset.gui.shared.table.containers.AssetContainer;
import net.nikr.eve.jeveasset.gui.shared.table.containers.NumberValue;


Expand Down Expand Up @@ -80,7 +81,7 @@ public class FilterMatcher<E> implements Matcher<E> {
if (CompareType.isColumnCompare(compare)) {
this.text = text;
} else {
this.text = format(text, true);
this.text = formatData(text, true);
}
empty = !enabled || text == null || text.isEmpty();
and = logic == Filter.LogicType.AND;
Expand Down Expand Up @@ -137,13 +138,13 @@ public boolean matches(final E item) {
case LESS_THAN_COLUMN:
return less(column, tableFormat.getColumnValue(item, text));
case EQUALS_COLUMN:
return equals(column, format(tableFormat.getColumnValue(item, text), false));
return equals(column, formatData(tableFormat.getColumnValue(item, text), false));
case EQUALS_NOT_COLUMN:
return !equals(column, format(tableFormat.getColumnValue(item, text), false));
return !equals(column, formatData(tableFormat.getColumnValue(item, text), false));
case CONTAINS_COLUMN:
return contains(column, format(tableFormat.getColumnValue(item, text), false));
return contains(column, formatData(tableFormat.getColumnValue(item, text), false));
case CONTAINS_NOT_COLUMN:
return !contains(column, format(tableFormat.getColumnValue(item, text), false));
return !contains(column, formatData(tableFormat.getColumnValue(item, text), false));
case BEFORE_COLUMN:
return before(column, tableFormat.getColumnValue(item, text));
case AFTER_COLUMN:
Expand All @@ -168,7 +169,7 @@ public static <E> String buildItemCache(SimpleTableFormat<E> filterControl, E e)
Object columnValue = filterControl.getColumnValue(e, testColumn.name());
if (columnValue != null) {
builder.append("\n");
builder.append(format(columnValue, false));
builder.append(formatData(columnValue, false));
builder.append("\r");
}
}
Expand Down Expand Up @@ -211,7 +212,7 @@ private boolean equals(final Object object1, final String formattedText) {
}

//Equals (case insentive)
return format(object1, false).equals(formattedText);
return formatData(object1, false).equals(formattedText);
}

private boolean regex(final Object object1, final Pattern pattern) {
Expand All @@ -221,7 +222,7 @@ private boolean regex(final Object object1, final Pattern pattern) {
}

//Rexex
return pattern.matcher(format(object1, false)).find();
return pattern.matcher(formatData(object1, false)).find();
}

private boolean contains(final Object object1, final String formattedText) {
Expand All @@ -231,7 +232,7 @@ private boolean contains(final Object object1, final String formattedText) {
}

//Contains (case insentive)
return format(object1, false).contains(formattedText);
return formatData(object1, false).contains(formattedText);
}

private boolean less(final Object object1, final Object object2) {
Expand Down Expand Up @@ -462,25 +463,50 @@ private static Date getDate(final Object obj, final boolean userInput) {
}
}

public static String format(final Object object, final boolean userInput) {
private static AssetContainer getAssetContainer(final Object obj) {
if (obj instanceof AssetContainer) {
return (AssetContainer) obj;
} else {
return null;
}
}

public static String formatFilter(final Object object) {
return format(object, false);
}

private static String formatData(final Object object, final boolean userInput) {
if (object == null) {
return null;
}
return format(object, userInput).toLowerCase();
}

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

//Number
Number number = getNumber(object, userInput);
if (number != null) {
return Formatter.compareFormat(number).toLowerCase();
return Formatter.compareFormat(number);
}

//Date
Date date = getDate(object, userInput);
if (date != null) {
return Formatter.columnDate(date).toLowerCase();
return Formatter.columnDate(date);
}

//AssetContainer
AssetContainer assetContainer = getAssetContainer(object);
if (assetContainer != null) {
return assetContainer.getContainer();
}

//String
return format(object.toString()).toLowerCase();
return format(object.toString());
}

private static String format(String string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import net.nikr.eve.jeveasset.gui.shared.table.TableCellRenderers.LongCellRenderer;
import net.nikr.eve.jeveasset.gui.shared.table.TableCellRenderers.TagsCellRenderer;
import net.nikr.eve.jeveasset.gui.shared.table.TableCellRenderers.ToStringCellRenderer;
import net.nikr.eve.jeveasset.gui.shared.table.containers.AssetContainer;
import net.nikr.eve.jeveasset.gui.shared.table.containers.DateOnly;
import net.nikr.eve.jeveasset.gui.shared.table.containers.ExpirerDate;
import net.nikr.eve.jeveasset.gui.shared.table.containers.YesNo;
Expand Down Expand Up @@ -135,6 +136,7 @@ public JAutoColumnTable(final Program program, final TableModel tableModel) {
this.setDefaultRenderer(DateOnly.class, new DateOnlyCellRenderer());
this.setDefaultRenderer(String.class, new ToStringCellRenderer(SwingConstants.LEFT));
this.setDefaultRenderer(Object.class, new ToStringCellRenderer());
this.setDefaultRenderer(AssetContainer.class, new ToStringCellRenderer(SwingConstants.LEFT));
this.setDefaultRenderer(Tags.class, new TagsCellRenderer());
this.setDefaultRenderer(YesNo.class, new ToStringCellRenderer(SwingConstants.CENTER));
this.setDefaultRenderer(ExpirerDate.class, new ToStringCellRenderer(SwingConstants.CENTER));
Expand Down
Loading

0 comments on commit 69b4dbd

Please sign in to comment.