use of org.talend.dq.nodes.DBColumnRepNode in project tdq-studio-se by Talend.
the class AbstractPagePart method updateBindConnection.
/**
* ADD mzhao 2009-05-05 bug:6587.
*/
protected void updateBindConnection(AbstractAnalysisMetadataPage masterPage, List<TableViewer> tableViewerPosStack) {
boolean isEmpty1 = tableViewerPosStack.get(0) == null || tableViewerPosStack.get(0).getInput() == null || ((List) tableViewerPosStack.get(0).getInput()).size() == 0;
boolean isEmpty2 = tableViewerPosStack.get(1) == null || tableViewerPosStack.get(1).getInput() == null || ((List) tableViewerPosStack.get(1).getInput()).size() == 0;
if (isEmpty1 && isEmpty2) {
return;
} else {
TableViewer columnsElementViewer = null;
if (!isEmpty1) {
columnsElementViewer = tableViewerPosStack.get(0);
} else {
columnsElementViewer = tableViewerPosStack.get(1);
}
Connection tdProvider = null;
Object input = columnsElementViewer.getInput();
List<DBColumnRepNode> columnSet = (List<DBColumnRepNode>) input;
if (columnSet != null && columnSet.size() != 0) {
TdColumn column = (TdColumn) ((MetadataColumnRepositoryObject) columnSet.get(0).getObject()).getTdColumn();
if (column != null && column.eIsProxy()) {
column = (TdColumn) EObjectHelper.resolveObject(column);
}
tdProvider = ConnectionHelper.getTdDataProvider(column);
setConnectionState(masterPage, tdProvider);
}
}
}
use of org.talend.dq.nodes.DBColumnRepNode 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.DBColumnRepNode in project tdq-studio-se by Talend.
the class ComparisonTableViewerDNDDecorate method validateColumnType.
// MOD mzhao 2009-09-14 Bug 8839.
@SuppressWarnings("unchecked")
private boolean validateColumnType(StructuredSelection selection, TableViewer targetViewer) {
if (selection == null) {
return false;
}
boolean isValidation = true;
List selectionList = selection.toList();
if (!allowDuplication) {
List elements = (List) targetViewer.getInput();
if (elements != null) {
for (Object element : elements) {
if (selectionList.contains(element)) {
isValidation = false;
break;
}
}
}
}
for (Object obj : selectionList) {
if (!(obj instanceof DBColumnRepNode)) {
isValidation = false;
break;
}
}
return isValidation;
}
use of org.talend.dq.nodes.DBColumnRepNode in project tdq-studio-se by Talend.
the class WhereClauseDND method installDND.
public static void installDND(final Text 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);
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
if (!(obj instanceof DBColumnRepNode)) {
event.detail = DND.DROP_NONE;
} else {
// event.detail = DND.DROP_MOVE;
event.feedback = DND.FEEDBACK_INSERT_AFTER;
}
}
@Override
public void dropAccept(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if (event.detail != DND.DROP_NONE) {
IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
if (!selection.isEmpty()) {
Iterator<DBColumnRepNode> it = selection.iterator();
IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
if (currentActiveEditor instanceof DQRuleEditor) {
// // Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(input.getFile());
while (it.hasNext()) {
// DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(lang, null);
DBColumnRepNode next = it.next();
String name = next.getTdColumn().getName();
targetControl.insert(name);
targetControl.forceFocus();
}
}
}
}
}
});
}
use of org.talend.dq.nodes.DBColumnRepNode 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