use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class DateFrequencyStateUtilTest method setUp.
@Before
public void setUp() throws Exception {
mapVal2Freq = new HashMap<Object, Long>();
mapVal2Freq.put(1993, 4L);
mapVal2Freq.put(1994, 23L);
mapVal2Freq.put(1996, 15L);
mapVal2Freq.put(1999, 11L);
yearLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createYearLowFrequencyIndicator();
yearLowFrequencyIndicator.setValueToFreq(mapVal2Freq);
yearLowFrequencyIndicator.setComputed(true);
units = new ArrayList<IndicatorUnit>();
ModelElementIndicator modelElementIndicator = UnitTestBuildHelper.createModelElementIndicator();
ColumnIndicatorUnit columnIndicatorUnit = new ColumnIndicatorUnit(IndicatorEnum.YearLowFrequencyIndicatorEnum, yearLowFrequencyIndicator, modelElementIndicator);
units.add(columnIndicatorUnit);
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class PatternStatisticsStateTest method setUp.
/**
* init the state.
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
List<IndicatorUnit> units = new ArrayList<IndicatorUnit>();
RegexpMatchingIndicator indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// $NON-NLS-1$
indicator.setName("Blank text");
indicator.setComputed(true);
units.add(new ColumnSetIndicatorUnit(IndicatorEnum.AllMatchIndicatorEnum, indicator));
patternStatisticsState = new PatternStatisticsState(units);
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method moveSelectedElements.
/**
* DOC yyi 7466 2010-03-22 change the order of appearence of indicators.
*
* @param newTree
* @param step
*/
protected void moveSelectedElements(Tree newTree, int step) {
TreeItem[] selection = newTree.getSelection();
if (selection != null) {
// used to set the selected columns focus at last
List<Object> selectedDataList = new ArrayList<Object>();
// TDQ-11530 msjian: get all selected data's list first to check how to move
List<IndicatorUnit> indicatorUnitList = new ArrayList<IndicatorUnit>();
List<ModelElementIndicator> dataList = new ArrayList<ModelElementIndicator>();
for (TreeItem item : selection) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
if (indicatorUnit != null) {
indicatorUnitList.add(indicatorUnit);
} else {
ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
dataList.add(data);
}
}
for (TreeItem item : selection) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
if (indicatorUnit != null) {
TypedReturnCode<IndicatorUnit[]> code = sortIndicatorUnits(data.getIndicatorUnits(), indicatorUnit, step, indicatorUnitList);
if (code.isOk()) {
if (null != code.getObject()) {
Indicator[] inds = new Indicator[code.getObject().length];
for (int i = 0; i < code.getObject().length; i++) {
inds[i] = code.getObject()[i].getIndicator();
}
data.setIndicators(inds);
}
selectedDataList.add(indicatorUnit);
}
} else {
int index = ArrayUtils.indexOf(modelElementIndicators, data);
int changeIndex = index + step;
if (changeIndex > -1 && changeIndex < modelElementIndicators.length) {
ModelElementIndicator tmpElement = modelElementIndicators[changeIndex];
// when the changed one is the selected one too, get next one
while (dataList.contains(tmpElement)) {
tmpElement = modelElementIndicators[++changeIndex];
}
modelElementIndicators[changeIndex] = modelElementIndicators[index];
modelElementIndicators[index] = tmpElement;
// after the data changed successfully remove it from the selected list
dataList.remove(data);
selectedDataList.add(data);
}
}
}
setElements(modelElementIndicators, true, false);
for (Object obj : selectedDataList) {
selectElement(tree.getItems(), obj);
}
masterPage.synNagivatorStat();
}
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method addColumnUdi.
/**
* DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
*
* @param treeItem
* @param meIndicator
* @param columnIndex
* @return
*/
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
TreeEditor addUdiEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
addUdiLabl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = getAnalysis().getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
// true,just create new indicatorUnit for some new added UDI then set dirty to true.
List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
Set<String> allSelectedIndNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof SysIndicatorDefinitionRepNode) {
IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
allSelectedIndicatorDefinitions.add(udid);
if (udid != null) {
allSelectedIndNames.add(udid.getName());
}
}
}
Set<String> oldSelectedIndNames = new HashSet<String>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof UserDefIndicator) {
if (allSelectedIndNames.contains(indicator.getName())) {
oldSelectedIndNames.add(indicator.getName());
} else {
// remove the UDI from UI need to insert this UDI into removeList
deleteIndicatorItems(meIndicator, indicatorUnit);
if (!isDirty()) {
setDirty(true);
}
}
}
}
treeItem.removeAll();
for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
continue;
}
IndicatorUnit[] addIndicatorUnits = null;
try {
addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
} catch (Throwable e1) {
log.warn(e1, e1);
}
if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
for (IndicatorUnit unit : addIndicatorUnits) {
createOneUnit(treeItem, unit);
}
if (!isDirty()) {
setDirty(true);
}
}
}
treeItem.setExpanded(true);
masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
}
}
});
addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
return addUdiEditor;
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method viewQueryForSelectedElement.
/**
* DOC mzhao Comment method "viewQueryForSelectedElement".
*
* @param newTree
*/
private void viewQueryForSelectedElement(Tree newTree) {
TreeItem[] selection = newTree.getSelection();
for (TreeItem item : selection) {
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
ConnectionItem connItem = (ConnectionItem) meIndicator.getModelElementRepositoryNode().getObject().getProperty().getItem();
Connection dataprovider = connItem.getConnection();
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression == null) {
MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.Warn"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.NoQueryDefined"));
return;
}
SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, expression.getBody(), meIndicator.getModelElementRepositoryNode().getObject().getProperty().getLabel());
}
}
Aggregations