亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? filesystembrowser.java

?? 手機郵箱撒的方式方式方式的
?? JAVA
字號:
//#condition MUJMAIL_FS
/*
MujMail - Simple mail client for J2ME
Copyright (C) 2008 David Hauzar <david.hauzar.mujmail@gmail.com>
Copyright (C) 2008 Nodir Yuldashev

This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package mujmail.ui;


import java.io.IOException;
import java.util.Enumeration;

import javax.microedition.io.Connector;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TextField;

import mujmail.Lang;
import mujmail.MujMail;
import mujmail.Properties;
import mujmail.jsr_75.FilesystemFactory;
import mujmail.jsr_75.MyFileConnection;
import mujmail.util.Callback;
import mujmail.util.StartupModes;

/**
 * Provides user interface for browsing the filesystem and choosing files and
 * directories.
 * 
 * @author Nodir Yuldashev, David Hauzar
 *  based on file attachment patch by John Dorfman
 */
public class FileSystemBrowser implements CommandListener { 
    /**
     * Enumeration class representing choosing modes of file system browser.
     */
    public static class ChoosingModes {
        private ChoosingModes() {};
        
        /** It will be possible to choose only files */
        public static final ChoosingModes FILES = new ChoosingModes();
        /** It will be possible to choose only directories */
        public static final ChoosingModes DIRECTORIES = new ChoosingModes();
    }
    
    /**
     * The thread that will be started after pressing select command.
     */
    private class SelectAction implements Runnable {
        private FileSystemBrowser fsBrowser;
        private Displayable displayable;
        public SelectAction(FileSystemBrowser fsBrowser, Displayable displayable) {
            this.fsBrowser = fsBrowser;
            this.displayable = displayable;
        }
        
        /**
         * Select command was pressed. If a directory have been chosen, go to this
         * directory. If a file have been chosen, this file is selected
         */
        public void run() {
            List curr = (List) displayable;
            final String tempcurrFile = curr.getString(curr.getSelectedIndex());
            if (tempcurrFile.endsWith(SEP_STR) || tempcurrFile.equals(UP_DIRECTORY)) {
                //Directory is chosen, go to the directory
                fsBrowser.traverseDirectory(tempcurrFile);
            } else {
                //File is chosen, choose this file and exit file system browser
                fileSelectedAction(tempcurrFile);
            }
        }
    }
    
    /**
     * Called when the file or directory was chosen.
     * Choose this file and exit filesystem browser - switch the display 
     * to the displayableCaller.
     * @param file 		chosen file or directory
     */
    private void fileSelectedAction(String file) {
        // set all state variables of the object - the file or directory has been chosen
        if (file.equals("..")) {
            currFile = "";
        } else {
            currFile = file;
        }
        wasFileSelected = true;
        System.out.println("Selected file" + file);
        selectedURL = "file://localhost/" + currDirName + currFile;

        // calls the object passed by user - the file or directory has been chosen
        finalAction.callback(this, "chosen");

        // switch the display: exit from file system browser
        mujMail.getDisplay().setCurrent(displayableCaller);
    }

    /** indicates whether the URL has been chosen until now */
    private boolean wasFileSelected;
    private final ChoosingModes choosingMode;
    private String currFile = "";
    private Callback finalAction;
    private MujMail mujMail;
    private Displayable displayableCaller;
    private String currDirName;
    private String selectedURL = "";
    private Command select = new Command(Lang.get(Lang.BTN_SELECT), Command.OK, 1);
    private Command confirm = new Command(Lang.get(Lang.BTN_CONFIRM), Command.SCREEN, 3);
    private Command cancel = new Command(Lang.get(Lang.BTN_CANCEL), Command.EXIT, 2);
    private Command createDir = new Command(Lang.get(Lang.BTN_FS_CREATE_DIR), Command.ITEM, 4);
    private final static String UP_DIRECTORY = "..";
    private final static String MEGA_ROOT = "";
    private final static String SEP_STR = "/";
    private final static char SEP = '/';
    private List browser;

    /**
     * Creates the instance of filesystem browser.
     * @param main the main object of the midlet - needed for changing focus, ...
     * @param caller the displayable caller - after browsing the filesystem,
     *  the focus will be returned to this object
     * @param finalAction method callback() of this object will be called before 
     *  exiting the browser;
     *  the parameter called will be this instance of FileSystemBrowser
     *  the parameter message will be of type String and will be "canceled" when
     *  user canceled the selection and "chosen" when user selected something
     * @param header the header of the filesystem browser form
     */
    public FileSystemBrowser(MujMail main, Displayable caller, Callback finalAction, 
            ChoosingModes choosingMode, String header) {
        this.choosingMode = choosingMode;
        this.finalAction = finalAction;
        mujMail = main;
        displayableCaller = caller;
        currDirName = MEGA_ROOT;
    }
    
