}
}
else if (FIELD_VALUE_ROLE.equals(valueRole))
{
final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
final FieldSelectorDialog editorDialog;
if (window instanceof Frame)
{
editorDialog = new FieldSelectorDialog((Frame) window);
}
else if (window instanceof Dialog)
{
editorDialog = new FieldSelectorDialog((Dialog) window);
}
else
{
editorDialog = new FieldSelectorDialog();
}
final FieldDefinition[] fields = getFields();
final String selectedItem = (String) comboBox.getSelectedItem();
FieldDefinition selected = null;
if (selectedItem != null)
{
for (int i = 0; i < fields.length; i++)
{
final FieldDefinition field = fields[i];
if (selectedItem.equals(field.getName()))
{
selected = field;
break;
}
}
}
final FieldDefinition fieldDefinition = editorDialog.performEdit(fields, selected);
if (fieldDefinition != null)
{
comboBox.setSelectedItem(fieldDefinition.getName());
}
}
else if (QUERY_VALUE_ROLE.equals(valueRole))
{
final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
final QuerySelectorDialog editorDialog;
if (window instanceof Frame)
{
editorDialog = new QuerySelectorDialog((Frame) window);
}
else if (window instanceof Dialog)
{
editorDialog = new QuerySelectorDialog((Dialog) window);
}
else
{
editorDialog = new QuerySelectorDialog();
}
final String selectedQuery =
editorDialog.performEdit(getQueryNames(), (String) comboBox.getSelectedItem());
if (editorDialog.isConfirmed())
{
comboBox.setSelectedItem(selectedQuery);
}
}
else if (GROUP_VALUE_ROLE.equals(valueRole))
{
final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
final GroupSelectorDialog editorDialog;
if (window instanceof Frame)
{
editorDialog = new GroupSelectorDialog((Frame) window);
}
else if (window instanceof Dialog)
{
editorDialog = new GroupSelectorDialog((Dialog) window);
}
else
{
editorDialog = new GroupSelectorDialog();
}
final String originalGroup = (String) comboBox.getSelectedItem();
final String selectedGroup = editorDialog.performEdit(getGroups(), originalGroup);
if (editorDialog.isConfirmed())
{
comboBox.setSelectedItem(selectedGroup);
}
}
else if (FORMULA_VALUE_ROLE.equals(valueRole))
{
final FormulaEditorDialog editorDialog =
GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), AbstractStringValueCellEditor.this);
final String originalFormula = (String) comboBox.getSelectedItem();
final String formula = editorDialog.editFormula(originalFormula, getFields());
if (formula != null)
{
comboBox.setSelectedItem(formula);
}
}
else if (NUMBER_FORMAT_VALUE_ROLE.equals(valueRole) || DATE_FORMAT_VALUE_ROLE.equals(valueRole))
{
final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
final TextAreaPropertyEditorDialog editorDialog;
if (window instanceof Frame)
{
editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
}
else if (window instanceof Dialog)
{
editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
}
else
{
editorDialog = new TextAreaPropertyEditorDialog();
}
final String originalFormula = (String) comboBox.getSelectedItem();
final String text = editorDialog.performEdit(originalFormula);
if (editorDialog.isConfirmed())
{
comboBox.setSelectedItem(text);
}
}
else
{
final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
final TextAreaPropertyEditorDialog editorDialog;
if (window instanceof Frame)
{
editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
}
else if (window instanceof Dialog)
{
editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
}
else
{
editorDialog = new TextAreaPropertyEditorDialog();
}
final JTextComponent textField = getTextField();
final String originalValue = textField.getText();
final String text = editorDialog.performEdit(originalValue);
if (editorDialog.isConfirmed())
{
textField.setText(text);
}
}