use of org.eclipse.emf.common.notify.Adapter in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
if (searchValue.equals("") || searchValue == null) {
return;
}
List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
matcher.setPattern("*" + searchValue.trim() + "*");
int index = -1;
// for the InputTables
for (InputXmlTree inputXmlTree : inputTrees) {
// ExpressionFilter
if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = inputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof InputXmlTreeEditPart) {
InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, inputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// TreeNode
for (TreeNode node : inputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
}
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the VarsTables
for (VarTable varTable : varTables) {
for (VarNode node : varTable.getNodes()) {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the OutputTables
for (OutputXmlTree outputXmlTree : outputTrees) {
// ExpressionFilter
if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = outputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, outputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// OutputTreeNode
for (OutputTreeNode node : outputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
} else {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
}
}
use of org.eclipse.emf.common.notify.Adapter in project tdi-studio-se by Talend.
the class SearchZoneMapper method getMatcherNodeFigure.
private Map<Integer, Figure> getMatcherNodeFigure(AbstractNode node) {
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
int i = -1;
TableEntityFigure figure = null;
if (node != null) {
EList<Adapter> adapter = node.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof TableEntityPart) {
TableEntityPart tableEntityPart = (TableEntityPart) adapter.get(0);
if (tableEntityPart != null && tableEntityPart.getFigure() != null && tableEntityPart.getFigure() instanceof TableEntityFigure) {
figure = (TableEntityFigure) tableEntityPart.getFigure();
}
}
}
if (node.getExpression() != null && matcher.matches(node.getExpression())) {
i++;
map.put(i, figure);
} else if (node.getName() != null && matcher.matches(node.getName())) {
i++;
map.put(i, figure);
}
}
return map;
}
use of org.eclipse.emf.common.notify.Adapter in project tdi-studio-se by Talend.
the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.
public void moveScrollBarZoneAtSelectedTableItem(Figure entry) {
if (entry != null) {
Rectangle bounds = entry.getBounds();
int selection = bounds.y - 100;
if (entry instanceof XmlmapTreeNodeFigure) {
XmlmapTreeNodeFigure xmlMapTreeNodeFigure = (XmlmapTreeNodeFigure) entry;
TreeNode treeNode = xmlMapTreeNodeFigure.getTreeNode();
if (treeNode != null) {
for (Adapter adapter : treeNode.eAdapters()) {
TreeNodeEditPart part = (TreeNodeEditPart) adapter;
XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
if (adapter instanceof OutputTreeNodeEditPart) {
Viewport viewport = xmlMapDataEditPart.getOutputScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
} else if (adapter instanceof TreeNodeEditPart) {
Viewport viewport = xmlMapDataEditPart.getInputScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
}
}
}
} else if (entry instanceof VarNodeFigure) {
VarNodeFigure varNodeFigure = (VarNodeFigure) entry;
VarNode varNode = varNodeFigure.getVarNode();
if (varNode != null) {
for (Adapter adapter : varNode.eAdapters()) {
VarNodeEditPart part = (VarNodeEditPart) adapter;
XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
Viewport viewport = xmlMapDataEditPart.getVarScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
}
}
}
}
}
Aggregations