Skip to content

Commit a9fe316

Browse files
committed
Merge branch 'master-clean' into alarm_apps
2 parents d3a15a2 + bf8042f commit a9fe316

132 files changed

Lines changed: 3431 additions & 1541 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import static org.phoebus.applications.alarm.AlarmSystem.logger;
1111

1212
import java.time.Instant;
13-
import java.util.ArrayList;
14-
import java.util.Arrays;
15-
import java.util.List;
16-
import java.util.Optional;
13+
import java.util.*;
1714
import java.util.logging.Level;
1815
import java.util.regex.Pattern;
1916
import java.util.stream.Collectors;
@@ -657,8 +654,20 @@ public void update(final List<AlarmInfoRow> active,
657654
{
658655
limitAlarmCount(active, active_count, "Active Alarms: ");
659656
limitAlarmCount(acknowledged, acknowledged_count, "Acknowledged Alarms: ");
657+
658+
/* Previously selected items that are still valid with the new alarm lists */
659+
List<String> active_selection = extractOldSelection(this.active, active);
660+
List<String> acknowledged_selection = extractOldSelection(this.acknowledged, acknowledged);
661+
660662
update(active_rows, active);
661663
update(acknowledged_rows, acknowledged);
664+
665+
/* Move this up here out of update(), doesn't need to be ran twice */
666+
selectRows();
667+
668+
/* Now that the table has been appropriately updated, select any still valid pvs */
669+
selectPvs(this.active, active_selection);
670+
selectPvs(this.acknowledged, acknowledged_selection);
662671
}
663672

664673
/** Limit the number of alarms
@@ -704,29 +713,29 @@ private void update(final ObservableList<AlarmInfoRow> items, final List<AlarmIn
704713
else // Trim items, input has fewer elements
705714
items.remove(N, items.size());
706715

707-
selectRows();
708716
}
709717

710718
/** Select all rows that match the current 'search' pattern */
711719
private void selectRows()
712720
{
721+
active.getSelectionModel().clearSelection();
722+
acknowledged.getSelectionModel().clearSelection();
723+
713724
final String glob = search.getText().trim();
714-
if (glob.isEmpty())
725+
if(glob.isEmpty())
715726
{
716-
active.getSelectionModel().clearSelection();
717-
acknowledged.getSelectionModel().clearSelection();
718727
return;
719728
}
720729

721730
final Pattern pattern = Pattern.compile(RegExHelper.fullRegexFromGlob(glob),
722-
Pattern.CASE_INSENSITIVE);
731+
Pattern.CASE_INSENSITIVE);
732+
723733
selectRows(active, pattern);
724734
selectRows(acknowledged, pattern);
725735
}
726736

727737
private void selectRows(final TableView<AlarmInfoRow> table, final Pattern pattern)
728738
{
729-
table.getSelectionModel().clearSelection();
730739

731740
int i = 0;
732741
for (AlarmInfoRow row : table.getItems())
@@ -737,4 +746,44 @@ private void selectRows(final TableView<AlarmInfoRow> table, final Pattern patte
737746
++i;
738747
}
739748
}
749+
750+
/** adds a list of pvs to the selection **/
751+
private void selectPvs(final TableView<AlarmInfoRow> table, final List<String> pvs) {
752+
HashSet<String> pv_set = new HashSet<>(pvs);
753+
754+
int i = 0;
755+
for (AlarmInfoRow row : table.getItems())
756+
{
757+
if(pv_set.contains(row.pv.get()))
758+
{
759+
table.getSelectionModel().select(i);
760+
}
761+
++i;
762+
}
763+
}
764+
765+
/** Find all selected items that are still valid in this new state **/
766+
private List<String> extractOldSelection(final TableView<AlarmInfoRow> table, final List<AlarmInfoRow> input)
767+
{
768+
/* input objects are probably not equal, compare them by their pv names */
769+
final HashSet<String> pvs = new HashSet<>();
770+
for(AlarmInfoRow row : input)
771+
{
772+
pvs.add(row.pv.get());
773+
}
774+
775+
final List<String> validSelection = new ArrayList<>();
776+
for(AlarmInfoRow row : table.getSelectionModel().getSelectedItems())
777+
{
778+
String pv = row.pv.get();
779+
if(pvs.contains(pv))
780+
{
781+
validSelection.add(pv);
782+
}
783+
}
784+
785+
table.getSelectionModel().clearSelection();
786+
787+
return validSelection;
788+
}
740789
}

