If a user has some custom parsers defined in their workspace, and
they upgrade past
1b7d4a9, we can still look in the old location
so that they do not have to re-create the parsers manually.
Change-Id: Idd1c5f92f58d925be7494c75b8d1b668f487c119
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/21651
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
IP-Clean: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME =
Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME).toString();
+ /** Legacy path to the XML definitions file (in the UI plug-in)
+ * TODO Remove once we feel the transition phase is over. */
+ private static final String CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME_LEGACY =
+ Activator.getDefault().getStateLocation().removeLastSegments(1).addTrailingSeparator()
+ .append("org.eclipse.linuxtools.tmf.ui") //$NON-NLS-1$
+ .append(CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME).toString();
+
private static final String CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomTxtTraceDefinition_definitionRootElement;
private static final String DEFINITION_ELEMENT = Messages.CustomTxtTraceDefinition_definition;
private static final String NAME_ATTRIBUTE = Messages.CustomTxtTraceDefinition_name;
* @return The loaded trace definitions
*/
public static CustomTxtTraceDefinition[] loadAll() {
+ File defaultFile = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
+ File legacyFile = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME_LEGACY);
+
+ /*
+ * If there is no file at the expected location, check the legacy
+ * location instead.
+ */
+ if (!defaultFile.exists() && legacyFile.exists()) {
+ CustomTxtTraceDefinition[] oldDefs = loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME_LEGACY);
+ for (CustomTxtTraceDefinition def : oldDefs) {
+ /* Save in the new location */
+ def.save();
+ }
+ }
+
return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
}
protected static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME =
Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();
+ /** Legacy path to the XML definitions file (in the UI plug-in)
+ * TODO Remove once we feel the transition phase is over. */
+ private static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME_LEGACY =
+ Activator.getDefault().getStateLocation().removeLastSegments(1).addTrailingSeparator()
+ .append("org.eclipse.linuxtools.tmf.ui") //$NON-NLS-1$
+ .append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();
+
private static final String CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomXmlTraceDefinition_definitionRootElement;
private static final String DEFINITION_ELEMENT = Messages.CustomXmlTraceDefinition_definition;
private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name;
* @return The loaded trace definitions
*/
public static CustomXmlTraceDefinition[] loadAll() {
+ File defaultFile = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
+ File legacyFile = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME_LEGACY);
+
+ /*
+ * If there is no file at the expected location, check the legacy
+ * location instead.
+ */
+ if (!defaultFile.exists() && legacyFile.exists()) {
+ CustomXmlTraceDefinition[] oldDefs = loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME_LEGACY);
+ for (CustomXmlTraceDefinition def : oldDefs) {
+ /* Save in the new location */
+ def.save();
+ }
+ }
+
return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
}