KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > backup > component > UIImportData


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.backup.component;
6
7 import java.util.* ;
8 import java.io.File JavaDoc ;
9 import org.exoplatform.faces.core.component.*;
10 import org.exoplatform.faces.core.event.*;
11 import org.exoplatform.portlets.backup.component.model.ImportData;
12 import org.exoplatform.services.backup.BackupService;
13
14 /**
15  * @email: tuan08@users.sourceforge.net
16  * @version: $Id: UIImportData.java,v 1.5 2004/09/21 00:16:11 tuan08 Exp $
17  */

18 public class UIImportData extends UIExoCommand {
19   protected String JavaDoc tabTitle_ ;
20   protected BackupService service_ ;
21   protected String JavaDoc directory_ ;
22   protected List importDatas_ ;
23   protected boolean adminRole_ = false ;
24
25   public UIImportData(BackupService service) {
26     setRendererType("ImportDataRenderer") ;
27     service_ = service ;
28   }
29   
30   public String JavaDoc getFamily() {
31     return "org.exoplatform.portlets.backup.component.UIImportData" ;
32   }
33   
34   public boolean hasAdminRole() { return adminRole_ ; }
35   public void setAdminRole(boolean b) { adminRole_ = b ; }
36   
37   BackupService getBackupService() { return service_ ; }
38   
39   public String JavaDoc getDirectory() { return directory_ ; }
40   public void setDirectory(String JavaDoc s) { directory_ = s ; }
41   
42   public List getImportDatas() { return importDatas_ ; }
43   
44   protected void populateImportData() {
45     File JavaDoc dir = new File JavaDoc(directory_) ;
46     File JavaDoc[] jarFiles = dir.listFiles(new JarFileFilter()) ;
47     importDatas_ = new ArrayList(jarFiles.length) ;
48     for(int i = 0; i < jarFiles.length; i++) {
49         importDatas_.add(new ImportData(jarFiles[i])) ;
50     }
51   }
52   
53   static public class RefreshActionListener extends ExoActionListener {
54     public void execute(ExoActionEvent event) throws Exception JavaDoc {
55       UIImportData ui = (UIImportData) event.getComponent() ;
56         ui.populateImportData() ;
57     }
58   }
59   
60   static public class ViewDataActionListener extends ExoActionListener {
61     public void execute(ExoActionEvent event) throws Exception JavaDoc {
62       UIImportData ui = (UIImportData) event.getComponent() ;
63         UINode parent = (UINode) ui.getParent() ;
64         UIData uiData = (UIData) parent.getChildComponentOfType(UIData.class) ;
65         String JavaDoc dataName = event.getParameter("dataName") ;
66         for(int i = 0 ; i < ui.importDatas_.size() ; i++) {
67             ImportData data = (ImportData) ui.importDatas_.get(i) ;
68             if(data.getName().equals(dataName)) {
69                 uiData.setImportDataModel(data) ;
70                 parent.setRenderedComponent(uiData.getId()) ;
71             }
72         }
73     }
74   }
75 }
Popular Tags