Skip to content

Commit

Permalink
Export: now only inquire for metadata when necessary. (#89)
Browse files Browse the repository at this point in the history
Exportformats: new function supportsMetaData. Changes in exportformats.xsd,
and exportformats.xml.
  • Loading branch information
bengtmartensson committed Jun 27, 2016
1 parent 74a33bd commit 8b02c3a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion IrScrutinizer/src/main/config/exportformats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ carrier_frequency </xsl:text>
</xsl:stylesheet>
</exportformats:exportformat>

<exportformats:exportformat name="irplus" extension="irplus" multiSignal="true" simpleSequence="false">
<exportformats:exportformat name="irplus" extension="irplus" multiSignal="true" simpleSequence="false" metadata="true">
<xsl:stylesheet xmlns:girr="http://www.harctoolbox.org/Girr" exclude-result-prefixes="girr"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ private HashMap<String, Command> getCommands(NamedIrSignal.LearnedIrSignalTableM
}

private File saveCommands(HashMap<String, Command> commands, String source, String title, RemoteSetExporter exporter) throws FileNotFoundException, IrpMasterException, IOException {
if (properties.getExportInquireDeviceData()) {
if (properties.getExportInquireDeviceData() && exporter.supportsMetaData()) {
Remote.MetaData newMetaData = MetaDataDialog.inquireMetaData(metaData, this);
if (newMetaData == null) // user bailed out
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class DynamicRemoteSetExportFormat extends RemoteSetExporter implements I
private final String extension;
private final boolean simpleSequence;
private final boolean binary;
private final boolean metadata;
private final Document xslt;

private DynamicRemoteSetExportFormat(Element el) {
Expand All @@ -59,6 +60,7 @@ private DynamicRemoteSetExportFormat(Element el) {
this.extension = el.getAttribute("extension");
this.simpleSequence = Boolean.parseBoolean(el.getAttribute("simpleSequence"));
this.binary = Boolean.parseBoolean(el.getAttribute("binary"));
this.metadata = Boolean.parseBoolean(el.getAttribute("metadata"));

xslt = XmlUtils.newDocument(true);
Node stylesheet = el.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "stylesheet").item(0);
Expand Down Expand Up @@ -113,6 +115,11 @@ public String getPreferredFileExtension() {
return extension;
}

@Override
public boolean supportsMetaData() {
return metadata;
}

@Override
public void export(RemoteSet remoteSet, String title, int count, File saveFile, String charsetName) throws IOException, IrpMasterException {
export(remoteSet, title, count, saveFile.getCanonicalPath(), charsetName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ public String getFormatName() {
public boolean supportsEmbeddedFormats() {
return true;
}

@Override
public boolean supportsMetaData() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public String getFormatName() {
return "LIRC";
}

@Override
public boolean supportsMetaData() {
return true;
}

// Jirc's definition of Lirc names:
// ('!' .. '{' | '}' .. '~' | '\u00A1' .. '\u00FF')+
private static String lircName(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ public boolean supportsEmbeddedFormats() {
public boolean considersRepetitions() {
return false;
}

public boolean supportsMetaData() {
return false;
}
}
5 changes: 5 additions & 0 deletions IrScrutinizer/src/main/schemas/exportformats.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<xs:documentation>True if the files are binary files.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="metadata" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>True if the format support remote meta data (not necessarily all).</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>

Expand Down
5 changes: 5 additions & 0 deletions schemas/exportformats.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<xs:documentation>True if the files are binary files.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="metadata" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>True if the format support remote meta data (not necessarily all).</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>

Expand Down

0 comments on commit 8b02c3a

Please sign in to comment.