Skip to content

Commit

Permalink
fix: fix source dialog chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
briacp committed Jun 5, 2023
1 parent 2304189 commit b58bdeb
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

import java.awt.Cursor;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -82,7 +84,9 @@
import org.omegat.gui.editor.IEditor;
import org.omegat.gui.main.IMainMenu;
import org.omegat.gui.main.IMainWindow;
import org.omegat.util.FileUtil;
import org.omegat.util.Log;
import org.omegat.util.StreamUtil;
import org.omegat.util.TMXProp;
import org.omegat.util.gui.UIThreadsUtil;
import org.openide.awt.Mnemonics;
Expand Down Expand Up @@ -170,7 +174,13 @@ public void onApplicationStartup() {

exportODTReview = new JMenuItem();
Mnemonics.setLocalizedText(exportODTReview, res.getString("odt.menu.export"));
exportODTReview.addActionListener(e -> projectExportODTReview());
exportODTReview.addActionListener(e -> {
try {
projectExportODTReview();
} catch (IOException ex) {
Log.logErrorRB(ex, res.getString("odt.error.export"));
}
});
projectMenu.add(exportODTReview, startMenuIndex++);

importODTReview = new JMenuItem();
Expand All @@ -183,7 +193,7 @@ public void onApplicationStartup() {
onProjectStatusChanged(false);
}

private void projectExportODTReview() {
private void projectExportODTReview() throws IOException {
// Deactivate current segment
UIThreadsUtil.mustBeSwingThread();
Core.getEditor().commitAndDeactivate();
Expand All @@ -199,10 +209,18 @@ private void projectExportODTReview() {
ODTReviewPlugin odtPlugin = new ODTReviewPlugin(currentProject);
File rootDir = props.getProjectRootDir();

// Get the source files (same as
// org.omegat.core.data.RealProject.loadSourceFiles())
File root = new File(props.getSourceRoot());
List<String> srcPathList = FileUtil
.buildRelativeFilesList(root, Collections.emptyList(), props.getSourceRootExcludes())
.stream().sorted(StreamUtil.comparatorByList(currentProject.getSourceFilesOrder()))
.collect(Collectors.toList());

// The file chooser includes a separate panel to select source
// files to include for review
ExportOdtFileChooser efc = new ExportOdtFileChooser(rootDir,
odtPlugin.project.getSourceFilesOrder(), res.getString("odt.chooser.export"));
ExportOdtFileChooser efc = new ExportOdtFileChooser(rootDir, srcPathList,
res.getString("odt.chooser.export"));
efc.setSelectedFile(new File(defaultFilename));
int efcResult = efc.showSaveDialog(Core.getMainWindow().getApplicationFrame());
if (efcResult != JFileChooser.APPROVE_OPTION) {
Expand Down

0 comments on commit b58bdeb

Please sign in to comment.