Changeset 6260
- Timestamp:
- 2003-12-12T17:58:10+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java
r6185 r6260 33 33 import org.greenstone.gatherer.gui.FileAssociationDialog; 34 34 import org.greenstone.gatherer.msm.MSMUtils; 35 import org.greenstone.gatherer.util.StaticStrings; 35 36 import org.greenstone.gatherer.util.Utility; 36 37 import org.greenstone.gatherer.util.WinRegistry; … … 65 66 String extension = entry.getAttribute(EXTENSION_ATTRIBUTE); 66 67 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; 78 83 } 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 } 80 88 } 81 89 command = null; … … 109 117 // for now uder linux get the fileassoc thing. but eventually want a separate thing. 110 118 // pretend we are tyring to open an html file 119 // Mmmoooo. - jmt12 111 120 String extension = "html"; 112 121 Element entry = getCommand(extension); … … 163 172 Element entry = getCommand(extension); 164 173 if(entry != null) { 174 ///ystem.err.println("Retrieved Value From Cache"); 165 175 command = MSMUtils.getValue(entry); 166 176 } 167 177 if(command == null || command.length() == 0) { 178 ///ystem.err.println("No Existing Command"); 168 179 // If command is null, and we are on windows try searching the registry. 169 180 if(Utility.isWindows()) { 181 ///ystem.err.println("Is Windows"); 170 182 command = WinRegistry.openCommand(filename); 171 183 } 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 172 190 // Otherwise display the dialog and ask the user to enter launching command. 173 191 if(command == null || command.length() == 0) { 192 ///ystem.err.println("Show Dialog"); 174 193 // Show the dialog which forces a user to select the launch command for a certain file. 175 194 FileAssociationDialog dialog = new FileAssociationDialog(this);
Note:
See TracChangeset
for help on using the changeset viewer.