mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Move confirmation OptionPane from SessionImpl to ConsolePanel
This commit is contained in:
parent
f31b1ab7e3
commit
bf3682fa77
2 changed files with 52 additions and 44 deletions
|
@ -32,7 +32,6 @@ import java.lang.reflect.UndeclaredThrowableException;
|
|||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.*;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
@ -1437,12 +1436,9 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean endUserSession(String userSessionId) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.endUserSession(sessionId, userSessionId);
|
||||
return true;
|
||||
}
|
||||
if (isConnected()) {
|
||||
server.endUserSession(sessionId, userSessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
@ -1455,12 +1451,9 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean muteUserChat(String userName, long durationMinutes) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute user " + userName + " for " + durationMinutes + " minutes?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.muteUser(sessionId, userName, durationMinutes);
|
||||
return true;
|
||||
}
|
||||
if (isConnected()) {
|
||||
server.muteUser(sessionId, userName, durationMinutes);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
@ -1473,12 +1466,9 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean setActivation(String userName, boolean active) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to set active to " + active + " for user: " + userName + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.setActivation(sessionId, userName, active);
|
||||
return true;
|
||||
}
|
||||
if (isConnected()) {
|
||||
server.setActivation(sessionId, userName, active);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
@ -1491,20 +1481,9 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean toggleActivation(String userName) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to active?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
return setActivation(userName, true);
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to INactive?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
return setActivation(userName, false);
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to toggle activation for user: " + userName + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.toggleActivation(sessionId, userName);
|
||||
return true;
|
||||
}
|
||||
if (isConnected()) {
|
||||
server.toggleActivation(sessionId, userName);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
@ -1517,12 +1496,9 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean lockUser(String userName, long durationMinute) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to lock user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.lockUser(sessionId, userName, durationMinute);
|
||||
return true;
|
||||
}
|
||||
if (isConnected()) {
|
||||
server.lockUser(sessionId, userName, durationMinute);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
|
|
@ -345,22 +345,54 @@ public class ConsolePanel extends javax.swing.JPanel {
|
|||
|
||||
private void btnEndSessionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEndSessionActionPerformed
|
||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||
ConsoleFrame.getSession().endUserSession((String) tableUserModel.getValueAt(row, TableUserModel.POS_GAME_INFO));
|
||||
String userSessionId = (String) tableUserModel.getValueAt(row, TableUserModel.POS_GAME_INFO);
|
||||
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().endUserSession(userSessionId);
|
||||
}
|
||||
}//GEN-LAST:event_btnEndSessionActionPerformed
|
||||
|
||||
private void btnMuteUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMuteUserActionPerformed
|
||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||
ConsoleFrame.getSession().muteUserChat((String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME), ((Number) spinnerMuteDurationMinutes.getValue()).longValue());
|
||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||
String userName = (String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME);
|
||||
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().muteUserChat(userName, durationMinute);
|
||||
}
|
||||
}//GEN-LAST:event_btnMuteUserActionPerformed
|
||||
|
||||
private void btnDeActivateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeActivateActionPerformed
|
||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||
ConsoleFrame.getSession().toggleActivation((String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME));
|
||||
String userName = (String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME);
|
||||
|
||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to active?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().setActivation(userName, true);
|
||||
return;
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to inactive?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().setActivation(userName, false);
|
||||
return;
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to toggle activation for user: " + userName + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().toggleActivation(userName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnDeActivateActionPerformed
|
||||
|
||||
private void btnLockUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLockUserActionPerformed
|
||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||
ConsoleFrame.getSession().lockUser((String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME), ((Number) spinnerMuteDurationMinutes.getValue()).longValue());
|
||||
String userName = (String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME);
|
||||
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to lock user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
ConsoleFrame.getSession().lockUser(userName, durationMinute);
|
||||
}
|
||||
}//GEN-LAST:event_btnLockUserActionPerformed
|
||||
|
||||
private void btnRemoveTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveTableActionPerformed
|
||||
|
|
Loading…
Reference in a new issue