1 26 27 package org.objectweb.ccm.filetransfer.explorer; 28 29 import java.awt.Component ; 30 import javax.swing.JOptionPane ; 31 import java.io.File ; 32 import java.io.BufferedReader ; 33 import java.io.FileReader ; 34 35 import org.objectweb.ccm.filetransfer.Prog; 36 import org.objectweb.ccm.filetransfer.ProgHome; 37 import org.objectweb.openccm.explorer.menu.OpenCCMBrowserConstants; 38 import org.objectweb.openccm.explorer.menu.JFileChooserSingleton; 39 import org.objectweb.util.explorer.api.MenuItemTreeView; 40 import org.objectweb.util.explorer.api.MenuItem; 41 import org.objectweb.util.explorer.api.TreeView; 42 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 43 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 44 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 45 import org.objectweb.util.explorer.swing.gui.lib.LabelBox; 46 import org.objectweb.util.explorer.swing.gui.lib.FileChooserBox; 47 48 54 public class ProgCreationAction 55 implements MenuItem, DialogAction 56 { 57 58 64 protected FileChooserBox channelDir_; 65 66 protected ProgHome progHome_; 67 68 74 80 86 public int getStatus(TreeView arg0){ 87 return MenuItem.ENABLED_STATUS; 88 } 89 90 public void actionPerformed(MenuItemTreeView e) throws Exception { 91 progHome_ = (ProgHome) e.getSelectedObject(); 92 DialogBox dialogBox = new DefaultDialogBox("Choose a Program directory"); 93 channelDir_ = new FileChooserBox("Dir",JFileChooserSingleton.getInstance(OpenCCMBrowserConstants.DIRECTORY_FILE_CHOOSER)); 94 dialogBox.addElementBox(channelDir_); 95 dialogBox.setValidateAction(this); 96 dialogBox.setValidateLabel("Create"); 97 dialogBox.setCancelLabel("Cancel"); 98 dialogBox.show(); 99 } 100 101 107 110 public void executeAction() throws Exception { 111 File f = channelDir_.getFile(); 112 if (f != null && f.exists()) { 113 String name = f.getName(); 114 Prog p = progHome_.create(); 115 p.the_name(name); 116 } 117 } 118 119 } | Popular Tags |