use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class IndicatorPaginationInfo method createMenuForAllDataEntity.
/**
* DOC yyin Comment method "createMenuForAllDataEntity".
*
* @param shell
* @param dataExplorer
* @param analysis
* @param chartDataEntities
* @return
*/
protected Map<String, Object> createMenuForAllDataEntity(Composite composite, DataExplorer dataExplorer, Analysis analysis, ChartDataEntity[] chartDataEntities) {
Map<String, Object> menuMap = new HashMap<String, Object>();
final ExecutionLanguage currentEngine = analysis.getParameters().getExecutionLanguage();
// ADD msjian TDQ-7275 2013-5-21: when allow drill down is not checked, no menu display
if (ExecutionLanguage.JAVA == currentEngine && !analysis.getParameters().isStoreData()) {
return menuMap;
}
// TDQ-7275~
for (ChartDataEntity oneDataEntity : chartDataEntities) {
Indicator indicator = oneDataEntity.getIndicator();
Menu menu = TOPChartUtils.getInstance().createMenu(composite, dataExplorer, analysis, oneDataEntity, indicator, false);
ChartTableFactory.addJobGenerationMenu(menu, analysis, indicator);
menuMap.put(oneDataEntity.getLabel(), menu);
}
return menuMap;
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisResultPage method createTable.
/**
* DOC xqliu Comment method "createTable".
*
* @param composite
*/
private void createTable(Composite composite) {
final TableViewer tableViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Table resultTable = tableViewer.getTable();
resultTable.setLinesVisible(true);
resultTable.setHeaderVisible(true);
// create table headers
TableStructureEntity tableStructure = getTableStructure();
String[] fieldNames = tableStructure.getFieldNames();
Integer[] fieldWidths = tableStructure.getFieldWidths();
for (int i = 0; i < fieldNames.length; ++i) {
TableColumn columnHeader = new TableColumn(resultTable, SWT.LEFT);
columnHeader.setText(fieldNames[i]);
columnHeader.setWidth(fieldWidths[i]);
}
// create table items
CustomerDefaultCategoryDataset dataset = initCustomerDataset();
ChartDataEntity[] dataEntities = dataset.getDataEntities();
if (dataEntities != null) {
// MOD mzhao bug 8839 There might be duplicate dependencies on left and right columnSet.
if (canShowChartForResultPage() && TOPChartUtils.getInstance().getColumnCount(dataset.getDataset()) < dataEntities.length) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
this.getEditor().getSite().getShell(), // $NON-NLS-1$
"Duplicate dependencies", // $NON-NLS-1$
"There might be duplicate dependencies on left and right columnSet.");
} else {
for (ChartDataEntity dataEntity : dataEntities) {
TableItem item = new TableItem(resultTable, SWT.NULL);
String numMatch = ((PatternChartDataEntity) dataEntity).getNumMatch();
String numNoMatch = ((PatternChartDataEntity) dataEntity).getNumNoMatch();
Number match = Long.parseLong(numMatch);
Number notMatch = Long.parseLong(numNoMatch);
Number row = match.intValue() + notMatch.intValue();
item.setText(0, dataEntity.getLabel());
item.setText(1, String.valueOf(match.intValue()));
// TDQ-8695 display "N/A" if it is infinite or NaN
double percentage = match.doubleValue() / row.doubleValue();
if (Double.isNaN(percentage) || Double.isInfinite(percentage)) {
item.setText(2, PluginConstant.NA_STRING);
} else {
item.setText(2, StringFormatUtil.format(String.valueOf(percentage), StringFormatUtil.PERCENT).toString());
}
item.setText(3, String.valueOf(row));
item.setData(dataEntity);
}
}
}
GridData gd = new GridData();
gd.heightHint = 180;
gd.widthHint = 450;
resultTable.setLayoutData(gd);
// add menus
ChartTableFactory.addMenuAndTip(tableViewer, new ColumnDependencyExplorer(), this.masterPage.getCurrentModelElement());
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class RedundancyAnalysisResultPage method createMenu.
/**
* DOC hcheng Comment method "createMenu".
*
* @param resultTable
* @param indicator
* @return
*/
private Menu createMenu(final Table resultTable, final RowMatchingIndicator indicator) {
if (indicator == null) {
return null;
}
final ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
getAnalysisHandler().getAnalyzedColumns();
if (columnSet == null) {
return null;
}
Menu menu = new Menu(resultTable);
MenuItem itemNotMatch = new MenuItem(menu, SWT.PUSH);
MenuItem itemRow = new MenuItem(menu, SWT.PUSH);
// MOD qiongli 2012-8-30 TDQ-5907 hide 'view match row' menue for hive connection.
final Connection provider = ConnectionHelper.getDataProvider(columnSet);
if (!ConnectionHelper.isHive(provider)) {
MenuItem itemMatch = new MenuItem(menu, SWT.PUSH);
itemMatch.setText(DataExplorer.MENU_VIEW_MATCH_ROWS);
itemMatch.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemMatch.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getRowsMatchStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
}
});
}
itemNotMatch.setText(DataExplorer.MENU_VIEW_NOT_MATCH_ROWS);
itemNotMatch.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemRow.setText(DataExplorer.MENU_VIEW_ROWS);
itemRow.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemNotMatch.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getRowsNotMatchStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
}
});
itemRow.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
// MOD 10913 zshen:unify the method that get sql query
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getAllRowsStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
// ~10913
}
});
return menu;
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class ResultPaginationInfo method createChart.
/**
* DOC bZhou Comment method "createChart".
*
* @param comp
* @param chartType
* @param units
*/
private void createChart(Composite comp, EIndicatorChartType chartType, List<IndicatorUnit> units) {
DynamicIndicatorModel dyModel = new DynamicIndicatorModel();
// MOD TDQ-8787 20140618 yyin: to let the chart and table use the same dataset
Object chart = null;
Object dataset = null;
// Added TDQ-8787 20140722 yyin:(when first switch from master to result) if there is some dynamic event for the
// current indicator, use its dataset directly (TDQ-9241)
IEventReceiver event = EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(), EventEnum.DQ_DYMANIC_CHART, 0);
// get the dataset from the event
if (event != null) {
dataset = ((DynamicChartEventReceiver) event).getDataset();
}
// ~
// Added TDQ-8787 2014-06-18 yyin: add the current units and dataset into the list
List<Indicator> indicators = null;
dyModel.setChartType(chartType);
this.dynamicList.add(dyModel);
if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
// for the summary indicators, the table show 2 more than the bar chart
dyModel.setSummaryIndicators(getIndicatorsForTable(units, true));
}
// create UI
ExpandableComposite subComp = uiPagination.getToolkit().createExpandableComposite(comp, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
subComp.setText(chartType.getLiteral());
subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
// MOD xqliu 2009-06-23 bug 7481
subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
// ~
final Composite composite = uiPagination.getToolkit().createComposite(subComp, SWT.NULL);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Analysis analysis = masterPage.getAnalysisHandler().getAnalysis();
// create table viewer firstly
ITableTypeStates tableTypeState = TableTypeStatesFactory.getInstance().getTableState(chartType, units);
ChartDataEntity[] dataEntities = tableTypeState.getDataEntity();
TableWithData chartData = new TableWithData(chartType, dataEntities);
TableViewer tableviewer = tableTypeState.getTableForm(composite);
tableviewer.setInput(chartData);
tableviewer.getTable().pack();
dyModel.setTableViewer(tableviewer);
DataExplorer dataExplorer = tableTypeState.getDataExplorer();
ChartTableFactory.addMenuAndTip(tableviewer, dataExplorer, analysis);
if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
// only text indicator need
indicators = getIndicators(dataEntities);
} else {
indicators = getIndicators(units);
}
dyModel.setIndicatorList(indicators);
// create chart
try {
if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartState(chartType, units);
boolean isPattern = chartTypeState instanceof PatternStatisticsState;
if (event == null) {
chart = chartTypeState.getChart();
if (chart != null && isSQLMode) {
// chart is null for MODE. Get the dataset by this way for SQL mode
if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 2);
if (dataset == null) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
}
dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart, 0));
} else {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
if (dataset == null) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, -1);
}
}
}
} else {
chart = chartTypeState.getChart(dataset);
}
dyModel.setDataset(dataset);
if (chart != null) {
if (!isPattern) {
// need not to decorate the chart of Pattern(Regex/Sql/UdiMatch)
TOPChartUtils.getInstance().decorateChart(chart, false);
} else {
TOPChartUtils.getInstance().decoratePatternMatching(chart);
}
Object chartComposite = TOPChartUtils.getInstance().createTalendChartComposite(composite, SWT.NONE, chart, true);
dyModel.setBawParentChartComp(chartComposite);
Map<String, Object> menuMap = createMenuForAllDataEntity((Composite) chartComposite, dataExplorer, analysis, ((ICustomerDataset) chartTypeState.getDataset()).getDataEntities());
// call chart service to create related mouse listener
if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, false);
} else {
TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, true);
}
}
}
// TDQ-11886 add these 2 catches.make it continue to work even if encounter some problems.
} catch (Error e) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), e);
} catch (Exception exp) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), exp);
}
subComp.setClient(composite);
subComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
masterPage.registerSection(subComp);
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class AbstractAnalysisResultPageWithChart method createMenuForAllDataEntity.
protected Map<String, Object> createMenuForAllDataEntity(Shell shell, DataExplorer dataExplorer, Analysis analysis, ChartDataEntity[] chartDataEntities) {
Map<String, Object> menuMap = new HashMap<String, Object>();
if (!analysis.getParameters().isStoreData()) {
return menuMap;
}
for (ChartDataEntity oneDataEntity : chartDataEntities) {
Indicator indicator = oneDataEntity.getIndicator();
Menu menu = createMenu(shell, dataExplorer, analysis, oneDataEntity, getEditorName(indicator));
ChartTableFactory.addJobGenerationMenu(menu, analysis, indicator);
menuMap.put(oneDataEntity.getLabel(), menu);
}
return menuMap;
}
Aggregations