SimpleName columnsList = ensureColumnsList();
ColumnConfigAssociation association = new ColumnConfigAssociation(columnsList);
AssociationObject associationObject = new AssociationObject(association, true);
if (nextColumn == null) {
Statement columnsListUsageStatement = AstNodeUtils.getEnclosingStatement(columnsList);
StatementTarget target = new StatementTarget(columnsListUsageStatement, true);
JavaInfoUtils.addTarget(column, associationObject, GridInfo.this, target);
} else {
JavaInfoUtils.add(column, associationObject, GridInfo.this, nextColumn);
}
}
@Override
void move(ColumnConfigInfo column, ColumnConfigInfo nextColumn) throws Exception {
SimpleName columnsList = ensureColumnsList();
ColumnConfigAssociation association = new ColumnConfigAssociation(columnsList);
AssociationObject associationObject = new AssociationObject(association, true);
if (nextColumn == null) {
Statement columnsListUsageStatement = AstNodeUtils.getEnclosingStatement(columnsList);
StatementTarget target = new StatementTarget(columnsListUsageStatement, true);
JavaInfoUtils.moveTarget(column, associationObject, GridInfo.this, null, target);
} else {
JavaInfoUtils.move(column, associationObject, GridInfo.this, nextColumn);
}
}
SimpleName ensureColumnsList() throws Exception {
ClassInstanceCreation columnModelCreation = getColumnModelCreation(true);
// "columns" List usage in "ColumnModel" creation
List<Expression> columnModelArguments = DomGenerics.arguments(columnModelCreation);
Expression columnsList = columnModelArguments.get(0);
if (columnsList instanceof SimpleName) {
return (SimpleName) columnsList;
}
// if no columns then generate new ArrayList
Statement columnModelStatement = AstNodeUtils.getEnclosingStatement(columnModelCreation);
StatementTarget target = new StatementTarget(columnModelStatement, true);
String configsName =
getEditor().getUniqueVariableName(
columnModelStatement.getStartPosition(),
"configs",
null);