Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2009-08-14 15:57:56 +0000
committersminto2009-08-14 15:57:56 +0000
commitc0ec4a7abcea953431dedaf0c3fc61ca9903708e (patch)
tree5621562505b52346a1bcbc1c1da07f21989a3125 /org.eclipse.mylyn.monitor.usage
parentfd57289b385cd0b63adbfe91ce8f9925225ee575 (diff)
downloadorg.eclipse.mylyn.incubator-c0ec4a7abcea953431dedaf0c3fc61ca9903708e.tar.gz
org.eclipse.mylyn.incubator-c0ec4a7abcea953431dedaf0c3fc61ca9903708e.tar.xz
org.eclipse.mylyn.incubator-c0ec4a7abcea953431dedaf0c3fc61ca9903708e.zip
NEW - bug 286460: [usage] clean up usage data collection and upload code
https://bugs.eclipse.org/bugs/show_bug.cgi?id=286460
Diffstat (limited to 'org.eclipse.mylyn.monitor.usage')
-rw-r--r--org.eclipse.mylyn.monitor.usage/schema/study.exsd60
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/StudyParameters.java57
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorExtensionPointReader.java172
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorPlugin.java261
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UsageUploadManager.java21
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/preferences/UsageDataPreferencePage.java28
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/GetNewUserIdPage.java31
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageSubmissionWizard.java48
-rw-r--r--org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageUploadWizardPage.java17
9 files changed, 339 insertions, 356 deletions
diff --git a/org.eclipse.mylyn.monitor.usage/schema/study.exsd b/org.eclipse.mylyn.monitor.usage/schema/study.exsd
index 0e4f2031..63cd31d4 100644
--- a/org.eclipse.mylyn.monitor.usage/schema/study.exsd
+++ b/org.eclipse.mylyn.monitor.usage/schema/study.exsd
@@ -1,10 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.mylar.monitor.ui">
+<schema targetNamespace="org.eclipse.mylar.monitor.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appInfo>
+ <appinfo>
<meta.schema plugin="org.eclipse.mylar.monitor.ui" id="study" name="Mylar Monitor Study"/>
- </appInfo>
+ </appinfo>
<documentation>
Provides a mechanism to connect a user study plug-in with the Mylyn Monitors usage monitoring facilities. For more information please see: http://wiki.eclipse.org/index.php/Mylyn_Integrator_Reference#Monitor_API
</documentation>
@@ -36,9 +36,9 @@
<documentation>
</documentation>
- <appInfo>
+ <appinfo>
<meta.attribute translatable="true"/>
- </appInfo>
+ </appinfo>
</annotation>
</attribute>
</complexType>
@@ -67,21 +67,21 @@
</documentation>
</annotation>
</attribute>
- <attribute name="questionnaire" type="string">
+ <attribute name="background" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
- <attribute name="background" type="string">
+ <attribute name="version" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
- <attribute name="version" type="string">
+ <attribute name="forceObfuscation" type="boolean">
<annotation>
<documentation>
@@ -119,9 +119,9 @@
<documentation>
</documentation>
- <appInfo>
+ <appinfo>
<meta.attribute kind="java" basedOn="org.eclipse.mylyn.monitor.usage.AbstractStudyQuestionnairePage:"/>
- </appInfo>
+ </appinfo>
</annotation>
</attribute>
<attribute name="backgroundPage" type="string">
@@ -129,9 +129,9 @@
<documentation>
</documentation>
- <appInfo>
+ <appinfo>
<meta.attribute kind="java"/>
- </appInfo>
+ </appinfo>
</annotation>
</attribute>
<attribute name="consentForm" type="string">
@@ -139,9 +139,9 @@
<documentation>
</documentation>
- <appInfo>
+ <appinfo>
<meta.attribute kind="resource"/>
- </appInfo>
+ </appinfo>
</annotation>
</attribute>
<attribute name="useContactField" type="boolean">
@@ -167,48 +167,24 @@
</element>
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="since"/>
- </appInfo>
+ </appinfo>
<documentation>
1.0
</documentation>
</annotation>
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="examples"/>
- </appInfo>
+ </appinfo>
<documentation>
See the org.eclipse.mylyn.examples.monitor.study plug-in for a reference implementation.
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
</schema>
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/StudyParameters.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/StudyParameters.java
index 43392e02..17c0f377 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/StudyParameters.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/StudyParameters.java
@@ -43,7 +43,9 @@ public class StudyParameters {
private String idServletUrl;
- private String questionaireServletUrl;
+ private String customizingPlugin;
+
+ private boolean forceObfuscation = false;
public String getUploadServletUrl() {
return uploadServletUrl;
@@ -65,16 +67,6 @@ public class StudyParameters {
}
}
- public String getQuestionaireServletUrl() {
- return questionaireServletUrl;
- }
-
- public void setQuestionaireServletUrl(String servletQuestionaire) {
- if (servletQuestionaire != null) {
- this.questionaireServletUrl = servletQuestionaire;
- }
- }
-
public String getFormsConsent() {
return formsConsent;
}
@@ -163,6 +155,37 @@ public class StudyParameters {
}
}
+ public void setCustomizingPlugin(String name) {
+ this.customizingPlugin = name;
+ }
+
+ public String getCustomizingPlugin() {
+ return customizingPlugin;
+ }
+
+ public boolean isBackgroundEnabled() {
+ return backgroundPage != null;
+ }
+
+ public boolean isQuestionnaireEnabled() {
+ return questionnairePage != null;
+ }
+
+ public String getCustomizedByMessage() {
+ String customizedBy = getCustomizingPlugin();
+ String message = "NOTE: You have previously downloaded the Mylyn monitor and a user study plug-in with id: "
+ + customizedBy + "\n" + "If you are not familiar with this plug-in do not upload data.";
+ return message;
+ }
+
+ public boolean usingContactField() {
+ if (getUseContactField().equals("true")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public boolean isComplete() {
return title != null && description != null && uploadServletUrl != null && idServletUrl != null;
}
@@ -171,4 +194,16 @@ public class StudyParameters {
return title == null && description == null && uploadServletUrl == null && idServletUrl == null;
}
+ public boolean forceObfuscation() {
+ return forceObfuscation;
+ }
+
+ public void setForceObfuscation(boolean forceObfuscation) {
+ this.forceObfuscation = forceObfuscation;
+ }
+
+ public String getUploadFileLabel() {
+ return "USAGE";// TODO make this extensible
+ }
+
}
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorExtensionPointReader.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorExtensionPointReader.java
new file mode 100644
index 00000000..028ec14e
--- /dev/null
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorExtensionPointReader.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.monitor.usage;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.monitor.usage.AbstractStudyBackgroundPage;
+import org.eclipse.mylyn.monitor.usage.AbstractStudyQuestionnairePage;
+
+class UiUsageMonitorExtensionPointReader {
+
+ public static final String EXTENSION_ID_STUDY = "org.eclipse.mylyn.monitor.usage.study";
+
+ public static final String ELEMENT_SCRIPTS = "scripts";
+
+ public static final String ELEMENT_SCRIPTS_VERSION = "version";
+
+ public static final String ELEMENT_SCRIPTS_SERVER_URL = "url";
+
+ public static final String ELEMENT_SCRIPTS_UPLOAD_USAGE = "upload";
+
+ public static final String ELEMENT_SCRIPTS_GET_USER_ID = "userId";
+
+ public static final String ELEMENT_SCRIPTS_FORCE_OBFUSCATION = "forceObfuscation";
+
+ public static final String ELEMENT_UI = "ui";
+
+ public static final String ELEMENT_UI_TITLE = "title";
+
+ public static final String ELEMENT_UI_DESCRIPTION = "description";
+
+ public static final String ELEMENT_UI_UPLOAD_PROMPT = "daysBetweenUpload";
+
+ public static final String ELEMENT_UI_QUESTIONNAIRE_PAGE = "questionnairePage";
+
+ public static final String ELEMENT_UI_BACKGROUND_PAGE = "backgroundPage";
+
+ public static final String ELEMENT_UI_CONSENT_FORM = "consentForm";
+
+ public static final String ELEMENT_UI_CONTACT_CONSENT_FIELD = "useContactField";
+
+ public static final String ELEMENT_MONITORS = "monitors";
+
+ public static final String ELEMENT_MONITORS_BROWSER_URL = "browserUrlFilter";
+
+ private boolean extensionsRead = false;
+
+ private StudyParameters studyParameters;
+
+ // private MonitorUsageExtensionPointReader thisReader = new
+ // MonitorUsageExtensionPointReader();
+
+ public synchronized StudyParameters getStudyParameters() {
+ if (!extensionsRead) {
+ initExtensions();
+ }
+ return studyParameters;
+ }
+
+ private void initExtensions() {
+ try {
+ if (!extensionsRead) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_STUDY);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ studyParameters = new StudyParameters();
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (element.getName().compareTo(ELEMENT_SCRIPTS) == 0) {
+ readScripts(element);
+ } else if (element.getName().compareTo(ELEMENT_UI) == 0) {
+ readForms(element);
+ } else if (element.getName().compareTo(ELEMENT_MONITORS) == 0) {
+ readMonitors(element);
+ }
+ }
+ studyParameters.setCustomizingPlugin(extension.getContributor().getName());
+
+ //TODO make this support multiple studies properly
+ // currently we only read the first one
+ break;
+ }
+ extensionsRead = true;
+ }
+ }
+ } catch (Throwable t) {
+ StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
+ "Could not read monitor extension", t));
+ }
+ }
+
+ private void readScripts(IConfigurationElement element) {
+ studyParameters.setVersion(element.getAttribute(ELEMENT_SCRIPTS_VERSION));
+ String serverUrl = element.getAttribute(ELEMENT_SCRIPTS_SERVER_URL);
+ String userIdScript = element.getAttribute(ELEMENT_SCRIPTS_GET_USER_ID);
+ String usageUploadScript = element.getAttribute(ELEMENT_SCRIPTS_UPLOAD_USAGE);
+ String forceObfuscationString = element.getAttribute(ELEMENT_SCRIPTS_FORCE_OBFUSCATION);
+
+ studyParameters.setUploadServletUrl(serverUrl + usageUploadScript);
+ studyParameters.setUserIdServletUrl(serverUrl + userIdScript);
+ studyParameters.setForceObfuscation(Boolean.parseBoolean(forceObfuscationString));
+
+ }
+
+ private void readForms(IConfigurationElement element) throws CoreException {
+ studyParameters.setTitle(element.getAttribute(ELEMENT_UI_TITLE));
+ studyParameters.setDescription(element.getAttribute(ELEMENT_UI_DESCRIPTION));
+ if (element.getAttribute(ELEMENT_UI_UPLOAD_PROMPT) != null) {
+ Integer uploadInt = new Integer(element.getAttribute(ELEMENT_UI_UPLOAD_PROMPT));
+ studyParameters.setTransmitPromptPeriod(UiUsageMonitorPlugin.HOUR * 24 * uploadInt);
+ }
+ studyParameters.setUseContactField(element.getAttribute(ELEMENT_UI_CONTACT_CONSENT_FIELD));
+
+ try {
+ if (element.getAttribute(ELEMENT_UI_QUESTIONNAIRE_PAGE) != null) {
+ Object questionnaireObject = element.createExecutableExtension(ELEMENT_UI_QUESTIONNAIRE_PAGE);
+ if (questionnaireObject instanceof AbstractStudyQuestionnairePage) {
+ AbstractStudyQuestionnairePage page = (AbstractStudyQuestionnairePage) questionnaireObject;
+ studyParameters.setQuestionnairePage(page);
+ }
+ } else {
+ }
+ } catch (Throwable e) {
+ StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN, "Could not load questionaire",
+ e));
+ }
+
+ try {
+ if (element.getAttribute(ELEMENT_UI_BACKGROUND_PAGE) != null) {
+ Object backgroundObject = element.createExecutableExtension(ELEMENT_UI_BACKGROUND_PAGE);
+ if (backgroundObject instanceof AbstractStudyBackgroundPage) {
+ AbstractStudyBackgroundPage page = (AbstractStudyBackgroundPage) backgroundObject;
+ studyParameters.setBackgroundPage(page);
+ }
+ } else {
+ }
+ } catch (Throwable e) {
+ StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
+ "Could not load background page", e));
+ }
+
+ studyParameters.setFormsConsent("/" + element.getAttribute(ELEMENT_UI_CONSENT_FORM));
+
+ }
+
+ private void readMonitors(IConfigurationElement element) throws CoreException {
+ // TODO: This should parse a list of filters but right now it takes
+ // the
+ // entire string as a single filter.
+ // ArrayList<String> urlList = new ArrayList<String>();
+ String urlList = element.getAttribute(ELEMENT_MONITORS_BROWSER_URL);
+ studyParameters.setAcceptedUrlList(urlList);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorPlugin.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorPlugin.java
index e494b090..9609e9db 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorPlugin.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UiUsageMonitorPlugin.java
@@ -20,20 +20,13 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
@@ -52,8 +45,6 @@ import org.eclipse.mylyn.monitor.ui.AbstractCommandMonitor;
import org.eclipse.mylyn.monitor.ui.IActionExecutionListener;
import org.eclipse.mylyn.monitor.ui.IMonitorLifecycleListener;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
-import org.eclipse.mylyn.monitor.usage.AbstractStudyBackgroundPage;
-import org.eclipse.mylyn.monitor.usage.AbstractStudyQuestionnairePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
@@ -72,39 +63,18 @@ import org.osgi.framework.BundleContext;
*/
public class UiUsageMonitorPlugin extends AbstractUIPlugin {
+ // TODO make ids be per-study
public static final String PREF_USER_ID = "org.eclipse.mylyn.user.id";
- public static String VERSION = "1.0";
+ public static final long HOUR = 60 * 60 * 1000;
- public static String UPLOAD_FILE_LABEL = "USAGE";
+ public static final long DAY = HOUR * 24;
- private static final long HOUR = 3600 * 1000;
+ public static final long DELAY_ON_USER_REQUEST = 5 * DAY;
- private static final long DAY = HOUR * 24;
+ public static final long DEFAULT_DELAY_DAYS_BETWEEN_TRANSMITS = 21;
- private static final long DELAY_ON_USER_REQUEST = 5 * DAY;
-
- public static final long DEFAULT_DELAY_BETWEEN_TRANSMITS = 21 * 24 * HOUR;
-
- public static final String DEFAULT_TITLE = "Mylyn Feedback";
-
- public static final String DEFAULT_DESCRIPTION = "Fill out the following form to help us improve Mylyn based on your input.\n";
-
- public static final String DEFAULT_ETHICS_FORM = "doc/study-ethics.html";
-
- public static final String DEFAULT_VERSION = "";
-
- public static final String DEFAULT_UPLOAD_SERVER = "http://mylyn.eclipse.org/monitor/upload";
-
- public static final String DEFAULT_UPLOAD_SERVLET_ID = "/GetUserIDServlet";
-
- public static final String DEFAULT_UPLOAD_SERVLET = "/MylarUsageUploadServlet";
-
- public static final String DEFAULT_ACCEPTED_URL_LIST = "";
-
- public static final String DEFAULT_CONTACT_CONSENT_FIELD = "false";
-
- public static final String ID_UI_PLUGIN = "org.eclipse.mylyn.ui";
+ public static final long DEFAULT_DELAY_BETWEEN_TRANSMITS = DEFAULT_DELAY_DAYS_BETWEEN_TRANSMITS * DAY;
public static final String MONITOR_LOG_NAME = "monitor-log";
@@ -112,8 +82,6 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
private InteractionEventLogger interactionLogger;
- private String customizingPlugin = null;
-
private PreferenceChangeMonitor preferenceMonitor;
private PerspectiveChangeMonitor perspectiveMonitor;
@@ -138,11 +106,7 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
private static boolean performingUpload = false;
- private boolean questionnaireEnabled = true;
-
- private boolean backgroundEnabled = false;
-
- private final StudyParameters studyParameters = new StudyParameters();
+ private StudyParameters studyParameters = new StudyParameters();
private final ListenerList lifecycleListeners = new ListenerList();
@@ -274,21 +238,12 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
public void run() {
try {
// ------- moved from synch start
- new MonitorUsageExtensionPointReader().initExtensions();
+ UiUsageMonitorExtensionPointReader uiUsageMonitorExtensionPointReader = new UiUsageMonitorExtensionPointReader();
+ studyParameters = uiUsageMonitorExtensionPointReader.getStudyParameters();
- if (studyParameters.isEmpty()) {
+ if (studyParameters == null || studyParameters.isEmpty()) {
- studyParameters.setVersion(DEFAULT_VERSION);
- studyParameters.setUploadServletUrl(DEFAULT_UPLOAD_SERVER + DEFAULT_UPLOAD_SERVLET);
- studyParameters.setUserIdServletUrl(DEFAULT_UPLOAD_SERVER + DEFAULT_UPLOAD_SERVLET_ID);
- studyParameters.setQuestionaireServletUrl(null);
-
- studyParameters.setTitle(DEFAULT_TITLE);
- studyParameters.setDescription(DEFAULT_DESCRIPTION);
- studyParameters.setTransmitPromptPeriod(DEFAULT_DELAY_BETWEEN_TRANSMITS);
- studyParameters.setUseContactField(DEFAULT_CONTACT_CONSENT_FIELD);
- studyParameters.setAcceptedUrlList(DEFAULT_ACCEPTED_URL_LIST);
- studyParameters.setFormsConsent("/" + DEFAULT_ETHICS_FORM);
+ initializeDefaultStudyParameters();
}
@@ -327,7 +282,6 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
public void startMonitoring() {
if (studyParameters == null || !studyParameters.isComplete()) {
- System.out.println("here");
return;
}
if (getPreferenceStore().contains(MonitorPreferenceConstants.PREF_MONITORING_STARTED)) {
@@ -389,7 +343,8 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
}
public boolean isObfuscationEnabled() {
- return UiUsageMonitorPlugin.getPrefs().getBoolean(MonitorPreferenceConstants.PREF_MONITORING_OBFUSCATE);
+ return UiUsageMonitorPlugin.getDefault().getPreferenceStore().getBoolean(
+ MonitorPreferenceConstants.PREF_MONITORING_OBFUSCATE);
}
public void stopMonitoring() {
@@ -626,10 +581,6 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
getPreferenceStore().setValue(MonitorPreferenceConstants.PREF_NUM_USER_EVENTS, numEvents);
}
- public static IPreferenceStore getPrefs() {
- return getDefault().getPreferenceStore();
- }
-
public static boolean isPerformingUpload() {
return performingUpload;
}
@@ -642,190 +593,24 @@ public class UiUsageMonitorPlugin extends AbstractUIPlugin {
return interactionLogger;
}
- public boolean isQuestionnaireEnabled() {
- return questionnaireEnabled;
- }
-
- public void setQuestionnaireEnabled(boolean questionnaireEnabled) {
- this.questionnaireEnabled = questionnaireEnabled;
- }
-
- class MonitorUsageExtensionPointReader {
-
- public static final String EXTENSION_ID_STUDY = "org.eclipse.mylyn.monitor.usage.study";
-
- public static final String ELEMENT_SCRIPTS = "scripts";
-
- public static final String ELEMENT_SCRIPTS_VERSION = "version";
-
- public static final String ELEMENT_SCRIPTS_SERVER_URL = "url";
-
- public static final String ELEMENT_SCRIPTS_UPLOAD_USAGE = "upload";
-
- public static final String ELEMENT_SCRIPTS_GET_USER_ID = "userId";
-
- public static final String ELEMENT_SCRIPTS_UPLOAD_QUESTIONNAIRE = "questionnaire";
-
- public static final String ELEMENT_UI = "ui";
-
- public static final String ELEMENT_UI_TITLE = "title";
-
- public static final String ELEMENT_UI_DESCRIPTION = "description";
-
- public static final String ELEMENT_UI_UPLOAD_PROMPT = "daysBetweenUpload";
-
- public static final String ELEMENT_UI_QUESTIONNAIRE_PAGE = "questionnairePage";
-
- public static final String ELEMENT_UI_BACKGROUND_PAGE = "backgroundPage";
-
- public static final String ELEMENT_UI_CONSENT_FORM = "consentForm";
-
- public static final String ELEMENT_UI_CONTACT_CONSENT_FIELD = "useContactField";
-
- public static final String ELEMENT_MONITORS = "monitors";
-
- public static final String ELEMENT_MONITORS_BROWSER_URL = "browserUrlFilter";
-
- private boolean extensionsRead = false;
-
- // private MonitorUsageExtensionPointReader thisReader = new
- // MonitorUsageExtensionPointReader();
-
- public void initExtensions() {
- try {
- if (!extensionsRead) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_STUDY);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- for (IExtension extension : extensions) {
- //TODO make this support multiple studies properly
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (element.getName().compareTo(ELEMENT_SCRIPTS) == 0) {
- readScripts(element);
- } else if (element.getName().compareTo(ELEMENT_UI) == 0) {
- readForms(element);
- } else if (element.getName().compareTo(ELEMENT_MONITORS) == 0) {
- readMonitors(element);
- }
- }
- customizingPlugin = extension.getContributor().getName();
- }
- extensionsRead = true;
- }
- }
- } catch (Throwable t) {
- StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
- "Could not read monitor extension", t));
- }
- }
-
- private void readScripts(IConfigurationElement element) {
- studyParameters.setVersion(element.getAttribute(ELEMENT_SCRIPTS_VERSION));
- String serverUrl = element.getAttribute(ELEMENT_SCRIPTS_SERVER_URL);
- String userIdScript = element.getAttribute(ELEMENT_SCRIPTS_GET_USER_ID);
- String usageUploadScript = element.getAttribute(ELEMENT_SCRIPTS_UPLOAD_USAGE);
- String questionaireUploadScript = element.getAttribute(ELEMENT_SCRIPTS_UPLOAD_QUESTIONNAIRE);
-
- studyParameters.setUploadServletUrl(serverUrl + usageUploadScript);
- studyParameters.setUserIdServletUrl(serverUrl + userIdScript);
- studyParameters.setQuestionaireServletUrl(serverUrl + questionaireUploadScript);
-
- }
-
- private void readForms(IConfigurationElement element) throws CoreException {
- studyParameters.setTitle(element.getAttribute(ELEMENT_UI_TITLE));
- studyParameters.setDescription(element.getAttribute(ELEMENT_UI_DESCRIPTION));
- if (element.getAttribute(ELEMENT_UI_UPLOAD_PROMPT) != null) {
- Integer uploadInt = new Integer(element.getAttribute(ELEMENT_UI_UPLOAD_PROMPT));
- studyParameters.setTransmitPromptPeriod(HOUR * 24 * uploadInt);
- }
- studyParameters.setUseContactField(element.getAttribute(ELEMENT_UI_CONTACT_CONSENT_FIELD));
-
- try {
- if (element.getAttribute(ELEMENT_UI_QUESTIONNAIRE_PAGE) != null) {
- Object questionnaireObject = element.createExecutableExtension(ELEMENT_UI_QUESTIONNAIRE_PAGE);
- if (questionnaireObject instanceof AbstractStudyQuestionnairePage) {
- AbstractStudyQuestionnairePage page = (AbstractStudyQuestionnairePage) questionnaireObject;
- studyParameters.setQuestionnairePage(page);
- }
- } else {
- UiUsageMonitorPlugin.getDefault().setQuestionnaireEnabled(false);
- }
- } catch (Throwable e) {
- StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
- "Could not load questionaire", e));
- UiUsageMonitorPlugin.getDefault().setQuestionnaireEnabled(false);
- }
-
- try {
- if (element.getAttribute(ELEMENT_UI_BACKGROUND_PAGE) != null) {
- Object backgroundObject = element.createExecutableExtension(ELEMENT_UI_BACKGROUND_PAGE);
- if (backgroundObject instanceof AbstractStudyBackgroundPage) {
- AbstractStudyBackgroundPage page = (AbstractStudyBackgroundPage) backgroundObject;
- studyParameters.setBackgroundPage(page);
- UiUsageMonitorPlugin.getDefault().setBackgroundEnabled(true);
- }
- } else {
- UiUsageMonitorPlugin.getDefault().setBackgroundEnabled(false);
- }
- } catch (Throwable e) {
- StatusHandler.log(new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
- "Could not load background page", e));
- UiUsageMonitorPlugin.getDefault().setBackgroundEnabled(false);
- }
-
- studyParameters.setFormsConsent("/" + element.getAttribute(ELEMENT_UI_CONSENT_FORM));
-
- }
-
- private void readMonitors(IConfigurationElement element) throws CoreException {
- // TODO: This should parse a list of filters but right now it takes
- // the
- // entire string as a single filter.
- // ArrayList<String> urlList = new ArrayList<String>();
- String urlList = element.getAttribute(ELEMENT_MONITORS_BROWSER_URL);
- studyParameters.setAcceptedUrlList(urlList);
- }
- }
-
public StudyParameters getStudyParameters() {
return studyParameters;
}
- public String getCustomizingPlugin() {
- return customizingPlugin;
- }
-
public boolean isMonitoringEnabled() {
return getPreferenceStore().getBoolean(MonitorPreferenceConstants.PREF_MONITORING_ENABLED);
}
- public String getCustomizedByMessage() {
- String customizedBy = UiUsageMonitorPlugin.getDefault().getCustomizingPlugin();
- String message = "NOTE: You have previously downloaded the Mylyn monitor and a user study plug-in with id: "
- + customizedBy + "\n" + "If you are not familiar with this plug-in do not upload data.";
- return message;
- }
-
- public boolean isBackgroundEnabled() {
- return backgroundEnabled;
- }
-
- public void setBackgroundEnabled(boolean backgroundEnabled) {
- this.backgroundEnabled = backgroundEnabled;
- }
-
- public String getExtensionVersion() {
- return studyParameters.getVersion();
- }
+ private void initializeDefaultStudyParameters() {
+ studyParameters.setVersion("");
+ studyParameters.setUploadServletUrl("http://mylyn.eclipse.org/monitor/upload/MylarUsageUploadServlet");
+ studyParameters.setUserIdServletUrl("http://mylyn.eclipse.org/monitor/upload/GetUserIDServlet");
- public boolean usingContactField() {
- if (studyParameters.getUseContactField().equals("true")) {
- return true;
- } else {
- return false;
- }
+ studyParameters.setTitle("Mylyn Feedback");
+ studyParameters.setDescription("Fill out the following form to help us improve Mylyn based on your input.\n");
+ studyParameters.setTransmitPromptPeriod(DEFAULT_DELAY_BETWEEN_TRANSMITS);
+ studyParameters.setUseContactField("false");
+ studyParameters.setAcceptedUrlList("");
+ studyParameters.setFormsConsent("/doc/study-ethics.html");
}
}
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UsageUploadManager.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UsageUploadManager.java
index d0e1252b..5ef4b2d6 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UsageUploadManager.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/UsageUploadManager.java
@@ -125,10 +125,10 @@ public class UsageUploadManager {
return false;
}
- public int getExistingUid(String firstName, String lastName, String emailAddress, boolean anonymous,
- IProgressMonitor monitor) {
+ public int getExistingUid(StudyParameters studyParameters, String firstName, String lastName, String emailAddress,
+ boolean anonymous, IProgressMonitor monitor) {
// TODO extract url for servlet
- String url = UiUsageMonitorPlugin.getDefault().getStudyParameters().getUserIdServletUrl();
+ String url = studyParameters.getUserIdServletUrl();
final GetMethod getUidMethod = new GetMethod(url);
try {
@@ -146,7 +146,7 @@ public class UsageUploadManager {
anon = new NameValuePair("anonymous", "false");
}
- if (UiUsageMonitorPlugin.getDefault().usingContactField()) {
+ if (studyParameters.usingContactField()) {
getUidMethod.setQueryString(new NameValuePair[] { first, last, email, job, size, buisness, anon,
contact });
} else {
@@ -219,9 +219,9 @@ public class UsageUploadManager {
return data;
}
- public int getNewUid(IProgressMonitor monitor) {
+ public int getNewUid(StudyParameters studyParameters, IProgressMonitor monitor) {
// TODO extract url for servlet
- String url = UiUsageMonitorPlugin.getDefault().getStudyParameters().getUserIdServletUrl();
+ String url = studyParameters.getUserIdServletUrl();
final PostMethod getUserIdMethod = new PostMethod(url);
try {
getUserIdMethod.addParameter(new NameValuePair("MylarUserID", ""));
@@ -232,7 +232,7 @@ public class UsageUploadManager {
if (status == HttpStatus.SC_ACCEPTED) {
InputStream inputStream = WebUtil.getResponseBodyAsStream(getUserIdMethod, monitor);
- byte[] buffer = new byte[8];
+ byte[] buffer = new byte[SIZE_OF_INT];
int numBytesRead = inputStream.read(buffer);
int uid = new Integer(new String(buffer, 0, numBytesRead)).intValue();
inputStream.close();
@@ -256,9 +256,10 @@ public class UsageUploadManager {
return -1;
}
- public int getNewUid(String firstName, String lastName, String emailAddress, boolean anonymous, String jobFunction,
- String companySize, String companyFunction, boolean contactEmail, IProgressMonitor monitor) {
- return getNewUid(monitor);
+ public int getNewUid(StudyParameters studyParameters, String firstName, String lastName, String emailAddress,
+ boolean anonymous, String jobFunction, String companySize, String companyFunction, boolean contactEmail,
+ IProgressMonitor monitor) {
+ return getNewUid(studyParameters, monitor);
// TODO add back the code for dealing with creasting a user given a name
// // NameValuePair first = new NameValuePair("firstName", firstName);
// // NameValuePair last = new NameValuePair("lastName", lastName);
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/preferences/UsageDataPreferencePage.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/preferences/UsageDataPreferencePage.java
index 5c22bf1a..35f6da9d 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/preferences/UsageDataPreferencePage.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/preferences/UsageDataPreferencePage.java
@@ -16,6 +16,7 @@ import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.mylyn.internal.monitor.usage.InteractionEventObfuscator;
import org.eclipse.mylyn.internal.monitor.usage.MonitorPreferenceConstants;
+import org.eclipse.mylyn.internal.monitor.usage.StudyParameters;
import org.eclipse.mylyn.internal.monitor.usage.UiUsageMonitorPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -58,10 +59,15 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
private Text submissionTime;
+ private final StudyParameters studyParameters;
+
public UsageDataPreferencePage() {
super();
- setPreferenceStore(UiUsageMonitorPlugin.getPrefs());
+ setPreferenceStore(UiUsageMonitorPlugin.getDefault().getPreferenceStore());
setDescription(DESCRIPTION);
+
+ studyParameters = UiUsageMonitorPlugin.getDefault().getStudyParameters();
+
}
@Override
@@ -70,9 +76,9 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
GridLayout layout = new GridLayout(1, false);
container.setLayout(layout);
- if (UiUsageMonitorPlugin.getDefault().getCustomizingPlugin() != null) {
+ if (studyParameters.getCustomizingPlugin() != null) {
Label label = new Label(parent, SWT.NULL);
- label.setText(UiUsageMonitorPlugin.getDefault().getCustomizedByMessage());
+ label.setText(studyParameters.getCustomizedByMessage());
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
}
@@ -135,6 +141,12 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
enableObfuscation.setText("Obfuscate elements using: ");
enableObfuscation.setSelection(getPreferenceStore().getBoolean(
MonitorPreferenceConstants.PREF_MONITORING_OBFUSCATE));
+
+ if (studyParameters.forceObfuscation()) {
+ enableObfuscation.setSelection(true);
+ enableObfuscation.setEnabled(false);
+ }
+
Label obfuscationLablel = new Label(group, SWT.NULL);
obfuscationLablel.setText(InteractionEventObfuscator.ENCRYPTION_ALGORITHM + " message digest one-way hash");
}
@@ -150,7 +162,7 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
uploadUrl = new Text(group, SWT.BORDER);
uploadUrl.setEditable(false);
uploadUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- uploadUrl.setText(UiUsageMonitorPlugin.getDefault().getStudyParameters().getUploadServletUrl());
+ uploadUrl.setText(studyParameters.getUploadServletUrl());
Label events = new Label(group, SWT.NULL);
events.setText(" Events since upload:");
@@ -180,9 +192,9 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
gridData.widthHint = 15;
submissionTime.setLayoutData(gridData);
long submissionFreq = UiUsageMonitorPlugin.DEFAULT_DELAY_BETWEEN_TRANSMITS;
- if (UiUsageMonitorPlugin.getPrefs().contains(MonitorPreferenceConstants.PREF_MONITORING_SUBMIT_FREQUENCY)) {
- submissionFreq = UiUsageMonitorPlugin.getPrefs().getLong(
- MonitorPreferenceConstants.PREF_MONITORING_SUBMIT_FREQUENCY);
+ if (UiUsageMonitorPlugin.getDefault().getPreferenceStore().contains(
+ MonitorPreferenceConstants.PREF_MONITORING_SUBMIT_FREQUENCY)) {
+ submissionFreq = getPreferenceStore().getLong(MonitorPreferenceConstants.PREF_MONITORING_SUBMIT_FREQUENCY);
}
long submissionFreqInDays = submissionFreq / DAYS_IN_MS;
submissionTime.setText("" + submissionFreqInDays);
@@ -231,7 +243,7 @@ public class UsageDataPreferencePage extends PreferencePage implements IWorkbenc
getPreferenceStore().setValue(MonitorPreferenceConstants.PREF_MONITORING_SUBMIT_FREQUENCY, transmitFrequency);
- UiUsageMonitorPlugin.getDefault().getStudyParameters().setTransmitPromptPeriod(transmitFrequency);
+ studyParameters.setTransmitPromptPeriod(transmitFrequency);
return true;
}
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/GetNewUserIdPage.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/GetNewUserIdPage.java
index 0dd50790..4278d263 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/GetNewUserIdPage.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/GetNewUserIdPage.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.monitor.usage.StudyParameters;
import org.eclipse.mylyn.internal.monitor.usage.UiUsageMonitorPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
@@ -88,15 +89,18 @@ public class GetNewUserIdPage extends WizardPage {
private boolean extendedMonitor = false;
- public GetNewUserIdPage(UsageSubmissionWizard wizard, boolean performUpload) {
+ private final StudyParameters studyParameters;
+
+ public GetNewUserIdPage(UsageSubmissionWizard wizard, StudyParameters studyParameters, boolean performUpload) {
super("Statistics Wizard");
+ this.studyParameters = studyParameters;
this.performUpload = performUpload;
setTitle("Get Mylyn Feedback User ID");
setDescription("In order to submit usage feedback you first need to get a User ID.\n");
this.wizard = wizard;
- if (UiUsageMonitorPlugin.getDefault().getCustomizingPlugin() != null) {
+ if (studyParameters.getCustomizingPlugin() != null) {
extendedMonitor = true;
- String customizedTitle = UiUsageMonitorPlugin.getDefault().getStudyParameters().getTitle();
+ String customizedTitle = studyParameters.getTitle();
if (!customizedTitle.equals("")) {
setTitle(customizedTitle + ": Consent Form and User ID");
}
@@ -117,7 +121,7 @@ public class GetNewUserIdPage extends WizardPage {
createInstructionSection(container);
createNamesSection(container);
createJobDetailSection(container);
- if (UiUsageMonitorPlugin.getDefault().usingContactField()) {
+ if (studyParameters.usingContactField()) {
createContactSection(container);
}
createUserIdButtons(container);
@@ -132,7 +136,7 @@ public class GetNewUserIdPage extends WizardPage {
if (extendedMonitor) {
Label label = new Label(parent, SWT.NULL);
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
- label.setText(UiUsageMonitorPlugin.getDefault().getCustomizedByMessage());
+ label.setText(studyParameters.getCustomizedByMessage());
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
@@ -144,8 +148,8 @@ public class GetNewUserIdPage extends WizardPage {
gd.widthHint = 600;
browser.setLayoutData(gd);
- URL url = Platform.getBundle(UiUsageMonitorPlugin.getDefault().getCustomizingPlugin()).getEntry(
- UiUsageMonitorPlugin.getDefault().getStudyParameters().getFormsConsent());
+ URL url = Platform.getBundle(studyParameters.getCustomizingPlugin()).getEntry(
+ studyParameters.getFormsConsent());
try {
URL localURL = Platform.asLocalURL(url);
browser.setUrl(localURL.toString());
@@ -384,9 +388,9 @@ public class GetNewUserIdPage extends WizardPage {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(first,
- last, email, anon, jobFunction, companySize, companyFunction, contactEmail,
- monitor);
+ uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(
+ studyParameters, first, last, email, anon, jobFunction, companySize,
+ companyFunction, contactEmail, monitor);
}
});
} catch (InvocationTargetException e1) {
@@ -434,8 +438,8 @@ public class GetNewUserIdPage extends WizardPage {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getExistingUid(first,
- last, email, anon, monitor);
+ uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getExistingUid(
+ studyParameters, first, last, email, anon, monitor);
}
});
} catch (InvocationTargetException e1) {
@@ -509,7 +513,8 @@ public class GetNewUserIdPage extends WizardPage {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(monitor);
+ uid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(
+ studyParameters, monitor);
}
});
} catch (InvocationTargetException e1) {
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageSubmissionWizard.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageSubmissionWizard.java
index 6807ed11..c3b61aec 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageSubmissionWizard.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageSubmissionWizard.java
@@ -32,6 +32,7 @@ import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.commons.core.ZipFileUtil;
import org.eclipse.mylyn.internal.monitor.usage.InteractionEventLogger;
import org.eclipse.mylyn.internal.monitor.usage.MonitorFileRolloverJob;
+import org.eclipse.mylyn.internal.monitor.usage.StudyParameters;
import org.eclipse.mylyn.internal.monitor.usage.UiUsageMonitorPlugin;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.usage.AbstractStudyBackgroundPage;
@@ -80,14 +81,15 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
private List<String> backupFilesToUpload;
+ private final StudyParameters studyParameters;
+
public UsageSubmissionWizard() {
- super();
- setTitles();
- init(true);
+ this(true);
}
public UsageSubmissionWizard(boolean performUpload) {
super();
+ studyParameters = UiUsageMonitorPlugin.getDefault().getStudyParameters();
setTitles();
init(performUpload);
}
@@ -110,7 +112,8 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
getContainer().run(false, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- newUid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(monitor);
+ newUid[0] = UiUsageMonitorPlugin.getDefault().getUploadManager().getNewUid(studyParameters,
+ monitor);
}
});
} catch (InvocationTargetException e1) {
@@ -122,18 +125,14 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
UiUsageMonitorPlugin.getDefault().getPreferenceStore().setValue(UiUsageMonitorPlugin.PREF_USER_ID, uid);
}
- uploadPage = new UsageUploadWizardPage(this);
+ uploadPage = new UsageUploadWizardPage(this, studyParameters);
fileSelectionPage = new UsageFileSelectionWizardPage("TODO, change this string");
- if (UiUsageMonitorPlugin.getDefault().isBackgroundEnabled()) {
- AbstractStudyBackgroundPage page = UiUsageMonitorPlugin.getDefault()
- .getStudyParameters()
- .getBackgroundPage();
+ if (studyParameters.isBackgroundEnabled()) {
+ AbstractStudyBackgroundPage page = studyParameters.getBackgroundPage();
backgroundPage = page;
}
- if (UiUsageMonitorPlugin.getDefault().isQuestionnaireEnabled() && performUpload) {
- AbstractStudyQuestionnairePage page = UiUsageMonitorPlugin.getDefault()
- .getStudyParameters()
- .getQuestionnairePage();
+ if (studyParameters.isQuestionnaireEnabled() && performUpload) {
+ AbstractStudyQuestionnairePage page = studyParameters.getQuestionnairePage();
questionnairePage = page;
}
super.setForcePreviousAndNextButtons(true);
@@ -150,11 +149,10 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
if (!performUpload) {
return true;
}
- if (UiUsageMonitorPlugin.getDefault().isQuestionnaireEnabled() && performUpload && questionnairePage != null) {
+ if (studyParameters.isQuestionnaireEnabled() && performUpload && questionnairePage != null) {
questionnaireFile = questionnairePage.createFeedbackFile();
}
- if (UiUsageMonitorPlugin.getDefault().isBackgroundEnabled() && performUpload && displayBackgroundPage
- && backgroundPage != null) {
+ if (studyParameters.isBackgroundEnabled() && performUpload && displayBackgroundPage && backgroundPage != null) {
backgroundFile = backgroundPage.createFeedbackFile();
}
@@ -196,9 +194,9 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
}
public void performUpload(IProgressMonitor monitor) {
- String servletUrl = UiUsageMonitorPlugin.getDefault().getStudyParameters().getUploadServletUrl();
+ String servletUrl = studyParameters.getUploadServletUrl();
boolean failed = false;
- if (UiUsageMonitorPlugin.getDefault().isBackgroundEnabled() && performUpload && backgroundFile != null) {
+ if (studyParameters.isBackgroundEnabled() && performUpload && backgroundFile != null) {
failed = !UiUsageMonitorPlugin.getDefault().getUploadManager().uploadFile(servletUrl, backgroundFile, uid,
monitor);
@@ -207,7 +205,7 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
}
}
- if (UiUsageMonitorPlugin.getDefault().isQuestionnaireEnabled() && performUpload && questionnaireFile != null) {
+ if (studyParameters.isQuestionnaireEnabled() && performUpload && questionnaireFile != null) {
failed = !UiUsageMonitorPlugin.getDefault().getUploadManager().uploadFile(servletUrl, questionnaireFile,
uid, monitor);
@@ -270,7 +268,7 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
@Override
public void addPages() {
- if (UiUsageMonitorPlugin.getDefault().isQuestionnaireEnabled() && performUpload && questionnairePage != null) {
+ if (studyParameters.isQuestionnaireEnabled() && performUpload && questionnairePage != null) {
addPage(questionnairePage);
}
if (performUpload) {
@@ -283,7 +281,7 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
}
public void addBackgroundPage() {
- if (UiUsageMonitorPlugin.getDefault().isBackgroundEnabled() && backgroundPage != null) {
+ if (studyParameters.isBackgroundEnabled() && backgroundPage != null) {
addPage(backgroundPage);
displayBackgroundPage = true;
}
@@ -293,16 +291,11 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
return monitorFile.getAbsolutePath();
}
- /** The status from the http request */
- private int status;
-
- /** the response for the http request */
- private String resp;
-
public int getUid() {
return uid;
}
+ // TODO allow this to be customized
private File processMonitorFile(File monitorFile) {
File processedFile = new File("processed-" + UiUsageMonitorPlugin.MONITOR_LOG_NAME + processedFileCount++
+ ".xml");
@@ -312,6 +305,7 @@ public class UsageSubmissionWizard extends Wizard implements INewWizard {
if (eventList.size() > 0) {
for (InteractionEvent event : eventList) {
+
if (event.getOriginId().startsWith(ORG_ECLIPSE_PREFIX)) {
logger.interactionObserved(event);
}
diff --git a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageUploadWizardPage.java b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageUploadWizardPage.java
index 400aab14..bde799e0 100644
--- a/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageUploadWizardPage.java
+++ b/org.eclipse.mylyn.monitor.usage/src/org/eclipse/mylyn/internal/monitor/usage/wizards/UsageUploadWizardPage.java
@@ -14,7 +14,7 @@ package org.eclipse.mylyn.internal.monitor.usage.wizards;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.mylyn.internal.monitor.usage.UiUsageMonitorPlugin;
+import org.eclipse.mylyn.internal.monitor.usage.StudyParameters;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -46,15 +46,18 @@ public class UsageUploadWizardPage extends WizardPage {
private final UsageSubmissionWizard wizard;
+ private final StudyParameters studyParameters;
+
/**
* Constructor
*/
- public UsageUploadWizardPage(UsageSubmissionWizard wizard) {
+ public UsageUploadWizardPage(UsageSubmissionWizard wizard, StudyParameters studyParameters) {
super("Usage Data Submission Wizard");
+ this.studyParameters = studyParameters;
setTitle("Usage Data Submission");
- if (UiUsageMonitorPlugin.getDefault().getCustomizingPlugin() != null) {
- String customizedTitle = UiUsageMonitorPlugin.getDefault().getStudyParameters().getTitle();
+ if (studyParameters.getCustomizingPlugin() != null) {
+ String customizedTitle = studyParameters.getTitle();
if (customizedTitle != null && !customizedTitle.equals("")) {
setTitle(customizedTitle + ": Usage Data Upload");
}
@@ -85,10 +88,10 @@ public class UsageUploadWizardPage extends WizardPage {
topContainerLayout.verticalSpacing = 9;
Label label;
- if (UiUsageMonitorPlugin.getDefault().getCustomizingPlugin() != null) {
+ if (studyParameters.getCustomizingPlugin() != null) {
label = new Label(parent, SWT.NULL);
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
- label.setText(UiUsageMonitorPlugin.getDefault().getCustomizedByMessage());
+ label.setText(studyParameters.getCustomizedByMessage());
}
label = new Label(topContainer, SWT.NULL);
@@ -98,7 +101,7 @@ public class UsageUploadWizardPage extends WizardPage {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
serverAddrText.setLayoutData(gd);
serverAddrText.setEditable(false);
- serverAddrText.setText(UiUsageMonitorPlugin.getDefault().getStudyParameters().getUploadServletUrl());
+ serverAddrText.setText(studyParameters.getUploadServletUrl());
label = new Label(topContainer, SWT.NULL);
label.setText("Usage file location:");

Back to the top