public ColumnTitleFigure(MapperTablePart xmlTreePart) { this.xmlTreePart = xmlTreePart; AbstractInOutTree xmlTree = (AbstractInOutTree) xmlTreePart.getModel(); if (xmlTree instanceof InputXmlTree) { InputXmlTree inputTree = (InputXmlTree) xmlTree; if (inputTree.isLookup()) { Label expression = new Label(); expression.setText("Exp.key"); expression.setBorder(new MarginBorder(3, 10, 3, -1)); expression.setLabelAlignment(PositionConstants.LEFT); this.add(expression); } } else { Label expression = new Label(); expression.setText("Expression"); expression.setBorder(new MarginBorder(3, 10, 3, -1)); expression.setLabelAlignment(PositionConstants.LEFT); this.add(expression); } Label column1 = new Label(); column1.setText("Column"); column1.setBorder(new MarginBorder(3, 10, 3, -1)); column1.setLabelAlignment(PositionConstants.LEFT); this.add(column1); setLayoutManager(new ColumnTitleLayout()); setBackgroundColor(ColorConstants.menuBackground); setOpaque(true); }
/* * (non-Javadoc) * * @see * org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask * (org .talend.core.model.properties.Item) */ @Override public ExecutionResult execute(Item item) { IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory(); ProcessType processType = getProcessType(item); boolean modified = false; if (processType != null) { for (Object obj : processType.getNode()) { NodeType nodeType = (NodeType) obj; if (nodeType.getComponentName().startsWith("tXMLMap")) { XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData(); EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees(); EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees(); boolean hasDocumentInTheMainInputTable = false; for (InputXmlTree inputTable : inputTables) { if (!(inputTable.isLookup())) { for (TreeNode inputEntry : inputTable.getNodes()) { if ("id_Document".equals(inputEntry.getType())) { hasDocumentInTheMainInputTable = true; } } } } if (hasDocumentInTheMainInputTable) { for (OutputXmlTree outputTable : outputTables) { for (TreeNode outputEntry : outputTable.getNodes()) { if ("id_Document".equals(outputEntry.getType())) { if (!outputTable.isAllInOne()) { outputTable.setAllInOne(true); modified = true; break; } } } } } } } } try { if (modified) { factory.save(item, true); return ExecutionResult.SUCCESS_WITH_ALERT; } else { return ExecutionResult.SUCCESS_NO_ALERT; } } catch (Exception e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } }
@Override public String getDescription() { StringBuilder sb = new StringBuilder(); String separator = " - "; // $NON-NLS-1$ if (entry instanceof TreeNode) { TreeNode inputEntry = (TreeNode) entry; IMetadataColumn metadataColumn = null; if (inputEntry.eContainer() instanceof InputXmlTree) { InputXmlTree tree = (InputXmlTree) inputEntry.eContainer(); List<IODataComponent> inputs = mapperManager.getMapperComponent().getIODataComponents().getInputs(); IMetadataTable table = null; for (int i = 0; i < inputs.size(); i++) { IODataComponent ioDataComponent = inputs.get(i); if (tree.getName() != null && tree.getName().equals(ioDataComponent.getConnection().getName())) { table = ioDataComponent.getTable(); break; } } if (table != null && table.getListColumns() != null) { for (IMetadataColumn column : table.getListColumns()) { if (inputEntry.getName().equals(column.getLabel())) { metadataColumn = column; } } } } sb.append(Messages.getString("EntryContentProposal.metadataColumn")) .append(" '") .append(inputEntry.getName()) // $NON-NLS-1$ //$NON-NLS-2$ .append("' "); // $NON-NLS-1$ sb.append( Messages.getString( "EntryContentProposal.properties")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // //$NON-NLS-4$ sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.column")) .append(inputEntry.getName()); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.key")) .append(inputEntry.isKey()); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.type")) .append(format(inputEntry.getType())); // $NON-NLS-1$ if (metadataColumn != null) { sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.length")); // $NON-NLS-1$ if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) { sb.append(format(metadataColumn.getLength())); } sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.precision")); // $NON-NLS-1$ if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) { sb.append(format(metadataColumn.getPrecision())); } sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.default")) .append(format(metadataColumn.getDefault())); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.comment")) .append(format(metadataColumn.getComment())); // $NON-NLS-1$ } sb.append(CARRIAGE_RETURN); if (inputEntry.eContainer() instanceof TreeNode) { sb.append(separator) .append(Messages.getString("EntryContentProposal.xPath")) .append(inputEntry.getXpath()); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); } sb.append(separator) .append(Messages.getString("EntryContentProposal.expressionKey")); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); sb.append(format(entry.getExpression())); sb.append(CARRIAGE_RETURN); } else if (entry instanceof VarNode) { sb.append(Messages.getString("EntryContentProposal.variable")) .append(" '") .append(entry.getName()) .append("' :"); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ sb.append(CARRIAGE_RETURN); sb.append(separator) .append(Messages.getString("EntryContentProposal.expressionKey")); // $NON-NLS-1$ sb.append(CARRIAGE_RETURN); sb.append(format(entry.getExpression())); } return sb.toString(); }