app/display/linearmeter/src/main/java/org/csstudio/display/extra/widgets/linearmeter/LinearMeterRepresentation.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,11 @@ private void valueChanged(WidgetProperty<?> property, Object old_value, Object n
344344
meter.setRange(observedMin - 1, observedMax + 1, false);
345345
newObservedMinAndMaxValues = false;
346346
linearMeterScaleHasChanged = true;
347-
} else if (meter.linearMeterScale.getValueRange().getLow() != 0.0 || meter.linearMeterScale.getValueRange().getHigh() != 100) {
348-
meter.setRange(0.0, 100.0, false);
349-
linearMeterScaleHasChanged = true;
347+
} else if (Double.isNaN(observedMin) || Double.isNaN(observedMax)) {
348+
if (meter.linearMeterScale.getValueRange().getLow() != 0.0 || meter.linearMeterScale.getValueRange().getHigh() != 100) {
349+
meter.setRange(0.0, 100.0, false);
350+
linearMeterScaleHasChanged = true;
351+
}
350352
}
351353
}
352354
}

app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/NavigationTabsWidget.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
*/
4848
public class NavigationTabsWidget extends VisibleWidget
4949
{
50+
private static final WidgetColor DEFAULT_SELECT_COLOR = new WidgetColor(236, 236, 236);
51+
private static final WidgetColor DEFAULT_DESELECT_COLOR = new WidgetColor(200, 200, 200);
5052
/** Widget descriptor */
5153
public static final WidgetDescriptor WIDGET_DESCRIPTOR =
5254
new WidgetDescriptor("navtabs", WidgetCategory.STRUCTURE,
@@ -61,10 +63,17 @@ public Widget createWidget()
6163
}
6264
};
6365

64-
// 'state' structure that describes one state
66+
// 'tab' structure that describes one tab
6567
private static final StructuredWidgetProperty.Descriptor propTab =
6668
new StructuredWidgetProperty.Descriptor(WidgetPropertyCategory.BEHAVIOR, "tab", "Tab");
6769

70+
// Elements of the 'tab' structure
71+
private static final WidgetPropertyDescriptor<WidgetColor> propIndividualSelectedColor =
72+
CommonWidgetProperties.newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "selected_color", "Selected Color");
73+
74+
private static final WidgetPropertyDescriptor<WidgetColor> propIndividualDeselectedColor =
75+
CommonWidgetProperties.newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "deselected_color", "Deselected Color");
76+
6877
/** Structure for one tab item and its embedded display */
6978
public static class TabProperty extends StructuredWidgetProperty
7079
{
@@ -77,8 +86,10 @@ public TabProperty(final Widget widget, final int index)
7786
Arrays.asList(propName.createProperty(widget, "Tab " + (index + 1)),
7887
propFile.createProperty(widget, ""),
7988
propMacros.createProperty(widget, new Macros()),
80-
propGroupName.createProperty(widget, "")
81-
));
89+
propGroupName.createProperty(widget, ""),
90+
propIndividualSelectedColor.createProperty(widget, DEFAULT_SELECT_COLOR),
91+
propIndividualDeselectedColor.createProperty(widget, DEFAULT_DESELECT_COLOR)
92+
));
8293
}
8394
/** @return Tab name */
8495
public WidgetProperty<String> name() { return getElement(0); }
@@ -88,6 +99,10 @@ public TabProperty(final Widget widget, final int index)
8899
public WidgetProperty<Macros> macros() { return getElement(2); }
89100
/** @return Optional sub-group of file */
90101
public WidgetProperty<String> group() { return getElement(3); }
102+
/** @return Tab color when selected */
103+
public WidgetProperty<WidgetColor> individual_selected_color() { return getElement(4); }
104+
/** @return Tab color when not selected */
105+
public WidgetProperty<WidgetColor> individual_deselected_color() { return getElement(5); }
91106
}
92107

