Skip to content

Commit 398d64f

Browse files
Merge remote-tracking branch 'origin/master' into Release_14.0.0
2 parents 4f374d2 + 9e42850 commit 398d64f

File tree

7 files changed

+406
-74
lines changed

7 files changed

+406
-74
lines changed

base/uk.ac.stfc.isis.ibex.ui.moxas/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.201.200",
1818
org.hamcrest.library;bundle-version="1.3.0",
1919
uk.ac.stfc.isis.ibex.model;bundle-version="1.0.0",
2020
uk.ac.stfc.isis.ibex.epics;bundle-version="1.0.0",
21-
uk.ac.stfc.isis.ibex.configserver;bundle-version="1.0.0"
21+
uk.ac.stfc.isis.ibex.configserver;bundle-version="1.0.0",
22+
uk.ac.stfc.isis.ibex.e4.ui;bundle-version="1.0.0"
2223
Export-Package: uk.ac.stfc.isis.ibex.ui.moxas.views

base/uk.ac.stfc.isis.ibex.ui.moxas/src/uk/ac/stfc/isis/ibex/ui/moxas/views/MoxaInfoPanel.java

Lines changed: 186 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
/*
2+
* This file is part of the ISIS IBEX application. Copyright (C) 2012-2023
3+
* Science & Technology Facilities Council. All rights reserved.
4+
*
5+
* This program is distributed in the hope that it will be useful. This program
6+
* and the accompanying materials are made available under the terms of the
7+
* Eclipse Public License v1.0 which accompanies this distribution. EXCEPT AS
8+
* EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM AND
9+
* ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
10+
* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more
11+
* details.
12+
*
13+
* You should have received a copy of the Eclipse Public License v1.0 along with
14+
* this program; if not, you can obtain a copy from
15+
* https://www.eclipse.org/org/documents/epl-v10.php or
16+
* http://opensource.org/licenses/eclipse-1.0.php
17+
*/
18+
19+
/*
20+
* Copyright (C) 2013-2014 Research Councils UK (STFC)
21+
*
22+
* This file is part of the Instrument Control Project at ISIS.
23+
*
24+
* This code and information are provided "as is" without warranty of any kind,
25+
* either expressed or implied, including but not limited to the implied
26+
* warranties of merchantability and/or fitness for a particular purpose.
27+
*/
28+
129
package uk.ac.stfc.isis.ibex.ui.moxas.views;
230

331
import java.beans.PropertyChangeEvent;
@@ -19,8 +47,11 @@
1947
import org.eclipse.swt.layout.GridData;
2048
import org.eclipse.swt.layout.GridLayout;
2149
import org.eclipse.swt.widgets.Button;
50+
import org.eclipse.swt.widgets.Label;
2251
import org.eclipse.swt.widgets.Composite;
2352
import org.eclipse.swt.widgets.TreeItem;
53+
import org.eclipse.wb.swt.SWTResourceManager;
54+
2455

2556
import uk.ac.stfc.isis.ibex.configserver.configuration.Ioc;
2657

