use of org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PropertiesTableEditorModel 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.PropertiesTableEditorModel in project tdi-studio-se by Talend.
the class TableByRowController 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>>();
if (param.getValue() == null || param.getValue().equals("")) {
param.setValue(new ArrayList<Map<String, Object>>());
}
init(elem, param);
tableEditorModel.setData(elem, param, getProcess(elem, part));
PropertiesTableByRowEditorView<Map<String, Object>> tableEditorView = new PropertiesTableByRowEditorView<Map<String, Object>>(parentComposite, SWT.NONE, tableEditorModel, true, 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() + 1 * 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);
top += this.dynamicProperty.getCurRowSize();
return null;
}
use of org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PropertiesTableEditorModel in project tdi-studio-se by Talend.
the class TableByRowController 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);
if (param.getValue() == null || param.getValue().equals("")) {
param.setValue(new ArrayList<Map<String, Object>>());
}
init(elem, param);
tableEditorModel.setData(elem, param, part.getProcess());
PropertiesTableByRowEditorView<Map<String, Object>> tableEditorView = new PropertiesTableByRowEditorView<Map<String, Object>>(subComposite, SWT.NONE, tableEditorModel, true, 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.PropertiesTableEditorModel 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;
}
use of org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PropertiesTableEditorModel in project tdi-studio-se by Talend.
the class PropertyTablePasteCommand method createPastableBeansList.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTablePasteCommand#createPastableBeansList(java
* .util.List)
*/
@Override
public List createPastableBeansList(ExtendedTableModel extendedTable, List copiedObjectsList) {
ArrayList list = new ArrayList();
IElementParameter param = null;
INode node = null;
if (extendedTable instanceof PropertiesTableEditorModel) {
PropertiesTableEditorModel<B> model = (PropertiesTableEditorModel<B>) extendedTable;
if (model.getElement() instanceof INode) {
node = (INode) model.getElement();
param = model.getElemParameter();
}
}
for (Object current : copiedObjectsList) {
if (current instanceof HashMap) {
// create a new column as a copy of this column
Map<String, Object> clonedRow = (Map<String, Object>) ((HashMap) current).clone();
if (param != null) {
for (String key : clonedRow.keySet()) {
Object value = clonedRow.get(key);
if (value instanceof String && !"".equals(value)) {
IElementParameter childParam = null;
for (Object o : param.getListItemsValue()) {
if (o instanceof IElementParameter) {
if (((IElementParameter) o).getName().equals(key)) {
childParam = (IElementParameter) o;
break;
}
}
}
if (childParam != null && childParam.getFieldType() == EParameterFieldType.SCHEMA_TYPE) {
IMetadataTable originalMetadata = node.getMetadataTable((String) value);
IMetadataTable clonedMetadata = originalMetadata.clone();
List<String> tableList = new ArrayList<String>();
for (IMetadataTable table : node.getMetadataList()) {
tableList.add(table.getTableName());
}
String newTableName = UniqueNodeNameGenerator.generateUniqueNodeName(originalMetadata.getTableName(), tableList);
clonedMetadata.setTableName(newTableName);
clonedMetadata.setLabel(newTableName);
node.getMetadataList().add(clonedMetadata);
clonedRow.put(key, newTableName);
}
}
}
}
list.add(clonedRow);
}
}
return list;
}
Aggregations