コード例 #1
0
 private static void saveIgnoreWords(Collection<String> words, File outFile) {
   try {
     File outFileTmp = new File(outFile.getPath() + ".new");
     Files.write(outFileTmp.toPath(), words);
     outFile.delete();
     FileUtil.rename(outFileTmp, outFile);
   } catch (IOException ex) {
     Log.log("Error saving ignore words");
     Log.log(ex);
   }
 }
コード例 #2
0
  public void editExportSelectionMenuItemActionPerformed() {
    if (!Core.getProject().isProjectLoaded()) return;

    String selection = Core.getEditor().getSelectedText();
    if (selection == null) {
      SourceTextEntry ste = Core.getEditor().getCurrentEntry();
      TMXEntry te = Core.getProject().getTranslationInfo(ste);
      if (te.isTranslated()) {
        selection = te.translation;
      } else {
        selection = ste.getSrcText();
      }
    }

    FileUtil.writeScriptFile(selection, OConsts.SELECTION_EXPORT);
  }
コード例 #3
0
  /**
   * Copy the specified files to the specified destination, then reload if indicated. Note that a
   * modal dialog will be shown if any of the specified files would be overwritten.
   *
   * @param destination The path to copy the files to
   * @param toImport Files to copy to destination path
   * @param doReload If true, the project will be reloaded after the files are successfully copied
   */
  public static void projectImportFiles(String destination, File[] toImport, boolean doReload) {
    UIThreadsUtil.mustBeSwingThread();

    if (!Core.getProject().isProjectLoaded()) {
      return;
    }

    // commit the current entry first
    Core.getEditor().commitAndLeave();

    try {
      FileUtil.copyFilesTo(new File(destination), toImport, new CollisionCallback());
      if (doReload) {
        projectReload();
      }
    } catch (IOException ioe) {
      Core.getMainWindow().displayErrorRB(ioe, "MAIN_ERROR_File_Import_Failed");
    }
  }
コード例 #4
0
 /** Empties the exported segments. */
 private void flushExportedSegments() {
   FileUtil.writeScriptFile("", OConsts.SOURCE_EXPORT);
   FileUtil.writeScriptFile("", OConsts.TARGET_EXPORT);
 }