Skip to content

Commit

Permalink
Merge pull request #1583 from ISISComputingGroup/ticket_7921_gui
Browse files Browse the repository at this point in the history
Show title and Users in dataweb option was added to the dashboard
  • Loading branch information
Thomas Lohnert authored Sep 12, 2023
2 parents c92e5b0 + ed845e5 commit 3d60ee7
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
import uk.ac.stfc.isis.ibex.epics.switching.ObservableFactory;
import uk.ac.stfc.isis.ibex.epics.switching.OnInstrumentSwitch;
import uk.ac.stfc.isis.ibex.epics.switching.SwitchableObservable;
import uk.ac.stfc.isis.ibex.epics.switching.WritableFactory;
import uk.ac.stfc.isis.ibex.epics.writing.Writable;
import uk.ac.stfc.isis.ibex.instrument.InstrumentUtils;
import uk.ac.stfc.isis.ibex.instrument.channels.BooleanChannel;
import uk.ac.stfc.isis.ibex.instrument.channels.CompressedCharWaveformChannel;
import uk.ac.stfc.isis.ibex.instrument.channels.LongChannel;
import uk.ac.stfc.isis.ibex.instrument.channels.StringChannel;

/**
Expand All @@ -39,23 +43,34 @@
public class DashboardObservables extends Closer {

private static final String USERS = "ED:SURNAME";

private static final String DISPLAY_TITLE = "DAE:TITLE:DISPLAY";

private final ObservableFactory obsFactory = new ObservableFactory(OnInstrumentSwitch.SWITCH);

private final Map<DashboardPv, SwitchableObservable<String>> valueObservables = new EnumMap<>(DashboardPv.class);
private final Map<DashboardPv, SwitchableObservable<String>> labelObservables = new EnumMap<>(DashboardPv.class);

private final WritableFactory writeFactory = new WritableFactory(OnInstrumentSwitch.SWITCH);

/**
* An observable for the list of users to be displayed on the dashboard.
*/

public final ForwardingObservable<String> users;

/**
* An observable for the title on the dashboard.
*/
public final ForwardingObservable<String> title;

/**
* An observable for the flag which denotes whether the title is displayed on the dashboard.
*/
public final ForwardingObservable<Boolean> displayTitle;

/**
* An observable for the flag which denotes whether the title is displayed on the dashboard.
*/
public final Writable<Long> displayTitleSetter;

