use of org.talend.designer.core.generic.ui.JsonTableView in project tdi-studio-se by Talend.
the class JsonTableController method estimateRowSize.
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
JsonTableView tableEditorView = generateTableEditorView(subComposite, param);
int height = adjustTableHeight(tableEditorView, param);
return height + ITabbedPropertyConstants.VSPACE;
}
use of org.talend.designer.core.generic.ui.JsonTableView in project tdi-studio-se by Talend.
the class JsonTableController method createControl.
@Override
public Control createControl(final Composite parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
final Composite container = parentComposite;
JsonTableView tableEditorView = generateTableEditorView(parentComposite, param);
final Composite mainComposite = tableEditorView.getMainComposite();
mainComposite.setData(PARAMETER_NAME, param.getName());
String labelDisplayName = param.getDisplayName();
CLabel label = getWidgetFactory().createCLabel(container, labelDisplayName);
FormData formData = new FormData();
if (lastControl != null) {
formData.left = new FormAttachment(lastControl, 0);
} else {
formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
formData.top = new FormAttachment(0, top);
label.setLayoutData(formData);
formData = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(label);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + (ITabbedPropertyConstants.HSPACE * 2)) > currentLabelWidth) {
currentLabelWidth = labelSize.x + (ITabbedPropertyConstants.HSPACE * 2);
}
if (numInRow == 1) {
if (lastControl != null) {
formData.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
formData.left = new FormAttachment(0, currentLabelWidth);
}
} else {
formData.left = new FormAttachment(label, 0, SWT.RIGHT);
}
formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
formData.top = new FormAttachment(0, top);
int height = adjustTableHeight(tableEditorView, param);
formData.bottom = new FormAttachment(0, top + height);
mainComposite.setLayoutData(formData);
hashCurControls.put(param.getName(), tableEditorView.getExtendedTableViewer().getTableViewerCreator());
this.dynamicProperty.setCurRowSize(height + ITabbedPropertyConstants.VSPACE);
if (isInWizard()) {
label.setAlignment(SWT.RIGHT);
if (lastControl != null) {
formData.right = new FormAttachment(lastControl, 0);
} else {
formData.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
}
formData.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth + ITabbedPropertyConstants.HSPACE);
formData = (FormData) label.getLayoutData();
formData.right = new FormAttachment(mainComposite, 0);
formData.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
return label;
}
return mainComposite;
}
use of org.talend.designer.core.generic.ui.JsonTableView in project tdi-studio-se by Talend.
the class JsonTableController method generateTableEditorView.
private JsonTableView generateTableEditorView(Composite parent, IElementParameter param) {
JsonTableVO vo = null;
Object value = param.getValue();
if (value != null) {
String valueStr = TalendQuoteUtils.removeQuotesIfExist(String.valueOf(value));
if (StringUtils.isNotBlank(valueStr)) {
vo = JsonTableHandler.getInstance().parse(valueStr);
}
}
if (vo != null) {
rows = vo.getData();
if (rows != null) {
rowsNum = rows.size();
}
titles = vo.getTitles();
}
JsonFieldModel tableEditorModel = new JsonFieldModel(rows);
JsonTableView tableEditorView = new JsonTableView(parent, tableEditorModel, readonly, !hideToolbar) {
@Override
protected List<String> getColumnTitles() {
return titles;
}
};
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly() || param.isRepositoryValueUsed());
tableEditorModel.setModifiedBeanListenable(tableEditorView.getTableViewerCreator());
final Table table = tableEditorView.getTable();
table.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
// add listener to tableMetadata (listen the event of the toolbars)
tableEditorView.getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {
@Override
public void handleEvent(ListenableListEvent event) {
if (elem instanceof Node) {
Node node = (Node) elem;
node.checkAndRefreshNode();
}
}
});
return tableEditorView;
}
Aggregations