private void searchForRuntimes(
      List<RuntimeDefinition> runtimeCollector, IPath path, IProgressMonitor monitor) {

    File[] files = null;
    if (path != null) {
      File root = path.toFile();
      if (root.isDirectory()) files = new File[] {root};
      else return;
    } else files = File.listRoots();

    if (files != null) {
      int size = files.length;
      monitor.beginTask("Searching " + path.toOSString(), size * 100);
      int work = 100 / size;
      for (int i = 0; i < size; i++) {
        if (monitor.isCanceled()) return;
        if (files[i] != null && files[i].isDirectory())
          searchDirectory(files[i], runtimeCollector, DEPTH, new SubProgressMonitor(monitor, 80));
        monitor.worked(20);
      }
      monitor.done();
    } else {
      monitor.beginTask("Searching " + path.toOSString(), 1);
      monitor.worked(1);
      monitor.done();
    }
  }
예제 #2
0
 /**
  * It can be necessary to determine which is the root of a path. For example, the root of
  * D:\Projects\Java is D:\.
  *
  * @param path The path used to get a root
  * @return The root which contais the specified path
  */
 public static String getRoot(String path) {
   File file = new File(path);
   File[] roots = file.listRoots();
   for (int i = 0; i < roots.length; i++)
     if (path.startsWith(roots[i].getPath())) return roots[i].getPath();
   return path;
 }
예제 #3
0
  protected List getDirectoryNames() throws IOException {
    List result = new ArrayList();

    addSubDirectoryNames(File.listRoots()[0], result, 10);

    return result;
  }
  /**
   * Returns absolute path for any project's folder. Since 1.6.0 supports relative paths (RFE
   * 1111956).
   *
   * @param relativePath relative path from project file.
   * @param defaultName default name for such a project's folder, if relativePath is "__DEFAULT__".
   */
  private static String computeAbsolutePath(
      String m_root, String relativePath, String defaultName) {
    if (OConsts.DEFAULT_FOLDER_MARKER.equals(relativePath))
      return m_root + defaultName + File.separator;
    else {
      try {
        // check if path starts with a system root
        boolean startsWithRoot = false;
        for (File root : File.listRoots()) {
          try // Under Windows and Java 1.4, there is an exception if
          { // using getCanonicalPath on a non-existent drive letter
            // [1875331] Relative paths not working under
            // Windows/Java 1.4
            String platformRelativePath = relativePath.replace('/', File.separatorChar);
            // If a plaform-dependent form of relativePath is not
            // used, startWith will always fail under Windows,
            // because Windows uses C:\, while the path is stored as
            // C:/ in omegat.project
            startsWithRoot = platformRelativePath.startsWith(root.getCanonicalPath());
          } catch (IOException e) {
            startsWithRoot = false;
          }
          if (startsWithRoot)
            // path starts with a root --> path is already absolute
            return new File(relativePath).getCanonicalPath() + File.separator;
        }

        // path does not start with a system root --> relative to
        // project root
        return new File(m_root, relativePath).getCanonicalPath() + File.separator;
      } catch (IOException e) {
        return relativePath;
      }
    }
  }
