use of org.talend.commons.ui.swt.actions.ITreeContextualAction in project tdi-studio-se by Talend.
the class ProcessVersionComposite method getEditPropertiesAction.
/**
*
* DOC xye Comment method "getEditPropertiesAction".
*
* @return
*/
public ITreeContextualAction getEditPropertiesAction(final Class<?> klazz) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.getClass() == klazz) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
return action;
}
}
}
}
}
return null;
}
use of org.talend.commons.ui.swt.actions.ITreeContextualAction in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createPopupMenu.
private void createPopupMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
BusinessAssignment businessAssignment = getBusinessAssignment(tableViewer.getSelection());
if (businessAssignment != null) {
repositoryNode = createRepositoryNode(businessAssignment);
if (repositoryNode != null) {
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, new StructuredSelection(repositoryNode));
if (action.isVisible()) {
((AContextualAction) action).setAvoidUnloadResources(true);
mgr.add(action);
}
}
}
if (ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
CorePlugin.getDefault().getDiagramModelService().addDeleteAssignmentAction(mgr, tableViewer.getSelection());
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
Aggregations