1 4 package org.terracotta.dso.actions; 5 6 import org.eclipse.core.resources.IProject; 7 import org.eclipse.jdt.core.IJavaElement; 8 import org.eclipse.jdt.core.IPackageFragment; 9 import org.eclipse.jface.viewers.ISelection; 10 import org.eclipse.swt.widgets.Menu; 11 12 import org.terracotta.dso.ProjectNature; 13 14 23 24 public class PackageFragmentHandler extends BaseMenuCreator { 25 private IPackageFragment m_fragment; 26 private AdaptableAction m_adaptableAction; 27 private ExcludedTypeAction m_excludedAction; 28 private LockHandler m_lockHandler; 29 30 public PackageFragmentHandler() { 31 super(); 32 33 m_adaptableAction = new AdaptableAction(); 34 m_excludedAction = new ExcludedTypeAction(); 35 m_lockHandler = new LockHandler(); 36 } 37 38 protected IJavaElement getJavaElement(ISelection selection) { 39 IPackageFragment fragment = ActionUtil.findSelectedPackageFragment(selection); 40 41 m_fragment = null; 42 43 if(fragment != null) { 44 IProject project = fragment.getJavaProject().getProject(); 45 46 try { 47 if(project.hasNature(ProjectNature.NATURE_ID)) { 48 m_fragment = fragment; 49 } 50 } catch(Exception e) {} 51 } 52 53 return m_fragment; 54 } 55 56 protected void fillMenu(Menu menu) { 57 if(m_fragment != null) { 58 m_adaptableAction.setJavaElement(m_fragment); 59 addMenuAction(menu, m_adaptableAction); 60 61 m_excludedAction.setJavaElement(m_fragment); 62 addMenuAction(menu, m_excludedAction); 63 64 m_lockHandler.fillMenu(menu); 65 } 66 } 67 } 68 | Popular Tags |