예제 #5
0
  public static String getStat() {
    StringBuilder stat = new StringBuilder();
    stat.append("Available processors (cores): ")
        .append(Runtime.getRuntime().availableProcessors());

    /* Total amount of free memory available to the JVM */
    stat.append("\nFree memory (bytes): ").append(Runtime.getRuntime().freeMemory());

    /* This will return Long.MAX_VALUE if there is no preset limit */
    long maxMemory = Runtime.getRuntime().maxMemory();
    /* Maximum amount of memory the JVM will attempt to use */
    stat.append("\nMaximum memory (bytes): ")
        .append(maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory);

    /* Total memory currently in use by the JVM */
    stat.append("\nTotal memory (bytes): ").append(Runtime.getRuntime().totalMemory());

    /* Get a list of all filesystem roots on this system */
    File[] roots = File.listRoots();

    /* For each filesystem root, print some info */
    for (File root : roots) {
      stat.append("\nFile system root: ").append(root.getAbsolutePath());
      stat.append("\nTotal space (bytes): ").append(root.getTotalSpace());
      stat.append("\nFree space (bytes): ").append(root.getFreeSpace());
      stat.append("\nUsable space (bytes): ").append(root.getUsableSpace());
    }

    return stat.toString();
  }
 @Override
 public int size() {
   if (path == null) {
     return File.listRoots().length;
   } else {
     File[] files = path.listFiles();
     return files == null ? 0 : files.length;
   }
 }
  protected FileChooserWinService() {
    pool = Executors.newFixedThreadPool(3, new ServiceThreadFactory("SystemDisplayNameGetter"));

    File[] roots = File.listRoots();

    for (File root : roots) {
      processRoot(root);
    }
  }
예제 #8
0
 @Override
 protected void initializeControls() {
   DefaultMutableTreeNode root = new DefaultMutableTreeNode("Computer", true);
   for (File file : File.listRoots()) {
     root.add(new DirNode(file));
   }
   tree = new JTree(root);
   // tree.setRootVisible(false);
 }
예제 #9
0
  public static String construct(String uid, String key) throws JSONException, SigarException {
    JSONObject construct = new JSONObject();
    construct.put("uid", uid);
    construct.put("key", key);
    construct.put("hostname", sigar.getNetInfo().getHostName());

    JSONObject obj = new JSONObject();
    obj.put("uptime", formatUptime(sigar.getUptime().getUptime()));
    obj.put("load1", ((int) (sigar.getCpuPerc().getCombined() * 100)));
    obj.put("load5", 0);
    obj.put("load15", 0);
    construct.put("uplo", obj);

    Mem mem = sigar.getMem();

    JSONObject memory = new JSONObject();
    memory.put("total", byteToMByte(mem.getTotal()));
    memory.put("used", byteToMByte(mem.getUsed()));
    memory.put("free", byteToMByte(mem.getFree()));
    memory.put("bufcac", 0);

    construct.put("ram", memory);

    LinkedList<HashMap<String, Object>> fsystems = new LinkedList<HashMap<String, Object>>();
    long total = 0;
    long used = 0;
    long free = 0;
    for (File file : File.listRoots()) {
      long ftotal = file.getTotalSpace();
      long ffree = file.getFreeSpace();
      long fused = ftotal - ffree;

      HashMap<String, Object> system = new HashMap<String, Object>();
      system.put("mount", file.getPath());
      system.put("total", byteToKByte(ftotal));
      system.put("used", byteToKByte(fused));
      system.put("avail", byteToKByte(ffree));
      fsystems.add(system);

      total += ftotal;
      free += ffree;
      used += fused;
    }

    HashMap<String, Object> bla = new HashMap<String, Object>();
    bla.put("single", fsystems);
    HashMap<String, Object> tot = new HashMap<String, Object>();
    tot.put("total", byteToKByte(total));
    tot.put("free", byteToKByte(free));
    tot.put("used", byteToKByte(used));
    bla.put("total", tot);

    construct.put("disk", bla);

    return construct.toString();
  }
예제 #10
0
  /**
   * It can be necessary to check if a path specified by the user is an absolute path (i.e
   * C:\Gfx\3d\Utils is absolute whereas ..\Jext is relative).
   *
   * @param path The path to check
   * @return <code>true</code> if <code>path</code> begins with a root name
   */
  public static boolean beginsWithRoot(String path) {
    if (path.length() == 0) return false;

    File file = new File(path);
    File[] roots = file.listRoots();
    for (int i = 0; i < roots.length; i++)
      if (path.regionMatches(true, 0, roots[i].getPath(), 0, roots[i].getPath().length()))
        return true;
    return false;
  }
 /**
  * 获取当前系统的磁盘占用率
  *
  * @return
  */
 public double getDiskState() {
   File[] roots = File.listRoots(); // 获取磁盘分区列表
   double totalDisk = 0, freeDisk = 0, diskPercentage;
   for (File file : roots) {
     totalDisk += file.getTotalSpace() / 1024 / 1024 / 1024;
     freeDisk += file.getFreeSpace() / 1024 / 1024 / 1024;
   }
   diskPercentage = 100 * (totalDisk - freeDisk) / totalDisk;
   return diskPercentage;
 }
