Skip to content

Commit 78f7e7d

Browse files
committed
Merge remote-tracking branch 'origin' into image_offset
2 parents fa0ab84 + 0214c07 commit 78f7e7d

File tree

45 files changed

+1177
-231
lines changed

Some content is hidden

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

45 files changed

+1177
-231
lines changed

app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java

Lines changed: 134 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@
2121
import javafx.application.Platform;
2222
import javafx.beans.InvalidationListener;
2323
import javafx.beans.property.SimpleIntegerProperty;
24+
import javafx.beans.property.SimpleObjectProperty;
2425
import javafx.beans.property.SimpleStringProperty;
2526
import javafx.collections.FXCollections;
2627
import javafx.collections.ObservableList;
2728
import javafx.geometry.Insets;
2829
import javafx.scene.control.Button;
2930
import javafx.scene.control.Label;
3031
import javafx.scene.control.SelectionMode;
32+
import javafx.scene.control.Spinner;
33+
import javafx.scene.control.TableCell;
3134
import javafx.scene.control.TableColumn;
3235
import javafx.scene.control.TableView;
3336
import javafx.scene.control.Tooltip;
37+
import javafx.scene.control.cell.ComboBoxTableCell;
3438
import javafx.scene.control.cell.TextFieldTableCell;
3539
import javafx.scene.layout.BorderPane;
3640
import javafx.scene.layout.VBox;
37-
import javafx.scene.paint.Color;
3841
import javafx.util.converter.DefaultStringConverter;
39-
import javafx.util.converter.IntegerStringConverter;
42+
4043

4144
/** Table for editing list of {@link TitleDetailDelay}
4245
*
@@ -46,6 +49,10 @@
4649
@SuppressWarnings("nls")
4750
public class TitleDetailDelayTable extends BorderPane
4851
{
52+
private enum Option_d {
53+
mailto, cmd, sevrpv
54+
};
55+
4956
private final ObservableList<TitleDetailDelay> items = FXCollections.observableArrayList();
5057

5158
private final TableView<TitleDetailDelay> table = new TableView<>(items);
@@ -82,11 +89,15 @@ public List<TitleDetailDelay> getItems()
8289
/** Table cell for 'delay'
8390
* Disables for actions that don't use the delay
8491
*/
85-
class DelayTableCell extends TextFieldTableCell<TitleDetailDelay, Integer>
92+
class DelayTableCell extends TableCell<TitleDetailDelay, Integer>
8693
{
94+
private final Spinner<Integer> spinner;
95+
8796
public DelayTableCell()
8897
{
89-
super(new IntegerStringConverter());
98+
this.spinner = new Spinner<>(0, 10000, 1);
99+
spinner.setEditable(true);
100+
this.spinner.valueProperty().addListener((observable, oldValue, newValue) -> commitEdit(newValue));
90101
}
91102

92103
@Override
@@ -96,18 +107,26 @@ public void updateItem(Integer item, boolean empty)
96107

97108
if (empty ||
98109
getTableRow() == null ||
99-
getTableRow().getItem() == null)
110+
getTableRow().getItem() == null ||
111+
spinner == null) {
112+
setGraphic(null);
100113
return;
114+
}
101115
if (getTableRow().getItem().hasDelay())
102116
{
103-
setDisable(false);
104-
setTextFill(Color.BLACK);
117+
spinner.setDisable(false);
118+
spinner.getEditor().setStyle("-fx-text-inner-color: black;");
119+
//spinner.getEditor().setTextFill(Color.BLACK);
105120
}
106121
else
107122
{
108-
setDisable(true);
109-
setTextFill(Color.LIGHTGRAY);
123+
spinner.setDisable(true);
124+
spinner.getEditor().setStyle("-fx-text-inner-color: lightgray;");
125+
//spinner.getEditor().setTextFill(Color.LIGHTGRAY);
110126
}
127+
128+
this.spinner.getValueFactory().setValue(item);
129+
setGraphic(spinner);
111130
}
112131
}
113132

@@ -139,26 +158,49 @@ private void createTable()
139158
table.getColumns().add(col);
140159

