github.com/ijc/docker-app@v0.6.1-0.20181012090447-c7ca8bc483fb/integrations/intellij/src/main/java/SelectApp.java (about)

     1  import com.intellij.openapi.actionSystem.*;
     2  import com.intellij.openapi.project.Project;
     3  import com.intellij.openapi.ui.Messages;
     4  import com.intellij.openapi.vfs.*;
     5  import com.intellij.openapi.fileChooser.*;
     6  import com.intellij.ide.util.PropertiesComponent;
     7  
     8  public class SelectApp extends AnAction {
     9      public SelectApp() {
    10          super("SelectApp");
    11      }
    12  
    13      public void actionPerformed(AnActionEvent event) {
    14          Project project = event.getProject();
    15          VirtualFile  vf = FileChooser.chooseFile(new FileChooserDescriptor(true, true, false, false, false, false), project, null);
    16          String path = "";
    17          String msg = "";
    18          if (vf != null) {
    19              path = vf.getCanonicalPath();
    20              msg = "Application path set to " + path;
    21  
    22          } else {
    23              msg = "Application path unset";
    24          }
    25          PropertiesComponent.getInstance(project).setValue("docker_app_path", path);
    26          Messages.showMessageDialog(project,  msg, "Confirmation", Messages.getInformationIcon());
    27      }
    28  }