use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase8.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
* . case8 :input parameter is DBColumnFolderRepNode
*/
@Test
public void testGetConnectionCase8() {
// create FileConnection
// connection
IRepositoryViewObject lastVersion = null;
String propertyID = createConnectionItem(connectionName, null, null);
TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
RepositoryNode dbCatalogRepNode = null;
// $NON-NLS-1$
createTdTable.setName("table1");
try {
lastVersion = factory.getLastVersion(propertyID);
dbCatalogRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(lastVersion, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
lastVersion = new TdTableRepositoryObject(lastVersion, createTdTable);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
// ~connection data
// ~FileConnection
// create DFColumnFolderRepNode
Assert.assertFalse(lastVersion == null);
DBTableRepNode dbTableRepNode = new DBTableRepNode(lastVersion, dbCatalogRepNode, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
DBColumnFolderRepNode dbColumnFolderRepNode = new DBColumnFolderRepNode(null, dbTableRepNode, null, null);
// ~DFColumnFolderRepNode
AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
Connection connection = provider.getConnection(dbColumnFolderRepNode);
Assert.assertTrue(connection != null);
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class SelectedCompareUIProvider method fillContextMenu.
@Override
public void fillContextMenu(IMenuManager menu) {
// TDQ-9394 hide all "Reload" menu.
if (!isShowMenu()) {
return;
}
if (isShowMenu()) {
return;
}
Iterator<?> iter = ((TreeSelection) this.getContext().getSelection()).iterator();
while (iter.hasNext()) {
Object obj = iter.next();
if (!(obj instanceof RepositoryNode)) {
return;
}
}
TreeSelection treeSelection = (TreeSelection) getContext().getSelection();
if (treeSelection == null) {
return;
}
Object firstElement = treeSelection.getFirstElement();
RepositoryNode rNode = (RepositoryNode) firstElement;
IFolder folder = WorkbenchUtils.getFolder(rNode);
IFolder metadataFolder = ResourceManager.getMetadataFolder();
if (!folder.getFullPath().toOSString().startsWith(metadataFolder.getFullPath().toOSString())) {
return;
}
Object[] selectedObj = treeSelection.toArray();
if (selectedObj.length < 2) {
return;
}
List<Object> objects = new ArrayList<Object>();
for (Object obj : selectedObj) {
Connection conn = getConnection(obj);
if (!MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
return;
}
RepositoryNode node = (RepositoryNode) obj;
if (node instanceof DBConnectionRepNode) {
Property property = ((DBConnectionRepNode) node).getObject().getProperty();
DatabaseConnectionItem databaseConnectionItem = (DatabaseConnectionItem) property.getItem();
Connection databaseConnection = databaseConnectionItem.getConnection();
objects.add(databaseConnection);
} else if (node instanceof DBCatalogRepNode) {
Catalog catalog = ((DBCatalogRepNode) node).getCatalog();
objects.add(catalog);
} else if (node instanceof DBSchemaRepNode) {
Schema schema = ((DBSchemaRepNode) node).getSchema();
objects.add(schema);
} else if (node instanceof DBTableRepNode) {
TdTable tdTable = ((DBTableRepNode) node).getTdTable();
objects.add(tdTable);
} else if (node instanceof DBColumnRepNode) {
TdColumn tdColumn = ((DBColumnRepNode) node).getTdColumn();
objects.add(tdColumn);
}
}
// MOD yyi 2011-03-22 17871:hide compare action for flat file column
if (2 == objects.size()) {
selectionCompareAction.refreshSelectedObj(objects.get(0), objects.get(1));
menu.add(selectionCompareAction);
}
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class AnalysisColumnSetTreeViewer method setInput.
@Override
public void setInput(Object[] objs) {
if (objs != null && objs.length != 0) {
List<DBColumnRepNode> columnList = new ArrayList<DBColumnRepNode>();
for (Object obj : objs) {
// default is should be sql engine.
if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode) {
columnList.addAll((Collection<? extends DBColumnRepNode>) ((ColumnSetRepNode) obj).getAllColumns());
} else if (obj instanceof DBColumnRepNode) {
columnList.add((DBColumnRepNode) obj);
}
}
// MOD yyi 2010-05-13 12828
Collections.reverse(columnList);
// MOD qiongli 2011-3-15 set DataFilterText disabled except TdColumn.
if (masterPage.getDataFilterComp() != null) {
masterPage.getDataFilterComp().getDataFilterText().setEnabled(!columnList.isEmpty());
if (columnList.isEmpty()) {
// when the selected column is not DB type,will disable the execute engine
// combobox.
masterPage.changeExecuteLanguageToJava(true);
} else {
// when the selected column is back to DB type, should enable the execute engine combobox again.
masterPage.enableExecuteLanguage();
}
}
ModelElementIndicator[] newSelects = translateSelectedNodeIntoIndicator(objs);
List<ModelElementIndicator> indicatorList = new ArrayList<ModelElementIndicator>();
if (newSelects != null) {
// indicator;
for (ModelElementIndicator column : newSelects) {
// if the modelElementIndicators contains selected column, add the column in modelElementIndicators
// to ColumnIndicatorList
boolean isOld = false;
for (ModelElementIndicator oldColumn : modelElementIndicators) {
if (oldColumn.getModelElementRepositoryNode().equals(column.getModelElementRepositoryNode())) {
indicatorList.add(oldColumn);
isOld = true;
break;
}
}
// else add this column in filterInputData to ColumnIndicatorList
if (!isOld) {
indicatorList.add(column);
}
}
this.modelElementIndicators = indicatorList.toArray(new ModelElementIndicator[indicatorList.size()]);
this.setElements(modelElementIndicators);
}
} else {
TreeItem[] items = this.tree.getItems();
for (TreeItem item : items) {
this.removeItemBranch(item);
}
super.setInput(objs);
}
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class TablesSelectionDialog method addCheckedListener.
@Override
protected void addCheckedListener() {
// When user checks a checkbox in the tree, check all its children
getTreeViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
TreePath treePath = new TreePath(new Object[] { event.getElement() });
getTreeViewer().setSelection(new TreeSelection(treePath));
if (event.getChecked()) {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, true);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, true);
}
} else {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, false);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, false);
}
}
updateOKStatus();
}
});
getTableViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof DBTableRepNode || element instanceof DBViewRepNode) {
handleTableChecked((IRepositoryNode) element, event.getChecked());
}
}
});
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class ColumnViewerDND method installDND.
/**
* DOC qzhang Comment method "installDND".
*/
public static void installDND(final Tree targetControl) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
final CommonViewer commonViewer = findView.getCommonViewer();
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { transfer };
DropTarget dropTarget = new DropTarget(targetControl, operations);
dropTarget.setTransfer(transfers);
DropTargetListener dndListener = new TreeDropTargetEffect(targetControl) {
ISelectionReceiver receiver = null;
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetAdapter#dragEnter(org.eclipse.swt .dnd.DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
super.dragEnter(event);
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
Object object = selection.getFirstElement();
// if (object instanceof IFile) {
if (object instanceof SysIndicatorDefinitionRepNode) {
receiver = new UDIReceiver();
} else if (object instanceof PatternRepNode) {
receiver = new PatternReceiver();
}
// MOD klliu 15750 2011-01-17 for Drag&Drop On columnset
if (object instanceof DBColumnRepNode || object instanceof DBTableRepNode || object instanceof DFColumnRepNode) {
receiver = new ColumnReceiver();
}
if (receiver == null) {
event.detail = DND.DROP_NONE;
} else {
event.feedback = DND.FEEDBACK_EXPAND;
receiver.doDropValidation(event, commonViewer);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.TreeDropTargetEffect#dragOver(org.eclipse .swt.dnd.DropTargetEvent)
*/
@Override
public void dragOver(DropTargetEvent event) {
super.dragOver(event);
// MOD yyi 2009-09-18 bug: 9044
if (null != receiver) {
receiver.doDropValidation(event, commonViewer);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd .DropTargetEvent)
*/
@Override
public void drop(DropTargetEvent event) {
int index = targetControl.getItemCount();
super.drop(event);
if (event.item == null) {
// TreeItem item = new TreeItem(targetControl, SWT.NONE);
// item.setText(texts);
// item.setText(text);
index = 0;
} else {
TreeItem item = (TreeItem) event.item;
TreeItem[] items = targetControl.getItems();
for (int i = 0; i < items.length; i++) {
if (items[i] == item) {
index = i;
break;
}
}
}
receiver.drop(event, commonViewer, index);
}
};
dropTarget.addDropListener(dndListener);
}
Aggregations