141160
col = new TableColumn<>("Detail");
142-
col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().detail.replace("\n", "\\n")));
143-
col.setCellFactory(column -> new TextFieldTableCell<>(new DefaultStringConverter()));
144-
col.setOnEditCommit(event ->
145-
{
146-
final int row = event.getTablePosition().getRow();
147-
final TitleDetailDelay item = new TitleDetailDelay(items.get(row).title, event.getNewValue().replace("\\n", "\n"), items.get(row).delay);
148-
items.set(row, item);
161+
col.setSortable(false);
162+
table.getColumns().add(col);
149163

164+
// Use a combo box to specified the action
165+
TableColumn<TitleDetailDelay, Option_d> tmpOptionCol = new TableColumn<>("Option");
166+
tmpOptionCol.setCellFactory(ComboBoxTableCell.forTableColumn(Option_d.values()));
167+
tmpOptionCol
168+
.setCellValueFactory(cell -> new SimpleObjectProperty<Option_d>(getOptionFromDetail(cell.getValue())));
169+
tmpOptionCol.setOnEditCommit(edit -> {
170+
final int row = edit.getTablePosition().getRow();
171+
TitleDetailDelay tmpT = items.get(row);
172+
Option_d option = edit.getNewValue();
173+
TitleDetailDelay newTitleDetailDelay = setOptionToDetail(tmpT, option);
174+
items.set(row, newTitleDetailDelay);
150175
// Trigger editing the delay.
151-
if (item.hasDelay())
152-
UpdateThrottle.TIMER.schedule(() ->
153-
Platform.runLater(() ->
154-
{
155-
table.getSelectionModel().clearAndSelect(row);
156-
table.edit(row, table.getColumns().get(2));
157-
}),
158-
200, TimeUnit.MILLISECONDS);
176+
if (newTitleDetailDelay.hasDelay())
177+
UpdateThrottle.TIMER.schedule(() -> Platform.runLater(() -> {
178+
table.getSelectionModel().clearAndSelect(row);
179+
table.edit(row, table.getColumns().get(2));
180+
}), 200, TimeUnit.MILLISECONDS);
159181
});
160-
col.setSortable(false);
161-
table.getColumns().add(col);
182+
tmpOptionCol.setEditable(true);
183+
col.getColumns().add(tmpOptionCol);
184+
185+
// Use a textfield to set info for detail
186+
TableColumn<TitleDetailDelay, String> infoCol = new TableColumn<>("Info");
187+
infoCol.setCellValueFactory(cell -> new SimpleStringProperty(getInfoFromDetail(cell.getValue())));
188+
infoCol.setCellFactory(column -> new TextFieldTableCell<>(new DefaultStringConverter()));
189+
infoCol.setOnEditCommit(event -> {
190+
final int row = event.getTablePosition().getRow();
191+
TitleDetailDelay tmpT = items.get(row);
192+
String newInfo = event.getNewValue();
193+
TitleDetailDelay newTitleDetailDelay = setInfoToDetail(tmpT, newInfo);
194+
items.set(row, newTitleDetailDelay);
195+
// Trigger editing the delay.
196+
if (newTitleDetailDelay.hasDelay())
197+
UpdateThrottle.TIMER.schedule(() -> Platform.runLater(() -> {
198+
table.getSelectionModel().clearAndSelect(row);
199+
table.edit(row, table.getColumns().get(2));
200+
}), 200, TimeUnit.MILLISECONDS);
201+
});
202+
infoCol.setSortable(false);
203+
col.getColumns().add(infoCol);
162204

163205
TableColumn<TitleDetailDelay, Integer> delayCol = new TableColumn<>("Delay");
164206
delayCol.setCellValueFactory(cell -> new SimpleIntegerProperty(cell.getValue().delay).asObject());
@@ -172,6 +214,72 @@ private void createTable()
172214
table.getColumns().add(delayCol);
173215
}
174216

217+
/**
218+
* This function extract the command option from detail "option:info"
219+
*
220+
* @param titleDetailDelay
221+
* @return enum Option_d either mailto or cmd
222+
*/
223+
private Option_d getOptionFromDetail(TitleDetailDelay titleDetailDelay) {
224+
Option_d option = null;
225+
String detail = titleDetailDelay != null ? titleDetailDelay.detail : null;
226+
String[] split = detail != null ? detail.split(":") : null;
227+
String optionString = split != null && split.length > 0 ? split[0] : null;
228+
try {
229+
option = optionString != null ? Option_d.valueOf(optionString) : Option_d.mailto;
230+
} catch (Exception e) {
231+
option = Option_d.mailto;
232+
}
233+
return option;
234+
}
235+
236+
/**
237+
* This function extract the info from detail "option:info"
238+
*
239+
* @param titleDetailDelay
240+
* @return information eg : mail or command
241+
*/
242+
private String getInfoFromDetail(TitleDetailDelay titleDetailDelay) {
243+
String info = "";
244+
String detail = titleDetailDelay != null ? titleDetailDelay.detail : null;
245+
String[] split = detail != null ? detail.split(":") : null;
246+
info = split != null && split.length > 1 ? split[1] : "";
247+
return info;
248+
}
249+
250+
/**
251+
* Create a new TitleDetailDelay from a given option
252+
* @param titleDetailDelay
253+
* @param option
254+
* @return new TitleDetailDelay
255+
*/
256+
private TitleDetailDelay setOptionToDetail(TitleDetailDelay titleDetailDelay, Option_d option) {
257+
TitleDetailDelay newTitleDetailDelay = titleDetailDelay;
258+
if (titleDetailDelay != null && option != null) {
259+
String info = getInfoFromDetail(titleDetailDelay);
260+
String detail = option.toString() + ":" + info;
261+
newTitleDetailDelay = new TitleDetailDelay(titleDetailDelay.title, detail, titleDetailDelay.delay);
262+
}
263+
return newTitleDetailDelay;
264+
}
265+
266+
/**
267+
* Create a new TitleDetailDelay from a given info
268+
* @param titleDetailDelay
269+
* @param option
270+
* @return new TitleDetailDelay
271+
*/
272+
private TitleDetailDelay setInfoToDetail(TitleDetailDelay titleDetailDelay, String info) {
273+
TitleDetailDelay newTitleDetailDelay = titleDetailDelay;
274+
if (titleDetailDelay != null && info != null) {
275+
Option_d option = getOptionFromDetail(titleDetailDelay);
276+
String newInfo = info.replace("\\n", "\n");
277+
String detail = option.toString() + ":" + newInfo;
278+
newTitleDetailDelay = new TitleDetailDelay(titleDetailDelay.title, detail, titleDetailDelay.delay);
279+
}
280+
return newTitleDetailDelay;
281+
}
282+
175283
private void createButtons()
176284
{
177285
add.setTooltip(new Tooltip("Add a new table item."));

app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PVSamples.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,17 @@ public PlotSample get(final int index)
115115
if (lock.getReadHoldCount() <= 0 && ! lock.isWriteLockedByCurrentThread())
116116
logger.log(Level.WARNING, "Missing lock", new Exception("Stack Trace"));
117117

118+
// If the data point is 'real'/raw then return it
118119
final int raw_count = getRawSize();
119120
if (index < raw_count)
120121
return getRawSample(index);
121-
// Last sample is valid, so it should still apply 'now'
122+
// Else, create a 'virtual' point by transforming its
123+
// timestamp to 'now' to display the currently implied value
122124
final PlotSample sample = getRawSample(raw_count-1);
123125
if (Instant.now().compareTo(sample.getPosition()) < 0)
124126
return sample;
125127
else
126-
return new PlotSample(sample.getSource(), VTypeHelper.transformTimestampToNow(sample.getVType()));
128+
return new PlotSample(sample.getSource(), VTypeHelper.transformTimestampToNow(sample.getVType()), true);
127129
}
128130

129131
/** Get 'raw' sample, no continuation until 'now'

app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public class PlotSample implements PlotDataItem<Instant>
4747
/** Waveform index */
4848
private AtomicInteger waveform_index;
4949

50+
/** Designates if this is a real data point, or just a 'virtual' one
51+
* created only for mechanical purposes (i.e. to connect the last data point to 'now')
52+
*/
53+
private boolean isVirtualSample = false;
54+
5055
/** Initialize with valid control system value
5156
* @param waveform_index Waveform index
5257
* @param source Info about the source of this sample
@@ -100,6 +105,12 @@ public PlotSample(final String source, final VType value)
100105
this(default_waveform_index, source, value);
101106
}
102107

108+
public PlotSample(final String source, final VType value, boolean isVirtualSample)
109+
{
110+
this(default_waveform_index, source, value);
111+
this.isVirtualSample = isVirtualSample;
112+
}
113+
103114
/** Initialize with (error) info, creating a non-plottable sample 'now'
104115
* @param source Data source hint
105116
* @param info Text used for info as well as error message
@@ -210,6 +221,11 @@ public String getInfo()
210221
return info;
211222
}
212223

224+
@Override
225+
public boolean isVirtual() {
226+
return this.isVirtualSample;
227+
}
228+
213229
@Override
214230
public String toString()
215231
{

app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/Perspective.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ private void createContextMenu()
198198
items.addAll(add_data);
199199

200200
items.add(new SeparatorMenuItem());
201-
items.add(new PrintAction(plot.getPlot()));
202-
items.add(new SaveSnapshotAction(plot.getPlot()));
201+
// Get screenshot of actual plot without optional toolbar
202+
items.add(new PrintAction(plot.getPlot().getCenter()));
203+
items.add(new SaveSnapshotAction(plot.getPlot().getCenter()));
203204

204205
SelectionService.getInstance().setSelection(this, Arrays.asList(DatabrowserSelection.of(model, plot)));
205206
List<ContextMenuEntry> supported = ContextMenuService.getInstance().listSupportedContextMenuEntries();

app/display/convert-medm/src/main/java/org/csstudio/opibuilder/adl2boy/translator/StripChart2Model.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void processWidget(ADLWidget adlWidget) throws Exception
4141
setColor(plotcom.getBackgroundColor(), CommonWidgetProperties.propBackgroundColor);
4242
}
4343

44-
widgetModel.propTimeRange().setValue(Math.round(plotWidget.getPeriod()) + " " + plotWidget.getUnits());
44+
widgetModel.propStart().setValue(Math.round(plotWidget.getPeriod()) + " " + plotWidget.getUnits());
4545

4646
final List<ADLPen> pens = plotWidget.getPens();
4747
if (pens.size() > 0)

app/display/editor/doc/rules.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ of the rule are accessible in the expression.
4848

4949
- 0 - OK
5050

51-
- 1 - Major
51+
- 1 - Minor
5252

53-
- 2 - Minor
53+
- 2 - Major
5454

5555
Value as Expression
5656
-------------------

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public class Messages
116116
Stripchart_Description,
117117
Stripchart_LabelFont,
118118
Stripchart_Name,
119-
Stripchart_TimeRange,
119+
Stripchart_StartTime,
120+
Stripchart_EndTime,
120121
Style,
121122
Style_Group,
122123
Style_Line,

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
*******************************************************************************/
88
package org.csstudio.display.builder.model.widgets;
99

10-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propBackgroundColor;
11-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propEnabled;
12-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propFont;
13-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propForegroundColor;
14-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propFormat;
15-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propIncrement;
16-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLimitsFromPV;
17-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propMaximum;
18-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propMinimum;
19-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPrecision;
20-
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propShowUnits;
21-
2210
import java.util.Arrays;
2311
import java.util.List;
2412

@@ -35,11 +23,11 @@
3523
import org.csstudio.display.builder.model.persist.NamedWidgetFonts;
3624
import org.csstudio.display.builder.model.persist.WidgetColorService;
3725
import org.csstudio.display.builder.model.persist.WidgetFontService;
38-
import org.csstudio.display.builder.model.properties.CommonWidgetProperties;
39-
import org.csstudio.display.builder.model.properties.WidgetColor;
40-
import org.csstudio.display.builder.model.properties.WidgetFont;
26+
import org.csstudio.display.builder.model.properties.*;
4127
import org.phoebus.ui.vtype.FormatOption;
4228

29+
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.*;
30+
4331
/** Widget that represents a spinner
4432
* @author Amanda Carpenter
4533
*/
@@ -79,6 +67,8 @@ public Widget createWidget()
7967
private volatile WidgetProperty<Boolean> buttons_on_left;
8068
private volatile WidgetProperty<Boolean> enabled;
8169
private volatile WidgetProperty<WidgetFont> font;
70+
private volatile WidgetProperty<HorizontalAlignment> horizontal_alignment;
71+
private volatile WidgetProperty<VerticalAlignment> vertical_alignment;
8272

8373
/** Constructor */
8474
public SpinnerWidget()
@@ -102,6 +92,8 @@ protected void defineProperties(final List<WidgetProperty<?>> properties)
10292
properties.add(increment = propIncrement.createProperty(this, 1.0));
10393
properties.add(buttons_on_left = propButtonsOnLeft.createProperty(this, false));
10494
properties.add(enabled = propEnabled.createProperty(this, true));
95+
properties.add(horizontal_alignment = propHorizontalAlignment.createProperty(this, HorizontalAlignment.LEFT));
96+
properties.add(vertical_alignment = propVerticalAlignment.createProperty(this, VerticalAlignment.TOP));
10597
}
10698

10799
@Override
@@ -181,4 +173,17 @@ public WidgetProperty<WidgetFont> propFont()
181173
{
182174
return font;
183175
}
176+
177+
/** @return 'horizontal_alignment' property */
178+
public WidgetProperty<HorizontalAlignment> propHorizontalAlignment()
179+
{
180+
return horizontal_alignment;
181+
}
182+
183+
/** @return 'vertical_alignment' property */
184+
public WidgetProperty<VerticalAlignment> propVerticalAlignment()
185+
{
186+
return vertical_alignment;
187+
}
188+
184189
}

0 commit comments

Comments
 (0)