1 package org.columba.mail.gui.tree.command; 19 20 import javax.swing.JTree ; 21 import javax.swing.tree.TreeNode ; 22 import javax.swing.tree.TreePath ; 23 24 import org.columba.api.command.ICommandReference; 25 import org.columba.api.command.IWorkerStatusController; 26 import org.columba.core.command.Command; 27 import org.columba.core.command.Worker; 28 import org.columba.mail.command.IMailFolderCommandReference; 29 import org.columba.mail.folder.FolderFactory; 30 import org.columba.mail.folder.IMailFolder; 31 32 36 public class CreateAndSelectSubFolderCommand extends Command { 37 38 private IMailFolder parentFolder; 39 40 private boolean success; 41 42 private JTree tree; 43 44 private IMailFolder childFolder; 45 46 public CreateAndSelectSubFolderCommand(JTree tree, 47 ICommandReference reference) { 48 super(reference); 49 50 success = true; 51 this.tree = tree; 52 } 53 54 57 public void updateGUI() throws Exception { 58 if (success) { 59 62 63 TreeNode [] nodes = childFolder.getPath(); 65 tree.setSelectionPath(new TreePath (nodes)); 66 } 67 } 68 69 72 public void execute(IWorkerStatusController worker) throws Exception { 73 parentFolder = (IMailFolder) ((IMailFolderCommandReference) getReference()) 74 .getSourceFolder(); 75 76 String name = ((IMailFolderCommandReference) getReference()) 77 .getFolderName(); 78 79 try { 80 childFolder = FolderFactory.getInstance().createDefaultChild( 81 parentFolder, name); 82 83 if (childFolder == null) { 86 success = false; 87 } 88 } catch (Exception ex) { 89 success = false; 90 throw ex; 91 } 92 } 93 } | Popular Tags |