    /**
     * Shows the browser window. Check for JSR75 availability has to be
     * performed before calling this function.
     * 
     * @param runMode the runmode of the filesystem browser
     */
    public void startBrowser(StartupModes runMode) {
        if (runMode == StartupModes.IN_THE_SAME_THREAD) {
            startBrowser();
        } else {
            // start in the new thread
            Runnable r = new Runnable() {

                public void run() {
                    startBrowser();
                }
            };
            Thread t = new Thread(r);
            t.start();
        }
    }
    
    /**
     * Starts the browsing of the filesystem with listing of all root directories.
     */
    private void startBrowser() {
        wasFileSelected = false;
        try {
            showCurrDir();
        } catch (SecurityException e) {
        } catch (Exception e) {
        }
    }

    /**
     * Gets the chosen URL. It can be URL of either file or directory according
     * to choosing mode of the file system browser.
     * @return the url choosen by user.
     */
    public String getSelectedURL() {
        return selectedURL;
    }
    /**
     * Gets the name of chosen file or directory.
     * @return the name of chosen file or directory.
     */
    public String getSelectedFileOrDirName() {
        return currFile;
    }
    
    /**
     * Gets true if some file or directory was chosen by FileSystem browser.
     * @return true if some file or directory was chosen, 
     *  false if not (canceled button) was pressed
     */
    public boolean wasFileSelected() {
        return wasFileSelected;
    }
    
    /**
     * Returns screen of filesystem browser to be displayed to user.
     *
     * @return the screen of filesystem browser to be displayed to user.
     */
    public Displayable getDisplayable() {
        return browser;
    }
    
    /**
     * Called from command action if select command was pressed.
     * If it was chosen a directory, go to this directory. If it was chosen 
     * a file, choose this file and exit - return focus to the caller.
     * @param caller the displayable caller - after browsing the filesystem,
     *  the focus will be returned to this object
     */
    private void selectAction(Displayable caller) {
        SelectAction r = new SelectAction(this, caller);
        Thread t = new Thread(r);
        t.start();
    }

    public void commandAction(Command c, Displayable d) {
        if (c == confirm) {
            // directory have been chosen
            List curr = (List) d;
            final String tempcurrFile = curr.getString(curr.getSelectedIndex());
            fileSelectedAction(tempcurrFile);
        }
        else if (c == select) {
            // file or directory was chosen
            selectAction(d);
        } else if (c == createDir) {
            // create new directory
            createDir(d);
        } else if (c == cancel) {
//TODO if possible destroy the instance of FileSystemBrowser
            mujMail.getDisplay().setCurrent(displayableCaller);
        }
    }
    
    /**
     * The callback object used to create new directory and switch focus back to
     * the filesystem browser.
     */
    private class CreateDirectory implements Callback {
        private String sMessage;
        private Displayable d;

        public CreateDirectory(FileSystemBrowser fsBrowser, Displayable d) {
            this.d = d;
        }
        
        public void callback(Object called, Object message) {
            this.sMessage = (String) message;
            Runnable runnable = new Runnable() {

                public void run() {
                    // creates the directory
                    try {
                        System.out.println(currDirName + sMessage);
                        MyFileConnection conn = FilesystemFactory.getFileConnection(
                                "file://localhost/" + currDirName + sMessage + SEP);
                        conn.mkdir();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        mujMail.alert.setAlert("The directory cannot by created", 
                                AlertType.ERROR);
                    }
                    // switch the focus back to the filesystem browser
                    mujMail.getDisplay().setCurrent(d);
                    traverseDirectory("");
                }
            };
            Thread thr = new Thread(runnable);
            thr.start();
        }
    }
    
    
    /**
     * Creates new directory.
     */
    private void createDir(Displayable d) {
        Callback callback = new CreateDirectory(this, d);
        TextInputDialog dialog = new TextInputDialog(Lang.get(Lang.FS_BROWSER_ENTER_DIR_NAME), 
                "", Properties.directoryLength, TextField.URL);
        dialog.start(getDisplayable(), callback);
    }

    /**
     * Shows current directory. This is directory given by currDirName.
     */
    private void showCurrDir() {
        Enumeration e;
        MyFileConnection currDir = null;
        try {
            browser = new List(currDirName, List.IMPLICIT);
            
            browser.setSelectCommand(select);
            browser.addCommand(cancel);
            browser.addCommand(select);
            if (choosingMode == ChoosingModes.DIRECTORIES) {
                browser.addCommand(confirm);
                if (currDirName != MEGA_ROOT) {
                    browser.addCommand(createDir);
                }
            }
            
            if (MEGA_ROOT.equals(currDirName)) {
                // we are on the top
                e = FilesystemFactory.getFileSystemRegistry().listRoots();
            } else {
                // we are in some nested directory
                currDir = FilesystemFactory.getFileConnection("file://localhost/" + currDirName, Connector.READ);
                e = currDir.list();
                browser.append(UP_DIRECTORY, null);
            }
            while (e.hasMoreElements()) {
                String fileName = (String) e.nextElement();
                if (fileName.charAt(fileName.length() - 1) == SEP) {
                    browser.append(fileName, null);
                } else if (choosingMode == ChoosingModes.FILES) {
                    browser.append(fileName, null);
                }
            }
            
            browser.setCommandListener(this);
            if (currDir != null) {
                currDir.close();
            }
            mujMail.getDisplay().setCurrent(browser);
        } catch (IOException ioe) {
            System.out.println("IO Exception occured");
        } catch (SecurityException se) {
            System.out.println("Security Exception occured");
        } catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("Exception occured");
        }
    }

    
    private void traverseDirectory(String fileName) {
        if (currDirName.equals(MEGA_ROOT)) {
            if (fileName.equals(UP_DIRECTORY)) {
                // can not go up from MEGA_ROOT
                finalAction.callback(this, "canceled");
                return;
            }
            currDirName = fileName;
        } else if (fileName.equals(UP_DIRECTORY)) {
            //Go up one directory
//TODO use setFileConnection when implemented
            int i = currDirName.lastIndexOf(SEP, currDirName.length() - 2);
            if (i != -1) {
                currDirName = currDirName.substring(0, i + 1);
            } else {
                currDirName = MEGA_ROOT;
            }
        } else {
            currDirName = currDirName + fileName;
        }
        showCurrDir();
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品高清| av毛片久久久久**hd| 中文字幕精品在线不卡| 国产精品自拍三区| 中文字幕免费一区| 欧美一区二区三区爱爱| a4yy欧美一区二区三区| 欧美韩国日本一区| 99国产麻豆精品| 国产一区欧美日韩| 欧美一级精品在线| 丁香天五香天堂综合| 日韩av高清在线观看| 亚洲特黄一级片| 色婷婷精品大在线视频| 亚洲自拍另类综合| 亚洲欧洲精品一区二区精品久久久| 福利一区在线观看| 国产精品一区二区在线观看不卡| 91福利在线导航| 成人av手机在线观看| 亚洲欧洲在线观看av| 日韩欧美一区二区三区在线| 欧美日韩精品欧美日韩精品一综合| 久久精品国产99久久6| 亚洲午夜影视影院在线观看| 久久久天堂av| 在线观看欧美精品| 国产美女视频一区| 91在线免费播放| 91丨porny丨首页| 蜜桃一区二区三区在线观看| 日本一二三四高清不卡| 精品卡一卡二卡三卡四在线| av在线综合网| youjizz国产精品| 看电视剧不卡顿的网站| 国产高清在线观看免费不卡| 国产乱子伦视频一区二区三区 | 99精品久久只有精品| 喷白浆一区二区| 青青草原综合久久大伊人精品 | 播五月开心婷婷综合| 亚洲国产日韩在线一区模特| 国产精品福利一区| 亚洲综合男人的天堂| 国产欧美日本一区视频| 欧美大片在线观看一区| 国产精品久久久久久亚洲伦| 精品日韩成人av| 欧美电视剧在线观看完整版| 国产精品久久久久久久第一福利| 日韩视频免费观看高清完整版| 欧美高清视频不卡网| 久久久精品综合| 日韩在线a电影| 亚洲电影中文字幕在线观看| 国产在线精品一区二区不卡了| 国产成人综合亚洲91猫咪| 国产精品入口麻豆原神| 亚洲国产va精品久久久不卡综合| 国产最新精品精品你懂的| 一卡二卡三卡日韩欧美| 天天综合色天天综合| 国产超碰在线一区| 懂色一区二区三区免费观看| 欧美日韩一区二区在线观看| 国产精品视频一二| 中文字幕免费不卡| 久久嫩草精品久久久精品| 欧美激情资源网| 日韩一区中文字幕| 久久久精品天堂| 日本欧美久久久久免费播放网| 狠狠色综合色综合网络| 国产91精品欧美| 精品电影一区二区| 亚洲欧洲日韩av| 久久久不卡网国产精品二区| 国产精品美女久久久久久久| 亚洲国产aⅴ成人精品无吗| 综合中文字幕亚洲| 春色校园综合激情亚洲| 日韩欧美第一区| 免费欧美高清视频| 欧美日韩在线亚洲一区蜜芽| 一区二区三区毛片| eeuss鲁片一区二区三区| 国产亚洲精品aa| 国产在线观看一区二区| 精品国产99国产精品| 免费成人av资源网| 69久久99精品久久久久婷婷| 亚洲一二三区视频在线观看| 欧美影视一区在线| 亚洲精品免费在线| 国产成人免费视| 亚洲国产精品成人综合| 国产精品亚洲专一区二区三区| 久久精品无码一区二区三区| 国产成人精品亚洲日本在线桃色| 日本成人在线网站| 国产精品资源在线| 日韩午夜电影av| 亚洲一区二区欧美日韩| 午夜av一区二区三区| 亚洲美女免费视频| 美女视频黄 久久| 亚洲成人av电影在线| 日本久久电影网| 欧美丝袜丝交足nylons图片| 日韩免费视频一区| 日韩影视精彩在线| 欧美在线免费观看视频| 制服丝袜亚洲精品中文字幕| 看国产成人h片视频| av电影在线观看完整版一区二区| 精品欧美久久久| 一区二区三区鲁丝不卡| 成人综合日日夜夜| 欧美日韩精品一区二区三区四区 | 精品久久久久久综合日本欧美| 制服丝袜亚洲色图| 亚洲欧美另类在线| 天堂一区二区在线| 欧美久久久久久蜜桃| 亚洲人成网站影音先锋播放| 国产69精品久久久久毛片| 精品91自产拍在线观看一区| 成人美女视频在线观看| 无码av中文一区二区三区桃花岛| 国产精品久久久久久久久免费相片 | 午夜国产精品一区| 中文字幕一区视频| 欧美大黄免费观看| 欧美日韩高清一区二区不卡| a在线欧美一区| 国产精品1区2区3区在线观看| 性做久久久久久免费观看| 中文子幕无线码一区tr| 欧美精品一区二区三区在线 | 欧美日韩精品欧美日韩精品| gogogo免费视频观看亚洲一| 高潮精品一区videoshd| 奇米影视在线99精品| 亚洲线精品一区二区三区八戒| 自拍偷拍亚洲欧美日韩| 国产欧美日韩精品在线| 久久老女人爱爱| 久久五月婷婷丁香社区| 欧美一区二区三区婷婷月色| 欧美日韩三级在线| 色婷婷综合久久久久中文| 99久久综合国产精品| 99在线精品免费| av在线不卡电影| 在线观看视频一区二区欧美日韩| 91色在线porny| 欧美三级在线视频| 欧美视频精品在线| 欧美喷潮久久久xxxxx| 欧美精品国产精品| 日韩美女在线视频| 欧美精品一区二区三| 久久网站最新地址| 国产精品无遮挡| 亚洲精品视频免费看| 亚洲成av人片观看| 久久精品国产成人一区二区三区| 国产成人自拍网| 91美女精品福利| 欧美日韩国产电影| 欧美亚洲动漫另类| 日韩亚洲欧美综合| 精品成人在线观看| 亚洲欧洲一区二区三区| 亚洲妇熟xx妇色黄| 久热成人在线视频| 成人精品高清在线| 欧美午夜不卡在线观看免费| 欧美一区三区四区| 国产亚洲精品7777| 一区二区视频免费在线观看| 午夜欧美在线一二页| 国产一区二区中文字幕| 91在线视频观看| 日韩一级视频免费观看在线| 中文字幕不卡在线观看| 亚洲女与黑人做爰| 蜜臀精品久久久久久蜜臀| 国产a精品视频| 欧美专区日韩专区| 久久午夜色播影院免费高清| 1000精品久久久久久久久| 亚洲视频精选在线| 亚洲主播在线观看| 国产一区二区三区黄视频| 91网上在线视频| 精品粉嫩aⅴ一区二区三区四区| 一区二区三区在线免费视频|