Skip to content

Commit 1a36d1d

Browse files
author
AdrianPotter
committed
Merge with master
2 parents e2abd31 + 977cb19 commit 1a36d1d

File tree

61 files changed

+15514
-8204
lines changed

Some content is hidden

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

61 files changed

+15514
-8204
lines changed

base/uk.ac.stfc.isis.ibex.activemq/src/uk/ac/stfc/isis/ibex/activemq/message/MessageParser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public void closeJMSConsumer() throws JMSException {
9696
@Override
9797
@SuppressWarnings("checkstyle:emptyblock")
9898
public void run() {
99-
System.out.println("Thread Running");
10099
while (running) {
101100
try {
102101
if (jmsConsumer != null) {

base/uk.ac.stfc.isis.ibex.client.tycho.parent/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@
253253
<module>../uk.ac.stfc.isis.ibex.nicos</module>
254254
<module>../uk.ac.stfc.isis.ibex.ui.weblinks.tests</module>
255255
<module>../uk.ac.stfc.isis.ibex.nicos.tests</module>
256+
<module>../uk.ac.stfc.isis.ibex.managermode</module>
257+
<module>../uk.ac.stfc.isis.ibex.managermode.tests</module>
256258
</modules>
257259
</project>
258260

base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/MacroValueValidatorTest.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package uk.ac.stfc.isis.ibex.configserver.tests.editing;
2121

2222
import static org.junit.Assert.*;
23+
import static org.mockito.Matchers.any;
2324
import static org.mockito.Mockito.*;
2425

2526
import java.beans.PropertyChangeEvent;
@@ -126,40 +127,15 @@ public void if_macro_is_null_then_showWarningIcon_property_left_as_false() {
126127
}
127128

128129
@Test
129-
public void if_validation_string_empty_then_not_OK() {
130+
public void if_validation_string_empty_then_OK() {
130131
// Arrange
131132
MacroValueValidator macroValidator = getValidator(macro);
132133

133134
// Act
134135
IStatus status = macroValidator.validate("");
135136

136137
// Assert
137-
assertFalse(status.isOK());
138-
}
139-
140-
@Test
141-
public void if_validation_string_empty_then_blank_warning_message() {
142-
// Arrange
143-
MacroValueValidator macroValidator = getValidator(macro);
144-
145-
// Act
146-
IStatus status = macroValidator.validate("");
147-
148-
// Assert
149-
assertEquals(MacroValueValidator.NO_MESSAGE, status.getMessage());
150-
}
151-
152-
@Test
153-
public void if_validation_string_empty_then_nameIsValid_property_change_to_false() {
154-
// Arrange
155-
MacroValueValidator macroValidator = getValidator(macro);
156-
157-
// Act
158-
macroValidator.validate("");
159-
160-
// Assert
161-
verify(mockNameIsValidListener, times(1)).propertyChange(changeCaptor.capture());
162-
assertEquals(false, changeCaptor.getValue().getNewValue());
138+
assertTrue(status.isOK());
163139
}
164140

165141
@Test

base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/editing/MacroValueValidator.java

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,42 @@
3838
*
3939
*/
4040
public class MacroValueValidator extends ModelObject implements IValidator {
41-
public static final String NAME_IS_VALID = "nameIsValid";
41+
/**
42+
* Property change that is fired when the name validity changes.
43+
*/
44+
public static final String NAME_IS_VALID = "nameIsValid";
45+
/**
46+
* Property change that is fired when the Show warning icon changes.
47+
*/
4248
public static final String SHOW_WARNING_ICON = "showWarningIcon";
4349

50+
/**
51+
* The message that is displayed when there is no error.
52+
*/
4453
public static final String NO_MESSAGE = "";
54+
/**
55+
* The message that is displayed when the macro does not match it's regex
56+
* pattern.
57+
*/
4558
public static final String PATTERN_MISMATCH_MESSAGE = "Macro value must match the pattern shown";
59+
/**
60+
* The message that is displayed when the regex pattern is invalid.
61+
*/
4662
public static final String PATTERN_INVALID = "Macro regex pattern invalid";
4763

4864
private final Label messageDisplayer;
4965
private Macro macro;
5066
private boolean nameIsValid = true;
5167
private boolean showWarningIcon = false;
5268

69+
/**
70+
* Constructor for the validator.
71+
*
72+
* @param macro
73+
* The macro to validate.
74+
* @param messageDisplayer
75+
* The label to display the error message on.
76+
*/
5377
public MacroValueValidator(Macro macro, Label messageDisplayer) {
5478
this.messageDisplayer = messageDisplayer;
5579
this.macro = macro;
@@ -62,9 +86,11 @@ public IStatus validate(Object text) {
6286
setShowWarningIcon(false);
6387

6488
try {
65-
if (macro == null || text.equals("")) {
66-
returnStatus = setError(NO_MESSAGE);
67-
} else if (!matchesPattern((String) text)) {
89+
if (macro == null) {
90+
returnStatus = setError(NO_MESSAGE);
91+
} else if (text.equals("")) {
92+
returnStatus = setNoError();
93+
} else if (!matchesPattern((String) text)) {
6894
setShowWarningIcon(true);
6995
returnStatus = setError(PATTERN_MISMATCH_MESSAGE);
7096
} else {
@@ -101,22 +127,50 @@ private boolean matchesPattern(String text) {
101127
return Pattern.matches(pattern, text);
102128
}
103129

130+
/**
131+
* Set the macro that this validator is looking at.
132+
*
133+
* @param macro
134+
* The macro to validate.
135+
*/
104136
public void setMacro(Macro macro) {
105137
this.macro = macro;
106138
}
107139

140+
/**
141+
* Get whether the macro name is valid.
142+
*
143+
* @return True if the macro name is valid
144+
*/
108145
public boolean getNameIsValid() {
109146
return nameIsValid;
110147
}
111148

149+
/**
150+
* Set if the macro name is valid.
151+
*
152+
* @param nameIsValid
153+
* True if the macro name is valid.
154+
*/
112155
public void setNameIsValid(boolean nameIsValid) {
113156
firePropertyChange(NAME_IS_VALID, this.nameIsValid, this.nameIsValid = nameIsValid);
114157
}
115158

159+
/**
160+
* Get whether the warning icon should be shown.
161+
*
162+
* @return True if the warning icon should be shown.
163+
*/
116164
public boolean getShowWarningIcon() {
117165
return showWarningIcon;
118166
}
119167

168+
/**
169+
* Set whether the warning icon should be shown.
170+
*
171+
* @param showWarningIcon
172+
* True if the warning icon should be shown.
173+
*/
120174
public void setShowWarningIcon(boolean showWarningIcon) {
121175
firePropertyChange(SHOW_WARNING_ICON, this.showWarningIcon, this.showWarningIcon = showWarningIcon);
122176
}

base/uk.ac.stfc.isis.ibex.dae.tests/src/uk/ac/stfc/isis/ibex/dae/tests/periods/WritingXmlFromPeriodSettingsTest.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package uk.ac.stfc.isis.ibex.dae.tests.periods;
2121

2222
import static org.hamcrest.CoreMatchers.*;
23-
import static org.junit.Assert.assertThat;
23+
import static org.junit.Assert.*;
2424

2525
import java.io.IOException;
2626
import java.net.MalformedURLException;
@@ -116,6 +116,20 @@ public void setup_source_is_updated() {
116116
assertThat(periodSettings.getSetupSource(), is(newValue));
117117
}
118118

119+
@Test
120+
public void setup_source_is_not_updated_if_null() {
121+
122+
// Arrange: Check that null is not the current setup source.
123+
assertNotEquals(periodSettings.getSetupSource(), null);
124+
125+
// Act: Try to set a setup source as null.
126+
periodSettings.setSetupSource(null);
127+
reloadSettingsFromCurrentValues();
128+
129+
// Assert: Check that null has been ignored.
130+
assertNotEquals(periodSettings.getSetupSource(), null);
131+
}
132+
119133

120134
@Test
121135
public void period_file_is_updated() {
@@ -139,6 +153,20 @@ public void period_control_type_is_updated() {
139153
assertThat(periodSettings.getPeriodType(), is(newValue));
140154
}
141155

156+
@Test
157+
public void period_control_type_is_not_updated_if_null() {
158+
159+
// Arrange: Check that null is not the current period type.
160+
assertNotEquals(periodSettings.getPeriodType(), null);
161+
162+
// Act: Try to set a period type as null.
163+
periodSettings.setPeriodType(null);
164+
reloadSettingsFromCurrentValues();
165+
166+
// Assert: Check that null has been ignored.
167+
assertNotEquals(periodSettings.getPeriodType(), null);
168+
}
169+
142170
@Test
143171
public void software_periods_is_updated() {
144172
int newValue = 12121;

base/uk.ac.stfc.isis.ibex.dae/src/uk/ac/stfc/isis/ibex/dae/experimentsetup/periods/XMLBackedPeriodSettings.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
import uk.ac.stfc.isis.ibex.dae.xml.XmlNode;
3434
import uk.ac.stfc.isis.ibex.logger.IsisLog;
3535

36+
/**
37+
* Gets the DAE period settings from XML.
38+
*/
3639
public class XMLBackedPeriodSettings extends PeriodSettings {
3740

3841
private static final Logger LOG = IsisLog.getLogger(XMLBackedPeriodSettings.class);
@@ -51,6 +54,9 @@ public class XMLBackedPeriodSettings extends PeriodSettings {
5154

5255
private final ArrayList<XmlBackedPeriod> periods = new ArrayList<>();
5356

57+
/**
58+
* Constructor.
59+
*/
5460
public XMLBackedPeriodSettings() {
5561
nodes.add(setupSource);
5662
nodes.add(periodFile);
@@ -68,45 +74,79 @@ public XMLBackedPeriodSettings() {
6874
xmlFile = new XmlFile(nodes);
6975
}
7076

77+
/**
78+
* Sets the xml.
79+
* @param xml the xml to set
80+
*/
7181
public void setXml(String xml) {
7282
xmlFile.setXml(xml);
7383
initialiseFromXml();
7484
}
7585

86+
/**
87+
* Gets the xml from file.
88+
* @return the xml
89+
*/
7690
public String xml() {
7791
return xmlFile.toString();
7892
}
7993

94+
/**
95+
* {@inheritDoc}
96+
*/
8097
@Override
8198
public void setSetupSource(PeriodSetupSource value) {
99+
if (value == null) {
100+
LOG.info("Error, attempted to set a null PeriodSetupSource.");
101+
return;
102+
}
82103
super.setSetupSource(value);
83104
setupSource.setValue(value);
84105
}
85106

107+
/**
108+
* {@inheritDoc}
109+
*/
86110
@Override
87111
public void setNewPeriodFile(String value) {
88112
super.setNewPeriodFile(value);
89113
periodFile.setValue(value);
90114
}
91115

116+
/**
117+
* {@inheritDoc}
118+
*/
92119
@Override
93120
public void setPeriodType(PeriodControlType value) {
121+
if (value == null) {
122+
LOG.info("Error, attempted to set a null PeriodControlType.");
123+
return;
124+
}
94125
super.setPeriodType(value);
95126
periodType.setValue(value);
96127
}
97128

129+
/**
130+
* {@inheritDoc}
131+
*/
98132
@Override
99133
public void setSoftwarePeriods(int value) {
100134
super.setSoftwarePeriods(value);
101135
softwarePeriods.setValue(value);
102136
}
103137

138+
/**
139+
* {@inheritDoc}
140+
*/
104141
@Override
105142
public void setHardwarePeriods(double value) {
106143
super.setHardwarePeriods(value);
107144
hardwarePeriods.setValue(value);
108145
}
109146

147+
/**
148+
* {@inheritDoc}
149+
*/
110150
@Override
111151
public void setOutputDelay(double value) {
112152
super.setOutputDelay(value);

base/uk.ac.stfc.isis.ibex.devicescreens/src/uk/ac/stfc/isis/ibex/devicescreens/components/ComponentType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public enum ComponentType {
9797
PRESSURE_GAUGE,
9898
/** 3D magnet component type. */
9999
SCIMAG3D,
100+
/** Stress rig component type. */
101+
STRESS_RIG,
100102
/** Polarises, Guide and Collimation for MUONFE. */
101103
PGC,
102104
/** Detector motion system component type. */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
4+
<attributes>
5+
<attribute name="maven.pomderived" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9+
<classpathentry kind="src" output="target/classes" path="src">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
16+
<classpathentry kind="output" path="target/classes"/>
17+
</classpath>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>uk.ac.stfc.isis.ibex.managermode.tests</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.ManifestBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.SchemaBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>org.eclipse.pde.PluginNature</nature>
33+
</natures>
34+
</projectDescription>

0 commit comments

Comments
 (0)