private String getDirectory(String _default) { String r=FuLib.expandedPath(_default); // System.err.println("### FD begin"); BuFileChooser chooser=new BuFileChooser(); chooser.setDialogTitle(getS("Repertoire")); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(false); chooser.resetChoosableFileFilters(); File f=new File(r); if(f.exists()) chooser.setCurrentDirectory(f); int returnVal=chooser.showDialog(this,getS("Slectionner")); // System.err.println("### FD end"); if(returnVal == JFileChooser.APPROVE_OPTION) { f=chooser.getSelectedFile(); // System.err.println("### f="+f); if(f!=null) r=f.getPath(); } return FuLib.reducedPath(r); } }
private String popFileChooser() { final BuFileChooser chooser = new CtuluFileChooser(false); if (filtre_ != null) { chooser.setFileFilter(filtre_); } if (dirOpen_ == null) { dirOpen_ = System.getProperty("user.dir") + File.separator + "exemples"; } if (dirOpen_ != null) { chooser.setCurrentDirectory(new File(dirOpen_)); } final int returnVal = chooser.showOpenDialog(this); dirOpen_ = chooser.getCurrentDirectory().getAbsolutePath(); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getAbsolutePath(); } return filename; } }
/** * Display a file chooser dialog box. * * @param owner <code>Component</code> which 'owns' the dialog * @param mode Can be either <code>LOAD</code> or <code>SAVE</code> * @return The path to selected file, null otherwise */ public static String chooseFile(Component owner, int mode) { BuFileChooser chooser = new BuFileChooser(); if (mode == OPEN) chooser.setDialogType(JFileChooser.OPEN_DIALOG); else if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) return chooser.getSelectedFile() .getAbsolutePath(); return null; }
public BuFileChooser() { super(); setDialogTitle(BuResource.BU.getString("Fichier")); Dimension e=getToolkit().getScreenSize(); setPreferredSize(new Dimension(Math.min(480,e.width-60), Math.max(480,e.height-360))); }
BuFileChooser chooser = new BuFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(true); chooser.resetChoosableFileFilters(); if (openDirectory_ != null) chooser.setCurrentDirectory(openDirectory_); chooser.setFileFilter(DjaLoadSaveLib.get(EXTENSIONS[0]).getFilter()); if ((lsi != null) && lsi.canLoad()) chooser.addChoosableFileFilter(lsi.getFilter()); int returnVal = chooser.showOpenDialog((BuApplication) getApp()); File f = chooser.getSelectedFile(); File[] files = chooser.getSelectedFiles();
BuFileChooser chooser = new BuFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(false); chooser.resetChoosableFileFilters(); if (saveDirectory_ != null) chooser.setCurrentDirectory(saveDirectory_); chooser.setFileFilter(DjaLoadSaveLib.get(EXTENSIONS[0]).getFilter()); if ((lsi != null) && lsi.canSave()) chooser.addChoosableFileFilter(lsi.getFilter()); chooser.setSelectedFile(new File(r)); int returnVal = chooser.showSaveDialog((BuApplication) getApp()); if (returnVal == JFileChooser.APPROVE_OPTION) { saveDirectory_ = chooser.getSelectedFile();
bfc_ = new CtuluFileChooser(false); bfc_.setFileSelectionMode(fileChooserSelectionMode_); bfc_.setMultiSelectionEnabled(multipleSelection_); if ((baseDir_ == null) || (value_ == null)) { if (value_ != null) { final File f = new File(value_); if (f.isAbsolute()) { bfc_.setSelectedFile(f); bfc_.setCurrentDirectory(CtuluLibFile.getAbsolutePath(baseDir_, value_).getParentFile()); final int r = bfc_.showOpenDialog(CtuluCellFileEditor.this); if (r == JFileChooser.APPROVE_OPTION) { if (onlyName_) { setValue(bfc_.getSelectedFile().getName()); } else if (baseDir_ == null) { setValue(bfc_.getSelectedFile().getAbsolutePath()); setValue(CtuluLibFile.getRelativeFile(bfc_.getSelectedFile(), baseDir_, 3));
public void actionPerformed(final ActionEvent _ae) { final BuFileChooser bf = new CtuluFileChooser(false); if (iconURL_ == null) { bf.setCurrentDirectory(CtuluFavoriteFiles.getLastDir()); } else { bf.setCurrentDirectory(FuLib.getParentFile(new File(iconURL_))); } bf.setDialogTitle((fudaaExec_ == null ? CtuluLibString.EMPTY_STRING : fudaaExec_.getViewedName()) + s + BuResource.BU.getString("Icne")); bf.setMultiSelectionEnabled(false); final int r = bf.showOpenDialog(FudaaExecPanel.this); if (r == JFileChooser.APPROVE_OPTION) { setIconUrl(bf.getSelectedFile().getAbsolutePath()); } } });
/** * Methode qui sauvegarde le fichier en cours de lecture sur l'emplacement voulu. */ public void sauvegarderFichierPdf(){ JarEntry fichierJar=getCurrentJarEntry(); if(fichierJar==null) return; File fichierDest=null; BuFileChooser chooser=new BuFileChooser(); int rep=chooser.showOpenDialog(ui_.getParentComponent()); if(rep==BuFileChooser.APPROVE_OPTION){ fichierDest=chooser.getSelectedFile(); } if(fichierDest!=null){ generateFileFromJar(fichierJar, fichierDest); } }
chooser.setFileFilter(filtre_); final int returnVal = chooser.showOpenDialog(parent); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getAbsolutePath(); if ((filename != null)) {
public static void main(String[] _args) { BuFileChooser p=new BuFileChooser(System.getProperty("user.dir")); p.setDragEnabled(true); p.setControlButtonsAreShown(false); if(p.getBorder() instanceof EmptyBorder) p.setBorder(BuLib.getEmptyBorder(5)); JFrame f=new JFrame("File Chooser"); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(p); f.pack(); f.show(); } }
/** * @deprecated */ public BuFileChooser(File _file) { this(); setCurrentDirectory(_file); }
/** * Display a file chooser dialog box. * @param owner <code>Component</code> which 'owns' the dialog * @param mode Can be either <code>LOAD</code> or <code>SAVE</code> * @return The path to selected file, null otherwise */ public static String chooseFile(Component owner, int mode) { BuFileChooser chooser = new BuFileChooser(); if (mode == OPEN) chooser.setDialogType(JFileChooser.OPEN_DIALOG); else if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) return chooser.getSelectedFile().getAbsolutePath(); return null; }
/** * Verifie que le chemin saisi contient bien un jar sinon demande correction a l'utilisateur. * @param pathPresumePourJar * @return */ public String verifPathForJarIsCorrect(String pathPresumePourJar){ File test=new File(pathPresumePourJar); if(test==null || !test.exists() || test.isDirectory()){ ui_.error(FudaaResource.FUDAA.getString("Erreur, Il n'y a pas de fichier jar de document l'adresse suivante: "+pathPresumePourJar)); BuFileChooser chooser=new BuFileChooser(); int rep=chooser.showOpenDialog(ui_.getParentComponent()); if(rep==BuFileChooser.APPROVE_OPTION){ pathPresumePourJar=chooser.getSelectedFile().getAbsolutePath(); } } return pathPresumePourJar; }
public synchronized void ouvrir() { Frame parent = null; if (appli_ instanceof Frame) { parent = (Frame) appli_; } final BuFileChooser chooser = new CtuluFileChooser(true); chooser.setFileFilter(filtre_); // if (dirOpen_ == null) // dirOpen_= System.getProperty("user.dir") + File.separator + "exemples"; // if (dirOpen_ != null) // chooser.setCurrentDirectory(new File(dirOpen_)); final int returnVal = chooser.showOpenDialog(parent); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getAbsolutePath(); if ((filename != null)) { // dirOpen_= new File(filename).getAbsolutePath(); // dirOpen_= // dirOpen_.substring(0, dirOpen_.lastIndexOf(File.separatorChar)); actualiseMenu(IN_DISABLE, OUT_ENABLE); ouvre(filename); fireStatusChanged(new FudaaProjetEvent(this, FudaaProjetEvent.PROJECT_OPENED)); } } }
private String getDirectory(String _default) { String r=FuLib.expandedPath(_default); // System.err.println("### FD begin"); BuFileChooser chooser=new BuFileChooser(); chooser.setDialogTitle(getS("Repertoire")); chooser.setFileSelectionMode(BuFileChooser.DIRECTORIES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(false); chooser.resetChoosableFileFilters(); File f=new File(r); if(f.exists()) chooser.setCurrentDirectory(f); int returnVal=chooser.showDialog(this,getS("Slectionner")); // System.err.println("### FD end"); if(returnVal == BuFileChooser.APPROVE_OPTION) { f=chooser.getSelectedFile(); // System.err.println("### f="+f); if(f!=null) r=f.getPath(); } return FuLib.reducedPath(r); } }