106
106
import org.harctoolbox.remotelocator.NotFoundException;
107
107
import org.xml.sax.SAXException;
108
108
109
+ @SuppressWarnings("serial")
109
110
public final class GuiMain extends javax.swing.JFrame {
110
111
111
112
private final static String ISSUES_URL = "https://github.com/bengtmartensson/IrScrutinizer/issues";
@@ -225,14 +226,12 @@ public GuiMain(String applicationHome, String propsfilename, boolean verbose, Li
225
226
loadLibraries();
226
227
setupGuiUtils();
227
228
setupTables();
228
- setupIrpDatabase (); // must come before initComponents
229
+ setupIrpDatabaseAndDecoder (); // must come before initComponents
229
230
setupImporters();
230
- setupDecoder();
231
231
loadExportFormats(); // must come before initComponents
232
232
initComponents();
233
233
if (!LircHardware.isLibraryLoaded())
234
234
sendingHardwareTabbedPane.remove(devLircPanel);
235
- girrImporter.setIrpRendererBean(irpMasterBean);
236
235
tweakTables();
237
236
tweakFrame();
238
237
setupRepeatFinder();
@@ -253,7 +252,7 @@ public GuiMain(String applicationHome, String propsfilename, boolean verbose, Li
253
252
* @throws IOException
254
253
* @throws ParserConfigurationException
255
254
* @throws SAXException
256
- * @throws IrpParseException
255
+ * @throws IrpParseException
257
256
*/
258
257
GuiMain() throws IOException, ParserConfigurationException, SAXException, IrpParseException {
259
258
this(System.getProperty("user.dir") + "/target");
@@ -339,18 +338,24 @@ private void setupTables() {
339
338
tableUtils = new TableUtils(guiUtils);
340
339
}
341
340
342
- private void setupIrpDatabase () throws IOException, IrpParseException, SAXException {
341
+ private void setupIrpDatabaseAndDecoder () throws IOException, IrpParseException, SAXException {
343
342
List<File> configFiles = new ArrayList<>(4);
344
343
configFiles.add(new File(properties.mkPathAbsolute(properties.getIrpProtocolsPath())));
345
344
String secondary = properties.getSecondaryIrpProtocolsPath();
346
345
if (!secondary.isEmpty())
347
346
configFiles.add(new File(secondary));
348
347
349
- irpDatabase = new IrpDatabase(configFiles);
350
- Command.setIrpDatabase(irpDatabase);
348
+ IrpDatabase newIrpDatabase = new IrpDatabase(configFiles);
351
349
properties.addSecondaryIrpProtocolsPathChangeListener((String name1, Object oldValue, Object newValue) -> {
352
- secondaryRemoveMenuItem.setEnabled(!((String ) newValue).isEmpty());
350
+ secondaryRemoveMenuItem.setEnabled(!((CharSequence ) newValue).isEmpty());
353
351
});
352
+ setupIrpDatabaseAndDecoder(newIrpDatabase);
353
+ }
354
+
355
+ private void setupIrpDatabaseAndDecoder(IrpDatabase newIrpDatabase) throws IrpParseException {
356
+ irpDatabase = newIrpDatabase;
357
+ setupDecoder();
358
+ Command.setIrpDatabase(irpDatabase);
354
359
}
355
360
356
361
private void setupImporters() throws MalformedURLException, IrpParseException {
@@ -473,7 +478,7 @@ private void setupIctImporter() {
473
478
474
479
private void setupGirrImporter() throws MalformedURLException {
475
480
Command.setAcceptEmptyCommands(properties.getAllowEmptyGirrCommands());
476
- girrImporter = new GirrImporter(properties.getGirrValidate(), new URL(properties.getGirrSchemaLocation()), irpDatabase );
481
+ girrImporter = new GirrImporter(properties.getGirrValidate(), new URL(properties.getGirrSchemaLocation()), this );
477
482
properties.addGirrSchemaLocationChangeListener((String name1, Object oldValue, Object newValue) -> {
478
483
try {
479
484
girrImporter.setUrl(new URL((String)newValue));
@@ -1452,7 +1457,7 @@ private void scrutinizeSignal() {
1452
1457
guiUtils.error("Unspecified error: \"" + ex.getMessage() + "\", please report.");
1453
1458
}
1454
1459
}
1455
-
1460
+
1456
1461
/**
1457
1462
* Invoke the decoding on the string given as argument.
1458
1463
* Meant for testing only-
@@ -1485,10 +1490,6 @@ GuiUtils getGuiUtils() {
1485
1490
return guiUtils;
1486
1491
}
1487
1492
1488
- IrpDatabase getIrpDatabase() {
1489
- return this.irpDatabase;
1490
- }
1491
-
1492
1493
private void updateOutputFormat(OutputTextFormat format) {
1493
1494
updateOutputFormat(format.ordinal());
1494
1495
}
@@ -2148,6 +2149,19 @@ private void transformNameActionPerformed(javax.swing.JTable table, NamedIrSigna
2148
2149
model.namesTransform(transformation, rows);
2149
2150
}
2150
2151
2152
+ public void patchProtocols(IrpDatabase newProtocols) {
2153
+ if (newProtocols.isEmpty())
2154
+ return;
2155
+ irpDatabase.patch(newProtocols);
2156
+ irpMasterBean.updateProtocols();
2157
+ try {
2158
+ setupDecoder();
2159
+ Command.setIrpDatabase(irpDatabase);
2160
+ } catch (IrpParseException ex) {
2161
+ guiUtils.error(ex);
2162
+ }
2163
+ }
2164
+
2151
2165
/**
2152
2166
* This method is called from within the constructor to initialize the form.
2153
2167
* WARNING: Do NOT modify this code. The content of this method is always
@@ -7045,6 +7059,7 @@ private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN
7045
7059
aboutBox = new AboutPopup(this, false);
7046
7060
aboutBox.setLocationRelativeTo(this);
7047
7061
}
7062
+ aboutBox.setVersion(irpDatabase.getVersion());
7048
7063
aboutBox.setVisible(true);
7049
7064
}//GEN-LAST:event_aboutMenuItemActionPerformed
7050
7065
@@ -8104,7 +8119,7 @@ private void irpProtocolsSelectMenuItemActionPerformed(java.awt.event.ActionEven
8104
8119
8105
8120
properties.setIrpProtocolsPath(f.getAbsolutePath());
8106
8121
try {
8107
- setupIrpDatabase ();
8122
+ setupIrpDatabaseAndDecoder ();
8108
8123
} catch (IOException | IrpParseException | SAXException ex) {
8109
8124
guiUtils.error(ex);
8110
8125
}
@@ -9183,7 +9198,7 @@ private void secondaryIrpProtocolsSelectMenuItemActionPerformed(java.awt.event.A
9183
9198
guiUtils.message("Secondary IrpProtocol file set to " + f.getAbsolutePath() + ".");
9184
9199
}
9185
9200
try {
9186
- setupIrpDatabase ();
9201
+ setupIrpDatabaseAndDecoder ();
9187
9202
} catch (IOException | IrpParseException | SAXException ex) {
9188
9203
guiUtils.error(ex);
9189
9204
}
@@ -9205,7 +9220,7 @@ private void secondaryIrpProtocolsEditMenuItemActionPerformed(java.awt.event.Act
9205
9220
9206
9221
private void irpProtocolsReloadMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_irpProtocolsReloadMenuItemActionPerformed
9207
9222
try {
9208
- setupIrpDatabase ();
9223
+ setupIrpDatabaseAndDecoder ();
9209
9224
} catch (IOException | IrpParseException | SAXException ex) {
9210
9225
guiUtils.error(ex);
9211
9226
}
0 commit comments