예제 #12
0
 public void setCurrentFolder(File folder) {
   this.currentFolder = folder;
   if (folder == null) {
     currentFiles = File.listRoots();
   } else {
     currentFiles = folder.listFiles(fileFilter);
   }
   sortFiles();
   fireTableDataChanged();
 }
예제 #13
0
  protected static DefaultFontMapper getMapper() {
    if (mapper == null) {
      //      long t = System.currentTimeMillis();
      mapper = new DefaultFontMapper();

      if (PApplet.platform == PApplet.MACOSX) {
        try {
          String homeLibraryFonts = System.getProperty("user.home") + "/Library/Fonts";
          mapper.insertDirectory(homeLibraryFonts);
        } catch (Exception e) {
          // might be a security issue with getProperty() and user.home
          // if this sketch is running from the web
        }
        // add the system font paths
        mapper.insertDirectory("/System/Library/Fonts");
        mapper.insertDirectory("/Library/Fonts");

      } else if (PApplet.platform == PApplet.WINDOWS) {
        // how to get the windows fonts directory?
        // could be c:\winnt\fonts or c:\windows\fonts or not even c:
        // maybe do a Runtime.exec() on echo %WINDIR% ?
        // Runtime.exec solution might be a mess on systems where the
        // the backslash/colon characters not really used (i.e. JP)

        // find the windows fonts folder
        File roots[] = File.listRoots();
        for (int i = 0; i < roots.length; i++) {
          if (roots[i].toString().startsWith("A:")) {
            // Seems to be a problem with some machines that the A:
            // drive is returned as an actual root, even if not available.
            // This won't fix the issue if the same thing happens with
            // other removable drive devices, but should fix the
            // initial/problem as cited by the bug report:
            // http://dev.processing.org/bugs/show_bug.cgi?id=478
            // If not, will need to use the other fileExists() code below.
            continue;
          }

          File folder = new File(roots[i], "WINDOWS/Fonts");
          if (folder.exists()) {
            mapper.insertDirectory(folder.getAbsolutePath());
            break;
          }
          folder = new File(roots[i], "WINNT/Fonts");
          if (folder.exists()) {
            mapper.insertDirectory(folder.getAbsolutePath());
            break;
          }
        }
      }
      //      System.out.println("mapping " + (System.currentTimeMillis() - t));
    }
    return mapper;
  }
