-
Notifications
You must be signed in to change notification settings - Fork 147
JUnitPropertyPage_java_file
Antonin Abhervé edited this page Sep 3, 2020
·
1 revision
package org.modelio.junit.propertypage;
import java.util.List;
import org.modelio.api.module.IModule;
import org.modelio.api.module.propertiesPage.AbstractModulePropertyPage;
import org.modelio.api.module.propertiesPage.IModulePropertyTable;
import org.modelio.metamodel.uml.infrastructure.ModelElement;
import org.modelio.vcore.smkernel.mapi.MObject;
public class JUnitPropertyPage extends AbstractModulePropertyPage {
public JUnitPropertyPage(IModule module, String name, String label, String bitmap) {
super(module, name, label, bitmap);
}
/**
* This method is called when the current selection
* changes and that the property box contents requires
* an update.
* In this example, simply add one property (the Name of
* the currently selected element)
*/
@Override
public void update(List<MObject> elements, IModulePropertyTable table) {
if (elements.size() == 1 && elements.get(0) instanceof ModelElement) {
ModelElement modelElement = ((ModelElement)elements.get(0));
table.addProperty ("Name", modelElement.getName());
}
}
/**
* This method is called when a value has been edited
* in the property box in the row.
* Here we simply have to update the currently selected
* element name.
* Note: One transaction is already open. So it is not
* necessary to create another one.
*/
@Override
public void changeProperty(List<MObject> elements, int row, String value) {
if (elements.size() == 1 && elements.get(0) instanceof ModelElement) {
ModelElement modelElement = ((ModelElement)elements.get(0));
switch (row) {
case 1: // First line is row == 1
modelElement.setName (value);
break;
}
}
}
}