1 /*******************************************************************************
2 * Copyright (c) 2017 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.markers
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
17 import org
.eclipse
.tracecompass
.internal
.tmf
.core
.markers
.MarkerConfigXmlParser
;
18 import org
.eclipse
.tracecompass
.internal
.tmf
.core
.markers
.MarkerSet
;
19 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
22 * Utility class for markers
24 public class MarkerUtils
{
26 private static final String MARKER_SET_KEY
= "marker.set"; //$NON-NLS-1$
28 private static MarkerSet fDefaultMarkerSet
= null;
31 * Get the default marker set
33 * @return the default marker set, or null if none is set
35 public static synchronized @Nullable MarkerSet
getDefaultMarkerSet() {
36 String id
= getDialogSettings().get(MARKER_SET_KEY
);
38 fDefaultMarkerSet
= null;
40 if (fDefaultMarkerSet
== null || !fDefaultMarkerSet
.getId().equals(id
)) {
41 for (MarkerSet markerSet
: MarkerConfigXmlParser
.getMarkerSets()) {
42 if (markerSet
.getId().equals(id
)) {
43 fDefaultMarkerSet
= markerSet
;
48 return fDefaultMarkerSet
;
52 * Set the default marker set
55 * the default marker set, or null to set none
57 public static synchronized void setDefaultMarkerSet(@Nullable MarkerSet markerSet
) {
58 fDefaultMarkerSet
= markerSet
;
59 String id
= (markerSet
== null) ?
null : markerSet
.getId();
60 getDialogSettings().put(MARKER_SET_KEY
, id
);
63 private static IDialogSettings
getDialogSettings() {
64 IDialogSettings settings
= Activator
.getDefault().getDialogSettings();
65 IDialogSettings dialogSettings
= settings
.getSection(MarkerUtils
.class.getName());
66 if (dialogSettings
== null) {
67 dialogSettings
= settings
.addNewSection(MarkerUtils
.class.getName());
69 return dialogSettings
;