Author: adietish
Date: 2010-10-01 12:25:25 -0400 (Fri, 01 Oct 2010)
New Revision: 25402
Added:
trunk/usage/plugins/org.jboss.tools.usage/META-INF/default-usage-branding.xml
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/IUsageBranding.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBranding.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBrandingMessages.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/messages.properties
Removed:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSConstants.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSUtils.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF
trunk/usage/plugins/org.jboss.tools.usage/build.properties
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBossToolsUsageActivator.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/PreferencesMessages.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencePage.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/messages.properties
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/ReportingMessages.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReport.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportDispatcher.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportEnablementDialog.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/messages.properties
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java
Log:
[JBDS-1338] initial implementation. Default branding supplied by a service in
org.jboss.tools.usage + specific branding by additional (superseeding) service in
com.jboss.jbds.usage.branding
Modified: trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF 2010-10-01 15:47:43 UTC
(rev 25401)
+++ trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF 2010-10-01 16:25:25 UTC
(rev 25402)
@@ -4,7 +4,8 @@
Bundle-SymbolicName: org.jboss.tools.usage;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.jboss.tools.usage.googleanalytics,
+Export-Package: org.jboss.tools.usage.branding,
+ org.jboss.tools.usage.googleanalytics,
org.jboss.tools.usage.googleanalytics.eclipse,
org.jboss.tools.usage.http,
org.jboss.tools.usage.internal;x-friends:="org.jboss.tools.usage.test",
@@ -21,5 +22,6 @@
Bundle-Activator: org.jboss.tools.usage.internal.JBossToolsUsageActivator
Bundle-Vendor: %bundle-vendor
Bundle-ActivationPolicy: lazy
+Service-Component: META-INF/default-usage-branding.xml
Added: trunk/usage/plugins/org.jboss.tools.usage/META-INF/default-usage-branding.xml
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/META-INF/default-usage-branding.xml
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/META-INF/default-usage-branding.xml 2010-10-01
16:25:25 UTC (rev 25402)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true" name="org.jboss.tools.usage.branding">
+ <implementation
class="org.jboss.tools.usage.internal.branding.JBossToolsUsageBranding"/>
+ <service>
+ <provide
interface="org.jboss.tools.usage.branding.IUsageBranding"/>
+ </service>
+ <property name="service.ranking" type="Integer"
value="-1"/>/service>
+</scr:component>
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/META-INF/default-usage-branding.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/usage/plugins/org.jboss.tools.usage/build.properties
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/build.properties 2010-10-01 15:47:43 UTC
(rev 25401)
+++ trunk/usage/plugins/org.jboss.tools.usage/build.properties 2010-10-01 16:25:25 UTC
(rev 25402)
@@ -1,19 +1,12 @@
output.. = bin/
bin.includes = .,\
- OSGI-INF/l10n/bundle.properties,\
- .classpath,\
- .project,\
- .settings/,\
- META-INF/,\
- JBoss Usage Reporter.launch,\
about.html,\
build.properties,\
plugin.xml,\
pom.xml,\
src/,\
- tracker-service.xml,\
- OSGI-INF/propertiesprovider-factory.xml
-src.includes = JBoss Usage Reporter.launch,\
- about.html,\
+ META-INF/,\
+ OSGI-INF/
+src.includes = about.html,\
pom.xml
source.. = src/
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/IUsageBranding.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/IUsageBranding.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/IUsageBranding.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -0,0 +1,22 @@
+package org.jboss.tools.usage.branding;
+
+public interface IUsageBranding {
+
+ public String getPreferencesDescription();
+
+ public String getPreferencesAllowReportingCheckboxLabel();
+
+ public String getStartupAllowReportingTitle();
+
+ public String getStartupAllowReportingCheckboxLabel();
+
+ public String getStartupAllowReportingMessage();
+
+ public String getStartupAllowReportingDetailLink();
+
+ public String getGlobalRemotePropertiesUrl();
+
+ public String getGoogleAnalyticsAccount();
+
+ public String getGoogleAnalyticsReportingHost();
+}
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/branding/IUsageBranding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSConstants.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSConstants.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSConstants.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.internal;
-
-public class JBDSConstants {
- /** the suffix that gets added to message keys when reporting JBDS */
- public static final String JBDS_MESSAGEKEY_SUFFIX = "_JBDS";
-
- /** the JBDS product feature id */
- public static final String JBDS_PRODUCT_ID =
"com.jboss.jbds.product.product";
-}
Deleted:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSUtils.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSUtils.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBDSUtils.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.internal;
-
-import org.eclipse.core.runtime.IProduct;
-import org.eclipse.core.runtime.Platform;
-
-
-public class JBDSUtils {
-
- private static Boolean isJBDS = null;
-
- public static boolean isJBDS() {
- if (isJBDS == null) {
- IProduct product = Platform.getProduct();
- isJBDS = (product != null
- && JBDSConstants.JBDS_PRODUCT_ID.equals(product.getId()));
- }
- return isJBDS;
- }
-}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBossToolsUsageActivator.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBossToolsUsageActivator.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/JBossToolsUsageActivator.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -11,11 +11,13 @@
package org.jboss.tools.usage.internal;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.tools.usage.branding.IUsageBranding;
import org.jboss.tools.usage.googleanalytics.IJBossToolsEclipseEnvironment;
import org.jboss.tools.usage.internal.preferences.UsageReportPreferencesUtils;
import org.jboss.tools.usage.internal.reporting.JBossToolsEclipseEnvironment;
-import org.jboss.tools.usage.internal.reporting.ReportingMessages;
+import org.jboss.tools.usage.util.BundleUtils;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
/**
* @author Andre Dietisheim
@@ -27,7 +29,7 @@
private static JBossToolsUsageActivator plugin;
private IJBossToolsEclipseEnvironment eclipseEnvironment;
-
+
public JBossToolsUsageActivator() {
plugin = this;
}
@@ -41,37 +43,32 @@
public static JBossToolsUsageActivator getDefault() {
return plugin;
}
-
+
public void start(BundleContext context) throws Exception {
super.start(context);
}
public IJBossToolsEclipseEnvironment getJBossToolsEclipseEnvironment() {
- if (eclipseEnvironment == null) {
- eclipseEnvironment = createEclipseEnvironment();
+ try {
+ if (eclipseEnvironment == null) {
+ eclipseEnvironment = createEclipseEnvironment();
+ }
+ return eclipseEnvironment;
+ } catch (Exception e) {
+ return null;
}
- return eclipseEnvironment;
}
- private IJBossToolsEclipseEnvironment createEclipseEnvironment() {
+ private IJBossToolsEclipseEnvironment createEclipseEnvironment() throws
InvalidSyntaxException {
+ IUsageBranding branding =
BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
+ JBossToolsUsageActivator
+ .getDefault().getBundle());
+ if (branding == null) {
+ return null;
+ }
+
return new JBossToolsEclipseEnvironment(
- getGoogleAnalyticsAccount(), getGoogleAnalyticsHostname(),
+ branding.getGoogleAnalyticsAccount(), branding.getGoogleAnalyticsReportingHost(),
UsageReportPreferencesUtils.getPreferences());
}
-
- private String getGoogleAnalyticsAccount() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_GoogleAnalytics_Account_JBDS;
- } else {
- return ReportingMessages.UsageReport_GoogleAnalytics_Account;
- }
- }
-
- private String getGoogleAnalyticsHostname() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_HostName_JBDS;
- } else {
- return ReportingMessages.UsageReport_HostName;
- }
- }
}
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBranding.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBranding.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBranding.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -0,0 +1,42 @@
+package org.jboss.tools.usage.internal.branding;
+
+import org.jboss.tools.usage.branding.IUsageBranding;
+
+public class JBossToolsUsageBranding implements IUsageBranding {
+
+ public String getPreferencesDescription() {
+ return JBossToolsUsageBrandingMessages.UsageReportPreferencePage_Description;
+ }
+
+ public String getPreferencesAllowReportingCheckboxLabel() {
+ return JBossToolsUsageBrandingMessages.UsageReportPreferencePage_AllowReporting;
+ }
+
+ public String getStartupAllowReportingTitle() {
+ return JBossToolsUsageBrandingMessages.UsageReport_DialogTitle;
+ }
+
+ public String getStartupAllowReportingMessage() {
+ return JBossToolsUsageBrandingMessages.UsageReport_DialogMessage;
+ }
+
+ public String getStartupAllowReportingCheckboxLabel() {
+ return JBossToolsUsageBrandingMessages.UsageReport_Checkbox_Text;
+ }
+
+ public String getStartupAllowReportingDetailLink() {
+ return JBossToolsUsageBrandingMessages.UsageReport_ExplanationPage;
+ }
+
+ public String getGlobalRemotePropertiesUrl() {
+ return JBossToolsUsageBrandingMessages.GlobalUsageSettings_RemoteProps_URL;
+ }
+
+ public String getGoogleAnalyticsAccount() {
+ return JBossToolsUsageBrandingMessages.UsageReport_GoogleAnalytics_Account;
+ }
+
+ public String getGoogleAnalyticsReportingHost() {
+ return JBossToolsUsageBrandingMessages.UsageReport_HostName;
+ }
+}
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBranding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBrandingMessages.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBrandingMessages.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBrandingMessages.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.internal.branding;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JBossToolsUsageBrandingMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.usage.internal.branding.messages"; //$NON-NLS-1$
+
+ public static String UsageReportPreferencePage_Description;
+ public static String UsageReportPreferencePage_AllowReporting;
+
+ public static String GlobalUsageSettings_RemoteProps_URL;
+
+// public static String UsageReportPreferencePage_Description_JBDS;
+// public static String UsageReportPreferencePage_AllowReporting_JBDS;
+//
+// public static String GlobalUsageSettings_RemoteProps_URL_JBDS;
+
+ public static String UsageReport_DialogTitle;
+ public static String UsageReport_DialogMessage;
+ public static String UsageReport_GoogleAnalytics_Account;
+ public static String UsageReport_Checkbox_Text;
+ public static String UsageReport_HostName;
+ public static String UsageReport_ExplanationPage;
+
+// public static String UsageReport_DialogTitle_JBDS;
+// public static String UsageReport_DialogMessage_JBDS;
+// public static String UsageReport_GoogleAnalytics_Account_JBDS;
+// public static String UsageReport_Checkbox_Text_JBDS;
+// public static String UsageReport_HostName_JBDS;
+// public static String UsageReport_ExplanationPage_JBDS;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, JBossToolsUsageBrandingMessages.class);
+ }
+
+ private JBossToolsUsageBrandingMessages() {
+ }
+}
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/JBossToolsUsageBrandingMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/messages.properties
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/messages.properties
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/messages.properties 2010-10-01
16:25:25 UTC (rev 25402)
@@ -0,0 +1,25 @@
+UsageReportPreferencePage_Description=Preference page with options for anonymous usage
data reporting.\nUsage data is used for statistical matters only.
+UsageReportPreferencePage_AllowReporting=&Please allow the JBoss Tools team to
receive anonymous usage\n statistics for this Eclipse installation with JBoss Tools.
+UsageReportPreferencePage_Error_Saving=Could not save the preferences.
+
+GlobalUsageSettings_RemoteProps_URL=http://anonsvn.jboss.org/repos/jbosstools/workspace/usage/usage.properties
+
+# this is a hack to get into the code freeze deadline. this stuff will be removed with a
proper implementatino
+UsageReportPreferencePage_Description_JBDS=Preference page with options for anonymous
usage data reporting.\nUsage data is used for statistical matters only.
+UsageReportPreferencePage_AllowReporting_JBDS=&Please allow Red Hat Inc. to receive
anonymous usage\n statistics for this JBoss Developer Studio installation.
+
+GlobalUsageSettings_RemoteProps_URL_JBDS=http://devstudio.jboss.com/usage/usage.properties
+
+UsageReport_DialogMessage=Please allow JBoss Tools team to receive anonymous usage
statistics for this Eclipse instance with JBoss Tools (<a>info</a>).
+UsageReport_Checkbox_Text=Report usage of JBoss Tools to JBoss Tools team.
+UsageReport_GoogleAnalytics_Account=UA-17645367-1
+UsageReport_HostName=jboss.org
+UsageReport_ExplanationPage=http://jboss.org/tools/usage
+
+# this is a hack to get into the code freeze deadline. this stuff will be removed with a
proper implementation
+UsageReport_DialogTitle_JBDS=JBoss Developer Studio Usage
+UsageReport_DialogMessage_JBDS=Please allow Red Hat Inc. to receive anonymous usage
statistics for this JBoss Developer Studio installation (<a>info</a>).
+UsageReport_GoogleAnalytics_Account_JBDS=UA-18653195-2
+UsageReport_Checkbox_Text_JBDS=Report usage of JBoss Developer Studio to Red Hat Inc.
+UsageReport_HostName_JBDS=devstudio.jboss.com
+UsageReport_ExplanationPage_JBDS=http://devstudio.jboss.com/usage
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/branding/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -12,10 +12,15 @@
import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.tools.usage.branding.IUsageBranding;
import org.jboss.tools.usage.http.HttpRemotePropertiesProvider;
import org.jboss.tools.usage.http.IPropertiesProvider;
-import org.jboss.tools.usage.internal.JBDSUtils;
+import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.util.BundleUtils;
+import org.jboss.tools.usage.util.LoggingUtils;
+import org.jboss.tools.usage.util.StatusUtils;
/**
* A class that implements a global reporting enablement setting. The current
@@ -46,18 +51,17 @@
private IPropertiesProvider remoteMap;
public GlobalUsageSettings(Plugin plugin) {
- remoteMap = createRemoteMap(
- getRemotePropsUrl()
- , VALUE_DELIMITER
- , plugin
- , REMOTEPROPS_USAGE_REPORTING_ENABLED_KEY);
- }
-
- private String getRemotePropsUrl() {
- if (JBDSUtils.isJBDS()) {
- return PreferencesMessages.GlobalUsageSettings_RemoteProps_URL_JBDS;
- } else {
- return PreferencesMessages.GlobalUsageSettings_RemoteProps_URL;
+ try {
+ IUsageBranding brandingService =
BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
+ JBossToolsUsageActivator.getDefault().getBundle());
+ remoteMap = createRemoteMap(
+ brandingService.getGlobalRemotePropertiesUrl()
+ , VALUE_DELIMITER
+ , plugin
+ , REMOTEPROPS_USAGE_REPORTING_ENABLED_KEY);
+ } catch (Exception e) {
+ IStatus status = StatusUtils.getErrorStatus(JBossToolsUsageActivator.PLUGIN_ID,
"could not ", e);
+ LoggingUtils.log(status, JBossToolsUsageActivator.getDefault());
}
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/PreferencesMessages.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/PreferencesMessages.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/PreferencesMessages.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -33,16 +33,6 @@
public static String UsageReportPreferencePage_ScreenResolution;
public static String UsageReportPreferencePage_Error_Saving;
- public static String UsageReportPreferencePage_Description;
- public static String UsageReportPreferencePage_AllowReporting;
-
- public static String GlobalUsageSettings_RemoteProps_URL;
-
- public static String UsageReportPreferencePage_Description_JBDS;
- public static String UsageReportPreferencePage_AllowReporting_JBDS;
-
- public static String GlobalUsageSettings_RemoteProps_URL_JBDS;
-
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencePage.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencePage.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencePage.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -17,6 +17,7 @@
import java.util.List;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -29,10 +30,11 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.usage.branding.IUsageBranding;
import org.jboss.tools.usage.googleanalytics.IJBossToolsEclipseEnvironment;
import org.jboss.tools.usage.googleanalytics.eclipse.IEclipseUserAgent;
-import org.jboss.tools.usage.internal.JBDSUtils;
import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.util.BundleUtils;
import org.jboss.tools.usage.util.StatusUtils;
import org.jboss.tools.usage.util.StringUtils;
import org.osgi.service.prefs.BackingStoreException;
@@ -65,46 +67,65 @@
fillLayout.marginWidth = 8;
group.setLayout(fillLayout);
StyledText text = new StyledText(group, SWT.BORDER | SWT.V_SCROLL);
+ text.setEditable(false);
IJBossToolsEclipseEnvironment eclipseEnvironment =
JBossToolsUsageActivator.getDefault()
.getJBossToolsEclipseEnvironment();
- createText(eclipseEnvironment, text);
- text.setEditable(false);
+ if (eclipseEnvironment == null) {
+ text.setText("usage reporting facility is disabled");
+ } else {
+ createText(eclipseEnvironment, text);
+ }
}
private void createText(IJBossToolsEclipseEnvironment eclipseEnvironment, StyledText
text) {
List<StyleRange> styles = new ArrayList<StyleRange>();
StringBuilder builder = new StringBuilder();
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_JBossToolsVersion,
eclipseEnvironment.getJBossToolsVersion(), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_JBossToolsComponents,
eclipseEnvironment.getKeyword(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_JBossToolsVersion,
+ eclipseEnvironment.getJBossToolsVersion(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_JBossToolsComponents,
+ eclipseEnvironment.getKeyword(), builder, styles);
builder.append(StringUtils.getLineSeparator());
IEclipseUserAgent eclipseUserAgent = eclipseEnvironment.getEclipseUserAgent();
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductId,
eclipseUserAgent.getApplicationName(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductId,
+ eclipseUserAgent.getApplicationName(), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductVersion,
eclipseUserAgent.getApplicationVersion(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductVersion,
+ eclipseUserAgent.getApplicationVersion(), builder, styles);
builder.append(StringUtils.getLineSeparator());
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_OperatingSystem,
eclipseUserAgent.getOS(), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_OperatingSystemVersion,
eclipseUserAgent.getOSVersion(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_OperatingSystem,
eclipseUserAgent.getOS(),
+ builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_OperatingSystemVersion,
+ eclipseUserAgent.getOSVersion(), builder, styles);
if (eclipseEnvironment.isLinuxDistro()) {
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_LinuxDistro,
eclipseEnvironment.getUserDefined(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_LinuxDistro,
+ eclipseEnvironment.getUserDefined(), builder, styles);
}
builder.append(StringUtils.getLineSeparator());
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_Locale,
eclipseUserAgent.getBrowserLanguage(), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ScreenColors,
eclipseEnvironment.getScreenColorDepth(), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ScreenResolution,
eclipseEnvironment.getScreenResolution(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_Locale,
eclipseUserAgent.getBrowserLanguage(),
+ builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ScreenColors,
+ eclipseEnvironment.getScreenColorDepth(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ScreenResolution,
+ eclipseEnvironment.getScreenResolution(), builder, styles);
builder.append(StringUtils.getLineSeparator());
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductOwner,
eclipseEnvironment.getHostname(), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_ProductOwner,
+ eclipseEnvironment.getHostname(), builder, styles);
builder.append(StringUtils.getLineSeparator());
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_NumberOfUsageHits,
String.valueOf(eclipseEnvironment.getVisitCount()), builder,
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_NumberOfUsageHits,
+ String.valueOf(eclipseEnvironment.getVisitCount()), builder,
styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_FirstUsageHit,
getFormattedDate(eclipseEnvironment.getFirstVisit()), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_LastUsageHit,
getFormattedDate(eclipseEnvironment.getLastVisit()), builder, styles);
- appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_CurrentUsageHit,
getFormattedDate(eclipseEnvironment.getCurrentVisit()), builder,
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_FirstUsageHit,
+ getFormattedDate(eclipseEnvironment.getFirstVisit()), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_LastUsageHit,
+ getFormattedDate(eclipseEnvironment.getLastVisit()), builder, styles);
+ appendLabeledValue(PreferencesMessages.UsageReportPreferencePage_CurrentUsageHit,
+ getFormattedDate(eclipseEnvironment.getCurrentVisit()), builder,
styles);
text.setText(builder.toString());
@@ -150,31 +171,34 @@
}
public void createFieldEditors() {
- addField(new BooleanFieldEditor(
- IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID
- , getCheckBoxlabel()
- , getFieldEditorParent()));
- }
-
- private String getCheckBoxlabel() {
- if (JBDSUtils.isJBDS()) {
- return PreferencesMessages.UsageReportPreferencePage_AllowReporting_JBDS;
- } else {
- return PreferencesMessages.UsageReportPreferencePage_AllowReporting;
+ IUsageBranding branding;
+ try {
+ branding = BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
JBossToolsUsageActivator
+ .getDefault().getBundle());
+ addField(new BooleanFieldEditor(
+ IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID
+ , branding.getPreferencesAllowReportingCheckboxLabel()
+ , getFieldEditorParent()));
+ } catch (Exception e) {
+ catchBrandingError(e);
}
}
public void init(IWorkbench workbench) {
setPreferenceStore(UsageReportPreferences.createPreferenceStore());
- setDescription(getPageDescription());
+ IUsageBranding branding;
+ try {
+ branding = BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
JBossToolsUsageActivator
+ .getDefault().getBundle());
+ setDescription(branding.getPreferencesDescription());
+ } catch (Exception e) {
+ catchBrandingError(e);
+ }
}
- private String getPageDescription() {
- if (JBDSUtils.isJBDS()) {
- return PreferencesMessages.UsageReportPreferencePage_Description_JBDS;
- } else {
- return PreferencesMessages.UsageReportPreferencePage_Description;
- }
+ private void catchBrandingError(Exception e) {
+ IStatus status = StatusUtils.getErrorStatus(JBossToolsUsageActivator.PLUGIN_ID,
"Could not find branding.", e);
+ ErrorDialog.openError(getShell(), "Branding Error", "Could not display
usage reporting preferences", status);
}
@Override
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/messages.properties
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/messages.properties 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/messages.properties 2010-10-01
16:25:25 UTC (rev 25402)
@@ -14,15 +14,4 @@
UsageReportPreferencePage_ProductVersion=Product version\:
UsageReportPreferencePage_ScreenColors=Screen Colors\:
UsageReportPreferencePage_ScreenResolution=Screen Resolution\:
-
-UsageReportPreferencePage_Description=Preference page with options for anonymous usage
data reporting.\nUsage data is used for statistical matters only.
-UsageReportPreferencePage_AllowReporting=&Please allow the JBoss Tools team to
receive anonymous usage\n statistics for this Eclipse installation with JBoss Tools.
-UsageReportPreferencePage_Error_Saving=Could not save the preferences.
-
-GlobalUsageSettings_RemoteProps_URL=http://anonsvn.jboss.org/repos/jbosstools/workspace/usage/usage.properties
-
-# this is a hack to get into the code freeze deadline. this stuff will be removed with a
proper implementatino
-UsageReportPreferencePage_Description_JBDS=Preference page with options for anonymous
usage data reporting.\nUsage data is used for statistical matters only.
-UsageReportPreferencePage_AllowReporting_JBDS=&Please allow Red Hat Inc. to receive
anonymous usage\n statistics for this JBoss Developer Studio installation.
-
-GlobalUsageSettings_RemoteProps_URL_JBDS=http://devstudio.jboss.com/usage/usage.properties
+UsageReportPreferencePage_Error_Saving=Could not save usage reporting preferences
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/ReportingMessages.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/ReportingMessages.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/ReportingMessages.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -18,22 +18,8 @@
public static String UsageReport_Reporting_Usage;
public static String UsageReport_Querying_Enablement;
public static String UsageReport_Asking_User;
- public static String UsageReport_DialogTitle;
public static String UsageReport_Error_SavePreferences;
- public static String UsageReport_Checkbox_Text;
- public static String UsageReport_DialogMessage;
- public static String UsageReport_GoogleAnalytics_Account;
- public static String UsageReport_HostName;
- public static String UsageReport_ExplanationPage;
-
- public static String UsageReport_DialogTitle_JBDS;
- public static String UsageReport_DialogMessage_JBDS;
- public static String UsageReport_GoogleAnalytics_Account_JBDS;
- public static String UsageReport_Checkbox_Text_JBDS;
- public static String UsageReport_HostName_JBDS;
- public static String UsageReport_ExplanationPage_JBDS;
-
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ReportingMessages.class);
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReport.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReport.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReport.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -34,6 +34,7 @@
import org.jboss.tools.usage.tracker.internal.SuffixFocusPoint;
import org.jboss.tools.usage.tracker.internal.Tracker;
import org.jboss.tools.usage.util.StatusUtils;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -47,7 +48,7 @@
private IJBossToolsEclipseEnvironment eclipseEnvironment;
- public UsageReport() {
+ public UsageReport() throws InvalidSyntaxException {
eclipseEnvironment =
JBossToolsUsageActivator.getDefault().getJBossToolsEclipseEnvironment();
focusPoint = new SuffixFocusPoint("tools",
eclipseEnvironment.getJBossToolsVersion()) //$NON-NLS-1$
.setChild(new FocusPoint("usage") //$NON-NLS-1$
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportDispatcher.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportDispatcher.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportDispatcher.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -10,8 +10,12 @@
******************************************************************************/
package org.jboss.tools.usage.internal.reporting;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IStartup;
+import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.util.LoggingUtils;
+import org.jboss.tools.usage.util.StatusUtils;
/**
* @author Andre Dieitsheim
@@ -22,7 +26,12 @@
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- new UsageReport().report();
+ try {
+ new UsageReport().report();
+ } catch (Exception e) {
+ IStatus status = StatusUtils.getErrorStatus(JBossToolsUsageActivator.PLUGIN_ID,
"could not start usage reporting", e);
+ LoggingUtils.log(status, JBossToolsUsageActivator.getDefault());
+ }
}
});
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportEnablementDialog.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportEnablementDialog.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/UsageReportEnablementDialog.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.usage.internal.reporting;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.window.IShellProvider;
@@ -22,9 +24,12 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
-import org.jboss.tools.usage.internal.JBDSUtils;
+import org.jboss.tools.usage.branding.IUsageBranding;
import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
import org.jboss.tools.usage.util.BrowserUtil;
+import org.jboss.tools.usage.util.BundleUtils;
+import org.jboss.tools.usage.util.StatusUtils;
+import org.osgi.framework.InvalidSyntaxException;
/**
* @author Andre Dietisheim
@@ -50,14 +55,13 @@
protected void configureShell(Shell shell) {
super.configureShell(shell);
- shell.setText(getDialogTitle());
- }
-
- private String getDialogTitle() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_DialogTitle_JBDS;
- } else {
- return ReportingMessages.UsageReport_DialogTitle;
+ try {
+ IUsageBranding branding =
BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
+ JBossToolsUsageActivator
+ .getDefault().getBundle());
+ shell.setText(branding.getStartupAllowReportingTitle());
+ } catch (InvalidSyntaxException e) {
+ catchBrandingError(e);
}
}
@@ -70,63 +74,52 @@
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
+ createUsageReportingWidgets(parent, composite);
+ applyDialogFont(composite);
- // message
- Link link = new Link(composite, SWT.WRAP);
- link.setFont(parent.getFont());
- link.setText(
- getLinkText());
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- BrowserUtil.checkedCreateExternalBrowser(
- getExplanationUrl(),
- JBossToolsUsageActivator.PLUGIN_ID,
- JBossToolsUsageActivator.getDefault().getLog());
- }
- });
- GridDataFactory.fillDefaults()
+ return composite;
+ }
+
+ private void createUsageReportingWidgets(Composite parent, Composite composite) {
+ try {
+ // message
+ Link link = new Link(composite, SWT.WRAP);
+ link.setFont(parent.getFont());
+
+ final IUsageBranding branding =
BundleUtils.getHighestRankedService(IUsageBranding.class.getName(),
+ JBossToolsUsageActivator.getDefault().getBundle());
+ link.setText(branding.getStartupAllowReportingMessage());
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ BrowserUtil.checkedCreateExternalBrowser(
+ branding.getStartupAllowReportingDetailLink(),
+ JBossToolsUsageActivator.PLUGIN_ID,
+ JBossToolsUsageActivator.getDefault().getLog());
+ }
+ });
+ GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.CENTER)
.grab(true, false)
.hint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH, SWT.DEFAULT)
.applyTo(link);
- // checkbox
- checkBox = new Button(composite, SWT.CHECK);
- checkBox.setText(getCheckBoxText());
- GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT,
SWT.CENTER).applyTo(checkBox);
+ // checkbox
+ checkBox = new Button(composite, SWT.CHECK);
+ checkBox.setText(branding.getStartupAllowReportingCheckboxLabel());
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT,
SWT.CENTER).applyTo(checkBox);
+ } catch (Exception e) {
+ catchBrandingError(e);
+ }
+ }
- applyDialogFont(composite);
-
- return composite;
+ private void catchBrandingError(Exception e) {
+ IStatus status = StatusUtils.getErrorStatus(JBossToolsUsageActivator.PLUGIN_ID,
"Could not find branding.", e);
+ ErrorDialog.openError(getShell(), "Branding Error", "Could not ask to
allow usage reporting", status);
+ close();
}
public boolean isReportEnabled() {
return reportEnabled;
}
-
- private String getCheckBoxText() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_Checkbox_Text_JBDS;
- } else {
- return ReportingMessages.UsageReport_Checkbox_Text;
- }
- }
-
- private String getLinkText() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_DialogMessage_JBDS;
- } else {
- return ReportingMessages.UsageReport_DialogMessage;
- }
- }
-
- private String getExplanationUrl() {
- if (JBDSUtils.isJBDS()) {
- return ReportingMessages.UsageReport_ExplanationPage_JBDS;
- } else {
- return ReportingMessages.UsageReport_ExplanationPage;
- }
- }
-
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/messages.properties
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/messages.properties 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/reporting/messages.properties 2010-10-01
16:25:25 UTC (rev 25402)
@@ -1,20 +1,4 @@
UsageReport_Reporting_Usage=Reporting JBoss Developer Studio usage
UsageReport_Querying_Enablement=Querying whether reporting is globally enabled
UsageReport_Asking_User=Asking User to allow reporting
-UsageReport_DialogTitle=JBoss Tools Usage
UsageReport_Error_SavePreferences=Could not save preferences {0}
-
-UsageReport_DialogMessage=Please allow JBoss Tools team to receive anonymous usage
statistics for this Eclipse instance with JBoss Tools (<a>info</a>).
-UsageReport_Checkbox_Text=Report usage of JBoss Tools to JBoss Tools team.
-UsageReport_GoogleAnalytics_Account=UA-17645367-1
-UsageReport_HostName=jboss.org
-UsageReport_ExplanationPage=http://jboss.org/tools/usage
-
-# this is a hack to get into the code freeze deadline. this stuff will be removed with a
proper implementation
-UsageReport_DialogTitle_JBDS=JBoss Developer Studio Usage
-UsageReport_DialogMessage_JBDS=Please allow Red Hat Inc. to receive anonymous usage
statistics for this JBoss Developer Studio installation (<a>info</a>).
-UsageReport_GoogleAnalytics_Account_JBDS=UA-18653195-2
-UsageReport_Checkbox_Text_JBDS=Report usage of JBoss Developer Studio to Red Hat Inc.
-UsageReport_HostName_JBDS=devstudio.jboss.com
-UsageReport_ExplanationPage_JBDS=http://devstudio.jboss.com/usage
-
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java 2010-10-01
15:47:43 UTC (rev 25401)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java 2010-10-01
16:25:25 UTC (rev 25402)
@@ -17,6 +17,10 @@
import org.jboss.tools.usage.util.collectionfilter.CollectionFilterUtils;
import org.jboss.tools.usage.util.collectionfilter.ICollectionFilter;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
/**
* @author Andre Dietisheim
@@ -70,4 +74,42 @@
return pattern.matcher(bundle.getSymbolicName()).matches();
}
}
+
+// @SuppressWarnings("unchecked")
+// public static <T> T getService(String serviceClass, Bundle bundle) {
+// BundleContext bundleContext = bundle.getBundleContext();
+// ServiceReference serviceReference = bundleContext.getServiceReference(serviceClass);
+// if (serviceReference == null) {
+// return null;
+// }
+// return (T) bundleContext.getService(serviceReference);
+// }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getHighestRankedService(String serviceClass, Bundle bundle)
throws InvalidSyntaxException {
+ BundleContext bundleContext = bundle.getBundleContext();
+ ServiceReference[] serviceReferences = bundleContext.getServiceReferences(serviceClass,
null);
+ if (serviceReferences.length != 0) {
+ ServiceReference reference = getHihgestRankedServiceReference(bundleContext,
serviceReferences);
+ if (reference != null) {
+ return (T) bundleContext.getService(reference);
+ }
+ }
+
+ return null;
+ }
+
+ private static ServiceReference getHihgestRankedServiceReference(BundleContext
bundleContext,
+ ServiceReference[] serviceReferences) {
+ Integer highestRanking = Integer.MIN_VALUE;
+ ServiceReference currentReference = null;
+ for (ServiceReference reference : serviceReferences) {
+ Integer ranking = (Integer) reference.getProperty(Constants.SERVICE_RANKING);
+ if (ranking > highestRanking) {
+ currentReference = reference;
+ highestRanking = ranking;
+ }
+ }
+ return currentReference;
+ }
}