use of org.talend.dq.nodes.PatternRepNode in project tdq-studio-se by Talend.
the class ExportPatternsWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
String targetFile = page.getTargetFile();
Object[] elements = page.getSelectedPatternsTree().getCheckedElements();
List<Pattern> seletedPatterns = new ArrayList<Pattern>();
for (Object element : elements) {
// MOD klliu 2011-03-08 bug 18657
if (element instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) element;
Pattern pattern = patternNode.getPattern();
seletedPatterns.add(pattern);
}
}
if ("".equals(targetFile)) {
// $NON-NLS-1$
MessageDialog.openError(getShell(), DefaultMessagesImpl.getString("ExportPatternsWizard.Error"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("ExportPatternsWizard.SpecifyValidResource"));
return false;
} else {
File resource = new File(targetFile);
if (isForExchange) {
ExportFactory.export(resource, folder, seletedPatterns.toArray(new Pattern[seletedPatterns.size()]));
for (Iterator<Pattern> iterator = seletedPatterns.iterator(); iterator.hasNext(); ) {
Pattern pattern = iterator.next();
// $NON-NLS-1$
File patternFile = new File(resource, ExportFactory.toLocalFileName(pattern.getName() + ".csv"));
if (patternFile.isFile() && patternFile.exists()) {
try {
// $NON-NLS-1$
FilesUtils.zip(patternFile, patternFile.getPath() + ".zip");
patternFile.delete();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
} else {
boolean isContinue = true;
if (resource.exists()) {
isContinue = MessageDialogWithToggle.openConfirm(null, // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.waring"), // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.fileAlreadyExist"));
}
if (!isContinue) {
return false;
}
ExportFactory.export(resource, folder, seletedPatterns.toArray(new Pattern[seletedPatterns.size()]));
}
CorePlugin.getDefault().refreshDQView(RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERNS));
CorePlugin.getDefault().refreshWorkSpace();
return true;
}
}
use of org.talend.dq.nodes.PatternRepNode in project tdq-studio-se by Talend.
the class PatternMouseAdapter method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = analysis.getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
// MOD gdbu 2011-8-26 bug : TDQ-2169
IRepositoryNode patternFolderNode = getPatternSelectDialogInputData();
if (patternFolderNode == null) {
return;
}
CheckedTreeSelectionDialog dialog = PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
if (null != filters) {
for (ViewerFilter filter : filters) {
dialog.addFilter(filter);
}
}
// ~TDQ-2169
Object[] selectedRepNodes = PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
dialog.setInitialSelections(selectedRepNodes);
dialog.create();
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-17 TDQ-5923,just remove some deselected indicatorUnit,just create new indicatorUnit
// for some new added pattern nodes.
List<PatternRepNode> allSelectedPatternNodes = new ArrayList<PatternRepNode>();
Set<String> allSelectedNodeNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) obj;
allSelectedPatternNodes.add(patternNode);
allSelectedNodeNames.add(patternNode.getLabel());
}
}
Set<String> oldSelectedNodeNames = new HashSet<String>();
Map<String, IndicatorUnit> oldSelectedUnits = new HashMap<String, IndicatorUnit>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof PatternMatchingIndicator) {
if (!allSelectedNodeNames.contains(indicator.getName())) {
// this method will deal dependency with same time
columnDropTree.deleteIndicatorItems(meIndicator, indicatorUnit);
if (!columnDropTree.isDirty()) {
columnDropTree.setDirty(true);
}
} else {
oldSelectedNodeNames.add(indicator.getName());
oldSelectedUnits.put(indicator.getName(), indicatorUnit);
}
}
}
// Added yyin 20121121 TDQ-6329: after remove all, should also add the old selected patterns
// because the columnset does not have pagination, can not refresh automatically
boolean addOldSelected = false;
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
addOldSelected = true;
}
if (addOldSelected) {
for (TreeItem child : treeItem.getItems()) {
masterPage.getTreeViewer().removeItemBranch(child);
}
}
// ~
treeItem.removeAll();
for (PatternRepNode patternNode : allSelectedPatternNodes) {
if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
continue;
}
TypedReturnCode<IndicatorUnit> trc = PatternUtilities.createIndicatorUnit(patternNode.getPattern(), meIndicator, analysis);
if (trc.isOk()) {
createOneUnit(trc.getObject());
// TDQ-8860 add msjian 2014-4-30:check whether show allmatchindicator in the indicators section
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
EventManager.getInstance().publish(analysis, EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
}
// TDQ-8860~
}
}
treeItem.setExpanded(true);
if (masterPage instanceof ColumnAnalysisDetailsPage) {
ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) masterPage;
page.refreshTheTree(page.getCurrentModelElementIndicators());
}
}
}
use of org.talend.dq.nodes.PatternRepNode 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.PatternRepNode 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.PatternRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method recursiveFindPattern.
public static PatternRepNode recursiveFindPattern(Pattern pattern) {
if (pattern == null) {
return null;
}
String uuid = getUUID(pattern);
if (uuid == null) {
return null;
}
List<PatternRepNode> patternRepNodes;
if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
patternRepNodes = getPatternRepNodes(getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX), true, true);
patternRepNodes.addAll(getPatternRepNodes(getLibrariesFolderNode(EResourceConstant.PATTERN_SQL), true, true));
} else {
Project inWhichProject = getInWhichProject(pattern);
patternRepNodes = getPatternRepNodes(getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX, inWhichProject), true, true);
patternRepNodes.addAll(getPatternRepNodes(getLibrariesFolderNode(EResourceConstant.PATTERN_SQL, inWhichProject), true, true));
}
if (patternRepNodes.size() > 0) {
for (PatternRepNode childNode : patternRepNodes) {
if (uuid.equals(getUUID(childNode.getPattern()))) {
return childNode;
}
}
}
return null;
}
Aggregations