Skip to content

Commit

Permalink
GUI option for removing secondary IRP data base. Resolves #540 .
Browse files Browse the repository at this point in the history
Some tweaks on icons and texts.
  • Loading branch information
bengtmartensson committed Nov 5, 2024
1 parent 2125be8 commit 643e461
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
21 changes: 18 additions & 3 deletions src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@
<MenuItem class="javax.swing.JMenuItem" name="irpProtocolsSelectMenuItem">
<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"/>
<Image iconType="3" name="/icons/Crystal-Clear/22x22/apps/database.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Select..."/>
<Property name="toolTipText" type="java.lang.String" value="Select IrpProtocols.xml to use."/>
Expand All @@ -1985,7 +1985,7 @@
<MenuItem class="javax.swing.JMenuItem" name="secondaryIrpProtocolsSelectMenuItem">
<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"/>
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/db_add.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Select secondary..."/>
<Property name="toolTipText" type="java.lang.String" value="Select a private version of IrpProtocols. to extend the standard one."/>
Expand All @@ -2006,14 +2006,29 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryIrpProtocolsEditMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="secondaryRemoveMenuItem">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/db_remove.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Remove secondary"/>
<Property name="toolTipText" type="java.lang.String" value="Remove the secondary data base. Does not delete any disk files."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryRemoveMenuItemActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="secondaryRemoveMenuItem.setEnabled(!properties.getSecondaryIrpProtocolsPath().isEmpty());&#xa;"/>
</AuxValues>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator46">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="irpProtocolsReloadMenuItem">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/reload.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Reload"/>
<Property name="text" type="java.lang.String" value="Reload IRP data base"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="irpProtocolsReloadMenuItemActionPerformed"/>
Expand Down
30 changes: 26 additions & 4 deletions src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ private void setupIrpDatabase() throws IOException, IrpParseException, SAXExcept

irpDatabase = new IrpDatabase(configFiles);
Command.setIrpDatabase(irpDatabase);
properties.addSecondaryIrpProtocolsPathChangeListener((String name1, Object oldValue, Object newValue) -> {
secondaryRemoveMenuItem.setEnabled(!((String) newValue).isEmpty());
});
}

private void setupImporters() throws MalformedURLException, IrpParseException {
Expand Down Expand Up @@ -2610,6 +2613,7 @@ private void initComponents() {
jSeparator45 = new javax.swing.JPopupMenu.Separator();
secondaryIrpProtocolsSelectMenuItem = new javax.swing.JMenuItem();
secondaryIrpProtocolsEditMenuItem = new javax.swing.JMenuItem();
secondaryRemoveMenuItem = new javax.swing.JMenuItem();
jSeparator46 = new javax.swing.JPopupMenu.Separator();
irpProtocolsReloadMenuItem = new javax.swing.JMenuItem();
exportFormatsMenu = new javax.swing.JMenu();
Expand Down Expand Up @@ -6545,7 +6549,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
irpProtocolsIniMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/apps/database.png"))); // NOI18N
irpProtocolsIniMenu.setText("IRP protocol database");

irpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/fileopen.png"))); // NOI18N
irpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/apps/database.png"))); // NOI18N
irpProtocolsSelectMenuItem.setText("Select...");
irpProtocolsSelectMenuItem.setToolTipText("Select IrpProtocols.xml to use.");
irpProtocolsSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
Expand All @@ -6566,7 +6570,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
irpProtocolsIniMenu.add(irpProtocolsEditMenuItem);
irpProtocolsIniMenu.add(jSeparator45);

secondaryIrpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/fileopen.png"))); // NOI18N
secondaryIrpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/db_add.png"))); // NOI18N
secondaryIrpProtocolsSelectMenuItem.setText("Select secondary...");
secondaryIrpProtocolsSelectMenuItem.setToolTipText("Select a private version of IrpProtocols. to extend the standard one.");
secondaryIrpProtocolsSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
Expand All @@ -6585,10 +6589,21 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});
irpProtocolsIniMenu.add(secondaryIrpProtocolsEditMenuItem);

secondaryRemoveMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/db_remove.png"))); // NOI18N
secondaryRemoveMenuItem.setText("Remove secondary");
secondaryRemoveMenuItem.setToolTipText("Remove the secondary data base. Does not delete any disk files.");
secondaryRemoveMenuItem.setEnabled(!properties.getSecondaryIrpProtocolsPath().isEmpty());
secondaryRemoveMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
secondaryRemoveMenuItemActionPerformed(evt);
}
});
irpProtocolsIniMenu.add(secondaryRemoveMenuItem);
irpProtocolsIniMenu.add(jSeparator46);

irpProtocolsReloadMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/reload.png"))); // NOI18N
irpProtocolsReloadMenuItem.setText("Reload");
irpProtocolsReloadMenuItem.setText("Reload IRP data base");
irpProtocolsReloadMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
irpProtocolsReloadMenuItemActionPerformed(evt);
Expand Down Expand Up @@ -9162,9 +9177,10 @@ private void secondaryIrpProtocolsSelectMenuItemActionPerformed(java.awt.event.A
return;
if (f.toString().equals("/dev/null") || f.getName().equalsIgnoreCase("NULL:")) {
properties.setSecondaryIrpProtocolsPath("");
guiUtils.message("secondary IrpProtocol was removed.");
guiUtils.message("Secondary IrpProtocol file removed.");
} else {
properties.setSecondaryIrpProtocolsPath(f.getAbsolutePath());
guiUtils.message("Secondary IrpProtocol file set to " + f.getAbsolutePath() + ".");
}
try {
setupIrpDatabase();
Expand Down Expand Up @@ -9229,6 +9245,11 @@ private void ControlTowerBrowserMenuItemActionPerformed(java.awt.event.ActionEve
HarcletFrame.newHarcletFrame(this, new ControlTowerBrowser(), false, lookAndFeelManager.getCurrentLAFClassName());
}//GEN-LAST:event_ControlTowerBrowserMenuItemActionPerformed

private void secondaryRemoveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondaryRemoveMenuItemActionPerformed
properties.setSecondaryIrpProtocolsPath("");
guiUtils.message("Secondary IrpProtocol file removed.");
}//GEN-LAST:event_secondaryRemoveMenuItemActionPerformed

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 @@ -9692,6 +9713,7 @@ private void tableKeyReleased(JTable table, KeyEvent evt) {
private javax.swing.JMenuItem secondaryExportFormatsSelectMenuItem;
private javax.swing.JMenuItem secondaryIrpProtocolsEditMenuItem;
private javax.swing.JMenuItem secondaryIrpProtocolsSelectMenuItem;
private javax.swing.JMenuItem secondaryRemoveMenuItem;
private javax.swing.JMenuItem sendMenuItem;
private javax.swing.JButton sendingCommandFusionHelpButton;
private javax.swing.JButton sendingDevLircHardwareHelpButton;
Expand Down

0 comments on commit 643e461

Please sign in to comment.