Added support for remote logging of editor usage.
diff --git a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
index 7794d75..7b696f1 100644
--- a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
@@ -26,6 +26,7 @@
Export-Package: com.google.eclipse.protobuf.ui.contentassist,
com.google.eclipse.protobuf.ui.contentassist.antlr,
com.google.eclipse.protobuf.ui.editor,
+ com.google.eclipse.protobuf.ui.editor.logging,
com.google.eclipse.protobuf.ui.plugin,
com.google.eclipse.protobuf.ui.preferences,
com.google.eclipse.protobuf.ui.preferences.compiler,
diff --git a/com.google.eclipse.protobuf.ui/plugin.xml b/com.google.eclipse.protobuf.ui/plugin.xml
index 8edb1b1..7b7c4da 100644
--- a/com.google.eclipse.protobuf.ui/plugin.xml
+++ b/com.google.eclipse.protobuf.ui/plugin.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
+ <extension-point id="remoteLogging" name="Remote Logging" schema="schema/remoteLogging.exsd"/>
<extension point="org.eclipse.ui.editors">
<editor class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" default="true" icon="icons/pb.gif"
@@ -256,4 +257,4 @@
<newWizardShortcut id="com.google.eclipse.protobuf.ui.wizards.NewProtoFileWizard" />
</perspectiveExtension>
</extension>
-</plugin>
\ No newline at end of file
+</plugin>
diff --git a/com.google.eclipse.protobuf.ui/schema/remoteLogging.exsd b/com.google.eclipse.protobuf.ui/schema/remoteLogging.exsd
new file mode 100644
index 0000000..7f16700
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/schema/remoteLogging.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.google.eclipse.protobuf.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="com.google.eclipse.protobuf.ui" id="remoteLoggin" name="Remote Logging"/>
+ </appInfo>
+ <documentation>
+ Provides support for remote logging.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="editorUsage">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":com.google.eclipse.protobuf.ui.editor.logging.EditorUsageLogger"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 1.2.7
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2012 Google, Inc.
+
+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:
+Google, Inc. - initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/EditorUsageLogger.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/EditorUsageLogger.java
new file mode 100644
index 0000000..e6fd701
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/EditorUsageLogger.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * 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
+ */
+package com.google.eclipse.protobuf.ui.editor.logging;
+
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * Logs usage of the Protocol Buffer editor.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public interface EditorUsageLogger {
+ void logDocumentCreation(IEditorInput editorInput);
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/RemoteLogger.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/RemoteLogger.java
new file mode 100644
index 0000000..999bb4d
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/logging/RemoteLogger.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * 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
+ */
+package com.google.eclipse.protobuf.ui.editor.logging;
+
+import static java.util.logging.Level.SEVERE;
+
+import com.google.inject.*;
+
+import org.eclipse.core.runtime.*;
+
+import java.util.logging.Logger;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@Singleton public class RemoteLogger {
+ private static final String EXTENSION_ID = "com.google.eclipse.protobuf.ui.remoteLogging";
+
+ private static Logger logger = Logger.getLogger(RemoteLogger.class.getCanonicalName());
+
+ @Inject private IExtensionRegistry registry;
+
+ private boolean initialized;
+ private EditorUsageLogger editorUsageLogger;
+
+ private final Object lock = new Object();
+
+ public EditorUsageLogger editorUsage() {
+ synchronized (lock) {
+ if (!initialized) {
+ initialize();
+ }
+ return editorUsageLogger;
+ }
+ }
+
+ private void initialize() {
+ initialized = true;
+ IConfigurationElement[] config = registry.getConfigurationElementsFor(EXTENSION_ID);
+ if (config == null) {
+ return;
+ }
+ for (IConfigurationElement e : config) {
+ if ("editorUsage".equals(e.getName()) && editorUsageLogger == null) {
+ try {
+ editorUsageLogger = (EditorUsageLogger) e.createExecutableExtension("class");
+ } catch (CoreException error) {
+ logger.log(SEVERE, "Unable to create 'editorUsage' instance", error);
+ }
+ }
+ }
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
index 5c53b9f..e32e226 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
@@ -16,7 +16,10 @@
import static org.eclipse.core.filebuffers.LocationKind.*;
import static org.eclipse.text.undo.DocumentUndoManagerRegistry.getDocumentUndoManager;
-import java.util.List;
+import com.google.eclipse.protobuf.ui.editor.logging.*;
+import com.google.eclipse.protobuf.ui.preferences.editor.save.SaveActionsPreferences;
+import com.google.eclipse.protobuf.ui.util.editor.ChangedLineRegionCalculator;
+import com.google.inject.*;
import org.eclipse.core.filebuffers.*;
import org.eclipse.core.runtime.*;
@@ -27,9 +30,7 @@
import org.eclipse.ui.*;
import org.eclipse.xtext.ui.editor.model.*;
-import com.google.eclipse.protobuf.ui.preferences.editor.save.SaveActionsPreferences;
-import com.google.eclipse.protobuf.ui.util.editor.ChangedLineRegionCalculator;
-import com.google.inject.*;
+import java.util.List;
/**
* @author alruiz@google.com (Alex Ruiz)
@@ -39,6 +40,7 @@
@Inject private ChangedLineRegionCalculator calculator;
@Inject private Provider<SaveActionsPreferences> preferencesProvider;
+ @Inject private RemoteLogger logger;
@Inject private SaveActions saveActions;
private final List<DocumentContentsFactory> documentFactories;
@@ -48,12 +50,22 @@
}
@Override protected ElementInfo createElementInfo(Object element) throws CoreException {
+ logEditorUsage(element);
if (findDocumentFactory(element) != null) {
return createElementInfo((IEditorInput) element);
}
return super.createElementInfo(element);
}
+ private void logEditorUsage(Object element) {
+ EditorUsageLogger editorUsageLogger = logger.editorUsage();
+ IEditorInput editorInput = null;
+ if (element instanceof IEditorInput) {
+ editorInput = (IEditorInput) element;
+ }
+ editorUsageLogger.logDocumentCreation(editorInput);
+ }
+
private ElementInfo createElementInfo(IEditorInput input) throws CoreException {
IDocument document = null;
IStatus status = null;