private void initTreeNavigatorNodes() { List<String> selectedNames = new ArrayList<String>(); EList<SalesforceModuleUnit> modules = temConnection.getModules(); // EList<SalesforceModuleUnit> modules = getConnection().getModules(); for (int i = 0; i < modules.size(); i++) { if (modules.get(i).getModuleName().equals(moduleName)) { for (int j = 0; j < modules.get(i).getTables().size(); j++) { selectedNames.add(modules.get(i).getTables().get(j).getLabel()); } break; } } tableNavigator.removeAll(); TableItem subItem = null; String lastSelectName = null; if (selectedNames != null && selectedNames.size() >= 1) { for (int i = 0; i < selectedNames.size(); i++) { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(selectedNames.get(i)); lastSelectName = selectedNames.get(i); } metadataNameText.setText(subItem.getText()); tableNavigator.setSelection(subItem); metadataTable = getTableByLabel(lastSelectName); } else { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(moduleName); } metadataEditor.setMetadataTable(metadataTable); }
private void addColumn(String label, FOXTreeNode node, EList columnList) { if (StringUtils.isEmpty(label)) { return; } MetadataEmfTableEditor editor = new MetadataEmfTableEditor(); String columnName = label; if (columnName.contains(":")) { // $NON-NLS-1$ columnName = columnName.split(":")[1]; // $NON-NLS-1$ } columnName = columnName.replaceAll("[^a-zA-Z0-9]", "_"); // $NON-NLS-1$ String dataType = node.getDataType(); MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn(); metadataColumn.setLabel(editor.getNextGeneratedColumnName(columnName, columnList)); metadataColumn.setOriginalField(label); metadataColumn.setTalendType(dataType); columnList.add(metadataColumn); node.setColumn(ConvertionHelper.convertToIMetaDataColumn(metadataColumn)); }
/** Initialize value, forceFocus first field. */ @Override protected void initialize() { // init the metadata Table String label = MetadataToolHelper.validateValue(metadataTable.getLabel()); metadataNameText.setText(label); metadataCommentText.setText(metadataTable.getComment()); metadataEditor.setMetadataTable(metadataTable); tableEditorView.setMetadataEditor(metadataEditor); tableEditorView.getTableViewerCreator().layout(); if (getConnection().isReadOnly()) { adaptFormToReadOnly(); } else { updateStatus(IStatus.OK, null); } }
@Override protected void addFieldsListeners() { // Navigation : when the user select a table tableNavigator.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String schemaLabel = tableNavigator.getSelection()[0].getText(); // org.talend.core.model.metadata.MetadataTable table = null; EList<SalesforceModuleUnit> modules = temConnection.getModules(); for (int i = 0; i < modules.size(); i++) { if (modules.get(i).getModuleName().equals(moduleName)) { for (int j = 0; j < modules.get(i).getTables().size(); j++) { if (modules.get(i).getTables().get(j).getLabel().equals(schemaLabel)) { metadataTable = modules.get(i).getTables().get(j); metadataNameText.setText(schemaLabel); break; } } break; } } metadataEditor.setMetadataTable(metadataTable); if (isReadOnly()) { addTableButton.setEnabled(false); } // } } }); // metadataNameText : Event modifyText metadataNameText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { String labelText = metadataNameText.getText(); MetadataToolHelper.validateSchema(labelText); changeTableNavigatorStatus(labelText); metadataTable.setLabel(labelText); if (tableNavigator.getSelection().length > 0) { tableNavigator.getSelection()[0].setText(labelText); } changeTableNavigatorStatus(checkFieldsValue()); // kFieldsValue(); } }); // metadataNameText : Event KeyListener metadataNameText.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { MetadataToolHelper.checkSchema(getShell(), e); // initTreeNavigatorNodes(); } }); // metadataCommentText : Event modifyText metadataCommentText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { metadataTable.setComment(metadataCommentText.getText()); } }); // add listener to tableMetadata (listen the event of the toolbars) tableEditorView .getMetadataEditor() .addAfterOperationListListener( new IListenableListListener() { @Override public void handleEvent(ListenableListEvent event) { checkFieldsValue(); } }); // add listener to tableMetadata (listen the event of the toolbars) metadataEditor.addAfterOperationListListener( new IListenableListListener() { @Override public void handleEvent(ListenableListEvent event) { changeTableNavigatorStatus(checkFieldsValue()); } }); }