Some changes to the server console.

This commit is contained in:
LevelX2 2016-10-04 17:40:37 +02:00
parent a1123b3c0b
commit db31264538
7 changed files with 212 additions and 89 deletions

View file

@ -52,8 +52,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jPanel3" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jPanel4" min="-2" pref="33" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -64,12 +64,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="249" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="358" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="347" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
@ -101,10 +101,16 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="btnDisconnect" min="-2" pref="103" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnDisconnect" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnEndSession" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="8" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="sliderMuteDurationMinutes" pref="0" max="32767" attributes="0"/>
<Component id="btnMuteUser" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="50" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -114,8 +120,10 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnDisconnect" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnEndSession" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnMuteUser" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
<Component id="sliderMuteDurationMinutes" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -137,6 +145,21 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnEndSessionActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnMuteUser">
<Properties>
<Property name="text" type="java.lang.String" value="Mute user"/>
<Property name="actionCommand" type="java.lang.String" value="Mute 1h"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnMuteUserActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSlider" name="sliderMuteDurationMinutes">
<Properties>
<Property name="maximum" type="int" value="3600"/>
<Property name="value" type="int" value="60"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
@ -159,7 +182,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jPanel5" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel6" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
@ -171,12 +194,15 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane2" alignment="0" pref="306" max="32767" attributes="0"/>
<Component id="jScrollPane2" alignment="0" pref="351" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane2" alignment="0" pref="356" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane2" min="-2" pref="343" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
@ -205,8 +231,9 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnRemoveTable" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="170" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -214,7 +241,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="btnRemoveTable" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="31" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View file

