1 19 package org.lucane.applications.sharedfolder.gui.actions; 20 21 import org.lucane.client.Client; 22 import org.lucane.client.widgets.DialogBox; 23 import org.lucane.client.acl.AclEditor; 24 import org.lucane.applications.sharedfolder.gui.FolderTableModel; 25 import org.lucane.applications.sharedfolder.model.SharedItem; 26 import org.lucane.applications.sharedfolder.SharedFolderPlugin; 27 28 import javax.swing.*; 29 import java.awt.event.ActionEvent ; 30 31 public class EditAclAction extends PerformableAction 32 { 33 private boolean history; 34 private SharedFolderPlugin plugin; 35 private JTable table; 36 37 public EditAclAction(SharedFolderPlugin plugin, JTable table, boolean history) 38 { 39 this.plugin = plugin; 40 this.table = table; 41 this.history = history; 42 43 putValue(Action.SMALL_ICON, plugin.getImageIcon("actions/editacl.png")); 44 putValue(Action.SHORT_DESCRIPTION, plugin.tr("tip.editAcl")); 45 } 46 47 public boolean isPerformable() 48 { 49 int row = table.getSelectedRow(); 50 if(row < 0 || history) 51 return false; 52 53 FolderTableModel model = (FolderTableModel)table.getModel(); 54 String user = Client.getInstance().getMyInfos().getName(); 55 return model.getItemAt(row).getOwner().equals(user); 56 } 57 58 public void actionPerformed(ActionEvent ae) 59 { 60 if(!isPerformable()) 61 return; 62 63 int row = table.getSelectedRow(); 64 FolderTableModel model = (FolderTableModel)table.getModel(); 65 SharedItem item = model.getItemAt(row); 66 67 try { 68 new AclEditor(plugin, plugin, getAclId(item)).show(); 69 } catch(Exception e) { 70 DialogBox.error(plugin.tr("err.unableToEditAcl")); 71 e.printStackTrace(); 72 } 73 } 74 75 private String getAclId(SharedItem item) 76 { 77 return (item.isFolder() ? "f" : "") + item.getId(); 78 } 79 } | Popular Tags |