summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-05-09 18:04:22 (EDT)
committer Bernd Hufmann2013-07-23 07:25:05 (EDT)
commit8714534cd3caedc8641fa5976b53a61b66f8d90b (patch)
tree1b6675a2a8ed9bf5733b5dac13c8f6776c615fe7
parentb1046ecac5b3d69c010e7d9977b268c83f101848 (diff)
downloadorg.eclipse.linuxtools-8714534cd3caedc8641fa5976b53a61b66f8d90b.zip
org.eclipse.linuxtools-8714534cd3caedc8641fa5976b53a61b66f8d90b.tar.gz
org.eclipse.linuxtools-8714534cd3caedc8641fa5976b53a61b66f8d90b.tar.bz2
Add timezones to preference pagerefs/changes/00/12700/9
Change-Id: I88281ba937889b816d846ac60a1e7c46d04ff34e Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/12700 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki1
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.help/doc/images/TmfTimestampFormatPage.pngbin111880 -> 22990 bytes
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java112
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java112
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/plugin.xml11
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/TmfCorePreferenceInitializer.java29
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/ITmfTimePreferencesConstants.java53
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimePreferences.java202
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java50
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java21
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/Messages.java32
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimePreferences.java202
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimestampFormatPage.java198
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/messages.properties13
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java19
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java10
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java42
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java22
20 files changed, 870 insertions, 265 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki b/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki
index 8ddeeea..b0d61ca 100644
--- a/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki
+++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki
@@ -1487,6 +1487,7 @@ The preference page has several subsections:
* '''Current Format''' a format string generated by the page
* '''Sample Display''' an example of a timestamp formatted with the '''Current Format''' string.
+* '''Time Zone''' the time zone to use when displaying the time. The value '''Local time''' corresponds to the local, system-configured, time zone.
* '''Data and Time format''' how to format the date (days/months/years) and the time (hours/minutes/seconds)
* '''Sub-second format''' how much precision is shown for the sub-second units
* '''Date delimiter''' the character used to delimit the date units such as months and years
diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/TmfTimestampFormatPage.png b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/TmfTimestampFormatPage.png
index 151901a..1d64199 100644
--- a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/TmfTimestampFormatPage.png
+++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/TmfTimestampFormatPage.png
Binary files differ
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
index 013c2d5..6f0bf6e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
@@ -27,9 +27,11 @@ import org.junit.runners.Suite;
TmfEventTypeManagerTest.class,
TmfEventTypeTest.class,
TmfSimpleTimestampTest.class,
+ TmfTimePreferencesTest.class,
TmfTimeRangeTest.class,
TmfTimestampDeltaTest.class,
TmfTimestampTest.class,
+ TmfTimestampFormatTest.class,
org.eclipse.linuxtools.tmf.core.tests.event.lookup.AllTests.class
})
public class AllTests {
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java
new file mode 100644
index 0000000..7ca61a4
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimePreferencesTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * 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:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
+import org.junit.Test;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Test suite for the TmfTimePreferences class.
+ */
+public class TmfTimePreferencesTest {
+
+ private static final String TIME_PATTERN = "HH:mm:ss.SSS CCC NNN";
+ private static final String INTERVAL_PATTERN = "TTT.SSS CCC NNN";
+
+ /**
+ * Test that the preferences get initialized to the default
+ */
+ @Test
+ public void testInit() {
+ assertEquals(DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID).get(ITmfTimePreferencesConstants.DATIME, null), ITmfTimePreferencesConstants.TIME_HOUR_FMT);
+ }
+
+ /**
+ * Test that getInstance returns an instance
+ */
+ @Test
+ public void testGetInstance() {
+ assertNotNull(TmfTimePreferences.getInstance());
+ }
+
+ /**
+ * Test that getTimePattern returns the appropriate time pattern (from the default)
+ */
+ @Test
+ public void testGetTimePattern() {
+ assertEquals(TIME_PATTERN, TmfTimePreferences.getInstance().getTimePattern());
+ }
+
+ /**
+ * Test that getIntervalPattern returns the appropriate interval pattern (from the default)
+ */
+ @Test
+ public void testGetIntervalPattern() {
+ assertEquals(INTERVAL_PATTERN, TmfTimePreferences.getInstance().getIntervalPattern());
+ }
+
+ /**
+ * Test that getTimeZone returns the appropriate time zone (from the default)
+ */
+ @Test
+ public void testGetTimeZone() {
+ assertEquals(TimeZone.getDefault(), TmfTimePreferences.getInstance().getTimeZone());
+ }
+
+ /**
+ * Test that getPreferenceMap returns the appropriate map even after preferences get modified
+ * and make sure it doesn't affect the defaults
+ */
+ @Test
+ public void testGetPreferenceMap() {
+ Map<String, String> defaultPreferenceMap = TmfTimePreferences.getInstance().getDefaultPreferenceMap();
+ assertEquals(ITmfTimePreferencesConstants.TIME_HOUR_FMT, defaultPreferenceMap.get(ITmfTimePreferencesConstants.DATIME));
+
+ // Modify the preferences
+ String testValue = ITmfTimePreferencesConstants.TIME_HOUR_FMT + "foo";
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ node.put(ITmfTimePreferencesConstants.DATIME, testValue);
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ }
+ // Make sure the modification is in the map
+ Map<String, String> preferenceMap = TmfTimePreferences.getInstance().getPreferenceMap();
+ assertEquals(testValue, preferenceMap.get(ITmfTimePreferencesConstants.DATIME));
+
+ // Make sure the default is still the same
+ defaultPreferenceMap = TmfTimePreferences.getInstance().getDefaultPreferenceMap();
+ assertEquals(ITmfTimePreferencesConstants.TIME_HOUR_FMT, defaultPreferenceMap.get(ITmfTimePreferencesConstants.DATIME));
+ }
+
+ /**
+ * Test that computeTimePattern computes the appropriate time pattern from a preference map (from the default)
+ */
+ @Test
+ public void testComputeTimePattern() {
+ assertEquals(TIME_PATTERN, TmfTimePreferences.getInstance().computeTimePattern(TmfTimePreferences.getInstance().getPreferenceMap()));
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java
new file mode 100644
index 0000000..7e1b82c
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampFormatTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * 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:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.event;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.TimeZone;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
+import org.junit.Test;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Test suite for the TmfTimestampFormat class.
+ */
+public class TmfTimestampFormatTest {
+
+ private static final String TEST_PATTERN = "HH:mm:ss.SSS";
+ private static final TimeZone TEST_TIME_ZONE = TimeZone.getTimeZone(TimeZone.getAvailableIDs(0)[0]);
+
+ private final TmfTimestampFormat tsf1 = new TmfTimestampFormat(TEST_PATTERN);
+ private final TmfTimestampFormat tsf2 = new TmfTimestampFormat(TEST_PATTERN, TEST_TIME_ZONE);
+
+ /**
+ * Test that the default value is loaded when using the default constructor
+ */
+ @Test
+ public void testDefaultConstructor() {
+ TmfTimestampFormat ts0 = new TmfTimestampFormat();
+ assertEquals("HH:mm:ss.SSS CCC NNN", ts0.toPattern());
+ }
+
+ /**
+ * Test that the value constructor properly assigns the value
+ */
+ @Test
+ public void testValueConstructor() {
+ assertEquals(TEST_PATTERN, tsf1.toPattern());
+ }
+
+ /**
+ * Test that the value constructor using a time zone properly assigns the pattern and time zone
+ */
+ @Test
+ public void testValueTimeZoneConstructor() {
+ assertEquals(TEST_PATTERN, tsf2.toPattern());
+ assertEquals(TEST_TIME_ZONE, tsf2.getTimeZone());
+ }
+
+ /**
+ * Make sure that the default formats in TmfTimestampFormat get updated when
+ * updateDefaultFormats is called.
+ */
+ @Test
+ public void testUpdateDefaultFormats() {
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+
+ String dateTimeTestValue = ITmfTimePreferencesConstants.TIME_HOUR_FMT + ":";
+ node.put(ITmfTimePreferencesConstants.DATIME, dateTimeTestValue);
+
+ String subSecTestValue = ITmfTimePreferencesConstants.SUBSEC_NANO_FMT + ":";
+ node.put(ITmfTimePreferencesConstants.SUBSEC, subSecTestValue);
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ }
+ TmfTimestampFormat.updateDefaultFormats();
+ String expected = dateTimeTestValue + "." + subSecTestValue;
+ String expected2 = "TTT." + subSecTestValue;
+ assertEquals(expected, TmfTimestampFormat.getDefaulTimeFormat().toPattern());
+ assertEquals(expected2, TmfTimestampFormat.getDefaulIntervalFormat().toPattern());
+ // Revert preferences
+ node.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
+ node.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ }
+ TmfTimestampFormat.updateDefaultFormats();
+ }
+
+ /**
+ * Test that getDefaulTimeFormat returns the appropriate value (from the default)
+ */
+ @Test
+ public void testGetDefaulTimeFormat() {
+ assertEquals(TmfTimestampFormat.getDefaulTimeFormat().toPattern(), TmfTimePreferences.getInstance().getTimePattern());
+ }
+
+ /**
+ * Test that getDefaulIntervalFormat returns the appropriate value (from the default)
+ */
+ @Test
+ public void testGetDefaulIntervalFormat() {
+ assertEquals(TmfTimestampFormat.getDefaulIntervalFormat().toPattern(), TmfTimePreferences.getInstance().getIntervalPattern());
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/plugin.xml b/lttng/org.eclipse.linuxtools.tmf.core/plugin.xml
new file mode 100644
index 0000000..deebba5
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.linuxtools.internal.tmf.core.TmfCorePreferenceInitializer">
+ </initializer>
+ </extension>
+
+</plugin>
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/TmfCorePreferenceInitializer.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/TmfCorePreferenceInitializer.java
new file mode 100644
index 0000000..5103f44
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/TmfCorePreferenceInitializer.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * 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:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.core;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
+
+/**
+ * Preference initializer for tmf.core
+ *
+ */
+public class TmfCorePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ @Override
+ public void initializeDefaultPreferences() {
+ TmfTimePreferences.init();
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/ITmfTimePreferencesConstants.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/ITmfTimePreferencesConstants.java
new file mode 100644
index 0000000..805043f
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/ITmfTimePreferencesConstants.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * 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:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.timestamp;
+
+/**
+ * @since 2.1
+ */
+@SuppressWarnings({ "javadoc", "nls" })
+public interface ITmfTimePreferencesConstants {
+ public static final String TIME_FORMAT_PREF = "org.eclipse.linuxtools.tmf.core.prefs.time.format";
+ public static final String DEFAULT_TIME_PATTERN = "HH:mm:ss.SSS_CCC_NNN";
+ public static final String DATIME = TIME_FORMAT_PREF + ".datime";
+ public static final String SUBSEC = TIME_FORMAT_PREF + ".subsec";
+ public static final String TIME_ZONE = TIME_FORMAT_PREF + ".timezone";
+ public static final String DATE_DELIMITER = TIME_FORMAT_PREF + ".date.delimiter";
+ public static final String TIME_DELIMITER = TIME_FORMAT_PREF + ".time.delimiter";
+ public static final String SSEC_DELIMITER = TIME_FORMAT_PREF + ".ssec.delimiter";
+ public static final String DATE_YEAR_FMT = "yyyy-MM-dd HH:mm:ss";
+ public static final String DATE_YEAR2_FMT = "yy-MM-dd HH:mm:ss";
+ public static final String DATE_MONTH_FMT = "MM-dd HH:mm:ss";
+ public static final String DATE_DAY_FMT = "dd HH:mm:ss";
+ public static final String DATE_JDAY_FMT = "DDD HH:mm:ss";
+ public static final String DATE_NO_FMT = "HH:mm:ss";
+ public static final String TIME_HOUR_FMT = "HH:mm:ss";
+ public static final String TIME_MINUTE_FMT = "mm:ss";
+ public static final String TIME_SECOND_FMT = "ss";
+ public static final String TIME_ELAPSED_FMT = "TTT";
+ public static final String TIME_NO_FMT = "";
+ public static final String SUBSEC_MILLI_FMT = "SSS";
+ public static final String SUBSEC_MICRO_FMT = "SSS CCC";
+ public static final String SUBSEC_NANO_FMT = "SSS CCC NNN";
+ public static final String SUBSEC_NO_FMT = "";
+ public static final String DELIMITER_NONE = "";
+ public static final String DELIMITER_SPACE = " ";
+ public static final String DELIMITER_PERIOD = ".";
+ public static final String DELIMITER_COMMA = ",";
+ public static final String DELIMITER_DASH = "-";
+ public static final String DELIMITER_UNDERLINE = "_";
+ public static final String DELIMITER_COLON = ":";
+ public static final String DELIMITER_SEMICOLON = ";";
+ public static final String DELIMITER_SLASH = "/";
+ public static final String DELIMITER_DQUOT = "\"";
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimePreferences.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimePreferences.java
new file mode 100644
index 0000000..900208a
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimePreferences.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * 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:
+ * Francois Chouinard - Initial API and implementation
+ * Marc-Andre Laperle - Add time zone preference
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.timestamp;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+
+/**
+ * TMF Time format preferences
+ *
+ * @author Francois Chouinard
+ * @version 1.0
+ * @since 2.1
+ */
+public class TmfTimePreferences {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ private static final String DATIME_DEFAULT = ITmfTimePreferencesConstants.TIME_HOUR_FMT;
+ private static final String SUBSEC_DEFAULT = ITmfTimePreferencesConstants.SUBSEC_NANO_FMT;
+ private static final String DATE_DELIMITER_DEFAULT = ITmfTimePreferencesConstants.DELIMITER_DASH;
+ private static final String TIME_DELIMITER_DEFAULT = ITmfTimePreferencesConstants.DELIMITER_COLON;
+ private static final String SSEC_DELIMITER_DEFAULT = ITmfTimePreferencesConstants.DELIMITER_SPACE;
+ private static final String TIME_ZONE_DEFAULT = TimeZone.getDefault().getID();
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private static TmfTimePreferences fPreferences;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Initialize the default preferences and the singleton
+ */
+ public static void init() {
+ IEclipsePreferences defaultPreferences = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, DATIME_DEFAULT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, SUBSEC_DEFAULT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATE_DELIMITER, DATE_DELIMITER_DEFAULT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.TIME_DELIMITER, TIME_DELIMITER_DEFAULT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.SSEC_DELIMITER, SSEC_DELIMITER_DEFAULT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.TIME_ZONE, TIME_ZONE_DEFAULT);
+
+ // Create the singleton and update default formats
+ getInstance();
+ }
+
+ /**
+ * Get the TmfTimePreferences singleton
+ *
+ * @return The TmfTimePreferences instance
+ */
+ public static synchronized TmfTimePreferences getInstance() {
+ if (fPreferences == null) {
+ fPreferences = new TmfTimePreferences();
+ TmfTimestampFormat.updateDefaultFormats();
+ }
+ return fPreferences;
+ }
+
+ /**
+ * Local constructor
+ */
+ private TmfTimePreferences() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters/Setters
+ // ------------------------------------------------------------------------
+
+ /**
+ * Return the timestamp pattern
+ *
+ * @return the timestamp pattern
+ */
+ public String getTimePattern() {
+ return computeTimePattern(getPreferenceMap(false));
+ }
+
+ /**
+ * Return the interval pattern
+ *
+ * @return the interval pattern
+ */
+ public String getIntervalPattern() {
+ return computeIntervalPattern(getPreferenceMap(false));
+ }
+
+ /**
+ * Get the time zone
+ *
+ * @return the time zone
+ */
+ public TimeZone getTimeZone() {
+ return TimeZone.getTimeZone(Platform.getPreferencesService().getString(Activator.PLUGIN_ID, ITmfTimePreferencesConstants.TIME_ZONE, TimeZone.getDefault().getID(), null));
+ }
+
+ /**
+ * Get the default preferences map
+ *
+ * @return a collection containing the default preferences
+ */
+ public Map<String, String> getDefaultPreferenceMap() {
+ return getPreferenceMap(true);
+ }
+
+ /**
+ * Get the current preferences map
+ *
+ * @return a collection containing the current preferences
+ */
+ public Map<String, String> getPreferenceMap() {
+ return getPreferenceMap(false);
+ }
+
+ private static Map<String, String> getPreferenceMap(boolean defaultValues) {
+ Map<String, String> prefsMap = new HashMap<String, String>();
+ IEclipsePreferences prefs = defaultValues ? DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID) : InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.SUBSEC, SUBSEC_DEFAULT);
+ prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.TIME_DELIMITER, TIME_DELIMITER_DEFAULT);
+ prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.SSEC_DELIMITER, SSEC_DELIMITER_DEFAULT);
+ prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.DATIME, DATIME_DEFAULT);
+ prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.DATE_DELIMITER, DATE_DELIMITER_DEFAULT);
+ return prefsMap;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ private static String computeIntervalPattern(Map<String, String> prefsMap) {
+ String ssecFmt = computeSubSecFormat(prefsMap);
+ return ITmfTimePreferencesConstants.TIME_ELAPSED_FMT + "." + ssecFmt; //$NON-NLS-1$
+ }
+
+ private static String computeSubSecFormat(Map<String, String> prefsMap) {
+ String sSecFormat = prefsMap.get(ITmfTimePreferencesConstants.SUBSEC);
+ String sSecFieldSep = prefsMap.get(ITmfTimePreferencesConstants.SSEC_DELIMITER);
+ String ssecFmt = sSecFormat.replaceAll(" ", sSecFieldSep); //$NON-NLS-1$
+ return ssecFmt;
+ }
+
+ private static void prefToMap(IEclipsePreferences node, Map<String, String> prefsMap, String key, String defaultValue) {
+ prefsMap.put(key, node.get(key, defaultValue));
+ }
+
+ /**
+ * Compute the time pattern with the collection of preferences
+ *
+ * @param prefsMap the preferences to apply when computing the time pattern
+ * @return the time pattern resulting in applying the preferences
+ */
+ public String computeTimePattern(Map<String, String> prefsMap) {
+ String dateTimeFormat = prefsMap.get(ITmfTimePreferencesConstants.DATIME);
+ if (dateTimeFormat == null) {
+ dateTimeFormat = ITmfTimePreferencesConstants.DEFAULT_TIME_PATTERN;
+ }
+
+ String dateFormat;
+ String timeFormat;
+ int index = dateTimeFormat.indexOf(' ');
+ if (index != -1) {
+ dateFormat = dateTimeFormat.substring(0, dateTimeFormat.indexOf(' ') + 1);
+ timeFormat = dateTimeFormat.substring(dateFormat.length());
+ } else {
+ dateFormat = ""; //$NON-NLS-1$
+ timeFormat = dateTimeFormat;
+ }
+
+ String dateFieldSep = prefsMap.get(ITmfTimePreferencesConstants.DATE_DELIMITER);
+ String timeFieldSep = prefsMap.get(ITmfTimePreferencesConstants.TIME_DELIMITER);
+ String dateFmt = dateFormat.replaceAll("-", dateFieldSep); //$NON-NLS-1$
+ String timeFmt = timeFormat.replaceAll(":", timeFieldSep); //$NON-NLS-1$
+
+ String ssecFmt = computeSubSecFormat(prefsMap);
+ return dateFmt + timeFmt + (ssecFmt.equals(ITmfTimePreferencesConstants.SUBSEC_NO_FMT) ? "" : '.' + ssecFmt); //$NON-NLS-1$;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java
index 50c143d..4d570f2 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java
@@ -7,7 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Initial API and implementation
+ * Marc-Andre Laperle - Add time zone preference
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.timestamp;
@@ -19,12 +20,10 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
-
/**
* A formatting and parsing facility that can handle timestamps that span the
* epoch with a precision down to the nanosecond. It can be understood as a
@@ -213,11 +212,9 @@ public class TmfTimestampFormat extends SimpleDateFormat {
// ------------------------------------------------------------------------
// The default timestamp pattern
- private static String fDefaultTimePattern = null;
private static TmfTimestampFormat fDefaultTimeFormat = null;
// The default time interval format
- private static String fDefaultIntervalPattern = null;
private static TmfTimestampFormat fDefaultIntervalFormat = null;
// The timestamp pattern
@@ -253,7 +250,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
* The default constructor (uses the default pattern)
*/
public TmfTimestampFormat() {
- this(fDefaultTimePattern);
+ this(TmfTimePreferences.getInstance().getTimePattern());
}
/**
@@ -266,6 +263,18 @@ public class TmfTimestampFormat extends SimpleDateFormat {
}
/**
+ * The full constructor
+ *
+ * @param pattern the format pattern
+ * @param timeZone the time zone
+ * @since 2.1
+ */
+ public TmfTimestampFormat(String pattern, TimeZone timeZone) {
+ setTimeZone(timeZone);
+ applyPattern(pattern);
+ }
+
+ /**
* The copy constructor
*
* @param other the other format pattern
@@ -279,12 +288,21 @@ public class TmfTimestampFormat extends SimpleDateFormat {
// ------------------------------------------------------------------------
/**
+ * @since 2.1
+ */
+ public static void updateDefaultFormats() {
+ fDefaultTimeFormat = new TmfTimestampFormat(TmfTimePreferences.getInstance().getTimePattern(), TmfTimePreferences.getInstance().getTimeZone());
+ fDefaultIntervalFormat = new TmfTimestampFormat(TmfTimePreferences.getInstance().getIntervalPattern());
+ }
+
+ /**
* @param pattern the new default time pattern
+ * @deprecated The default time pattern depends on the preferences, see
+ * {@link TmfTimePreferences}. To change the default time
+ * pattern, modify the preferences and call {@link #updateDefaultFormats()}
*/
+ @Deprecated
public static void setDefaultTimeFormat(final String pattern) {
- fDefaultTimePattern = pattern;
- fDefaultTimeFormat = new TmfTimestampFormat(fDefaultTimePattern);
- TmfSignalManager.dispatchSignal(new TmfTimestampFormatUpdateSignal(null));
}
/**
@@ -292,18 +310,20 @@ public class TmfTimestampFormat extends SimpleDateFormat {
*/
public static TmfTimestampFormat getDefaulTimeFormat() {
if (fDefaultTimeFormat == null) {
- fDefaultTimeFormat = new TmfTimestampFormat(DEFAULT_TIME_PATTERN);
+ fDefaultTimeFormat = new TmfTimestampFormat(TmfTimePreferences.getInstance().getTimePattern(), TmfTimePreferences.getInstance().getTimeZone());
}
return fDefaultTimeFormat;
}
/**
* @param pattern the new default interval pattern
+ * @deprecated The default interval format pattern depends on the
+ * preferences, see {@link TmfTimePreferences}. To change the
+ * default time pattern, modify the preferences and call
+ * {@link #updateDefaultFormats()}
*/
+ @Deprecated
public static void setDefaultIntervalFormat(final String pattern) {
- fDefaultIntervalPattern = pattern;
- fDefaultIntervalFormat = new TmfTimestampFormat(fDefaultIntervalPattern);
- TmfSignalManager.dispatchSignal(new TmfTimestampFormatUpdateSignal(null));
}
/**
@@ -311,7 +331,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
*/
public static TmfTimestampFormat getDefaulIntervalFormat() {
if (fDefaultIntervalFormat == null) {
- fDefaultIntervalFormat = new TmfTimestampFormat(DEFAULT_INTERVAL_PATTERN);
+ fDefaultIntervalFormat = new TmfTimestampFormat(TmfTimePreferences.getInstance().getIntervalPattern());
}
return fDefaultIntervalFormat;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java
index 6b290fa..8ef0012 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Activator.java
@@ -15,14 +15,16 @@ package org.eclipse.linuxtools.internal.tmf.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
-import org.eclipse.linuxtools.tmf.ui.properties.TmfTimePreferences;
import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventAdapterFactory;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
/**
@@ -38,6 +40,10 @@ public class Activator extends AbstractUIPlugin {
* The plug-in ID
*/
public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$
+ /**
+ * The core plug-in ID
+ */
+ public static final String PLUGIN_CORE_ID = "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
/**
* The shared instance
@@ -45,6 +51,7 @@ public class Activator extends AbstractUIPlugin {
private static Activator plugin;
private TmfEventAdapterFactory fTmfEventAdapterFactory;
+ private IPreferenceStore fCorePreferenceStore;
// ------------------------------------------------------------------------
// Constructors
@@ -79,7 +86,6 @@ public class Activator extends AbstractUIPlugin {
plugin = this;
TmfUiTracer.init();
TmfTraceElement.init();
- TmfTimePreferences.init();
fTmfEventAdapterFactory = new TmfEventAdapterFactory();
Platform.getAdapterManager().registerAdapters(fTmfEventAdapterFactory, ITmfEvent.class);
@@ -94,6 +100,17 @@ public class Activator extends AbstractUIPlugin {
super.stop(context);
}
+ /**
+ * Returns a preference store for org.eclipse.linux.tmf.core preferences
+ * @return the preference store
+ */
+ public IPreferenceStore getCorePreferenceStore() {
+ if (fCorePreferenceStore == null) {
+ fCorePreferenceStore= new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_CORE_ID);
+ }
+ return fCorePreferenceStore;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java
index c30641b..292310e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java
@@ -689,7 +689,9 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus
*/
@TmfSignalHandler
public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal) {
- fEventsTable.refresh();
+ if (fEventsTable != null) {
+ fEventsTable.refresh();
+ }
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/Messages.java
new file mode 100644
index 0000000..19ae246
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/Messages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * 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:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.properties;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 2.1
+ */
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.properties.messages"; //$NON-NLS-1$
+
+ public static String TmfTimestampFormatPage_LocalTime;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimePreferences.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimePreferences.java
index 141864c..20d363c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimePreferences.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimePreferences.java
@@ -14,7 +14,6 @@ package org.eclipse.linuxtools.tmf.ui.properties;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
/**
* TMF Time format preferences
@@ -22,95 +21,37 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
* @author Francois Chouinard
* @version 1.0
* @since 2.0
+ * @deprecated Use {@link org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences} instead.
*/
@SuppressWarnings("javadoc")
+@Deprecated
public class TmfTimePreferences {
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
public static final String DEFAULT_TIME_PATTERN = "HH:mm:ss.SSS_CCC_NNN"; //$NON-NLS-1$
- static final String TIME_FORMAT_PREF = "org.eclipse.linuxtools.tmf.ui.prefs.time.format"; //$NON-NLS-1$
- static final String DATIME = TIME_FORMAT_PREF + ".datime"; //$NON-NLS-1$
- static final String SUBSEC = TIME_FORMAT_PREF + ".subsec"; //$NON-NLS-1$
-
- static final String DATE_DELIMITER = TIME_FORMAT_PREF + ".date.delimiter"; //$NON-NLS-1$
- static final String TIME_DELIMITER = TIME_FORMAT_PREF + ".time.delimiter"; //$NON-NLS-1$
- static final String SSEC_DELIMITER = TIME_FORMAT_PREF + ".ssec.delimiter"; //$NON-NLS-1$
-
- static final String DATE_YEAR_FMT = "yyyy-MM-dd HH:mm:ss"; //$NON-NLS-1$
- static final String DATE_YEAR2_FMT = "yy-MM-dd HH:mm:ss"; //$NON-NLS-1$
- static final String DATE_MONTH_FMT = "MM-dd HH:mm:ss"; //$NON-NLS-1$
- static final String DATE_DAY_FMT = "dd HH:mm:ss"; //$NON-NLS-1$
- static final String DATE_JDAY_FMT = "DDD HH:mm:ss"; //$NON-NLS-1$
- static final String DATE_NO_FMT = "HH:mm:ss"; //$NON-NLS-1$
-
- static final String TIME_HOUR_FMT = "HH:mm:ss"; //$NON-NLS-1$
- static final String TIME_MINUTE_FMT = "mm:ss"; //$NON-NLS-1$
- static final String TIME_SECOND_FMT = "ss"; //$NON-NLS-1$
- static final String TIME_ELAPSED_FMT = "TTT"; //$NON-NLS-1$
- static final String TIME_NO_FMT = ""; //$NON-NLS-1$
-
- static final String SUBSEC_MILLI_FMT = "SSS"; //$NON-NLS-1$
- static final String SUBSEC_MICRO_FMT = "SSS CCC"; //$NON-NLS-1$
- static final String SUBSEC_NANO_FMT = "SSS CCC NNN"; //$NON-NLS-1$
- static final String SUBSEC_NO_FMT = ""; //$NON-NLS-1$
-
- static final String DELIMITER_NONE = ""; //$NON-NLS-1$
- static final String DELIMITER_SPACE = " "; //$NON-NLS-1$
- static final String DELIMITER_PERIOD = "."; //$NON-NLS-1$
- static final String DELIMITER_COMMA = ","; //$NON-NLS-1$
- static final String DELIMITER_DASH = "-"; //$NON-NLS-1$
- static final String DELIMITER_UNDERLINE = "_"; //$NON-NLS-1$
- static final String DELIMITER_COLON = ":"; //$NON-NLS-1$
- static final String DELIMITER_SEMICOLON = ";"; //$NON-NLS-1$
- static final String DELIMITER_SLASH = "/"; //$NON-NLS-1$
- static final String DELIMITER_DQUOT = "\""; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
private static TmfTimePreferences fPreferences;
- private static IPreferenceStore fPreferenceStore;
- private static String fTimestampPattern;
- private static String fIntervalPattern;
-
- private String fDatimeFormat;
- private String fDateFormat;
- private String fTimeFormat;
- private String fSSecFormat;
-
- private String fDateFieldSep = "-"; //$NON-NLS-1$
- private String fTimeFieldSep = ":"; //$NON-NLS-1$
- private String fSSecFieldSep = " "; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
+ /**
+ * @deprecated Use {@link org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences#init} instead.
+ */
+ @Deprecated
public static void init() {
- fPreferenceStore = Activator.getDefault().getPreferenceStore();
- fPreferenceStore.setDefault(TmfTimePreferences.DATIME, TIME_HOUR_FMT);
- fPreferenceStore.setDefault(TmfTimePreferences.SUBSEC, SUBSEC_NANO_FMT);
- fPreferenceStore.setDefault(TmfTimePreferences.DATE_DELIMITER, DELIMITER_DASH);
- fPreferenceStore.setDefault(TmfTimePreferences.TIME_DELIMITER, DELIMITER_COLON);
- fPreferenceStore.setDefault(TmfTimePreferences.SSEC_DELIMITER, DELIMITER_SPACE);
-
- // Create the singleton and initialize format preferences
- getInstance();
+ org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences.init();
}
+ /**
+ * @deprecated Use {@link org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences} instead.
+ */
+ @Deprecated
public static synchronized IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null) {
- init();
- }
- return fPreferenceStore;
+ init();
+ return Activator.getDefault().getCorePreferenceStore();
}
+ /**
+ * @deprecated Use {@link org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences#getInstance} instead.
+ */
+ @Deprecated
public static synchronized TmfTimePreferences getInstance() {
if (fPreferences == null) {
fPreferences = new TmfTimePreferences();
@@ -119,115 +60,12 @@ public class TmfTimePreferences {
}
/**
- * Local constructor
- */
- private TmfTimePreferences() {
- initPatterns();
- setTimePattern(fTimestampPattern);
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters
- // ------------------------------------------------------------------------
-
- /**
* @return the timestamp pattern
+ * @deprecated Use {@link org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences#getTimePattern} instead.
*/
+ @Deprecated
public static String getTimePattern() {
- return fTimestampPattern;
- }
-
- /**
- * Sets the timestamp pattern and updates TmfTimestampFormat
- *
- * @param timePattern the new timestamp pattern
- */
- static void setTimePattern(String timePattern) {
- fTimestampPattern = timePattern;
- TmfTimestampFormat.setDefaultTimeFormat(fTimestampPattern);
- TmfTimestampFormat.setDefaultIntervalFormat(fIntervalPattern);
- }
-
- /**
- * Update the Date field separator
- * @param pattern the Date field separator
- */
- void setDateFieldSep(String pattern) {
- fDateFieldSep = pattern;
- }
-
- /**
- * Update the Time field separator
- * @param pattern the Time field separator
- */
- void setTimeFieldSep(String pattern) {
- fTimeFieldSep = pattern;
- }
-
- /**
- * Update the Subseconds field separator
- * @param pattern the Subseconds field separator
- */
- void setSSecFieldSep(String pattern) {
- fSSecFieldSep = pattern;
- }
-
- /**
- * Update the Date/Time format
- * @param pattern the Date/Time format
- */
- void setDateTimeFormat(String pattern) {
- fDatimeFormat = pattern;
- if (fDatimeFormat == null) {
- fDatimeFormat = DEFAULT_TIME_PATTERN;
- }
- int index = fDatimeFormat.indexOf(' ');
- if (index != -1) {
- fDateFormat = fDatimeFormat.substring(0, fDatimeFormat.indexOf(' ') + 1);
- fTimeFormat = fDatimeFormat.substring(fDateFormat.length());
- } else {
- fDateFormat = ""; //$NON-NLS-1$
- fTimeFormat = fDatimeFormat;
- }
- }
-
- /**
- * Update the Subseconds format
- * @param pattern the Subseconds format
- */
- void setSSecFormat(String pattern) {
- fSSecFormat = pattern;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- void initPatterns() {
- setDateTimeFormat(fPreferenceStore.getString(DATIME));
- fSSecFormat = fPreferenceStore.getString(SUBSEC);
- fDateFieldSep = fPreferenceStore.getString(DATE_DELIMITER);
- fTimeFieldSep = fPreferenceStore.getString(TIME_DELIMITER);
- fSSecFieldSep = fPreferenceStore.getString(SSEC_DELIMITER);
- updatePatterns();
- }
-
- void updatePatterns() {
- String dateFmt = fDateFormat.replaceAll("-", fDateFieldSep); //$NON-NLS-1$
- String timeFmt = fTimeFormat.replaceAll(":", fTimeFieldSep); //$NON-NLS-1$
- String ssecFmt = fSSecFormat.replaceAll(" ", fSSecFieldSep); //$NON-NLS-1$
-
- fTimestampPattern = dateFmt + timeFmt + "." + ssecFmt; //$NON-NLS-1$
- fIntervalPattern = "TTT." + ssecFmt; //$NON-NLS-1$
- }
-
- void setDefaults() {
- setDateTimeFormat(TmfTimePreferences.TIME_HOUR_FMT);
- setSSecFormat(TmfTimePreferences.SUBSEC_NANO_FMT);
- setDateFieldSep(TmfTimePreferences.DELIMITER_DASH);
- setTimeFieldSep(TmfTimePreferences.DELIMITER_COLON);
- setSSecFieldSep(TmfTimePreferences.DELIMITER_SPACE);
- updatePatterns();
+ return org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences.getInstance().getTimePattern();
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimestampFormatPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimestampFormatPage.java
index b13da9f..2ccd66b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimestampFormatPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/TmfTimestampFormatPage.java
@@ -7,16 +7,26 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Initial API and implementation
+ * Marc-Andre Laperle - Add time zone preference
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.properties;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -31,9 +41,9 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * The TMF timestamp format configuration page. This page is used to select
- * the global timestamp and interval time formats (for display and parsing).
- * The user can either pick a pre-defined format or enter his/her own.
+ * The TMF timestamp format configuration page. This page is used to select the
+ * global timestamp and interval time formats (for display and parsing). The
+ * user can either pick a pre-defined format or enter his/her own.
*
* @version 1.0
* @author Francois Chouinard
@@ -47,50 +57,90 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
// Date and Time formats
private static final String[][] fDateTimeFormats = new String[][] {
- { TmfTimePreferences.DATE_YEAR_FMT, TmfTimePreferences.DATE_YEAR_FMT },
- { TmfTimePreferences.DATE_YEAR2_FMT, TmfTimePreferences.DATE_YEAR2_FMT },
- { TmfTimePreferences.DATE_MONTH_FMT, TmfTimePreferences.DATE_MONTH_FMT },
- { TmfTimePreferences.DATE_DAY_FMT, TmfTimePreferences.DATE_DAY_FMT },
- { TmfTimePreferences.DATE_JDAY_FMT, TmfTimePreferences.DATE_JDAY_FMT },
- { TmfTimePreferences.TIME_HOUR_FMT, TmfTimePreferences.TIME_HOUR_FMT },
- { TmfTimePreferences.TIME_MINUTE_FMT, TmfTimePreferences.TIME_MINUTE_FMT },
- { TmfTimePreferences.TIME_SECOND_FMT, TmfTimePreferences.TIME_SECOND_FMT },
- { TmfTimePreferences.TIME_ELAPSED_FMT + " (secs in epoch)", TmfTimePreferences.TIME_ELAPSED_FMT }, //$NON-NLS-1$
- { "(none)", TmfTimePreferences.TIME_NO_FMT }, //$NON-NLS-1$
+ { ITmfTimePreferencesConstants.DATE_YEAR_FMT, ITmfTimePreferencesConstants.DATE_YEAR_FMT },
+ { ITmfTimePreferencesConstants.DATE_YEAR2_FMT, ITmfTimePreferencesConstants.DATE_YEAR2_FMT },
+ { ITmfTimePreferencesConstants.DATE_MONTH_FMT, ITmfTimePreferencesConstants.DATE_MONTH_FMT },
+ { ITmfTimePreferencesConstants.DATE_DAY_FMT, ITmfTimePreferencesConstants.DATE_DAY_FMT },
+ { ITmfTimePreferencesConstants.DATE_JDAY_FMT, ITmfTimePreferencesConstants.DATE_JDAY_FMT },
+ { ITmfTimePreferencesConstants.TIME_HOUR_FMT, ITmfTimePreferencesConstants.TIME_HOUR_FMT },
+ { ITmfTimePreferencesConstants.TIME_MINUTE_FMT, ITmfTimePreferencesConstants.TIME_MINUTE_FMT },
+ { ITmfTimePreferencesConstants.TIME_SECOND_FMT, ITmfTimePreferencesConstants.TIME_SECOND_FMT },
+ { ITmfTimePreferencesConstants.TIME_ELAPSED_FMT + " (secs in epoch)", ITmfTimePreferencesConstants.TIME_ELAPSED_FMT }, //$NON-NLS-1$
+ { "(none)", ITmfTimePreferencesConstants.TIME_NO_FMT }, //$NON-NLS-1$
};
// Sub-second formats
private static final String[][] fSubSecondFormats = new String[][] {
- { TmfTimePreferences.SUBSEC_MILLI_FMT + " (ms)", TmfTimePreferences.SUBSEC_MILLI_FMT }, //$NON-NLS-1$
- { TmfTimePreferences.SUBSEC_MICRO_FMT + " (µs)", TmfTimePreferences.SUBSEC_MICRO_FMT }, //$NON-NLS-1$
- { TmfTimePreferences.SUBSEC_NANO_FMT + " (ns)", TmfTimePreferences.SUBSEC_NANO_FMT }, //$NON-NLS-1$
+ { ITmfTimePreferencesConstants.SUBSEC_MILLI_FMT + " (ms)", ITmfTimePreferencesConstants.SUBSEC_MILLI_FMT }, //$NON-NLS-1$
+ { ITmfTimePreferencesConstants.SUBSEC_MICRO_FMT + " (µs)", ITmfTimePreferencesConstants.SUBSEC_MICRO_FMT }, //$NON-NLS-1$
+ { ITmfTimePreferencesConstants.SUBSEC_NANO_FMT + " (ns)", ITmfTimePreferencesConstants.SUBSEC_NANO_FMT }, //$NON-NLS-1$
};
// Date and Time delimiters
private static final String[][] fDateTimeDelimiters = new String[][] {
- { "(none)", TmfTimePreferences.DELIMITER_NONE }, //$NON-NLS-1$
- { " (space)", TmfTimePreferences.DELIMITER_SPACE }, //$NON-NLS-1$
- { ", (comma)", TmfTimePreferences.DELIMITER_COMMA }, //$NON-NLS-1$
- { "- (dash)", TmfTimePreferences.DELIMITER_DASH }, //$NON-NLS-1$
- { "_ (underline)", TmfTimePreferences.DELIMITER_UNDERLINE }, //$NON-NLS-1$
- { ": (colon)", TmfTimePreferences.DELIMITER_COLON }, //$NON-NLS-1$
- { "; (semicolon)", TmfTimePreferences.DELIMITER_SEMICOLON }, //$NON-NLS-1$
- { "/ (slash)", TmfTimePreferences.DELIMITER_SLASH }, //$NON-NLS-1$
- { "\" (dbl-quote)", TmfTimePreferences.DELIMITER_DQUOT }, //$NON-NLS-1$
+ { "(none)", ITmfTimePreferencesConstants.DELIMITER_NONE }, //$NON-NLS-1$
+ { " (space)", ITmfTimePreferencesConstants.DELIMITER_SPACE }, //$NON-NLS-1$
+ { ", (comma)", ITmfTimePreferencesConstants.DELIMITER_COMMA }, //$NON-NLS-1$
+ { "- (dash)", ITmfTimePreferencesConstants.DELIMITER_DASH }, //$NON-NLS-1$
+ { "_ (underline)", ITmfTimePreferencesConstants.DELIMITER_UNDERLINE }, //$NON-NLS-1$
+ { ": (colon)", ITmfTimePreferencesConstants.DELIMITER_COLON }, //$NON-NLS-1$
+ { "; (semicolon)", ITmfTimePreferencesConstants.DELIMITER_SEMICOLON }, //$NON-NLS-1$
+ { "/ (slash)", ITmfTimePreferencesConstants.DELIMITER_SLASH }, //$NON-NLS-1$
+ { "\" (dbl-quote)", ITmfTimePreferencesConstants.DELIMITER_DQUOT }, //$NON-NLS-1$
};
// Sub-Second delimiters
private static final String[][] fSubSecondDelimiters = new String[][] {
- { "(none)", TmfTimePreferences.DELIMITER_NONE }, //$NON-NLS-1$
- { " (space)", TmfTimePreferences.DELIMITER_SPACE }, //$NON-NLS-1$
- { ", (comma)", TmfTimePreferences.DELIMITER_COMMA }, //$NON-NLS-1$
- { "- (dash)", TmfTimePreferences.DELIMITER_DASH }, //$NON-NLS-1$
- { "_ (underline)", TmfTimePreferences.DELIMITER_UNDERLINE }, //$NON-NLS-1$
- { ": (colon)", TmfTimePreferences.DELIMITER_COLON }, //$NON-NLS-1$
- { "; (semicolon)", TmfTimePreferences.DELIMITER_SEMICOLON }, //$NON-NLS-1$
- { "/ (slash)", TmfTimePreferences.DELIMITER_SLASH }, //$NON-NLS-1$
- { "\" (dbl-quote)", TmfTimePreferences.DELIMITER_DQUOT }, //$NON-NLS-1$
- { ". (period)", TmfTimePreferences.DELIMITER_PERIOD }, //$NON-NLS-1$
+ { "(none)", ITmfTimePreferencesConstants.DELIMITER_NONE }, //$NON-NLS-1$
+ { " (space)", ITmfTimePreferencesConstants.DELIMITER_SPACE }, //$NON-NLS-1$
+ { ", (comma)", ITmfTimePreferencesConstants.DELIMITER_COMMA }, //$NON-NLS-1$
+ { "- (dash)", ITmfTimePreferencesConstants.DELIMITER_DASH }, //$NON-NLS-1$
+ { "_ (underline)", ITmfTimePreferencesConstants.DELIMITER_UNDERLINE }, //$NON-NLS-1$
+ { ": (colon)", ITmfTimePreferencesConstants.DELIMITER_COLON }, //$NON-NLS-1$
+ { "; (semicolon)", ITmfTimePreferencesConstants.DELIMITER_SEMICOLON }, //$NON-NLS-1$
+ { "/ (slash)", ITmfTimePreferencesConstants.DELIMITER_SLASH }, //$NON-NLS-1$
+ { "\" (dbl-quote)", ITmfTimePreferencesConstants.DELIMITER_DQUOT }, //$NON-NLS-1$
+ { ". (period)", ITmfTimePreferencesConstants.DELIMITER_PERIOD }, //$NON-NLS-1$
+ };
+
+ // Time zones
+ @SuppressWarnings("nls")
+ private static final String[] timeZones = new String[] {
+ Messages.TmfTimestampFormatPage_LocalTime,
+ "GMT-12",
+ "GMT-11",
+ "GMT-10",
+ "GMT-9:30",
+ "GMT-9",
+ "GMT-7",
+ "GMT-6",
+ "GMT-5",
+ "GMT-4",
+ "GMT-3:30",
+ "GMT-3",
+ "GMT-2",
+ "GMT-1",
+ "GMT",
+ "GMT+1",
+ "GMT+2",
+ "GMT+3",
+ "GMT+3:30",
+ "GMT+4",
+ "GMT+4:30",
+ "GMT+5",
+ "GMT+5:30",
+ "GMT+6",
+ "GMT+7",
+ "GMT+8",
+ "GMT+9",
+ "GMT+9:30",
+ "GMT+10",
+ "GMT+10:30",
+ "GMT+11",
+ "GMT+11:30",
+ "GMT+12",
+ "GMT+13:00",
+ "GMT+14:00"
};
// ------------------------------------------------------------------------
@@ -106,7 +156,9 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
private Composite fExampleSection;
private Text fPatternDisplay;
private Text fExampleDisplay;
- private String fTimePattern;
+
+ // Timezone section
+ private ComboFieldEditor fCombo;
// Date/Time format section
private RadioGroupFieldEditor fDateTimeFields;
@@ -121,6 +173,8 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
private String fProperty;
private String fChangedProperty;
+ private Map<String, String> fPreferenceMap;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -129,8 +183,9 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
* The default constructor
*/
public TmfTimestampFormatPage() {
- fPreferenceStore = TmfTimePreferences.getPreferenceStore();
+ fPreferenceStore = getPreferenceStore();
fTimePreference = TmfTimePreferences.getInstance();
+ fPreferenceMap = fTimePreference.getPreferenceMap();
}
// ------------------------------------------------------------------------
@@ -138,6 +193,11 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
// ------------------------------------------------------------------------
@Override
+ protected IPreferenceStore doGetPreferenceStore() {
+ return Activator.getDefault().getCorePreferenceStore();
+ }
+
+ @Override
public void init(IWorkbench workbench) {
}
@@ -174,40 +234,59 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
separator.setLayoutData(
new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
+ // Time Zones
+ String[][] timeZoneIntervals = new String[timeZones.length][2];
+ timeZoneIntervals[0][0] = timeZones[0];
+ timeZoneIntervals[0][1] = fPreferenceStore.getDefaultString(ITmfTimePreferencesConstants.TIME_ZONE);
+ for (int i = 1; i < timeZones.length; i++) {
+ TimeZone tz = null;
+ try {
+ tz = TimeZone.getTimeZone(timeZones[i]);
+ timeZoneIntervals[i][0] = tz.getDisplayName();
+ timeZoneIntervals[i][1] = tz.getID();
+ } catch (NullPointerException e) {
+ System.out.println("TimeZone " + timeZones[i] + " does not exist."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ fCombo = new ComboFieldEditor(ITmfTimePreferencesConstants.TIME_ZONE, "Time Zone", timeZoneIntervals, fPage); //$NON-NLS-1$
+ fCombo.setPreferenceStore(fPreferenceStore);
+ fCombo.load();
+ fCombo.setPropertyChangeListener(this);
+
// Date and Time section
fDateTimeFields = new RadioGroupFieldEditor(
- TmfTimePreferences.DATIME, "Date and Time format", 3, fDateTimeFormats, fPage, true); //$NON-NLS-1$
+ ITmfTimePreferencesConstants.DATIME, "Date and Time format", 3, fDateTimeFormats, fPage, true); //$NON-NLS-1$
fDateTimeFields.setPreferenceStore(fPreferenceStore);
fDateTimeFields.load();
fDateTimeFields.setPropertyChangeListener(this);
// Sub-second section
fSSecFields = new RadioGroupFieldEditor(
- TmfTimePreferences.SUBSEC, "Sub-second format", 3, fSubSecondFormats, fPage, true); //$NON-NLS-1$
+ ITmfTimePreferencesConstants.SUBSEC, "Sub-second format", 3, fSubSecondFormats, fPage, true); //$NON-NLS-1$
fSSecFields.setPreferenceStore(fPreferenceStore);
fSSecFields.load();
fSSecFields.setPropertyChangeListener(this);
// Separators section
fDateFieldDelim = new RadioGroupFieldEditor(
- TmfTimePreferences.DATE_DELIMITER, "Date delimiter", 5, fDateTimeDelimiters, fPage, true); //$NON-NLS-1$
+ ITmfTimePreferencesConstants.DATE_DELIMITER, "Date delimiter", 5, fDateTimeDelimiters, fPage, true); //$NON-NLS-1$
fDateFieldDelim.setPreferenceStore(fPreferenceStore);
fDateFieldDelim.load();
fDateFieldDelim.setPropertyChangeListener(this);
fTimeFieldDelim = new RadioGroupFieldEditor(
- TmfTimePreferences.TIME_DELIMITER, "Time delimiter", 5, fDateTimeDelimiters, fPage, true); //$NON-NLS-1$
+ ITmfTimePreferencesConstants.TIME_DELIMITER, "Time delimiter", 5, fDateTimeDelimiters, fPage, true); //$NON-NLS-1$
fTimeFieldDelim.setPreferenceStore(fPreferenceStore);
fTimeFieldDelim.load();
fTimeFieldDelim.setPropertyChangeListener(this);
fSSecFieldDelim = new RadioGroupFieldEditor(
- TmfTimePreferences.SSEC_DELIMITER, "Sub-Second Delimiter", 5, fSubSecondDelimiters, fPage, true); //$NON-NLS-1$
+ ITmfTimePreferencesConstants.SSEC_DELIMITER, "Sub-Second Delimiter", 5, fSubSecondDelimiters, fPage, true); //$NON-NLS-1$
fSSecFieldDelim.setPreferenceStore(fPreferenceStore);
fSSecFieldDelim.load();
fSSecFieldDelim.setPropertyChangeListener(this);
- fTimePreference.initPatterns();
refresh();
return fPage;
}
@@ -219,9 +298,9 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
fDateFieldDelim.loadDefault();
fTimeFieldDelim.loadDefault();
fSSecFieldDelim.loadDefault();
+ fCombo.loadDefault();
- fTimePreference.setDefaults();
- fTimePattern = TmfTimePreferences.getTimePattern();
+ fPreferenceMap = TmfTimePreferences.getInstance().getDefaultPreferenceMap();
displayExample();
}
@@ -232,8 +311,10 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
fDateFieldDelim.store();
fTimeFieldDelim.store();
fSSecFieldDelim.store();
+ fCombo.store();
- TmfTimePreferences.setTimePattern(fTimePattern);
+ TmfTimestampFormat.updateDefaultFormats();
+ TmfSignalManager.dispatchSignal(new TmfTimestampFormatUpdateSignal(null));
displayExample();
}
@@ -282,27 +363,22 @@ public class TmfTimestampFormatPage extends PreferencePage implements IWorkbench
}
void updatePatterns() {
- if (TmfTimePreferences.DATIME.equals(fProperty)) {
- fTimePreference.setDateTimeFormat(fChangedProperty);
- } else if (TmfTimePreferences.SUBSEC.equals(fProperty)) {
- fTimePreference.setSSecFormat(fChangedProperty);
- } else if (TmfTimePreferences.DATE_DELIMITER.equals(fProperty)) {
- fTimePreference.setDateFieldSep(fChangedProperty);
- } else if (TmfTimePreferences.TIME_DELIMITER.equals(fProperty)) {
- fTimePreference.setTimeFieldSep(fChangedProperty);
- } else if (TmfTimePreferences.SSEC_DELIMITER.equals(fProperty)) {
- fTimePreference.setSSecFieldSep(fChangedProperty);
+ if (ITmfTimePreferencesConstants.DATIME.equals(fProperty) ||
+ ITmfTimePreferencesConstants.SUBSEC.equals(fProperty) ||
+ ITmfTimePreferencesConstants.DATE_DELIMITER.equals(fProperty) ||
+ ITmfTimePreferencesConstants.TIME_DELIMITER.equals(fProperty) ||
+ ITmfTimePreferencesConstants.SSEC_DELIMITER.equals(fProperty)) {
+ fPreferenceMap.put(fProperty, fChangedProperty);
}
- fTimePreference.updatePatterns();
- fTimePattern = TmfTimePreferences.getTimePattern();
}
private void displayExample() {
long ts = 1332170682500677380L;
- fPatternDisplay.setText(fTimePattern);
+ String timePattern = fTimePreference.computeTimePattern(fPreferenceMap);
+ fPatternDisplay.setText(timePattern);
fPatternDisplay.redraw();
- fExampleDisplay.setText(new TmfTimestampFormat(fTimePattern).format(ts));
+ fExampleDisplay.setText(new TmfTimestampFormat(timePattern).format(ts));
fExampleDisplay.redraw();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/messages.properties
new file mode 100644
index 0000000..446e998
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/properties/messages.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2013 Ericsson
+#
+# 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:
+# Marc-Andre Laperle - Initial API and implementation
+###############################################################################
+
+TmfTimestampFormatPage_LocalTime=Local time
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java
index c256a31..ec4f1b4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java
@@ -10,6 +10,7 @@
* Florian Wininger - Initial API and implementation
* Alexandre Montplaisir - Refactoring, performance tweaks
* Bernd Hufmann - Updated signal handling
+ * Marc-Andre Laperle - Add time zone preference
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.statesystem;
@@ -30,6 +31,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
@@ -501,6 +503,23 @@ public class TmfStateSystemExplorer extends TmfView {
};
thread.start();
}
+
+ /**
+ * Update the display to use the updated timestamp format
+ *
+ * @param signal the incoming signal
+ * @since 2.1
+ */
+ @TmfSignalHandler
+ public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal) {
+ Thread thread = new Thread("State system visualizer update") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ updateTable();
+ }
+ };
+ thread.start();
+ }
/**
* Function for the delete TreeItem
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java
index 615ad1e..54223a7 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java
@@ -10,6 +10,7 @@
* Patrick Tasse - Initial API and implementation
* Bernd Hufmann - Updated signal handling
* Geneviève Bastien - Move code to provide base classes for time graph view
+ * Marc-Andre Laperle - Add time zone preference
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.timegraph;
@@ -35,6 +36,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
@@ -684,6 +686,14 @@ public abstract class AbstractTimeGraphView extends TmfView {
});
}
+ /**
+ * @param signal the format of the timestamps was updated.
+ */
+ @TmfSignalHandler
+ public void updateTimeFormat( final TmfTimestampFormatUpdateSignal signal){
+ this.fTimeGraphCombo.refresh();
+ }
+
// ------------------------------------------------------------------------
// Internal
// ------------------------------------------------------------------------
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
index 1853547..143369b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
@@ -10,6 +10,7 @@
* Ruslan A. Scherbakov, Intel - Initial API and implementation
* Alvaro Sanchez-Leon - Updated for TMF
* Patrick Tasse - Refactoring
+ * Marc-Andre Laperle - Add time zone preference
*****************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
@@ -18,7 +19,12 @@ import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
import org.eclipse.swt.SWT;
@@ -97,8 +103,16 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
*/
public TimeGraphScale(Composite parent, TimeGraphColorScheme colors) {
super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED);
+ TmfSignalManager.register(this);
addMouseListener(this);
addMouseMoveListener(this);
+ TimeDraw.updateTimeZone();
+ }
+
+ @Override
+ public void dispose() {
+ TmfSignalManager.deregister(this);
+ super.dispose();
}
/**
@@ -528,6 +542,19 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
fTime1bak = fTimeProvider.getTime1();
}
}
+
+ /**
+ * Update the display to use the updated timestamp format
+ *
+ * @param signal the incoming signal
+ * @since 2.1
+ */
+ @TmfSignalHandler
+ public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal) {
+ TimeDraw.updateTimeZone();
+ Utils.updateTimeZone();
+ redraw();
+ }
}
abstract class TimeDraw {
@@ -551,6 +578,21 @@ abstract class TimeDraw {
protected static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
protected static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
+ protected static final SimpleDateFormat formatArray[] = {
+ SEC_FORMAT, SEC_FORMAT_HEADER, MIN_FORMAT, MIN_FORMAT_HEADER,
+ HOURS_FORMAT, HOURS_FORMAT_HEADER, DAY_FORMAT, DAY_FORMAT_HEADER, MONTH_FORMAT, YEAR_FORMAT
+ };
+
+ /**
+ * Updates the timezone using the preferences.
+ */
+ public static void updateTimeZone() {
+ final TimeZone timeZone = TmfTimePreferences.getInstance().getTimeZone();
+ for (SimpleDateFormat sdf : formatArray) {
+ sdf.setTimeZone(timeZone);
+ }
+ }
+
static String sep(long n) {
StringBuilder retVal = new StringBuilder();
String s = Long.toString(n);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
index 298967c..78f8ba7 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
@@ -6,10 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Intel Corporation - Initial API and implementation
- * Ruslan A. Scherbakov, Intel - Initial API and implementation
- * Alvaro Sanchez-Leon - Udpated for TMF
- * Patrick Tasse - Refactoring
+ * Intel Corporation - Initial API and implementation
+ * Ruslan A. Scherbakov, Intel - Initial API and implementation
+ * Alvaro Sanchez-Leon - Udpated for TMF
+ * Patrick Tasse - Refactoring
+ * Marc-Andre Laperle - Add time zone preference
*****************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
@@ -18,7 +19,9 @@ import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
+import java.util.TimeZone;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
import org.eclipse.swt.graphics.Color;
@@ -80,6 +83,17 @@ public class Utils {
private static final long SEC_IN_NS = 1000000000;
private static final long MILLISEC_IN_NS = 1000000;
+ /**
+ * Update the time and date formats to use the current time zone
+ *
+ * @since 2.1
+ */
+ public static void updateTimeZone() {
+ TimeZone timeZone = TmfTimePreferences.getInstance().getTimeZone();
+ TIME_FORMAT.setTimeZone(timeZone);
+ DATE_FORMAT.setTimeZone(timeZone);
+ }
+
static Rectangle clone(Rectangle source) {
return new Rectangle(source.x, source.y, source.width, source.height);
}