Merge branch 'master' of ssh://109.200.159.85/var/lib/git/mage

This commit is contained in:
BetaSteward 2012-01-27 21:37:07 -05:00
commit f7354dc69c
14 changed files with 1065 additions and 149 deletions

View file

@ -61,6 +61,19 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents> <SubComponents>
<Component class="javax.swing.JButton" name="btnSendFeedback">
<Properties>
<Property name="text" type="java.lang.String" value="Feedback"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSendFeedbackActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator4">
</Component>
<Component class="javax.swing.JButton" name="btnConnect"> <Component class="javax.swing.JButton" name="btnConnect">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Connect"/> <Property name="text" type="java.lang.String" value="Connect"/>
@ -77,7 +90,7 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConnectActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConnectActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator4"> <Component class="javax.swing.JToolBar$Separator" name="jSeparator3">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnGames"> <Component class="javax.swing.JButton" name="btnGames">
<Properties> <Properties>
@ -95,7 +108,7 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGamesActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGamesActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator3"> <Component class="javax.swing.JToolBar$Separator" name="jSeparator1">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnDeckEditor"> <Component class="javax.swing.JButton" name="btnDeckEditor">
<Properties> <Properties>
@ -157,7 +170,7 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAboutActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAboutActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator1"> <Component class="javax.swing.JToolBar$Separator" name="jSeparator7">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnExit"> <Component class="javax.swing.JButton" name="btnExit">
<Properties> <Properties>

View file

@ -35,7 +35,6 @@
package mage.client; package mage.client;
import mage.Constants; import mage.Constants;
import mage.interfaces.Action;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.client.cards.CardsStorage; import mage.client.cards.CardsStorage;
@ -62,7 +61,8 @@ import mage.client.util.SettingsManager;
import mage.client.util.gui.ArrowBuilder; import mage.client.util.gui.ArrowBuilder;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
import mage.interfaces.*; import mage.interfaces.Action;
import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient; import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection; import mage.remote.Connection;
@ -616,10 +616,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
desktopPane = new MageJDesktop(); desktopPane = new MageJDesktop();
mageToolbar = new javax.swing.JToolBar(); mageToolbar = new javax.swing.JToolBar();
btnConnect = new javax.swing.JButton(); btnSendFeedback = new javax.swing.JButton();
jSeparator4 = new javax.swing.JToolBar.Separator(); jSeparator4 = new javax.swing.JToolBar.Separator();
btnGames = new javax.swing.JButton(); btnConnect = new javax.swing.JButton();
jSeparator3 = new javax.swing.JToolBar.Separator(); jSeparator3 = new javax.swing.JToolBar.Separator();
btnGames = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator();
btnDeckEditor = new javax.swing.JButton(); btnDeckEditor = new javax.swing.JButton();
jSeparator2 = new javax.swing.JToolBar.Separator(); jSeparator2 = new javax.swing.JToolBar.Separator();
btnCollectionViewer = new javax.swing.JButton(); btnCollectionViewer = new javax.swing.JButton();
@ -627,18 +629,30 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnPreferences = new javax.swing.JButton(); btnPreferences = new javax.swing.JButton();
jSeparator6 = new javax.swing.JToolBar.Separator(); jSeparator6 = new javax.swing.JToolBar.Separator();
btnAbout = new javax.swing.JButton(); btnAbout = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator(); jSeparator7 = new javax.swing.JToolBar.Separator();
btnExit = new javax.swing.JButton(); btnExit = new javax.swing.JButton();
lblStatus = new javax.swing.JLabel(); lblStatus = new javax.swing.JLabel();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new Dimension(600, 400)); setMinimumSize(new java.awt.Dimension(1024, 768));
desktopPane.setBackground(new java.awt.Color(204, 204, 204)); desktopPane.setBackground(new java.awt.Color(204, 204, 204));
mageToolbar.setFloatable(false); mageToolbar.setFloatable(false);
mageToolbar.setRollover(true); mageToolbar.setRollover(true);
btnSendFeedback.setText("Feedback");
btnSendFeedback.setFocusable(false);
btnSendFeedback.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnSendFeedback.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSendFeedback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSendFeedbackActionPerformed(evt);
}
});
mageToolbar.add(btnSendFeedback);
mageToolbar.add(jSeparator4);
btnConnect.setText("Connect"); btnConnect.setText("Connect");
btnConnect.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnConnect.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnConnect.setFocusable(false); btnConnect.setFocusable(false);
@ -650,7 +664,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
}); });
mageToolbar.add(btnConnect); mageToolbar.add(btnConnect);
mageToolbar.add(jSeparator4); mageToolbar.add(jSeparator3);
btnGames.setText("Games"); btnGames.setText("Games");
btnGames.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnGames.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
@ -663,7 +677,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
}); });
mageToolbar.add(btnGames); mageToolbar.add(btnGames);
mageToolbar.add(jSeparator3); mageToolbar.add(jSeparator1);
btnDeckEditor.setText("Deck Editor"); btnDeckEditor.setText("Deck Editor");
btnDeckEditor.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnDeckEditor.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
@ -713,7 +727,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
}); });
mageToolbar.add(btnAbout); mageToolbar.add(btnAbout);
mageToolbar.add(jSeparator1); mageToolbar.add(jSeparator7);
btnExit.setText("Exit"); btnExit.setText("Exit");
btnExit.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnExit.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
@ -813,6 +827,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
PreferencesDialog.main(new String[]{}); PreferencesDialog.main(new String[]{});
}//GEN-LAST:event_btnPreferencesActionPerformed }//GEN-LAST:event_btnPreferencesActionPerformed
private void btnSendFeedbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendFeedbackActionPerformed
if (!session.isConnected()) {
JOptionPane.showMessageDialog(null, "You may send us feedback only when connected to server.", "Information", JOptionPane.INFORMATION_MESSAGE);
return;
}
FeedbackDialog.main(new String[]{});
}//GEN-LAST:event_btnSendFeedbackActionPerformed
public void exitApp() { public void exitApp() {
if (session.isConnected()) { if (session.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
@ -962,6 +984,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private javax.swing.JButton btnExit; private javax.swing.JButton btnExit;
private javax.swing.JButton btnGames; private javax.swing.JButton btnGames;
private javax.swing.JButton btnPreferences; private javax.swing.JButton btnPreferences;
private javax.swing.JButton btnSendFeedback;
private static javax.swing.JDesktopPane desktopPane; private static javax.swing.JDesktopPane desktopPane;
private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator2;
@ -969,6 +992,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private javax.swing.JToolBar.Separator jSeparator4; private javax.swing.JToolBar.Separator jSeparator4;
private javax.swing.JToolBar.Separator jSeparator5; private javax.swing.JToolBar.Separator jSeparator5;
private javax.swing.JToolBar.Separator jSeparator6; private javax.swing.JToolBar.Separator jSeparator6;
private javax.swing.JToolBar.Separator jSeparator7;
private javax.swing.JLabel lblStatus; private javax.swing.JLabel lblStatus;
private javax.swing.JToolBar mageToolbar; private javax.swing.JToolBar mageToolbar;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -0,0 +1,258 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Feedback"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" pref="469" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="324" max="32767" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jTabbedPane1" min="-2" pref="292" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="sendButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Feedback"/>
</AccessibilityProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel6">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Give feedback">
<Property name="tabTitle" type="java.lang.String" value="Give feedback"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlProxy" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlProxy" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="41" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="pnlProxy">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="lblProxyUserName" alignment="0" max="32767" attributes="1"/>
<Component id="lblProxyType" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblProxyServer" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblProxyPort" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="cbFeedbackType" pref="243" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" pref="46" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="1">
<Component id="txtEmail" pref="238" max="32767" attributes="1"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" pref="46" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group>
<Component id="txtIdeaTitle" alignment="0" pref="325" max="32767" attributes="1"/>
<Component id="jScrollPane1" alignment="0" pref="325" max="32767" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblProxyServer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtIdeaTitle" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbFeedbackType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblProxyType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblProxyUserName" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="85" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtEmail" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblProxyPort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="21" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblProxyServer">
<Properties>
<Property name="text" type="java.lang.String" value="Enter your idea*"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtIdeaTitle">
</Component>
<Component class="javax.swing.JLabel" name="lblProxyPort">
<Properties>
<Property name="text" type="java.lang.String" value="Your email:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtEmail">
</Component>
<Component class="javax.swing.JLabel" name="lblProxyUserName">
<Properties>
<Property name="text" type="java.lang.String" value="Describe your idea*"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbFeedbackType">
</Component>
<Component class="javax.swing.JLabel" name="lblProxyType">
<Properties>
<Property name="text" type="java.lang.String" value="Category"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="txtFeedbackMessage">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="0"/>
</Property>
<Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" value="(300 characters max)"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="2"/>
</Property>
<Property name="text" type="java.lang.String" value="(optional)"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="2"/>
</Property>
<Property name="text" type="java.lang.String" value="(optional)"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="33" green="99" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="I suggest you..."/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="sendButton">
<Properties>
<Property name="text" type="java.lang.String" value="Send"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,328 @@
/*
* Copyright 2012 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
package mage.client.dialog;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
import javax.swing.*;
/**
* Feedback dialog.
*
* @author noxx
*/
public class FeedbackDialog extends javax.swing.JDialog {
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
private String[] feedbackTypes = {"", "Bug or \"something doesn't work\"",
"Feature or \"I need that function\"",
"Thank you or \"Devs, you are so cool!\"",
"Question or \"I'm so curious about\""};
/** Creates new form PreferencesDialog */
public FeedbackDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
cbFeedbackType.setModel(new DefaultComboBoxModel(feedbackTypes));
}
/** 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
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel6 = new javax.swing.JPanel();
pnlProxy = new javax.swing.JPanel();
lblProxyServer = new javax.swing.JLabel();
txtIdeaTitle = new javax.swing.JTextField();
lblProxyPort = new javax.swing.JLabel();
txtEmail = new javax.swing.JTextField();
lblProxyUserName = new javax.swing.JLabel();
cbFeedbackType = new javax.swing.JComboBox();
lblProxyType = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtFeedbackMessage = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Feedback");
lblProxyServer.setText("Enter your idea*");
lblProxyPort.setText("Your email:");
lblProxyUserName.setText("Describe your idea*");
lblProxyType.setText("Category");
txtFeedbackMessage.setColumns(20);
txtFeedbackMessage.setFont(new java.awt.Font("Tahoma", 0, 11));
txtFeedbackMessage.setRows(5);
txtFeedbackMessage.setText("(300 characters max)");
jScrollPane1.setViewportView(txtFeedbackMessage);
jLabel2.setFont(new java.awt.Font("Tahoma", 2, 11));
jLabel2.setText("(optional)");
jLabel3.setFont(new java.awt.Font("Tahoma", 2, 11));
jLabel3.setText("(optional)");
javax.swing.GroupLayout pnlProxyLayout = new javax.swing.GroupLayout(pnlProxy);
pnlProxy.setLayout(pnlProxyLayout);
pnlProxyLayout.setHorizontalGroup(
pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlProxyLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(lblProxyUserName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblProxyType, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblProxyServer, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(lblProxyPort))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlProxyLayout.createSequentialGroup()
.addComponent(cbFeedbackType, 0, 243, Short.MAX_VALUE)
.addGap(26, 26, 26)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlProxyLayout.createSequentialGroup()
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(pnlProxyLayout.createSequentialGroup()
.addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
.addGap(32, 32, 32)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(9, 9, 9))
.addComponent(txtIdeaTitle, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE))
.addContainerGap())))
);
pnlProxyLayout.setVerticalGroup(
pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlProxyLayout.createSequentialGroup()
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblProxyServer)
.addComponent(txtIdeaTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbFeedbackType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblProxyType)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblProxyUserName)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblProxyPort))
.addContainerGap(21, Short.MAX_VALUE))
);
jLabel1.setFont(new java.awt.Font("Arial", 1, 14));
jLabel1.setForeground(new java.awt.Color(255, 153, 51));
jLabel1.setText("I suggest you...");
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlProxy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlProxy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(41, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Give feedback", jPanel6);
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(324, Short.MAX_VALUE)
.addComponent(sendButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)
.addGap(17, 17, 17))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(sendButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.getAccessibleContext().setAccessibleName("Feedback");
pack();
}// </editor-fold>//GEN-END:initComponents
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
dialog.setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
String title = txtIdeaTitle.getText().trim();
if (title.isEmpty()) {
JOptionPane.showMessageDialog(null, "\"Enter your idea\" is a mandatory field", "Warning", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (title.length() > 100) {
JOptionPane.showMessageDialog(null, "\"Enter your idea\" value is too long (100 characters max)", "Warning", JOptionPane.INFORMATION_MESSAGE);
return;
}
String type = cleanUpType(cbFeedbackType.getSelectedItem().toString());
String message = txtFeedbackMessage.getText().trim();
if (message.isEmpty()) {
JOptionPane.showMessageDialog(null, "\"Describe your idea\" is a mandatory field.", "Warning", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (message.length() > 300) {
JOptionPane.showMessageDialog(null, "\"Describe your idea\" value is too long (300 characters max)", "Warning", JOptionPane.INFORMATION_MESSAGE);
}
String email = cleanUpType(cbFeedbackType.getSelectedItem().toString());
if (MageFrame.getSession().sendFeedback(title, type, message, email)) {
JOptionPane.showMessageDialog(null, "Feedback was sent. Thank you!", "Success", JOptionPane.INFORMATION_MESSAGE);
reset();
} else {
JOptionPane.showMessageDialog(null, "Couldn't sent feedback.", "Error", JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_sendButtonActionPerformed
private String cleanUpType(String type) {
if (type == null || type.isEmpty()) {
return "";
}
if (type.toLowerCase().startsWith("bug")) {
return "bug";
}
if (type.toLowerCase().startsWith("feature")) {
return "feature";
}
if (type.toLowerCase().startsWith("thank")) {
return "thank";
}
if (type.toLowerCase().startsWith("question")) {
return "question";
}
return "";
}
private void reset() {
jTabbedPane1.setSelectedIndex(0);
txtIdeaTitle.setText("");
txtFeedbackMessage.setText("");
txtEmail.setText("");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (!dialog.isVisible()) {
dialog.setLocation(300, 200);
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JComboBox cbFeedbackType;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel lblProxyPort;
private javax.swing.JLabel lblProxyServer;
private javax.swing.JLabel lblProxyType;
private javax.swing.JLabel lblProxyUserName;
private javax.swing.JPanel pnlProxy;
private javax.swing.JButton sendButton;
private javax.swing.JTextField txtEmail;
private javax.swing.JTextArea txtFeedbackMessage;
private javax.swing.JTextField txtIdeaTitle;
// End of variables declaration//GEN-END:variables
private static final FeedbackDialog dialog = new FeedbackDialog(new javax.swing.JFrame(), true);
static {
dialog.setResizable(false);
}
}

View file

@ -1,5 +1,6 @@
package mage.db; package mage.db;
import mage.db.model.Feedback;
import mage.db.model.Log; import mage.db.model.Log;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -19,12 +20,18 @@ public enum EntityManager implements Storage {
private static final String MAGE_JDBC_URL = "jdbc:sqlite:db/mage.db"; private static final String MAGE_JDBC_URL = "jdbc:sqlite:db/mage.db";
private static final String MAGE_JDBC_URL_FEEDBACK_DB = "jdbc:sqlite:db/feedback.db";
private static String QUERY_SAVE_LOG = "insert into logs values (?, ?, ?, ?, ?, ?, ?, ?)"; private static String QUERY_SAVE_LOG = "insert into logs values (?, ?, ?, ?, ?, ?, ?, ?)";
private static String QUERY_GET_ALL_LOGS = "select * from logs"; private static String QUERY_GET_ALL_LOGS = "select * from logs";
private static String QUERY_SAVE_FEEDBACK = "insert into feedbacks values (?, ?, ?, ?, ?, ?, ?, ?)";
private static String QUERY_GET_ALL_FEEDBACKS = "select * from feedbacks";
static { static {
try { try {
init(); init();
initFeedbackDB();
} catch (Exception e) { } catch (Exception e) {
log.fatal(e); log.fatal(e);
e.printStackTrace(); e.printStackTrace();
@ -69,6 +76,10 @@ public enum EntityManager implements Storage {
} }
} }
/**
* Get all logs
* @return
*/
@Override @Override
public List<Log> getAllLogs() { public List<Log> getAllLogs() {
List<Log> logs = new ArrayList<Log>(); List<Log> logs = new ArrayList<Log>();
@ -88,7 +99,6 @@ public enum EntityManager implements Storage {
} }
args.add(arg); args.add(arg);
} }
log.setArguments(args);
logs.add(log); logs.add(log);
} }
rs.close(); rs.close();
@ -106,6 +116,86 @@ public enum EntityManager implements Storage {
return logs; return logs;
} }
/**
* Inserts feedback entry to DB.
*
*
* @param username
* @param title
* @param type
* @param message
* @param email
* @param host
* @param created
* @throws SQLException
*/
public void insertFeedback(String username, String title, String type, String message, String email, String host, java.util.Date created) throws SQLException {
Connection conn = DriverManager.getConnection(MAGE_JDBC_URL_FEEDBACK_DB);
try {
PreparedStatement prep = conn.prepareStatement(QUERY_SAVE_FEEDBACK);
prep.setString(1, username);
prep.setString(2, title);
prep.setString(3, type);
prep.setString(4, message);
prep.setString(5, email);
prep.setString(6, host);
prep.setDate(7, new java.sql.Date(created.getTime()));
prep.setString(8, "new");
prep.execute();
} finally {
try {
if (conn != null) conn.close();
} catch (Exception e) {
// swallow
}
}
}
/**
* Get all feedbacks
* @return
*/
@Override
public List<Feedback> getAllFeedbacks() {
List<Feedback> feedbacks = new ArrayList<Feedback>();
try {
Connection conn = DriverManager.getConnection(MAGE_JDBC_URL_FEEDBACK_DB);
try {
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(QUERY_GET_ALL_FEEDBACKS);
while (rs.next()) {
Feedback feedback = new Feedback();
feedback.setUsername(rs.getString(1));
feedback.setTitle(rs.getString(2));
feedback.setType(rs.getString(3));
feedback.setMessage(rs.getString(4));
feedback.setEmail(rs.getString(5));
feedback.setHost(rs.getString(6));
feedback.setCreatedDate(rs.getDate(7));
feedback.setStatus(rs.getString(8));
feedbacks.add(feedback);
}
rs.close();
} finally {
try {
if (conn != null) conn.close();
} catch (Exception e) {
// swallow
}
}
} catch (SQLException e) {
log.fatal("SQL Exception: ", e);
}
return feedbacks;
}
/** /**
* Inits database. Creates tables if they don't exist. * Inits database. Creates tables if they don't exist.
* *
@ -128,6 +218,22 @@ public enum EntityManager implements Storage {
} }
} }
protected static void initFeedbackDB() throws Exception {
Class.forName("org.sqlite.JDBC");
checkDBFolderExistance();
Connection conn = DriverManager.getConnection(MAGE_JDBC_URL_FEEDBACK_DB);
try {
Statement stat = conn.createStatement();
stat.executeUpdate("create table if not exists feedbacks (username, title, type, message, email, host, created_dt, status);");
} finally {
try {
conn.close();
} catch (Exception e) {
// swallow
}
}
}
/** /**
* Reinits database. Drops all tables and then creates them from scratch. * Reinits database. Drops all tables and then creates them from scratch.
* BE CAREFUL! THIS METHOD WILL DESTROY ALL DATA. * BE CAREFUL! THIS METHOD WILL DESTROY ALL DATA.

View file

@ -1,5 +1,6 @@
package mage.db; package mage.db;
import mage.db.model.Feedback;
import mage.db.model.Log; import mage.db.model.Log;
import java.text.DateFormat; import java.text.DateFormat;
@ -29,5 +30,14 @@ public class EntityManagerTest {
System.out.println("]"); System.out.println("]");
System.out.println(" --------------"); System.out.println(" --------------");
} }
System.out.println("********************************");
List<Feedback> feedbackList = EntityManager.instance.getAllFeedbacks();
System.out.println("feedbacks found: " + feedbackList.size());
for (Feedback feedback : feedbackList) {
System.out.println(feedback.toString());
System.out.println("--------------");
}
} }
} }

View file

@ -1,14 +1,18 @@
package mage.db; package mage.db;
import mage.db.model.Feedback;
import mage.db.model.Log; import mage.db.model.Log;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* * Storage interface for saving and fetching entities.
* @author noxx
*/ */
public interface Storage { public interface Storage {
void insertLog(String key, Date date, String... args) throws Exception; void insertLog(String key, Date date, String... args) throws Exception;
List<Log> getAllLogs(); List<Log> getAllLogs();
void insertFeedback(String username, String title, String type, String message, String email, String host, java.util.Date created) throws Exception;
List<Feedback> getAllFeedbacks();
} }

