NOTE: IF YOU WISH TO SUGGEST A NEW FEATURE, PLEASE POST A NEW QUESTION AND TAG AS "FEATURE REQUEST". THANK YOU.

Get rid of java.awt.Desktop to open file browser/alternatives.

rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 394   Unicorn
edited December 2018 in Product Ideas

Hello, RapidMiners!

 

According to my findings motivated by this conversation with @kayman: RapidMiner relies upon the java.awt.Desktop class to execute the Open in file browser action. That works on Windows, Mac and older some Linux/Gnome machines, leaving out other desktop environments. There is a feature that could benefit all other desktop environments that aren't quite compatible. (e.g. Ubuntu 18, as we found out).

 

It would be a good thing to add a default file manager as part of the RapidMiner Studio configuration (most users don't adjust these unless they are advanced users), and stick to (default) if none is configured.

 

if .isDesktopSupported() is true and (default) is chosen as file manager, open the files in the default file manager as reported by the java.awt.Desktop class. Otherwise, if .isDesktopSupported() is false and default is selected, try to open anyway or present users with a message that says that they need to configure a file manager; else, open files with the file manager chosen by the user.

 

RapidMiner users on various Linux platforms will benefit from this, as desktop integration has always been incomplete there, and will give a workaround whenever things change, like it happened with Ubuntu.

 

What do you think?

 

Tagged:
0
0 votes

Open for Voting · Last Updated

PROD-565

Comments

  • mschmitzmschmitz Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 2,074  RM Data Scientist

    @rfuentealba,

    for reference, this is the source code of the action:

    https://github.com/rapidminer/rapidminer-studio/blob/master/src/main/java/com/rapidminer/repository/gui/actions/OpenInFileBrowserAction.java

     

    what would you do if isDesktopSupported() is false?

     

    BR,

    Martin

    - Head of Data Science Services at RapidMiner -
    Dortmund, Germany
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 394   Unicorn

    Hello @mschmitz,

     

    First, on the RapidMiner Studio Preferences, on the System tab, add a section to specify a file manager that is different from the default one offered by the operating system. There I can specify that I want to use gmc (Gnome Midnight Commander) instead of nautilus (the default one in Gnome, AFAIK).

     

    On the OpenFileInBrowserAction.java file, do this:

     

     

    • Move the if statement from lines 55-57 to line 64 so that the confirmation goes before trying to open a file.
    • Add a new condition (I don't know how to recover RapidMiner Studio preferences from this class, that's what prevented me from submitting a patch, but for pseudocode reasons, I'll call it RapidMinerStudioPreferences):

    if (RapidMinerStudioPreferences.defaultFileBrowser.isEmpty() && (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN))) {
        alert_that_no_browser_can_open_stuff();

        return;

    }

     

    • In lines 87-onwards (pseudocode again, I'm not good at Java):

    // try to open if it exists and is a directory

    File file = new File(pathBuilder.toString());

     

    if (file.exists() && file.isDirectory())

    {

        // Try to open with default if the default file browser is empty.

        // Otherwise, execute the default file browser passing the file as a
        // parameter.

        if (RapidMinerStudioPreferences.defaultFileBrowser.isEmpty()) {

            Desktop.getDesktop().open(file);

        } else {

            Runtime.getRuntime().exec(String.format("sh -c %s %s", RapidMinerStudioPreferences.defaultFileBrowser, file);

        }

    }

     

    If the method chosen for launching a process can return the result of the operation, read it and if it's different from 0, throw an exception that will be captured by the catch statement on lines 97-99.

     

    For what is worth, there are more ways to launch UNIX processes, I just cited a simple one that might or might not be appropriate.

     

    Is this detailed enough? Thank you!

  • sgenzersgenzer 12Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,383  Community Manager

    reported to dev team and tagged @mschmitz on the ticket.

  • mschmitzmschmitz Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 2,074  RM Data Scientist

    @rfuentealba,

     

    just as an idea: I could provide an extension on github which has a new action called "Open File (Ubuntu)". This would have basically the same class i referenced here. Would you be able to edit the class so that the extension does it?

     

    BR,

    Martin

    - Head of Data Science Services at RapidMiner -
    Dortmund, Germany
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 394   Unicorn

    Hi @mschmitz,

     

    What is your idea, keeping that as a plugin to not put that kind of logic on the core, or once the plugin works you want to merge that there?

     

    All the best,

     

  • mschmitzmschmitz Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 2,074  RM Data Scientist

    @rfuentealba,

    good question. I got another functionality lying around which allows you to write ExampleSets to Excel by just right clicking on it. So this extension would have 2 new options. I personally would like to either:

     

    - Have an open source extension with more then 1 "Custom Action" to make it useful

    - Merge it into core

     

    One nice part of the open soruce part would be, that other people can learn from this.

     

    But i am not the person who decides on this.

     

    Best,

    Martin

    - Head of Data Science Services at RapidMiner -
    Dortmund, Germany
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 394   Unicorn

    @mschmitz, I have no problems with any choice, actually, and I can do part of it. From the usability point of view, it can be confusing to have two menu items for the same action, though.

     

    There are two things I don't know how to do: one is adding a new tab in the Preferences menu so that I can configure the default file browser there, and the other is retrieving the value to use it elsewhere. If you can point me to the pieces of code for that, I can help you with either choice.

     

    All the best,

     

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Moderator, Employee, Member, University Professor Posts: 1,800   RM Engineering
    Hi,

    This little feature will come at one point in the future. I already implemented it while working on something else, but it will probably not be released for some time.
    It will be done pretty much exactly like your pseudo code above :)

    Regards,
    Marco
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 394   Unicorn
    Awesome! Thank you.

    All the best,

    Rodrigo.
Sign In or Register to comment.