|
1 | 1 |
|
2 | 2 | /* |
3 | | - * This file is part of the ISIS IBEX application. Copyright (C) 2012-2017 |
| 3 | + * This file is part of the ISIS IBEX application. Copyright (C) 2012-2025 |
4 | 4 | * Science & Technology Facilities Council. All rights reserved. |
5 | 5 | * |
6 | 6 | * This program is distributed in the hope that it will be useful. This program |
|
36 | 36 | import uk.ac.stfc.isis.ibex.configserver.configuration.Block; |
37 | 37 | import uk.ac.stfc.isis.ibex.configserver.configuration.ComponentInfo; |
38 | 38 | import uk.ac.stfc.isis.ibex.configserver.configuration.Configuration; |
| 39 | +import uk.ac.stfc.isis.ibex.configserver.configuration.GlobalMacro; |
39 | 40 | import uk.ac.stfc.isis.ibex.configserver.configuration.Group; |
40 | 41 | import uk.ac.stfc.isis.ibex.configserver.configuration.Ioc; |
41 | 42 | import uk.ac.stfc.isis.ibex.configserver.configuration.Macro; |
@@ -142,7 +143,8 @@ public class EditableConfiguration extends ModelObject implements GroupNamesProv |
142 | 143 | /** Current error message to be displayed **/ |
143 | 144 | private String currentErrorMessage = noError; |
144 | 145 |
|
145 | | - |
| 146 | + /** The global macros associated with any configuration. */ |
| 147 | + private List<GlobalMacro> globalmacros; |
146 | 148 |
|
147 | 149 | /** |
148 | 150 | * Listener for block renaming events. |
@@ -180,69 +182,67 @@ public void propertyChange(PropertyChangeEvent evt) { |
180 | 182 | * @param pvs |
181 | 183 | * The PVs available to the configuration |
182 | 184 | */ |
183 | | - public EditableConfiguration( |
184 | | - Configuration config, |
185 | | - Collection<EditableIoc> iocs, |
186 | | - Collection<Configuration> components, |
187 | | - Collection<PV> pvs) { |
188 | | - this.name = config.name(); |
189 | | - this.description = config.description(); |
190 | | - this.synoptic = config.synoptic(); |
191 | | - this.isProtected = config.isProtected(); |
192 | | - this.isDynamic = config.isDynamic(); |
193 | | - this.configuresBlockGWAndArchiver = config.configuresBlockGWAndArchiver(); |
194 | | - originalProtectedFlag = this.isProtected; |
195 | | - this.allIocs = new ArrayList<>(); |
196 | | - this.managerMode = ManagerModeModel.getInstance(); |
197 | | - this.isSaveButtonEnabled = true; |
198 | | - this.enableSaveAsButton = true; |
199 | | - managerModePv = managerMode.getManagerModeObservable(); |
200 | | - |
201 | | - for (EditableIoc ioc : iocs) { |
202 | | - EditableIoc newIoc = new EditableIoc(ioc, ioc.getDescription()); |
203 | | - newIoc.setAvailableMacros(new ArrayList<>(ioc.getAvailableMacros())); |
204 | | - this.allIocs.add(newIoc); |
205 | | - } |
| 185 | + public EditableConfiguration(Configuration config, Collection<EditableIoc> iocs, |
| 186 | + Collection<Configuration> components, Collection<PV> pvs) { |
| 187 | + this.name = config.name(); |
| 188 | + this.description = config.description(); |
| 189 | + this.synoptic = config.synoptic(); |
| 190 | + this.isProtected = config.isProtected(); |
| 191 | + this.isDynamic = config.isDynamic(); |
| 192 | + this.configuresBlockGWAndArchiver = config.configuresBlockGWAndArchiver(); |
| 193 | + originalProtectedFlag = this.isProtected; |
| 194 | + this.allIocs = new ArrayList<>(); |
| 195 | + this.managerMode = ManagerModeModel.getInstance(); |
| 196 | + this.isSaveButtonEnabled = true; |
| 197 | + this.enableSaveAsButton = true; |
| 198 | + managerModePv = managerMode.getManagerModeObservable(); |
| 199 | + |
| 200 | + for (EditableIoc ioc : iocs) { |
| 201 | + EditableIoc newIoc = new EditableIoc(ioc, ioc.getDescription()); |
| 202 | + newIoc.setAvailableMacros(new ArrayList<>(ioc.getAvailableMacros())); |
| 203 | + this.allIocs.add(newIoc); |
| 204 | + } |
206 | 205 |
|
207 | | - this.history = new ArrayList<>(); |
| 206 | + this.history = new ArrayList<>(); |
208 | 207 |
|
209 | | - for (String date : config.getHistory()) { |
210 | | - this.history.add(date); |
211 | | - } |
| 208 | + for (String date : config.getHistory()) { |
| 209 | + this.history.add(date); |
| 210 | + } |
212 | 211 |
|
213 | | - this.pvs = new ArrayList<>(pvs); |
| 212 | + this.pvs = new ArrayList<>(pvs); |
214 | 213 |
|
215 | | - for (Block block : config.getBlocks()) { |
216 | | - EditableBlock eb = new EditableBlock(block); |
217 | | - allBlocks.add(eb); |
218 | | - addRenameListener(eb); |
219 | | - } |
| 214 | + for (Block block : config.getBlocks()) { |
| 215 | + EditableBlock eb = new EditableBlock(block); |
| 216 | + allBlocks.add(eb); |
| 217 | + addRenameListener(eb); |
| 218 | + } |
220 | 219 |
|
221 | | - for (Group group : config.getGroups()) { |
222 | | - if (!group.hasComponent()) { |
223 | | - editableGroups.add(new EditableGroup(this, group)); |
| 220 | + for (Group group : config.getGroups()) { |
| 221 | + if (!group.hasComponent()) { |
| 222 | + editableGroups.add(new EditableGroup(this, group)); |
| 223 | + } |
224 | 224 | } |
225 | | - } |
226 | | - |
227 | | - editableGroups = new ArrayList<>(DisplayUtils.removeOtherGroup(editableGroups)); |
228 | 225 |
|
229 | | - for (EditableIoc ioc : allIocs) { |
230 | | - iocMap.put(ioc.getName(), ioc); |
231 | | - } |
232 | | - initMacros(iocMap); |
| 226 | + editableGroups = new ArrayList<>(DisplayUtils.removeOtherGroup(editableGroups)); |
233 | 227 |
|
234 | | - for (Ioc ioc : config.getIocs()) { |
235 | | - addIoc(convertIoc(ioc)); |
236 | | - } |
| 228 | + for (EditableIoc ioc : allIocs) { |
| 229 | + iocMap.put(ioc.getName(), ioc); |
| 230 | + } |
| 231 | + initMacros(iocMap); |
| 232 | + |
| 233 | + for (Ioc ioc : config.getIocs()) { |
| 234 | + addIoc(convertIoc(ioc)); |
| 235 | + } |
237 | 236 |
|
238 | | - Collection<Configuration> selectedComponents = getComponentDetails(config.getComponents(), components); |
239 | | - editableComponents = new EditableComponents(selectedComponents, components); |
240 | | - editableComponents.addPropertyChangeListener(evt -> updateComponents()); |
| 237 | + Collection<Configuration> selectedComponents = getComponentDetails(config.getComponents(), components); |
| 238 | + editableComponents = new EditableComponents(selectedComponents, components); |
| 239 | + editableComponents.addPropertyChangeListener(evt -> updateComponents()); |
241 | 240 |
|
242 | | - updateComponents(); |
243 | | - setEnableSaveAsButton(); |
244 | | - addObserver(); |
245 | | - } |
| 241 | + updateComponents(); |
| 242 | + setEnableSaveAsButton(); |
| 243 | + addObserver(); |
| 244 | + this.globalmacros = config.getGlobalmacros(); |
| 245 | + } |
246 | 246 |
|
247 | 247 | private EditableIoc convertIoc(Ioc ioc) { |
248 | 248 | final EditableIoc generalIOC = iocMap.get(ioc.getName()); |
@@ -666,28 +666,31 @@ public void removeGroup(EditableGroup group) { |
666 | 666 | firePropertyChange("groups", groupsBefore, transformGroups()); |
667 | 667 | } |
668 | 668 |
|
669 | | - /** |
670 | | - * Return in a form suitable for saving as a configuration. |
671 | | - * |
672 | | - * @return the underlying configuration |
673 | | - */ |
674 | | - public Configuration asConfiguration() { |
675 | | - Configuration config = new Configuration(getName(), getDescription(), getSynoptic(), transformIocs(), transformBlocks(), |
676 | | - transformGroups(), transformComponents(), getHistory(), getIsProtected(), getIsDynamic(), getIfconfiguresBlockGWAndArchiver()); |
677 | | - return new ComponentFilteredConfiguration(config); |
678 | | - } |
| 669 | + /** |
| 670 | + * Return in a form suitable for saving as a configuration. |
| 671 | + * |
| 672 | + * @return the underlying configuration |
| 673 | + */ |
| 674 | + public Configuration asConfiguration() { |
| 675 | + Configuration config = new Configuration(getName(), getDescription(), getSynoptic(), transformIocs(), |
| 676 | + transformBlocks(), transformGroups(), transformComponents(), getHistory(), getIsProtected(), |
| 677 | + getIsDynamic(), getIfconfiguresBlockGWAndArchiver(), getGlobalmacros()); |
| 678 | + return new ComponentFilteredConfiguration(config); |
| 679 | + } |
679 | 680 |
|
680 | | - /** |
681 | | - * Return in a form suitable for saving as a component - ie without |
682 | | - * contained components. |
683 | | - * |
684 | | - * @return the configuration as a component |
685 | | - */ |
686 | | - public Configuration asComponent() { |
687 | | - Configuration config = asConfiguration(); |
688 | | - return new Configuration(config.name(), config.description(), config.synoptic(), config.getIocs(), |
689 | | - config.getBlocks(), config.getGroups(), Collections.<ComponentInfo>emptyList(), config.getHistory(), config.isProtected(), config.isDynamic(), config.configuresBlockGWAndArchiver()); |
690 | | - } |
| 681 | + /** |
| 682 | + * Return in a form suitable for saving as a component - ie without contained |
| 683 | + * components. |
| 684 | + * |
| 685 | + * @return the configuration as a component |
| 686 | + */ |
| 687 | + public Configuration asComponent() { |
| 688 | + Configuration config = asConfiguration(); |
| 689 | + return new Configuration(config.name(), config.description(), config.synoptic(), config.getIocs(), |
| 690 | + config.getBlocks(), config.getGroups(), Collections.<ComponentInfo>emptyList(), config.getHistory(), |
| 691 | + config.isProtected(), config.isDynamic(), config.configuresBlockGWAndArchiver(), |
| 692 | + config.getGlobalmacros()); |
| 693 | + } |
691 | 694 |
|
692 | 695 | /** |
693 | 696 | * Swaps the indices of two groups in the configuration (for moving them up |
@@ -898,4 +901,11 @@ public void close() { |
898 | 901 | this.managerModeObservable.ifPresent(ManagerModeObserver::close); |
899 | 902 | this.managerModeObservable = Optional.empty(); |
900 | 903 | } |
| 904 | + |
| 905 | + /** |
| 906 | + * @return the globalmacros |
| 907 | + */ |
| 908 | + public List<GlobalMacro> getGlobalmacros() { |
| 909 | + return globalmacros; |
| 910 | + } |
901 | 911 | } |
0 commit comments