1 5 package org.exoplatform.portlets.backup.component; 6 7 import java.util.* ; 8 import java.io.File ; 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 18 public class UIImportData extends UIExoCommand { 19 protected String tabTitle_ ; 20 protected BackupService service_ ; 21 protected String 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 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 getDirectory() { return directory_ ; } 40 public void setDirectory(String s) { directory_ = s ; } 41 42 public List getImportDatas() { return importDatas_ ; } 43 44 protected void populateImportData() { 45 File dir = new File (directory_) ; 46 File [] 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 { 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 { 62 UIImportData ui = (UIImportData) event.getComponent() ; 63 UINode parent = (UINode) ui.getParent() ; 64 UIData uiData = (UIData) parent.getChildComponentOfType(UIData.class) ; 65 String 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 |