@@ -36,6 +67,7 @@ public class MoxaInfoPanel extends Composite {
3667
private static final int COLUMN_WIDTH = 500;
3768
private static final int COLUMN_WIDTH_NARROW = 150;
3869

70+
private static final String UP_STATUS = "up";
3971
/**
4072
* The constructor.
4173
*
@@ -48,67 +80,11 @@ public MoxaInfoPanel(Composite parent, int style, MoxasViewModel model) {
4880
setLayout(new GridLayout(1, false));
4981

5082
final var viewer = new TreeViewer(this, SWT.FULL_SELECTION);
51-
TreeViewerColumn moxaPortColumn = new TreeViewerColumn(viewer, SWT.NONE);
52-
moxaPortColumn.getColumn().setText("Physical MOXA port");
53-
moxaPortColumn.getColumn().setWidth(COLUMN_WIDTH);
54-
55-
moxaPortColumn.setLabelProvider(new ColumnLabelProvider() {
56-
@Override
57-
public String getText(Object element) {
58-
if (element instanceof MoxaList) {
59-
MoxaList list = MoxaList.class.cast(element);
60-
String name = list.name;
61-
return name;
62-
} else {
63-
MoxaModelObject p = (MoxaModelObject) element;
64-
return p.getPhysPort();
65-
}
66-
}
67-
});
68-
TreeViewerColumn comPortColumn = new TreeViewerColumn(viewer, SWT.NONE);
69-
comPortColumn.getColumn().setText("COM port");
70-
comPortColumn.getColumn().setWidth(COLUMN_WIDTH_NARROW);
71-
72-
comPortColumn.setLabelProvider(new ColumnLabelProvider() {
73-
@Override
74-
public String getText(Object element) {
75-
if (element instanceof ArrayList<?>) {
76-
return null;
77-
}
78-
MoxaModelObject p = (MoxaModelObject) element;
79-
return p.getComPort();
80-
}
81-
});
82-
TreeViewerColumn iocColumn = new TreeViewerColumn(viewer, SWT.NONE);
83-
iocColumn.getColumn().setText("Connected IOC");
84-
iocColumn.getColumn().setWidth(COLUMN_WIDTH);
85-
86-
iocColumn.setLabelProvider(new ColumnLabelProvider() {
87-
@Override
88-
public Color getForeground(Object element) {
89-
// Change the text colour of cells where a port is connected to multiple IOCs
90-
if (element instanceof MoxaModelObject) {
91-
MoxaModelObject p = (MoxaModelObject) element;
92-
List<Ioc> iocs = p.getIocs();
93-
94-
if (iocs.size() > 1) {
95-
return new Color(255, 0, 0);
96-
}
97-
}
98-
return super.getForeground(element);
99-
}
100-
101-
@Override
102-
public String getText(Object element) {
103-
if (element instanceof ArrayList<?>) {
104-
return null;
105-
}
106-
MoxaModelObject p = (MoxaModelObject) element;
107-
List<Ioc> iocs = p.getIocs();
108-
109-
return iocs.stream().map(Ioc::getName).collect(joining(", "));
110-
}
111-
});
83+
makePhysicalPortColumn(viewer);
84+
makeComPortColumn(viewer);
85+
makeConnectedIOCColumn(viewer);
86+
makeStatusColumn(viewer);
87+
makeAdditionInfoColumn(viewer);
11288

11389
viewer.setContentProvider(new MoxaTableContentProvider());
11490

@@ -131,10 +107,10 @@ public void treeExpanded(TreeEvent e) {
131107
TreeItem item = (TreeItem) e.item;
132108
model.addExpanded(item.getText());
133109
}
134-
});
135-
110+
});
111+
136112
Composite expansionComposite = new Composite(this, SWT.FILL);
137-
expansionComposite.setLayout(new GridLayout(3, true));
113+
expansionComposite.setLayout(new GridLayout(5, true));
138114
expandButton = new Button(expansionComposite, SWT.NONE);
139115
expandButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
140116
expandButton.setText("\u25BC Expand All");
@@ -155,6 +131,11 @@ public void widgetSelected(SelectionEvent e) {
155131
}
156132
});
157133

134+
Label refreshLabel = new Label(expansionComposite, SWT.NONE);
135+
refreshLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 3, 1));
136+
refreshLabel.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
137+
refreshLabel.setText("Items will refresh every 30 seconds");
138+
158139
model.addUiThreadPropertyChangeListener("moxaMappings", new PropertyChangeListener() {
159140
@Override
160141
public void propertyChange(PropertyChangeEvent evt) {
@@ -164,8 +145,8 @@ public void propertyChange(PropertyChangeEvent evt) {
164145
model.refresh();
165146
}
166147
});
167-
168-
model.addUiThreadPropertyChangeListener("expanded", new PropertyChangeListener() {
148+
149+
model.addUiThreadPropertyChangeListener("expanded", new PropertyChangeListener() {
169150
@Override
170151
public void propertyChange(PropertyChangeEvent evt) {
171152
// Re-expand previously expanded items
@@ -186,4 +167,143 @@ public void propertyChange(PropertyChangeEvent evt) {
186167
});
187168
}
188169

170+
/**
171+
* @param viewer
172+
*/
173+
private void makeComPortColumn(final TreeViewer viewer) {
174+
TreeViewerColumn comPortColumn = new TreeViewerColumn(viewer, SWT.NONE);
175+
comPortColumn.getColumn().setText("COM port");
176+
comPortColumn.getColumn().setWidth(COLUMN_WIDTH_NARROW);
177+
178+
comPortColumn.setLabelProvider(new ColumnLabelProvider() {
179+
@Override
180+
public String getText(Object element) {
181+
if (element instanceof ArrayList<?>) {
182+
return null;
183+
}
184+
MoxaModelObject p = (MoxaModelObject) element;
185+
return p.getComPort();
186+
}
187+
});
188+
}
189+
190+
/**
191+
* @param viewer
192+
*/
193+
private void makePhysicalPortColumn(final TreeViewer viewer) {
194+
TreeViewerColumn moxaPortColumn = new TreeViewerColumn(viewer, SWT.NONE);
195+
moxaPortColumn.getColumn().setText("Physical MOXA port");
196+
moxaPortColumn.getColumn().setWidth(COLUMN_WIDTH);
197+
198+
moxaPortColumn.setLabelProvider(new ColumnLabelProvider() {
199+
@Override
200+
public String getText(Object element) {
201+
if (element instanceof MoxaList) {
202+
MoxaList list = MoxaList.class.cast(element);
203+
String name = list.name;
204+
205+
// extracting uptime for conversion and display
206+
String[] parts = name.split("\\)\\(");
207+
if (1 < parts.length) {
208+
String uptime = parts[1].substring(0, parts[1].length() - 1);
209+
name = parts[0] + ") [Up " + MoxasViewModel.toDaysHoursMinutes(Long.valueOf(uptime) * 10) + "]";
210+
}
211+
return name;
212+
} else {
213+
MoxaModelObject p = (MoxaModelObject) element;
214+
return p.getPhysPort();
215+
}
216+
}
217+
});
218+
}
219+
220+
/**
221+
* @param viewer
222+
*/
223+
private void makeConnectedIOCColumn(final TreeViewer viewer) {
224+
TreeViewerColumn iocColumn = new TreeViewerColumn(viewer, SWT.NONE);
225+
iocColumn.getColumn().setText("Connected IOC");
226+
iocColumn.getColumn().setWidth(COLUMN_WIDTH_NARROW);
227+
228+
iocColumn.setLabelProvider(new ColumnLabelProvider() {
229+
@Override
230+
public Color getForeground(Object element) {
231+
// Change the text colour of cells where a port is connected to multiple IOCs
232+
if (element instanceof MoxaModelObject) {
233+
MoxaModelObject p = (MoxaModelObject) element;
234+
List<Ioc> iocs = p.getIocs();
235+
236+
if (iocs.size() > 1) {
237+
return new Color(255, 0, 0);
238+
}
239+
}
240+
return super.getForeground(element);
241+
}
242+
243+
@Override
244+
public String getText(Object element) {
245+
if (element instanceof ArrayList<?>) {
246+
return null;
247+
}
248+
MoxaModelObject p = (MoxaModelObject) element;
249+
List<Ioc> iocs = p.getIocs();
250+
251+
return iocs.stream().map(Ioc::getName).collect(joining(", "));
252+
}
253+
});
254+
}
255+
256+
/**
257+
* @param viewer
258+
*/
259+
private void makeStatusColumn(final TreeViewer viewer) {
260+
TreeViewerColumn infoColumn = new TreeViewerColumn(viewer, SWT.NONE);
261+
infoColumn.getColumn().setText("Status");
262+
infoColumn.getColumn().setWidth(COLUMN_WIDTH_NARROW);
263+
264+
infoColumn.setLabelProvider(new ColumnLabelProvider() {
265+
@Override
266+
public String getText(Object element) {
267+
if (element instanceof ArrayList<?>) {
268+
return null;
269+
}
270+
MoxaModelObject field = (MoxaModelObject) element;
271+
return field.getStatus();
272+
}
273+
274+
@Override
275+
public Color getForeground(Object element) {
276+
// Change the text colour of cells where a port is physically connected
277+
if (element instanceof MoxaModelObject) {
278+
MoxaModelObject field = (MoxaModelObject) element;
279+
280+
if (field.getStatus().equalsIgnoreCase(UP_STATUS)) {
281+
return new Color(0, 0, 255);
282+
}
283+
}
284+
return super.getForeground(element);
285+
}
286+
});
287+
}
288+
289+
/**
290+
* @param viewer
291+
*/
292+
private void makeAdditionInfoColumn(final TreeViewer viewer) {
293+
TreeViewerColumn infoColumn = new TreeViewerColumn(viewer, SWT.NONE);
294+
infoColumn.getColumn().setText("Additional Info");
295+
infoColumn.getColumn().setWidth(COLUMN_WIDTH);
296+
297+
infoColumn.setLabelProvider(new ColumnLabelProvider() {
298+
@Override
299+
public String getText(Object element) {
300+
if (element instanceof ArrayList<?>) {
301+
return null;
302+
}
303+
MoxaModelObject field = (MoxaModelObject) element;
304+
return field.getAdditionalInfo();
305+
}
306+
});
307+
}
308+
189309
}

