Skip to content

Commit

Permalink
Implemented secondary export formats file/directory. Resolves #294.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtmartensson committed Feb 18, 2024
1 parent da4a9e2 commit b3e5490
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,34 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportFormatsSelectMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator47">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="secondaryExportFormatsEditMenuItem">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/edit.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Open secondary..."/>
<Property name="toolTipText" type="java.lang.String" value="Edit the private export formats file or directory."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryExportFormatsEditMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="secondaryExportFormatsSelectMenuItem">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/fileopen.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Select secondary..."/>
<Property name="toolTipText" type="java.lang.String" value="Select a private export formats file or directory."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryExportFormatsSelectMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator48">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="exportFormatsReloadMenuItem">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
Expand Down
70 changes: 68 additions & 2 deletions src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,13 @@ private void loadExportFormats() throws ParserConfigurationException, SAXExcepti
exportFormatManager.add("Text", () -> newTextExporter());
exportFormatManager.add("ProntoClassic", () -> newProntoClassicExporter());

exportFormatManager.addDynamicFormats(guiUtils, new File(properties.mkPathAbsolute(properties.getExportFormatFilePath())));
addDynamicExportFormats(properties.getExportFormatFilePath());
addDynamicExportFormats(properties.getSecondaryExportFormatFilePath());
}

private void addDynamicExportFormats(String file) throws ParserConfigurationException, SAXException, IOException {
if (!file.isEmpty())
exportFormatManager.addDynamicFormats(guiUtils, new File(properties.mkPathAbsolute(file)));
}

private void setupDecoder() throws IrpParseException {
Expand Down Expand Up @@ -2597,6 +2603,10 @@ private void initComponents() {
exportFormatsMenu = new javax.swing.JMenu();
exportFormatsEditMenuItem = new javax.swing.JMenuItem();
exportFormatsSelectMenuItem = new javax.swing.JMenuItem();
jSeparator47 = new javax.swing.JPopupMenu.Separator();
secondaryExportFormatsEditMenuItem = new javax.swing.JMenuItem();
secondaryExportFormatsSelectMenuItem = new javax.swing.JMenuItem();
jSeparator48 = new javax.swing.JPopupMenu.Separator();
exportFormatsReloadMenuItem = new javax.swing.JMenuItem();
jSeparator20 = new javax.swing.JPopupMenu.Separator();
importOptionsMenu = new javax.swing.JMenu();
Expand Down Expand Up @@ -6705,6 +6715,28 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});
exportFormatsMenu.add(exportFormatsSelectMenuItem);
exportFormatsMenu.add(jSeparator47);

secondaryExportFormatsEditMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/edit.png"))); // NOI18N
secondaryExportFormatsEditMenuItem.setText("Open secondary...");
secondaryExportFormatsEditMenuItem.setToolTipText("Edit the private export formats file or directory.");
secondaryExportFormatsEditMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
secondaryExportFormatsEditMenuItemActionPerformed(evt);
}
});
exportFormatsMenu.add(secondaryExportFormatsEditMenuItem);

secondaryExportFormatsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/fileopen.png"))); // NOI18N
secondaryExportFormatsSelectMenuItem.setText("Select secondary...");
secondaryExportFormatsSelectMenuItem.setToolTipText("Select a private export formats file or directory.");
secondaryExportFormatsSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
secondaryExportFormatsSelectMenuItemActionPerformed(evt);
}
});
exportFormatsMenu.add(secondaryExportFormatsSelectMenuItem);
exportFormatsMenu.add(jSeparator48);

exportFormatsReloadMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/reload.png"))); // NOI18N
exportFormatsReloadMenuItem.setText("Reload");
Expand Down Expand Up @@ -9326,7 +9358,7 @@ private void secondaryIrpProtocolsSelectMenuItemActionPerformed(java.awt.event.A
File f = SelectFile.selectFile(this, "Select secondary protocol file", selectorStartDir, false, false, "XML files (*.xml)", "xml");
if (f == null)
return;
if (f.toString().equals("/dev/null") || f.toString().equalsIgnoreCase("NULL:")) {
if (f.toString().equals("/dev/null") || f.getName().equalsIgnoreCase("NULL:")) {
properties.setSecondaryIrpProtocolsPath("");
guiUtils.message("secondary IrpProtocol was removed.");
} else {
Expand Down Expand Up @@ -9361,6 +9393,36 @@ private void irpProtocolsReloadMenuItemActionPerformed(java.awt.event.ActionEven
}
}//GEN-LAST:event_irpProtocolsReloadMenuItemActionPerformed

private void secondaryExportFormatsEditMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondaryExportFormatsEditMenuItemActionPerformed
try {
String secondary = properties.getSecondaryExportFormatFilePath();
if (secondary.isEmpty()) {
guiUtils.error("No secondary export format selected. Nothing to edit.");
return;
}
guiUtils.open(new File(properties.mkPathAbsolute(secondary)));
guiUtils.warning("If editing, changes will not take effect before reloading.");
} catch (IOException ex) {
guiUtils.error(ex);
}
}//GEN-LAST:event_secondaryExportFormatsEditMenuItemActionPerformed

private void secondaryExportFormatsSelectMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondaryExportFormatsSelectMenuItemActionPerformed
String secondary = properties.getSecondaryExportFormatFilePath();
String selectorStartDir = secondary.isEmpty() ? System.getProperty("user.home") : new File(properties.mkPathAbsolute(secondary)).getParent();
File f = SelectFile.selectFile(this, "Select secondary export format file/directory", selectorStartDir, false, false, JFileChooser.FILES_AND_DIRECTORIES, "XML files (*.xml)", "xml");

if (f == null)
return;
if (f.toString().equals("/dev/null") || f.getName().equalsIgnoreCase("NULL:")) {
properties.setSecondaryExportFormatFilePath("");
guiUtils.message("secondary export format removed.");
} else {
properties.setSecondaryExportFormatFilePath(f.getAbsolutePath());
}
loadExportFormatsGuiRefresh();
}//GEN-LAST:event_secondaryExportFormatsSelectMenuItemActionPerformed

