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.SharedFolderPlugin; 24 25 import javax.swing.*; 26 import java.awt.event.ActionEvent ; 27 28 public class CreateFolderAction extends PerformableAction 29 { 30 private SharedFolderPlugin plugin; 31 private JTable table; 32 private boolean history; 33 34 public CreateFolderAction(SharedFolderPlugin plugin, JTable table, boolean history) 35 { 36 this.plugin = plugin; 37 this.table = table; 38 this.history = history; 39 40 putValue(Action.SMALL_ICON, plugin.getImageIcon("actions/createfolder.png")); 41 putValue(Action.SHORT_DESCRIPTION, plugin.tr("tip.createFolder")); 42 } 43 44 public boolean isPerformable() 45 { 46 FolderTableModel model = (FolderTableModel)table.getModel(); 47 return !history && model.getCurrentFolder().isWritable(); 48 } 49 50 public void actionPerformed(ActionEvent ae) 51 { 52 if(!isPerformable()) 53 return; 54 55 FolderTableModel model = (FolderTableModel)table.getModel(); 56 String name = DialogBox.input(plugin.tr("tip.createFolder"), plugin.tr("msg.enterFolderName")); 57 if(name == null || name.length() == 0) 58 return; 59 60 try { 61 plugin.createFolder(model.getCurrentFolder().getId(), name); 62 new RefreshAction(plugin, table, history).actionPerformed(ae); 63 } catch(Exception e) { 64 DialogBox.error(e.getMessage()); 65 e.printStackTrace(); 66 } 67 } 68 } | Popular Tags |