use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.
the class AbstractColumnDropTree method dropModelElements.
public void dropModelElements(List<? extends IRepositoryNode> repositoryNode, int index) {
int size = repositoryNode.size();
ModelElementIndicator[] meIndicators = new ModelElementIndicator[size];
for (int i = 0; i < size; i++) {
IRepositoryNode repNode = repositoryNode.get(i);
IRepositoryViewObject repViewObj = repNode.getObject();
// TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(repViewObj);
if (repNode instanceof DFColumnRepNode) {
meIndicators[i] = ModelElementIndicatorHelper.createDFColumnIndicator(repNode);
} else if (repViewObj != null && repViewObj instanceof MetadataColumnRepositoryObject) {
meIndicators[i] = ModelElementIndicatorHelper.createColumnIndicator(repNode);
}
}
addElements(meIndicators);
}
use of org.talend.dq.nodes.DFColumnRepNode 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);
}
use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.
the class NominalValuesDPSelectionPage method addListeners.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
*/
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) object;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
// int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
if (Java2SqlType.isTextInSQL(javaSQLType)) {
advanceToNextPageOrFinish();
} else {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
tempList.add(columnNode);
setAddTextIndicator(false);
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// use MetadataHelper
for (DFColumnRepNode col : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
}
advanceToNextPageOrFinish();
}
}
}
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
nodes = new ArrayList<IRepositoryNode>();
if (object instanceof ColumnRepNode) {
List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
nodes.addAll(list);
if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
for (IRepositoryNode obj : nodes) {
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) obj;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
if (!Java2SqlType.isTextInSQL(javaSQLType)) {
tempList.add(columnNode);
setAddTextIndicator(false);
}
}
}
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// zqin get the column and change their datamining type to "Nominal"
for (DFColumnRepNode column : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
}
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(false);
// $NON-NLS-1$
setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
}
} else {
setPageComplete(false);
setMessage(chooseConnStr);
}
} catch (Exception e) {
log.error(e, e);
}
}
});
}
use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.
the class ImageLib method getImageNameByRepositoryNode.
public static String getImageNameByRepositoryNode(IRepositoryNode node) {
String imageName = null;
IRepositoryViewObject viewObject = node.getObject();
ENodeType type = node.getType();
if (node instanceof ReportAnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof RecycleBinRepNode) {
imageName = ImageLib.RECYCLEBIN_EMPTY;
} else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
String label = viewObject.getLabel();
if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
imageName = ImageLib.DATA_PROFILING;
} else if (label.equals(EResourceConstant.METADATA.getName())) {
imageName = ImageLib.METADATA;
} else if (node instanceof DBConnectionFolderRepNode) {
imageName = ImageLib.CONNECTION;
} else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
imageName = ImageLib.FILE_DELIMITED;
} else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
imageName = ImageLib.HADOOP_CLUSTER;
} else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
imageName = ImageLib.LIBRARIES;
} else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
imageName = ImageLib.EXCHANGE;
} else {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
} else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
if (node instanceof DBConnectionRepNode) {
imageName = ImageLib.TD_DATAPROVIDER;
} else if (node instanceof DFConnectionRepNode) {
imageName = ImageLib.FILE_DELIMITED;
} else if (node instanceof AnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof ReportRepNode) {
imageName = ImageLib.REPORT_OBJECT;
} else if (node instanceof SysIndicatorDefinitionRepNode) {
imageName = ImageLib.IND_DEFINITION;
} else if (node instanceof PatternRepNode) {
imageName = ImageLib.PATTERN_REG;
} else if (node instanceof RuleRepNode) {
imageName = ImageLib.DQ_RULE;
} else if (node instanceof SourceFileRepNode) {
imageName = ImageLib.SOURCE_FILE;
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
imageName = ImageLib.EXCHANGE;
} else if (node instanceof JrxmlTempleteRepNode) {
imageName = ImageLib.JRXML_ICON;
}
} else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
if (node instanceof DBCatalogRepNode) {
imageName = ImageLib.CATALOG;
} else if (node instanceof DBSchemaRepNode) {
imageName = ImageLib.SCHEMA;
} else if (node instanceof DBTableFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBViewFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
imageName = ImageLib.TABLE;
} else if (node instanceof DBViewRepNode) {
imageName = ImageLib.VIEW;
} else if (node instanceof DBColumnRepNode) {
if (((DBColumnRepNode) node).isKey()) {
imageName = ImageLib.PK_COLUMN;
} else {
imageName = ImageLib.TD_COLUMN;
}
} else if (node instanceof DFColumnRepNode) {
imageName = ImageLib.TD_COLUMN;
} else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
}
return imageName;
}
use of org.talend.dq.nodes.DFColumnRepNode in project tdq-studio-se by Talend.
the class ColumnsSelectionDialog method getAllCheckElements.
protected void getAllCheckElements() {
// Added TDQ-8718 20140506 yyin: should not load from DB(connect) when get checked elements
DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
try {
Object[] checkedNodes = this.getTreeViewer().getCheckedElements();
for (Object checkedNode : checkedNodes) {
IRepositoryNode repNode = (IRepositoryNode) checkedNode;
if (repNode instanceof DBColumnRepNode || repNode instanceof DFColumnRepNode) {
if (!allCheckedElements.contains(repNode)) {
allCheckedElements.add(repNode);
}
} else if (repNode instanceof DFTableRepNode || repNode instanceof DBTableRepNode || repNode instanceof DBViewRepNode) {
if (!getTableviewCheckedElements(allCheckedElements, repNode)) {
List<IRepositoryNode> children = repNode.getChildren().get(0).getChildren();
for (IRepositoryNode node : children) {
if (!allCheckedElements.contains(node)) {
allCheckedElements.add(node);
}
}
}
}
}
} finally {
// Added TDQ-8718 20140506 yyin
DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
}
// ADD msjian 2011-7-8 feature 22206: Add filters
Iterator<?> it = modelElementCheckedMap.keySet().iterator();
while (it.hasNext()) {
RepositoryNode reposNode = (RepositoryNode) it.next();
List<?> columnList = (ArrayList<?>) modelElementCheckedMap.get(reposNode);
for (int i = 0; i < columnList.size(); i++) {
if (columnList.get(i) instanceof DBColumnRepNode || columnList.get(i) instanceof DFColumnRepNode) {
if (!allCheckedElements.contains(columnList.get(i))) {
allCheckedElements.add((IRepositoryNode) columnList.get(i));
}
}
}
}
}
Aggregations