use of org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PropertiesTableEditorView in project tdi-studio-se by Talend.
the class TableController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
PropertiesTableEditorModel<Map<String, Object>> tableEditorModel = new PropertiesTableEditorModel<Map<String, Object>>();
updateTableValues(param);
tableEditorModel.setData(elem, param, part.getProcess());
PropertiesTableEditorView<Map<String, Object>> tableEditorView = new PropertiesTableEditorView<Map<String, Object>>(subComposite, SWT.NONE, tableEditorModel, !param.isBasedOnSchema(), false);
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly());
final Table table = tableEditorView.getTable();
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = tableEditorView.getExtendedToolbar().getToolbar().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y + 5;
}
int currentHeightEditor = table.getHeaderHeight() + ((List) param.getValue()).size() * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int minHeightEditor = table.getHeaderHeight() + getNumberLines(param) * table.getItemHeight() + table.getItemHeight() + toolbarSize;
tableEditorView.getMainComposite().dispose();
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
return ySize2 + ITabbedPropertyConstants.VSPACE;
}
use of org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PropertiesTableEditorView in project tdi-studio-se by Talend.
the class TableController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#
* createControl(org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
public Control createControl(final Composite parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControlPrm) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
final Composite container = parentComposite;
PropertiesTableEditorModel<Map<String, Object>> tableEditorModel = new PropertiesTableEditorModel<Map<String, Object>>();
tableEditorModel.setData(elem, param, getProcess(elem, part));
PropertiesTableEditorView<Map<String, Object>> tableEditorView = new PropertiesTableEditorView<Map<String, Object>>(parentComposite, SWT.NONE, tableEditorModel, !param.isBasedOnSchema(), false);
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly() || param.isRepositoryValueUsed());
tableEditorModel.setModifiedBeanListenable(tableEditorView.getTableViewerCreator());
tableEditorModel.addModifiedBeanListenerForAggregateComponent();
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();
}
}
});
final Composite mainComposite = tableEditorView.getMainComposite();
CLabel labelLabel2 = getWidgetFactory().createCLabel(container, param.getDisplayName());
FormData formData = new FormData();
if (lastControlPrm != null) {
formData.left = new FormAttachment(lastControlPrm, 0);
} else {
formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
formData.top = new FormAttachment(0, top);
labelLabel2.setLayoutData(formData);
if (numInRow != 1) {
labelLabel2.setAlignment(SWT.RIGHT);
}
// *********************
formData = new FormData();
int currentLabelWidth2 = STANDARD_LABEL_WIDTH;
GC gc2 = new GC(labelLabel2);
Point labelSize2 = gc2.stringExtent(param.getDisplayName());
gc2.dispose();
boolean needOffset = true;
if ((labelSize2.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth2) {
currentLabelWidth2 = labelSize2.x + ITabbedPropertyConstants.HSPACE;
needOffset = false;
}
int tableHorizontalOffset = -5;
if (numInRow == 1) {
if (lastControlPrm != null) {
if (needOffset) {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2);
}
} else {
if (needOffset) {
formData.left = new FormAttachment(0, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(0, currentLabelWidth2);
}
}
} else {
formData.left = new FormAttachment(labelLabel2, 0 + tableHorizontalOffset, SWT.RIGHT);
}
formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
formData.top = new FormAttachment(0, top);
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = tableEditorView.getExtendedToolbar().getToolbar().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y + 5;
}
int currentHeightEditor = table.getHeaderHeight() + ((List) param.getValue()).size() * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int minHeightEditor = table.getHeaderHeight() + getNumberLines(param) * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
ySize2 = Math.min(ySize2, 500);
formData.bottom = new FormAttachment(0, top + ySize2);
mainComposite.setLayoutData(formData);
hashCurControls.put(param.getName(), tableEditorView.getExtendedTableViewer().getTableViewerCreator());
hashCurControls.put(TOOLBAR_NAME, tableEditorView.getToolBar());
updateTableValues(param);
this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
if (isInWizard()) {
labelLabel2.setAlignment(SWT.RIGHT);
if (lastControlPrm != null) {
formData.right = new FormAttachment(lastControlPrm, 0);
} else {
formData.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
}
formData.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth2 + ITabbedPropertyConstants.HSPACE);
formData = (FormData) labelLabel2.getLayoutData();
formData.right = new FormAttachment(mainComposite, 0);
formData.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
return labelLabel2;
}
return mainComposite;
}
Aggregations