mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* MageDialog - Removed some memory leaks for client dialogs (more to come soon).
This commit is contained in:
parent
2302b39b47
commit
4ab572bd0e
9 changed files with 59 additions and 34 deletions
|
|
@ -1122,6 +1122,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
chats.put(chatId, chatPanel);
|
||||
}
|
||||
|
||||
public static void removeChat(UUID chatId) {
|
||||
chats.remove(chatId);
|
||||
}
|
||||
|
||||
public static GamePanel getGame(UUID gameId) {
|
||||
return games.get(gameId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
public void disconnect() {
|
||||
if (session != null) {
|
||||
session.leaveChat(chatId);
|
||||
MageFrame.removeChat(chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
package mage.client.components;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class MageUI {
|
||||
|
||||
private Map<MageComponents, Component> ui = new HashMap<MageComponents, Component>();
|
||||
private Map<MageComponents, Object> sync = new HashMap<MageComponents, Object>();
|
||||
private final Map<MageComponents, Component> ui = new EnumMap<MageComponents, Component>(MageComponents.class);
|
||||
private final Map<MageComponents, Object> sync = new EnumMap<MageComponents, Object>(MageComponents.class);
|
||||
|
||||
public JButton getButton(MageComponents name) throws InterruptedException {
|
||||
//System.out.println("request for " + name);
|
||||
|
|
@ -70,6 +69,12 @@ public class MageUI {
|
|||
}
|
||||
}
|
||||
|
||||
public void removeButton(MageComponents name) {
|
||||
synchronized (ui) {
|
||||
ui.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(MageComponents name, Component component) {
|
||||
synchronized (ui) {
|
||||
ui.put(name, component);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<Component id="jLabel3" min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="30" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="34" max="32767" attributes="0"/>
|
||||
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Thanks: maurer.it, Rafbill, Alvin, cbt33."/>
|
||||
<Property name="text" type="java.lang.String" value="Thanks: maurer.it, Rafbill, Alvin, cbt33, Quercitron."/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
|
|
|
|||
|
|
@ -26,15 +26,17 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.dialog;
|
||||
|
||||
import mage.utils.MageVersion;
|
||||
|
||||
/*
|
||||
* AboutDialog.java
|
||||
*
|
||||
* Created on Mar 10, 2010, 8:19:41 AM
|
||||
*/
|
||||
|
||||
package mage.client.dialog;
|
||||
|
||||
import mage.utils.MageVersion;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,8 +46,9 @@ public class AboutDialog extends MageDialog {
|
|||
|
||||
/** Creates new form AboutDialog */
|
||||
public AboutDialog() {
|
||||
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
initComponents();
|
||||
this.modal = false;
|
||||
// this.modal = false;
|
||||
}
|
||||
|
||||
public void showDialog(MageVersion version) {
|
||||
|
|
@ -87,7 +90,7 @@ public class AboutDialog extends MageDialog {
|
|||
|
||||
jLabel3.setText("Devs: BetaSteward, Noxx, Eugen.Rivniy, North, LevelX2, Jeff, Plopman. ");
|
||||
|
||||
jLabel4.setText("Thanks: maurer.it, Rafbill, Alvin, cbt33.");
|
||||
jLabel4.setText("Thanks: maurer.it, Rafbill, Alvin, cbt33, Quercitron.");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
|
@ -119,7 +122,7 @@ public class AboutDialog extends MageDialog {
|
|||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jLabel4)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
|
||||
.addComponent(btnOk)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
|
@ -128,7 +131,9 @@ public class AboutDialog extends MageDialog {
|
|||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.hideDialog();
|
||||
|
||||
|
||||
this.removeDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
|||
|
|
@ -39,14 +39,16 @@ import org.apache.log4j.Logger;
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
import mage.client.MageFrame;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class MageDialog extends javax.swing.JInternalFrame {
|
||||
public class MageDialog extends javax.swing.JInternalFrame {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||
|
||||
|
|
@ -61,8 +63,9 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
public void show() {
|
||||
super.show();
|
||||
this.toFront();
|
||||
if (modal)
|
||||
if (modal) {
|
||||
this.setClosable(false);
|
||||
}
|
||||
if (this.modal) {
|
||||
startModal();
|
||||
}
|
||||
|
|
@ -71,8 +74,9 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
@Override
|
||||
public void setVisible(boolean value) {
|
||||
super.setVisible(value);
|
||||
if (value)
|
||||
if (value) {
|
||||
this.toFront();
|
||||
}
|
||||
if (modal) {
|
||||
this.setClosable(false);
|
||||
if (value) {
|
||||
|
|
@ -159,22 +163,20 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
}
|
||||
|
||||
public void removeDialog() {
|
||||
this.setVisible(false);
|
||||
setVisible(false);
|
||||
MageFrame.getDesktop().remove(this);
|
||||
this.ui.uninstallUI(this);
|
||||
this.dispose();
|
||||
try {
|
||||
this.setSelected(false);
|
||||
} catch (PropertyVetoException ex) {
|
||||
java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitelBarToolTip(final String text) {
|
||||
desktopIcon.setToolTipText(text); //tooltip on icon
|
||||
Component[] children = desktopIcon.getComponents();
|
||||
// if (children != null) {
|
||||
// for(int i = 0; i < children.length; i++) {
|
||||
// if (children[i] instanceof JButton){
|
||||
// ((JButton)children[i]).setToolTipText(text);//tooltip on icon button
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
children = getComponents();
|
||||
Component[] children = getComponents();
|
||||
if (children != null) {
|
||||
for(int i = 0; i < children.length; i++) {
|
||||
if (children[i].getClass().getName().equalsIgnoreCase(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jSplitPane1" pref="275" max="32767" attributes="0"/>
|
||||
<Component id="jSplitPane1" pref="279" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnMoveDown" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
|
|
|||
|
|
@ -139,9 +139,12 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}
|
||||
|
||||
public void closeDialog() {
|
||||
if (updateTask != null) updateTask.cancel(true);
|
||||
if (updateTask != null) {
|
||||
updateTask.cancel(true);
|
||||
}
|
||||
this.chatPanel.disconnect();
|
||||
this.hideDialog();
|
||||
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
||||
this.removeDialog();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -243,11 +246,13 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
||||
closeDialog();
|
||||
if (!isTournament)
|
||||
if (!isTournament) {
|
||||
session.startGame(roomId, tableId);
|
||||
else
|
||||
}
|
||||
else {
|
||||
session.startTournament(roomId, tableId);
|
||||
}
|
||||
closeDialog();
|
||||
}//GEN-LAST:event_btnStartActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue