Skip to content

Commit 643e461

Browse files
GUI option for removing secondary IRP data base. Resolves #540 .
Some tweaks on icons and texts.
1 parent 2125be8 commit 643e461

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@
19591959
<MenuItem class="javax.swing.JMenuItem" name="irpProtocolsSelectMenuItem">
19601960
<Properties>
19611961
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
1962-
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/fileopen.png"/>
1962+
<Image iconType="3" name="/icons/Crystal-Clear/22x22/apps/database.png"/>
19631963
</Property>
19641964
<Property name="text" type="java.lang.String" value="Select..."/>
19651965
<Property name="toolTipText" type="java.lang.String" value="Select IrpProtocols.xml to use."/>
@@ -1985,7 +1985,7 @@
19851985
<MenuItem class="javax.swing.JMenuItem" name="secondaryIrpProtocolsSelectMenuItem">
19861986
<Properties>
19871987
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
1988-
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/fileopen.png"/>
1988+
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/db_add.png"/>
19891989
</Property>
19901990
<Property name="text" type="java.lang.String" value="Select secondary..."/>
19911991
<Property name="toolTipText" type="java.lang.String" value="Select a private version of IrpProtocols. to extend the standard one."/>
@@ -2006,14 +2006,29 @@
20062006
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryIrpProtocolsEditMenuItemActionPerformed"/>
20072007
</Events>
20082008
</MenuItem>
2009+
<MenuItem class="javax.swing.JMenuItem" name="secondaryRemoveMenuItem">
2010+
<Properties>
2011+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
2012+
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/db_remove.png"/>
2013+
</Property>
2014+
<Property name="text" type="java.lang.String" value="Remove secondary"/>
2015+
<Property name="toolTipText" type="java.lang.String" value="Remove the secondary data base. Does not delete any disk files."/>
2016+
</Properties>
2017+
<Events>
2018+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="secondaryRemoveMenuItemActionPerformed"/>
2019+
</Events>
2020+
<AuxValues>
2021+
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="secondaryRemoveMenuItem.setEnabled(!properties.getSecondaryIrpProtocolsPath().isEmpty());&#xa;"/>
2022+
</AuxValues>
2023+
</MenuItem>
20092024
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator46">
20102025
</MenuItem>
20112026
<MenuItem class="javax.swing.JMenuItem" name="irpProtocolsReloadMenuItem">
20122027
<Properties>
20132028
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
20142029
<Image iconType="3" name="/icons/Crystal-Clear/22x22/actions/reload.png"/>
20152030
</Property>
2016-
<Property name="text" type="java.lang.String" value="Reload"/>
2031+
<Property name="text" type="java.lang.String" value="Reload IRP data base"/>
20172032
</Properties>
20182033
<Events>
20192034
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="irpProtocolsReloadMenuItemActionPerformed"/>

src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ private void setupIrpDatabase() throws IOException, IrpParseException, SAXExcept
348348

349349
irpDatabase = new IrpDatabase(configFiles);
350350
Command.setIrpDatabase(irpDatabase);
351+
properties.addSecondaryIrpProtocolsPathChangeListener((String name1, Object oldValue, Object newValue) -> {
352+
secondaryRemoveMenuItem.setEnabled(!((String) newValue).isEmpty());
353+
});
351354
}
352355

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

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

6569-
secondaryIrpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/fileopen.png"))); // NOI18N
6573+
secondaryIrpProtocolsSelectMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/db_add.png"))); // NOI18N
65706574
secondaryIrpProtocolsSelectMenuItem.setText("Select secondary...");
65716575
secondaryIrpProtocolsSelectMenuItem.setToolTipText("Select a private version of IrpProtocols. to extend the standard one.");
65726576
secondaryIrpProtocolsSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
@@ -6585,10 +6589,21 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
65856589
}
65866590
});
65876591
irpProtocolsIniMenu.add(secondaryIrpProtocolsEditMenuItem);
6592+
6593+
secondaryRemoveMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/db_remove.png"))); // NOI18N
6594+
secondaryRemoveMenuItem.setText("Remove secondary");
6595+
secondaryRemoveMenuItem.setToolTipText("Remove the secondary data base. Does not delete any disk files.");
6596+
secondaryRemoveMenuItem.setEnabled(!properties.getSecondaryIrpProtocolsPath().isEmpty());
6597+
secondaryRemoveMenuItem.addActionListener(new java.awt.event.ActionListener() {
6598+
public void actionPerformed(java.awt.event.ActionEvent evt) {
6599+
secondaryRemoveMenuItemActionPerformed(evt);
6600+
}
6601+
});
6602+
irpProtocolsIniMenu.add(secondaryRemoveMenuItem);
65886603
irpProtocolsIniMenu.add(jSeparator46);
65896604

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

9248+
private void secondaryRemoveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondaryRemoveMenuItemActionPerformed
9249+
properties.setSecondaryIrpProtocolsPath("");
9250+
guiUtils.message("Secondary IrpProtocol file removed.");
9251+
}//GEN-LAST:event_secondaryRemoveMenuItemActionPerformed
9252+
92329253
private void tableKeyReleased(JTable table, KeyEvent evt) {
92339254
if (evt.getModifiersEx() == java.awt.event.InputEvent.CTRL_DOWN_MASK
92349255
&& evt.getExtendedKeyCode() == java.awt.event.KeyEvent.VK_F ) {
@@ -9692,6 +9713,7 @@ private void tableKeyReleased(JTable table, KeyEvent evt) {
96929713
private javax.swing.JMenuItem secondaryExportFormatsSelectMenuItem;
96939714
private javax.swing.JMenuItem secondaryIrpProtocolsEditMenuItem;
96949715
private javax.swing.JMenuItem secondaryIrpProtocolsSelectMenuItem;
9716+
private javax.swing.JMenuItem secondaryRemoveMenuItem;
96959717
private javax.swing.JMenuItem sendMenuItem;
96969718
private javax.swing.JButton sendingCommandFusionHelpButton;
96979719
private javax.swing.JButton sendingDevLircHardwareHelpButton;

0 commit comments

Comments
 (0)