Search in sources :

Example 1 with TdAddTaskAction

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);
    // 
    // }
    // }
    }
}
Also used : TdAddTaskAction(org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction) TreeSelection(org.eclipse.jface.viewers.TreeSelection) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 2 with TdAddTaskAction

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);
}
Also used : TdAddTaskAction(org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IDatabaseJobService(org.talend.dataprofiler.core.service.IDatabaseJobService) Analysis(org.talend.dataquality.analysis.Analysis) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Aggregations

TdAddTaskAction (org.talend.dataprofiler.core.ui.action.actions.TdAddTaskAction)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 IDatabaseJobService (org.talend.dataprofiler.core.service.IDatabaseJobService)1 Analysis (org.talend.dataquality.analysis.Analysis)1 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)1 ReportAnalysisRepNode (org.talend.dq.nodes.ReportAnalysisRepNode)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1