Skip to content

Commit

Permalink
Bug Fix: Corporation contract assets owner is now optional (char/corp…
Browse files Browse the repository at this point in the history
…/both) (Issue #476)
  • Loading branch information
GoldenGnu committed Oct 17, 2024
1 parent 1fc7aec commit 55466b0
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import net.nikr.eve.jeveasset.data.settings.Settings;


public abstract class AbstractOwner implements OwnerType, Comparable<OwnerType> {
public abstract class AbstractOwner implements OwnerType {

private List<MyAccountBalance> accountBalances = new ArrayList<>();
private Set<MyMarketOrder> marketOrders = new HashSet<>();
Expand Down Expand Up @@ -513,10 +513,4 @@ public void setUnallocatedSkillPoints(Integer unallocatedSkillPoints) {
public void setActiveShip(MyShip activeShip) {
this.activeShip = activeShip;
}

@Override
public final int compareTo(final OwnerType o) {
return this.getOwnerName().compareToIgnoreCase(o.getOwnerName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@
import net.nikr.eve.jeveasset.data.api.raw.RawBlueprint;


public interface OwnerType extends Comparable<OwnerType> {
public interface OwnerType extends SimpleOwner {

//Info
public String getOwnerName();
public String getCorporationName();
public void setOwnerName(final String ownerName);
public void setCorporationName(String corporationName);
public long getOwnerID();
public void setOwnerID(final long ownerID);
public boolean isCorporation();
public boolean isShowOwner();
public Date getExpire();
public String getComparator();
Expand All @@ -60,7 +57,6 @@ public interface OwnerType extends Comparable<OwnerType> {
public void setInvalid(boolean invalid);
public void setResetAccountName();
public void setAccountName(final String accountName);
public MyShip getActiveShip();
public void setActiveShip(MyShip activeShip);
//Data
public List<MyAccountBalance> getAccountBalances();
Expand All @@ -72,7 +68,6 @@ public interface OwnerType extends Comparable<OwnerType> {
public List<MyAsset> getAssets();
public Map<Long, RawBlueprint> getBlueprints();
public Map<Integer, String> getWalletDivisions();
public Map<Integer, String> getAssetDivisions();
public List<MySkill> getSkills();
public Long getTotalSkillPoints();
public Integer getUnallocatedSkillPoints();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2009-2023 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.data.api.accounts;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import net.nikr.eve.jeveasset.data.api.my.MyShip;


public interface SimpleOwner extends Comparable<SimpleOwner> {
public long getOwnerID();
public String getOwnerName();
public boolean isCorporation();
default Map<Integer, String> getAssetDivisions() {
return new HashMap<>();
}
@Nullable
default MyShip getActiveShip() {
return null;
}
@Override
default int compareTo(final SimpleOwner o) {
return this.getOwnerName().compareToIgnoreCase(o.getOwnerName());
}
}
16 changes: 8 additions & 8 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 @@ -27,7 +27,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import net.nikr.eve.jeveasset.data.api.accounts.OwnerType;
import net.nikr.eve.jeveasset.data.api.accounts.SimpleOwner;
import net.nikr.eve.jeveasset.data.api.my.MyIndustryJob.IndustryActivity;
import net.nikr.eve.jeveasset.data.api.raw.RawAsset;
import net.nikr.eve.jeveasset.data.sde.Item;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class MyAsset extends RawAsset implements Comparable<MyAsset>, InfoItem,
private final List<MyAsset> assets = new ArrayList<>();
private final RawAsset rawAsset;
private final Item item;
private final OwnerType owner;
private final SimpleOwner owner;
private final List<MyAsset> parents;
private final Set<Long> owners;
private final boolean generated;
Expand Down Expand Up @@ -129,7 +129,7 @@ public MyAsset(MyLocation location) {
setLocationID(location.getLocationID());
}

public MyAsset(final RawAsset rawAsset, final Item item, final OwnerType owner, final List<MyAsset> parents) {
public MyAsset(final RawAsset rawAsset, final Item item, final SimpleOwner owner, final List<MyAsset> parents) {
super(rawAsset);
this.rawAsset = rawAsset;
this.item = item;
Expand Down Expand Up @@ -185,15 +185,15 @@ private void updateBlueprint() {

public MyAsset(MyIndustryJob industryJob, boolean output) {
this(new RawAsset(industryJob, output),
industryJob.isManufacturing() && output ? ApiIdConverter.getItemUpdate(industryJob.getProductTypeID()) : industryJob.getItem(), industryJob.getOwner(), new ArrayList<MyAsset>());
industryJob.isManufacturing() && output ? ApiIdConverter.getItemUpdate(industryJob.getProductTypeID()) : industryJob.getItem(), industryJob.getOwner(), new ArrayList<>());
}

public MyAsset(MyMarketOrder marketOrder) {
this(new RawAsset(marketOrder), marketOrder.getItem(), marketOrder.getOwner(), new ArrayList<MyAsset>());
this(new RawAsset(marketOrder), marketOrder.getItem(), marketOrder.getOwner(), new ArrayList<>());
}

public MyAsset(MyContractItem contractItem, final OwnerType owner) {
this(new RawAsset(contractItem), contractItem.getItem(), owner, new ArrayList<MyAsset>());
public MyAsset(MyContractItem contractItem, final SimpleOwner owner) {
this(new RawAsset(contractItem), contractItem.getItem(), owner, new ArrayList<>());
}

public void addAsset(final MyAsset asset) {
Expand Down Expand Up @@ -281,7 +281,7 @@ public String getOwnerName() {
return owner.getOwnerName();
}

public OwnerType getOwner() {
public SimpleOwner getOwner() {
return owner;
}

Expand Down
22 changes: 21 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 @@ -104,7 +104,9 @@ public static enum SettingFlag {
FLAG_CONTAINERS_SHOW_ITEM_ID,
FLAG_LOCK_TOOLS,
FLAG_SHOW_SUBPILE_TREE,
FLAG_INDUSTRY_JOBS_HISTORY
FLAG_INDUSTRY_JOBS_HISTORY,
FLAG_ASSETS_CONTRACTS_OWNER_CORP,
FLAG_ASSETS_CONTRACTS_OWNER_BOTH
}

public static enum TransactionProfitPrice {
Expand Down Expand Up @@ -304,6 +306,8 @@ protected Settings() {
flags.put(SettingFlag.FLAG_LOCK_TOOLS, false);
flags.put(SettingFlag.FLAG_SHOW_SUBPILE_TREE, true);
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);
cacheFlags();
//Default Filters
List<Filter> filter;
Expand Down Expand Up @@ -914,6 +918,22 @@ public void setIndustryJobsHistory(final boolean journalHistory) {
flags.put(SettingFlag.FLAG_INDUSTRY_JOBS_HISTORY, journalHistory);
}

public boolean isAssetsContractsOwnerCorporation() {
return flags.get(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_CORP);
}

public void setAssetsContractsOwnerCorporation(final boolean assetsContractsOwnerCorporation) {
flags.put(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_CORP, assetsContractsOwnerCorporation);
}

public boolean isAssetsContractsOwnerBoth() {
return flags.get(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_BOTH);
}

public void setAssetsContractsOwnerBoth(final boolean assetsContractsOwnerBoth) {
flags.put(SettingFlag.FLAG_ASSETS_CONTRACTS_OWNER_BOTH, assetsContractsOwnerBoth);
}

public boolean isMarketOrderHistory() {
return flags.get(SettingFlag.FLAG_MARKET_ORDER_HISTORY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import net.nikr.eve.jeveasset.Program;
import net.nikr.eve.jeveasset.data.settings.Settings;
import net.nikr.eve.jeveasset.gui.images.Images;
Expand All @@ -31,10 +35,39 @@

public class AssetsToolSettingsPanel extends JSettingsPanel {

private static enum ContractsOwnerFormat {
ISSUER_CHARACTER() {
@Override
protected String getName() {
return DialoguesSettings.get().contractAssetsCharacter();
}
},
ISSUER_CORPORATION() {
@Override
protected String getName() {
return DialoguesSettings.get().contractAssetsCorporation();
}
},
ISSUER_BOTH() {
@Override
protected String getName() {
return DialoguesSettings.get().contractAssetsBoth();
}
};

@Override
public String toString() {
return getName();
}

protected abstract String getName();
}

private final JCheckBox jSellOrders;
private final JCheckBox jBuyOrders;
private final JCheckBox jSellContracts;
private final JCheckBox jBuyContracts;
private final JComboBox<ContractsOwnerFormat> jContractsOwner;
private final JCheckBox jManufacturing;
private final JCheckBox jCopying;
private final JCheckBox jContainerItemID;
Expand All @@ -46,41 +79,84 @@ public AssetsToolSettingsPanel(final Program program, final SettingsDialog setti
jBuyOrders = new JCheckBox(DialoguesSettings.get().includeBuyOrders());
jSellContracts = new JCheckBox(DialoguesSettings.get().includeSellContracts());
jBuyContracts = new JCheckBox(DialoguesSettings.get().includeBuyContracts());
JLabel jContractsOwnerLabel = new JLabel(DialoguesSettings.get().contractAssetsLabel());
JLabel jContractsOwnerWarn = new JLabel(DialoguesSettings.get().contractAssetsLabelWarn());
jContractsOwner = new JComboBox<>(ContractsOwnerFormat.values());
jContractsOwner.setPrototypeDisplayValue(ContractsOwnerFormat.ISSUER_BOTH);
jContractsOwner.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jContractsOwnerWarn.setVisible(jContractsOwner.getItemAt(jContractsOwner.getSelectedIndex()) == ContractsOwnerFormat.ISSUER_BOTH);
}
});
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)
.addComponent(jSellOrders)
.addComponent(jBuyOrders)
.addComponent(jSellContracts)
.addComponent(jBuyContracts)
.addComponent(jManufacturing)
.addComponent(jCopying)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(jSellOrders)
.addComponent(jBuyOrders)
.addComponent(jSellContracts)
.addComponent(jBuyContracts)
.addComponent(jManufacturing)
.addComponent(jCopying)
)
.addGap(0, 0, 100)
.addGroup(layout.createParallelGroup()
.addComponent(jContractsOwnerLabel)
.addComponent(jContractsOwner, 200, 200, 200)
.addComponent(jContractsOwnerWarn)
)
)
.addComponent(jContainerItemID)
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jBuyOrders, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jSellContracts, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jBuyContracts, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addGap(0)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(jSellContracts, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jContractsOwnerLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
)
.addGap(0)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(jBuyContracts, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jContractsOwner, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
)
.addGap(0)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(jContractsOwnerWarn, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
)
)
)
.addGap(0)
.addComponent(jCopying, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addGap(5)
.addComponent(jContainerItemID, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
);
}

@Override
public UpdateType save() {
ContractsOwnerFormat contractsOwnerFormat = jContractsOwner.getItemAt(jContractsOwner.getSelectedIndex());

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()
|| Settings.get().isIncludeCopying()
|| (contractsOwnerFormat != ContractsOwnerFormat.ISSUER_CHARACTER && !Settings.get().isAssetsContractsOwnerCorporation() && !Settings.get().isAssetsContractsOwnerBoth())
|| (contractsOwnerFormat != ContractsOwnerFormat.ISSUER_CORPORATION && Settings.get().isAssetsContractsOwnerCorporation())
|| (contractsOwnerFormat != ContractsOwnerFormat.ISSUER_BOTH && Settings.get().isAssetsContractsOwnerBoth())

;
boolean updateContainers = jContainerItemID.isSelected() != Settings.get().isContainersShowItemID();
Settings.get().setIncludeSellOrders(jSellOrders.isSelected());
Expand All @@ -90,6 +166,8 @@ public UpdateType save() {
Settings.get().setIncludeManufacturing(jManufacturing.isSelected());
Settings.get().setIncludeCopying(jCopying.isSelected());
Settings.get().setContainersShowItemID(jContainerItemID.isSelected());
Settings.get().setAssetsContractsOwnerCorporation(contractsOwnerFormat == ContractsOwnerFormat.ISSUER_CORPORATION);
Settings.get().setAssetsContractsOwnerBoth(contractsOwnerFormat == ContractsOwnerFormat.ISSUER_BOTH);
if (fullUpdate) {
return UpdateType.FULL_UPDATE;
} else if (updateContainers) {
Expand All @@ -108,6 +186,13 @@ public void load() {
jManufacturing.setSelected(Settings.get().isIncludeManufacturing());
jCopying.setSelected(Settings.get().isIncludeCopying());
jContainerItemID.setSelected(Settings.get().isContainersShowItemID());
if (Settings.get().isAssetsContractsOwnerCorporation()) {
jContractsOwner.setSelectedItem(ContractsOwnerFormat.ISSUER_CORPORATION);
} else if (Settings.get().isAssetsContractsOwnerBoth()) {
jContractsOwner.setSelectedItem(ContractsOwnerFormat.ISSUER_BOTH);
} else {
jContractsOwner.setSelectedItem(ContractsOwnerFormat.ISSUER_CHARACTER);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import ca.odell.glazedlists.matchers.Matcher;
import java.util.Collections;
import java.util.Set;
import net.nikr.eve.jeveasset.data.api.accounts.OwnerType;
import net.nikr.eve.jeveasset.data.api.accounts.SimpleOwner;
import net.nikr.eve.jeveasset.data.api.my.MyAsset;
import net.nikr.eve.jeveasset.data.sde.Item;
import net.nikr.eve.jeveasset.data.sde.MyLocation;
Expand Down Expand Up @@ -107,7 +107,7 @@ public String toString() {

private final Item item;
private final MyLocation location; //New objects are created by updateData() - no need to update
private final OwnerType owner;
private final SimpleOwner owner;
private final String name;
private final String shipTypeName;
private final String shipItemName;
Expand All @@ -120,7 +120,7 @@ public String toString() {
private final boolean first;
private final Set<Long> owners;

public Loadout(Item item, MyLocation location, OwnerType owner, String name, MyAsset ship, String flag, Double price, double value, long count, boolean first) {
public Loadout(Item item, MyLocation location, SimpleOwner owner, String name, MyAsset ship, String flag, Double price, double value, long count, boolean first) {
this.item = item;
this.location = location;
this.owner = owner;
Expand Down
Loading

0 comments on commit 55466b0

Please # to comment.