use of org.talend.dataprofiler.core.service.IDatabaseJobService in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method createTreeMenu.
/**
* DOC qzhang Comment method "createTreeMenu". MOD qiongli bug 16252.Add a param of 'isColumnSetMenu'
*
* @param newTree
* @param containEdit
*/
public void createTreeMenu(boolean isColumnSetMenu) {
Menu oldMenu = tree.getMenu();
if (oldMenu != null && !oldMenu.isDisposed()) {
oldMenu.dispose();
}
Menu menu = new Menu(tree);
if (isSelectedColumn(tree.getSelection())) {
if (!isMetadataColumnSelected(tree.getSelection())) {
MenuItem previewMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
previewMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.previewDQElement"));
previewMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
previewMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
previewSelectedElements(tree);
}
});
}
if (isColumnSetMenu) {
MenuItem createColumnAnalysisMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
createColumnAnalysisMenuItem.setText(DefaultMessagesImpl.getString("CreateColumnAnalysisAction.columnAnalysis"));
createColumnAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
createColumnAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createColumnAnalysis(tree);
}
});
}
MenuItem showLocationMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showLocationMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
showLocationMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showLocationMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
showSelectedElements(tree);
}
});
}
if (isSelectedIndicator(tree.getSelection()) && !isMetadataColumnIndicatorSelected(tree.getSelection())) {
// MOD 2009-01-04 mzhao
MenuItem showQueryMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showQueryMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.viewQuery"));
showQueryMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showQueryMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
viewQueryForSelectedElement(tree);
}
});
}
if (isSelectedPatternIndicator(tree.getSelection())) {
MenuItem 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)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editPattern(tree);
}
});
}
// judge to indicator whether is frequency
if (isSelectedFrequencyIndicator(tree.getSelection()) && PluginChecker.isTDCPLoaded()) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final IDatabaseJobService service = (IDatabaseJobService) GlobalServiceRegister.getDefault().getService(IJobService.class);
if (service != null) {
service.setIndicator(getSelectedIndicator(tree.getSelection()));
IRepositoryNode anaNode = getAnalysis2();
Analysis ana;
if (anaNode instanceof ReportAnalysisRepNode) {
ana = ((ReportAnalysisRepNode) anaNode).getAnalysis();
} else {
ana = ((AnalysisRepNode) anaNode).getAnalysis();
}
service.setAnalysis(ana);
service.executeJob();
}
}
});
}
if (isSelectedUDIndicator(tree.getSelection())) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editUDIndicator"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.IND_DEFINITION));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editUDIndicator(tree);
}
});
}
// add common menu to the tree
MenuItem addTaskItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
addTaskItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.AddTask"));
addTaskItem.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
addTaskItem.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) {
IRepositoryNode ana = getAnalysis2();
// MOD qiongli 2011-1-12 feature 16796 :handle the case of ModelElement name is null
(new TdAddTaskAction(tree.getShell(), ana)).run();
}
}
});
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) {
removeSelectedElements2(tree);
}
});
tree.setMenu(menu);
}
use of org.talend.dataprofiler.core.service.IDatabaseJobService in project tdq-studio-se by Talend.
the class ChartTableFactory method addJobGenerationMenu.
/**
* add contextual menu for job generation.
*
* @param menu
* @param analysis
* @param currentIndicator
*/
public static void addJobGenerationMenu(final Menu menu, final Analysis analysis, final Indicator currentIndicator) {
Connection tdDataProvider = (Connection) analysis.getContext().getConnection();
boolean isDelimitedFileAnalysis = ConnectionUtils.isDelimitedFileConnection(tdDataProvider);
boolean isHiveConnection = ConnectionHelper.isHive(tdDataProvider);
boolean isVertica = ConnectionHelper.isVertica(tdDataProvider);
if (PluginChecker.isTDCPLoaded() && !(isDelimitedFileAnalysis || isHiveConnection)) {
final IDatabaseJobService service = (IDatabaseJobService) GlobalServiceRegister.getDefault().getService(IJobService.class);
if (service != null) {
service.setIndicator(currentIndicator);
service.setAnalysis(analysis);
MenuItem item = null;
if (isDUDIndicator(currentIndicator) && AnalysisType.COLUMN_SET != analysis.getParameters().getAnalysisType()) {
item = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
item.setText(DefaultMessagesImpl.getString("ChartTableFactory.RemoveDuplicate"));
} else if (isPatternMatchingIndicator(currentIndicator) && !isVertica) {
// TDQ--8864 forbidden the genarate job menu for SQL pattern, remove this after TDQ-8875 is DONE
if (!isSQLPatternMatchingIndicator(currentIndicator)) {
item = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
item.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
}
} else if (isAllMatchIndicator(currentIndicator)) {
item = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
item.setText(DefaultMessagesImpl.getString("ChartTableFactory.gen_etl_job_row"));
} else if (isPhonseNumberIndicator(currentIndicator)) {
item = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
item.setText(DefaultMessagesImpl.getString("ChartTableFactory.gen_std_phone_job"));
} else if (isDqRule(currentIndicator)) {
item = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
item.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
}
if (item != null) {
item.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
service.executeJob();
}
});
}
}
}
}
Aggregations