Merge pull request #5703 from deathbeam/remove-unused

Cleanup GE plugin code
This commit is contained in:
Tomas Slusny
2018-09-29 21:22:02 +02:00
committed by GitHub
7 changed files with 18 additions and 48 deletions

View File

@@ -41,7 +41,7 @@ public class GrandExchangeInputListener extends MouseListener implements KeyList
private final GrandExchangePlugin plugin; private final GrandExchangePlugin plugin;
@Inject @Inject
GrandExchangeInputListener(Client client, GrandExchangePlugin plugin) private GrandExchangeInputListener(Client client, GrandExchangePlugin plugin)
{ {
this.client = client; this.client = client;
this.plugin = plugin; this.plugin = plugin;

View File

@@ -62,7 +62,7 @@ class GrandExchangeItemPanel extends JPanel
setBackground(ColorScheme.MEDIUM_GRAY_COLOR); setBackground(ColorScheme.MEDIUM_GRAY_COLOR);
Color background = getBackground(); Color background = getBackground();
List<JPanel> panels = new ArrayList(); List<JPanel> panels = new ArrayList<>();
panels.add(this); panels.add(this);
MouseAdapter itemPanelMouseListener = new MouseAdapter() MouseAdapter itemPanelMouseListener = new MouseAdapter()
@@ -165,7 +165,7 @@ class GrandExchangeItemPanel extends JPanel
} }
} }
private void geLink(String name, int itemID) private static void geLink(String name, int itemID)
{ {
final String url = "http://services.runescape.com/m=itemdb_oldschool/" final String url = "http://services.runescape.com/m=itemdb_oldschool/"
+ name.replaceAll(" ", "_") + name.replaceAll(" ", "_")

View File

@@ -28,7 +28,7 @@ import lombok.Value;
import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.game.AsyncBufferedImage;
@Value @Value
public class GrandExchangeItems class GrandExchangeItems
{ {
private final AsyncBufferedImage icon; private final AsyncBufferedImage icon;
private final String name; private final String name;

View File

@@ -68,11 +68,9 @@ public class GrandExchangeOfferSlot extends JPanel
private final JLabel itemIcon = new JLabel(); private final JLabel itemIcon = new JLabel();
private final JLabel itemName = new JLabel(); private final JLabel itemName = new JLabel();
private final JLabel offerInfo = new JLabel(); private final JLabel offerInfo = new JLabel();
private final JLabel switchFaceViewIcon = new JLabel();
private final JLabel itemPrice = new JLabel(); private final JLabel itemPrice = new JLabel();
private final JLabel offerSpent = new JLabel(); private final JLabel offerSpent = new JLabel();
private final JLabel switchDetailsViewIcon = new JLabel();
private final ThinProgressBar progressBar = new ThinProgressBar(); private final ThinProgressBar progressBar = new ThinProgressBar();
@@ -90,11 +88,6 @@ public class GrandExchangeOfferSlot extends JPanel
* in the sidebar * in the sidebar
*/ */
GrandExchangeOfferSlot() GrandExchangeOfferSlot()
{
buildPanel();
}
private void buildPanel()
{ {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -144,6 +137,7 @@ public class GrandExchangeOfferSlot extends JPanel
offerInfo.setVerticalAlignment(JLabel.TOP); offerInfo.setVerticalAlignment(JLabel.TOP);
offerInfo.setFont(FontManager.getRunescapeSmallFont()); offerInfo.setFont(FontManager.getRunescapeSmallFont());
JLabel switchFaceViewIcon = new JLabel();
switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON); switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON);
switchFaceViewIcon.setVerticalAlignment(JLabel.CENTER); switchFaceViewIcon.setVerticalAlignment(JLabel.CENTER);
switchFaceViewIcon.setHorizontalAlignment(JLabel.CENTER); switchFaceViewIcon.setHorizontalAlignment(JLabel.CENTER);
@@ -174,6 +168,7 @@ public class GrandExchangeOfferSlot extends JPanel
offerSpent.setVerticalAlignment(JLabel.TOP); offerSpent.setVerticalAlignment(JLabel.TOP);
offerSpent.setFont(FontManager.getRunescapeSmallFont()); offerSpent.setFont(FontManager.getRunescapeSmallFont());
JLabel switchDetailsViewIcon = new JLabel();
switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON); switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON);
switchDetailsViewIcon.setVerticalAlignment(JLabel.CENTER); switchDetailsViewIcon.setVerticalAlignment(JLabel.CENTER);
switchDetailsViewIcon.setHorizontalAlignment(JLabel.CENTER); switchDetailsViewIcon.setHorizontalAlignment(JLabel.CENTER);
@@ -197,7 +192,7 @@ public class GrandExchangeOfferSlot extends JPanel
add(container, BorderLayout.CENTER); add(container, BorderLayout.CENTER);
add(progressBar, BorderLayout.SOUTH); add(progressBar, BorderLayout.SOUTH);
} }
void updateOffer(ItemComposition offerItem, BufferedImage itemImage, @Nullable GrandExchangeOffer newOffer) void updateOffer(ItemComposition offerItem, BufferedImage itemImage, @Nullable GrandExchangeOffer newOffer)
{ {
if (newOffer == null || newOffer.getState() == EMPTY) if (newOffer == null || newOffer.getState() == EMPTY)

View File

@@ -30,14 +30,11 @@ import java.awt.CardLayout;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.concurrent.ScheduledExecutorService;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import net.runelite.api.Client;
import net.runelite.api.GrandExchangeOffer; import net.runelite.api.GrandExchangeOffer;
import net.runelite.api.GrandExchangeOfferState; import net.runelite.api.GrandExchangeOfferState;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.ui.components.PluginErrorPanel;
@@ -54,27 +51,12 @@ public class GrandExchangeOffersPanel extends JPanel
/* The offers container, this will hold all the individual ge offers panels */ /* The offers container, this will hold all the individual ge offers panels */
private final JPanel offerPanel = new JPanel(); private final JPanel offerPanel = new JPanel();
/* The error panel, this displays an error message */
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
/* The center panel, this holds either the error panel or the offers container */ /* The center panel, this holds either the error panel or the offers container */
private final JPanel container = new JPanel(cardLayout); private final JPanel container = new JPanel(cardLayout);
private final Client client; private final GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS];
private final ItemManager itemManager;
private final ScheduledExecutorService executor;
private GrandExchangeOfferSlot[] offerSlotPanels = new GrandExchangeOfferSlot[MAX_OFFERS]; GrandExchangeOffersPanel()
public GrandExchangeOffersPanel(Client client, ItemManager itemManager, ScheduledExecutorService executor)
{
this.client = client;
this.itemManager = itemManager;
this.executor = executor;
init();
}
void init()
{ {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -96,6 +78,8 @@ public class GrandExchangeOffersPanel extends JPanel
/* This panel wraps the error panel and limits its height */ /* This panel wraps the error panel and limits its height */
JPanel errorWrapper = new JPanel(new BorderLayout()); JPanel errorWrapper = new JPanel(new BorderLayout());
errorWrapper.setBackground(ColorScheme.DARK_GRAY_COLOR); errorWrapper.setBackground(ColorScheme.DARK_GRAY_COLOR);
/* The error panel, this displays an error message */
PluginErrorPanel errorPanel = new PluginErrorPanel();
errorWrapper.add(errorPanel, BorderLayout.NORTH); errorWrapper.add(errorPanel, BorderLayout.NORTH);
errorPanel.setBorder(new EmptyBorder(50, 20, 20, 20)); errorPanel.setBorder(new EmptyBorder(50, 20, 20, 20));
@@ -197,5 +181,4 @@ public class GrandExchangeOffersPanel extends JPanel
} }
} }
} }

