use of org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction in project tdq-studio-se by Talend.
the class ModelElementTaskProvider method fillContextMenu.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
// MOD by hcheng 07-28-2009,for 8273,Remove the "add task" menu on the system indicators.
Object firstElement = currentSelection.getFirstElement();
if (firstElement instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) firstElement;
addTaskAction = new TdAddTaskAction(site.getViewSite().getShell(), node);
menu.add(addTaskAction);
// RepositoryNode parent = node.getParent();
// if (!(parent instanceof ReportSubFolderRepNode)) {
// Item item = node.getObject().getProperty().getItem();
// if (item instanceof TDQAnalysisItem || item instanceof TDQReportItem || item instanceof ConnectionItem) {
// // IPath append = WorkbenchUtils.getFilePath(node);
// // IFile file = ResourceManager.getRootProject().getFile(append);
// // addTaskAction = new TdAddTaskAction(site.getViewSite().getShell(), file);
// addTaskAction = new TdAddTaskAction(site.getViewSite().getShell(), node);
// menu.add(addTaskAction);
//
// }
// }
}
}
use of org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction 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);
}
Aggregations