From 9eab64a32b0df0d5aca966a64569c48b79cc4fbd Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 12 Dec 2019 17:13:30 +0000 Subject: [PATCH] JAL-3447 Satisfactory file associations. cif, mcif and pdb now not opened by Jalview by default -- but are associated. In Windows and linux installer, are deselected by default. 'jalview://' as a URL scheme now associated in Windows and macOS. --- utils/install4j/auto_file_associations-i4j8.pl | 105 +++---- .../file_associations_auto-Info_plist.xml | 108 +++---- .../file_associations_auto-install4j8.xml | 329 +++++++++++--------- .../file_associations_template-Info_plist.xml | 4 +- .../file_associations_template-install4j8.xml | 7 +- utils/install4j/install4j8_template.install4j | 81 ++--- 6 files changed, 305 insertions(+), 329 deletions(-) diff --git a/utils/install4j/auto_file_associations-i4j8.pl b/utils/install4j/auto_file_associations-i4j8.pl index df04a6a..c418aad 100755 --- a/utils/install4j/auto_file_associations-i4j8.pl +++ b/utils/install4j/auto_file_associations-i4j8.pl @@ -47,6 +47,8 @@ my $add_extensions = { }; my @put_first = qw(jalview jvl); +my @non_primary = qw(mmcif mmcif2 pdb); + my $v = ($i4jversion >= 8)?$i4jversion:""; my $i4jtemplatefile = "file_associations_template-install4j${v}.xml"; my $i4jtemplate; @@ -72,6 +74,11 @@ $macautofile =~ s/template/auto$1/; my $i4jautofile = $i4jtemplatefile; $i4jautofile =~ s/template/auto$1/; +for my $key (sort keys %$add_associations) { + my $a = $add_associations->{$key}; + warn("Known file association for $a->{shortname} (".join(",",@{$a->{extensions}}).")\n"); +} + open(MA,">$macautofile") or die ("Could not open '$macautofile' for writing"); print MA "CFBundleDocumentTypes\n\n\n"; @@ -106,7 +113,7 @@ while(my $line = ) { name => $name, extensions => \@extensions }; - warn("Adding file association for $shortname (".join(",",@extensions).")\n"); + warn("Reading file association for $shortname (".join(",",@extensions).")\n"); } } close(IN); @@ -115,7 +122,7 @@ my %all_associations = (%$file_associations, %$add_associations); my $num = 0; my $i4jcount = 0; -my @ordered = @put_first; +my @ordered = (@put_first, @non_primary); for my $key (sort keys %all_associations) { next if grep($_ eq $key, @ordered); push(@ordered, $key); @@ -127,16 +134,10 @@ for my $key (@ordered) { my $extensions = $a->{extensions}; my @extensions = @$extensions; - # multiple extensions now all dealt with together since i4j 8.0.1 - #for my $ext (@extensions) { - # $num++; - #} $num++ - - #delete $all_associations{$shortname}; - #print "NUM: $num\n"; } +warn("--\n"); for my $shortname (@ordered) { my $a = $all_associations{$shortname}; @@ -146,24 +147,30 @@ for my $shortname (@ordered) { my $extensions = $a->{extensions}; my $mimetype = $mimetypes->{$shortname}; $mimetype = "application/x-$shortname+txt" unless $mimetype; - #$mimetype = "application/x-$shortname" unless $mimetype; my $iconfile = $a->{iconfile}; $iconfile = "Jalview-File" unless $iconfile; + my $primary = (! grep($_ eq $shortname, @non_primary)); + my $primarystring = $primary?"true":"false"; + my $role = $primary?"Editor":"Viewer"; + my @extensions = @$extensions; - #warn("LINE: $line\nFound extensions '".join("', '", @extensions)."' for $name Files ($shortname)'n"); my $xname = xml_escape($name); my $xmimetype = xml_escape($mimetype); my $xshortname = xml_escape($shortname); my $xiconfile = xml_escape($iconfile); + my $xrole = xml_escape($role); + my $xprimarystring = xml_escape($primarystring); my $macentry = $mactemplate; $macentry =~ s/\$\$NAME\$\$/$xname/g; $macentry =~ s/\$\$SHORTNAME\$\$/$xshortname/g; $macentry =~ s/\$\$MIMETYPE\$\$/$xmimetype/g; $macentry =~ s/\$\$ICONFILE\$\$/$xiconfile/g; + $macentry =~ s/\$\$ROLE\$\$/$xrole/g; + $macentry =~ s/\$\$PRIMARY\$\$/$xprimarystring/g; while ($macentry =~ m/\$\$([^\$]*)EXTENSIONS([^\$]*)\$\$/) { my $pre = $1; my $post = $2; @@ -181,73 +188,53 @@ for my $shortname (@ordered) { $i4jentry =~ s/\$\$SHORTNAME\$\$/$xshortname/g; $i4jentry =~ s/\$\$MIMETYPE\$\$/$xmimetype/g; $i4jentry =~ s/\$\$ICONFILE\$\$/$xiconfile/g; - -# multiple extensions now all dealt with together since i4j 8.0.1 -# my $unixext; -# for my $ext (sort @extensions) { -# if (not defined($unixext)) { -# $unixext = $ext; -# next; -# } -# if (length($ext) < length($unixext)) { -# $unixext = $ext; -# next; -# } -# } -# for my $ext (@extensions) { -# $i4jcount++; -# #print "COUNT: $i4jcount\n"; -# my $progresspercent = int(($i4jcount/$num)*100); -# #print "PC: $progresspercent\n"; -# $progresspercent = 100 if $progresspercent > 100; -# my $xext = xml_escape($ext); -# my $addunixextension = ($ext eq $unixext)?"true":"false"; -# -# my $i4jextentry = $i4jentry; -# $i4jextentry =~ s/\$\$ADDUNIXEXTENSION\$\$/$addunixextension/g; -# $i4jextentry =~ s/\$\$EXTENSION\$\$/$xext/g; -# $i4jextentry =~ s/\$\$PROGRESSPERCENT\$\$/$progresspercent/g; -# $i4jextentry =~ s/\$\$ID\$\$/$id/g; -# $id++; -# $i4jextentry =~ s/\$\$ID1\$\$/$id/g; -# $id++; -# $i4jextentry =~ s/\$\$ID2\$\$/$id/g; -# $id++; -# -# print IA $i4jextentry; -# } + $i4jentry =~ s/\$\$PRIMARY\$\$/$xprimarystring/g; my $ext = join(",",sort(@extensions)); my $xdisplayext = xml_escape(join(", ", map(".$_",sort(@extensions)))); $i4jcount++; -#print "COUNT: $i4jcount\n"; my $progresspercent = int(($i4jcount/$num)*100); -#print "PC: $progresspercent\n"; $progresspercent = 100 if $progresspercent > 100; my $xext = xml_escape($ext); - #my $addunixextension = ($ext eq $unixext)?"true":"false"; my $addunixextension = "true"; - my $i4jextentry = $i4jentry; - $i4jextentry =~ s/\$\$ADDUNIXEXTENSION\$\$/$addunixextension/g; - $i4jextentry =~ s/\$\$EXTENSION\$\$/$xext/g; - $i4jextentry =~ s/\$\$DISPLAYEXTENSION\$\$/$xdisplayext/g; - $i4jextentry =~ s/\$\$PROGRESSPERCENT\$\$/$progresspercent/g; - $i4jextentry =~ s/\$\$ID\$\$/$id/g; + $i4jentry =~ s/\$\$ADDUNIXEXTENSION\$\$/$addunixextension/g; + $i4jentry =~ s/\$\$EXTENSION\$\$/$xext/g; + $i4jentry =~ s/\$\$DISPLAYEXTENSION\$\$/$xdisplayext/g; + $i4jentry =~ s/\$\$PROGRESSPERCENT\$\$/$progresspercent/g; + $i4jentry =~ s/\$\$ID\$\$/$id/g; $id++; - $i4jextentry =~ s/\$\$ID1\$\$/$id/g; + $i4jentry =~ s/\$\$ID1\$\$/$id/g; $id++; - $i4jextentry =~ s/\$\$ID2\$\$/$id/g; + $i4jentry =~ s/\$\$ID2\$\$/$id/g; $id++; - print IA $i4jextentry; - + print IA $i4jentry; delete $all_associations{$shortname}; + warn("Writing entry for $name (".join(",",@$extensions).": $mimetype)\n"); } close(IA); print MA "\n"; +# +# print MA " +# +# CFBundleURLTypes +# +# +# CFBundleURLName +# org.jalview.jalview-desktop.url.jalview +# CFBundleTypeRole +# Editor +# CFBundleURLSchemes +# +# jalview +# +# +# +# +# "; close(MA); sub xml_escape { diff --git a/utils/install4j/file_associations_auto-Info_plist.xml b/utils/install4j/file_associations_auto-Info_plist.xml index 5922f2d..67f5ba0 100644 --- a/utils/install4j/file_associations_auto-Info_plist.xml +++ b/utils/install4j/file_associations_auto-Info_plist.xml @@ -42,75 +42,76 @@ CFBundleTypeExtensions -amsa +cif CFBundleTypeName -AMSA File +mmCIF File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole -Editor +Viewer CFBundleTypeMIMETypes -application/x-amsa+txt +chemical/x-cif LSIsAppleDefaultForType - + CFBundleTypeExtensions -annotations -jvannotations +mcif +mmcif CFBundleTypeName -Jalview Annotations File +mmCIF File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole -Editor +Viewer CFBundleTypeMIMETypes -application/x-jalview-annotations+text +chemical/x-mcif LSIsAppleDefaultForType - + CFBundleTypeExtensions -biojson +pdb +ent CFBundleTypeName -BioJSON File +PDB File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole -Editor +Viewer CFBundleTypeMIMETypes -application/x-jalview-biojson+json +chemical/x-pdb LSIsAppleDefaultForType - + CFBundleTypeExtensions -blc +amsa CFBundleTypeName -BLC File +AMSA File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-blc+txt +application/x-amsa+txt LSIsAppleDefaultForType @@ -119,17 +120,18 @@ CFBundleTypeExtensions -aln +annotations +jvannotations CFBundleTypeName -Clustal File +Jalview Annotations File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-clustal+txt +application/x-jalview-annotations+text LSIsAppleDefaultForType @@ -138,18 +140,17 @@ CFBundleTypeExtensions -fa -fasta +biojson CFBundleTypeName -Fasta File +BioJSON File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-fasta+txt +application/x-jalview-biojson+json LSIsAppleDefaultForType @@ -158,18 +159,17 @@ CFBundleTypeExtensions -features -jvfeatures +blc CFBundleTypeName -Jalview Features File +BLC File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-jalview-features+text +application/x-blc+txt LSIsAppleDefaultForType @@ -178,17 +178,17 @@ CFBundleTypeExtensions -gff2 +aln CFBundleTypeName -Generic Features Format v2 File +Clustal File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-gff2+txt +application/x-clustal+txt LSIsAppleDefaultForType @@ -197,17 +197,18 @@ CFBundleTypeExtensions -gff3 +fa +fasta CFBundleTypeName -Generic Features Format v3 File +Fasta File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-gff3+txt +application/x-fasta+txt LSIsAppleDefaultForType @@ -216,18 +217,18 @@ CFBundleTypeExtensions -concise -jnet +features +jvfeatures CFBundleTypeName -JnetFile File +Jalview Features File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-jalview-jnet+text +application/x-jalview-features+text LSIsAppleDefaultForType @@ -236,17 +237,17 @@ CFBundleTypeExtensions -cif +gff2 CFBundleTypeName -mmCIF File +Generic Features Format v2 File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -chemical/x-cif +application/x-gff2+txt LSIsAppleDefaultForType @@ -255,18 +256,17 @@ CFBundleTypeExtensions -mcif -mmcif +gff3 CFBundleTypeName -mmCIF File +Generic Features Format v3 File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -chemical/x-mcif +application/x-gff3+txt LSIsAppleDefaultForType @@ -275,17 +275,18 @@ CFBundleTypeExtensions -msf +concise +jnet CFBundleTypeName -MSF File +JnetFile File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -application/x-msf+txt +application/x-jalview-jnet+text LSIsAppleDefaultForType @@ -294,18 +295,17 @@ CFBundleTypeExtensions -pdb -ent +msf CFBundleTypeName -PDB File +MSF File CFBundleTypeIconFile Jalview-File.icns CFBundleTypeRole Editor CFBundleTypeMIMETypes -chemical/x-pdb +application/x-msf+txt LSIsAppleDefaultForType diff --git a/utils/install4j/file_associations_auto-install4j8.xml b/utils/install4j/file_associations_auto-install4j8.xml index d37b053..f6884ee 100644 --- a/utils/install4j/file_associations_auto-install4j8.xml +++ b/utils/install4j/file_associations_auto-install4j8.xml @@ -1,5 +1,5 @@ - + Jalview (.jvp) Creating file associations... @@ -8,17 +8,18 @@ - + - + Jalview File jvp 737 + Jalview-File.icns @@ -44,7 +45,7 @@ - + Jalview Launch (.jvl) Creating file associations... @@ -53,17 +54,18 @@ - + - + Jalview Launch File jvl 737 + Jalview-Launch.icns @@ -88,33 +90,34 @@ - - + + - AMSA (.amsa) + mmCIF (.cif) Creating file associations... - + - + - AMSA File - amsa + mmCIF File + cif 737 + Jalview-File.icns - + @@ -123,7 +126,7 @@ Jalview-File.png - application/x-amsa+txt + chemical/x-cif Jalview-File.ico @@ -133,33 +136,34 @@ - - + + - Jalview Annotations (.annotations, .jvannotations) + mmCIF (.mcif, .mmcif) Creating file associations... - + - + - Jalview Annotations File - annotations,jvannotations + mmCIF File + mcif,mmcif 737 + Jalview-File.icns - + @@ -168,7 +172,7 @@ Jalview-File.png - application/x-jalview-annotations+text + chemical/x-mcif Jalview-File.ico @@ -178,33 +182,34 @@ - - + + - BioJSON (.biojson) + PDB (.ent, .pdb) Creating file associations... - + - + - BioJSON File - biojson + PDB File + ent,pdb 737 + Jalview-File.icns - + @@ -213,7 +218,7 @@ Jalview-File.png - application/x-jalview-biojson+json + chemical/x-pdb Jalview-File.ico @@ -223,33 +228,34 @@ - - + + - BLC (.blc) + AMSA (.amsa) Creating file associations... - + - + - BLC File - blc + AMSA File + amsa 737 + Jalview-File.icns - + @@ -258,7 +264,7 @@ Jalview-File.png - application/x-blc+txt + application/x-amsa+txt Jalview-File.ico @@ -268,33 +274,34 @@ - - + + - Clustal (.aln) + Jalview Annotations (.annotations, .jvannotations) Creating file associations... - + - + - Clustal File - aln + Jalview Annotations File + annotations,jvannotations 737 + Jalview-File.icns - + @@ -303,7 +310,7 @@ Jalview-File.png - application/x-clustal+txt + application/x-jalview-annotations+text Jalview-File.ico @@ -313,33 +320,34 @@ - - + + - Fasta (.fa, .fasta) + BioJSON (.biojson) Creating file associations... - + - + - Fasta File - fa,fasta + BioJSON File + biojson 737 + Jalview-File.icns - + @@ -348,7 +356,7 @@ Jalview-File.png - application/x-fasta+txt + application/x-jalview-biojson+json Jalview-File.ico @@ -358,33 +366,34 @@ - - + + - Jalview Features (.features, .jvfeatures) + BLC (.blc) Creating file associations... - + - + - Jalview Features File - features,jvfeatures + BLC File + blc 737 + Jalview-File.icns - + @@ -393,7 +402,7 @@ Jalview-File.png - application/x-jalview-features+text + application/x-blc+txt Jalview-File.ico @@ -403,33 +412,34 @@ - - + + - Generic Features Format v2 (.gff2) + Clustal (.aln) Creating file associations... - + - + - Generic Features Format v2 File - gff2 + Clustal File + aln 737 + Jalview-File.icns - + @@ -438,7 +448,7 @@ Jalview-File.png - application/x-gff2+txt + application/x-clustal+txt Jalview-File.ico @@ -448,33 +458,34 @@ - - + + - Generic Features Format v3 (.gff3) + Fasta (.fa, .fasta) Creating file associations... - + - + - Generic Features Format v3 File - gff3 + Fasta File + fa,fasta 737 + Jalview-File.icns - + @@ -483,7 +494,7 @@ Jalview-File.png - application/x-gff3+txt + application/x-fasta+txt Jalview-File.ico @@ -493,33 +504,34 @@ - - + + - JnetFile (.concise, .jnet) + Jalview Features (.features, .jvfeatures) Creating file associations... - + - + - JnetFile File - concise,jnet + Jalview Features File + features,jvfeatures 737 + Jalview-File.icns - + @@ -528,7 +540,7 @@ Jalview-File.png - application/x-jalview-jnet+text + application/x-jalview-features+text Jalview-File.ico @@ -538,33 +550,34 @@ - - + + - mmCIF (.cif) + Generic Features Format v2 (.gff2) Creating file associations... - + - + - mmCIF File - cif + Generic Features Format v2 File + gff2 737 + Jalview-File.icns - + @@ -573,7 +586,7 @@ Jalview-File.png - chemical/x-cif + application/x-gff2+txt Jalview-File.ico @@ -583,33 +596,34 @@ - - + + - mmCIF (.mcif, .mmcif) + Generic Features Format v3 (.gff3) Creating file associations... - + - + - mmCIF File - mcif,mmcif + Generic Features Format v3 File + gff3 737 + Jalview-File.icns - + @@ -618,7 +632,7 @@ Jalview-File.png - chemical/x-mcif + application/x-gff3+txt Jalview-File.ico @@ -628,33 +642,34 @@ - - + + - MSF (.msf) + JnetFile (.concise, .jnet) Creating file associations... - + - + - MSF File - msf + JnetFile File + concise,jnet 737 + Jalview-File.icns - + @@ -663,7 +678,7 @@ Jalview-File.png - application/x-msf+txt + application/x-jalview-jnet+text Jalview-File.ico @@ -673,33 +688,34 @@ - - + + - PDB (.ent, .pdb) + MSF (.msf) Creating file associations... - + - + - PDB File - ent,pdb + MSF File + msf 737 + Jalview-File.icns - + @@ -708,7 +724,7 @@ Jalview-File.png - chemical/x-pdb + application/x-msf+txt Jalview-File.ico @@ -719,7 +735,7 @@ - + PFAM (.pfam) Creating file associations... @@ -728,17 +744,18 @@ - + - + PFAM File pfam 737 + Jalview-File.icns @@ -764,7 +781,7 @@ - + PHYLIP (.phy) Creating file associations... @@ -773,17 +790,18 @@ - + - + PHYLIP File phy 737 + Jalview-File.icns @@ -809,7 +827,7 @@ - + PileUp (.pileup) Creating file associations... @@ -818,17 +836,18 @@ - + - + PileUp File pileup 737 + Jalview-File.icns @@ -854,7 +873,7 @@ - + PIR (.pir) Creating file associations... @@ -863,17 +882,18 @@ - + - + PIR File pir 737 + Jalview-File.icns @@ -899,7 +919,7 @@ - + RNAML (.rnaml) Creating file associations... @@ -908,17 +928,18 @@ - + - + RNAML File rnaml 737 + Jalview-File.icns @@ -944,7 +965,7 @@ - + Substitution Matrix (.mat) Creating file associations... @@ -953,17 +974,18 @@ - + - + Substitution Matrix File mat 737 + Jalview-File.icns @@ -989,7 +1011,7 @@ - + Stockholm (.stk, .sto) Creating file associations... @@ -998,17 +1020,18 @@ - + - + Stockholm File stk,sto 737 + Jalview-File.icns diff --git a/utils/install4j/file_associations_template-Info_plist.xml b/utils/install4j/file_associations_template-Info_plist.xml index 7fa4fed..a260658 100644 --- a/utils/install4j/file_associations_template-Info_plist.xml +++ b/utils/install4j/file_associations_template-Info_plist.xml @@ -8,12 +8,12 @@ $$ CFBundleTypeIconFile $$ICONFILE$$.icns CFBundleTypeRole -Editor +$$ROLE$$ CFBundleTypeMIMETypes $$MIMETYPE$$ LSIsAppleDefaultForType - +<$$PRIMARY$$/> diff --git a/utils/install4j/file_associations_template-install4j8.xml b/utils/install4j/file_associations_template-install4j8.xml index bd1a4e1..ac0393a 100644 --- a/utils/install4j/file_associations_template-install4j8.xml +++ b/utils/install4j/file_associations_template-install4j8.xml @@ -1,5 +1,5 @@ - + $$NAME$$ ($$DISPLAYEXTENSION$$) Creating file associations... @@ -8,17 +8,18 @@ - + - + $$NAME$$ File $$EXTENSION$$ 737 + $$ICONFILE$$.icns diff --git a/utils/install4j/install4j8_template.install4j b/utils/install4j/install4j8_template.install4j index c94b0c3..c57474b 100644 --- a/utils/install4j/install4j8_template.install4j +++ b/utils/install4j/install4j8_template.install4j @@ -9,27 +9,26 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -114,29 +113,9 @@ - - ${compiler:file("${compiler:INFO_PLIST_FILE_ASSOCIATIONS_FILE}")} - - - - - - - - - - - - - - - - - - - - - + + 2350 + ${compiler:file("${compiler:INFO_PLIST_FILE_ASSOCIATIONS_FILE}")} @@ -450,7 +429,7 @@ return console.askOkCancel(message, true); - + 737 jalview @@ -1071,7 +1050,6 @@ return console.askYesNo(message, true); - @@ -1090,7 +1068,6 @@ return console.askYesNo(message, true); - @@ -1107,9 +1084,6 @@ return console.askYesNo(message, true); - - - @@ -1126,9 +1100,6 @@ return console.askYesNo(message, true); - - - @@ -1166,9 +1137,6 @@ return console.askYesNo(message, true); - - - @@ -1184,9 +1152,6 @@ return console.askYesNo(message, true); - - - -- 1.7.10.2