if (element instanceof BooleanCriterionElement) {
JCheckBox checkBox = new JCheckBox();
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
component = checkBox;
} else if (element instanceof StringCriterionElement) {
StringCriterionElement stringElement = (StringCriterionElement) element;
boolean acceptRE = stringElement.acceptRegularExpression();
boolean acceptExp = stringElement.acceptPtolemyExpression();
Color background;
if (acceptRE) {
background = _REGULAR_EXPRESSION_BACKGROUND;
} else if (acceptExp) {
background = _PTOLEMY_EXPRESSION_BACKGROUND;
} else {
background = _NON_REGULAR_EXPRESSION_BACKGROUND;
}
if (element instanceof ChoiceCriterionElement) {
ChoiceCriterionElement choiceElement = (ChoiceCriterionElement) element;
ColorizedComboBox comboBox = new ColorizedComboBox(
background);
comboBox.setEditable(choiceElement.isEditable());
for (Object choice : choiceElement.getChoices()) {
comboBox.addItem(choice);
}
component = comboBox;
} else {
component = new ColorizedTextField(background);
}
} else if (element instanceof StringOperationElement) {
StringOperationElement stringElement = (StringOperationElement) element;
boolean acceptExp = stringElement.acceptPtolemyExpression();
Color background;
if (acceptExp) {
background = _PTOLEMY_EXPRESSION_BACKGROUND;
} else {
background = _NON_REGULAR_EXPRESSION_BACKGROUND;