use of org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method createCellEditorOn.
@Override
protected CellEditor createCellEditorOn(Composite composite) {
Composite parent = (Composite) source.getViewer().getControl();
CellEditor cellEditor = null;
Figure figure = null;
if (this.locator instanceof XmlMapNodeCellEditorLocator) {
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
figure = lo.getFigure();
}
if (figure instanceof IComboCell) {
try {
// tree setting can be edit or not
if (source instanceof InputXmlTreeEditPart) {
InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
return null;
}
}
if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
return null;
}
}
}
if (source instanceof OutputXmlTreeEditPart) {
OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
boolean hasAggregate = false;
for (int i = 0; i < outputTree.getNodes().size(); i++) {
OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
hasAggregate = hasAggreage(outputTreeNode);
if (hasAggregate) {
break;
}
}
if (hasAggregate) {
return null;
}
} else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
}
}
cellEditor = new XmlComboCellEditor();
cellEditor.create(composite);
((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
} catch (Exception e) {
return null;
}
} else if (figure instanceof ITextCell) {
// this one is created for direct doc child name , no use anymore...
cellEditor = new TextCellEditor(composite);
cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
// for the search
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
figure = (VarNodeTextLabel) lo.getFigure();
if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
if (searchZone.getSearchMaps().size() > 0) {
searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
searchZone.getSearchZoneMapper().setHightlightAll(false);
searchZone.getSearchMaps().clear();
searchZone.hightLightAll.setSelected(false);
}
}
}
} else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
} else if (figure instanceof ITextAreaCell) {
TextAreaBehavior behavior = new TextAreaBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
} else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
}
// }
return cellEditor;
}
use of org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior in project tdi-studio-se by Talend.
the class FunParaTableView2 method createColumns.
@Override
protected void createColumns(TableViewerCreator<Parameter> tableViewerCreator, final Table table) {
this.tableViewerCreator = tableViewerCreator;
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
TableViewerCreatorColumn column;
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("FunParaTableView2.Parameter"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {
public String get(Parameter bean) {
return bean.getName();
}
public void set(Parameter bean, Object value) {
}
});
column.setModifiable(false);
column.setWidth(115);
// column.setCellEditor(new
// TextCellEditor(tableViewerCreator.getTable()));
// ////////////////////////////////////////////////////////
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("FunParaTableView2.Value"));
column.setId(VALUE_PROPERTY);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExtendedTextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column, behavior);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {
public String get(Parameter bean) {
StringBuffer id = new StringBuffer();
//$NON-NLS-1$
id.append(component.getLabel() + "=>");
TableItem[] item = rowGenTableEditor2.getTable().getSelection();
if (item.length == 1) {
//$NON-NLS-1$
id.append(((MetadataColumnExt) item[0].getData()).getLabel() + "=>");
}
cellEditor.setOwnerId(id.append(bean.getName()).toString());
cellEditor.setExpressionType(bean.getType());
String valueTemp = bean.getValue();
if (valueTemp != null && !valueTemp.endsWith(" ")) {
bean.setValue(valueTemp + " ");
}
return bean.getValue();
}
public void set(Parameter bean, Object value) {
if (value == null) {
return;
}
String valueTemp = value.toString();
if (!valueTemp.endsWith(" ")) {
value = value + " ";
}
bean.setValue(value.toString());
if (ext != null) {
ext.setChanged(true);
}
if (!rowGenTableEditor2.getTableViewerCreator().getTableViewer().isCellEditorActive()) {
rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
}
}
});
column.setModifiable(true);
column.setWidth(115);
dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(mainComposite, cellEditor, component);
behavior.setCellEditorDialog(dialog);
cellEditor.setContentProposalProvider(getProcessProposals());
//$NON-NLS-1$
cellEditor.setExpressionType("String");
column.setCellEditor(cellEditor);
// ////////////////////////////////////////////////////////
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("FunParaTableView2.Comment"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {
public String get(Parameter bean) {
return bean.getComment();
}
public void set(Parameter bean, Object value) {
}
});
column.setModifiable(false);
column.setWidth(155);
// column.setCellEditor(new
// TextCellEditor(tableViewerCreator.getTable()));
// ////////////////////////////////////////////////////////
}
Aggregations