base/uk.ac.stfc.isis.ibex.ui.moxas/src/uk/ac/stfc/isis/ibex/ui/moxas/views/MoxaModelObject.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* This file is part of the ISIS IBEX application. Copyright (C) 2012-2015
3+
* This file is part of the ISIS IBEX application. Copyright (C) 2012-2023
44
* Science & Technology Facilities Council. All rights reserved.
55
*
66
* This program is distributed in the hope that it will be useful. This program
@@ -44,18 +44,24 @@ public class MoxaModelObject extends ModelObject implements Comparable<MoxaModel
4444
private final String physport;
4545
private final String comport;
4646
private final List<Ioc> iocs;
47+
private final String status;
48+
private final String additionalInfo;
4749

4850
/**
4951
* Instantiates a new moxa mapping pair.
5052
*
5153
* @param physport physical moxa port number for a mapping.
5254
* @param comport COM port for a mapping.
5355
* @param iocs List of IOCs using the COM port.
56+
* @param status the Operation Status information
57+
* @param additionalInfo Any additional information available for the port
5458
*/
55-
public MoxaModelObject(String physport, String comport, List<Ioc> iocs) {
59+
public MoxaModelObject(String physport, String comport, List<Ioc> iocs, String status, String additionalInfo) {
5660
this.physport = physport;
5761
this.comport = comport;
5862
this.iocs = new ArrayList<Ioc>(iocs);
63+
this.additionalInfo = additionalInfo;
64+
this.status = status;
5965
}
6066

6167
/**
@@ -83,6 +89,21 @@ public String getComPort() {
8389
public List<Ioc> getIocs() {
8490
return new ArrayList<Ioc>(iocs);
8591
}
92+
93+
/**
94+
* @return status of the port
95+
*/
96+
public String getStatus() {
97+
return status;
98+
}
99+
100+
/**
101+
*
102+
* @return any additional information
103+
*/
104+
public String getAdditionalInfo() {
105+
return additionalInfo;
106+
}
86107

87108
/**
88109
* {@inheritDoc}

0 commit comments

Comments
 (0)