コード例 #1
0
 protected String packageNameForComponent(String componentName) {
   IProject project =
       ResourcesPlugin.getWorkspace().getRoot().getProject(getContainerFullPath().segment(0));
   try {
     LocalizedComponentsLocateResult result =
         LocatePlugin.getDefault().getLocalizedComponentsLocateResult(project, componentName);
     IType javaType;
     if (result != null && (javaType = result.getDotJavaType()) != null) {
       return javaType.getPackageFragment().getElementName();
     }
   } catch (CoreException e) {
     e.printStackTrace();
   } catch (LocateException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #2
0
 protected IPath componentPathForPackage(IPackageFragment _selection) {
   try {
     LocatePlugin locate = LocatePlugin.getDefault();
     for (IJavaElement element : _selection.getChildren()) {
       String componentName = locate.fileNameWithoutExtension(element.getElementName());
       LocalizedComponentsLocateResult result =
           locate.getLocalizedComponentsLocateResult(
               _selection.getJavaProject().getProject(), componentName);
       IFolder[] components = result.getComponents();
       if (components.length > 0) {
         IContainer selectionPath = components[0].getParent();
         return selectionPath.getFullPath();
       }
     }
   } catch (CoreException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (LocateException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }