use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel 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.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method commit.
@Override
public void commit() {
DirectEditType directEditType = cellAndType.get(getCellEditor());
if (directEditType != null) {
switch(directEditType) {
case SERACH:
VarNodeTextLabel figure = null;
if (this.locator instanceof XmlMapNodeCellEditorLocator) {
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
figure = (VarNodeTextLabel) lo.getFigure();
Object searchTextObject = getDirectEditRequest().getCellEditor().getValue();
if (searchTextObject != null) {
if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
searchZone.search(searchTextObject.toString());
figure.setText(searchTextObject.toString());
}
}
}
}
}
}
super.commit();
}
use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.
the class XmlMapSearchZoneToolBar method createZoneContent.
@Override
public void createZoneContent() {
super.createZoneContent();
Label findLabel = new Label("Find :");
add(findLabel);
searchText = new VarNodeTextLabel();
searchText.setDirectEditType(DirectEditType.SERACH);
// searchText.setText("Enter search text prefix or pattern(*,?)");
searchText.setLabelAlignment(PositionConstants.LEFT);
searchText.setBorder(new LineBorder(ColorConstants.gray));
searchText.setOpaque(true);
searchText.setBackgroundColor(ColorConstants.white);
add(searchText);
this.add(move_down);
this.add(move_up);
this.add(hightLightAll);
move_down.setEnabled(true);
move_up.setEnabled(true);
}
use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.
the class VarEntityFigure method createVariableContainer.
protected Figure createVariableContainer() {
Figure container = new Figure();
// container.setBorder(new RowBorder());
ToolbarLayout manager = new ToolbarLayout() {
@Override
public void layout(IFigure parent) {
super.layout(parent);
List children = parent.getChildren();
if (children.size() == 2) {
Figure checkImageFigure = (Figure) children.get(0);
Figure variableFigure = (Figure) children.get(1);
Rectangle varFigureBounds = variableFigure.getBounds().getCopy();
int avialableWith = parent.getBounds().width - checkImageFigure.getBounds().width;
if (avialableWith > varFigureBounds.width) {
varFigureBounds.width = avialableWith;
}
variableFigure.setBounds(varFigureBounds);
}
}
};
manager.setVertical(false);
manager.setStretchMinorAxis(false);
container.setLayoutManager(manager);
// if(varNode.)
Label nullableToolTip = new Label("Nullable");
if (!isNullable()) {
checkImage = new ImageFigure(ImageProvider.getImage(EImage.UNCHECKED_ICON));
} else {
checkImage = new ImageFigure(ImageProvider.getImage(EImage.CHECKED_ICON));
}
checkImage.setToolTip(nullableToolTip);
variableLabel = new VarNodeTextLabel();
variableLabel.setText(getVarName());
variableLabel.setLabelAlignment(PositionConstants.LEFT);
variableLabel.setBorder(new MarginBorder(2, 5, 2, -1));
container.add(checkImage);
container.add(variableLabel);
addCheckListener();
return container;
}
Aggregations