@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.getFirstElement() instanceof FeatureValue) {
FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
FeatureStructure newValue;
Type fsSuperType = featureValue.getFeature().getRange();
if (!fsSuperType.isArray()) {
List<Type> subTypes =
document.getCAS().getTypeSystem().getProperlySubsumedTypes(fsSuperType);
Type typeToCreate;
int arraySize = -1;
if (subTypes.size() == 0) {
typeToCreate = fsSuperType;
}
else {
CreateFeatureStructureDialog createFsDialog =
new CreateFeatureStructureDialog(Display.getCurrent()
.getActiveShell(), fsSuperType, document.getCAS().getTypeSystem());
int returnCode = createFsDialog.open();
if (returnCode == IDialogConstants.OK_ID) {
typeToCreate = createFsDialog.getType();
arraySize = createFsDialog.getArraySize();
}
else {
return;
}
}
newValue = createFS(typeToCreate, arraySize);
document.addFeatureStructure(newValue);
} else {
Type arrayType = featureValue.getFeature().getRange();
CreateFeatureStructureDialog createArrayDialog = new CreateFeatureStructureDialog(Display.getCurrent()
.getActiveShell(), arrayType, document.getCAS().getTypeSystem());
int returnCode = createArrayDialog.open();
if (returnCode == IDialogConstants.OK_ID) {
newValue = createFS(arrayType, createArrayDialog.getArraySize());
} else {
return;
}
}
featureValue.getFeatureStructure().setFeatureValue(featureValue.getFeature(), newValue);
document.update(featureValue.getFeatureStructure());
}
else if (selection.getFirstElement() instanceof ArrayValue) {
ArrayValue value = (ArrayValue) selection.getFirstElement();