use of org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class JSONFileMetadataEmfToolbarEditor method createAddPushButton.
@Override
protected AddPushButton createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
protected Object getObjectToAdd() {
MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
if (tableEditorModel.getMetadataTable() == null) {
tableEditorModel.setMetadataTable(ConnectionFactory.eINSTANCE.createMetadataTable());
}
MetadataColumn metadatacolumn = tableEditorModel.createNewMetadataColumn(dbmsId);
return metadatacolumn;
}
};
}
use of org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class PropertiesTableToolbarEditorView method createAddPushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createAddPushButton()
*/
@Override
protected AddPushButton createAddPushButton() {
final AddPushButton addPushButton = new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
public boolean getEnabledState() {
if (model != null && !model.getElemParameter().getElement().isReadOnly() && (model.getElemParameter().getName().equals("HADOOP_ADVANCED_PROPERTIES") || model.getElemParameter().getName().equals("HBASE_PARAMETERS") || model.getElemParameter().getName().equals("SPARK_ADVANCED_PROPERTIES")) && !model.getElemParameter().isRepositoryValueUsed()) {
return true;
}
return super.getEnabledState() && (model == null || !model.getElemParameter().isBasedOnSubjobStarts());
}
@Override
protected Object getObjectToAdd() {
PropertiesTableEditorModel tableEditorModel = (PropertiesTableEditorModel) getExtendedTableViewer().getExtendedControlModel();
if (!tableEditorModel.isButtonEnabled()) {
MessageDialog.openInformation(tableEditorModel.getTableViewer().getControl().getShell(), "Information", "All output columns have been added already");
return null;
}
Object newEntry = tableEditorModel.createNewEntry();
if (tableEditorModel.isAggregateRow() && newEntry instanceof Map) {
List<ColumnInfo> tableInputs = new ArrayList<ColumnInfo>();
String[] displayNames = tableEditorModel.getElemParameter().getListItemsDisplayName();
Object[] itemsValue = tableEditorModel.getElemParameter().getListItemsValue();
// default name //$NON-NLS-1$
String paramColumnsName = "COLUMN";
for (int i = 0; i < itemsValue.length; i++) {
if (itemsValue[i] instanceof IElementParameter) {
IElementParameter tableParameter = (IElementParameter) itemsValue[i];
if (tableParameter.getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
paramColumnsName = tableParameter.getName();
} else {
ColumnInfo row = new ColumnInfo();
row.name = displayNames[i];
row.parameter = tableParameter;
row.defaultValue = "";
tableInputs.add(row);
}
}
}
Node node = (Node) tableEditorModel.getElement();
String outputTableName = null;
if (node.getMetadataList() != null && !node.getMetadataList().isEmpty()) {
IMetadataTable metadata = node.getMetadataList().get(0);
if (metadata.getListColumns() != null) {
for (IMetadataColumn column : metadata.getListColumns()) {
if (!tableEditorModel.exist(column.getLabel())) {
outputTableName = column.getLabel();
break;
}
}
}
}
if (outputTableName != null) {
Map mapObject = (Map) newEntry;
if (mapObject.containsKey(paramColumnsName)) {
mapObject.put(paramColumnsName, outputTableName);
}
for (ColumnInfo col : tableInputs) {
Object defaultValue = col.defaultValue;
Object found = findDefaultName(outputTableName, col);
if (found != null && !"".equals(found)) {
defaultValue = found;
}
if (defaultValue != null && !"".equals(defaultValue)) {
mapObject.put(col.parameter.getName(), defaultValue);
}
}
}
}
return newEntry;
}
};
// TDI-6568, after added, fire change
addPushButton.addListener(getPropertyChangeListener(), false);
return addPushButton;
}
use of org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class HL7MetadataEmfToolbarEditor method createAddPushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createAddPushButton()
*/
@Override
protected AddPushButton createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
boolean hasSchema = false;
@Override
protected Object getObjectToAdd() {
if (hasSchema) {
MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
if (tableEditorModel.getMetadataTable() == null) {
tableEditorModel.setMetadataTable(ConnectionFactory.eINSTANCE.createMetadataTable());
}
MetadataColumn metadatacolumn = tableEditorModel.createNewMetadataColumn(dbmsId);
metadatacolumn.setLength(226);
metadatacolumn.setPrecision(0);
updateCurrentTableModelAndMap(tableEditorModel);
return metadatacolumn;
}
return null;
}
@Override
protected void beforeCommandExecution() {
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
hasSchema = true;
super.beforeCommandExecution();
} else {
hasSchema = false;
MessageDialog.openError(HL7MetadataEmfToolbarEditor.this.getParentComposite().getShell(), "Can't add new column!", "Need to init a schema by choosing a file at first");
}
}
private void updateCurrentTableModelAndMap(MetadataEmfTableEditor tableEditorModel) {
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
linker.getManager().updateRelationMapping(key, tableEditorModel.createNewMetadataColumn(dbmsId), true);
}
}
@Override
public boolean getEnabledState() {
// 13749
return super.getEnabledState() && !isRepository;
}
};
}
use of org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class ExtractionFieldsWithJSONXPathEditorView method initToolBar.
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.advanced.dataeditor.AbstractDataTableEditorView#initToolBar()
*/
@Override
protected ExtendedToolbarView initToolBar() {
return new ExtendedToolbarView(getMainComposite(), SWT.NONE, getExtendedTableViewer()) {
@Override
protected AddPushButtonForExtendedTable createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
protected Object getObjectToAdd() {
UniqueStringGenerator<SchemaTarget> generator = new UniqueStringGenerator<SchemaTarget>("column", getModel().getBeansList()) {
@Override
protected String getBeanString(SchemaTarget bean) {
// TODO Auto-generated method stub
return bean.getRelativeXPathQuery();
}
};
SchemaTarget tarhe = getModel().createNewSchemaTarget();
tarhe.setRelativeXPathQuery(generator.getUniqueString());
tarhe.setTagName(generator.getUniqueString());
return tarhe;
}
};
}
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createPastePushButton()
*/
@Override
protected PastePushButton createPastePushButton() {
return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
return new ExtendedTablePasteCommand(extendedTableModel, indexWhereInsert) {
@Override
public List createPastableBeansList(ExtendedTableModel extendedTableModel, List copiedObjectsList) {
ArrayList list = new ArrayList();
JSONExtractorFieldModel fieldsModel = (JSONExtractorFieldModel) extendedTableModel;
for (Object current : copiedObjectsList) {
if (current instanceof SchemaTarget) {
SchemaTarget original = (SchemaTarget) current;
SchemaTarget copy = fieldsModel.createNewSchemaTarget();
copy.setRelativeXPathQuery(original.getRelativeXPathQuery());
copy.setTagName(original.getTagName());
list.add(copy);
}
}
return list;
}
};
}
};
}
};
}
use of org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class ConnectionsListButtonsToolBar method createAddPushButton.
@Override
protected AddPushButton createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
protected Object getObjectToAdd() {
ConnectionBean newConnection = new ConnectionBean();
newConnection.setName(NEW_CONNECTION_LABEL);
return newConnection;
}
};
}
Aggregations