@@ -96,7 +96,7 @@ public String osName() {
9696 public void configure (final PlatformService service ) {
9797 super .configure (service );
9898
99- // Create or update .desktop file for desktop integration
99+ // Create or update .desktop file for desktop integration.
100100 try {
101101 installDesktopFile ();
102102 }
@@ -121,7 +121,7 @@ public boolean isWebLinksEnabled() {
121121 try {
122122 final DesktopFile df = getOrCreateDesktopFile ();
123123
124- // Check if any scheme is registered
124+ // Check if any scheme is registered.
125125 for (final String scheme : schemes ()) {
126126 if (df .hasMimeType ("x-scheme-handler/" + scheme )) return true ;
127127 }
@@ -162,7 +162,7 @@ public void setDesktopIconPresent(final boolean install) throws IOException {
162162 final DesktopFile df = getOrCreateDesktopFile ();
163163
164164 if (install ) {
165- // Ensure .desktop file has all required fields
165+ // Ensure .desktop file has all required fields.
166166 if (df .getName () == null ) {
167167 final String appName = System .getProperty ("scijava.app.name" , "SciJava Application" );
168168 df .setName (appName );
@@ -185,7 +185,7 @@ public void setDesktopIconPresent(final boolean install) throws IOException {
185185 df .setGenericName (appName );
186186 }
187187
188- // Set optional fields if provided
188+ // Set optional fields if provided.
189189 final String appIcon = System .getProperty ("scijava.app.icon" );
190190 if (appIcon != null && df .getIcon () == null ) {
191191 df .setIcon (appIcon );
@@ -215,7 +215,7 @@ public boolean isFileExtensionsEnabled() {
215215 final DesktopFile df = getOrCreateDesktopFile ();
216216 final Map <String , String > mimeMapping = loadMimeTypeMapping ();
217217
218- // Check if any file extension MIME types are in the .desktop file
218+ // Check if any file extension MIME types are in the .desktop file.
219219 for (final String mimeType : mimeMapping .values ()) {
220220 if (df .hasMimeType (mimeType )) return true ;
221221 }
@@ -244,10 +244,10 @@ public void setFileExtensionsEnabled(final boolean enable) throws IOException {
244244 }
245245
246246 if (enable ) {
247- // Register custom MIME types for formats without standard types
247+ // Register custom MIME types for formats without standard types.
248248 registerCustomMimeTypes (mimeMapping );
249249
250- // Add MIME types to .desktop file
250+ // Add MIME types to .desktop file.
251251 final DesktopFile df = getOrCreateDesktopFile ();
252252 for (final String mimeType : mimeMapping .values ()) {
253253 df .addMimeType (mimeType );
@@ -258,15 +258,15 @@ public void setFileExtensionsEnabled(final boolean enable) throws IOException {
258258 log .info ("Registered " + mimeMapping .size () + " file extension MIME types" );
259259 }
260260 } else {
261- // Remove file extension MIME types from .desktop file
262- // Keep URI scheme handlers (x-scheme-handler/...)
261+ // Remove file extension MIME types from .desktop file.
262+ // Keep URI scheme handlers (x-scheme-handler/...).
263263 final DesktopFile df = getOrCreateDesktopFile ();
264264
265265 for (final String mimeType : mimeMapping .values ()) {
266266 df .removeMimeType (mimeType );
267267 }
268268
269- // Re-add URI scheme handlers
269+ // Re-add URI scheme handlers.
270270 for (final String scheme : schemes ()) {
271271 df .addMimeType ("x-scheme-handler/" + scheme );
272272 }
@@ -389,7 +389,7 @@ private String sanitizeFileName(final String name) {
389389 // -- Helper methods --
390390
391391 private LinkService linkService () {
392- // NB: We cannot declare LinkService as an @Parameter because
392+ // NB: We cannot declare LinkService as a @Parameter because
393393 // the PlatformService creates its plugin singletons before the
394394 // LinkService has been instantiated and added to the context.
395395 return context .getService (LinkService .class );
@@ -430,26 +430,26 @@ private synchronized Map<String, String> loadMimeTypeMapping() throws IOExceptio
430430 * Creates ~/.local/share/mime/packages/[appName].xml and runs update-mime-database.
431431 */
432432 private void registerCustomMimeTypes (final Map <String , String > mimeMapping ) throws IOException {
433- // Separate standard from custom MIME types
433+ // Separate standard from custom MIME types.
434434 final Map <String , String > customTypes = new LinkedHashMap <>();
435435 for (final Map .Entry <String , String > entry : mimeMapping .entrySet ()) {
436436 final String mimeType = entry .getValue ();
437- // Custom types use application/x- prefix
437+ // Custom types use application/x- prefix.
438438 if (mimeType .startsWith ("application/x-" )) {
439439 customTypes .put (entry .getKey (), mimeType );
440440 }
441441 }
442442
443443 if (customTypes .isEmpty ()) {
444- // No custom types to register
444+ // No custom types to register.
445445 return ;
446446 }
447447
448- // Generate MIME types XML
448+ // Generate MIME types XML.
449449 final String appName = System .getProperty ("scijava.app.name" , "SciJava" );
450450 final String mimeXml = generateMimeTypesXml (customTypes , appName );
451451
452- // Write to ~/.local/share/mime/packages/<app>.xml
452+ // Write to ~/.local/share/mime/packages/<app>.xml.
453453 final Path mimeDir = Paths .get (System .getProperty ("user.home" ),
454454 ".local/share/mime/packages" );
455455 Files .createDirectories (mimeDir );
@@ -458,7 +458,7 @@ private void registerCustomMimeTypes(final Map<String, String> mimeMapping) thro
458458 Files .writeString (mimeFile , mimeXml , StandardOpenOption .CREATE ,
459459 StandardOpenOption .TRUNCATE_EXISTING );
460460
461- // Update MIME database
461+ // Update MIME database.
462462 try {
463463 final ProcessBuilder pb = new ProcessBuilder (
464464 "update-mime-database" ,
@@ -495,7 +495,7 @@ private String generateMimeTypesXml(final Map<String, String> customTypes,
495495 final String extension = entry .getKey ();
496496 final String mimeType = entry .getValue ();
497497
498- // Generate human-readable comment from MIME type
498+ // Generate human-readable comment from MIME type.
499499 final String comment = generateMimeTypeComment (mimeType );
500500
501501 xml .append (" <mime-type type=\" " ).append (mimeType ).append ("\" >\n " );
@@ -513,14 +513,14 @@ private String generateMimeTypesXml(final Map<String, String> customTypes,
513513 * For example, "application/x-zeiss-czi" becomes "Zeiss CZI File".
514514 */
515515 private String generateMimeTypeComment (final String mimeType ) {
516- // Extract the format part (e.g., "zeiss-czi" from "application/x-zeiss-czi")
516+ // Extract the format part (e.g., "zeiss-czi" from "application/x-zeiss-czi").
517517 final String format = mimeType .substring (mimeType .lastIndexOf ('/' ) + 1 );
518518
519- // Remove "x-" prefix if present
519+ // Remove "x-" prefix if present.
520520 final String cleanFormat = format .startsWith ("x-" ) ?
521521 format .substring (2 ) : format ;
522522
523- // Convert to title case
523+ // Convert to title case.
524524 final String [] parts = cleanFormat .split ("-" );
525525 final StringBuilder comment = new StringBuilder ();
526526 for (final String part : parts ) {
0 commit comments