예제 #14
0
  @RequestMapping(value = "/website/ips/{ipsPosition}")
  public String goToSlave(@PathVariable("ipsPosition") int ipsPosition, ModelMap model) {

    currentMasterThread = master.clients[ipsPosition];
    currentMasterThread.sendMessage("AvailablePythonScripts");
    currentMasterThread.sendMessage("AvailablePythonVersions");
    File folderPath = master.folderInfo.folderPath;
    if (folderPath != null) {
      list = new ArrayList<File>();
      listBoolean = new ArrayList<Boolean>();
      try {
        showDir(folderPath);
      } catch (IOException e) {
        e.printStackTrace();
      }

    } else {
      File[] roots = File.listRoots();
      list = new ArrayList<File>();
      listBoolean = new ArrayList<Boolean>();
      for (int i = 0; i < roots.length; i++) {
        list.add(roots[i]);
        listBoolean.add(true);
      }
    }
    model.addAttribute("folderList", list);
    model.addAttribute("folderListBoolean", listBoolean);
    model.addAttribute("PcName", currentMasterThread.osInfo.get("PcName"));
    model.addAttribute("OsName", currentMasterThread.osInfo.get("OsName"));
    model.addAttribute("PythonVersions", currentMasterThread.pythonVersions);
    model.addAttribute("XmlResults", currentMasterThread.getXmlResults());
    model.addAttribute("XmlResultsHashTables", currentMasterThread.getXmlResultsHashtables());
    model.addAttribute("XmlResultsBooleans", currentMasterThread.getXmlResultsBoolean());
    if (currentMasterThread.lastScriptResults != null) {
      model.addAttribute("LastScriptResults", currentMasterThread.lastScriptResults);
    } else {
      model.addAttribute("LastScriptResults", "No Script was run lately");
    }

    model.addAttribute("Status", currentMasterThread.status);

    while (currentMasterThread.pythonScriptsAvailable == null) ;
    ArrayList<String> availablePythonScripts = new ArrayList<String>();
    System.out.println("Nr of scripts: " + currentMasterThread.pythonScriptsAvailable.length);
    for (int i = 0; i < currentMasterThread.pythonScriptsAvailable.length; i++) {
      availablePythonScripts.add(
          currentMasterThread.pythonScriptsAvailable[i][0]
              + ":("
              + currentMasterThread.pythonScriptsAvailable[i][2]
              + ")");
    }
    model.addAttribute("Scripts", availablePythonScripts);
    return "main";
  }
예제 #15
0
  /**
   * Finds all UMS devices that contains Droid in root
   *
   * @return
   */
  private static ArrayList<Device> findUMS() {
    ArrayList<Device> UMS = new ArrayList<>();

    // for each pathname in pathname array
    for (File path : File.listRoots()) {
      if (Files.exists(Paths.get(path.toString(), "Droid"))) {
        UMS.add(new DeviceUMS(path));
      }
    }
    return UMS;
  }
  public void init(Editor _editor) {
    this.m_editor = _editor;

    File toolRoot = null;
    try {
      toolRoot =
          new File(
                  SequantoAutomationTool.class
                      .getProtectionDomain()
                      .getCodeSource()
                      .getLocation()
                      .toURI())
              .getParentFile()
              .getParentFile();
    } catch (java.net.URISyntaxException ex) {
      toolRoot =
          new File(
                  SequantoAutomationTool.class
                      .getProtectionDomain()
                      .getCodeSource()
                      .getLocation()
                      .getPath())
              .getParentFile()
              .getParentFile();
    }

    m_generatorPy =
        new File(new File(toolRoot, "generator"), "generate_automation_defines.py")
            .getAbsolutePath();
    m_isWindows = System.getProperty("os.name").toLowerCase().contains("win");
    if (m_isWindows) {
      for (File root : File.listRoots()) {
        File[] files =
            root.listFiles(
                new FileFilter() {
                  public boolean accept(File f) {
                    return f.getName().toLowerCase().startsWith("python");
                  }
                });
        if (files != null) {
          for (File directory : files) {
            m_pythonPath = new File(directory, "python.exe");
            break;
          }
        }
      }
      if (m_pythonPath == null) {
        Base.showMessage(
            "ERROR",
            String.format(
                "Could not python interpreter - Generate Automation tool will not work."));
      }
    }
  }
예제 #17
0
 /** Method to find and add the roots of the machine to the list. Called for WBFile.computer */
 public void dispDrives() {
   // Fill window with root directories
   File[] f = File.listRoots();
   for (int i = 0; i < f.length; i++) {
     WBFile tmpFile = new WBFile(scene, f[i]);
     fileSelector.addListElement(tmpFile);
     currDispFiles.add(tmpFile);
     tmpFile.setIcon("directory");
   }
   lookInText.setText("     Computer");
 }
