1 26 package org.objectweb.openccm.explorer.menu; 27 28 29 import javax.swing.JPanel ; 30 import javax.swing.JScrollPane ; 31 import javax.swing.Box ; 32 33 import org.objectweb.util.explorer.api.Entry; 34 import org.objectweb.util.explorer.api.Tree; 35 import org.objectweb.util.explorer.swing.api.Explorer; 36 37 import org.objectweb.fractal.api.Component; 38 import org.objectweb.fractal.api.NoSuchInterfaceException; 39 import org.objectweb.openccm.explorer.CORBA.ConsoleFactory; 40 import org.objectweb.openccm.explorer.menu.TreeDialogSingleton; 41 42 import java.awt.Dimension ; 43 import java.io.File ; 44 45 52 public class BrowserPanel extends JPanel { 53 54 55 protected FileChooserPanel fileChooserPanel_; 56 57 58 protected Component tree_; 59 60 61 protected Tree treeItf_; 62 63 66 public BrowserPanel(String nameFieldLabel, String nameBrowserLabel, int fileFilter) { 67 68 fileChooserPanel_ = new FileChooserPanel(nameFieldLabel, nameBrowserLabel, fileFilter); 69 70 Box b = Box.createVerticalBox(); 71 b.add(Box.createVerticalGlue()); 72 73 b.add(fileChooserPanel_); 74 75 b.add(Box.createVerticalStrut(10)); 76 77 try { 78 tree_ = TreeDialogSingleton.getInstance(); 79 Explorer explorerItf = (Explorer)tree_.getFcInterface(Explorer.EXPLORER); 80 treeItf_ = (Tree)tree_.getFcInterface(Tree.TREE); 81 Box treeBox = Box.createHorizontalBox(); 82 JScrollPane scroll = new JScrollPane (explorerItf.getTree()); 84 scroll.setPreferredSize(new Dimension (350, 150)); 85 treeBox.add(scroll); 86 b.add(treeBox); 87 88 b.add(Box.createVerticalGlue()); 89 90 add(b); 91 } catch (NoSuchInterfaceException e) { 92 ConsoleFactory.getDebugConsole().add(e.getMessage()); 93 } 94 } 95 96 97 public String getLabel() { 98 return fileChooserPanel_.getLabel(); 99 } 100 101 102 public File getFile() { 103 return fileChooserPanel_.getFile(); 104 } 105 106 107 public Object getSelectedObject() { 108 if (tree_ != null) { 109 Entry entry = treeItf_.getSelectedEntry(); 110 if (entry != null) 111 return entry.getValue(); 112 } 113 return null; 114 } 115 116 } 117 | Popular Tags |