private void tableKeyReleased(JTable table, KeyEvent evt) {
if (evt.getModifiersEx() == java.awt.event.InputEvent.CTRL_DOWN_MASK
&& evt.getExtendedKeyCode() == java.awt.event.KeyEvent.VK_F ) {
Expand Down Expand Up @@ -9689,6 +9751,8 @@ private void tableKeyReleased(JTable table, KeyEvent evt) {
private javax.swing.JPopupMenu.Separator jSeparator44;
private javax.swing.JPopupMenu.Separator jSeparator45;
private javax.swing.JPopupMenu.Separator jSeparator46;
private javax.swing.JPopupMenu.Separator jSeparator47;
private javax.swing.JPopupMenu.Separator jSeparator48;
private javax.swing.JPopupMenu.Separator jSeparator5;
private javax.swing.JPopupMenu.Separator jSeparator6;
private javax.swing.JPopupMenu.Separator jSeparator7;
Expand Down Expand Up @@ -9829,6 +9893,8 @@ private void tableKeyReleased(JTable table, KeyEvent evt) {
private javax.swing.JMenuItem scrutinizeSignalProtocolDocuMenuItem;
private javax.swing.JMenuItem searchParametrizedMenuItem;
private javax.swing.JMenuItem searchRawMenuItem;
private javax.swing.JMenuItem secondaryExportFormatsEditMenuItem;
private javax.swing.JMenuItem secondaryExportFormatsSelectMenuItem;
private javax.swing.JMenuItem secondaryIrpProtocolsEditMenuItem;
private javax.swing.JMenuItem secondaryIrpProtocolsSelectMenuItem;
private javax.swing.JMenuItem sendMenuItem;
Expand Down
3 changes: 1 addition & 2 deletions src/main/xml/Props.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ this program. If not, see http://www.gnu.org/licenses/.

<!-- All relative file names are relative to IRSCRUTINIZERHOME = applicationHome -->
<properties package="org.harctoolbox.irscrutinizer" useXml = "true" appName="Version.appName" home-environment-var="IRSCRUTINIZERHOME">
<import class="org.harctoolbox.harchardware.ir.IrTrans"/>
<!--import class="org.harctoolbox.harchardware.ir.LircClient"/-->
<import class="org.harctoolbox.ircore.IrCoreUtils"/>
<import class="org.harctoolbox.ircore.IrSequence"/>
<property name="autoOpenExports" type="boolean" default='"false"' />
Expand Down Expand Up @@ -66,6 +64,7 @@ this program. If not, see http://www.gnu.org/licenses/.
<property name="exportDir" type="string" default='System.getProperty("user.home") + File.separator + "Documents" + File.separator + "IrScrutinizer"' doc='Directory to which to write exports.'/>
<property name="defaultImportDir" type="string" default='"testfiles"' doc='Just the starting directory for file selectors.'/>
<property name="exportFormatFilePath" type="string" default='"exportformats.d"' doc='File or directory containing export format descriptions.'/>
<property name="secondaryExportFormatFilePath" type="string" default='""' doc='Path to secondary export formats (file or directory).' />
<property name="exportFormatName" type="string" default='"Girr"' doc='Name of currenty selected export file format' />
<property name="globalCacheIpName" type="string" default='org.harctoolbox.harchardware.ir.GlobalCache.DEFAULT_IP' doc="IP Name or Address of GlobalCache to use (transmitting)."/>
<property name="globalCacheModule" type="int" default='"2"' doc='Module number of Global Cache to use, see its documentation.'/>
Expand Down

0 comments on commit b3e5490

Please sign in to comment.