예제 #18
0
  public SystemeDeFichiers() {
    listeners = new EventListenerList();
    racine = new Vector();

    // racine.add(new File("/home/charly"));

    File[] racFs;
    racFs = File.listRoots();
    for (int n = 0; n < racFs.length; n++) {
      racine.add(racFs[n]);
    }
  }
  public boolean import_file() throws IOException {
    // System.out.println("got here.");
    // System.out.println(name);

    /*
    We are working on this =)
    */
    File[] files = File.listRoots();
    for (File f : files) {
      f.getPath();
      // System.out.println(f.getAbsolutePath());
      f1 = new File(name);
      // System.out.println(f1.getParent());
      // DEBUG
      if (f1.getName().equalsIgnoreCase(name)) System.out.println("found it");
    }
    try {
      FileReader fr = new FileReader(name);
      BufferedReader br = new BufferedReader(fr);
      while ((line = br.readLine()) != null) {
        // System.out.println(line);
        if (line != null) {
          if (fileContents == null) {
            fileContents = line;
          } else {
            fileContents = fileContents + "\n" + line;
          }
        }
      }

      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      /* debug
      System.out.println("After Format : " + sdf.format(f1.lastModified()));
      */
      dateCreated = sdf.format(f1.lastModified());
      if (fileContents == null) {
        System.out.println("didn't find it");
        JOptionPane.showMessageDialog(null, Local.getString("We cannot find your document"));
      }
      br.close();

    } catch (IOException ex) {
      JOptionPane.showMessageDialog(null, Local.getString("there was a problem finding your file"));
      name = null;
      return false;
    }
    // }

    JOptionPane.showMessageDialog(
        null, Local.getString("We imported your file, just click ok (twice)"));
    return true;
  }
 @Override
 public FileOrDirectoryMatrix get(int index) {
   File[] files = null;
   if (path == null) {
     files = File.listRoots();
   } else {
     files = path.listFiles();
   }
   if (files[index].isFile()) {
     return new FileMatrix(files[index]);
   } else {
     return new DirectoryMatrix(files[index]);
   }
 }
 /**
  * Get FS roots without {@link #isFloppy(File) floppy drives}.
  *
  * @return list of FS roots, never {@code null}.
  */
 private static List<File> getFsRoots() {
   File[] fsRoots = File.listRoots();
   if (fsRoots == null) {
     // should not happen
     return Collections.emptyList();
   }
   List<File> result = new ArrayList<File>(fsRoots.length);
   for (File root : fsRoots) {
     LOGGER.log(Level.FINE, "FS root: {0}", root);
     if (isFloppy(root)) {
       LOGGER.log(Level.FINE, "Skipping floppy: {0}", root);
       continue;
     }
     result.add(root);
   }
   return result;
 }
