public void actionPerformed(ActionEvent e) { try { FileUtils.showFile(new File(physicalURI)); } catch (IOException ex) { logger.error("An error occurred when attempting to show a file in the operating system.", ex); } } }
/** * Copies a file to the specified directory. * @param file The file to be copied. * @param directory The directory the file should be copied to. */ public static void copyFileToDirectory(File file, File directory) throws IOException { copyFile(file, directory); }
public static void deleteRecursively(File file) { if (file.isDirectory()){ File[] files = file.listFiles(); if (files != null) { for(File f : files){ deleteRecursively(f); } } } file.delete(); }
/** * Attempts to show a File using the native operating * system file view, for example the Finder on a Mac, * or Explorer on Windows. This may not work on all * platforms. * @param file The file to be shown */ public static void showFile(File file) throws IOException { if (System.getProperty("os.name").indexOf("Mac") != -1) { showInFinder(file); } else if (System.getProperty("os.name").indexOf("Windows") != -1) { showInExplorer(file); } else { logger.debug("showFile not implemented for " + System.getProperty("os.name")); } }
FileUtils.copyFileToDirectory(pluginFile, newPluginFile); if (oldPluginFile != null && oldPluginFile.exists()){ FileUtils.deleteRecursively(oldPluginFile);
private static Optional<File> copyPluginToInstallLocation(File downloadedPlugin, PluginInfo info) throws URISyntaxException { final Optional<File> backupFileName = moveExistingPluginToBackupLocation(info); final File pluginsFolder = new File(System.getProperty(ProtegeApplication.BUNDLE_DIR_PROP)); final String destinationFileName = String.format("%s-%s.jar", info.getId(), info.getAvailableVersion()); final File downloadedPluginDestination = new File(pluginsFolder, destinationFileName); try { FileUtils.copyFile(downloadedPlugin, downloadedPluginDestination); logger.info("Copied the {} plugin to {} in the plugins directory", info.getLabel(), downloadedPluginDestination.getName()); deletePluginBackup(backupFileName); return Optional.of(downloadedPluginDestination); } catch (IOException e) { try { File userPluginDirectory = ProtegeDirectories.getUserPluginDirectory(); logger.info("Could not copy the plugin to Protege plugins directory: {}", e.getMessage()); File userDirectoryPluginFile = new File(userPluginDirectory, info.getId() + ".jar"); FileUtils.copyFileToDirectory(downloadedPlugin, userDirectoryPluginFile); logger.info("Copied the {} plugin to the user plugin directory at {}. " + "This plugin will only be use-able by the current user.", info.getLabel(), userPluginDirectory); deletePluginBackup(backupFileName); return Optional.of(userDirectoryPluginFile); } catch (IOException ioe) { logger.error("An error occurred whilst attempting to save the plugin: {}", ioe.getMessage(), ioe); return Optional.empty(); } } }
public static void showErrorMessage(String title, String message) { int ret = JOptionPane.showOptionDialog( null, "<html><body>" + "<div style=\"font-weight: bold; padding-bottom: 10px;\">" + message + "</div>" + "<div>" + "Please check the protege.log file in the logs directory for details." + "</div>" + "</body></html>", title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, new Object[]{VIEW_LOG, OK}, OK ); if(ret != 0) { return; } FileUtils.showLogFile(); } }
/** * Attempts to show a File using the native operating * system file view, for example the Finder on a Mac, * or Explorer on Windows. This may not work on all * platforms. * @param file The file to be shown */ public static void showFile(File file) throws IOException { if (System.getProperty("os.name").contains("Mac")) { showInFinder(file); } else if (System.getProperty("os.name").contains("Windows")) { showInExplorer(file); } else { logger.debug("showFile not implemented for " + System.getProperty("os.name")); } }
FileUtils.copyFileToDirectory(pluginFile, newPluginFile); newPluginFile = new File(CommonProtegeProperties.getUserPluginDirectory(), info.getId() + ".jar"); try { FileUtils.copyFileToDirectory(pluginFile, newPluginFile); logger.info("Save of plugin to user plugin directory succeeded"); logger.info("Update only seen by invoking user"); FileUtils.deleteRecursively(oldPluginFile);
JButton showLogFile = new JButton("Show log file"); showLogFile.setToolTipText("Show the log file in the system file browser"); showLogFile.addActionListener(e -> FileUtils.showLogFile()); JButton preferencesButton = new JButton("Preferences"); preferencesButton.addActionListener(e -> showPreferences());
@Override public void activate(Component component, MouseEvent event) { try { FileUtils.showFile(file); } catch (IOException e) { logger.error("Could not activate file link.", e.getMessage(), e); } }
/** * Attempts to show a File using the native operating * system file view, for example the Finder on a Mac, * or Explorer on Windows. This may not work on all * platforms. * @param file The file to be shown */ public static void showFile(File file) throws IOException { if (System.getProperty("os.name").indexOf("Mac") != -1) { showInFinder(file); } else if (System.getProperty("os.name").indexOf("Windows") != -1) { showInExplorer(file); } else { logger.debug("showFile not implemented for " + System.getProperty("os.name")); } }
public static void deleteRecursively(File file) { if (file.isDirectory()){ for(File f : file.listFiles()){ deleteRecursively(f); } } file.delete(); }
/** * Copies a file to the specified directory. * @param file The file to be copied. * @param directory The directory the file should be copied to. */ public static void copyFileToDirectory(File file, File directory) throws IOException { copyFile(file, directory); }
public void actionPerformed(ActionEvent e) { try { FileUtils.showFile(new File(physicalURI)); } catch (IOException ex) { logger.error("An error occurred when attempting to show a file in the operating system.", ex); } } }
public static void deleteRecursively(File file) { if (file.isDirectory()){ for(File f : file.listFiles()){ deleteRecursively(f); } } file.delete(); }
/** * Copies a file to the specified directory. * @param file The file to be copied. * @param directory The directory the file should be copied to. */ public static void copyFileToDirectory(File file, File directory) throws IOException { copyFile(file, directory); }
public void actionPerformed(ActionEvent e) { try { FileUtils.showFile(new File(physicalURI)); } catch (IOException ex) { logger.error(ex); } } }
private static void deletePluginBackup(Optional<File> existingPluginLocation) { if (existingPluginLocation.isPresent() && existingPluginLocation.get().exists()) { FileUtils.deleteRecursively(existingPluginLocation.get()); } }
public void actionPerformed(ActionEvent e) { try { FileUtils.showFile(new File(physicalURI)); } catch (IOException ex) { logger.error(ex); } } }