use of org.talend.repository.model.json.SchemaTarget 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.repository.model.json.SchemaTarget in project tdi-studio-se by Talend.
the class ExtractionFieldsWithJSONXPathEditorView method createColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
* .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
*/
@Override
protected void createColumns(TableViewerCreator<SchemaTarget> tableViewerCreator, final Table table) {
CellEditorValueAdapter intValueAdapter = new CellEditorValueAdapter() {
@Override
public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
try {
return new Integer(value.toString());
} catch (Exception ex) {
return null;
}
}
@Override
public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
if (value != null) {
return String.valueOf(value);
}
//$NON-NLS-1$
return "";
}
};
// //////////////////////////////////////////////////////////////////////////////////////
// column for mouse selection
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWidth(15);
// //////////////////////////////////////////////////////////////////////////////////////
// X Path Query
column = new TableViewerCreatorColumn(tableViewerCreator);
xPathColumn = column;
//$NON-NLS-1$
column.setTitle("Relative or absolute path expression");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<SchemaTarget, String>() {
@Override
public String get(SchemaTarget bean) {
return bean.getRelativeXPathQuery();
}
@Override
public void set(SchemaTarget bean, String value) {
bean.setRelativeXPathQuery(value);
}
});
xPathCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
column.setCellEditor(xPathCellEditor);
xPathCellEditor.addListener(new DialogErrorForCellEditorListener(xPathCellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
if (state == CELL_EDITOR_STATE.EDITING) {
linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
}
}
@Override
public String validateValue(String newValue, int beanPosition) {
String currentLoopXPath = linker.getCurrentLoopXPath();
String value = null;
if (newValue.trim().length() == 0) {
return null;
} else if (newValue.trim().startsWith(linker.getRootSeperator())) {
value = newValue;
} else {
value = currentLoopXPath + linker.getFieldSeperator() + newValue;
}
return linker.validateXPathExpression(value);
}
});
column.setModifiable(true);
column.setWeight(30);
column.setMinimumWidth(50);
//$NON-NLS-1$
column.setDefaultInternalValue("");
// //////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////
// Tag Name
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("Column Name");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<SchemaTarget, String>() {
@Override
public String get(SchemaTarget bean) {
return bean.getTagName();
}
@Override
public void set(SchemaTarget bean, String value) {
bean.setTagName(value);
}
});
column.setModifiable(true);
column.setWeight(10);
column.setMinimumWidth(50);
// column.setCellEditor(new TextCellEditor(table));
//$NON-NLS-1$
column.setDefaultInternalValue("");
final TextCellEditorWithProposal tagNameCellEditor = createTagNameEditor(tableViewerCreator, column);
column.setCellEditor(tagNameCellEditor);
}
use of org.talend.repository.model.json.SchemaTarget in project tdi-studio-se by Talend.
the class JSONToXPathLinker method handleListenableListAfterTableViewerRefreshedEvent.
public void handleListenableListAfterTableViewerRefreshedEvent(final ListenableListEvent<SchemaTarget> event) {
if (event.type == ListenableListEvent.TYPE.ADDED) {
ProgressDialog progressDialog = new ProgressDialog(getTree().getShell(), 1000) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) {
monitorWrap = new EventLoopProgressMonitor(monitor);
List<SchemaTarget> addedObjects = new ArrayList<SchemaTarget>(event.addedObjects);
JSONToXPathLinker.this.createFieldsLinkWithProgressMonitor(monitorWrap, addedObjects.size(), addedObjects, event.index, addedObjects.size());
monitorWrap.done();
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
getBackgroundRefresher().refreshBackground();
} else if (event.type == ListenableListEvent.TYPE.SWAPED) {
getBackgroundRefresher().refreshBackground();
} else if (event.type == TYPE.REMOVED) {
getBackgroundRefresher().refreshBackground();
}
}
use of org.talend.repository.model.json.SchemaTarget in project tdi-studio-se by Talend.
the class JSONToXPathLinker method parseAllFieldsXPathExpressions.
public void parseAllFieldsXPathExpressions() {
List<SchemaTarget> beansList = fieldsTableEditorView.getExtendedTableModel().getBeansList();
int lstSize = beansList.size();
for (int i = 0; i < lstSize; i++) {
SchemaTarget schemaTarget = beansList.get(i);
onXPathValueChanged(fieldsTableEditorView.getTable(), schemaTarget.getRelativeXPathQuery(), i);
}
}
Aggregations