Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-17 12:40:53 -0500
committerUwe Stieber2011-12-17 12:40:53 -0500
commit5b5dcf236034b834b3772f3b3bc9145a54c8d2b4 (patch)
treee1dbc0e07a8c7d73b3a77bdb3084ce7abcaf7bd1
parent7160dea98dd3515cbd8002965e721e028fa2e236 (diff)
downloadorg.eclipse.tcf-5b5dcf236034b834b3772f3b3bc9145a54c8d2b4.tar.gz
org.eclipse.tcf-5b5dcf236034b834b3772f3b3bc9145a54c8d2b4.tar.xz
org.eclipse.tcf-5b5dcf236034b834b3772f3b3bc9145a54c8d2b4.zip
Target Explorer: Add TCF logging preference page
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/interfaces/IPreferenceKeys.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/PreferencesInitializer.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/preferences/LoggingPreferencePage.java251
12 files changed, 342 insertions, 36 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
index ec97a63bf..340226d45 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/activator/CoreBundleActivator.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.tcf.log.core.activator;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
import org.osgi.framework.BundleContext;
@@ -19,6 +20,8 @@ import org.osgi.framework.BundleContext;
public class CoreBundleActivator extends Plugin {
// The shared instance
private static CoreBundleActivator plugin;
+ // The scoped preferences instance
+ private static ScopedEclipsePreferences scopedPreferences = null;
// The trace handler instance
private static TraceHandler traceHandler;
@@ -42,6 +45,16 @@ public class CoreBundleActivator extends Plugin {
}
/**
+ * Return the scoped preferences for this plugin.
+ */
+ public static ScopedEclipsePreferences getScopedPreferences() {
+ if (scopedPreferences == null) {
+ scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
+ }
+ return scopedPreferences;
+ }
+
+ /**
* Returns the bundles trace handler.
*
* @return The bundles trace handler.
@@ -68,6 +81,8 @@ public class CoreBundleActivator extends Plugin {
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
+ scopedPreferences = null;
+ traceHandler = null;
super.stop(context);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/interfaces/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/interfaces/IPreferenceKeys.java
index 0490269cb..d478f8edc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/interfaces/IPreferenceKeys.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/interfaces/IPreferenceKeys.java
@@ -25,6 +25,12 @@ public interface IPreferenceKeys {
public final String PREF_LOGGING_ENABLED = PREFIX + "enabled"; //$NON-NLS-1$
/**
+ * If set to <code>true</code>, the logger will send events to the monitor
+ * to allow following the back-end communication within the UI.
+ */
+ public final String PREF_MONITOR_ENABLED = PREFIX + "monitor.enabled"; //$NON-NLS-1$
+
+ /**
* If set to <code>true</code>, locator heart beat events are logged.
*/
public final String PREF_SHOW_HEARTBEATS = PREFIX + "show.heartbeats"; //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
index 810da446e..9c475542e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
@@ -19,19 +19,18 @@ import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.interfaces.listeners.IChannelStateChangeListener;
+import org.eclipse.tcf.te.tcf.core.interfaces.listeners.IProtocolStateChangeListener;
import org.eclipse.tcf.te.tcf.log.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.log.core.interfaces.IPreferenceKeys;
import org.eclipse.tcf.te.tcf.log.core.internal.listener.ChannelStateChangeListener;
import org.eclipse.tcf.te.tcf.log.core.internal.listener.ChannelTraceListener;
import org.eclipse.tcf.te.tcf.log.core.internal.nls.Messages;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.listeners.IChannelStateChangeListener;
-import org.eclipse.tcf.te.tcf.core.interfaces.listeners.IProtocolStateChangeListener;
/**
@@ -102,8 +101,8 @@ public final class LogManager implements IProtocolStateChangeListener {
* preference settings
*/
private void initializeFromPreferences() {
- String fileSize = Platform.getPreferencesService().getString(CoreBundleActivator.getUniqueIdentifier(),
- IPreferenceKeys.PREF_MAX_FILE_SIZE, "5M", null); //$NON-NLS-1$
+ String fileSize = CoreBundleActivator.getScopedPreferences().getString(IPreferenceKeys.PREF_MAX_FILE_SIZE);
+ if (fileSize == null) fileSize = "5M"; //$NON-NLS-1$
try {
// If the last character is either K, M or G -> convert to bytes
@@ -128,8 +127,8 @@ public final class LogManager implements IProtocolStateChangeListener {
maxFileSize = 5242880L;
}
- maxInCycle = Platform.getPreferencesService().getInt(CoreBundleActivator.getUniqueIdentifier(),
- IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, 5, null);
+ maxInCycle = CoreBundleActivator.getScopedPreferences().getInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE);
+ if (maxInCycle <= 0) maxInCycle = 5;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/PreferencesInitializer.java
index 4c7bfa0b1..c335abaf5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/PreferencesInitializer.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/PreferencesInitializer.java
@@ -10,8 +10,7 @@
package org.eclipse.tcf.te.tcf.log.core.internal;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.tcf.log.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.log.core.interfaces.IPreferenceKeys;
@@ -33,19 +32,21 @@ public class PreferencesInitializer extends AbstractPreferenceInitializer {
*/
@Override
public void initializeDefaultPreferences() {
- // Get the bundles preferences manager
- IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(CoreBundleActivator.getUniqueIdentifier());
+ // Get the bundles scoped preferences store
+ ScopedEclipsePreferences prefs = CoreBundleActivator.getScopedPreferences();
if (prefs != null) {
- // [Hidden] Enable back-end communication logging: default on
- prefs.putBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED, true);
- // [Hidden] Heat beat events: default off
- prefs.putBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS, false);
- // [Hidden] Framework events: default off
- prefs.putBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, false);
- // [Hidden] Maximum log file size in bytes: default 5M
- prefs.put(IPreferenceKeys.PREF_MAX_FILE_SIZE, "5M"); //$NON-NLS-1$
- // [Hidden] Maximum number of log files in cycle: default 5
- prefs.putInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, 5);
+ // Enable back-end communication logging: default on
+ prefs.putDefaultBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED, true);
+ // Enable back-end communication monitor: default off
+ prefs.putDefaultBoolean(IPreferenceKeys.PREF_MONITOR_ENABLED, false);
+ // Heat beat events: default off
+ prefs.putDefaultBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS, false);
+ // Framework events: default off
+ prefs.putDefaultBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, false);
+ // Maximum log file size in bytes: default 5M
+ prefs.putDefaultString(IPreferenceKeys.PREF_MAX_FILE_SIZE, "5M"); //$NON-NLS-1$
+ // Maximum number of log files in cycle: default 5
+ prefs.putDefaultInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, 5);
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
index 2ffba07b7..7ff7d24f1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListener.java
@@ -16,7 +16,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.core.AbstractChannel.TraceListener;
import org.eclipse.tcf.protocol.IChannel;
@@ -119,14 +118,12 @@ public class ChannelTraceListener implements TraceListener {
*/
private void doLogMessage(final char type, String token, String service, String name, byte[] data, boolean received) {
// Filter out the heart beat messages if not overwritten by the preferences
- boolean showHeartbeats = Platform.getPreferencesService().getBoolean(CoreBundleActivator.getUniqueIdentifier(),
- IPreferenceKeys.PREF_SHOW_HEARTBEATS, false, null);
+ boolean showHeartbeats = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS);
if (!showHeartbeats && name != null && name.toLowerCase().contains("heartbeat")) { //$NON-NLS-1$
return;
}
// Filter out framework events if not overwritten by the preferences
- boolean frameworkEvents = Platform.getPreferencesService().getBoolean(CoreBundleActivator.getUniqueIdentifier(),
- IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, false, null);
+ boolean frameworkEvents = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS);
if (!frameworkEvents && type == 'F') {
return;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
index fd87fdf67..28607bc1b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
@@ -16,7 +16,6 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.core.AbstractChannel;
import org.eclipse.tcf.protocol.IChannel;
@@ -74,8 +73,7 @@ public class ChannelTraceListenerManager {
if (!(channel instanceof AbstractChannel)) return;
// Get the preference key if or if not logging is enabled
- boolean loggingEnabled = Platform.getPreferencesService().getBoolean(CoreBundleActivator.getUniqueIdentifier(),
- IPreferenceKeys.PREF_LOGGING_ENABLED, false, null);
+ boolean loggingEnabled = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED);
// If false, we are done here and wont create any console or trace listener.
if (!loggingEnabled) return;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
index 5ae0ca93e..473776058 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
@@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.core;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.core.scripting;bundle-version="1.0.0",
- org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0"
+ org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0",
+ org.eclipse.tcf.te.tcf.log.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
index 0fb07dd50..c3533fce1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
@@ -26,6 +26,10 @@ NewTargetWizard.description=Specify the attributes of the peer to connect to.
NodePropertiesEditorPage.name=General
+# ***** Preference and Property Pages *****
+
+preference.page.name = Logging (TCF)
+
# ***** Command Contributions *****
command.category.name=Target Explorer Commands (TCF)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index a28aef2a4..ae7725e08 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -64,7 +64,7 @@
</wizard>
</extension>
-<!-- Target Explorer Details Editor page contributions -->
+<!-- Editor page contributions -->
<extension point="org.eclipse.tcf.te.ui.views.editorPages">
<editorPage
class="org.eclipse.tcf.te.tcf.ui.internal.editor.pages.NodePropertiesEditorPage"
@@ -73,7 +73,7 @@
</editorPage>
</extension>
-<!-- Target Explorer Details Editor page binding contributions -->
+<!-- Editor page binding contributions -->
<extension point="org.eclipse.tcf.te.ui.views.editorPageBindings">
<editorPageBinding
id="org.eclipse.tcf.te.tcf.ui.binding.NodePropertiesEditorPage"
@@ -87,7 +87,17 @@
</editorPageBinding>
</extension>
-<!-- Target Explorer menu contributions -->
+<!-- Preference page contributions -->
+ <extension point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.tcf.te.ui.preferences.general"
+ class="org.eclipse.tcf.te.tcf.ui.preferences.LoggingPreferencePage"
+ id="org.eclipse.tcf.te.ui.preferences.tcf.logging"
+ name="%preference.page.name">
+ </page>
+ </extension>
+
+<!-- Menu contributions -->
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.TargetExplorer#Popup?after=group.refresh">
<command
@@ -136,7 +146,7 @@
</menuContribution>
</extension>
-<!-- Target Explorer command contributions -->
+<!-- Command contributions -->
<extension point="org.eclipse.ui.commands">
<category
id="org.eclipse.tcf.te.tcf.ui.commands.category"
@@ -150,7 +160,7 @@
</command>
</extension>
-<!-- Target Explorer handler contributions -->
+<!-- Handler contributions -->
<extension point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.tcf.te.tcf.ui.internal.handler.RefreshCommandHandler"
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index a97fd4cbe..e141fbe89 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -133,4 +133,15 @@ public class Messages extends NLS {
public static String AgentSelectionDialog_dialogTitle;
public static String AgentSelectionDialog_title;
public static String AgentSelectionDialog_message;
+
+ public static String LoggingPreferencePage_label;
+ public static String LoggingPreferencePage_enabled_label;
+ public static String LoggingPreferencePage_monitorEnabled_label;
+ public static String LoggingPreferencePage_filterGroup_label;
+ public static String LoggingPreferencePage_showHeartbeats_label;
+ public static String LoggingPreferencePage_showFrameworkEvents_label;
+ public static String LoggingPreferencePage_logfileGroup_label;
+ public static String LoggingPreferencePage_maxFileSize_label;
+ public static String LoggingPreferencePage_maxFileSize_error;
+ public static String LoggingPreferencePage_maxFilesInCycle_label;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
index 8ee194c98..718d8c85d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
@@ -67,3 +67,16 @@ DeleteCommandHandler_error_deleteFailed=Failed to delete static peer.
AgentSelectionDialog_dialogTitle=Select Agent(s)
AgentSelectionDialog_title=Select Agent(s)
AgentSelectionDialog_message=Select the agent(s) for the operation to perform.
+
+# ***** Preference Pages *****
+
+LoggingPreferencePage_label=Logging settings for agent communication:
+LoggingPreferencePage_enabled_label=Enable logging
+LoggingPreferencePage_monitorEnabled_label=Enable agent communication monitor
+LoggingPreferencePage_filterGroup_label=Event Filter Settings
+LoggingPreferencePage_showHeartbeats_label=Log peer heart beat events
+LoggingPreferencePage_showFrameworkEvents_label=Log low-level framework events
+LoggingPreferencePage_logfileGroup_label=Log File Settings
+LoggingPreferencePage_maxFileSize_label=Maximum Log File Size:
+LoggingPreferencePage_maxFileSize_error=Invalid Log File Size.
+LoggingPreferencePage_maxFilesInCycle_label=Maximum # of Files in Rotation:
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/preferences/LoggingPreferencePage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/preferences/LoggingPreferencePage.java
new file mode 100644
index 000000000..268d24dc3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/preferences/LoggingPreferencePage.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.preferences;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.tcf.log.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.log.core.interfaces.IPreferenceKeys;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Agent communication logging preference page.
+ */
+@SuppressWarnings("restriction")
+public class LoggingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+ // References to the field editors
+ private BooleanFieldEditor enabled;
+ private BooleanFieldEditor monitorEnabled;
+ private BooleanFieldEditor showHeartbeats;
+ private BooleanFieldEditor showFrameworkEvents;
+ private StringFieldEditor logfileSize;
+ private IntegerFieldEditor filesInCycle;
+
+ // The preference store used internally for the field editors
+ private IPreferenceStore store;
+
+ /**
+ * Log file size field editor implementation.
+ */
+ private class LogfileSizeFieldEditor extends StringFieldEditor {
+ private Pattern valid = Pattern.compile("0|[1-9][0-9]*[KMG]?"); //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param name The name of the preference this field editor works on.
+ * @param labelText The label text.
+ * @param parent the parent of the field editor's control
+ */
+ public LogfileSizeFieldEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ this.setEmptyStringAllowed(false);
+ this.setTextLimit(6);
+ this.setErrorMessage(Messages.LoggingPreferencePage_maxFileSize_error);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.StringFieldEditor#doCheckState()
+ */
+ @Override
+ protected boolean doCheckState() {
+ if (valid.matcher(getStringValue()).matches()) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+
+ /**
+ * Constructor.
+ */
+ public LoggingPreferencePage() {
+ super(FieldEditorPreferencePage.GRID);
+
+ // The internal preference store never needs saving
+ store = new PreferenceStore() {
+ @Override
+ public boolean needsSaving() {
+ return false;
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ @Override
+ protected void createFieldEditors() {
+ Composite parent = getFieldEditorParent();
+ ((GridLayout)parent.getLayout()).makeColumnsEqualWidth = false;
+
+ Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setFont(parent.getFont());
+
+ Label label = new Label(panel, SWT.HORIZONTAL);
+ label.setText(Messages.LoggingPreferencePage_label);
+ GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ label.setLayoutData(layoutData);
+
+ createSpacer(panel, 2);
+
+ enabled = new BooleanFieldEditor(IPreferenceKeys.PREF_LOGGING_ENABLED,
+ Messages.LoggingPreferencePage_enabled_label, panel);
+ addField(enabled);
+
+ monitorEnabled = new BooleanFieldEditor(IPreferenceKeys.PREF_MONITOR_ENABLED,
+ Messages.LoggingPreferencePage_monitorEnabled_label, panel);
+ addField(monitorEnabled);
+
+ createSpacer(panel, 2);
+
+ Group filterGroup = new Group(panel, SWT.NONE);
+ filterGroup.setText(Messages.LoggingPreferencePage_filterGroup_label);
+ filterGroup.setLayout(new GridLayout(2, false));
+ filterGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // The composite is necessary to get the margins within the group right!
+ Composite filterPanel = new Composite(filterGroup, SWT.NONE);
+ filterPanel.setLayout(new GridLayout());
+ filterPanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ showHeartbeats = new BooleanFieldEditor(IPreferenceKeys.PREF_SHOW_HEARTBEATS,
+ Messages.LoggingPreferencePage_showHeartbeats_label, filterPanel);
+ addField(showHeartbeats);
+
+ showFrameworkEvents = new BooleanFieldEditor(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS,
+ Messages.LoggingPreferencePage_showFrameworkEvents_label, filterPanel);
+ addField(showFrameworkEvents);
+
+ createSpacer(panel, 2);
+
+ Group logfileGroup = new Group(panel, SWT.NONE);
+ logfileGroup.setText(Messages.LoggingPreferencePage_logfileGroup_label);
+ logfileGroup.setLayout(new GridLayout(2, false));
+ logfileGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // The composite is necessary to get the margins within the group right!
+ Composite logfilePanel = new Composite(logfileGroup, SWT.NONE);
+ logfilePanel.setLayout(new GridLayout());
+ logfilePanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ logfileSize = new LogfileSizeFieldEditor(IPreferenceKeys.PREF_MAX_FILE_SIZE,
+ Messages.LoggingPreferencePage_maxFileSize_label, logfilePanel);
+ addField(logfileSize);
+
+ filesInCycle = new IntegerFieldEditor(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE,
+ Messages.LoggingPreferencePage_maxFilesInCycle_label, logfilePanel);
+ addField(filesInCycle);
+ }
+
+ /**
+ * Creates a empty space, 1/4 as high as a line.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param columnSpan The horizontal span.
+ */
+ protected void createSpacer(Composite parent, int columnSpan) {
+ Assert.isNotNull(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = columnSpan;
+ gd.heightHint = SWTControlUtil.convertHeightInCharsToPixels(parent, 1) / 4;
+ new Label(parent, SWT.NONE).setLayoutData(gd);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
+ */
+ @Override
+ protected void initialize() {
+ ScopedEclipsePreferences prefs = CoreBundleActivator.getScopedPreferences();
+
+ store.setDefault(IPreferenceKeys.PREF_LOGGING_ENABLED, prefs.getDefaultBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED));
+ store.setValue(IPreferenceKeys.PREF_LOGGING_ENABLED, prefs.getBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED));
+
+ store.setDefault(IPreferenceKeys.PREF_MONITOR_ENABLED, prefs.getDefaultBoolean(IPreferenceKeys.PREF_MONITOR_ENABLED));
+ store.setValue(IPreferenceKeys.PREF_MONITOR_ENABLED, prefs.getBoolean(IPreferenceKeys.PREF_MONITOR_ENABLED));
+
+ store.setDefault(IPreferenceKeys.PREF_SHOW_HEARTBEATS, prefs.getDefaultBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS));
+ store.setValue(IPreferenceKeys.PREF_SHOW_HEARTBEATS, prefs.getBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS));
+
+ store.setDefault(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, prefs.getDefaultBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS));
+ store.setValue(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, prefs.getBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS));
+
+ store.setDefault(IPreferenceKeys.PREF_MAX_FILE_SIZE, prefs.getDefaultString(IPreferenceKeys.PREF_MAX_FILE_SIZE));
+ store.setValue(IPreferenceKeys.PREF_MAX_FILE_SIZE, prefs.getString(IPreferenceKeys.PREF_MAX_FILE_SIZE));
+
+ store.setDefault(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, prefs.getDefaultInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE));
+ store.setValue(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, prefs.getInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE));
+
+ // Load values into field editors
+ super.initialize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ boolean success = super.performOk();
+
+ if (success) {
+ ScopedEclipsePreferences prefs = CoreBundleActivator.getScopedPreferences();
+
+ prefs.putBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED, store.getBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED));
+ prefs.putBoolean(IPreferenceKeys.PREF_MONITOR_ENABLED, store.getBoolean(IPreferenceKeys.PREF_MONITOR_ENABLED));
+
+ prefs.putBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS, store.getBoolean(IPreferenceKeys.PREF_SHOW_HEARTBEATS));
+ prefs.putBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS, store.getBoolean(IPreferenceKeys.PREF_SHOW_FRAMEWORK_EVENTS));
+
+ prefs.putString(IPreferenceKeys.PREF_MAX_FILE_SIZE, store.getString(IPreferenceKeys.PREF_MAX_FILE_SIZE));
+ prefs.putInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE, store.getInt(IPreferenceKeys.PREF_MAX_FILES_IN_CYCLE));
+ }
+
+ return success;
+ }
+}

Back to the top