1 19 package org.lucane.applications.sharedfolder.gui.actions; 20 21 import org.lucane.client.widgets.DialogBox; 22 import org.lucane.applications.sharedfolder.gui.FolderTableModel; 23 import org.lucane.applications.sharedfolder.model.FolderInfo; 24 import org.lucane.applications.sharedfolder.SharedFolderPlugin; 25 26 import javax.swing.*; 27 import java.awt.event.ActionEvent ; 28 import java.util.ArrayList ; 29 30 public class RefreshAction extends PerformableAction 31 { 32 private SharedFolderPlugin plugin; 33 private JTable table; 34 private boolean history; 35 36 public RefreshAction(SharedFolderPlugin plugin, JTable table, boolean history) 37 { 38 this.plugin = plugin; 39 this.table = table; 40 this.history = history; 41 42 putValue(Action.SMALL_ICON, plugin.getImageIcon("actions/refresh.png")); 43 putValue(Action.SHORT_DESCRIPTION, plugin.tr("tip.refresh")); 44 } 45 46 public boolean isPerformable() 47 { 48 return !history; 49 } 50 51 public void actionPerformed(ActionEvent ae) 52 { 53 FolderTableModel model = (FolderTableModel)table.getModel(); 54 FolderInfo current = model.getCurrentFolder(); 55 56 ArrayList items = new ArrayList (); 57 try { 58 items.addAll(plugin.listFolders(current.getId())); 59 items.addAll(plugin.listFiles(current.getId())); 60 model.setItems(plugin.getFolder(current.getId()), items); 61 } catch(Exception e) { 62 DialogBox.error(e.getMessage()); 63 e.printStackTrace(); 64 } 65 66 } 67 } | Popular Tags |