Skip to content

Commit

Permalink
New Feature: Added Evepraisal to the loopup menu and new copy+ menu w…
Browse files Browse the repository at this point in the history
…ith Eve MultiBuy/Evepraisal format (Issue #6 and #56)

+Code improvements to JAutoMenu
  • Loading branch information
GoldenGnu committed Mar 7, 2019
1 parent 1d6b490 commit bd6e73c
Show file tree
Hide file tree
Showing 32 changed files with 336 additions and 37 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/nikr/eve/jeveasset/data/api/my/MyAsset.java
Expand Up @@ -249,6 +249,11 @@ public Item getItem() {
return item;
}

@Override
public long getItemCount() {
return getCount();
}

@Override
public MyLocation getLocation() {
return location;
Expand Down
Expand Up @@ -129,6 +129,11 @@ public Item getItem() {
return item;
}

@Override
public long getItemCount() {
return getQuantity();
}

@Override
public String getCopyString() {
StringBuilder builder = new StringBuilder();
Expand Down
Expand Up @@ -449,6 +449,11 @@ public Item getItem() {
return item;
}

@Override
public long getItemCount() {
return 1; //Just one blueprint here
}

@Override
public int hashCode() {
int hash = 5;
Expand Down
Expand Up @@ -248,6 +248,11 @@ public Item getItem() {
return item;
}

@Override
public long getItemCount() {
return getVolumeRemain();
}

@Override
public MyLocation getLocation() {
return location;
Expand Down
Expand Up @@ -89,6 +89,11 @@ public Item getItem() {
return item;
}

@Override
public long getItemCount() {
return getQuantity();
}

public String getOwnerName() {
return owner.getOwnerName();
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/nikr/eve/jeveasset/data/sde/Item.java
Expand Up @@ -157,6 +157,11 @@ public Item getItem() {
return this;
}

@Override
public long getItemCount() {
return 1; //Just this one item?
}

public void setPriceReprocessed(double priceReprocessed) {
this.priceReprocessed = priceReprocessed;
}
Expand Down
Expand Up @@ -25,4 +25,5 @@

public interface ItemType {
public Item getItem();
public long getItemCount();
}
Expand Up @@ -94,6 +94,7 @@ public enum Images {
LINK_EVE_MARKETDATA ("link_eve_marketdata.png"),
LINK_EVEINFO ("link_eveinfo.png"),
LINK_EVE_MARKETS ("link_eve_markets.png"),
LINK_EVEPRAISAL ("link_evepraisal.png"),
LINK_DOTLAN_EVEMAPS ("link_dotlan_evemaps.png"),
LINK_LOOKUP ("link_lookup.png"),
LINK_CHRUKER ("link_chruker.png"),
Expand Down
Expand Up @@ -68,7 +68,7 @@ private enum TextDialogAction {
private final JButton jCancel;
private final Color exportColor;
private final Color importColor;
private JCustomFileChooser jFileChooser;
private final JCustomFileChooser jFileChooser;

private String returnValue = null;

Expand Down
Expand Up @@ -46,8 +46,6 @@ private enum MenuAssetFilterAction {
ITEM_TYPE_FILTER
}

private MenuData<T> menuData;

private final JMenuItem jTypeID;
private final JMenuItem jStation;
private final JMenuItem jSystem;
Expand Down Expand Up @@ -92,8 +90,7 @@ public JMenuAssetFilter(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jTypeID.setEnabled(!menuData.getTypeIDs().isEmpty());
jStation.setEnabled(!menuData.getStationAndCitadelNames().isEmpty());
jSystem.setEnabled(!menuData.getSystemNames().isEmpty());
Expand Down
@@ -0,0 +1,70 @@
/*
* Copyright 2009-2018 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.shared.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Map;
import javax.swing.JMenuItem;
import net.nikr.eve.jeveasset.Program;
import net.nikr.eve.jeveasset.data.sde.Item;
import net.nikr.eve.jeveasset.gui.images.Images;
import net.nikr.eve.jeveasset.gui.shared.components.JTextDialog;
import net.nikr.eve.jeveasset.gui.shared.menu.MenuManager.JAutoMenu;
import net.nikr.eve.jeveasset.i18n.GuiShared;

public class JMenuCopyPlus<T> extends JAutoMenu<T> {

private final DecimalFormat number = new DecimalFormat("0");
private final JTextDialog jTextDialog;
private final JMenuItem jEveMultiBuy;


public JMenuCopyPlus(Program program) {
super(GuiShared.get().copyPlus(), program);
setIcon(Images.EDIT_COPY.getIcon());

jTextDialog = new JTextDialog(program.getMainWindow().getFrame());

jEveMultiBuy = new JMenuItem(GuiShared.get().copyEveMultiBuy());
jEveMultiBuy.setIcon(Images.MISC_EVE.getIcon());
jEveMultiBuy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StringBuilder builder = new StringBuilder();
for (Map.Entry<Item, Long> entry : menuData.getItemCounts().entrySet()) {
builder.append(entry.getKey().getTypeName());
builder.append(" ");
builder.append(number.format(entry.getValue()));
builder.append("\r\n");
}
jTextDialog.exportText(builder.toString());
}
});
add(jEveMultiBuy);
}

@Override
protected void updateMenuData() {
jEveMultiBuy.setEnabled(!menuData.getItemCounts().isEmpty());
}
}
Expand Up @@ -52,8 +52,6 @@ private enum MenuJumpsAction {
private final JMenuItem jClear;
private final Class<T> clazz;

private MenuData<T> menuData;

public JMenuJumps(Program program, Class<T> clazz) {
super(GuiShared.get().jumps(), program);
this.clazz = clazz;
Expand All @@ -78,9 +76,7 @@ public JMenuJumps(Program program, Class<T> clazz) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;

public void updateMenuData() {
removeAll();

add(jAddSelected);
Expand Down
Expand Up @@ -51,8 +51,6 @@ private enum MenuLocationAction {
private final JMenuItem jReset;
private final JSelectionDialog<MyLocation> jLocationDialog;

private MenuData<T> menuData;

public JMenuLocation(final Program program) {
super((GuiShared.get().location()), program);
setIcon(Images.LOC_LOCATIONS.getIcon());
Expand Down Expand Up @@ -85,8 +83,7 @@ public JMenuLocation(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jEdit.setEnabled(!menuData.getEditableCitadelLocations().isEmpty());
jUpdate.setEnabled(!menuData.getEditableCitadelLocations().isEmpty());
if (StructureUpdateDialog.structuresUpdatable(program)) {
Expand Down
Expand Up @@ -34,6 +34,7 @@
import net.nikr.eve.jeveasset.gui.tabs.overview.OverviewTab.OverviewAction;
import net.nikr.eve.jeveasset.i18n.GuiShared;
import net.nikr.eve.jeveasset.i18n.TabsOverview;
import net.nikr.eve.jeveasset.io.online.EvepraisalGetter;
import net.nikr.eve.jeveasset.io.shared.DesktopUtil;


Expand All @@ -54,6 +55,7 @@ private enum MenuLookupAction {
EVEMAPS_DOTLAN_SYSTEM,
EVEMAPS_DOTLAN_REGION,
EVE_INFO,
EVEPRAISAL,
}

private final JMenu jDotlan;
Expand All @@ -73,11 +75,10 @@ private enum MenuLookupAction {
private final JMenuItem jzKillboard;
private final JMenuItem jEveRef;
private final JMenuItem jEveInfo;
private final JMenuItem jEvepraisal;
private final JMenu jIndustry;
private final JMenuItem jFuzzworkBlueprints;

private MenuData<T> menuData;

public JMenuLookup(final Program program) {
super(GuiShared.get().lookup(), program);

Expand Down Expand Up @@ -148,6 +149,12 @@ public JMenuLookup(final Program program) {
jFuzzworkMarket.addActionListener(listener);
jMarket.add(jFuzzworkMarket);

jEvepraisal = new JMenuItem(GuiShared.get().evepraisal());
jEvepraisal.setIcon(Images.LINK_EVEPRAISAL.getIcon());
jEvepraisal.setActionCommand(MenuLookupAction.EVEPRAISAL.name());
jEvepraisal.addActionListener(listener);
jMarket.add(jEvepraisal);

jItemDatabase = new JMenu(GuiShared.get().itemDatabase());
jItemDatabase.setIcon(Images.TOOL_ASSETS.getIcon());
add(jItemDatabase);
Expand Down Expand Up @@ -195,8 +202,7 @@ public JMenuLookup(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jDotlan.setEnabled(!menuData.getStationNames().isEmpty() || !menuData.getSystemNames().isEmpty() || !menuData.getRegionNames().isEmpty());
jDotlanStation.setEnabled(!menuData.getStationNames().isEmpty());
jDotlanSystem.setEnabled(!menuData.getSystemNames().isEmpty());
Expand Down Expand Up @@ -315,6 +321,11 @@ public void actionPerformed(final ActionEvent e) {
urls.add("https://everef.net/type/" + typeID+ "?utm_source=jeveassets");
}
DesktopUtil.browse(urls, program);
} else if (MenuLookupAction.EVEPRAISAL.name().equals(e.getActionCommand())) {
String evepraisal = EvepraisalGetter.post(menuData.getItemCounts());
if (evepraisal != null) {
DesktopUtil.browse("https://evepraisal.com/a/" + evepraisal, program);
}
} else if (MenuLookupAction.FUZZWORK_BLUEPRINTS.name().equals(e.getActionCommand())) {
Set<String> urls = new HashSet<String>();
for (int typeID : menuData.getTypeIDs()) {
Expand Down
Expand Up @@ -91,7 +91,7 @@ public JMenuName(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
public void updateMenuData() {
itemNames = new ArrayList<UserItem<Long, String>>();
containerNames = new ArrayList<UserItem<Long, String>>();
for (MyAsset asset : menuData.getAssets()) {
Expand Down
Expand Up @@ -46,8 +46,6 @@ private enum MenuPriceAction {
private final JMenuItem jEdit;
private final JMenuItem jReset;

private MenuData<T> menuData;

public JMenuPrice(final Program program) {
super(GuiShared.get().itemPriceTitle(), program); //
this.setIcon(Images.SETTINGS_USER_PRICE.getIcon());
Expand All @@ -69,8 +67,7 @@ public JMenuPrice(final Program program) {


@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jEdit.setEnabled(!menuData.getPrices().isEmpty());
jReset.setEnabled(!menuData.getPrices().isEmpty() && program.getUserPriceSettingsPanel().containsKey(menuData.getPrices().keySet()));
}
Expand Down
Expand Up @@ -64,7 +64,7 @@ public JMenuReprocessed(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
public void updateMenuData() {
items.clear();
for (int typeID : menuData.getTypeIDs()) {
Item item = StaticData.get().getItems().get(typeID);
Expand Down
Expand Up @@ -37,8 +37,7 @@ private enum MenuRoutingAction {
SYSTEM,
STATION
}

private MenuData<T> menuData;

private final JMenuItem jSystem;
private final JMenuItem jStation;

Expand All @@ -62,8 +61,7 @@ public JMenuRouting(Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jStation.setEnabled(!menuData.getAutopilotStationLocations().isEmpty() && menuData.getContracts().size() <= 1);
jSystem.setEnabled(!menuData.getSystemLocations().isEmpty() && menuData.getContracts().size() <= 1);
}
Expand Down
Expand Up @@ -49,8 +49,6 @@ private enum MenuStockpileAction {
private final List<JMenuItem> jMenuItems = new ArrayList<JMenuItem>();
private final JMenuItem jAddToNew;

private MenuData<T> menuData;

ListenerClass listener = new ListenerClass();

public JMenuStockpile(final Program program) {
Expand All @@ -64,8 +62,7 @@ public JMenuStockpile(final Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
if (stockpilesCashe == null || !stockpilesCashe.equals(Settings.get().getStockpiles())) {
updateMenu(); //Stockpiles changed...
}
Expand Down
Expand Up @@ -63,7 +63,7 @@ public JMenuTags(Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
public void updateMenuData() {
tagsTypes = menuData.getTags();

boolean valid = !tagsTypes.isEmpty();
Expand Down
Expand Up @@ -72,7 +72,6 @@ public static enum EsiOwnerRequirement {
private final JMenuItem jOwner;
private final JMenuItem jContracts;

private MenuData<T> menuData;
private static JLockWindow jLockWindow = null;

public JMenuUI(Program program) {
Expand Down Expand Up @@ -117,8 +116,7 @@ public JMenuUI(Program program) {
}

@Override
public void setMenuData(MenuData<T> menuData) {
this.menuData = menuData;
public void updateMenuData() {
jWaypoints.setEnabled(menuData.getSystemLocations().size() == 1 || menuData.getAutopilotStationLocations().size() == 1 || menuData.getContracts().size() == 1);
jStation.setEnabled(menuData.getAutopilotStationLocations().size() == 1 || menuData.getContracts().size() == 1);
jSystem.setEnabled(menuData.getSystemLocations().size() == 1 || menuData.getContracts().size() == 1);
Expand Down

0 comments on commit bd6e73c

Please sign in to comment.