use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnNominalIntervalTreeViewer method createTreeMenu.
/**
* DOC xzhao Comment method "createTreeMenu".
*
* @param newTree
* @param containEdit
*/
private void createTreeMenu(final Tree newTree, boolean containEdit) {
Menu oldMenu = newTree.getMenu();
if (oldMenu != null && !oldMenu.isDisposed()) {
oldMenu.dispose();
}
menu = new Menu(newTree);
MenuItem deleteMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
deleteMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.removeElement"));
deleteMenuItem.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
deleteMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
removeSelectedElements(newTree);
// MOD mzhao 2005-05-05 bug 6587.
// MOD mzhao 2009-06-8, bug 5887.
// updateBindConnection(masterPage, tree);
}
});
// ADD 2009-01-07 mzhao for feature:0005664
MenuItem showMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
showMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = newTree.getSelection();
if (selection.length > 0) {
// if DqRepository view is not openning we will not do anything
DQRespositoryView dqview = CorePlugin.getDefault().findAndOpenRepositoryView();
if (dqview == null) {
return;
}
// TdColumn tdColumn = (TdColumn) selection[0].getData(COLUMN_INDICATOR_KEY);
dqview.showSelectedElements(selection[0].getData(COLUMN_INDICATOR_KEY));
}
}
});
if (containEdit) {
editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editPattern"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
TreeItem treeItem = selection[0];
IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(INDICATOR_UNIT_KEY);
PatternMatchingIndicator indicator = (PatternMatchingIndicator) indicatorUnit.getIndicator();
Pattern pattern = indicator.getParameters().getDataValidDomain().getPatterns().get(0);
// MOD mzhao 2009-03-13 Feature 6066 Move all folders
// into one project.
IFile file = ResourceFileMap.findCorrespondingFile(pattern);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
activePage.openEditor(new FileEditorInput(file), // $NON-NLS-1$
"org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor");
} catch (PartInitException e1) {
log.error(e1, e1);
}
}
}
});
}
newTree.setMenu(menu);
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnNominalIntervalTreeViewer method addTreeListener.
private void addTreeListener(final Tree tree) {
tree.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (e.getSource() instanceof Tree) {
Tree currentTree = (Tree) e.getSource();
if (currentTree.getSelection().length > 0) {
enabledButtons(true);
}
}
}
public void focusLost(FocusEvent e) {
if (e.getSource() instanceof Tree) {
Tree currentTree = (Tree) e.getSource();
if (currentTree.getSelection().length <= 0) {
enabledButtons(false);
}
}
}
});
tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean con = false;
if (e.item instanceof TreeItem) {
enabledButtons(true);
TreeItem item = (TreeItem) e.item;
if (item.getData(INDICATOR_UNIT_KEY) != null) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
IndicatorEnum type = indicatorUnit.getType();
con = IndicatorEnum.RegexpMatchingIndicatorEnum.compareTo(type) == 0 || IndicatorEnum.SqlPatternMatchingIndicatorEnum.compareTo(type) == 0;
}
}
createTreeMenu(tree, con);
showDetailView(tree);
}
});
tree.addTreeListener(treeAdapter);
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnSetTreeViewer method removeItemBranch.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.core.ui.editor.composite.AbstractColumnDropTree#removeItemBranch(org.eclipse.swt.widgets
* .TreeItem)
*/
@Override
protected void removeItemBranch(TreeItem item) {
// MOD yyi 2011-03-22 19460: The "remove elements" option on the contextual menu does not work
IndicatorUnit unit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
// MOD klliu check the item is column or pattern
if (item.getData(COLUMN_INDICATOR_KEY) != null) {
deleteColumnItems(meIndicator.getModelElementRepositoryNode());
deleteModelElementItems(meIndicator);
masterPage.setCurrentModelElementIndicators(modelElementIndicators);
}
if (null != unit) {
meIndicator.removeIndicatorUnit(unit);
}
super.removeItemBranch(item);
// add msjian TDQ-8860 2014-4-30:check whether show allmatchindicator in the indicators section.
EventManager.getInstance().publish(this.getAnalysis(), EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
// TDQ-8860~
// MOD mzhao 2009-06-8, bug 5887.
updateBindConnection(masterPage, tree);
enabledButtons(false);
tree.setFocus();
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method sortIndicatorUnits.
/**
* DOC yyi Sort indicators.
*
* @param units
* @param targetUnit
* @param step
* @return
*/
private TypedReturnCode<IndicatorUnit[]> sortIndicatorUnits(IndicatorUnit[] units, IndicatorUnit targetUnit, int step, List<IndicatorUnit> indicatorUnitList) {
TypedReturnCode<IndicatorUnit[]> code = new TypedReturnCode<IndicatorUnit[]>();
int index = -1;
for (int i = 0; i < units.length; i++) {
if (targetUnit.getIndicator() == units[i].getIndicator()) {
index = i;
break;
} else if (null != units[i].getChildren()) {
TypedReturnCode<IndicatorUnit[]> code2 = sortIndicatorUnits(units[i].getChildren(), targetUnit, step, indicatorUnitList);
if (null != code2.getObject()) {
units[i].setChildren(code2.getObject());
code.setOk(true);
break;
}
}
}
int changeIndex = index + step;
if (-1 != index && changeIndex > -1 && changeIndex < units.length) {
IndicatorUnit tmpUnit = units[changeIndex];
// when the changed one is the selected one too, get next one
while (indicatorUnitList.contains(tmpUnit)) {
tmpUnit = units[++changeIndex];
}
units[changeIndex] = units[index];
units[index] = tmpUnit;
// after the data changed successfully remove it from the selected list
indicatorUnitList.remove(targetUnit);
// $NON-NLS-1$
code.setReturnCode("", true, units);
}
return code;
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method isExpressionNull.
private String isExpressionNull(TreeItem item) {
String expressContent = null;
ModelElement me = null;
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
if (indicatorUnit != null) {
IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
// MetadataXmlElementTypeRepositoryObject
if (reposViewObj instanceof MetadataColumnRepositoryObject) {
me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
}
Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression != null) {
expressContent = expression.getBody();
}
} else {
IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
parentNodeForColumnNode.getObject().getLabel());
}
return expressContent;
}
Aggregations