Search in sources :

Example 1 with MultiState

use of com.bc.pmpheep.ueditor.define.MultiState in project pmph by BCSquad.

the class FileManager method listFile.

public State listFile(int index) {
    File dir = new File(this.dir);
    State state = null;
    if (!dir.exists()) {
        return new BaseState(false, AppInfo.NOT_EXIST);
    }
    if (!dir.isDirectory()) {
        return new BaseState(false, AppInfo.NOT_DIRECTORY);
    }
    Collection<File> list = FileUtils.listFiles(dir, this.allowFiles, true);
    if (index < 0 || index > list.size()) {
        state = new MultiState(true);
    } else {
        Object[] fileList = Arrays.copyOfRange(list.toArray(), index, index + this.count);
        state = this.getState(fileList);
    }
    state.putInfo("start", index);
    state.putInfo("total", list.size());
    return state;
}
Also used : BaseState(com.bc.pmpheep.ueditor.define.BaseState) BaseState(com.bc.pmpheep.ueditor.define.BaseState) State(com.bc.pmpheep.ueditor.define.State) MultiState(com.bc.pmpheep.ueditor.define.MultiState) MultiState(com.bc.pmpheep.ueditor.define.MultiState) File(java.io.File)

Example 2 with MultiState

use of com.bc.pmpheep.ueditor.define.MultiState in project pmph by BCSquad.

the class FileManager method getState.

private State getState(Object[] files) {
    MultiState state = new MultiState(true);
    BaseState fileState = null;
    File file = null;
    for (Object obj : files) {
        if (obj == null) {
            break;
        }
        file = (File) obj;
        fileState = new BaseState(true);
        fileState.putInfo("url", PathFormat.format(this.getPath(file)));
        state.addState(fileState);
    }
    return state;
}
Also used : BaseState(com.bc.pmpheep.ueditor.define.BaseState) MultiState(com.bc.pmpheep.ueditor.define.MultiState) File(java.io.File)

Aggregations

BaseState (com.bc.pmpheep.ueditor.define.BaseState)2 MultiState (com.bc.pmpheep.ueditor.define.MultiState)2 File (java.io.File)2 State (com.bc.pmpheep.ueditor.define.State)1