- if (reply == JOptionPane.YES_OPTION)
- {
- jalview.bin.Cache.log.debug("Opening "+qurl);
- jalview.util.BrowserLauncher.openURL(qurl);
- }
- }
- } catch (Exception e) {
- jalview.bin.Cache.log.warn("When trying to access questionnaire URL "+url,e);
+ public void run()
+ {
+ if (url == null)
+ {
+ return;
+ }
+ boolean prompt = false;
+ try
+ {
+ // First - check to see if wee have an old questionnaire/response id pair.
+ String lastq = jalview.bin.Cache.getProperty("QUESTIONNAIRE");
+ if (lastq == null)
+ {
+ prompt = checkresponse(new URL(url
+ + (url.indexOf('?') > -1 ? "&" : "?") + "checkresponse=1"));
+ }
+ else
+ {
+ String qurl = url + (url.indexOf('?') > -1 ? "&" : "?")
+ + "checkresponse=1";
+ // query the server with the old qid/id pair
+ String qqid = lastq.indexOf(':') > -1
+ ? lastq.substring(0, lastq.indexOf(':'))
+ : null;
+ if (qqid != null && qqid != "null" && qqid.length() > 0)
+ {
+ qurl += "&qid=" + qqid;
+ qid = qqid;
+ String qrid = lastq.substring(lastq.indexOf(':') + 1); // retrieve
+ // old rid
+ if (qrid != null && !qrid.equals("null"))
+ {
+ rid = qrid;
+ qurl += "&rid=" + qrid;
+ }
+ }
+ // see if we have already responsed to this questionnaire.
+ prompt = checkresponse(new URL(qurl));
+ }
+ if (qid != null && rid != null)
+ {
+ // Update our local property cache with latest qid and rid
+ jalview.bin.Cache.setProperty("QUESTIONNAIRE", qid + ":" + rid);
+ }
+ if (prompt)
+ {
+ String qurl = url + (url.indexOf('?') > -1 ? "&" : "?") + "qid="
+ + qid + "&rid=" + rid;
+ jalview.bin.Cache.log
+ .info("Prompting user for questionnaire at " + qurl);
+ int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.getString("label.jalview_new_questionnaire"),
+ MessageManager.getString("label.jalview_user_survey"),
+ JvOptionPane.YES_NO_OPTION, JvOptionPane.QUESTION_MESSAGE);
+
+ if (reply == JvOptionPane.YES_OPTION)
+ {
+ jalview.bin.Cache.log.debug("Opening " + qurl);
+ jalview.util.BrowserLauncher.openURL(qurl);