예제 #22
0
  /**
   * 获取系统最大剩余空间的分区
   *
   * @return
   */
  public String getDriverMaxSpace() {
    String os = System.getProperty("os.name");
    if (os.contains("Windows")) {
      int max = 0;
      File[] roots = File.listRoots();
      for (int i = 0; i < roots.length; i++) {
        long spaceSize = roots[0].getFreeSpace();
        if (roots[i].getFreeSpace() > spaceSize) {
          max = i;
          continue;
        }
        dirPath = roots[max].getPath() + "video";
      }
    } else {
      // linux df -m |awk 'NR>1{print $1,$4}'
      BufferedReader br = null;
      String[] shell = new String[] {"sh", "-c", "df -m |awk 'NR>1{print $6\",\"$4}'"};
      Map<String, String> result = new HashMap<String, String>();

      try {
        Process process = Runtime.getRuntime().exec(shell);
        process.waitFor();
        br = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
        String line = null;
        while ((line = br.readLine()) != null) {
          result.put(line.split(",")[1].replaceAll(",", ""), line.split(",")[0]);
        }
      } catch (IOException e) {
        e.printStackTrace();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      long max = 0;
      for (Map.Entry<String, String> entry : result.entrySet()) {
        if (Integer.valueOf(entry.getKey()) > max) {
          max = Integer.valueOf(entry.getKey());
        }
      }
      dirPath = result.get(String.valueOf(max)) + "video_linux";
    }
    new FileInfo().checkSubsection(dirPath);
    logger.info("use dir path is : " + dirPath);
    return dirPath;
  }
예제 #23
0
  private void createBrowseLocalFilesView(FormToolkit toolkit, Composite parent) {
    Section localFilesSection =
        toolkit.createSection(parent, Section.TITLE_BAR | Section.DESCRIPTION);

    localFilesSection.setText("Local Files");
    localFilesSection.setDescription("Double click to add to current project");

    Composite composite = toolkit.createComposite(localFilesSection, SWT.WRAP);
    composite.setBounds(10, 94, 64, 64);

    FormData fd_composite = new FormData();
    fd_composite.bottom = new FormAttachment(100, -10);
    fd_composite.right = new FormAttachment(0, 751);
    fd_composite.left = new FormAttachment(0, 10);
    composite.setLayoutData(fd_composite);
    composite.setLayout(new TreeColumnLayout());

    treeViewer = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    Tree localFilesTree = treeViewer.getTree();
    localFilesTree.setHeaderVisible(true);
    localFilesTree.setLinesVisible(true);

    treeViewer.setAutoExpandLevel(2);

    drillDownAdapter = new DrillDownAdapter(treeViewer);

    treeViewer.setContentProvider(new ViewContentProvider());

    treeViewer.setLabelProvider(new ViewLabelProvider());

    treeViewer.setSorter(new NameSorter());
    treeViewer.setInput(File.listRoots());

    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(treeViewer.getControl(), "com.plugin.tryplugin.viewer");

    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
    localFilesSection.setClient(composite);
  }
예제 #24
0
파일: Ini.java 프로젝트: AtrumGeost/ati_ds
  /**
   * Descripción de Método
   *
   * @return
   */
  public static String findOXPHome() {

    String ch = getOXPHome();

    if (ch != null) {
      return ch;
    }

    File[] roots = File.listRoots();

    for (int i = 0; i < roots.length; i++) {

      if (roots[i].getAbsolutePath().startsWith("A:")) {
        continue;
      }

      File[] subs = roots[i].listFiles();

      if (subs == null) {
        continue;
      }

      for (int j = 0; j < subs.length; j++) {

        if (!subs[j].isDirectory()) {
          continue;
        }

        String fileName = subs[j].getAbsolutePath();

        if (fileName.indexOf("ServidorOXP") != 1) {

          String libDir = fileName + File.separator + "lib";
          File lib = new File(libDir);

          if (lib.exists() && lib.isDirectory()) {
            return fileName;
          }
        }
      }
    }

    return ch;
  } // findOXPHome
예제 #25
0
  @Test
  public void relativePaths() throws Exception {
    Arrays.asList(File.listRoots());
    File base = new File("/tmp/x");
    File nested = new File("/tmp/x/y");
    assertThat(archetypeUtils.relativePath(base, nested), equalTo("y"));

    //        base = new File("/tmp/x");
    //        nested = new File("/bin/y");
    //        assertThat(archetypeUtils.relativePath(base, nested), equalTo("/bin/y"));

    base = new File("/tmp/x");
    nested = new File("/tmp/x");
    assertThat(archetypeUtils.relativePath(base, nested), equalTo(""));

    base = new File("/tmp/x/..");
    nested = new File("/tmp/x");
    assertThat(archetypeUtils.relativePath(base, nested), equalTo("x"));
  }
예제 #26
0
  @SuppressWarnings("rawtypes")
  @Delegate(
      interfaceName = "com.ocean.FttpWorker",
      methodName = "getChildFileMeta",
      policy = DelegatePolicy.Implements)
  public FileResult[] getChildFileProperty(String f) throws RemoteException, FttpException {
    // System.out.println(f);
    FileResult[] frs = null;
    ;
    new FileAdapter(f);
    File[] farr = f.length() > 0 ? new FileAdapter(f).listFiles() : File.listRoots();

    if (farr != null && farr.length > 0) {
      frs = new FileResult[farr.length];
      for (int i = 0; i < farr.length; i++) frs[i] = getFileProperty(farr[i].getPath());
    }

    return frs;
  }
예제 #27
0
 @Delegate(
     interfaceName = "com.ocean.FttpWorker",
     methodName = "listRoots",
     policy = DelegatePolicy.Implements)
 public String[] getListRoots() throws RemoteException, FttpException {
   String[] rts = null;
   FileAdapter fa = new FileAdapter("/");
   try {
     File[] fls = File.listRoots();
     if (fls != null && fls.length > 0) {
       rts = new String[fls.length];
       for (int i = 0; i < fls.length; i++) rts[i] = fls[i].getPath();
     }
   } catch (Exception e) {
     fa.close();
     throw new FttpException(e);
   }
   fa.close();
   return rts;
 }
예제 #28
0
  public FileSystemXml() {
    _roots = File.listRoots();

    for (int i = 1; i < _roots.length; i++) {
      Element item = new Element("item");
      racine.addContent(item);
      Attribute id0 = new Attribute("id", "0");
      racine.setAttribute(id0);
      Attribute txt = new Attribute("text", _roots[i].toString());
      item.setAttribute(txt);
      Attribute id = new Attribute("id", _roots[i].toString());
      item.setAttribute(id);
      Attribute im0 = new Attribute("im0", "leaf.gif");
      item.setAttribute(im0);
      Attribute im1 = new Attribute("im1", "folderOpen.gif");
      item.setAttribute(im1);
      Attribute im2 = new Attribute("im2", "folderClosed.gif");
      item.setAttribute(im2);
      getSubDirs(_roots[i], item);
    }
  }
  /** Populate tree */
  private void populateTree() {

    // create model
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("My Computer");
    DefaultTreeModel model = new DefaultTreeModel(rootNode, true);

    // add root drives
    File rootDrives[] = File.listRoots();
    DefaultMutableTreeNode driveNodes[] = new DefaultMutableTreeNode[rootDrives.length];
    for (int i = 0; i < rootDrives.length; ++i) {
      driveNodes[i] = new DefaultMutableTreeNode(rootDrives[i]);
      rootNode.add(driveNodes[i]);
    }

    tree.setModel(model);
    tree.setRootVisible(false);
    tree.setExpandsSelectedPaths(true);
    tree.addTreeWillExpandListener(this);
    tree.setCellRenderer(new DirTreeCellRenderer());
    tree.addTreeSelectionListener(this);
  }
 public void promptForNewVfsRoot() {
   boolean done = false;
   String defaultText = vfsBrowser.rootFileObject.getName().getURI();
   String text = defaultText;
   while (!done) {
     if (text == null) {
       text = defaultText;
     }
     File fileRoots[] = File.listRoots();
     String roots[] = new String[fileRoots.length];
     for (int i = 0; i < roots.length; i++) {
       try {
         roots[i] = fileRoots[i].toURI().toURL().toExternalForm();
       } catch (MalformedURLException e) {
         e.printStackTrace();
       }
     }
     ComboBoxInputDialog textDialog =
         new ComboBoxInputDialog(
             Messages.getString("VfsFileChooserDialog.enterNewVFSRoot"),
             text,
             roots,
             650,
             100); //$NON-NLS-1$
     text = textDialog.open();
     if (text != null && !"".equals(text)) { // $NON-NLS-1$
       try {
         vfsBrowser.resetVfsRoot(currentPanel.resolveFile(text));
         done = true;
       } catch (FileSystemException e) {
         MessageBox errorDialog = new MessageBox(vfsBrowser.getDisplay().getActiveShell(), SWT.OK);
         errorDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$
         errorDialog.setMessage(e.getMessage());
         errorDialog.open();
       }
     } else {
       done = true;
     }
   }
 }