Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions java/edu/cmu/cs/hcii/cogtool/test/FileAssociationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* CogTool Copyright Notice and Distribution Terms
* CogTool 1.3, Copyright (c) 2005-2013 Carnegie Mellon University
* This software is distributed under the terms of the FSF Lesser
* Gnu Public License (see LGPL.txt).
*******************************************************************************/

package edu.cmu.cs.hcii.cogtool.test;

import java.util.ArrayList;
import java.util.List;

import joptsimple.OptionParser;
import joptsimple.OptionSet;

/**
* Test class to verify that file association and argument passing works correctly.
* This test simulates the argument parsing logic used in CogTool.main().
*/
public class FileAssociationTest {

public static void main(String[] args) {
System.out.println("FileAssociationTest: Testing argument parsing...");
System.out.println("Number of arguments received: " + args.length);

for (int i = 0; i < args.length; i++) {
System.out.println("Argument " + i + ": '" + args[i] + "'");
}

try {
// Use the same option parser configuration as CogTool
OptionParser parser = new OptionParser("f:i:re:s:qQ");
// The psn is supplied on MacOS when a GUI application is double-clicked;
// we just ignore it, but need to recognize it so we can ignore it.
parser.accepts("psn", "process serial number (ignored)").withRequiredArg();
OptionSet opts = parser.parse(args);

List<String> filesToLoad = new ArrayList<String>();
for (Object obj : opts.nonOptionArguments()) {
filesToLoad.add((String)obj);
}

System.out.println("Files to load: " + filesToLoad.size());
for (String file : filesToLoad) {
System.out.println(" - " + file);
}

if (filesToLoad.isEmpty()) {
System.out.println("WARNING: No files to load. File association may not be working correctly.");
} else {
System.out.println("SUCCESS: File association appears to be working correctly.");
}

} catch (Exception e) {
System.err.println("ERROR: Exception during argument parsing: " + e.getMessage());
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion lib/macintosh/cogtoolstart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ JAVAROOT="$RESDIR/Java"

cd "$RESDIR"

exec $JAVACMD -XstartOnFirstThread -classpath "$JAVAROOT/CogTool.jar:$JAVAROOT/MacSupport.jar:$JAVAROOT/WindowsImageTransfer.jar:$JAVAROOT/commons-collections-3.1.jar:$JAVAROOT/commons-lang-2.1.jar:$JAVAROOT/ecf.jar:$JAVAROOT/js.jar:$JAVAROOT/draw2d.jar:$JAVAROOT/swt.jar:$JAVAROOT/xercesImpl.jar:$JAVAROOT/xml-apis.jar:$JAVAROOT/MozillaGlue.jar:$JAVAROOT/MozillaInterfaces.jar:$JAVAROOT/jopt-simple.jar:$BASEDIR" -Djava.library.path="$JAVAROOT/dll" -Dcogtool.version="$BLDVER" -Dcogtool.revision="$BLDREV" -Dcogtool.build="$BLDTIM" -Xmx400000000 edu.cmu.cs.hcii.cogtool.CogTool $*
exec $JAVACMD -XstartOnFirstThread -classpath "$JAVAROOT/CogTool.jar:$JAVAROOT/MacSupport.jar:$JAVAROOT/WindowsImageTransfer.jar:$JAVAROOT/commons-collections-3.1.jar:$JAVAROOT/commons-lang-2.1.jar:$JAVAROOT/ecf.jar:$JAVAROOT/js.jar:$JAVAROOT/draw2d.jar:$JAVAROOT/swt.jar:$JAVAROOT/xercesImpl.jar:$JAVAROOT/xml-apis.jar:$JAVAROOT/MozillaGlue.jar:$JAVAROOT/MozillaInterfaces.jar:$JAVAROOT/jopt-simple.jar:$BASEDIR" -Djava.library.path="$JAVAROOT/dll" -Dcogtool.version="$BLDVER" -Dcogtool.revision="$BLDREV" -Dcogtool.build="$BLDTIM" -Xmx400000000 edu.cmu.cs.hcii.cogtool.CogTool "$@"
15 changes: 15 additions & 0 deletions res/CogTool.tmp/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
<string>CgTl</string>
<key>CFBundleVersion</key>
<string>VERSTRING</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>cgt</string>
</array>
<key>CFBundleTypeName</key>
<string>CogTool Project</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>CogTool.Document</string>
</dict>
</array>
<key>LSEnvironment</key>
<dict>
<key>BLDREV</key>
Expand Down
34 changes: 34 additions & 0 deletions test_file_association.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Test script to verify file association works
# This script simulates what happens when a .cgt file is double-clicked

echo "Testing CogTool file association..."

# Create a test .cgt file
TEST_FILE="/tmp/test_project.cgt"
echo "Creating test file: $TEST_FILE"
echo '<?xml version="1.0" encoding="UTF-8"?><project></project>' > "$TEST_FILE"

# Test the cogtoolstart script directly with the file argument
echo "Testing cogtoolstart script with file argument..."
SCRIPT_DIR="$(dirname "$0")"
COGTOOLSTART="$SCRIPT_DIR/lib/macintosh/cogtoolstart"

if [ -f "$COGTOOLSTART" ]; then
echo "Found cogtoolstart script at: $COGTOOLSTART"
echo "Testing with argument: $TEST_FILE"

# Add some debug output to see what arguments are passed
echo "Arguments passed to cogtoolstart: $TEST_FILE"

# We can't actually run this without building the app, but we can check the script
echo "Script content:"
cat "$COGTOOLSTART"
else
echo "ERROR: cogtoolstart script not found at $COGTOOLSTART"
fi

# Clean up
rm -f "$TEST_FILE"
echo "Test completed."