Search in sources :

Example 16 with IProperty

use of com.archimatetool.model.IProperty in project archi by archimatetool.

the class CommonTests method testProperties.

public static void testProperties(IProperties properties) {
    testList(properties.getProperties(), IArchimatePackage.eINSTANCE.getProperty());
    String key = "some_key", value = "some_value";
    IProperty property = IArchimateFactory.eINSTANCE.createProperty();
    property.setKey(key);
    property.setValue(value);
    properties.getProperties().add(property);
    // Check entry is correct
    EList<IProperty> entries = properties.getProperties();
    assertEquals(1, entries.size());
    IProperty testProperty = entries.get(0);
    assertEquals(property, testProperty);
    assertEquals(testProperty.getKey(), key);
    assertEquals(testProperty.getValue(), value);
}
Also used : IProperty(com.archimatetool.model.IProperty)

Example 17 with IProperty

use of com.archimatetool.model.IProperty in project archi by archimatetool.

the class PropertiesModelDataSourceTests method runOnceBeforeEachTest.

@Before
public void runOnceBeforeEachTest() {
    model = IArchimateFactory.eINSTANCE.createArchimateModel();
    IProperty property = IArchimateFactory.eINSTANCE.createProperty();
    property.setKey("key1");
    property.setValue("value1");
    model.getProperties().add(property);
    property = IArchimateFactory.eINSTANCE.createProperty();
    property.setKey("key2");
    property.setValue("value2");
    model.getProperties().add(property);
    ds = new PropertiesModelDataSource(model);
}
Also used : IProperty(com.archimatetool.model.IProperty) Before(org.junit.Before)

Example 18 with IProperty

use of com.archimatetool.model.IProperty in project archi by archimatetool.

the class PropertiesRenderer method renderPropertiesValuesCustomList.

// List of all of a certain property key with separator
private String renderPropertiesValuesCustomList(IArchimateModelObject object, String text) {
    Matcher matcher = FILTERED_PROPERTIES_WITH_SEPARATOR_PATTERN.matcher(text);
    while (matcher.find()) {
        String prefix = matcher.group(1);
        String separator = matcher.group(2);
        String key = matcher.group(3);
        String s = "";
        IArchimateModelObject refObject = getObjectFromPrefix(object, prefix);
        if (refObject instanceof IProperties) {
            for (IProperty property : ((IProperties) refObject).getProperties()) {
                if (property.getKey().equals(key)) {
                    if (!s.isEmpty()) {
                        s += separator;
                    }
                    s += property.getValue();
                }
            }
            text = text.replace(matcher.group(), s);
        }
    }
    return text;
}
Also used : IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) Matcher(java.util.regex.Matcher) IProperty(com.archimatetool.model.IProperty) IProperties(com.archimatetool.model.IProperties)

Example 19 with IProperty

use of com.archimatetool.model.IProperty in project archi by archimatetool.

the class UserPropertiesManagerDialog method checkDeletions.

/**
 * Check for deletions
 */
private void checkDeletions(CompoundCommand compoundCmd) {
    for (Iterator<EObject> iter = fArchimateModel.eAllContents(); iter.hasNext(); ) {
        EObject element = iter.next();
        if (element instanceof IProperty) {
            IProperty property = (IProperty) element;
            String key = property.getKey();
            if (key != null && !fKeysTable.containsKey(key)) {
                Command cmd = new DeletePropertyKeyCommand(((IProperties) property.eContainer()).getProperties(), property);
                compoundCmd.add(cmd);
            }
        }
    }
}
Also used : IProperty(com.archimatetool.model.IProperty) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) EObject(org.eclipse.emf.ecore.EObject)

Example 20 with IProperty

use of com.archimatetool.model.IProperty in project archi by archimatetool.

the class UserPropertiesManagerDialog method addKeyNameChangeCommands.

/**
 * Change all instances of key to new name
 */
private void addKeyNameChangeCommands(CompoundCommand compoundCmd, String oldName, String newName) {
    for (Iterator<EObject> iter = fArchimateModel.eAllContents(); iter.hasNext(); ) {
        EObject element = iter.next();
        if (element instanceof IProperty) {
            String key = ((IProperty) element).getKey();
            if (key != null && key.equals(oldName)) {
                Command cmd = new RenamePropertyKeyCommand((IProperty) element, oldName, newName);
                compoundCmd.add(cmd);
            }
        }
    }
}
Also used : IProperty(com.archimatetool.model.IProperty) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

IProperty (com.archimatetool.model.IProperty)32 EObject (org.eclipse.emf.ecore.EObject)10 Test (org.junit.Test)9 IArchimateElement (com.archimatetool.model.IArchimateElement)5 IProperties (com.archimatetool.model.IProperties)5 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)4 Point (org.eclipse.swt.graphics.Point)4 HashSet (java.util.HashSet)3 Matcher (java.util.regex.Matcher)3 EObjectNonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand)2 IArchimateConcept (com.archimatetool.model.IArchimateConcept)2 Command (org.eclipse.gef.commands.Command)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Element (org.jdom2.Element)2 CSVParseException (com.archimatetool.csv.CSVParseException)1 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)1 IPreferenceConstants (com.archimatetool.editor.preferences.IPreferenceConstants)1