@ -24,9 +24,9 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
/*
/*
* ConsolePanel.java
*
* Created on 14-May-2011, 6:08:48 PM
@ -63,7 +63,9 @@ public class ConsolePanel extends javax.swing.JPanel {
private UpdateUsersTask updateUsersTask;
private UpdateTablesTask updateTablesTask;
/** Creates new form ConsolePanel */
/**
* Creates new form ConsolePanel
*/
public ConsolePanel() {
this.tableUserModel = new TableUserModel();
this.tableTableModel = new TableTableModel();
@ -91,7 +93,6 @@ public class ConsolePanel extends javax.swing.JPanel {
this.tblTables.getSelectionModel().setSelectionInterval(row, row);
}
public void start() {
updateUsersTask = new UpdateUsersTask(ConsoleFrame.getSession(), this);
updateTablesTask = new UpdateTablesTask(ConsoleFrame.getSession(), ConsoleFrame.getSession().getMainRoomId(), this);
@ -108,10 +109,10 @@ public class ConsolePanel extends javax.swing.JPanel {
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -125,6 +126,8 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel4 = new javax.swing.JPanel();
btnDisconnect = new javax.swing.JButton();
btnEndSession = new javax.swing.JButton();
btnMuteUser = new javax.swing.JButton();
sliderMuteDurationMinutes = new javax.swing.JSlider();
jPanel2 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
@ -142,11 +145,11 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
);
jPanel4.setVerifyInputWhenFocusTarget(false);
@ -165,23 +168,41 @@ public class ConsolePanel extends javax.swing.JPanel {
}
});
btnMuteUser.setText("Mute user");
btnMuteUser.setActionCommand("Mute 1h");
btnMuteUser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMuteUserActionPerformed(evt);
}
});
sliderMuteDurationMinutes.setMaximum(3600);
sliderMuteDurationMinutes.setValue(60);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(btnDisconnect, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addContainerGap()
.addComponent(btnDisconnect)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnEndSession)
.addContainerGap(8, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(sliderMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(btnMuteUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(50, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDisconnect)
.addComponent(btnEndSession))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(btnEndSession)
.addComponent(btnMuteUser))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addComponent(sliderMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
@ -195,8 +216,8 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jSplitPane1.setLeftComponent(jPanel1);
@ -208,11 +229,13 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
btnRemoveTable.setLabel("Remove Table");
@ -227,14 +250,15 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnRemoveTable)
.addContainerGap(170, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(btnRemoveTable)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(31, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
@ -242,13 +266,13 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
@ -258,7 +282,7 @@ public class ConsolePanel extends javax.swing.JPanel {
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -268,22 +292,28 @@ public class ConsolePanel extends javax.swing.JPanel {
private void btnDisconnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisconnectActionPerformed
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
ConsoleFrame.getSession().disconnectUser((String)tableUserModel.getValueAt(row, 3));
ConsoleFrame.getSession().disconnectUser((String) tableUserModel.getValueAt(row, TableUserModel.POS_SESSION_ID));
}//GEN-LAST:event_btnDisconnectActionPerformed
private void btnRemoveTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveTableActionPerformed
int row = this.tblTables.convertRowIndexToModel(tblTables.getSelectedRow());
ConsoleFrame.getSession().removeTable((UUID)tableTableModel.getValueAt(row, 7));
ConsoleFrame.getSession().removeTable((UUID) tableTableModel.getValueAt(row, 7));
}//GEN-LAST:event_btnRemoveTableActionPerformed
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, 3));
ConsoleFrame.getSession().endUserSession((String) tableUserModel.getValueAt(row, TableUserModel.POS_GAME_INFO));
}//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), sliderMuteDurationMinutes.getValue());
}//GEN-LAST:event_btnMuteUserActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnDisconnect;
private javax.swing.JButton btnEndSession;
private javax.swing.JButton btnMuteUser;
private javax.swing.JButton btnRemoveTable;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
@ -294,13 +324,22 @@ public class ConsolePanel extends javax.swing.JPanel {
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSlider sliderMuteDurationMinutes;
private javax.swing.JTable tblTables;
private javax.swing.JTable tblUsers;
// End of variables declaration//GEN-END:variables
}
class TableUserModel extends AbstractTableModel {
private final String[] columnNames = new String[]{"User Name", "Host", "Time Connected", "SessionId", "Gameinfo"};
public static final int POS_USER_NAME = 0;
public static final int POS_HOST = 1;
public static final int POS_TIME_CONNECTED = 2;
public static final int POS_SESSION_ID = 3;
public static final int POS_GAME_INFO = 4;
public static final int POS_USER_STATE = 5;
private final String[] columnNames = new String[]{"User Name", "Host", "Time Connected", "SessionId", "Gameinfo", "User State"};
private UserView[] users = new UserView[0];
private static final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
@ -322,16 +361,18 @@ class TableUserModel extends AbstractTableModel {
@Override
public Object getValueAt(int arg0, int arg1) {
switch (arg1) {
case 0:
case POS_USER_NAME:
return users[arg0].getUserName();
case 1:
case POS_HOST:
return users[arg0].getHost();
case 2:
case POS_TIME_CONNECTED:
return formatter.format(users[arg0].getConnectionTime());
case 3:
case POS_SESSION_ID:
return users[arg0].getSessionId();
case 4:
case POS_GAME_INFO:
return users[arg0].getGameInfo();
case POS_USER_STATE:
return users[arg0].getUserState();
}
return "";
}
@ -348,7 +389,7 @@ class TableUserModel extends AbstractTableModel {
}
@Override
public Class getColumnClass(int columnIndex){
public Class getColumnClass(int columnIndex) {
return String.class;
}
@ -360,10 +401,10 @@ class TableUserModel extends AbstractTableModel {
}
class TableTableModel extends AbstractTableModel {
private final String[] columnNames = new String[]{"Table Name", "Owner", "Game Type", "Deck Type", "Status"};
private TableView[] tables = new TableView[0];
public void loadData(Collection<TableView> tables) {
this.tables = tables.toArray(new TableView[0]);
this.fireTableDataChanged();
@ -397,7 +438,7 @@ class TableTableModel extends AbstractTableModel {
case 6:
if (!tables[arg0].getGames().isEmpty()) {
return tables[arg0].getGames().get(0);
}
}
return null;
case 7:
return tables[arg0].getTableId();
@ -417,7 +458,7 @@ class TableTableModel extends AbstractTableModel {
}
@Override
public Class getColumnClass(int columnIndex){
public Class getColumnClass(int columnIndex) {
return String.class;
}
@ -497,7 +538,8 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
logger.fatal("Update Users Task error", ex);
} catch (ExecutionException ex) {
logger.fatal("Update Users Task error", ex);
} catch (CancellationException ex) {}
} catch (CancellationException ex) {
}
}
}
@ -537,6 +579,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
logger.fatal("Update Tables Task error", ex);
} catch (ExecutionException ex) {
logger.fatal("Update Tables Task error", ex);
} catch (CancellationException ex) {}
} catch (CancellationException ex) {
}
}
}