Пример #1
0
 private static IPath getPathForLevelUp(int levelUp) {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < levelUp; i++) {
     sb.append("../"); // $NON-NLS-1$
   }
   return new Path(sb.toString());
 }
Пример #2
0
 public static String getRelativePath(IPath filePath, IPath pathToGitRoot) {
   StringBuilder sb = new StringBuilder();
   String file = null;
   if (!filePath.hasTrailingSeparator()) {
     file = filePath.lastSegment();
     filePath = filePath.removeLastSegments(1);
   }
   for (int i = 0; i < pathToGitRoot.segments().length; i++) {
     if (pathToGitRoot.segments()[i].equals(".."))
       sb.append(
               filePath.segment(filePath.segments().length - pathToGitRoot.segments().length + i))
           .append("/");
     // else TODO
   }
   if (file != null) sb.append(file);
   return sb.toString();
 }
Пример #3
0
 public EmailContent(String fileName) throws URISyntaxException, IOException {
   URL entry = GitActivator.getDefault().getBundleContext().getBundle().getEntry(fileName);
   if (entry == null) throw new IOException("File not found: " + fileName);
   BufferedReader reader = new BufferedReader(new InputStreamReader(entry.openStream()));
   String line = null;
   try {
     title = reader.readLine();
     StringBuilder stringBuilder = new StringBuilder();
     String ls = System.getProperty("line.separator");
     while ((line = reader.readLine()) != null) {
       stringBuilder.append(line);
       stringBuilder.append(ls);
     }
     content = stringBuilder.toString();
   } finally {
     reader.close();
   }
 }