mirror of
https://github.com/correl/mage.git
synced 2025-04-12 09:11:05 -09:00
added client proxy settings + other fixes
This commit is contained in:
parent
ddeb0de911
commit
1fef6e6bb4
7 changed files with 263 additions and 60 deletions
Mage.Client/src/main/java/mage/client
|
@ -464,15 +464,22 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
return session.connect(userName, serverName, port);
|
||||
}
|
||||
|
||||
public static boolean connect(String userName, String serverName, int port, String proxyServer, int proxyPort) {
|
||||
return session.connect(userName, serverName, port, proxyServer, proxyPort);
|
||||
}
|
||||
|
||||
public boolean autoConnect() {
|
||||
boolean autoConnect = Boolean.parseBoolean(prefs.get("autoConnect", "false"));
|
||||
if (autoConnect) {
|
||||
String userName = prefs.get("userName", "");
|
||||
String server = prefs.get("serverAddress", "");
|
||||
int port = Integer.parseInt(prefs.get("serverPort", ""));
|
||||
String proxyServer = prefs.get("proxyAddress", "");
|
||||
int proxyPort = Integer.parseInt(prefs.get("proxyPort", ""));
|
||||
boolean useProxy = Boolean.parseBoolean(prefs.get("useProxy", "false"));
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (MageFrame.connect(userName, server, port)) {
|
||||
if (MageFrame.connect(userName, server, port, useProxy?proxyServer:"", useProxy?proxyPort:0)) {
|
||||
return true;
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(rootPane, "Unable to connect to server");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
|
@ -25,62 +25,72 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="btnConnect" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="lblPort" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblServer" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="btnConnect" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="lblPort" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblServer" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="txtPort" min="-2" pref="71" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="131" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtServer" pref="260" max="32767" attributes="0"/>
|
||||
<Component id="txtUserName" alignment="0" pref="260" max="32767" attributes="0"/>
|
||||
<Component id="chkAutoConnect" alignment="0" pref="260" max="32767" attributes="0"/>
|
||||
<Component id="chkUseProxy" alignment="0" pref="260" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="txtPort" min="-2" pref="71" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="131" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtServer" pref="245" max="32767" attributes="0"/>
|
||||
<Component id="txtUserName" alignment="0" pref="245" max="32767" attributes="0"/>
|
||||
<Component id="chkAutoConnect" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="pnlProxy" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" 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"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lblServer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtServer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="txtPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtUserName" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkAutoConnect" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkUseProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pnlProxy" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnConnect" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -143,5 +153,75 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkAutoConnectActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkUseProxy">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Use Proxy"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkUseProxyActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="pnlProxy">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="lblProxyPort" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblProxyServer" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtProxyPort" min="-2" pref="71" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyServer" alignment="0" pref="260" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</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="txtProxyServer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lblProxyPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="lblProxyServer">
|
||||
<Properties>
|
||||
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
||||
<ComponentRef name="txtServer"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Server:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyServer">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblProxyPort">
|
||||
<Properties>
|
||||
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
||||
<ComponentRef name="txtPort"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Port:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyPort">
|
||||
<Events>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtProxyPortkeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
|
|
@ -59,11 +59,37 @@ public class ConnectDialog extends MageDialog {
|
|||
this.txtPort.setText(MageFrame.getPreferences().get("serverPort", Integer.toString(Config.port)));
|
||||
this.txtUserName.setText(MageFrame.getPreferences().get("userName", ""));
|
||||
this.chkAutoConnect.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get("autoConnect", "false")));
|
||||
this.txtProxyServer.setText(MageFrame.getPreferences().get("proxyAddress", Config.serverName));
|
||||
this.txtProxyPort.setText(MageFrame.getPreferences().get("proxyPort", Integer.toString(Config.port)));
|
||||
this.chkUseProxy.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get("useProxy", "false")));
|
||||
this.showProxySettings();
|
||||
this.setModal(true);
|
||||
this.setLocation(50, 50);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private void showProxySettings() {
|
||||
if (chkUseProxy.isSelected()) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
}
|
||||
else {
|
||||
this.pnlProxy.setVisible(false);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
MageFrame.getPreferences().put("serverAddress", txtServer.getText());
|
||||
MageFrame.getPreferences().put("serverPort", txtPort.getText());
|
||||
MageFrame.getPreferences().put("userName", txtUserName.getText());
|
||||
MageFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
|
||||
MageFrame.getPreferences().put("proxyAddress", txtProxyServer.getText());
|
||||
MageFrame.getPreferences().put("proxyPort", txtProxyPort.getText());
|
||||
MageFrame.getPreferences().put("useProxy", Boolean.toString(chkUseProxy.isSelected()));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
@ -82,6 +108,12 @@ public class ConnectDialog extends MageDialog {
|
|||
btnConnect = new javax.swing.JButton();
|
||||
btnCancel = new javax.swing.JButton();
|
||||
chkAutoConnect = new javax.swing.JCheckBox();
|
||||
chkUseProxy = new javax.swing.JCheckBox();
|
||||
pnlProxy = new javax.swing.JPanel();
|
||||
lblProxyServer = new javax.swing.JLabel();
|
||||
txtProxyServer = new javax.swing.JTextField();
|
||||
lblProxyPort = new javax.swing.JLabel();
|
||||
txtProxyPort = new javax.swing.JTextField();
|
||||
|
||||
setTitle("Connect");
|
||||
setNormalBounds(new java.awt.Rectangle(100, 100, 410, 307));
|
||||
|
@ -122,31 +154,81 @@ public class ConnectDialog extends MageDialog {
|
|||
}
|
||||
});
|
||||
|
||||
chkUseProxy.setText("Use Proxy");
|
||||
chkUseProxy.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
chkUseProxyActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
lblProxyServer.setLabelFor(txtServer);
|
||||
lblProxyServer.setText("Server:");
|
||||
|
||||
lblProxyPort.setLabelFor(txtPort);
|
||||
lblProxyPort.setText("Port:");
|
||||
|
||||
txtProxyPort.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyTyped(java.awt.event.KeyEvent evt) {
|
||||
txtProxyPortkeyTyped(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout pnlProxyLayout = new javax.swing.GroupLayout(pnlProxy);
|
||||
pnlProxy.setLayout(pnlProxyLayout);
|
||||
pnlProxyLayout.setHorizontalGroup(
|
||||
pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlProxyLayout.createSequentialGroup()
|
||||
.addGap(30, 30, 30)
|
||||
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblProxyPort)
|
||||
.addComponent(lblProxyServer))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtProxyServer, javax.swing.GroupLayout.DEFAULT_SIZE, 260, 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(txtProxyServer, 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(lblProxyPort)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnConnect)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblUserName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(131, 131, 131))
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
|
||||
.addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addContainerGap())
|
||||
.addComponent(btnConnect)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblUserName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(131, 131, 131))
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
|
||||
.addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
|
||||
.addComponent(chkUseProxy, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))))
|
||||
.addContainerGap())
|
||||
.addComponent(pnlProxy, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -165,7 +247,11 @@ public class ConnectDialog extends MageDialog {
|
|||
.addComponent(lblUserName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkAutoConnect)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkUseProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(pnlProxy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCancel)
|
||||
.addComponent(btnConnect))
|
||||
|
@ -201,12 +287,17 @@ public class ConnectDialog extends MageDialog {
|
|||
}
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (MageFrame.connect(txtUserName.getText(), txtServer.getText(), Integer.valueOf(txtPort.getText()))) {
|
||||
MageFrame.getPreferences().put("serverAddress", txtServer.getText());
|
||||
MageFrame.getPreferences().put("serverPort", txtPort.getText());
|
||||
MageFrame.getPreferences().put("userName", txtUserName.getText());
|
||||
MageFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
|
||||
this.setVisible(false);
|
||||
if (chkUseProxy.isSelected()) {
|
||||
if (MageFrame.connect(txtUserName.getText(), txtServer.getText(), Integer.valueOf(txtPort.getText()), txtProxyServer.getText(), Integer.valueOf(txtProxyPort.getText()))) {
|
||||
this.saveSettings();
|
||||
this.setVisible(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (MageFrame.connect(txtUserName.getText(), txtServer.getText(), Integer.valueOf(txtPort.getText()))) {
|
||||
this.saveSettings();
|
||||
this.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -226,15 +317,29 @@ public class ConnectDialog extends MageDialog {
|
|||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_chkAutoConnectActionPerformed
|
||||
|
||||
private void txtProxyPortkeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtProxyPortkeyTyped
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtProxyPortkeyTyped
|
||||
|
||||
private void chkUseProxyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkUseProxyActionPerformed
|
||||
this.showProxySettings();
|
||||
}//GEN-LAST:event_chkUseProxyActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JButton btnConnect;
|
||||
private javax.swing.JCheckBox chkAutoConnect;
|
||||
private javax.swing.JCheckBox chkUseProxy;
|
||||
private javax.swing.JLabel lblPort;
|
||||
private javax.swing.JLabel lblProxyPort;
|
||||
private javax.swing.JLabel lblProxyServer;
|
||||
private javax.swing.JLabel lblServer;
|
||||
private javax.swing.JLabel lblUserName;
|
||||
private javax.swing.JPanel pnlProxy;
|
||||
private javax.swing.JTextField txtPort;
|
||||
private javax.swing.JTextField txtProxyPort;
|
||||
private javax.swing.JTextField txtProxyServer;
|
||||
private javax.swing.JTextField txtServer;
|
||||
private javax.swing.JTextField txtUserName;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
|
|
@ -65,6 +65,7 @@ public class JoinTableDialog extends MageDialog {
|
|||
public void showDialog(UUID roomId, UUID tableId) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
|
||||
this.setModal(true);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
|
|
|
@ -60,15 +60,13 @@ public class Client implements CallbackClient {
|
|||
private final static Logger logger = Logger.getLogger(Client.class);
|
||||
|
||||
private UUID clientId;
|
||||
private String userName;
|
||||
private MageFrame frame;
|
||||
private Session session;
|
||||
private int messageId = 0;
|
||||
|
||||
public Client(Session session, MageFrame frame, String userName) {
|
||||
public Client(Session session, MageFrame frame) {
|
||||
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.userName = userName;
|
||||
this.frame = frame;
|
||||
this.session = session;
|
||||
|
||||
|
|
|
@ -86,17 +86,29 @@ public class Session {
|
|||
public Session(MageFrame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
public boolean connect(String userName, String serverName, int port) {
|
||||
return connect(userName, serverName, port, "", 0);
|
||||
}
|
||||
|
||||
public boolean connect(String userName, String serverName, int port, String proxyServer, int proxyPort) {
|
||||
if (isConnected()) {
|
||||
disconnect();
|
||||
}
|
||||
try {
|
||||
System.setSecurityManager(null);
|
||||
if (proxyServer.length() > 0) {
|
||||
System.setProperty("socksProxyHost", proxyServer);
|
||||
System.setProperty("socksProxyPort", Integer.toString(proxyPort));
|
||||
}
|
||||
else {
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksProxyPort");
|
||||
}
|
||||
Registry reg = LocateRegistry.getRegistry(serverName, port);
|
||||
this.server = (Server) reg.lookup(Config.remoteServer);
|
||||
this.userName = userName;
|
||||
this.client = new Client(this, frame, userName);
|
||||
if (client == null)
|
||||
client = new Client(this, frame);
|
||||
sessionId = server.registerClient(userName, client.getId(), frame.getVersion());
|
||||
callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
|
||||
serverState = server.getServerState();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
if (Config.defaultComputerName != null) this.txtPlayerName.setText(Config.defaultComputerName);
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
public void setPlayerName(String playerName) {
|
||||
this.txtPlayerName.setText(playerName);
|
||||
this.txtPlayerName.setEditable(false);
|
||||
this.txtPlayerName.setEnabled(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue