diff --git a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/ConfigurationTest.java b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/ConfigurationTest.java index e830508e7a..ea3da9bec1 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/ConfigurationTest.java +++ b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/ConfigurationTest.java @@ -49,7 +49,7 @@ public void GIVEN_blank_default_synoptic_WHEN_creating_configuration_THEN_defaul String defaultSynoptic = ""; // Act - Configuration config = new Configuration("name", "description", defaultSynoptic, iocs, blocks, groups, components, history, true, false, false); + Configuration config = new Configuration("name", "description", defaultSynoptic, iocs, blocks, groups, components, history, true, false, false, null); // Assert assertEquals(ConfigEditing.NONE_SYNOPTIC_NAME, config.synoptic()); @@ -58,7 +58,7 @@ public void GIVEN_blank_default_synoptic_WHEN_creating_configuration_THEN_defaul @Test public void GIVEN_non_dynamic_configuration_THEN_display_name_is_the_same_as_config_name() { - Configuration config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, false, false); + Configuration config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, false, false, null); // Assert assertEquals(config.getDisplayName(), "name"); @@ -67,7 +67,7 @@ public void GIVEN_non_dynamic_configuration_THEN_display_name_is_the_same_as_con @Test public void GIVEN_dynamic_configuration_THEN_display_name_has_dynamic_appended() { - Configuration config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, true, false); + Configuration config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, true, false, null); // Assert assertEquals(config.getDisplayName(), "name (dynamic)"); diff --git a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/EditableConfigurationTest.java b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/EditableConfigurationTest.java index 1142063df2..cad74d9824 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/EditableConfigurationTest.java +++ b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/editing/EditableConfigurationTest.java @@ -132,7 +132,8 @@ public static Configuration emptyConfig() { Collections.emptyList(), true, false, - false); + false, + null); } protected void populateConfig() { @@ -146,7 +147,7 @@ protected void populateConfig() { } protected Configuration config() { - return new Configuration(NAME, DESCRIPTION, SYNOPTIC, iocs, blocks, groups, components, history, true, false, false); + return new Configuration(NAME, DESCRIPTION, SYNOPTIC, iocs, blocks, groups, components, history, true, false, false, null); } protected EditableConfiguration edit(Configuration config) { @@ -217,9 +218,9 @@ public void GIVEN_configuration_WHEN_component_added_THEN_blocks_from_component_ var component = new Configuration("comp", "desc", "", Collections.emptyList(), List.of(new Block("comp_blockname", "", false, false)), - Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, true, false); + Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, true, false, null); - var config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, true, false); + var config = new Configuration("name", "description", "", iocs, blocks, groups, components, history, false, true, false, null); var editable = new EditableConfiguration(config, Collections.emptyList(), List.of(component), Collections.emptyList()); assertEquals(editable.getAllBlocks().size(), 0); @@ -238,7 +239,7 @@ public void GIVEN_configuration_WHEN_component_added_THEN_blocks_from_component_ public void GIVEN_component_with_group_WHEN_component_added_THEN_group_from_component_read_only() { var group = new Group("comp_group", Collections.emptyList(), "comp"); var component = new Configuration("comp", "desc", "", Collections.emptyList(), Collections.emptyList(), - List.of(group), Collections.emptyList(), Collections.emptyList(), false, true, false); + List.of(group), Collections.emptyList(), Collections.emptyList(), false, true, false, null); var editable = new EditableConfiguration(emptyConfig(), Collections.emptyList(), List.of(component), Collections.emptyList()); assertEquals(editable.getEditableGroups().size(), 0); @@ -261,7 +262,7 @@ public void GIVEN_component_with_group_WHEN_component_added_THEN_group_from_comp public void GIVEN_component_with_block_not_in_group_WHEN_component_added_THEN_block_from_component() { var block = new Block("block", "PV", true, true); var component = new Configuration("comp", "desc", "", Collections.emptyList(), List.of(block), Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), false, true, false); + Collections.emptyList(), Collections.emptyList(), false, true, false, null); var editable = new EditableConfiguration(emptyConfig(), Collections.emptyList(), List.of(component), Collections.emptyList()); assertEquals(editable.getBlocksOutsideGroup().size(), 0); diff --git a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/internal/ImportConverterTest.java b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/internal/ImportConverterTest.java index 9c36959bf2..2f56f83cc1 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/internal/ImportConverterTest.java +++ b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/internal/ImportConverterTest.java @@ -74,9 +74,9 @@ public static void setUp() { editableIocs.add(editableIoc); source = new Configuration(COMPONENT_NAME, COMPONENT_DESC, null, Arrays.asList(new Ioc(editableIoc)), Arrays.asList(BLOCK), - Arrays.asList(GROUP), Collections.emptyList(), Collections.emptyList(), false, false, false); + Arrays.asList(GROUP), Collections.emptyList(), Collections.emptyList(), false, false, false, null); empty = new Configuration("EMPTY", "EMTPY DESC", null, Collections.emptyList(), Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, false, false); + Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, false, false, null); destination = new EditableConfiguration(empty, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); ImportConverter.convert(source, destination, SOURCE_PREFIX, DESTINATION_PREFIX, editableIocs); diff --git a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/json/JsonConvertersTest.java b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/json/JsonConvertersTest.java index ad42fa3b73..ab0eca5731 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/json/JsonConvertersTest.java +++ b/base/uk.ac.stfc.isis.ibex.configserver.tests/src/uk/ac/stfc/isis/ibex/configserver/tests/json/JsonConvertersTest.java @@ -242,7 +242,7 @@ public void conversion_config_to_string() throws ConversionException { //Arrange Function conv = new JsonConverters().configToString(); Configuration testConfig = new Configuration(configName, configDescription); - String expected = "{\"name\":\"" + configName + "\",\"description\":\"" + configDescription + "\",\"isProtected\":false,\"isDynamic\":false,\"configuresBlockGWAndArchiver\":false,\"iocs\":[],\"blocks\":[],\"groups\":[],\"components\":[],\"history\":[]}"; + String expected = "{\"name\":\"" + configName + "\",\"description\":\"" + configDescription + "\",\"isProtected\":false,\"isDynamic\":false,\"configuresBlockGWAndArchiver\":false,\"iocs\":[],\"blocks\":[],\"groups\":[],\"components\":[],\"history\":[],\"globalmacros\":[]}"; //Act String test = conv.apply(testConfig); diff --git a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/Configuration.java b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/Configuration.java index 935fb1f7cb..539e74c0f1 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/Configuration.java +++ b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/Configuration.java @@ -50,6 +50,7 @@ public class Configuration extends ModelObject { private List groups = new ArrayList<>(); private List components = new ArrayList<>(); private List history = new ArrayList<>(); + private List globalmacros = new ArrayList<>(); /** * Create a new configuration. @@ -81,11 +82,12 @@ public Configuration(String name, String description) { * automatically * @param configuresBlockGWAndArchiver True this configuration includes the block gateway and archive files; * False these are generated by the block server + * @param globalmacros The global macros */ public Configuration(String name, String description, String defaultSynoptic, Collection iocs, Collection blocks, Collection groups, Collection components, Collection history, boolean isProtected, boolean isDynamic, - boolean configuresBlockGWAndArchiver) { + boolean configuresBlockGWAndArchiver, Collection globalmacros) { this.name = name; this.description = description; this.synoptic = defaultSynoptic == null || defaultSynoptic.equals("") ? ConfigEditing.NONE_SYNOPTIC_NAME @@ -114,6 +116,12 @@ public Configuration(String name, String description, String defaultSynoptic, Co for (String date : history) { this.history.add(date); } + + if (null != globalmacros) { + for (GlobalMacro globalMacro : globalmacros) { + this.globalmacros.add(new GlobalMacro(globalMacro)); + } + } } /** @@ -123,7 +131,8 @@ public Configuration(String name, String description, String defaultSynoptic, Co */ public Configuration(Configuration other) { this(other.name(), other.description(), other.synoptic(), other.getIocs(), other.getBlocks(), other.getGroups(), - other.getComponents(), other.getHistory(), other.isProtected, other.isDynamic, other.configuresBlockGWAndArchiver); + other.getComponents(), other.getHistory(), other.isProtected, other.isDynamic, + other.configuresBlockGWAndArchiver, other.getGlobalmacros()); this.pv = other.pv; } @@ -251,4 +260,11 @@ public String toString() { public String getName() { return name; } + + /** + * @return A collection of the configuration's blocks + */ + public List getGlobalmacros() { + return globalmacros != null ? new ArrayList<>(globalmacros) : Collections.emptyList(); + } } diff --git a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/GlobalMacro.java b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/GlobalMacro.java new file mode 100644 index 0000000000..17b38ed45a --- /dev/null +++ b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/configuration/GlobalMacro.java @@ -0,0 +1,111 @@ +/* +* This file is part of the ISIS IBEX application. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. +* All rights reserved. +* +* This program is distributed in the hope that it will be useful. +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution. +* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM +* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES +* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more details. +* +* You should have received a copy of the Eclipse Public License v1.0 +* along with this program; if not, you can obtain a copy from +* https://www.eclipse.org/org/documents/epl-v10.php or +* http://opensource.org/licenses/eclipse-1.0.php +*/ + +package uk.ac.stfc.isis.ibex.configserver.configuration; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import uk.ac.stfc.isis.ibex.model.ModelObject; + +/** + * Represents a global macro. + * + * Contains the IOC name, or none, and a list of associated macros + * + */ +public class GlobalMacro extends ModelObject implements Comparable { + + private final String name; + + private Map macros; + + /** + * Create a Global Macro with a given name. + * + * @param name The IOC name (or global) + */ + public GlobalMacro(String name) { + this.name = name; + } + + /** + * Create a copy of a Global Macro list for an IOC (or global). + * + * @param globalMacro The Global Macro to copy + */ + public GlobalMacro(GlobalMacro globalMacro) { + this.name = globalMacro.getName(); + //this.macros = new ArrayList<>(globalMacro.getMacros()); + this.macros = new HashMap(globalMacro.getMacros()); + } + + /** + * @return The IOC name + */ + public String getName() { + return name; + } + + /** + * @return A collection of macros + */ + public Map getMacros() { + return Optional.ofNullable(macros).orElseGet(HashMap::new); + } + + /** + * Compares this GlobalMacro to another based on name. Used for sorting. + */ + @Override + public int compareTo(GlobalMacro other) { + if (this.name != null && other.name != null) { + return this.name.compareTo(other.name); + } + return 0; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + GlobalMacro other = (GlobalMacro) obj; + if (this.name == null && other.name == null) { + return true; + } + if (this.name == null || other.name == null) { + return false; + } + return this.name.equals(other.name); + } + + @Override + public int hashCode() { + return name == null ? 0 : name.hashCode(); + } + + @Override + public String toString() { + return "GlobalMacro [name=" + name + ", macros=" + macros + "]"; + } +} diff --git a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/editing/EditableConfiguration.java b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/editing/EditableConfiguration.java index 45d02ff007..44e354a706 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/editing/EditableConfiguration.java +++ b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/editing/EditableConfiguration.java @@ -1,6 +1,6 @@ /* - * This file is part of the ISIS IBEX application. Copyright (C) 2012-2017 + * This file is part of the ISIS IBEX application. Copyright (C) 2012-2025 * Science & Technology Facilities Council. All rights reserved. * * This program is distributed in the hope that it will be useful. This program @@ -36,6 +36,7 @@ import uk.ac.stfc.isis.ibex.configserver.configuration.Block; import uk.ac.stfc.isis.ibex.configserver.configuration.ComponentInfo; import uk.ac.stfc.isis.ibex.configserver.configuration.Configuration; +import uk.ac.stfc.isis.ibex.configserver.configuration.GlobalMacro; import uk.ac.stfc.isis.ibex.configserver.configuration.Group; import uk.ac.stfc.isis.ibex.configserver.configuration.Ioc; import uk.ac.stfc.isis.ibex.configserver.configuration.Macro; @@ -142,7 +143,8 @@ public class EditableConfiguration extends ModelObject implements GroupNamesProv /** Current error message to be displayed **/ private String currentErrorMessage = noError; - + /** The global macros associated with any configuration. */ + private List globalmacros; /** * Listener for block renaming events. @@ -180,69 +182,67 @@ public void propertyChange(PropertyChangeEvent evt) { * @param pvs * The PVs available to the configuration */ - public EditableConfiguration( - Configuration config, - Collection iocs, - Collection components, - Collection pvs) { - this.name = config.name(); - this.description = config.description(); - this.synoptic = config.synoptic(); - this.isProtected = config.isProtected(); - this.isDynamic = config.isDynamic(); - this.configuresBlockGWAndArchiver = config.configuresBlockGWAndArchiver(); - originalProtectedFlag = this.isProtected; - this.allIocs = new ArrayList<>(); - this.managerMode = ManagerModeModel.getInstance(); - this.isSaveButtonEnabled = true; - this.enableSaveAsButton = true; - managerModePv = managerMode.getManagerModeObservable(); - - for (EditableIoc ioc : iocs) { - EditableIoc newIoc = new EditableIoc(ioc, ioc.getDescription()); - newIoc.setAvailableMacros(new ArrayList<>(ioc.getAvailableMacros())); - this.allIocs.add(newIoc); - } + public EditableConfiguration(Configuration config, Collection iocs, + Collection components, Collection pvs) { + this.name = config.name(); + this.description = config.description(); + this.synoptic = config.synoptic(); + this.isProtected = config.isProtected(); + this.isDynamic = config.isDynamic(); + this.configuresBlockGWAndArchiver = config.configuresBlockGWAndArchiver(); + originalProtectedFlag = this.isProtected; + this.allIocs = new ArrayList<>(); + this.managerMode = ManagerModeModel.getInstance(); + this.isSaveButtonEnabled = true; + this.enableSaveAsButton = true; + managerModePv = managerMode.getManagerModeObservable(); + + for (EditableIoc ioc : iocs) { + EditableIoc newIoc = new EditableIoc(ioc, ioc.getDescription()); + newIoc.setAvailableMacros(new ArrayList<>(ioc.getAvailableMacros())); + this.allIocs.add(newIoc); + } - this.history = new ArrayList<>(); + this.history = new ArrayList<>(); - for (String date : config.getHistory()) { - this.history.add(date); - } + for (String date : config.getHistory()) { + this.history.add(date); + } - this.pvs = new ArrayList<>(pvs); + this.pvs = new ArrayList<>(pvs); - for (Block block : config.getBlocks()) { - EditableBlock eb = new EditableBlock(block); - allBlocks.add(eb); - addRenameListener(eb); - } + for (Block block : config.getBlocks()) { + EditableBlock eb = new EditableBlock(block); + allBlocks.add(eb); + addRenameListener(eb); + } - for (Group group : config.getGroups()) { - if (!group.hasComponent()) { - editableGroups.add(new EditableGroup(this, group)); + for (Group group : config.getGroups()) { + if (!group.hasComponent()) { + editableGroups.add(new EditableGroup(this, group)); + } } - } - - editableGroups = new ArrayList<>(DisplayUtils.removeOtherGroup(editableGroups)); - for (EditableIoc ioc : allIocs) { - iocMap.put(ioc.getName(), ioc); - } - initMacros(iocMap); + editableGroups = new ArrayList<>(DisplayUtils.removeOtherGroup(editableGroups)); - for (Ioc ioc : config.getIocs()) { - addIoc(convertIoc(ioc)); - } + for (EditableIoc ioc : allIocs) { + iocMap.put(ioc.getName(), ioc); + } + initMacros(iocMap); + + for (Ioc ioc : config.getIocs()) { + addIoc(convertIoc(ioc)); + } - Collection selectedComponents = getComponentDetails(config.getComponents(), components); - editableComponents = new EditableComponents(selectedComponents, components); - editableComponents.addPropertyChangeListener(evt -> updateComponents()); + Collection selectedComponents = getComponentDetails(config.getComponents(), components); + editableComponents = new EditableComponents(selectedComponents, components); + editableComponents.addPropertyChangeListener(evt -> updateComponents()); - updateComponents(); - setEnableSaveAsButton(); - addObserver(); - } + updateComponents(); + setEnableSaveAsButton(); + addObserver(); + this.globalmacros = config.getGlobalmacros(); + } private EditableIoc convertIoc(Ioc ioc) { final EditableIoc generalIOC = iocMap.get(ioc.getName()); @@ -666,28 +666,31 @@ public void removeGroup(EditableGroup group) { firePropertyChange("groups", groupsBefore, transformGroups()); } - /** - * Return in a form suitable for saving as a configuration. - * - * @return the underlying configuration - */ - public Configuration asConfiguration() { - Configuration config = new Configuration(getName(), getDescription(), getSynoptic(), transformIocs(), transformBlocks(), - transformGroups(), transformComponents(), getHistory(), getIsProtected(), getIsDynamic(), getIfconfiguresBlockGWAndArchiver()); - return new ComponentFilteredConfiguration(config); - } + /** + * Return in a form suitable for saving as a configuration. + * + * @return the underlying configuration + */ + public Configuration asConfiguration() { + Configuration config = new Configuration(getName(), getDescription(), getSynoptic(), transformIocs(), + transformBlocks(), transformGroups(), transformComponents(), getHistory(), getIsProtected(), + getIsDynamic(), getIfconfiguresBlockGWAndArchiver(), getGlobalmacros()); + return new ComponentFilteredConfiguration(config); + } - /** - * Return in a form suitable for saving as a component - ie without - * contained components. - * - * @return the configuration as a component - */ - public Configuration asComponent() { - Configuration config = asConfiguration(); - return new Configuration(config.name(), config.description(), config.synoptic(), config.getIocs(), - config.getBlocks(), config.getGroups(), Collections.emptyList(), config.getHistory(), config.isProtected(), config.isDynamic(), config.configuresBlockGWAndArchiver()); - } + /** + * Return in a form suitable for saving as a component - ie without contained + * components. + * + * @return the configuration as a component + */ + public Configuration asComponent() { + Configuration config = asConfiguration(); + return new Configuration(config.name(), config.description(), config.synoptic(), config.getIocs(), + config.getBlocks(), config.getGroups(), Collections.emptyList(), config.getHistory(), + config.isProtected(), config.isDynamic(), config.configuresBlockGWAndArchiver(), + config.getGlobalmacros()); + } /** * Swaps the indices of two groups in the configuration (for moving them up @@ -898,4 +901,11 @@ public void close() { this.managerModeObservable.ifPresent(ManagerModeObserver::close); this.managerModeObservable = Optional.empty(); } + + /** + * @return the globalmacros + */ + public List getGlobalmacros() { + return globalmacros; + } } diff --git a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/internal/ComponentFilteredConfiguration.java b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/internal/ComponentFilteredConfiguration.java index ee5ab96453..175f9b8175 100644 --- a/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/internal/ComponentFilteredConfiguration.java +++ b/base/uk.ac.stfc.isis.ibex.configserver/src/uk/ac/stfc/isis/ibex/configserver/internal/ComponentFilteredConfiguration.java @@ -1,7 +1,7 @@ /* * This file is part of the ISIS IBEX application. -* Copyright (C) 2012-2015 Science & Technology Facilities Council. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. * All rights reserved. * * This program is distributed in the hope that it will be useful. @@ -41,9 +41,10 @@ public class ComponentFilteredConfiguration extends Configuration { * The unfiltered configuration */ public ComponentFilteredConfiguration(Configuration other) { - super(other.name(), other.description(), other.synoptic(), filterIocs(other.getIocs()), - filterBlocks(other.getBlocks()), filterGroups(other.getGroups()), other.getComponents(), - other.getHistory(), other.isProtected(), other.isDynamic(), other.configuresBlockGWAndArchiver()); + super(other.name(), other.description(), other.synoptic(), filterIocs(other.getIocs()), + filterBlocks(other.getBlocks()), filterGroups(other.getGroups()), other.getComponents(), + other.getHistory(), other.isProtected(), other.isDynamic(), other.configuresBlockGWAndArchiver(), + other.getGlobalmacros()); } /** diff --git a/base/uk.ac.stfc.isis.ibex.targetplatform/targetplatform.target b/base/uk.ac.stfc.isis.ibex.targetplatform/targetplatform.target index 99004b1f31..5ed956066d 100644 --- a/base/uk.ac.stfc.isis.ibex.targetplatform/targetplatform.target +++ b/base/uk.ac.stfc.isis.ibex.targetplatform/targetplatform.target @@ -86,6 +86,9 @@ + + + diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/tests/EditConfigHelperTest.java b/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/tests/EditConfigHelperTest.java new file mode 100644 index 0000000000..69894f3011 --- /dev/null +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/tests/EditConfigHelperTest.java @@ -0,0 +1,59 @@ +package uk.ac.stfc.isis.ibex.ui.configserver.commands.helpers.tests; + + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; + +import uk.ac.stfc.isis.ibex.configserver.configuration.GlobalMacro; +import uk.ac.stfc.isis.ibex.configserver.editing.EditableConfiguration; +import uk.ac.stfc.isis.ibex.ui.configserver.commands.helpers.EditConfigHelper; +@RunWith(org.mockito.junit.MockitoJUnitRunner.StrictStubs.class) +public class EditConfigHelperTest { + + EditableConfiguration config; + + @Before + public void setUp() { + config = Mockito.mock(EditableConfiguration.class); + when(config.getName()).thenReturn("current"); + } + + @Test + public void testOpenDialogs_WhenNoGlobalMacros_CheckSubtitle() throws IOException { + // Arrange + when(config.getGlobalmacros()).thenReturn(null); + String expectedSubTitle = "Editing the current configuration"; + // Assert + assertEquals(expectedSubTitle, EditConfigHelper.createSubTitle(config, config.getName())); + } + + @Test + public void testOpenDialogs_WhenGlobalMacrosExist_CheckSubtitle() throws IOException { + // Arrange + List globalMacros = List.of(new GlobalMacro("macro1"), new GlobalMacro("macro2")); + when(config.getGlobalmacros()).thenReturn(globalMacros); + String expectedSubTitle = "Editing the current configuration\nNote: There also are global macros defined. " + + "See the Global Macros tab.\nThey over-ride IOC level macro"; + + // Assert + assertEquals(expectedSubTitle, EditConfigHelper.createSubTitle(config, config.getName())); + } + + @Test + public void testOpenDialogs_WhenEMptyGlobalMacros_CheckSubtitle() throws IOException { + // Arrange + when(config.getGlobalmacros()).thenReturn(new ArrayList()); + String expectedSubTitle = "Editing the current configuration"; + // Assert + assertEquals(expectedSubTitle, EditConfigHelper.createSubTitle(config, config.getName())); + } +} diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/tests/IocStateTest.java b/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/tests/IocStateTest.java index 0fd753e37c..7bd29b5684 100644 --- a/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/tests/IocStateTest.java +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver.tests/src/uk/ac/stfc/isis/ibex/ui/configserver/tests/IocStateTest.java @@ -76,7 +76,7 @@ public void GIVEN_ioc_in_config_WHEN_call_getInCurrentConfig_THEN_true() { // Arrange Configuration configWithIoc = new Configuration("Config name", "desc", "", Collections.singleton(new Ioc(IOC_NAME)), - Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), false, false, false); + Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), false, false, false, null); when(currentConfig.getValue()).thenReturn(configWithIoc); when(componentDetails.getValue()).thenReturn(Collections.emptySet()); @@ -96,11 +96,11 @@ public void GIVEN_ioc_in_selected_component_WHEN_call_getInCurrentConfig_THEN_tr // Arrange Configuration configWithComp = new Configuration("Config name", "desc", "", Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), - Collections.singleton(new ComponentInfo("Selected component")), Collections.emptySet(), false, false, false); + Collections.singleton(new ComponentInfo("Selected component")), Collections.emptySet(), false, false, false, null); Collection components = Collections.singleton(new Configuration("Selected component", "desc", "", Collections.singleton(new Ioc(IOC_NAME)), Collections.emptySet(), Collections.emptySet(), - Collections.emptySet(), Collections.emptySet(), false, false, false)); + Collections.emptySet(), Collections.emptySet(), false, false, false, null)); when(currentConfig.getValue()).thenReturn(configWithComp); when(componentDetails.getValue()).thenReturn(components); @@ -122,7 +122,7 @@ public void GIVEN_ioc_in_not_selected_component_WHEN_call_getInCurrentConfig_THE Collection components = Collections.singleton(new Configuration("Not selected component", "desc", "", Collections.singleton(new Ioc(IOC_NAME)), Collections.emptySet(), Collections.emptySet(), - Collections.emptySet(), Collections.emptySet(), false, false, false)); + Collections.emptySet(), Collections.emptySet(), false, false, false, null)); when(currentConfig.getValue()).thenReturn(configWithNoComp); when(componentDetails.getValue()).thenReturn(components); diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/AddBlockToConfigHelper.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/AddBlockToConfigHelper.java index 9d44f04843..6e2e101820 100644 --- a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/AddBlockToConfigHelper.java +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/AddBlockToConfigHelper.java @@ -1,8 +1,27 @@ +/** +* This file is part of the ISIS IBEX application. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. +* All rights reserved. +* +* This program is distributed in the hope that it will be useful. +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution. +* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM +* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES +* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more details. +* +* You should have received a copy of the Eclipse Public License v1.0 +* along with this program; if not, you can obtain a copy from +* https://www.eclipse.org/org/documents/epl-v10.php or +* http://opensource.org/licenses/eclipse-1.0.php +*/ package uk.ac.stfc.isis.ibex.ui.configserver.commands.helpers; import java.io.IOException; + import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; + import uk.ac.stfc.isis.ibex.configserver.ConfigServer; import uk.ac.stfc.isis.ibex.configserver.editing.EditableConfiguration; import uk.ac.stfc.isis.ibex.ui.configserver.dialogs.EditConfigDialog; @@ -21,7 +40,6 @@ public class AddBlockToConfigHelper extends EditConfigHelper { */ public AddBlockToConfigHelper(Shell shell, ConfigServer server) { super(shell, server); - } /** @@ -40,16 +58,12 @@ public void openDialogs(EditableConfiguration config, boolean isCurrent, boolean boolean openEditBlockDialog, String pvName) throws IOException { config.setIsComponent(false); final String configName = getConfigDisplayName(config, isCurrent); - final String subTitle = "Editing the " + configName + " configuration"; - + final String subTitle = createSubTitle(config, configName); EditConfigDialog dialog = new EditConfigDialog(shell, title, subTitle, config, false, configurationViewModels, editBlockFirst, openEditBlockDialog, pvName); // Creating dialog to edit configuration dialog.addNew(config); // Open edit block dialog before editing the configuration if (dialog.open() == Window.OK) { // Edit configuration dialog - server.saveAs().write(config.asConfiguration()); // Saving the block to the configuration - } } - } diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/EditConfigHelper.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/EditConfigHelper.java index 6d0f617e04..48012b9416 100644 --- a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/EditConfigHelper.java +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/EditConfigHelper.java @@ -1,7 +1,7 @@ /* * This file is part of the ISIS IBEX application. - * Copyright (C) 2012-2016 Science & Technology Facilities Council. + * Copyright (C) 2012-2025 Science & Technology Facilities Council. * All rights reserved. * * This program is distributed in the hope that it will be useful. @@ -58,8 +58,7 @@ public EditConfigHelper(Shell shell, ConfigServer server) { protected void openDialog(EditableConfiguration config, boolean isCurrent, boolean editBlockFirst) { config.setIsComponent(false); final String configName = getConfigDisplayName(config, isCurrent); - final String subTitle = "Editing the " + configName + " configuration"; - + final String subTitle = createSubTitle(config, configName); EditConfigDialog dialog = new EditConfigDialog(shell, title, subTitle, config, false, configurationViewModels, editBlockFirst); if (dialog.open() == Window.OK) { @@ -71,4 +70,17 @@ protected void openDialog(EditableConfiguration config, boolean isCurrent, boole } } + /** + * @param config the configuration + * @param configName the name to be displayed for the configuration + * @return the title of the dialog + */ + public static String createSubTitle(EditableConfiguration config, final String configName) { + String subTitle = "Editing the " + configName + " configuration"; + var macros = config.getGlobalmacros(); + if (null != macros && !macros.isEmpty()) { + subTitle += "\nNote: There also are global macros defined. See the Global Macros tab.\nThey over-ride IOC level macro"; + } + return subTitle; + } } diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/ViewConfigHelper.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/ViewConfigHelper.java index e381ae732f..386df2e94b 100644 --- a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/ViewConfigHelper.java +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/commands/helpers/ViewConfigHelper.java @@ -1,7 +1,6 @@ - /* * This file is part of the ISIS IBEX application. - * Copyright (C) 2012-2016 Science & Technology Facilities Council. + * Copyright (C) 2012-2025 Science & Technology Facilities Council. * All rights reserved. * * This program is distributed in the hope that it will be useful. @@ -22,6 +21,8 @@ */ package uk.ac.stfc.isis.ibex.ui.configserver.commands.helpers; +import java.util.Optional; + import org.eclipse.swt.widgets.Shell; import uk.ac.stfc.isis.ibex.configserver.editing.EditableConfiguration; @@ -58,7 +59,10 @@ public ViewConfigHelper(Shell shell) { protected void openDialog(EditableConfiguration config, boolean isCurrent, boolean editBlockFirst) { final String configName = getConfigDisplayName(config, isCurrent); - final String subTitle = "Viewing the " + configName + " configuration"; + String subTitle = "Viewing the " + configName + " configuration"; + if (Optional.ofNullable(config.getGlobalmacros()).map(l -> l.isEmpty()).orElse(true)) { + subTitle += "\nNote: There also are global macros defined. See the Global Macros tab.\nThey over-ride IOC level macro"; + } config.setIsComponent(false); ConfigDetailsDialog dialog = diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/ConfigEditorPanel.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/ConfigEditorPanel.java index 890c55843e..de66c3c3b3 100644 --- a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/ConfigEditorPanel.java +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/ConfigEditorPanel.java @@ -1,7 +1,7 @@ /* * This file is part of the ISIS IBEX application. -* Copyright (C) 2012-2015 Science & Technology Facilities Council. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. * All rights reserved. * * This program is distributed in the hope that it will be useful. @@ -35,6 +35,7 @@ import uk.ac.stfc.isis.ibex.ui.configserver.editing.components.ComponentEditorPanel; import uk.ac.stfc.isis.ibex.ui.configserver.editing.groups.GroupsEditorPanel; import uk.ac.stfc.isis.ibex.ui.configserver.editing.iocs.IocOverviewPanel; +import uk.ac.stfc.isis.ibex.ui.configserver.editing.macros.GlobalMacroOverviewPanel; import uk.ac.stfc.isis.ibex.ui.configserver.editing.summary.SummaryPanel; import uk.ac.stfc.isis.ibex.validators.MessageDisplayer; @@ -122,6 +123,13 @@ public void widgetSelected(SelectionEvent e) { groupsTab.setControl(groups); setConfigToEdit(config); + + if (!config.getGlobalmacros().isEmpty()) { + final GlobalMacroOverviewPanel globalMacros = new GlobalMacroOverviewPanel(editorTabs, config); + TabItem globalMacrosTab = new TabItem(editorTabs, SWT.NONE); + globalMacrosTab.setText("Global Macros"); + globalMacrosTab.setControl(globalMacros); + } } /** diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroOverviewPanel.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroOverviewPanel.java new file mode 100644 index 0000000000..423ff08205 --- /dev/null +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroOverviewPanel.java @@ -0,0 +1,82 @@ +/* +* This file is part of the ISIS IBEX application. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. +* All rights reserved. +* +* This program is distributed in the hope that it will be useful. +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution. +* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM +* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES +* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more details. +* +* You should have received a copy of the Eclipse Public License v1.0 +* along with this program; if not, you can obtain a copy from +* https://www.eclipse.org/org/documents/epl-v10.php or +* http://opensource.org/licenses/eclipse-1.0.php +*/ + +package uk.ac.stfc.isis.ibex.ui.configserver.editing.macros; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; + +import uk.ac.stfc.isis.ibex.configserver.configuration.GlobalMacro; +import uk.ac.stfc.isis.ibex.configserver.editing.EditableConfiguration; + +/** + * Panel showing an overview of all global macros. + */ +@SuppressWarnings("checkstyle:magicnumber") +public class GlobalMacroOverviewPanel extends Composite { + private Collection macros; + private final GlobalMacroTable table; + + /** + * Constructor for the Macro panel. + * + * @param parent The parent composite. + * @param config The configuration details. + */ + public GlobalMacroOverviewPanel(Composite parent, EditableConfiguration config) { + super(parent, SWT.NONE); + setLayout(new FillLayout(SWT.HORIZONTAL)); + table = new GlobalMacroTable(this, SWT.NONE, SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); + GridData grid = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + grid.widthHint = 428; + table.setLayoutData(grid); + setMacros(config.getGlobalmacros()); + table.setRows(macros); + } + + /** + * Sets the macros to be displayed by the panel. + * + * @param globalmacros The macros that are defined at the global level. + */ + public void setMacros(final List globalmacros) { + macros = (globalmacros == null) ? new ArrayList<>() + : globalmacros.stream() + .sorted() + .filter(Objects::nonNull) + .flatMap(macro -> macro.getMacros() + .entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .map(entry -> new GlobalMacroViewModel( + macro.getName(), + entry.getKey(), + entry.getValue() + )) + ) + .collect(Collectors.toList()); + } +} diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroTable.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroTable.java new file mode 100644 index 0000000000..23e3332f8b --- /dev/null +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroTable.java @@ -0,0 +1,113 @@ +/* +* This file is part of the ISIS IBEX application. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. +* All rights reserved. +* +* This program is distributed in the hope that it will be useful. +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution. +* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM +* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES +* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more details. +* +* You should have received a copy of the Eclipse Public License v1.0 +* along with this program; if not, you can obtain a copy from +* https://www.eclipse.org/org/documents/epl-v10.php or +* http://opensource.org/licenses/eclipse-1.0.php +*/ + +package uk.ac.stfc.isis.ibex.ui.configserver.editing.macros; + +import java.util.Collection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import uk.ac.stfc.isis.ibex.ui.tables.DataboundCellLabelProvider; +import uk.ac.stfc.isis.ibex.ui.tables.DataboundTable; + +/** + * The table for viewing global macros. + */ +public class GlobalMacroTable extends DataboundTable { + private static final int COLUMN_WIDTH = 5; + private enum Columns { + IOC_NAME("IOC Name", "iocName"), MACRO_NAME("Macro Name", "macroName"), MACRO_VALUE("Macro Value", "macroValue"); + + private String columnName; + private String propertyName; + Columns(String columnName, String propertyName) { + this.columnName = columnName; + this.propertyName = propertyName; + } + } + + /** + * Constructor for the table. + * + * @param parent The composite to put the table in. + * @param style The SWT style of this databound table. + * @param tableStyle The SWT style of the inner table object. + */ + public GlobalMacroTable(Composite parent, int style, int tableStyle) { + super(parent, style, tableStyle | SWT.BORDER); + initialise(); + } + + /** + * Sets the rows of the table. + * @param rows The rows to set. + */ + @Override + public void setRows(Collection rows) { + super.setRows(rows); + super.refresh(); + } + + /** + * Adds the columns to the table. + */ + @Override + protected void addColumns() { + iocName(); + macroName(); + macroValue(); + } + + /** + * Creates the IOC Name column. + */ + private void iocName() { + createColumn(Columns.IOC_NAME.columnName, COLUMN_WIDTH, + new DataboundCellLabelProvider(observeProperty(Columns.IOC_NAME.propertyName)) { + @Override + protected String stringFromRow(GlobalMacroViewModel row) { + return row.getIocName(); + } + }); + } + + /** + * Creates the Macro Name column. + */ + private void macroName() { + createColumn(Columns.MACRO_NAME.columnName, COLUMN_WIDTH, + new DataboundCellLabelProvider(observeProperty(Columns.MACRO_NAME.propertyName)) { + @Override + protected String stringFromRow(GlobalMacroViewModel row) { + return row.getMacroName(); + } + }); + } + + /** + * Creates the Macro value column. + */ + private void macroValue() { + createColumn(Columns.MACRO_VALUE.columnName, COLUMN_WIDTH, new DataboundCellLabelProvider( + observeProperty(Columns.MACRO_VALUE.propertyName)) { + @Override + protected String stringFromRow(GlobalMacroViewModel row) { + return row.getMacroValue(); + } + }); + } +} diff --git a/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroViewModel.java b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroViewModel.java new file mode 100644 index 0000000000..31904ce7fe --- /dev/null +++ b/base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/GlobalMacroViewModel.java @@ -0,0 +1,65 @@ +/* +* This file is part of the ISIS IBEX application. +* Copyright (C) 2012-2025 Science & Technology Facilities Council. +* All rights reserved. +* +* This program is distributed in the hope that it will be useful. +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution. +* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM +* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES +* OR CONDITIONS OF ANY KIND. See the Eclipse Public License v1.0 for more details. +* +* You should have received a copy of the Eclipse Public License v1.0 +* along with this program; if not, you can obtain a copy from +* https://www.eclipse.org/org/documents/epl-v10.php or +* http://opensource.org/licenses/eclipse-1.0.php +*/ +package uk.ac.stfc.isis.ibex.ui.configserver.editing.macros; + +import uk.ac.stfc.isis.ibex.model.ModelObject; + +/** + * View model for the global macro, just a container for the global macro values. + */ +public class GlobalMacroViewModel extends ModelObject { + + private final String iocName; + private final String macroName; + private final String macroValue; + + + /** + * Constructor. Sets the use default based on provided macro. + * + * @param iocName The IOC Name. + * @param macroName The Macro Name. + * @param macroValue The Macro Value. + */ + public GlobalMacroViewModel(String iocName, String macroName, String macroValue) { + this.iocName = iocName; + this.macroName = macroName; + this.macroValue = macroValue; + } + + /** + * @return the iocName + */ + public String getIocName() { + return iocName; + } + + /** + * @return the macroName + */ + public String getMacroName() { + return macroName; + } + + /** + * @return the macroValue + */ + public String getMacroValue() { + return macroValue; + } +}