93108
// 'tabs' array
@@ -101,15 +116,18 @@ public TabProperty(final Widget widget, final int index)
101116
private static final WidgetPropertyDescriptor<Integer> propTabSpacing =
102117
CommonWidgetProperties.newIntegerPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "tab_spacing", "Tab Spacing");
103118

104-
private static final WidgetPropertyDescriptor<WidgetColor> propDeselectedColor =
105-
CommonWidgetProperties.newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "deselected_color", "Deselected Color");
106-
119+
private static final WidgetPropertyDescriptor<Boolean> propEnablePerTabColors =
120+
CommonWidgetProperties.newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "enable_per_tab_colors", "Per Tab Colors");
107121

122+
private static final WidgetPropertyDescriptor<WidgetColor> propDeselectedColor =
123+
CommonWidgetProperties.newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "deselected_color", "Deselected Color");
124+
108125
private volatile ArrayWidgetProperty<TabProperty> tabs;
109126
private volatile WidgetProperty<Direction> direction;
110127
private volatile WidgetProperty<Integer> tab_width;
111128
private volatile WidgetProperty<Integer> tab_height;
112129
private volatile WidgetProperty<Integer> tab_spacing;
130+
private volatile WidgetProperty<Boolean> enable_per_tab_colors;
113131
private volatile WidgetProperty<WidgetColor> selected_color;
114132
private volatile WidgetProperty<WidgetColor> deselected_color;
115133
private volatile WidgetProperty<WidgetFont> font;
@@ -134,8 +152,9 @@ protected void defineProperties(final List<WidgetProperty<?>> properties)
134152
properties.add(tab_width = propTabWidth.createProperty(this, ActionButtonWidget.DEFAULT_WIDTH));
135153
properties.add(tab_height = propTabHeight.createProperty(this, ActionButtonWidget.DEFAULT_HEIGHT));
136154
properties.add(tab_spacing = propTabSpacing.createProperty(this, 2));
137-
properties.add(selected_color = propSelectedColor.createProperty(this, new WidgetColor(236, 236, 236)));
138-
properties.add(deselected_color = propDeselectedColor.createProperty(this, new WidgetColor(200, 200, 200)));
155+
properties.add(enable_per_tab_colors = propEnablePerTabColors.createProperty(this, false));
156+
properties.add(selected_color = propSelectedColor.createProperty(this, DEFAULT_SELECT_COLOR));
157+
properties.add(deselected_color = propDeselectedColor.createProperty(this, DEFAULT_DESELECT_COLOR));
139158
properties.add(font = propFont.createProperty(this, WidgetFontService.get(NamedWidgetFonts.DEFAULT)));
140159
properties.add(active = propActiveTab.createProperty(this, 0));
141160
properties.add(embedded_model = runtimeModel.createProperty(this, null));
@@ -171,6 +190,12 @@ public WidgetProperty<Integer> propTabSpacing()
171190
return tab_spacing;
172191
}
173192

193+
/** @return 'enable_per_tab_colors' property */
194+
public WidgetProperty<Boolean> propEnablePerTabColors()
195+
{
196+
return enable_per_tab_colors;
197+
}
198+
174199
/** @return 'selected_color' property */
175200
public WidgetProperty<WidgetColor> propSelectedColor()
176201
{

0 commit comments

Comments
 (0)