summaryrefslogtreecommitdiffstats
path: root/java/com/tigervnc/vncviewer/ServerDialog.java
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2012-09-01 19:24:26 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2012-09-01 19:24:26 +0000
commit4a95c7f69e8b308612c8fde4c748f148cdde6598 (patch)
treeaf0059b3e5b472e4bc139abec033e0ebb6bf11e3 /java/com/tigervnc/vncviewer/ServerDialog.java
parent3b0f2ae380ed9d1ac2e679480cf450329cc8f4e5 (diff)
downloadtigervnc-4a95c7f69e8b308612c8fde4c748f148cdde6598.tar.gz
tigervnc-4a95c7f69e8b308612c8fde4c748f148cdde6598.zip
Forces all dialogs except for the clipboard to be modal. Fixes cases where dialogs are not brought to the front while in fullscreen mode. Corrects a few corner cases where viewer did not exit properly.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4988 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com/tigervnc/vncviewer/ServerDialog.java')
-rw-r--r--java/com/tigervnc/vncviewer/ServerDialog.java69
1 files changed, 35 insertions, 34 deletions
diff --git a/java/com/tigervnc/vncviewer/ServerDialog.java b/java/com/tigervnc/vncviewer/ServerDialog.java
index 3efc5859..976dc7f2 100644
--- a/java/com/tigervnc/vncviewer/ServerDialog.java
+++ b/java/com/tigervnc/vncviewer/ServerDialog.java
@@ -47,7 +47,7 @@ class ServerDialog extends Dialog implements
if (cc.viewer.nViewers == 1) {
cc.viewer.exit(1);
} else {
- ok = false;
+ ret = false;
endDialog();
}
}
@@ -117,21 +117,18 @@ class ServerDialog extends Dialog implements
}
public void itemStateChanged(ItemEvent e) {
- //Object s = e.getSource();
+ return;
}
public void actionPerformed(ActionEvent e) {
Object s = e.getSource();
if (s instanceof JButton && (JButton)s == okButton) {
- ok = true;
- String serverName = (String)server.getSelectedItem();
- if (serverName != null) {
- Configuration.setParam("Server", Hostname.getHost(serverName));
- Configuration.setParam("Port", Integer.toString(Hostname.getPort(serverName)));
- }
+ commit();
endDialog();
} else if (s instanceof JButton && (JButton)s == cancelButton) {
- ok = false;
+ if (cc.viewer.nViewers == 1)
+ cc.viewer.exit(1);
+ ret = false;
endDialog();
} else if (s instanceof JButton && (JButton)s == optionsButton) {
options.showDialog(this);
@@ -141,38 +138,42 @@ class ServerDialog extends Dialog implements
if (e.getActionCommand().equals("comboBoxEdited")) {
server.insertItemAt(editor.getItem(), 0);
server.setSelectedIndex(0);
- ok = true;
+ commit();
endDialog();
}
}
}
-
- public void endDialog() {
- if (ok) {
- if (!server.getSelectedItem().toString().equals("")) {
- String valueStr = UserPreferences.get("ServerDialog", "history");
- String t = (valueStr == null) ? "" : valueStr;
- StringTokenizer st = new StringTokenizer(t, ",");
- StringBuffer sb = new StringBuffer().append((String)server.getSelectedItem());
- while (st.hasMoreTokens()) {
- String s = st.nextToken();
- if (!s.equals((String)server.getSelectedItem()) && !s.equals("")) {
- sb.append(',');
- sb.append(s);
- }
- }
- UserPreferences.set("ServerDialog", "history", sb.toString());
- UserPreferences.save("ServerDialog");
- }
- }
- done = true;
- if (modal) {
- synchronized (this) {
- notify();
+ private void commit() {
+ String serverName = (String)server.getSelectedItem();
+ if (serverName == null || serverName.equals("")) {
+ vlog.error("Invalid servername specified");
+ if (cc.viewer.nViewers == 1)
+ cc.viewer.exit(1);
+ ret = false;
+ endDialog();
+ }
+ // set params
+ Configuration.setParam("Server", Hostname.getHost(serverName));
+ Configuration.setParam("Port", Integer.toString(Hostname.getPort(serverName)));
+ // Update the history list
+ String valueStr = UserPreferences.get("ServerDialog", "history");
+ String t = (valueStr == null) ? "" : valueStr;
+ StringTokenizer st = new StringTokenizer(t, ",");
+ StringBuffer sb = new StringBuffer().append((String)server.getSelectedItem());
+ while (st.hasMoreTokens()) {
+ String str = st.nextToken();
+ if (!str.equals((String)server.getSelectedItem()) && !str.equals("")) {
+ sb.append(',');
+ sb.append(str);
}
}
- this.dispose();
+ UserPreferences.set("ServerDialog", "history", sb.toString());
+ UserPreferences.save("ServerDialog");
+ }
+
+ public void endDialog() {
+ super.endDialog();
}
CConn cc;