Code Search for Developers
 
 
  

LocalBean.java from GridBlocks at Krugle


Show LocalBean.java syntax highlighted

/*
 * Copyright (c) 2005 
 * Helsinki Institute of Physics
 * see LICENSE file for details
 * 
 * Created on Nov 1, 2005
 * LocalBean.java
 */
package fi.hip.gb.portlet.disk;

import java.util.ArrayList;
import java.util.List;

import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;

import fi.hip.gb.disk.FileManager;
import fi.hip.gb.disk.info.LocalInfoBean;

/**
 * Bean for local file management.
 * 
 * @author Juho Karppinen
 * @version $Id: LocalBean.java 1076 2006-06-07 13:55:21Z jkarppin $
 */
public class LocalBean {
    private HtmlDataTable dataTable;
    
    /**
     * Gets all local files
     * @return
     */
    public ArrayList<LocalInfoBean> getFiles() {
        ArrayList<LocalInfoBean> al = new ArrayList<LocalInfoBean>();
        LocalInfoBean[] files  = FileManager.files();
        for (int i = 0; i < files.length; i++) {
            al.add(files[i]);
        }
        return al;
    }
    
    
    public void setDataTable(HtmlDataTable dataTable) {
        this.dataTable = dataTable;
    }
    public HtmlDataTable getDataTable() {
        return this.dataTable;
    }
    
    /**
     * Action to show status of the local file
     * @param event action event
     */
    public void showStatus(ActionEvent event) {
        LocalInfoBean file = (LocalInfoBean)this.getDataTable().getRowData();

        System.out.println("local status of " + file.getFileInfo().getFileName());
        
        /* Pre-seed the managed bean */
        FacesContext ctx       = FacesContext.getCurrentInstance();
        ValueBinding binding   = ctx.getApplication().createValueBinding("#{selectedFile}");
        binding.setValue(ctx, file);
    }
    
    /**
     * Action to clear the local file
     */
    public void clearLocal() {
        System.out.println("clear");
        /* Pull out the currently selected contact */
        LocalInfoBean file    = (LocalInfoBean)this.getDataTable().getRowData();
        FileManager.clearFile(file.getLocalFile());
        System.out.println("Clearing: " + file.getFileInfo().getFileName());
    }
    
    /**
     * Action to clear all finished files from portal machine.
     */
    public void clearFinished() {
        FileManager.clearFinished();
    }
}




See more files for this project here

GridBlocks

GridBlocks builds a grid application framework via easy-to-use building blocks in distributed environment. The framework offers components for Grid security, distributed storage, computing, and Portlet web interfaces.

Project homepage: http://sourceforge.net/projects/gridblocks
Programming language(s): Java,JSP,XML
License: other

  GlobalBean.java
  LocalBean.java
  UploadPortlet.java