21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 package jdk.jpackage.test; |
23 package jdk.jpackage.test; |
24 |
24 |
25 import java.nio.file.Path; |
25 import java.nio.file.Path; |
|
26 import java.util.HashMap; |
26 import java.util.Map; |
27 import java.util.Map; |
27 |
28 |
28 |
29 |
29 public class FileAssociations { |
30 final public class FileAssociations { |
30 public FileAssociations(String faSuffixName) { |
31 public FileAssociations(String faSuffixName) { |
31 suffixName = faSuffixName; |
32 suffixName = faSuffixName; |
32 setFilename("fa"); |
33 setFilename("fa"); |
33 setDescription("jpackage test extention"); |
34 setDescription("jpackage test extention"); |
34 } |
35 } |
35 |
36 |
36 public void createFile() { |
37 public void createFile() { |
37 TKit.createPropertiesFile(file, |
38 Map<String, String> entries = new HashMap<>(Map.of( |
38 Map.entry("extension", suffixName), |
39 "extension", suffixName, |
39 Map.entry("mime-type", getMime()), |
40 "mime-type", getMime(), |
40 Map.entry("description", description)); |
41 "description", description |
|
42 )); |
|
43 if (icon != null) { |
|
44 if (TKit.isWindows()) { |
|
45 entries.put("icon", icon.toString().replace("\\", "/")); |
|
46 } else { |
|
47 entries.put("icon", icon.toString()); |
|
48 } |
|
49 } |
|
50 TKit.createPropertiesFile(file, entries); |
41 } |
51 } |
42 |
52 |
43 final public FileAssociations setFilename(String v) { |
53 public FileAssociations setFilename(String v) { |
44 file = TKit.workDir().resolve(v + ".properties"); |
54 file = TKit.workDir().resolve(v + ".properties"); |
45 return this; |
55 return this; |
46 } |
56 } |
47 |
57 |
48 final public FileAssociations setDescription(String v) { |
58 public FileAssociations setDescription(String v) { |
49 description = v; |
59 description = v; |
|
60 return this; |
|
61 } |
|
62 |
|
63 public FileAssociations setIcon(Path v) { |
|
64 icon = v; |
50 return this; |
65 return this; |
51 } |
66 } |
52 |
67 |
53 public Path getPropertiesFile() { |
68 public Path getPropertiesFile() { |
54 return file; |
69 return file; |