Changeset 6260


Ignore:
Timestamp:
2003-12-12T17:58:10+13:00 (20 years ago)
Author:
jmt12
Message:

Added default 'open' command if under Mac

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java

    r6185 r6260  
    3333import org.greenstone.gatherer.gui.FileAssociationDialog;
    3434import org.greenstone.gatherer.msm.MSMUtils;
     35import org.greenstone.gatherer.util.StaticStrings;
    3536import org.greenstone.gatherer.util.Utility;
    3637import org.greenstone.gatherer.util.WinRegistry;
     
    6566        String extension = entry.getAttribute(EXTENSION_ATTRIBUTE);
    6667        String command = MSMUtils.getValue(entry);
    67         // If we encounter a command of "", and we are on windows, we try to automatically set this command.
    68         if(command.length() == 0 && Utility.isWindows()) {
    69             // Create a dummy filename with the appropriate extension
    70             String dummy_file = "dummy." + extension;
    71             command = WinRegistry.openCommand(dummy_file);
    72             // If this succeeded add the association.
    73             if(command != null) {
    74             // Remember to replace the dummy filename with %1
    75             command = command.replaceAll(dummy_file, FILENAME_ARG);
    76             // Replace the text in this node.
    77             MSMUtils.setValue(entry, command);
     68        // If we encounter a command of ""...
     69        if(command.length() == 0) {
     70            // and if we are on windows, we try to automatically set this command.
     71            if(Utility.isWindows()) {
     72            // Create a dummy filename with the appropriate extension
     73            String dummy_file = "dummy." + extension;
     74            command = WinRegistry.openCommand(dummy_file);
     75            // If this succeeded add the association.
     76            if(command != null) {
     77                // Remember to replace the dummy filename with %1
     78                command = command.replaceAll(dummy_file, FILENAME_ARG);
     79                // Replace the text in this node.
     80                MSMUtils.setValue(entry, command);
     81            }
     82            dummy_file = null;
    7883            }
    79             dummy_file = null;
     84            // and if we are on windows, we default to the open program
     85            if(Utility.isMac()) {
     86            MSMUtils.setValue(entry, StaticStrings.MAC_OPEN_COMMAND);
     87            }
    8088        }
    8189        command = null;
     
    109117    // for now uder linux get the fileassoc thing. but eventually want a separate thing.
    110118    // pretend we are tyring to open an html file
     119    // Mmmoooo. - jmt12
    111120    String extension = "html";
    112121    Element entry = getCommand(extension);
     
    163172        Element entry = getCommand(extension);
    164173        if(entry != null) {
     174        ///ystem.err.println("Retrieved Value From Cache");
    165175        command = MSMUtils.getValue(entry);
    166176        }
    167177        if(command == null || command.length() == 0) {
     178        ///ystem.err.println("No Existing Command");
    168179        // If command is null, and we are on windows try searching the registry.
    169180        if(Utility.isWindows()) {
     181            ///ystem.err.println("Is Windows");
    170182            command = WinRegistry.openCommand(filename);
    171183        }
     184        // If we are on a mac, default to using the open program
     185        else if(Utility.isMac()) {
     186            ///ystem.err.println("Is Mac");
     187            command = StaticStrings.MAC_OPEN_COMMAND;
     188        }
     189
    172190        // Otherwise display the dialog and ask the user to enter launching command.
    173191        if(command == null || command.length() == 0) {
     192            ///ystem.err.println("Show Dialog");
    174193            // Show the dialog which forces a user to select the launch command for a certain file.
    175194            FileAssociationDialog dialog = new FileAssociationDialog(this);
Note: See TracChangeset for help on using the changeset viewer.