mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* memory leaks - Made collection viewer removeable for gc.
This commit is contained in:
parent
f85c28b70a
commit
f1956e4a12
3 changed files with 44 additions and 20 deletions
|
@ -408,7 +408,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
backgroundPane.setSize(1024, 768);
|
||||
desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error while setting background.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
backgroundPane.add(title);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error while adding mage label.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1036,10 +1036,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
}
|
||||
try {
|
||||
collectionViewerPane = new CollectionViewerPane();
|
||||
CollectionViewerPane collectionViewerPane = new CollectionViewerPane();
|
||||
desktopPane.add(collectionViewerPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
collectionViewerPane.setMaximum(true);
|
||||
this.collectionViewerPane.setVisible(true);
|
||||
collectionViewerPane.setVisible(true);
|
||||
setActive(collectionViewerPane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
logger.fatal(null, ex);
|
||||
|
@ -1118,7 +1118,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private static final long serialVersionUID = -9104885239063142218L;
|
||||
private ImagePanel backgroundPane;
|
||||
private TablesPane tablesPane;
|
||||
private CollectionViewerPane collectionViewerPane;
|
||||
// private CollectionViewerPane collectionViewerPane;
|
||||
|
||||
public void setStatusText(String status) {
|
||||
this.lblStatus.setText(status);
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
*/
|
||||
package mage.client.deckeditor.collection.viewer;
|
||||
|
||||
import mage.client.MagePane;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.JComponent;
|
||||
import mage.client.MagePane;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
||||
/**
|
||||
* Collection viewer pane.
|
||||
|
@ -47,8 +46,8 @@ public class CollectionViewerPane extends MagePane {
|
|||
boolean initialized = false;
|
||||
this.setTitle("Collection Viewier");
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
Map<String, JComponent> uiComponents = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(uiComponents);
|
||||
if (container != null) {
|
||||
collectionViewerPanel = new CollectionViewerPanel();
|
||||
initComponents(container);
|
||||
|
|
|
@ -27,15 +27,27 @@
|
|||
*/
|
||||
package mage.client.deckeditor.collection.viewer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Pane with big card and mage book.
|
||||
|
@ -44,6 +56,8 @@ import java.awt.event.ActionListener;
|
|||
*/
|
||||
public final class CollectionViewerPanel extends JPanel {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CollectionViewerPanel.class);
|
||||
|
||||
protected static String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
|
||||
protected static String FORMAT_CONFIG_KEY = "collectionViewerFormat";
|
||||
|
||||
|
@ -53,7 +67,7 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
String format = PreferencesDialog.getCachedValue(CollectionViewerPanel.FORMAT_CONFIG_KEY, ConstructedFormats.getDefault());
|
||||
formats.setSelectedItem(format);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error setting selected format", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,14 +202,25 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
}
|
||||
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
this.removeCollectionViewer();
|
||||
}
|
||||
|
||||
private void hidePopup() {
|
||||
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
||||
}
|
||||
|
||||
public void removeCollectionViewer() {
|
||||
hidePopup();
|
||||
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof CollectionViewerPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
if (c != null) {
|
||||
((CollectionViewerPane)c).removeFrame();
|
||||
}
|
||||
|
||||
}
|
||||
private final class MageBookContainer extends JPanel {
|
||||
public MageBookContainer() {
|
||||
super();
|
||||
|
|
Loading…
Reference in a new issue