⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filetreelabelprovider.java

📁 dump3 morpheus 0.2.9 src
💻 JAVA
字号:
/**
 * DuMP3 version morpheus_0.2.9 - a duplicate/similar file finder in Java<BR>
 * Copyright 2005 Alexander Gr&auml;sser<BR>
 * All Rights Reserved, http://dump3.sourceforge.net/<BR>
 * <BR>
 * This file is part of DuMP3.<BR>
 * <BR>
 * DuMP3 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later version.<BR>
 * <BR>
 * DuMP3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.<BR>
 * <BR>
 * You should have received a copy of the GNU General Public License along with DuMP3; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301 USA
 */
package net.za.grasser.duplicate.gui;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import com.cloudgarden.resource.SWTResourceManager;

/**
 * This class ...
 * 
 * @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
 * @version $Revision: 1.6 $
 */
public class FileTreeLabelProvider extends LabelProvider {
  /**
   * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
   */
  @Override
  public String getText(final Object element) {
    final File f = (File)element;
    String s = f.getName();
    if (s.length() == 0) {
      try {
        final String a = f.getPath().substring(0, (f.getPath().length() - 1));
        final Process proc = Runtime.getRuntime().exec(("net use " + a));
        final BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
        String line = null;
        while ((line = br.readLine()) != null) {
          if (line.startsWith("Remote")) {
            s = a + " (" + line.substring(line.indexOf("\\")) + ")";
          }
        }
        proc.waitFor();
        if (s.length() == 0) {
          s = a;
        }
      } catch (final Exception e) {
        e.printStackTrace();
      }
    }
    return s;
  }

  /**
   * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
   */
  @Override
  public Image getImage(final Object element) {
    if (((File)element).isDirectory()) {
      return SWTResourceManager.getImage("icons/folder.gif");
    } else if (((File)element).isFile()) {
      return SWTResourceManager.getImage("icons/file.gif");
    } else {
      return SWTResourceManager.getImage("icons/close.gif");
    }
    /**
     * <pre>
     * if ((((File)element)).isDirectory()) {
     *   return SWTResourceManager.getImage(&quot;file:icons/folder.gif&quot;);
     * } else if ((((File)element)).isDirectory()) {
     *   return SWTResourceManager.getImage(&quot;file:icons/file.gif&quot;);
     * } else {
     *   return SWTResourceManager.getImage(&quot;file:icons/close.gif&quot;);
     * }
     * </pre>
     */
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -