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 OpenParentAction extends PerformableAction 31 { 32 private SharedFolderPlugin plugin; 33 private JTable table; 34 private boolean history; 35 36 public OpenParentAction(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/openparent.png")); 43 putValue(Action.SHORT_DESCRIPTION, plugin.tr("tip.openParent")); 44 } 45 46 public boolean isPerformable() 47 { 48 FolderTableModel model = (FolderTableModel)table.getModel(); 49 FolderInfo current = model.getCurrentFolder(); 50 if(history || current == null || current.getId() == FolderInfo.ROOT_ID) 51 return false; 52 53 return true; 54 } 55 56 public void actionPerformed(ActionEvent ae) 57 { 58 if(!isPerformable()) 59 return; 60 61 FolderTableModel model = (FolderTableModel)table.getModel(); 62 FolderInfo current = model.getCurrentFolder(); 63 64 ArrayList items = new ArrayList (); 65 try { 66 items.addAll(plugin.listFolders(current.getParentId())); 67 items.addAll(plugin.listFiles(current.getParentId())); 68 model.setItems(plugin.getFolder(current.getParentId()), items); 69 } catch(Exception e) { 70 DialogBox.error(e.getMessage()); 71 e.printStackTrace(); 72 } 73 74 } 75 } | Popular Tags |