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

rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University ProfessorPosts:568Unicorn
edited December 2018 inProduct Feedback - Resolved

Hello, RapidMiners!

According to my findings motivated bythis conversationwith@kayman: RapidMiner relies upon thejava.awt.Desktopclass to execute theOpen in file browseraction. 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 thejava.awt.Desktopclass. 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

Scheduled for Release·Last Updated

Will be released in RM 9.7 PROD-565

Comments

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University ProfessorPosts:3,389RM 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 ProfessorPosts:568Unicorn

    Hello@mschmitz,

    First, on theRapidMiner Studio Preferences, on theSystemtab, 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 usegmc(Gnome Midnight Commander) instead ofnautilus(the default one in Gnome, AFAIK).

    On theOpenFileInBrowserAction.javafile, do this:

    • Move theifstatement from lines55-57to line64以便确认之前试图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 lines87-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 thecatchstatement 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 Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM ModeratorPosts:2,959Community Manager

    reported to dev team and tagged@mschmitzon the ticket.

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University ProfessorPosts:3,389RM 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 ProfessorPosts:568Unicorn

    Hi@mschmitz,

    什么是你的想法,保持作为一个插件不put that kind of logic on the core, or once the plugin works you want to merge that there?

    All the best,

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University ProfessorPosts:3,389RM 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 ProfessorPosts:568Unicorn

    @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 thePreferencesmenu 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 Administrator, Moderator, Employee, Member, University ProfessorPosts:1,984RM 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 ProfessorPosts:568Unicorn
    Awesome! Thank you.

    All the best,

    Rodrigo.
Sign InorRegisterto comment.