View File

@@ -33,7 +33,6 @@ import javax.inject.Inject;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
@@ -56,7 +55,7 @@ class GrandExchangePanel extends PluginPanel
private GrandExchangeOffersPanel offersPanel; private GrandExchangeOffersPanel offersPanel;
@Inject @Inject
GrandExchangePanel(Client client, ClientThread clientThread, ItemManager itemManager, ScheduledExecutorService executor) private GrandExchangePanel(ClientThread clientThread, ItemManager itemManager, ScheduledExecutorService executor)
{ {
super(false); super(false);
@@ -67,7 +66,7 @@ class GrandExchangePanel extends PluginPanel
searchPanel = new GrandExchangeSearchPanel(clientThread, itemManager, executor); searchPanel = new GrandExchangeSearchPanel(clientThread, itemManager, executor);
//Offers Panel //Offers Panel
offersPanel = new GrandExchangeOffersPanel(client, itemManager, executor); offersPanel = new GrandExchangeOffersPanel();
MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel); MaterialTab offersTab = new MaterialTab("Offers", tabGroup, offersPanel);
searchTab = new MaterialTab("Search", tabGroup, searchPanel); searchTab = new MaterialTab("Search", tabGroup, searchPanel);

View File

@@ -72,9 +72,6 @@ class GrandExchangeSearchPanel extends JPanel
private final IconTextField searchBar = new IconTextField(); private final IconTextField searchBar = new IconTextField();
/* The main container, this holds the search bar and the center panel */
private final JPanel container = new JPanel();
/* The results container, this will hold all the individual ge item panels */ /* The results container, this will hold all the individual ge item panels */
private final JPanel searchItemsPanel = new JPanel(); private final JPanel searchItemsPanel = new JPanel();
@@ -84,10 +81,7 @@ class GrandExchangeSearchPanel extends JPanel
/* The error panel, this displays an error message */ /* The error panel, this displays an error message */
private final PluginErrorPanel errorPanel = new PluginErrorPanel(); private final PluginErrorPanel errorPanel = new PluginErrorPanel();
/* The results wrapper, this scrolling panel wraps the results container */ private final List<GrandExchangeItems> itemsList = new ArrayList<>();
private JScrollPane resultsWrapper;
private List<GrandExchangeItems> itemsList = new ArrayList<>();
@Setter @Setter
private Map<Integer, Integer> itemGELimits = Collections.emptyMap(); private Map<Integer, Integer> itemGELimits = Collections.emptyMap();
@@ -97,14 +91,12 @@ class GrandExchangeSearchPanel extends JPanel
this.clientThread = clientThread; this.clientThread = clientThread;
this.itemManager = itemManager; this.itemManager = itemManager;
this.executor = executor; this.executor = executor;
init();
}
private void init()
{
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
/* The main container, this holds the search bar and the center panel */
JPanel container = new JPanel();
container.setLayout(new BorderLayout(5, 5)); container.setLayout(new BorderLayout(5, 5));
container.setBorder(new EmptyBorder(10, 10, 10, 10)); container.setBorder(new EmptyBorder(10, 10, 10, 10));
container.setBackground(ColorScheme.DARK_GRAY_COLOR); container.setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -128,7 +120,8 @@ class GrandExchangeSearchPanel extends JPanel
wrapper.setBackground(ColorScheme.DARK_GRAY_COLOR); wrapper.setBackground(ColorScheme.DARK_GRAY_COLOR);
wrapper.add(searchItemsPanel, BorderLayout.NORTH); wrapper.add(searchItemsPanel, BorderLayout.NORTH);
resultsWrapper = new JScrollPane(wrapper); /* The results wrapper, this scrolling panel wraps the results container */
JScrollPane resultsWrapper = new JScrollPane(wrapper);
resultsWrapper.setBackground(ColorScheme.DARK_GRAY_COLOR); resultsWrapper.setBackground(ColorScheme.DARK_GRAY_COLOR);
resultsWrapper.getVerticalScrollBar().setPreferredSize(new Dimension(12, 0)); resultsWrapper.getVerticalScrollBar().setPreferredSize(new Dimension(12, 0));
resultsWrapper.getVerticalScrollBar().setBorder(new EmptyBorder(0, 5, 0, 0)); resultsWrapper.getVerticalScrollBar().setBorder(new EmptyBorder(0, 5, 0, 0));