/**
* An observable for the run state on the dashboard.
*/
Expand All @@ -71,7 +86,12 @@ private SwitchableObservable<String> getObservable(final String pv) {
public DashboardObservables() {
users = registerForClose(obsFactory.getSwitchableObservable(new CompressedCharWaveformChannel(),
InstrumentUtils.addPrefix(USERS)));


displayTitleSetter = writeFactory.getSwitchableWritable(new LongChannel(),
InstrumentUtils.addPrefix(DISPLAY_TITLE));

displayTitle = obsFactory.getSwitchableObservable(new BooleanChannel(),
InstrumentUtils.addPrefix(DISPLAY_TITLE));
final DaeObservables dae = new DaeObservables();
title = registerForClose(dae.title);
runState = registerForClose(dae.runState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class ExperimentDetailsVariables {

/** The observable for display title status. **/
public final ForwardingObservable<Boolean> displayTitle;

/** The writable for display title status. **/
public final Writable<Long> displayTitleSetter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

import uk.ac.stfc.isis.ibex.epics.adapters.TextUpdatedObservableAdapter;
import uk.ac.stfc.isis.ibex.epics.adapters.UpdatedObservableAdapter;
import uk.ac.stfc.isis.ibex.epics.observing.BooleanWritableObservableAdapter;
import uk.ac.stfc.isis.ibex.epics.observing.ForwardingObservable;
import uk.ac.stfc.isis.ibex.epics.pv.Closer;
import uk.ac.stfc.isis.ibex.epics.writing.Writable;
import uk.ac.stfc.isis.ibex.model.UpdatedValue;

/**
Expand All @@ -33,16 +35,28 @@ public class TitlePanelModel extends Closer {
private final UpdatedObservableAdapter<String> title;
private final UpdatedObservableAdapter<String> users;

/**
* An observable for whether to display the title on the web dashboard.
*/
public final BooleanWritableObservableAdapter displayTitle;


/**
* Create the model.
* @param title an observable on the title
* @param users an observable on the users
* @param displayTitle is an observable and writer on the displayTitle
* @param displayTitleSetter is an observable and writer on the displayTitle visibility
*/
public TitlePanelModel(ForwardingObservable<String> title, ForwardingObservable<String> users) {
public TitlePanelModel(ForwardingObservable<String> title, ForwardingObservable<String> users, ForwardingObservable<Boolean> displayTitle, Writable<Long> displayTitleSetter) {
this.title = registerForClose(new TextUpdatedObservableAdapter(title));
this.users = registerForClose(new TextUpdatedObservableAdapter(users));
}
this.displayTitle = registerForClose(new BooleanWritableObservableAdapter(displayTitleSetter, displayTitle));



}

/**
* Gets the title.
* @return the title
Expand All @@ -58,4 +72,14 @@ public UpdatedValue<String> title() {
public UpdatedValue<String> users() {
return users;
}

/**
* Gets the displayTitle.
* @return the displayTitle
*/
public BooleanWritableObservableAdapter displayTitle() {
return displayTitle;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class DashboardView {
private final BannerModel bannerModel = new BannerModel(dashboard.observables());

private final TitlePanelModel titleModel =
new TitlePanelModel(dashboard.observables().title, dashboard.observables().users);
new TitlePanelModel(dashboard.observables().title, dashboard.observables().users, dashboard.observables().displayTitle, dashboard.observables().displayTitleSetter);

/**
* Create the dashboard view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;

import uk.ac.stfc.isis.ibex.ui.Utils;
import uk.ac.stfc.isis.ibex.ui.dashboard.models.TitlePanelModel;
Expand All @@ -41,7 +44,8 @@ public class TitlePanel extends Composite {

private final Label title;
private final Label users;

private Button btnDisplayTitle;

/**
* Default constructor, creates the panel.
*
Expand All @@ -60,7 +64,7 @@ public TitlePanel(Composite parent, int style, TitlePanelModel model, Font font)
this.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

Label lblTitle = new Label(this, SWT.NONE);
lblTitle.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblTitle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
lblTitle.setFont(font);
lblTitle.setText("Title:");

Expand All @@ -71,14 +75,27 @@ public TitlePanel(Composite parent, int style, TitlePanelModel model, Font font)
title.setToolTipText("Experiment title");

Label lblUsers = new Label(this, SWT.NONE);
lblUsers.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblUsers.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
lblUsers.setFont(font);
lblUsers.setText("Users:");

users = new Label(this, SWT.NONE);
users.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
users.setFont(font);
users.setText("Experiment users");
users.setToolTipText("Experiment users");

btnDisplayTitle = new Button(this, SWT.CHECK);
btnDisplayTitle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
btnDisplayTitle.setFont(font);
btnDisplayTitle.setText("Show Title and Users in Dataweb Dashboard Page");
btnDisplayTitle.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
model.displayTitle().uncheckedSetValue(btnDisplayTitle.getSelection());
}
});

if (model != null) {
bind(model);
Expand All @@ -103,7 +120,11 @@ public String convert(String fromObject) {
WidgetProperties.tooltipText().observe(title),
BeanProperties.<Object, String>value("value").observe(model.title()),
null, literalAmpersands);

bindingContext.bindValue(WidgetProperties.buttonSelection().observe(btnDisplayTitle),
BeanProperties.value("value").observe(model.displayTitle().value()));
bindingContext.bindValue(WidgetProperties.enabled().observe(btnDisplayTitle),
BeanProperties.value("value").observe(model.displayTitle().canSetValue()));

if (Utils.SHOULD_HIDE_USER_INFORMATION) {
users.setText("<Users unavailable>");
users.setToolTipText("<Users unavailable>");
Expand All @@ -116,7 +137,7 @@ public String convert(String fromObject) {
bindingContext.bindValue(
WidgetProperties.tooltipText().observe(users),
BeanProperties.<Object, String>value("value").observe(model.users()),
null, new UpdateValueStrategy<String, String>().setConverter(deJsoner));
null, new UpdateValueStrategy<String, String>().setConverter(deJsoner));
}
}
}
}

0 comments on commit 3d60ee7

Please sign in to comment.