Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open .meta files from Solid Pods/Linked Data Platform file structure #1249

Open
danielbakas opened this issue Dec 25, 2024 · 5 comments
Open

Comments

@danielbakas
Copy link

Hi!

I'm trying to open .meta files (which have ttl content).

The Solid Protocol, which implements the Linked Data Platform Standard, allows users to declare a .meta file for a given directory or container.

This .meta file is actually a turtle file.

How can we open this file in Protegé so we can manage our ontologies in these files?

Thank you in advance!

@gouttegd
Copy link
Collaborator

Is the problem that you can’t select a file with a .meta extension in the “Open file…” dialog? If so, are you running on MacOS? On other platforms, the file dialog shows only “OWL files” by default, but there should be an option to enable choosing a file of any type, regardless of its extension.

On MacOS, that does not seem possible – I am not sure why, I’ll investigate that later.

For now, you have two workarounds:

  • rename the file to give it an extension recognised by Protégé (such as .ttl), or
  • use the open command on the command line:
open -a Protégé myfile.meta

(But you may need to run that command twice: once to start Protégé, and another one to actually get it to open the file – this is because of another known bug.)

If your problem is different – in particular, if you are not under MacOS –, please provide more details.

@danielbakas
Copy link
Author

danielbakas commented Dec 25, 2024

Hi @gouttegd!!

That is precisely the issue, and I am using macOS!

An additional note is that the files are hidden files. They are not something.meta (although they can be too). They are instead just .meta.

Given they are natural to the file system of Solid and Linked Data Platforms, I could not rename them.

And having over 20 files named like this, opening one by one with a command like this might be hard in the long run.

Is this an issue only for the macOS version? Is there a way to select and open non-RDF/OWL files that might have RDF/OWL content? What about hidden files?

Thank you so much @gouttegd!

Looking forward to your thoughts

@gouttegd
Copy link
Collaborator

Is this an issue only for the macOS version?

Yes. As I have said, on GNU/Linux and Windows the “Open file” dialog allows to remove the constraint that only “OWL files” (files with a recognised extension, such as .owl, .ttl, .obo, .ofn, and a few others) can be selected and opened, and to select and open any file instead, regardless of its extension. The MacOS dialog seemingly does not have such an option – again, I am not sure why.

Is there a way to select and open non-RDF/OWL files that might have RDF/OWL content?

On MacOS, not from within Protégé itself. A workaround is to open those files from the Finder, by manually associating the .meta extension to Protégé: in the Finder, right-click on a .meta file (you may have to configure the Finder to show hidden files first, see below), and in the contextual menu, select Open With > Other…; then in the ”Choose an application” dialog, make sure to enable “All applications” instead of “Recommended Applications”, and choose to open the file with Protégé.

(This is basically the graphical version of the open -a Protégé … workaround I mentioned in my previous message.)

What about hidden files?

Use Command + Shift + . to toggle the display of hidden files. This works both in the Finder and in a “Open file” dialog. (But within a “Open file” dialog, this will only allow you to see the .meta files; the dialog still won’t allow you to select them.)

@danielbakas
Copy link
Author

Yes. As I have said, on GNU/Linux and Windows the “Open file” dialog allows to remove the constraint that only “OWL files” (files with a recognised extension, such as .owl, .ttl, .obo, .ofn, and a few others) can be selected and opened, and to select and open any file instead, regardless of its extension. The MacOS dialog seemingly does not have such an option – again, I am not sure why.

This might be useful:

import javax.swing.*;
import java.awt.*;
import java.io.File;

public class FileChooserExample {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("File Chooser Example");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 200);

            JButton button = new JButton("Open File");
            button.addActionListener(e -> {
                JFileChooser fileChooser = new JFileChooser();

                // Add a filter for .owl files
                fileChooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {
                    @Override
                    public boolean accept(File f) {
                        return f.isDirectory() || f.getName().toLowerCase().endsWith(".owl");
                    }

                    @Override
                    public String getDescription() {
                        return "OWL Files (*.owl)";
                    }
                });

                // Enable "All Files" option
                fileChooser.setAcceptAllFileFilterUsed(true);

                // Set the default filter to .owl
                fileChooser.setFileFilter(fileChooser.getChoosableFileFilters()[0]);

                int result = fileChooser.showOpenDialog(frame);
                if (result == JFileChooser.APPROVE_OPTION) {
                    File selectedFile = fileChooser.getSelectedFile();
                    System.out.println("Selected file: " + selectedFile.getAbsolutePath());
                }
            });

            frame.getContentPane().add(button, BorderLayout.CENTER);
            frame.setVisible(true);
        });
    }
}

I read somewhere that this code might allow a user to initially choose .owl (or any extension you choose), but also allow a dropdown which would allow the user to select any file if switched.

Thanks for the rest!

@gouttegd
Copy link
Collaborator

gouttegd commented Jan 6, 2025

This is not as simple as Protégé on macOS is using the native (AWT-based) file dialog, which on macOS simply does not include an option to select any file if a filter is set.

The only way to fix that would be to drop the native dialog and use the non-native (Swing-based) dialog instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants