Skip to content

Commit 7696302

Browse files
committed
Fix import of BOY files that carry no widget version=1.0.0
1 parent 24f4992 commit 7696302

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

app/display/model/src/main/java/org/csstudio/display/builder/model/Widget.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2015-2016 Oak Ridge National Laboratory.
2+
* Copyright (c) 2015-2022 Oak Ridge National Laboratory.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -80,6 +80,9 @@ public class Widget
8080
*/
8181
public static final Version BASE_WIDGET_VERSION = new Version(2, 0, 0);
8282

83+
/** Typical version of legacy BOY display widgets */
84+
public static final Version TYPICAL_LEGACY_WIDGET_VERSION = new Version(1, 0, 0);
85+
8386
// These user data keys are reserved for internal use
8487
// of the framework.
8588
//

app/display/model/src/main/java/org/csstudio/display/builder/model/persist/ModelReader.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2015-2020 Oak Ridge National Laboratory.
2+
* Copyright (c) 2015-2022 Oak Ridge National Laboratory.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -362,7 +362,18 @@ private static Version readVersion(final Element element)
362362
{
363363
final String text = element.getAttribute(XMLTags.VERSION);
364364
if (text.isEmpty())
365+
{
366+
// Does widget look like a legacy widget without a type?
367+
// Then assume 1.0.0
368+
if (element.getAttribute(XMLTags.TYPE).isEmpty() &&
369+
element.getAttribute("typeId") != null &&
370+
element.getAttribute("typeId").startsWith("org.csstudio.opibuilder.widgets."))
371+
return Widget.TYPICAL_LEGACY_WIDGET_VERSION;
372+
373+
// Otherwise assume it's a new version but created by a script or manually
374+
// so didn't bother to populate more than absolutely necessary
365375
return Widget.BASE_WIDGET_VERSION;
376+
}
366377
return Version.parse(text);
367378
}
368379
}

0 commit comments

Comments
 (0)