////////////////////////////////////////////////////////////////////////////
private void bindColumnsAsArray(MethodInvocation invocation, List<JavaInfo> javaInfoList)
throws Exception {
List<Expression> asListArguments = DomGenerics.arguments(invocation);
// create info
final EllipsisObjectInfo arrayInfo =
new EllipsisObjectInfo(getEditor(),
"Arrays.asList",
EditorState.get(getEditor()).getEditorLoader().loadClass(
"com.extjs.gxt.ui.client.widget.grid.ColumnConfig"),
invocation,
0);
addChild(arrayInfo);
arrayInfo.setRemoveOnEmpty(false);
arrayInfo.setHideInTree(true);
arrayInfo.setOnEmptySource("java.util.Collections.<com.extjs.gxt.ui.client.widget.grid.ColumnConfig>emptyList()");
// process infos
for (Expression asListArgument : asListArguments) {
for (JavaInfo javaInfo : javaInfoList) {
if (javaInfo instanceof ColumnConfigInfo && javaInfo.getParent() == null) {
ColumnConfigInfo column = (ColumnConfigInfo) javaInfo;
if (column.isRepresentedBy(asListArgument)) {
addChild(column);
arrayInfo.addItem(column);
column.setAssociation(new InvocationChildEllipsisAssociation(invocation, arrayInfo));
}
}
}
}
m_columnBinder = new ColumnsBinder() {
@Override
void bindColumnObjects() {
// do nothing
}
@Override
void create(ColumnConfigInfo column, ColumnConfigInfo nextColumn) throws Exception {
ensureColumnsAsArray();
arrayInfo.command_CREATE(column, nextColumn);
}
@Override
void move(ColumnConfigInfo column, ColumnConfigInfo nextColumn) throws Exception {
ensureColumnsAsArray();
arrayInfo.command_MOVE(column, nextColumn);
}
void ensureColumnsAsArray() 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 MethodInvocation) {
MethodInvocation invocation = (MethodInvocation) columnsList;
if (invocation == arrayInfo.getInvocation()) {
return;
}
}
// if no columns then generate new Array.asList()
MethodInvocation invocation =
(MethodInvocation) getEditor().replaceExpression(
columnsList,
"java.util.Arrays.asList()");
arrayInfo.setInvocation(invocation);
}
};
}