mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
More changes to reduce memory leaks.
This commit is contained in:
parent
da2dc4cd5a
commit
e2c0e211ef
4 changed files with 229 additions and 149 deletions
|
|
@ -34,13 +34,10 @@
|
|||
|
||||
package mage.client.game;
|
||||
|
||||
import java.beans.PropertyVetoException;
|
||||
import mage.client.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.MagePane;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -68,13 +65,20 @@ public class GamePane extends MagePane {
|
|||
}
|
||||
|
||||
public void hideGame() {
|
||||
try {
|
||||
gamePanel.hideGame();
|
||||
this.setClosed(true);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(GamePane.class.getName()).log(Level.SEVERE, "GamePane could not be closed", ex);
|
||||
this.dispose();
|
||||
}
|
||||
// try {
|
||||
MageFrame.deactivate(this);
|
||||
MageFrame.getDesktop().remove(this);
|
||||
|
||||
gamePanel.cleanUp();
|
||||
|
||||
this.getUI().uninstallUI(this);
|
||||
this.removeAll();
|
||||
this.dispose();
|
||||
// this.setClosed(true);
|
||||
// } catch (PropertyVetoException ex) {
|
||||
// Logger.getLogger(GamePane.class.getName()).log(Level.SEVERE, "GamePane could not be closed", ex);
|
||||
// this.dispose();
|
||||
// }
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,46 @@
|
|||
*/
|
||||
package mage.client.game;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
|
|
@ -36,35 +76,34 @@ import mage.client.components.HoverButton;
|
|||
import mage.client.components.MageComponents;
|
||||
import mage.client.components.ext.dlg.DialogManager;
|
||||
import mage.client.components.layout.RelativeLayout;
|
||||
import mage.client.dialog.*;
|
||||
import mage.client.dialog.ExileZoneDialog;
|
||||
import mage.client.dialog.PickChoiceDialog;
|
||||
import mage.client.dialog.PickNumberDialog;
|
||||
import mage.client.dialog.PickPileDialog;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||
import mage.client.plugins.adapters.MageActionCallback;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.remote.Session;
|
||||
import mage.view.*;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.ExileView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.LookedAtView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.PlayerView;
|
||||
import mage.view.RevealedView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import mage.cards.Card;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com, nantuko8
|
||||
|
|
@ -105,12 +144,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
// Override layout (I can't edit generated code)
|
||||
this.setLayout(new BorderLayout());
|
||||
final JLayeredPane j = new JLayeredPane();
|
||||
j.setSize(1024, 768);
|
||||
this.add(j);
|
||||
j.add(jSplitPane0, JLayeredPane.DEFAULT_LAYER);
|
||||
final JLayeredPane jLayeredBackgroundPane = new JLayeredPane();
|
||||
jLayeredBackgroundPane.setSize(1024, 768);
|
||||
this.add(jLayeredBackgroundPane);
|
||||
jLayeredBackgroundPane.add(jSplitPane0, JLayeredPane.DEFAULT_LAYER);
|
||||
|
||||
Map<String, JComponent> myUi = getUIComponents(j);
|
||||
Map<String, JComponent> myUi = getUIComponents(jLayeredBackgroundPane);
|
||||
Plugins.getInstance().updateGamePanel(myUi);
|
||||
|
||||
// Enlarge jlayeredpane on resize
|
||||
|
|
@ -119,7 +158,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
public void componentResized(ComponentEvent e) {
|
||||
int width = ((JComponent) e.getSource()).getWidth();
|
||||
int height = ((JComponent) e.getSource()).getHeight();
|
||||
j.setSize(width, height);
|
||||
jLayeredBackgroundPane.setSize(width, height);
|
||||
jSplitPane0.setSize(width, height);
|
||||
|
||||
if (height < storedHeight) {
|
||||
|
|
@ -160,12 +199,39 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
MageFrame.removeGame(gameId);
|
||||
saveDividerLocations();
|
||||
this.gameChatPanel.disconnect();
|
||||
|
||||
for (MouseListener ml :this.getMouseListeners()) {
|
||||
this.removeMouseListener(ml);
|
||||
}
|
||||
for (MouseListener ml :this.btnConcede.getMouseListeners()) {
|
||||
this.btnConcede.removeMouseListener(ml);
|
||||
}
|
||||
for (MouseListener ml :this.btnEndTurn.getMouseListeners()) {
|
||||
this.btnEndTurn.removeMouseListener(ml);
|
||||
}
|
||||
for (MouseListener ml :this.btnSwitchHands.getMouseListeners()) {
|
||||
this.btnSwitchHands.removeMouseListener(ml);
|
||||
}
|
||||
|
||||
for (ActionListener al :this.btnStopWatching.getActionListeners()) {
|
||||
this.btnStopWatching.removeActionListener(al);
|
||||
}
|
||||
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
||||
this.btnNextPlay.removeActionListener(al);
|
||||
}
|
||||
for(Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry: players.entrySet()) {
|
||||
playAreaPanelEntry.getValue().CleanUp();
|
||||
// playAreaPanelEntry.getValue().getUI().uninstallUI(playAreaPanelEntry.getValue());
|
||||
// playAreaPanelEntry.getValue().removeAll();
|
||||
}
|
||||
this.players.clear();
|
||||
|
||||
this.pnlBattlefield.removeAll();
|
||||
|
||||
|
||||
this.getUI().uninstallUI(this);
|
||||
|
||||
|
||||
if (pickNumber != null) {
|
||||
MageFrame.getDesktop().remove(pickNumber);
|
||||
pickNumber.removeDialog();
|
||||
}
|
||||
for (ExileZoneDialog exile: exiles.values()) {
|
||||
|
|
@ -174,12 +240,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
for (ShowCardsDialog reveal: revealed.values()) {
|
||||
reveal.hideDialog();
|
||||
}
|
||||
this.jSplitPane0.getUI().uninstallUI(jSplitPane0);
|
||||
this.jSplitPane0.removeAll();
|
||||
|
||||
try {
|
||||
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||
popupContainer.setVisible(false);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("popupContainer error:", ex);
|
||||
}
|
||||
}
|
||||
this.removeAll();
|
||||
}
|
||||
|
||||
private void saveDividerLocations() {
|
||||
|
|
@ -324,13 +394,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
* Closes the game and it's resources
|
||||
*/
|
||||
public void hideGame() {
|
||||
cleanUp();
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof GamePane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((GamePane)c).hideFrame();
|
||||
((GamePane)c).hideGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -76,14 +77,22 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
update(player);
|
||||
}
|
||||
|
||||
public void CleanUp() {
|
||||
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
|
||||
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
||||
}
|
||||
this.removeAll();
|
||||
this.getUI().uninstallUI(this);
|
||||
}
|
||||
|
||||
private void addPopupMenu() {
|
||||
final JPopupMenu Pmenu;
|
||||
final JPopupMenu popupMenu;
|
||||
JMenuItem menuItem;
|
||||
|
||||
Pmenu = new JPopupMenu();
|
||||
popupMenu = new JPopupMenu();
|
||||
|
||||
menuItem = new JMenuItem("F2 - Confirm");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Confirm (F2)
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -97,7 +106,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
|
||||
menuItem = new JMenuItem("F3 - Cancel previous F4/F9 skip action");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Cancel (F3)
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -107,10 +116,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
Pmenu.addSeparator();
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JMenuItem("F4 - Skip phases until next turn (stop on stack/attack/block)");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Skip to next turn (F4)
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -121,7 +130,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
});
|
||||
|
||||
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Skip to next own turn (F9)
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -131,10 +140,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
Pmenu.addSeparator();
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JMenuItem("Concede game");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Concede
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -146,10 +155,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
Pmenu.addSeparator();
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JMenuItem("Concede complete match");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Quit match
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -170,20 +179,20 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void mouseReleased(MouseEvent Me) {
|
||||
if (Me.isPopupTrigger() && playingMode) {
|
||||
Pmenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addPopupMenuWatcher() {
|
||||
final JPopupMenu Pmenu;
|
||||
final JPopupMenu popupMenu;
|
||||
JMenuItem menuItem;
|
||||
|
||||
Pmenu = new JPopupMenu();
|
||||
popupMenu = new JPopupMenu();
|
||||
|
||||
menuItem = new JMenuItem("Stop watching");
|
||||
Pmenu.add(menuItem);
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Stop watching
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
|
@ -200,7 +209,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void mouseReleased(MouseEvent Me) {
|
||||
if (Me.isPopupTrigger() && playingMode) {
|
||||
Pmenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import java.io.InputStream;
|
|||
import java.util.Map;
|
||||
|
||||
@PluginImplementation
|
||||
@Author(name = "nantuko")
|
||||
@Author(name = "nantuko")
|
||||
/* udpated by Noahsark */
|
||||
public class ThemePluginImpl implements ThemePlugin {
|
||||
|
||||
|
|
@ -27,6 +27,7 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
private static BufferedImage background;
|
||||
private List flist = new List();
|
||||
private String BackgroundDir = "backgrounds" + File.separator;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
}
|
||||
|
|
@ -40,52 +41,51 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
return "[Theme plugin, version 0.5]";
|
||||
}
|
||||
|
||||
public boolean loadimages(){
|
||||
public boolean loadimages() {
|
||||
File filedir = new File(BackgroundDir);
|
||||
File[] filelist = filedir.listFiles();
|
||||
if(filelist == null) return false;
|
||||
if(filelist.length == 0) return false;
|
||||
for(File f:filelist){
|
||||
if (filelist == null) {
|
||||
return false;
|
||||
}
|
||||
if (filelist.length == 0) {
|
||||
return false;
|
||||
}
|
||||
for (File f : filelist) {
|
||||
String filename = f.getName().toLowerCase();
|
||||
if(filename != null && (filename.endsWith(".png") || filename.endsWith(".jpg")
|
||||
|| filename.endsWith(".bmp"))){
|
||||
flist.add(filename);
|
||||
if (filename != null && (filename.endsWith(".png") || filename.endsWith(".jpg")
|
||||
|| filename.endsWith(".bmp"))) {
|
||||
flist.add(filename);
|
||||
}
|
||||
}
|
||||
if(flist.getItemCount() == 0) return false;
|
||||
if (flist.getItemCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInGame(Map<String, JComponent> ui) {
|
||||
BufferedImage background;
|
||||
try {
|
||||
|
||||
if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_DEFAULT,
|
||||
"true").equals("true")){
|
||||
|
||||
background = loadbuffer_default();
|
||||
|
||||
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_RANDOM,
|
||||
"true").equals("true")){
|
||||
|
||||
background = loadbuffer_random();
|
||||
|
||||
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "") != null){
|
||||
|
||||
background = loadbuffer_selected();
|
||||
|
||||
}else{
|
||||
background = loadbuffer_default();
|
||||
}
|
||||
|
||||
if (background == null) {
|
||||
background = loadbuffer_default();
|
||||
}
|
||||
if (background == null){
|
||||
throw new FileNotFoundException("Couldn't find in resources.");
|
||||
}
|
||||
BufferedImage backgroundImage;
|
||||
try {
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_DEFAULT,"true").equals("true")) {
|
||||
backgroundImage = loadbuffer_default();
|
||||
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_RANDOM,"true").equals("true")) {
|
||||
backgroundImage = loadbuffer_random();
|
||||
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "") != null) {
|
||||
backgroundImage = loadbuffer_selected();
|
||||
} else {
|
||||
backgroundImage = loadbuffer_default();
|
||||
}
|
||||
|
||||
if (backgroundImage == null) {
|
||||
backgroundImage = loadbuffer_default();
|
||||
}
|
||||
if (backgroundImage == null) {
|
||||
throw new FileNotFoundException("Couldn't find in resources.");
|
||||
}
|
||||
|
||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||
ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanel.TILED);
|
||||
|
||||
unsetOpaque(ui.get("jSplitPane1"));
|
||||
unsetOpaque(ui.get("pnlBattlefield"));
|
||||
|
|
@ -102,45 +102,41 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BufferedImage loadbuffer_default() throws IOException{
|
||||
String filename = "/dragon.png";
|
||||
BufferedImage res;
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
res = ImageIO.read(is);
|
||||
return res;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_random() throws IOException{
|
||||
BufferedImage res;
|
||||
if(loadimages()){
|
||||
int it = (int)Math.abs(Math.random()*(flist.getItemCount()));
|
||||
String filename = BackgroundDir + flist.getItem(it);
|
||||
res = ImageIO.read(new File(filename));
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_selected() throws IOException{
|
||||
BufferedImage res;
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BATTLEFIELD_IMAGE, "");
|
||||
if(path != null && !path.equals("")){
|
||||
try{
|
||||
res = ImageIO.read(new File(path));
|
||||
return res;
|
||||
}catch(Exception e){
|
||||
res = null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_default() throws IOException {
|
||||
String filename = "/dragon.png";
|
||||
BufferedImage res;
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
res = ImageIO.read(is);
|
||||
return res;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_random() throws IOException {
|
||||
BufferedImage res;
|
||||
if (loadimages()) {
|
||||
int it = (int) Math.abs(Math.random() * (flist.getItemCount()));
|
||||
String filename = BackgroundDir + flist.getItem(it);
|
||||
res = ImageIO.read(new File(filename));
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_selected() throws IOException {
|
||||
BufferedImage res;
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "");
|
||||
if (path != null && !path.equals("")) {
|
||||
try {
|
||||
res = ImageIO.read(new File(path));
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
res = null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public JComponent updateTable(Map<String, JComponent> ui) {
|
||||
ImagePanel bgPanel = createImagePanelInstance();
|
||||
|
|
@ -150,7 +146,7 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
unsetOpaque(ui.get("tablesPanel"));
|
||||
JComponent viewport = ui.get("jScrollPane1ViewPort");
|
||||
if (viewport != null) {
|
||||
viewport.setBackground(new Color(255,255,255,50));
|
||||
viewport.setBackground(new Color(255, 255, 255, 50));
|
||||
}
|
||||
return bgPanel;
|
||||
}
|
||||
|
|
@ -161,34 +157,36 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
if (background == null) {
|
||||
String filename = "/background.png";
|
||||
try {
|
||||
if(PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")){
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
background = ImageIO.read(is);
|
||||
}else{
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BACKGROUND_IMAGE, "");
|
||||
if(path != null && !path.equals("")){
|
||||
try{
|
||||
} else {
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
|
||||
if (path != null && !path.equals("")) {
|
||||
try {
|
||||
File f = new File(path);
|
||||
if(f != null)
|
||||
background = ImageIO.read(f);
|
||||
}catch(Exception e){
|
||||
if (f != null) {
|
||||
background = ImageIO.read(f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
background = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (background == null){
|
||||
if (background == null) {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
background = ImageIO.read(is);
|
||||
}
|
||||
if(background == null) throw new
|
||||
FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}catch (Exception e) {
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue