List of usage examples for org.apache.commons.io.filefilter TrueFileFilter INSTANCE
IOFileFilter INSTANCE
To view the source code for org.apache.commons.io.filefilter TrueFileFilter INSTANCE.
Click Source Link
From source file:io.github.jeremgamer.editor.panels.Others.java
public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from ww w . j a va2 s . c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList), "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new OtherSave(name); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (otherList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList), "tes-vous sr de vouloir supprimer ce composant?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } OtherSave os = new OtherSave(); try { os.load(file); } catch (IOException e1) { e1.printStackTrace(); } String type = null; switch (os.getInt("type")) { case 0: type = "Zone de saisie"; break; case 1: type = "Zone de saisie de mot de passe"; break; case 2: type = "Zone de saisie (Grande)"; break; case 3: type = "Case cocher"; break; case 4: type = "Menu droulant"; break; case 5: type = "Barre de progression"; break; case 6: type = "Slider"; break; case 7: type = "Spinner"; break; } for (String section : ps.getSectionsContaining( otherList.getSelectedValue() + " (" + type + ")")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (otherList.getSelectedValue().equals(op.getFileName())) { op.setFileName(""); } op.hide(); file.delete(); data.remove(otherList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); otherList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(otherList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:net.sf.jvifm.ui.Util.java
public static IOFileFilter getDefaultFileFilter() { IOFileFilter filter;//from w w w.j ava 2s. c om Preference preference = Preference.getInstance(); if (preference.isShowHide()) { filter = TrueFileFilter.INSTANCE; } else { filter = HiddenFileFilter.VISIBLE; } return filter; }
From source file:de.uzk.hki.da.model.Package.java
/** * Scans folder recursively and generates dafiles for * each file. sets the path of the file to baseName. * * @param repName the rep name/*from ww w .ja v a 2s .c o m*/ * @return the list */ public List<DAFile> scanRepRecursively(Path dataPath, String repName) { String repFolderPath = Path.make(dataPath, repName).toString(); if (!new File(repFolderPath).exists()) throw new IllegalArgumentException(repFolderPath + " does not exist"); logger.debug("scanning " + repFolderPath); Collection<File> found = FileUtils.listFiles(new File(repFolderPath), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); List<DAFile> result = new ArrayList<DAFile>(); int offset = repFolderPath.length(); for (File f : found) { DAFile newFile = new DAFile(repName, f.getPath().substring(offset + 1, f.getPath().length())); logger.debug("found: " + newFile.toString()); result.add(newFile); this.getFiles().add(newFile); } return result; }
From source file:com.bbytes.jfilesync.sync.FileMonitor.java
/** * Scan the entire source folder and send the lsit of files with checksum . if checksum is * different on client side then these files are replaced by client *///from w w w . j a v a2s .com public void syncFullDirsAndFiles() { Collection<File> allFiles = FileUtils.listFilesAndDirs(new File(sourceFolderToMonitor), TrueFileFilter.INSTANCE, DirectoryFileFilter.INSTANCE); for (File file : allFiles) { fileModified(file, FileMessageType.DIRECTORY_STRUCTURE_SYNC, file.isDirectory()); } }
From source file:io.github.jeremgamer.editor.panels.Panels.java
public Panels(final JFrame frame, final PanelsPanel pp) { this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from w w w . j av a 2 s . c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(panelList), "Nommez le panneau :", "Crer un panneau", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new PanelSave(name); PanelsPanel.updateLists(); mainPanel.addItem(name); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (panelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/panels/" + panelList.getSelectedValue() + "/" + panelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(panelList), "tes-vous sr de vouloir supprimer ce panneau?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (panelList.getSelectedValue().equals(pp.getFileName())) { pp.setFileName(""); } pp.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); mainPanel.removeItem(panelList.getSelectedValue()); data.remove(panelList.getSelectedIndex()); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); mainPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); GeneralSave gs = new GeneralSave(); try { gs.load(new File("projects/" + Editor.getProjectName() + "/general.rbd")); gs.set("mainPanel", combo.getSelectedItem()); } catch (IOException e) { e.printStackTrace(); } } }); updateList(); panelList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(panelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); JPanel mainPanelInput = new JPanel(); mainPanelInput.setPreferredSize(new Dimension(280, 35)); mainPanelInput.setMaximumSize(new Dimension(280, 35)); mainPanelInput.add(new JLabel("Panneau principal:")); mainPanel.setPreferredSize(new Dimension(150, 27)); mainPanelInput.add(mainPanel); this.add(mainPanelInput); }
From source file:de.egore911.versioning.deployer.performer.PerformReplacement.java
private static void perform(File directory, List<String> wildcards, List<ReplacementPair> replacements) { if (!directory.exists()) { LOG.error("Directory {} does not exist", directory); return;/*w w w . j a v a 2s .c om*/ } if (!directory.isDirectory()) { LOG.error("{} is not a directory", directory); return; } IOFileFilter fileFilter = new WildcardFileFilter(wildcards); Collection<File> files = FileUtils.listFiles(directory, fileFilter, TrueFileFilter.INSTANCE); for (File file : files) { try { String content = FileUtils.readFileToString(file); for (ReplacementPair replacement : replacements) { content = content.replace("${versioning:" + replacement.variable + "}", replacement.value); } FileUtils.write(file, content); } catch (IOException e) { LOG.error(e.getMessage(), e); } } }
From source file:ch.admin.suis.msghandler.signer.SignerTest.java
public void testSigningWithOneOutbox() throws SignerException, IOException, ConfigurationException { initialize();// www . j av a2 s . c o m System.out.println("testSigningWithOneOutbox"); SigningOutbox signOutbox = new SigningOutboxMHCfg(p12File, "12345678", signingOutbox1, signatureProperties, null); final File workingDir = createWorkingDir(); final File corruptedDir = new File(workingDir, ClientCommons.CORRUPTED_DIR); Signer signer = new Signer(signOutbox, workingDir, corruptedDir); List<File> signedFiles = signer.sign(); signedFiles.forEach((f) -> { f.deleteOnExit(); }); assertEquals(signOutbox.getAllPDFsToSign().size(), signedFiles.size()); assertEquals(signedFiles, signOutbox.getAllPDFsToSign()); signer.cleanUp(signedFiles); assertEquals(0, signOutbox.getAllPDFsToSign().size()); // The corrupted directory must be empty assert FileUtils.listFiles(corruptedDir, TrueFileFilter.INSTANCE, null).isEmpty(); }
From source file:com.siemens.scr.avt.ad.io.AnnotationBatchLoader.java
private void parseSegDicomFromDirectroy(File directory) throws IOException { Iterator<File> fileIterator = FileUtils.iterateFiles(directory, new SuffixFileFilter(".dcm"), TrueFileFilter.INSTANCE); while (fileIterator.hasNext()) { File file = fileIterator.next(); DicomObject dob = DicomParser.read(file); if (dob == null) continue; String dicomUID = dob.getString(Tag.MediaStorageSOPInstanceUID); sopInstanceUID2URL.put(dicomUID, file); }/* w ww . j a v a 2s. c o m*/ }
From source file:com.btoddb.fastpersitentqueue.InMemorySegmentMgrTest.java
@Test public void testShutdown() throws Exception { mgr.init();/* ww w . j av a 2 s .c o m*/ for (int i = 0; i < numEntries; i++) { mgr.push(new FpqEntry(idGen.incrementAndGet(), String.format( "%02d-3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i).getBytes())); } mgr.shutdown(); assertThat(mgr.getSegments(), is(empty())); assertThat(mgr.getNumberOfActiveSegments(), is(0)); assertThat(mgr.getNumberOfEntries(), is(0L)); assertThat(FileUtils.listFiles(theDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE), hasSize(5)); }
From source file:com.przyjaznyplan.utils.CsvConverter.java
private void ifTextGetIt(String value, ContentValues sqlValues) { if (value != null && value.endsWith(TXT_EXT)) { Collection files = FileUtils.listFiles(new File(rootFolder), new NameFileFilter(value), TrueFileFilter.INSTANCE); Iterator<File> iterator = files.iterator(); if (iterator.hasNext()) { File f = iterator.next(); List<String> linesOfText = null; try { linesOfText = FileUtils.readLines(f); } catch (IOException e) { Log.e("File IO", e.getMessage()); }//from w ww . jav a 2 s . co m StringBuilder builder = new StringBuilder(); if (linesOfText != null) { for (String line : linesOfText) { builder.append(line); } } sqlValues.put(Czynnosc.TEXT, builder.toString()); } } else if (value != null && value.length() > 0) { sqlValues.put(Czynnosc.TEXT, value); } }