| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AdicionarFotos | 
 | 
 | 2.5;2,5 | 
| 1 |  /** | |
| 2 |   * Copyright 2008 WebPhotos | |
| 3 |   * | |
| 4 |   * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 |   * you may not use this file except in compliance with the License. | |
| 6 |   * You may obtain a copy of the License at | |
| 7 |   * | |
| 8 |   *      http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 |   * | |
| 10 |   * Unless required by applicable law or agreed to in writing, software | |
| 11 |   * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 |   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 |   * See the License for the specific language governing permissions and | |
| 14 |   * limitations under the License. | |
| 15 |   */ | |
| 16 |  package net.sf.webphotos.gui; | |
| 17 | ||
| 18 |  import java.io.File; | |
| 19 |  import javax.swing.JComponent; | |
| 20 |  import javax.swing.JFileChooser; | |
| 21 |  import net.sf.webphotos.gui.util.ImageFilter; | |
| 22 | ||
| 23 |  /** | |
| 24 |   * Implementa um menu para seleção de arquivos de imagem. | |
| 25 |   * Não possui utilizações. | |
| 26 |   */ | |
| 27 | public class AdicionarFotos { | |
| 28 | private static JFileChooser fc; | |
| 29 | private static int retornoFc; | |
| 30 | ||
| 31 | 0 |      private AdicionarFotos() { | 
| 32 | 0 |      } | 
| 33 | ||
| 34 |      /** | |
| 35 |       * Retorna um vetor com os arquivos selecionados para inclusão. | |
| 36 |       * Configura o objeto JFileChooser para escolher os arquivos, testa se as imagens são válidas através da classe ImageFilter. | |
| 37 |       * Seta um diretório com parâmetro caminho e retorna os arquivos selecionados. | |
| 38 |       * Não possui utilizações. | |
| 39 |       * @param caminho Caminho do diretório de imagens. | |
| 40 |       * @param pai Componente para busca no opendialog. | |
| 41 |       * @return Retorna uma lista de imagens. | |
| 42 |       */ | |
| 43 | public static File[] getFiles(String caminho, JComponent pai) { | |
| 44 | 0 |          fc=new JFileChooser(); | 
| 45 | 0 |          fc.setAcceptAllFileFilterUsed(false); | 
| 46 | 0 |          fc.setFileFilter(new ImageFilter()); | 
| 47 | 0 |          fc.setDialogTitle("Adicionar fotos ao álbum"); | 
| 48 | 0 |          fc.setApproveButtonText("Ok"); | 
| 49 | 0 |          fc.setApproveButtonToolTipText("Adiciona as fotos selecionadas ao álbum"); | 
| 50 | 0 |          fc.setMultiSelectionEnabled(true); | 
| 51 | ||
| 52 | 0 |          File f=new File(caminho); | 
| 53 | 0 |          if(f.isDirectory()) { | 
| 54 | 0 |              fc.setCurrentDirectory(f); | 
| 55 | } | |
| 56 | ||
| 57 | 0 |          retornoFc=fc.showOpenDialog(pai); | 
| 58 | ||
| 59 | 0 |          if(retornoFc==JFileChooser.APPROVE_OPTION) { | 
| 60 | 0 |                  return fc.getSelectedFiles(); | 
| 61 | 0 |          } else { return null; } | 
| 62 | } | |
| 63 | } |