From 505fbd23cde95a4cb98ff4a60c17875b011fd580 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Wed, 4 Aug 2021 20:30:51 +0200 Subject: [PATCH] chore: refactored gui classes --- .../pro/litvinovg/w2phtml/gui/BasePanel.java | 256 ++++ .../w2phtml/gui/ConfigurationWindow.java | 1167 +---------------- .../litvinovg/w2phtml/gui/ControlPanel.java | 84 ++ .../pro/litvinovg/w2phtml/gui/Contstants.java | 91 ++ .../pro/litvinovg/w2phtml/gui/EpubPanel.java | 213 +++ .../pro/litvinovg/w2phtml/gui/HTMLPanel.java | 238 ++++ .../litvinovg/w2phtml/gui/PanelFactory.java | 59 + .../w2phtml/gui/PreferencesStorage.java | 125 ++ .../pro/litvinovg/w2phtml/gui/RDFPanel.java | 273 ++++ .../litvinovg/w2phtml/gui/UIPreferences.java | 60 + 10 files changed, 1429 insertions(+), 1137 deletions(-) create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/BasePanel.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/ControlPanel.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/Contstants.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/EpubPanel.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/HTMLPanel.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/PanelFactory.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/PreferencesStorage.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/RDFPanel.java create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/UIPreferences.java diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/BasePanel.java b/src/main/java/pro/litvinovg/w2phtml/gui/BasePanel.java new file mode 100644 index 0000000..2272f79 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/BasePanel.java @@ -0,0 +1,256 @@ +package pro.litvinovg.w2phtml.gui; + +import static pro.litvinovg.w2phtml.gui.Contstants.*; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.HashMap; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class BasePanel extends JPanel { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Localizer localizer = null; + private JFrame singleFrame = null; + private UIPreferences preferences = null; + private HashMap configuration = null; + public BasePanel(Localizer localizer, JFrame singleFrame, HashMap configuration, UIPreferences preferences) { + this.localizer = localizer; + this.singleFrame = singleFrame; + this.configuration = configuration; + this.preferences = preferences; + } + + public BasePanel(Localizer localizer, JFrame singleFrame) { + this.localizer = localizer; + this.singleFrame = singleFrame; + } + + protected JCheckBox addMathJaxCB(Localizer localizer, UIPreferences preferences) { + JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX)); + cb_UseMathJax.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX))); + return cb_UseMathJax; + } + + protected void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) { + + File inputFile = new File(newFilePath); + if (!inputFile.exists()) { + return; + } + if (!inputFile.isDirectory()) { + File parent = inputFile.getParentFile(); + if (parent == null) { + return; + } + if (!parent.canWrite()) { + JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(CANT_WRITE_MESSAGE)); + } + } + if (newFilePath.length() < 3) { + return; + } + String exportPath; + if (inputFile.isDirectory()) { + exportPath = newFilePath; + tf_OutputFile.setText(exportPath); + } else { + String importExt = newFilePath.substring(newFilePath.length() - 3, newFilePath.length()).toLowerCase(); + if (importExt.equals(ODT_FILE_EXTENSION)) { + exportPath = newFilePath.substring(0, newFilePath.length() - 3) + extension; + tf_OutputFile.setText(exportPath); + } + } + } + + protected JCheckBox addIgnoreEmptyParsCB() { + JCheckBox cb_IgnoreEmptyParagraphs = new JCheckBox(localizer.getTranslation(LABEL_INGNORE_EMPTY_PARS)); + cb_IgnoreEmptyParagraphs.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_EMPTY_PARS))); + configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs); + return cb_IgnoreEmptyParagraphs; + } + + protected JCheckBox addSplitWholePagesOnly() { + JCheckBox cb_SplitWholePagesOnly = new JCheckBox(localizer.getTranslation(LABEL_SPLIT_WHOLE_PAGES_ONLY)); + cb_SplitWholePagesOnly.setSelected(Boolean.parseBoolean(preferences.get(PREF_SPLIT_WHOLE_PAGES))); + configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly); + return cb_SplitWholePagesOnly; + } + + protected JCheckBox addMathJaxCB() { + JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX)); + cb_UseMathJax.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX))); + configuration.put(ARG_USE_MATHJAX, cb_UseMathJax); + return cb_UseMathJax; + } + protected JCheckBox addIgnoreHardLineBreaks() { + JCheckBox cb_IgnoreHardLineBreaks = new JCheckBox(localizer.getTranslation(LABEL_FILETER_HARD_LINE_BREAKS)); + cb_IgnoreHardLineBreaks.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_HARD_BREAKS))); + configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks); + return cb_IgnoreHardLineBreaks; + } + + protected JTextField addLetterSpacingFilter() { + JTextField tf_FilterLetterSpacing = new JTextField(); + tf_FilterLetterSpacing.setText(preferences.get(PREF_LETTER_SPACING)); + configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing); + tf_FilterLetterSpacing.setColumns(10); + return tf_FilterLetterSpacing; + } + + protected JTextField addSplitByLevel() { + JTextField tf_SplitByLevel = new JTextField(); + configuration.put(ARG_SPLIT_LEVEL, tf_SplitByLevel); + tf_SplitByLevel.setText(preferences.get(PREF_SPLIT_BY_LEVEL)); + tf_SplitByLevel.setColumns(10); + return tf_SplitByLevel; + } + + protected JCheckBox addInlineStyles() { + JCheckBox cb_InlineStyles = new JCheckBox(localizer.getTranslation(LABEL_INLINE_STYLES)); + cb_InlineStyles.setSelected(Boolean.parseBoolean(preferences.get(PREF_INLINE_STYLES))); + configuration.put(ARG_CSS_INLINE, cb_InlineStyles); + return cb_InlineStyles; + } + + protected JCheckBox addGreenstoneTags() { + JCheckBox cb_Greenstone = new JCheckBox(localizer.getTranslation(LABEL_GREENSTONE_SPLIT)); + configuration.put(ARG_GREENSTONE, cb_Greenstone); + cb_Greenstone.setSelected(Boolean.parseBoolean(preferences.get(PREF_GREENSTONE_TAGS))); + return cb_Greenstone; + } + + protected JTextField addOutputFileTextField() { + JTextField tf_OutputFile = new JTextField(""); + configuration.put(ARG_OUTPUT_FILE, tf_OutputFile); + tf_OutputFile.setColumns(10); + return tf_OutputFile; + } + + protected JCheckBox addPagination() { + JCheckBox cb_Pagination = new JCheckBox(localizer.getTranslation(LABEL_PAGINATION)); + cb_Pagination.setSelected(Boolean.getBoolean(preferences.get(PREF_PAGINATION))); + configuration.put(ARG_PAGINATION, cb_Pagination); + return cb_Pagination; + } + + protected JCheckBox addConvertToPX() { + JCheckBox cb_convertToPx = new JCheckBox(localizer.getTranslation(LABEL_CONVERT_TO_PX)); + cb_convertToPx.setSelected(Boolean.getBoolean(preferences.get(PREF_CONVERT_TO_PX))); + configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx); + return cb_convertToPx; + } + + protected JTextField addPageBreakStyle() { + JTextField tf_pageBreakInlineStyle = new JTextField(preferences.get(PREF_PAGEBREAK_STYLES)); + tf_pageBreakInlineStyle.setColumns(10); + configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle); + return tf_pageBreakInlineStyle; + } + + protected JLabel addTargetFormat(String format) { + JLabel lb_TargetFormat = new JLabel(format); + configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat); + return lb_TargetFormat; + } + + protected JTextField addScaling() { + JTextField tf_Scale = new JTextField(); + tf_Scale.setText(preferences.get(PREF_SCALING)); + tf_Scale.setColumns(10); + configuration.put(ARG_SCALING, tf_Scale); + return tf_Scale; + } + + protected JTextField addInputFile() { + JTextField tf_inputFile = new JTextField(preferences.getSourceFileName()); + tf_inputFile.setColumns(10); + configuration.put(ARG_INPUT_FILE, tf_inputFile); + return tf_inputFile; + } + + protected JComboBox addImageResolution() { + JComboBox cbox_image_resolution = new JComboBox(preferences.getAll(PREF_RESOLUTIONS)); + cbox_image_resolution.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_IMAGE_RESOLUTION))); + configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution); + return cbox_image_resolution; + } + + protected JTextField addMaxWidth() { + JTextField tf_MaxWidth = new JTextField(preferences.get(PREF_MAX_WIDTH)); + tf_MaxWidth.setColumns(10); + configuration.put(ARG_MAX_WIDTH, tf_MaxWidth); + return tf_MaxWidth; + } + + protected JCheckBox addEmbedRasterImages() { + JCheckBox cb_EmbedRaster = new JCheckBox(localizer.getTranslation(LABEL_EMBED_RASTER)); + cb_EmbedRaster.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_RASTER))); + configuration.put(ARG_EMBED_IMG, cb_EmbedRaster); + return cb_EmbedRaster; + } + + protected JCheckBox addEmbedVectorImages() { + JCheckBox cb_EmbedVectorImages = new JCheckBox(localizer.getTranslation(LABEL_EMBED_VECTOR)); + cb_EmbedVectorImages.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_VECTOR))); + configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages); + return cb_EmbedVectorImages; + } + + protected JButton addChooseOutputButton(JTextField tf_OutputFile, String fileExtension) { + JButton btn_ChooseOutputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); + btn_ChooseOutputFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileDialog fileDialog = new FileDialog(); + String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),fileExtension); + if (newFilePath != null && !newFilePath.isEmpty()) { + tf_OutputFile.setText(newFilePath); + } + } + }); + return btn_ChooseOutputFile; + } + + protected void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) { + + File inputFile = new File(newFilePath); + if (!inputFile.exists()) { + return; + } + if (inputFile.isDirectory()) { + tf_MetadataFile.setText(newFilePath); + } else { + File parent = inputFile.getParentFile(); + if (parent == null) { + return; + } + if (newFilePath.length() < 3) { + return; + } + String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase(); + if (importExt.equals(ODT_FILE_EXTENSION)) { + String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension; + File metaFile = new File(metadataPath); + if (metaFile.exists() && metaFile.canRead()){ + tf_MetadataFile.setText(metadataPath); + } else { + tf_MetadataFile.setText(""); + } + } + } + + } +} \ No newline at end of file diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java index 94afdf6..3389e7e 100644 --- a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java +++ b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java @@ -1,113 +1,31 @@ package pro.litvinovg.w2phtml.gui; -import java.awt.EventQueue; +import static pro.litvinovg.w2phtml.gui.Contstants.*; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.GridLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.GroupLayout.Alignment; +import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.UIManager; import com.sun.star.uno.XComponentContext; -import pro.litvinovg.xml.Debug; -import w2phtml.Application; - -import java.awt.Toolkit; -import java.awt.GridLayout; -import javax.swing.JTabbedPane; -import javax.swing.JMenuBar; -import javax.swing.JOptionPane; -import javax.swing.JMenu; -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JCheckBox; -import javax.swing.JTextField; -import javax.swing.GroupLayout; -import javax.swing.GroupLayout.Alignment; -import javax.swing.GroupLayout.ParallelGroup; -import javax.swing.GroupLayout.SequentialGroup; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.JRadioButton; -import javax.swing.JButton; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.HashMap; -import java.util.Set; -import java.awt.event.ActionEvent; -import javax.swing.JSplitPane; -import java.awt.BorderLayout; -import javax.swing.JDesktopPane; -import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; -import javax.swing.SpringLayout; -import java.awt.FlowLayout; -import java.awt.CardLayout; -import java.awt.Component; -import javax.swing.SwingConstants; -import javax.swing.JComboBox; -import java.awt.Choice; - public class ConfigurationWindow extends JFrame { - private static final String LABEL_HTML5 = "label_html5"; - private static final String BUTTON_CONVERT_LABEL = "button_convert_label"; - private static final String MESSAGE_NOT_IMPLEMENTED = "message_not_implemented"; - private static final String BUTTON_EXIT_LABEL = "button_exit_label"; - private static final String BUTTON_SAVE_LABEL = "button_save_label"; - private static final String BUTTON_SAVEAS_LABEL = "button_saveas_label"; - private static final String ARG_PAGINATION = "pagination"; - private static final String ARG_IMAGE_RESOLUTION = "image_resolution"; - private static final String ARG_CSV_METADATA = "csv_metadata"; - private static final String ARG_RDF_TYPE = "rdf_type"; - private static final String CSV_FILE_EXTENSION = "csv"; - private static final String RDF_FILE_EXTENSION = "rdf"; - private static final String CANT_WRITE_MESSAGE = "error_cant_write"; - private static final String HTML_FILE_EXTENSION = "html"; - private static final String ARG_MAX_WIDTH = "max_width"; - private static final String LABEL_SPLIT_BY_HEADING = "label_split_by_heading"; - private static final String DEFAULT_PAGEBREAK_STYLE_SETTINGS = "height:3em;margin-top:1em;margin-bottom:1em;background-color:#f6f6f6;"; - private static final String EPUB_FILE_EXTENSION = "epub"; - private static final String ODT_FILE_EXTENSION = "odt"; - private static final String CONVERTER_TITLE_LABEL = "converter_title_label"; - private static final String LABEL_TYPE = "label_type"; - private static final String LABEL_METADATA_PATH = "label_metadata_path"; - private static final String LABEL_FILETER_HARD_LINE_BREAKS = "label_fileter_hard_line_breaks"; - private static final String LABEL_USE_MATHJAX = "label_use_mathjax"; - private static final String LABEL_SPLIT_WHOLE_PAGES_ONLY = "label_split_whole_pages_only"; - private static final String ARG_IGNORE_HARD_LINE_BREAKS = "ignore_hard_line_breaks"; - private static final String ARG_IGNORE_EMPTY_PARAGRAPHS = "ignore_empty_paragraphs"; - private static final String ARG_GREENSTONE = "greenstone"; - private static final String ARG_SPLIT_LEVEL = "split_level"; - private static final String ARG_ALIGN_SPLITS_TO_PAGES = "align_splits_to_pages"; - private static final String ARG_USE_MATHJAX = "use_mathjax"; - private static final String ARG_OUTPUT_FILE = "outputFile"; - private static final String ARG_TARGET_FORMAT = "targetFormat"; - private static final String ARG_INPUT_FILE = "inputFile"; - private static final String ARG_CONVERT_TO_PX = "convert_to_px"; - private static final String SCALING_DEFAULT_VALUE = "100%"; - private static final String ARG_SCALING = "scaling"; - private static final String ARG_EMBED_IMG = "embed_img"; - private static final String ARG_EMBED_SVG = "embed_svg"; - private static final String ARG_CSS_INLINE = "css_inline"; - private static final String ARG_MIN_LETTER_SPACING = "min_letter_spacing"; - private static final String LABEL_PAGINATION = "label_pagination"; - private static final String LABEL_IMAGE_RESOLUTION = "label_image_resolution"; - private static final String ARG_PAGE_BREAK_STYLE = "page_break_style"; - private static final String LABEL_BREAK_STYLE = "label_break_style"; - private static final String LETTER_SPACING_DEFAULT_VALUE = "0.15"; - private static final String LABEL_GREENSTONE_SPLIT = "label_greenstone_split"; - private static final String LABEL_INGNORE_EMPTY_PARS = "label_ingnore_empty_pars"; - private static final String LABEL_MIN_LETTER_SPACING = "label_min_letter_spacing"; - private static final String LABEL_MAX_BODY_WIDTH = "label_max_body_width"; - private static final String OUTPUT_FILE_PATH = "label_output_file_path"; - private static final String LABEL_BUTTON_CHOOSE = "label_button_choose"; - private static final String LABEL_TARGET_FORMAT = "label_target_format"; - private static final String LABEL_INPUT_FILE_PATH = "label_input_file_path"; - private static final String LABEL_CONVERT_TO_PX = "label_convert_to_px"; - private static final String LABEL_SCALE = "label_scale"; - private static final String LABEL_EMBED_RASTER = "label_embed_raster"; - private static final String LABEL_EMBED_VECTOR = "label_embed_vector"; - private static final String LABEL_INLINE_STYLES = "label_inline_styles"; /** * */ @@ -124,9 +42,8 @@ public class ConfigurationWindow extends JFrame { } private XComponentContext context; - private String fileName = ""; private Localizer localizer; - private String[] resolutions = {"0","72","150","300","600","1200","2400"}; + private PreferencesStorage storage; /** * Create the application. @@ -137,12 +54,13 @@ public class ConfigurationWindow extends JFrame { public ConfigurationWindow(XComponentContext context, ODTDocument doc) { this.context = context; - fileName = doc.getFileName(); initializeConfigurationWindow(); + storage.setSourceFileName(doc.getFileName()); } private void initializeConfigurationWindow() { this.localizer = new Localizer(); + initializePreferences(); setTitle(localizer.getTranslation(CONVERTER_TITLE_LABEL)); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setIconImage(Toolkit.getDefaultToolkit().getImage(ConfigurationWindow.class.getResource("/pro/litvinovg/w2phtml/gui/resources/w2phtml.png"))); @@ -150,1049 +68,23 @@ public class ConfigurationWindow extends JFrame { createEvents(); } + private void initializePreferences() { + storage = new PreferencesStorage(); + } + private void createEvents() { // TODO Auto-generated method stub } private void initComponents() { - getContentPane().setLayout(new GridLayout(1, 0, 0, 0)); - JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); getContentPane().add(tabbedPane); - - JPanel panel_rdf = createRDFPanel(); - JPanel panel_epub = createEpubPanel(); - JPanel panel_html = createHTMLPanel(); - - - tabbedPane.addTab("HTML", null, panel_html, null); - tabbedPane.addTab("RDF", null, panel_rdf, null); - tabbedPane.addTab("ePub", null, panel_epub, null); - - } - - private JPanel createEpubPanel() { - JPanel panel_epub = new JPanel(); - HashMap configuration = new HashMap(); - JPanel panel_control = createControlPanel(configuration); - JPanel panel_configEpub = createConfigEpubPanel(configuration); - applyDefaultLayout(panel_epub, panel_configEpub, panel_control); - return panel_epub; - } - - private JPanel createRDFPanel() { - JPanel panel_rdf = new JPanel(); - HashMap configuration = new HashMap(); - JPanel panel_control = createControlPanel(configuration); - JPanel panel_configRDF = createConfigRDFPanel(configuration); - applyDefaultLayout2(panel_rdf, panel_configRDF, panel_control); - return panel_rdf; - } - - private JPanel createHTMLPanel() { - JPanel panel_html = new JPanel(); - HashMap configuration = new HashMap(); - JPanel panel_configHTML = createConfigHTMLPanel(configuration); - JPanel panel_control = createControlPanel(configuration); - applyDefaultLayout3(panel_html, panel_configHTML, panel_control); - return panel_html; - } - - private void applyDefaultLayout(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) { - - GroupLayout gl_panel_html = new GroupLayout(tabbedPanel); - gl_panel_html.setHorizontalGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addGroup(gl_panel_html.createSequentialGroup().addGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE).addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE)).addGap(4))); - gl_panel_html.setVerticalGroup(gl_panel_html.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, - gl_panel_html.createSequentialGroup() - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))); - tabbedPanel.setLayout(gl_panel_html); - } - private void applyDefaultLayout2(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) { - - GroupLayout gl_panel_html = new GroupLayout(tabbedPanel); - gl_panel_html.setHorizontalGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addGroup(gl_panel_html.createSequentialGroup().addGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE).addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE)).addGap(4))); - gl_panel_html.setVerticalGroup(gl_panel_html.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, - gl_panel_html.createSequentialGroup() - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))); - tabbedPanel.setLayout(gl_panel_html); - } - private void applyDefaultLayout3(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) { - - GroupLayout gl_panel_html = new GroupLayout(tabbedPanel); - gl_panel_html.setHorizontalGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addGroup(gl_panel_html.createSequentialGroup().addGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE).addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE)).addGap(4))); - gl_panel_html.setVerticalGroup(gl_panel_html.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, - gl_panel_html.createSequentialGroup() - .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))); - tabbedPanel.setLayout(gl_panel_html); - } - - - private JPanel createConfigEpubPanel(HashMap configuration) { - JPanel panel_configHTML = new JPanel(); - - JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX)); - cb_UseMathJax.setSelected(true); - configuration.put(ARG_USE_MATHJAX, cb_UseMathJax); - - JCheckBox cb_IgnoreEmptyParagraphs = new JCheckBox(localizer.getTranslation(LABEL_INGNORE_EMPTY_PARS)); - cb_IgnoreEmptyParagraphs.setSelected(false); - configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs); - - JCheckBox cb_IgnoreHardLineBreaks = new JCheckBox(localizer.getTranslation(LABEL_FILETER_HARD_LINE_BREAKS)); - cb_IgnoreHardLineBreaks.setSelected(false); - configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks); - - JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); - - JTextField tf_FilterLetterSpacing = new JTextField(); - tf_FilterLetterSpacing.setText(LETTER_SPACING_DEFAULT_VALUE); - configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing); - - tf_FilterLetterSpacing.setColumns(10); - - JCheckBox cb_InlineStyles = new JCheckBox(localizer.getTranslation(LABEL_INLINE_STYLES)); - cb_InlineStyles.setSelected(true); - configuration.put(ARG_CSS_INLINE, cb_InlineStyles); - - JCheckBox cb_EmbedVectorImages = new JCheckBox(localizer.getTranslation(LABEL_EMBED_VECTOR)); - cb_EmbedVectorImages.setSelected(true); - configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages); - - JCheckBox cb_EmbedRaster = new JCheckBox(localizer.getTranslation(LABEL_EMBED_RASTER)); - cb_EmbedRaster.setSelected(true); - configuration.put(ARG_EMBED_IMG, cb_EmbedRaster); - - JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); - JTextField tf_Scale = new JTextField(); - tf_Scale.setText(SCALING_DEFAULT_VALUE); - configuration.put(ARG_SCALING, tf_Scale); - - tf_Scale.setColumns(10); - - JCheckBox cb_convertToPx = new JCheckBox(localizer.getTranslation(LABEL_CONVERT_TO_PX)); - configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx); - - JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); - - JTextField tf_inputFile = new JTextField(fileName); - tf_inputFile.setColumns(10); - configuration.put(ARG_INPUT_FILE, tf_inputFile); - - - JLabel lb_TargetFormat = new JLabel("epub3"); - configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat); - - - JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); - JTextField tf_OutputFile = new JTextField(""); - configuration.put(ARG_OUTPUT_FILE, tf_OutputFile); - tf_OutputFile.setColumns(10); - - JButton btnChooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btnChooseFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_inputFile.setText(newFilePath); - setOutputFilePath(newFilePath,tf_OutputFile,EPUB_FILE_EXTENSION); - - } - } - }); - - - JButton btn_ChooseOutputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btn_ChooseOutputFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),EPUB_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_OutputFile.setText(newFilePath); - } - } - }); - - - - JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); - - JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); - - JTextField tf_pageBreakInlineStyle = new JTextField(); - configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle); - tf_pageBreakInlineStyle.setText(DEFAULT_PAGEBREAK_STYLE_SETTINGS); - tf_pageBreakInlineStyle.setColumns(10); - - JCheckBox cb_Pagination = new JCheckBox(localizer.getTranslation(LABEL_PAGINATION)); - cb_Pagination.setSelected(true); - configuration.put(ARG_PAGINATION, cb_Pagination); - - JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); - - JComboBox cbox_image_resolution = new JComboBox(resolutions); - configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution); - cbox_image_resolution.setSelectedIndex(2); - - GroupLayout gl_panel_configHTML = new GroupLayout(panel_configHTML); - gl_panel_configHTML.setHorizontalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(34) - .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE) - .addGap(7) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE) - .addGap(60)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(32) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 336, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_FilterLetterSpacing, GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE) - .addGap(215)) - .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 389, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 405, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 409, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 313, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 349, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_EmbedRaster, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)) - .addGap(463)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(1) - .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE) - .addGap(10) - .addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE) - .addGap(21) - .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) - .addGap(10)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_TargetFormat_description) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(3) - .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) - .addGap(14) - .addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE) - .addGap(22) - .addComponent(btnChooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) - .addGap(10))) - .addGap(48)))))) - ); - gl_panel_configHTML.setVerticalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addContainerGap() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.TRAILING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_TargetFormat_description) - .addComponent(lb_TargetFormat)) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(16) - .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(12) - .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) - .addGap(2)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(btnChooseFile) - .addPreferredGap(ComponentPlacement.RELATED))) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(7) - .addComponent(btn_ChooseOutputFile)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(8) - .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(10) - .addComponent(lb_OutFilePath))) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(8) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(7) - .addComponent(lb_pageBreakInlineStyle))) - .addGap(22) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(2) - .addComponent(lb_Scale)) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(8) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cb_InlineStyles) - .addGap(7) - .addComponent(cb_EmbedVectorImages) - .addGap(7) - .addComponent(cb_EmbedRaster) - .addGap(7) - .addComponent(cb_convertToPx) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cb_IgnoreHardLineBreaks) - .addGap(7) - .addComponent(cb_IgnoreEmptyParagraphs) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_UseMathJax) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cb_Pagination) - .addGap(7) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_ImageResolution) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(118, Short.MAX_VALUE)) - ); - panel_configHTML.setLayout(gl_panel_configHTML); - return panel_configHTML; - } - - - private JPanel createConfigHTMLPanel(HashMap configuration) { - JPanel panel_configHTML = new JPanel(); - - JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX)); - cb_UseMathJax.setSelected(true); - configuration.put(ARG_USE_MATHJAX, cb_UseMathJax); - - JCheckBox cb_SplitWholePagesOnly = new JCheckBox(localizer.getTranslation(LABEL_SPLIT_WHOLE_PAGES_ONLY)); - configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly); - - JLabel lb_SplitByLevel = new JLabel(localizer.getTranslation(LABEL_SPLIT_BY_HEADING)); - JTextField tf_SplitByLevel = new JTextField(); - configuration.put(ARG_SPLIT_LEVEL, tf_SplitByLevel); - - tf_SplitByLevel.setColumns(10); - - JCheckBox cb_Greenstone = new JCheckBox(localizer.getTranslation(LABEL_GREENSTONE_SPLIT)); - configuration.put(ARG_GREENSTONE, cb_Greenstone); - - JCheckBox cb_IgnoreEmptyParagraphs = new JCheckBox(localizer.getTranslation(LABEL_INGNORE_EMPTY_PARS)); - cb_IgnoreEmptyParagraphs.setSelected(false); - configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs); - - JCheckBox cb_IgnoreHardLineBreaks = new JCheckBox(localizer.getTranslation(LABEL_FILETER_HARD_LINE_BREAKS)); - cb_IgnoreHardLineBreaks.setSelected(false); - configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks); - - JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); - - JTextField tf_FilterLetterSpacing = new JTextField(); - tf_FilterLetterSpacing.setText(LETTER_SPACING_DEFAULT_VALUE); - configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing); - - tf_FilterLetterSpacing.setColumns(10); - - JCheckBox cb_InlineStyles = new JCheckBox(localizer.getTranslation(LABEL_INLINE_STYLES)); - cb_InlineStyles.setSelected(true); - configuration.put(ARG_CSS_INLINE, cb_InlineStyles); - - JCheckBox cb_EmbedVectorImages = new JCheckBox(localizer.getTranslation(LABEL_EMBED_VECTOR)); - cb_EmbedVectorImages.setSelected(true); - configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages); - - JCheckBox cb_EmbedRaster = new JCheckBox(localizer.getTranslation(LABEL_EMBED_RASTER)); - cb_EmbedRaster.setSelected(true); - configuration.put(ARG_EMBED_IMG, cb_EmbedRaster); - - JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); - JTextField tf_Scale = new JTextField(); - tf_Scale.setText(SCALING_DEFAULT_VALUE); - configuration.put(ARG_SCALING, tf_Scale); - - tf_Scale.setColumns(10); - - JLabel lb_MaxWidth = new JLabel(localizer.getTranslation(LABEL_MAX_BODY_WIDTH)); - - JTextField tf_MaxWidth = new JTextField(); - configuration.put(ARG_MAX_WIDTH, tf_MaxWidth); - - tf_MaxWidth.setColumns(10); - - JCheckBox cb_convertToPx = new JCheckBox(localizer.getTranslation(LABEL_CONVERT_TO_PX)); - configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx); - - JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); - - JTextField tf_inputFile = new JTextField(fileName); - tf_inputFile.setColumns(10); - configuration.put(ARG_INPUT_FILE, tf_inputFile); - - - JLabel lb_TargetFormat = new JLabel(localizer.getTranslation(LABEL_HTML5)); - configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat); - JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); - - JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); - JTextField tf_OutputFile = new JTextField(""); - tf_OutputFile.setColumns(10); - configuration.put(ARG_OUTPUT_FILE, tf_OutputFile); - - JButton btn_ChooseInputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btn_ChooseInputFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_inputFile.setText(newFilePath); - setOutputFilePath(newFilePath,tf_OutputFile,HTML_FILE_EXTENSION); - } - } - - - }); - - JButton btn_ChooseOutputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btn_ChooseOutputFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),HTML_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_OutputFile.setText(newFilePath); - } - } - }); - - JTextField tf_pageBreakInlineStyle = new JTextField(); - configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle); - tf_pageBreakInlineStyle.setText(DEFAULT_PAGEBREAK_STYLE_SETTINGS); - tf_pageBreakInlineStyle.setColumns(10); - - JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); - - JCheckBox cb_Pagination = new JCheckBox(localizer.getTranslation(LABEL_PAGINATION)); - cb_Pagination.setSelected(true); - configuration.put(ARG_PAGINATION, cb_Pagination); - - JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); - - JComboBox cbox_image_resolution = new JComboBox(resolutions); - cbox_image_resolution.setSelectedIndex(2); - - configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution); - - - GroupLayout gl_panel_configHTML = new GroupLayout(panel_configHTML); - gl_panel_configHTML.setHorizontalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(32) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 454, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE) - .addGap(541)) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_Greenstone, GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 441, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 341, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_EmbedRaster) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 276, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 350, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE) - .addGap(635)) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) - .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(tf_OutputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE) - .addComponent(tf_inputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) - .addComponent(btn_ChooseInputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) - .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 352, GroupLayout.PREFERRED_SIZE) - .addComponent(cb_SplitWholePagesOnly, GroupLayout.PREFERRED_SIZE, 323, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE) - .addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)))) - .addGap(145))))))))))))) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 366, GroupLayout.PREFERRED_SIZE) - .addGap(4) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))) - .addGap(615)))) - ); - gl_panel_configHTML.setVerticalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(12) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_TargetFormat_description) - .addComponent(lb_TargetFormat)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(btn_ChooseInputFile)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(2) - .addComponent(lb_FilePath))) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_OutFilePath) - .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(btn_ChooseOutputFile)) - .addGap(12) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_pageBreakInlineStyle) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(18) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_Scale) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_MaxWidth) - .addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_FilterLetterSpacing) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_InlineStyles) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_EmbedVectorImages) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_EmbedRaster) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_convertToPx) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_IgnoreHardLineBreaks) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_IgnoreEmptyParagraphs) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_Greenstone) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cb_SplitWholePagesOnly) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_UseMathJax) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_Pagination) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_ImageResolution) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(101)) - ); - panel_configHTML.setLayout(gl_panel_configHTML); - return panel_configHTML; - } - - protected void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) { - - File inputFile = new File(newFilePath); - if (!inputFile.exists()) { - return; - } - if (!inputFile.isDirectory()) { - File parent = inputFile.getParentFile(); - if (parent == null) { - return; - } - if (!parent.canWrite()){ - JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(CANT_WRITE_MESSAGE)); - } - } - if (newFilePath.length() < 3) { - return; - } - String exportPath; - if (inputFile.isDirectory()) { - exportPath = newFilePath; - tf_OutputFile.setText(exportPath); - } else { - String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase(); - if (importExt.equals(ODT_FILE_EXTENSION)) { - exportPath = newFilePath.substring(0, newFilePath.length()-3) + extension; - tf_OutputFile.setText(exportPath); - } - } - } - - protected void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) { - - File inputFile = new File(newFilePath); - if (!inputFile.exists()) { - return; - } - if (inputFile.isDirectory()) { - tf_MetadataFile.setText(newFilePath); - } else { - File parent = inputFile.getParentFile(); - if (parent == null) { - return; - } - if (newFilePath.length() < 3) { - return; - } - String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase(); - if (importExt.equals(ODT_FILE_EXTENSION)) { - String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension; - File metaFile = new File(metadataPath); - if (metaFile.exists() && metaFile.canRead()){ - tf_MetadataFile.setText(metadataPath); - } else { - tf_MetadataFile.setText(""); - } - } - } - } - - private JPanel createConfigRDFPanel(HashMap configuration) { - JPanel panel_configHTML = new JPanel(); - - JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX)); - cb_UseMathJax.setSelected(true); - configuration.put(ARG_USE_MATHJAX, cb_UseMathJax); - - JCheckBox cb_IgnoreEmptyParagraphs = new JCheckBox(localizer.getTranslation(LABEL_INGNORE_EMPTY_PARS)); - cb_IgnoreEmptyParagraphs.setSelected(false); - configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs); - - JCheckBox cb_IgnoreHardLineBreaks = new JCheckBox(localizer.getTranslation(LABEL_FILETER_HARD_LINE_BREAKS)); - cb_IgnoreHardLineBreaks.setSelected(false); - configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks); - - JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); - - JTextField tf_FilterLetterSpacing = new JTextField(); - tf_FilterLetterSpacing.setText(LETTER_SPACING_DEFAULT_VALUE); - configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing); - - tf_FilterLetterSpacing.setColumns(10); - - JCheckBox cb_InlineStyles = new JCheckBox(localizer.getTranslation(LABEL_INLINE_STYLES)); - cb_InlineStyles.setEnabled(false); - cb_InlineStyles.setSelected(true); - configuration.put(ARG_CSS_INLINE, cb_InlineStyles); - - JCheckBox cb_EmbedVectorImages = new JCheckBox(localizer.getTranslation(LABEL_EMBED_VECTOR)); - cb_EmbedVectorImages.setEnabled(false); - cb_EmbedVectorImages.setSelected(true); - configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages); - - JCheckBox cb_EmbedRaster = new JCheckBox(localizer.getTranslation(LABEL_EMBED_RASTER)); - cb_EmbedRaster.setEnabled(false); - cb_EmbedRaster.setSelected(true); - configuration.put(ARG_EMBED_IMG, cb_EmbedRaster); - - JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); - JTextField tf_Scale = new JTextField(); - tf_Scale.setText(SCALING_DEFAULT_VALUE); - configuration.put(ARG_SCALING, tf_Scale); - - tf_Scale.setColumns(10); - - JCheckBox cb_convertToPx = new JCheckBox(localizer.getTranslation(LABEL_CONVERT_TO_PX)); - configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx); - - JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); - - JTextField tf_inputFile = new JTextField(fileName); - tf_inputFile.setColumns(10); - configuration.put(ARG_INPUT_FILE, tf_inputFile); - - JLabel lb_TargetFormat = new JLabel(RDF_FILE_EXTENSION); - configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat); - - JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); - - JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); - - JTextField tf_OutputFile = new JTextField(""); - configuration.put(ARG_OUTPUT_FILE, tf_OutputFile); - tf_OutputFile.setColumns(10); - - String[] types = {"elenphArticle", "encArticle", "book", "journal"}; - JComboBox cbox_type = new JComboBox(types); - configuration.put(ARG_RDF_TYPE, cbox_type); - - - JLabel lb_type = new JLabel(localizer.getTranslation(LABEL_TYPE)); - - JLabel lb_metadataFilePath = new JLabel(localizer.getTranslation(LABEL_METADATA_PATH)); - - JTextField tf_metadataPath = new JTextField(""); - configuration.put(ARG_CSV_METADATA, tf_metadataPath); - - JButton btnChooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btnChooseFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_inputFile.setText(newFilePath); - setOutputFilePath(newFilePath,tf_OutputFile,RDF_FILE_EXTENSION); - setMetadataFilePath(newFilePath,tf_metadataPath,CSV_FILE_EXTENSION); - } - } - }); - - - - JButton btn_ChooseOutputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btn_ChooseOutputFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),RDF_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_OutputFile.setText(newFilePath); - } - } - }); - - - tf_metadataPath.setColumns(10); - - JButton btn_metadataChoose = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); - btn_metadataChoose.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileDialog fileDialog = new FileDialog(); - String newFilePath = fileDialog.chooseFile(tf_metadataPath.getText(),CSV_FILE_EXTENSION); - if (newFilePath != null && !newFilePath.isEmpty()) { - tf_metadataPath.setText(newFilePath); - } - } - }); - - JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); - - JTextField tf_pageBreakInlineStyle = new JTextField(); - configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle); - - tf_pageBreakInlineStyle.setText(DEFAULT_PAGEBREAK_STYLE_SETTINGS); - tf_pageBreakInlineStyle.setColumns(10); - - JCheckBox cb_Pagination = new JCheckBox(localizer.getTranslation(LABEL_PAGINATION)); - configuration.put(ARG_PAGINATION, cb_Pagination); - - JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); - - JComboBox cbox_image_resolution = new JComboBox(resolutions); - configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution); - cbox_image_resolution.setSelectedIndex(2); - - - GroupLayout gl_panel_configHTML = new GroupLayout(panel_configHTML); - gl_panel_configHTML.setHorizontalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(32) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 369, GroupLayout.PREFERRED_SIZE) - .addGap(4) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_EmbedRaster) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_EmbedVectorImages) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_FilterLetterSpacing) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(599)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(cb_InlineStyles) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE) - .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE) - .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(tf_metadataPath, GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE) - .addGap(1)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE) - .addGap(3))))) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(11) - .addComponent(btnChooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(12) - .addComponent(btn_metadataChoose, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(11) - .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) - .addGap(149)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE) - .addGap(145)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_type, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE) - .addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) - .addGap(21)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE) - .addContainerGap()))))) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 339, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 344, GroupLayout.PREFERRED_SIZE) - .addContainerGap())))) - ); - gl_panel_configHTML.setVerticalGroup( - gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addContainerGap() - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_TargetFormat_description) - .addComponent(lb_TargetFormat)) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(22) - .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(24) - .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) - .addComponent(tf_metadataPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) - .addGroup(gl_panel_configHTML.createSequentialGroup() - .addGap(46) - .addComponent(btnChooseFile) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btn_metadataChoose) - .addGap(7) - .addComponent(btn_ChooseOutputFile))) - .addGap(20) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) - .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(18) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_type) - .addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_Scale) - .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_FilterLetterSpacing) - .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(10) - .addComponent(cb_InlineStyles) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_EmbedVectorImages) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_EmbedRaster) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_convertToPx) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_IgnoreHardLineBreaks) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_IgnoreEmptyParagraphs) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cb_UseMathJax) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cb_Pagination) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) - .addComponent(lb_ImageResolution) - .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(87, Short.MAX_VALUE)) - ); - panel_configHTML.setLayout(gl_panel_configHTML); - return panel_configHTML; - } - - private JPanel createControlPanel(HashMap configuration) { - JPanel controlPanel = new JPanel(); - - JButton btn_Exit = new JButton(localizer.getTranslation(BUTTON_EXIT_LABEL)); - btn_Exit.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - singleFrame.setVisible(false); - singleFrame.dispose(); - } - }); - - JButton btn_SaveAs = new JButton(localizer.getTranslation(BUTTON_SAVEAS_LABEL)); - btn_SaveAs.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED)); - } - }); - JButton btn_Save = new JButton(localizer.getTranslation(BUTTON_SAVE_LABEL)); - btn_Save.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED)); - } - }); - JButton btn_startConversion = new JButton(localizer.getTranslation(BUTTON_CONVERT_LABEL)); - btn_startConversion.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - try { - ConversionExecutor executor = new ConversionExecutor(configuration, singleFrame); - executor.convert(); - } catch(Throwable e) { - StringWriter errors = new StringWriter(); - e.printStackTrace(new PrintWriter(errors)); - JOptionPane.showMessageDialog(singleFrame,errors.toString()); - } - } - - }); - - GroupLayout gl_panel_control = new GroupLayout(controlPanel); - gl_panel_control.setHorizontalGroup( - gl_panel_control.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_control.createSequentialGroup() - .addGap(83) - .addComponent(btn_Exit, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE) - .addGap(18) - .addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE) - .addGap(18) - .addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) - .addGap(18) - .addComponent(btn_startConversion, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE) - .addContainerGap(427, Short.MAX_VALUE)) - ); - gl_panel_control.setVerticalGroup( - gl_panel_control.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel_control.createSequentialGroup() - .addContainerGap() - .addGroup(gl_panel_control.createParallelGroup(Alignment.BASELINE) - .addComponent(btn_SaveAs) - .addComponent(btn_Save) - .addComponent(btn_Exit) - .addComponent(btn_startConversion)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - controlPanel.setLayout(gl_panel_control); - return controlPanel; + PanelFactory panelFactory = new PanelFactory(localizer, singleFrame, storage, tabbedPane); + JPanel html = panelFactory.createPanel(HTML,HTML); + JPanel rdf = panelFactory.createPanel(RDF,RDF); + JPanel epub = panelFactory.createPanel(EPUB,EPUB); } public static void runGUI(XComponentContext context) { @@ -1217,6 +109,7 @@ public class ConfigurationWindow extends JFrame { } catch (Throwable e) { String message = e.getLocalizedMessage(); + e.printStackTrace(); JOptionPane.showMessageDialog(singleFrame, message); } } diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ControlPanel.java b/src/main/java/pro/litvinovg/w2phtml/gui/ControlPanel.java new file mode 100644 index 0000000..ecd2e49 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/ControlPanel.java @@ -0,0 +1,84 @@ +package pro.litvinovg.w2phtml.gui; + +import static pro.litvinovg.w2phtml.gui.Contstants.*; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.GroupLayout.Alignment; + +public class ControlPanel extends BasePanel { + public ControlPanel(HashMap configuration,Localizer localizer, JFrame singleFrame) { + super(localizer, singleFrame); + + JButton btn_Exit = new JButton(localizer.getTranslation(BUTTON_EXIT_LABEL)); + btn_Exit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + singleFrame.setVisible(false); + singleFrame.dispose(); + } + }); + + JButton btn_SaveAs = new JButton(localizer.getTranslation(BUTTON_SAVEAS_LABEL)); + btn_SaveAs.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED)); + } + }); + JButton btn_Save = new JButton(localizer.getTranslation(BUTTON_SAVE_LABEL)); + btn_Save.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED)); + } + }); + JButton btn_startConversion = new JButton(localizer.getTranslation(BUTTON_CONVERT_LABEL)); + btn_startConversion.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + try { + ConversionExecutor executor = new ConversionExecutor(configuration, singleFrame); + executor.convert(); + } catch(Throwable e) { + StringWriter errors = new StringWriter(); + e.printStackTrace(new PrintWriter(errors)); + JOptionPane.showMessageDialog(singleFrame,errors.toString()); + } + } + + }); + + GroupLayout gl_panel_control = new GroupLayout(this); + gl_panel_control.setHorizontalGroup( + gl_panel_control.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_control.createSequentialGroup() + .addGap(83) + .addComponent(btn_Exit, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE) + .addGap(18) + .addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE) + .addGap(18) + .addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) + .addGap(18) + .addComponent(btn_startConversion, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE) + .addContainerGap(427, Short.MAX_VALUE)) + ); + gl_panel_control.setVerticalGroup( + gl_panel_control.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_control.createSequentialGroup() + .addContainerGap() + .addGroup(gl_panel_control.createParallelGroup(Alignment.BASELINE) + .addComponent(btn_SaveAs) + .addComponent(btn_Save) + .addComponent(btn_Exit) + .addComponent(btn_startConversion)) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + this.setLayout(gl_panel_control); + } +} diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/Contstants.java b/src/main/java/pro/litvinovg/w2phtml/gui/Contstants.java new file mode 100644 index 0000000..a3bb9fb --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/Contstants.java @@ -0,0 +1,91 @@ +package pro.litvinovg.w2phtml.gui; + +public class Contstants { + public static final String LABEL_HTML5 = "label_html5"; + public static final String BUTTON_CONVERT_LABEL = "button_convert_label"; + public static final String MESSAGE_NOT_IMPLEMENTED = "message_not_implemented"; + public static final String BUTTON_EXIT_LABEL = "button_exit_label"; + public static final String BUTTON_SAVE_LABEL = "button_save_label"; + public static final String BUTTON_SAVEAS_LABEL = "button_saveas_label"; + public static final String ARG_PAGINATION = "pagination"; + public static final String ARG_IMAGE_RESOLUTION = "image_resolution"; + public static final String ARG_CSV_METADATA = "csv_metadata"; + public static final String ARG_RDF_TYPE = "rdf_type"; + public static final String CSV_FILE_EXTENSION = "csv"; + public static final String RDF_FILE_EXTENSION = "rdf"; + public static final String CANT_WRITE_MESSAGE = "error_cant_write"; + public static final String HTML_FILE_EXTENSION = "html"; + public static final String ARG_MAX_WIDTH = "max_width"; + public static final String LABEL_SPLIT_BY_HEADING = "label_split_by_heading"; + public static final String DEFAULT_PAGEBREAK_STYLE_SETTINGS = "height:3em;margin-top:1em;margin-bottom:1em;background-color:#f6f6f6;"; + public static final String EPUB_FILE_EXTENSION = "epub"; + public static final String ODT_FILE_EXTENSION = "odt"; + public static final String CONVERTER_TITLE_LABEL = "converter_title_label"; + public static final String LABEL_TYPE = "label_type"; + public static final String LABEL_METADATA_PATH = "label_metadata_path"; + public static final String LABEL_FILETER_HARD_LINE_BREAKS = "label_fileter_hard_line_breaks"; + public static final String LABEL_USE_MATHJAX = "label_use_mathjax"; + public static final String LABEL_SPLIT_WHOLE_PAGES_ONLY = "label_split_whole_pages_only"; + public static final String ARG_IGNORE_HARD_LINE_BREAKS = "ignore_hard_line_breaks"; + public static final String ARG_IGNORE_EMPTY_PARAGRAPHS = "ignore_empty_paragraphs"; + public static final String ARG_GREENSTONE = "greenstone"; + public static final String ARG_SPLIT_LEVEL = "split_level"; + public static final String ARG_ALIGN_SPLITS_TO_PAGES = "align_splits_to_pages"; + public static final String ARG_USE_MATHJAX = "use_mathjax"; + public static final String ARG_OUTPUT_FILE = "outputFile"; + public static final String ARG_TARGET_FORMAT = "targetFormat"; + public static final String ARG_INPUT_FILE = "inputFile"; + public static final String ARG_CONVERT_TO_PX = "convert_to_px"; + public static final String SCALING_DEFAULT_VALUE = "100%"; + public static final String ARG_SCALING = "scaling"; + public static final String ARG_EMBED_IMG = "embed_img"; + public static final String ARG_EMBED_SVG = "embed_svg"; + public static final String ARG_CSS_INLINE = "css_inline"; + public static final String ARG_MIN_LETTER_SPACING = "min_letter_spacing"; + public static final String LABEL_PAGINATION = "label_pagination"; + public static final String LABEL_IMAGE_RESOLUTION = "label_image_resolution"; + public static final String ARG_PAGE_BREAK_STYLE = "page_break_style"; + public static final String LABEL_BREAK_STYLE = "label_break_style"; + public static final String LABEL_GREENSTONE_SPLIT = "label_greenstone_split"; + public static final String LABEL_INGNORE_EMPTY_PARS = "label_ingnore_empty_pars"; + public static final String LABEL_MIN_LETTER_SPACING = "label_min_letter_spacing"; + public static final String LABEL_MAX_BODY_WIDTH = "label_max_body_width"; + public static final String OUTPUT_FILE_PATH = "label_output_file_path"; + public static final String LABEL_BUTTON_CHOOSE = "label_button_choose"; + public static final String LABEL_TARGET_FORMAT = "label_target_format"; + public static final String LABEL_INPUT_FILE_PATH = "label_input_file_path"; + public static final String LABEL_CONVERT_TO_PX = "label_convert_to_px"; + public static final String LABEL_SCALE = "label_scale"; + public static final String LABEL_EMBED_RASTER = "label_embed_raster"; + public static final String LABEL_EMBED_VECTOR = "label_embed_vector"; + public static final String LABEL_INLINE_STYLES = "label_inline_styles"; + public static final String EPUB3_TARGET_FORMAT = "epub3"; + public static final String HTML5_TARGET_FORMAT = "html5"; + public static final String RDF_TARGET_FORMAT = "rdf"; + + + public static final String HTML = "HTML"; + public static final String EPUB = "EPUB"; + public static final String RDF = "RDF"; + public static final String PREF_RESOLUTIONS = "resolutions"; + public static final String PREF_PUBLICATION_TYPES = "publication_types"; + public static final String PREF_DEFAULT_PUBLICATION_TYPE = "default_publication_type"; + public static final String PREF_DEFAULT_IMAGE_RESOLUTION = "default_image_resolution"; + public static final String PREF_USE_MATHJAX = "use_mathjax"; + public static final String PREF_IGNORE_EMPTY_PARS = "ignore_empty_paragraphs"; + public static final String PREF_IGNORE_HARD_BREAKS = "ignore_hard_breaks"; + public static final String PREF_SPLIT_BY_LEVEL = "split_by_level"; + public static final String PREF_GREENSTONE_TAGS = "greenstone_tags"; + public static final String PREF_SPLIT_WHOLE_PAGES = "split_whole_pages"; + public static final String PREF_LETTER_SPACING = "letter_spacing_filter"; + public static final String PREF_INLINE_STYLES = "inline_styles"; + public static final String PREF_EMBED_RASTER = "embed_raster"; + public static final String PREF_EMBED_VECTOR = "embed_vector"; + public static final String PREF_SCALING = "scaling"; + public static final String PREF_MAX_WIDTH = "max_width"; + public static final String PREF_PAGEBREAK_STYLES = "pagebreak_styles"; + public static final String PREF_CONVERT_TO_PX = "convert_to_px"; + public static final String PREF_PAGINATION = "pagination"; + + +} diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/EpubPanel.java b/src/main/java/pro/litvinovg/w2phtml/gui/EpubPanel.java new file mode 100644 index 0000000..764f6dc --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/EpubPanel.java @@ -0,0 +1,213 @@ +package pro.litvinovg.w2phtml.gui; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; +import static pro.litvinovg.w2phtml.gui.Contstants.*; + + +public class EpubPanel extends BasePanel { + + + /** + * + */ + private static final long serialVersionUID = 1L; + + public EpubPanel(HashMap configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) { + super(localizer, singleFrame, configuration, preferences); + + JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); + JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); + JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); + JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); + JLabel lb_TargetFormat = addTargetFormat(EPUB3_TARGET_FORMAT); + JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); + JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); + JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); + + JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(); + JTextField tf_OutputFile = addOutputFileTextField(); + JTextField tf_inputFile = addInputFile(); + JTextField tf_Scale = addScaling(); + JTextField tf_pageBreakInlineStyle = addPageBreakStyle(); + + JCheckBox cb_UseMathJax = addMathJaxCB(); + JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(); + JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(); + JCheckBox cb_InlineStyles = addInlineStyles(); + JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(); + JCheckBox cb_EmbedRaster = addEmbedRasterImages(); + JCheckBox cb_convertToPx = addConvertToPX(); + JCheckBox cb_Pagination = addPagination(); + + JComboBox cbox_image_resolution = addImageResolution(); + + JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, EPUB_FILE_EXTENSION); + JButton btn_chooseFile = addButtonChooseFile(localizer, tf_OutputFile, tf_inputFile); + + GroupLayout gl_panel_configHTML = new GroupLayout(this); + gl_panel_configHTML.setHorizontalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(34) + .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE) + .addGap(7) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE) + .addGap(60)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(32) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 336, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_FilterLetterSpacing, GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE) + .addGap(215)) + .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 389, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 405, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 409, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 313, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 349, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_EmbedRaster, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)) + .addGap(463)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(1) + .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE) + .addGap(10) + .addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE) + .addGap(21) + .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) + .addGap(10)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_TargetFormat_description) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(3) + .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) + .addGap(14) + .addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE) + .addGap(22) + .addComponent(btn_chooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) + .addGap(10))) + .addGap(48)))))) + ); + gl_panel_configHTML.setVerticalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addContainerGap() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.TRAILING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_TargetFormat_description) + .addComponent(lb_TargetFormat)) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(16) + .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(12) + .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) + .addGap(2)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(btn_chooseFile) + .addPreferredGap(ComponentPlacement.RELATED))) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(7) + .addComponent(btn_ChooseOutputFile)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(8) + .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(10) + .addComponent(lb_OutFilePath))) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(8) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(7) + .addComponent(lb_pageBreakInlineStyle))) + .addGap(22) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(2) + .addComponent(lb_Scale)) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(8) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cb_InlineStyles) + .addGap(7) + .addComponent(cb_EmbedVectorImages) + .addGap(7) + .addComponent(cb_EmbedRaster) + .addGap(7) + .addComponent(cb_convertToPx) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cb_IgnoreHardLineBreaks) + .addGap(7) + .addComponent(cb_IgnoreEmptyParagraphs) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_UseMathJax) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cb_Pagination) + .addGap(7) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_ImageResolution) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addContainerGap(118, Short.MAX_VALUE)) + ); + this.setLayout(gl_panel_configHTML); + } + + private JButton addButtonChooseFile(Localizer localizer, JTextField tf_OutputFile, JTextField tf_inputFile) { + JButton btn_chooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); + btn_chooseFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileDialog fileDialog = new FileDialog(); + String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); + if (newFilePath != null && !newFilePath.isEmpty()) { + tf_inputFile.setText(newFilePath); + setOutputFilePath(newFilePath,tf_OutputFile,EPUB_FILE_EXTENSION); + } + } + }); + return btn_chooseFile; + } + + + + +} diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/HTMLPanel.java b/src/main/java/pro/litvinovg/w2phtml/gui/HTMLPanel.java new file mode 100644 index 0000000..495fb11 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/HTMLPanel.java @@ -0,0 +1,238 @@ +package pro.litvinovg.w2phtml.gui; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; +import static pro.litvinovg.w2phtml.gui.Contstants.*; + + +public class HTMLPanel extends BasePanel{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public HTMLPanel(HashMap configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) { + super(localizer, singleFrame, configuration, preferences); + + JLabel lb_SplitByLevel = new JLabel(localizer.getTranslation(LABEL_SPLIT_BY_HEADING)); + JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); + JLabel lb_TargetFormat = addTargetFormat(HTML5_TARGET_FORMAT); + JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); + JLabel lb_MaxWidth = new JLabel(localizer.getTranslation(LABEL_MAX_BODY_WIDTH)); + JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); + JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); + JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); + JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); + JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); + + JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(); + JTextField tf_SplitByLevel = addSplitByLevel(); + JTextField tf_Scale = addScaling(); + JTextField tf_MaxWidth = addMaxWidth(); + JTextField tf_inputFile = addInputFile(); + JTextField tf_OutputFile = addOutputFileTextField(); + JTextField tf_pageBreakInlineStyle = addPageBreakStyle(); + + JCheckBox cb_UseMathJax = addMathJaxCB(); + JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(); + JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(); + JCheckBox cb_SplitWholePagesOnly = addSplitWholePagesOnly(); + JCheckBox cb_Greenstone = addGreenstoneTags(); + JCheckBox cb_InlineStyles = addInlineStyles(); + JCheckBox cb_EmbedRaster = addEmbedRasterImages(); + JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(); + JCheckBox cb_convertToPx = addConvertToPX(); + JCheckBox cb_Pagination = addPagination(); + + JComboBox cbox_image_resolution = addImageResolution(); + + JButton btn_chooseFile = addButtonChooseFile(localizer, tf_inputFile, tf_OutputFile); + JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, HTML_FILE_EXTENSION); + + GroupLayout gl_panel_configHTML = new GroupLayout(this); + gl_panel_configHTML.setHorizontalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(32) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 454, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE) + .addGap(541)) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_Greenstone, GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 441, GroupLayout.PREFERRED_SIZE) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 341, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_EmbedRaster) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 276, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 350, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE) + .addGap(635)) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) + .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(tf_OutputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE) + .addComponent(tf_inputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) + .addComponent(btn_chooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) + .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 352, GroupLayout.PREFERRED_SIZE) + .addComponent(cb_SplitWholePagesOnly, GroupLayout.PREFERRED_SIZE, 323, GroupLayout.PREFERRED_SIZE) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE) + .addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)))) + .addGap(145))))))))))))) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 366, GroupLayout.PREFERRED_SIZE) + .addGap(4) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))) + .addGap(615)))) + ); + gl_panel_configHTML.setVerticalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(12) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_TargetFormat_description) + .addComponent(lb_TargetFormat)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(btn_chooseFile)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(2) + .addComponent(lb_FilePath))) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_OutFilePath) + .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(btn_ChooseOutputFile)) + .addGap(12) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_pageBreakInlineStyle) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(18) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_Scale) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_MaxWidth) + .addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_FilterLetterSpacing) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_InlineStyles) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_EmbedVectorImages) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_EmbedRaster) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_convertToPx) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_IgnoreHardLineBreaks) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_IgnoreEmptyParagraphs) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_Greenstone) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cb_SplitWholePagesOnly) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_UseMathJax) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_Pagination) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_ImageResolution) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(101)) + ); + this.setLayout(gl_panel_configHTML); + } + + private JButton addButtonChooseFile(Localizer localizer, JTextField tf_inputFile, JTextField tf_OutputFile) { + JButton btn_chooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); + btn_chooseFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); + if (newFilePath != null && !newFilePath.isEmpty()) { + tf_inputFile.setText(newFilePath); + setOutputFilePath(newFilePath,tf_OutputFile,HTML_FILE_EXTENSION); + } + } + }); + return btn_chooseFile; + } + + +} + diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/PanelFactory.java b/src/main/java/pro/litvinovg/w2phtml/gui/PanelFactory.java new file mode 100644 index 0000000..ad8b841 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/PanelFactory.java @@ -0,0 +1,59 @@ +package pro.litvinovg.w2phtml.gui; + +import java.awt.Component; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; +import static pro.litvinovg.w2phtml.gui.Contstants.*; + + +public class PanelFactory { + + private Localizer localizer; + private JFrame singleFrame; + private PreferencesStorage storage; + private JTabbedPane tabbedPane; + + public PanelFactory(Localizer localizer,JFrame singleFrame, PreferencesStorage preferences,JTabbedPane tabbedPane) { + this.localizer = localizer; + this.singleFrame = singleFrame; + this.storage = preferences; + this.tabbedPane = tabbedPane; + } + public JPanel createPanel(String type, String name) { + JPanel panel = new JPanel(); + HashMap configuration = new HashMap(); + JPanel panel_control = new ControlPanel(configuration, localizer, singleFrame); + JPanel panel_configuration = null; + if (EPUB.equals(type)){ + panel_configuration = new EpubPanel(configuration, localizer, storage.get(name,type),singleFrame); + } else if (RDF.equals(type)) { + panel_configuration = new RDFPanel(configuration, localizer, storage.get(name,type),singleFrame); + } else { + panel_configuration = new HTMLPanel(configuration, localizer, storage.get(name,type),singleFrame); + } + applyDefaultLayout(panel, panel_configuration, panel_control); + tabbedPane.addTab(name, null, panel, null); + return panel; + } + + private void applyDefaultLayout(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) { + + GroupLayout gl_panel_html = new GroupLayout(tabbedPanel); + gl_panel_html.setHorizontalGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) + .addGroup(gl_panel_html.createSequentialGroup().addGroup(gl_panel_html.createParallelGroup(Alignment.TRAILING) + .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE).addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, 852, Short.MAX_VALUE)).addGap(4))); + gl_panel_html.setVerticalGroup(gl_panel_html.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, + gl_panel_html.createSequentialGroup() + .addComponent(configPanel, GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))); + tabbedPanel.setLayout(gl_panel_html); + } + +} diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/PreferencesStorage.java b/src/main/java/pro/litvinovg/w2phtml/gui/PreferencesStorage.java new file mode 100644 index 0000000..0caafdb --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/PreferencesStorage.java @@ -0,0 +1,125 @@ +package pro.litvinovg.w2phtml.gui; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.prefs.Preferences; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import static pro.litvinovg.w2phtml.gui.Contstants.*; + + +public class PreferencesStorage { + + private static final Logger logger = LoggerFactory.getLogger(PreferencesStorage.class); + private Map preferences; + + private Preferences storage; + + public PreferencesStorage() { + initializeDefaults(); + storage = Preferences.userRoot(); + } + + private void initializeDefaults() { + preferences = new HashMap(); + initializeDefault(); + } + + private void initializeDefault() { + initializeDefaultHTML(); + initializeDefaultEpub(); + initializeDefaultRDF(); + } + + private void initializeDefaultHTML() { + UIPreferences prefs = new UIPreferences(); + add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs); + add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs); + add(PREF_USE_MATHJAX,"true", prefs); + add(PREF_IGNORE_EMPTY_PARS,"false", prefs); + add(PREF_IGNORE_HARD_BREAKS,"false", prefs); + add(PREF_GREENSTONE_TAGS,"false", prefs); + add(PREF_LETTER_SPACING,"0.15",prefs); + add(PREF_INLINE_STYLES,"true", prefs); + add(PREF_EMBED_RASTER,"true", prefs); + add(PREF_EMBED_VECTOR,"true", prefs); + add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs); + add(PREF_PAGINATION,"true",prefs); + + preferences.put(HTML, prefs); + } + + + private void initializeDefaultEpub() { + UIPreferences prefs = new UIPreferences(); + add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs); + add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs); + add(PREF_USE_MATHJAX,"true", prefs); + add(PREF_IGNORE_EMPTY_PARS,"false", prefs); + add(PREF_IGNORE_HARD_BREAKS,"false", prefs); + add(PREF_LETTER_SPACING,"0.15",prefs); + add(PREF_INLINE_STYLES,"true", prefs); + add(PREF_EMBED_RASTER,"true", prefs); + add(PREF_EMBED_VECTOR,"true", prefs); + add(PREF_SCALING, SCALING_DEFAULT_VALUE, prefs); + add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs); + add(PREF_PAGINATION,"true",prefs); + + preferences.put(EPUB, prefs); + } + + private void initializeDefaultRDF() { + UIPreferences prefs = new UIPreferences(); + add(PREF_PUBLICATION_TYPES, new String[]{"elenphArticle", "encArticle", "book", "journal"} , prefs); + add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs); + add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs); + add(PREF_DEFAULT_PUBLICATION_TYPE,"0", prefs); + add(PREF_USE_MATHJAX,"true", prefs); + add(PREF_IGNORE_EMPTY_PARS,"false", prefs); + add(PREF_IGNORE_HARD_BREAKS,"false", prefs); + add(PREF_LETTER_SPACING,"0.15",prefs); + add(PREF_INLINE_STYLES,"true", prefs); + add(PREF_EMBED_RASTER,"true", prefs); + add(PREF_EMBED_VECTOR,"true", prefs); + add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs); + add(PREF_PAGINATION,"true",prefs); + + preferences.put(RDF, prefs); + } + + private void add(String key, String[] strings,UIPreferences prefs) { + ArrayList values = new ArrayList(Arrays.asList(strings)); + prefs.put(key, values); + } + + private void add(String key, String value,UIPreferences prefs) { + ArrayList values = new ArrayList(); + values.add(value); + prefs.put(key, values); + } + + public UIPreferences get(String name, String type) { + if (preferences.containsKey(name)) { + return preferences.get(name); + } else { + return preferences.get(type); + } + + } + + public void setSourceFileName(String fileName) { + Iterator> it = preferences.entrySet().iterator(); + while (it.hasNext()) { + Entry pair = it.next(); + UIPreferences value = (UIPreferences) pair.getValue(); + value.setSourceFileName(fileName); + } + } +} + + diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/RDFPanel.java b/src/main/java/pro/litvinovg/w2phtml/gui/RDFPanel.java new file mode 100644 index 0000000..b5d8744 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/RDFPanel.java @@ -0,0 +1,273 @@ +package pro.litvinovg.w2phtml.gui; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; + +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; +import static pro.litvinovg.w2phtml.gui.Contstants.*; + + +public class RDFPanel extends BasePanel { + /** + * + */ + private static final long serialVersionUID = 1L; + + public RDFPanel(HashMap configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) { + super(localizer, singleFrame, configuration, preferences); + + JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING)); + JLabel lb_TargetFormat = addTargetFormat(RDF_TARGET_FORMAT); + JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE)); + JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH)); + JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT)); + JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH)); + JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION)); + JLabel lb_type = new JLabel(localizer.getTranslation(LABEL_TYPE)); + JLabel lb_metadataFilePath = new JLabel(localizer.getTranslation(LABEL_METADATA_PATH)); + JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE)); + + JTextField tf_OutputFile = addOutputFileTextField(); + JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(); + JTextField tf_Scale = addScaling(); + JTextField tf_inputFile = addInputFile(); + JTextField tf_metadataPath = addMetadataPath(configuration); + JTextField tf_pageBreakInlineStyle = addPageBreakStyle(); + + JCheckBox cb_UseMathJax = addMathJaxCB(); + JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(); + JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(); + JCheckBox cb_InlineStyles = addInlineStyles(); + cb_InlineStyles.setEnabled(false); + JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(); + cb_EmbedVectorImages.setEnabled(false); + JCheckBox cb_EmbedRaster = addEmbedRasterImages(); + cb_EmbedRaster.setEnabled(false); + JCheckBox cb_convertToPx = addConvertToPX(); + JCheckBox cb_Pagination = addPagination(); + + JComboBox cbox_image_resolution = addImageResolution(); + JComboBox cbox_type = addPubTypes(configuration, preferences); + + JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, RDF_FILE_EXTENSION); + JButton btn_ChooseFile = addChooseFile(localizer, tf_OutputFile, tf_inputFile, tf_metadataPath); + JButton btn_metadataChoose = addMetadataButton(localizer, tf_metadataPath); + + GroupLayout gl_panel_configHTML = new GroupLayout(this); + gl_panel_configHTML.setHorizontalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(32) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 369, GroupLayout.PREFERRED_SIZE) + .addGap(4) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_EmbedRaster) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_EmbedVectorImages) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_FilterLetterSpacing) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addGap(599)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(cb_InlineStyles) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE) + .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE) + .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(tf_metadataPath, GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE) + .addGap(1)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE) + .addGap(3))))) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(11) + .addComponent(btn_ChooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(12) + .addComponent(btn_metadataChoose, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(11) + .addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) + .addGap(149)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE) + .addGap(145)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_type, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE) + .addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) + .addGap(21)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE) + .addContainerGap()))))) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 339, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 344, GroupLayout.PREFERRED_SIZE) + .addContainerGap())))) + ); + gl_panel_configHTML.setVerticalGroup( + gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addContainerGap() + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_TargetFormat_description) + .addComponent(lb_TargetFormat)) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(22) + .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(24) + .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING) + .addComponent(tf_metadataPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) + .addGroup(gl_panel_configHTML.createSequentialGroup() + .addGap(46) + .addComponent(btn_ChooseFile) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(btn_metadataChoose) + .addGap(7) + .addComponent(btn_ChooseOutputFile))) + .addGap(20) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) + .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(18) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_type) + .addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_Scale) + .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_FilterLetterSpacing) + .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(10) + .addComponent(cb_InlineStyles) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_EmbedVectorImages) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_EmbedRaster) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_convertToPx) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_IgnoreHardLineBreaks) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_IgnoreEmptyParagraphs) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(cb_UseMathJax) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(cb_Pagination) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE) + .addComponent(lb_ImageResolution) + .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addContainerGap(87, Short.MAX_VALUE)) + ); + this.setLayout(gl_panel_configHTML); + } + + private JButton addMetadataButton(Localizer localizer, JTextField tf_metadataPath) { + JButton btn_metadataChoose = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); + btn_metadataChoose.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String newFilePath = FileDialog.chooseFile(tf_metadataPath.getText(),CSV_FILE_EXTENSION); + if (newFilePath != null && !newFilePath.isEmpty()) { + tf_metadataPath.setText(newFilePath); + } + } + }); + return btn_metadataChoose; + } + + private JTextField addMetadataPath(HashMap configuration) { + JTextField tf_metadataPath = new JTextField(""); + tf_metadataPath.setColumns(10); + configuration.put(ARG_CSV_METADATA, tf_metadataPath); + return tf_metadataPath; + } + + private JButton addChooseFile(Localizer localizer, JTextField tf_OutputFile, JTextField tf_inputFile, + JTextField tf_metadataPath) { + JButton btnChooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE)); + btnChooseFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); + if (newFilePath != null && !newFilePath.isEmpty()) { + tf_inputFile.setText(newFilePath); + setOutputFilePath(newFilePath,tf_OutputFile,RDF_FILE_EXTENSION); + setMetadataFilePath(newFilePath,tf_metadataPath,CSV_FILE_EXTENSION); + } + } + }); + return btnChooseFile; + } + + private JComboBox addPubTypes(HashMap configuration, UIPreferences preferences) { + JComboBox cbox_type = new JComboBox(preferences.getAll(PREF_PUBLICATION_TYPES)); + cbox_type.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_PUBLICATION_TYPE))); + configuration.put(ARG_RDF_TYPE, cbox_type); + return cbox_type; + } + + +} diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/UIPreferences.java b/src/main/java/pro/litvinovg/w2phtml/gui/UIPreferences.java new file mode 100644 index 0000000..3fb1f61 --- /dev/null +++ b/src/main/java/pro/litvinovg/w2phtml/gui/UIPreferences.java @@ -0,0 +1,60 @@ +package pro.litvinovg.w2phtml.gui; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +public class UIPreferences { + private Map> prefs; + + private String sourceFileName = ""; + + public UIPreferences() { + prefs = new HashMap>(); + } + + public UIPreferences(Map> sourcePrefs) { + Iterator>> it = sourcePrefs.entrySet().iterator(); + while (it.hasNext()) { + Entry> pair = (Entry>) it.next(); + prefs = new HashMap>(); + prefs.put(new String(pair.getKey()), new ArrayList(pair.getValue())); + } + } + + public void put(String name, ArrayListvalues) { + prefs.put(name, values); + } + + public String getSourceFileName() { + return sourceFileName; + } + + public void setSourceFileName(String sourceFileName) { + this.sourceFileName = sourceFileName; + } + + public String[] getAll(String name) { + if (prefs.containsKey(name)) { + return (String[]) prefs.get(name).toArray(new String[0]); + } else { + return new String[0]; + } + } + + public String get(String name) { + if (prefs.containsKey(name)) { + return prefs.get(name).get(0); + } else { + return ""; + } + } + + public UIPreferences clone() { + UIPreferences clonedPrefs = new UIPreferences(prefs); + clonedPrefs.setSourceFileName(sourceFileName); + return clonedPrefs; + } +}