View file

@ -0,0 +1,102 @@
package mage.db.model;
import java.util.Date;
/**
* Feedback entity.
*
* @author noxx
*/
public class Feedback {
private String username;
private String title;
private String type;
private String message;
private String email;
private String host;
private Date createdDate;
private String status;
public Feedback() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
String msg = message != null && message.length() > 5 ? message.substring(0, 5) : message;
sb.append("Feedback [username=").append(username)
.append(", host=").append(host)
.append(", title=").append(title)
.append(", type=").append(type)
.append(", message=").append(msg)
.append("...]");
return sb.toString();
}
}

View file

@ -125,4 +125,7 @@ public interface MageServer {
// messages of the day // messages of the day
public Object getServerMessagesCompressed(String sessionId) throws MageException; public Object getServerMessagesCompressed(String sessionId) throws MageException;
// feedback
public void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
} }

View file

@ -252,6 +252,18 @@ public class Session {
client.showError("Network error. You have been disconnected"); client.showError("Network error. You have been disconnected");
} }
public synchronized boolean sendFeedback(String title, String type, String message, String email) {
if (isConnected()) {
try {
server.sendFeedbackMessage(sessionId, connection.getUsername(), title, type, message, email);
return true;
} catch (MageException e) {
logger.error(e);
}
}
return false;
}
class CallbackHandler implements InvokerCallbackHandler { class CallbackHandler implements InvokerCallbackHandler {
@Override @Override
public void handleCallback(Callback callback) throws HandleCallbackException { public void handleCallback(Callback callback) throws HandleCallbackException {

View file

@ -42,6 +42,7 @@ import mage.remote.MageVersionException;
import mage.server.draft.DraftManager; import mage.server.draft.DraftManager;
import mage.server.game.*; import mage.server.game.*;
import mage.server.services.LogKeys; import mage.server.services.LogKeys;
import mage.server.services.impl.FeedbackServiceImpl;
import mage.server.services.impl.LogServiceImpl; import mage.server.services.impl.LogServiceImpl;
import mage.server.tournament.TournamentFactory; import mage.server.tournament.TournamentFactory;
import mage.server.tournament.TournamentManager; import mage.server.tournament.TournamentManager;
@ -61,7 +62,7 @@ import java.util.concurrent.ExecutorService;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com, noxx
*/ */
public class MageServerImpl implements MageServer { public class MageServerImpl implements MageServer {
@ -707,6 +708,19 @@ public class MageServerImpl implements MageServer {
}); });
} }
@Override
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
if (title != null && message != null) {
execute("sendFeedbackMessage", sessionId, new Action() {
public void execute() {
String host = SessionManager.getInstance().getSession(sessionId).getHost();
FeedbackServiceImpl.instance.feedback(username, title, type, message, email, host);
LogServiceImpl.instance.log(LogKeys.KEY_FEEDBACK_ADDED, sessionId, username, host);
}
});
}
}
public void sendBroadcastMessage(final String sessionId, final String message) throws MageException { public void sendBroadcastMessage(final String sessionId, final String message) throws MageException {
if (message != null) { if (message != null) {
execute("sendBroadcastMessage", sessionId, new Action() { execute("sendBroadcastMessage", sessionId, new Action() {

View file

@ -0,0 +1,14 @@
package mage.server.services;
/**
* Responsible for gathering feedback from users and storing them in DB.
*
* @author noxx
*/
public interface FeedbackService {
/**
* Saves feedback.
*/
void feedback(String username, String title, String type, String message, String email, String host);
}

View file

@ -28,4 +28,6 @@ public interface LogKeys {
public static final String KEY_WRONG_VERSION = "wrongVersion"; public static final String KEY_WRONG_VERSION = "wrongVersion";
public static final String KEY_NOT_ADMIN = "notAdminRestrictedOperation"; public static final String KEY_NOT_ADMIN = "notAdminRestrictedOperation";
public static final String KEY_FEEDBACK_ADDED = "feedbackAdded";
} }

View file

@ -0,0 +1,26 @@
package mage.server.services.impl;
import mage.db.EntityManager;
import mage.server.services.FeedbackService;
import org.apache.log4j.Logger;
import java.util.Calendar;
/**
* @author noxx
*/
public enum FeedbackServiceImpl implements FeedbackService {
instance;
private static Logger log = Logger.getLogger(FeedbackServiceImpl.class);
@Override
public void feedback(String username, String title, String type, String message, String email, String host) {
Calendar cal = Calendar.getInstance();
try {
EntityManager.instance.insertFeedback(username, title, type, message, email, host, cal.getTime());
} catch (Exception e) {
log.fatal(e);
}
}
}