public FlatWelcomeScreen() {
      super(new BorderLayout());
      mySlidingPanel.add("root", this);
      setBackground(getMainBackground());
      if (RecentProjectsManager.getInstance()
              .getRecentProjectsActions(false, isUseProjectGroups())
              .length
          > 0) {
        final JComponent recentProjects = createRecentProjects();
        add(recentProjects, BorderLayout.WEST);
        final JList projectsList = UIUtil.findComponentOfType(recentProjects, JList.class);
        if (projectsList != null) {
          projectsList
              .getModel()
              .addListDataListener(
                  new ListDataListener() {
                    @Override
                    public void intervalAdded(ListDataEvent e) {}

                    @Override
                    public void intervalRemoved(ListDataEvent e) {
                      removeIfNeeded();
                    }

                    private void removeIfNeeded() {
                      if (RecentProjectsManager.getInstance()
                              .getRecentProjectsActions(false, isUseProjectGroups())
                              .length
                          == 0) {
                        FlatWelcomeScreen.this.remove(recentProjects);
                        FlatWelcomeScreen.this.revalidate();
                        FlatWelcomeScreen.this.repaint();
                      }
                    }

                    @Override
                    public void contentsChanged(ListDataEvent e) {
                      removeIfNeeded();
                    }
                  });
          projectsList.addFocusListener(
              new FocusListener() {
                @Override
                public void focusGained(FocusEvent e) {
                  projectsList.repaint();
                }

                @Override
                public void focusLost(FocusEvent e) {
                  projectsList.repaint();
                }
              });
        }
      }
      add(createBody(), BorderLayout.CENTER);
    }
 public static String getBaseDir() {
   final String lastProjectLocation =
       RecentProjectsManager.getInstance().getLastProjectCreationLocation();
   if (lastProjectLocation != null) {
     return lastProjectLocation.replace('/', File.separatorChar);
   }
   final String userHome = SystemProperties.getUserHome();
   //noinspection HardCodedStringLiteral
   return userHome.replace('/', File.separatorChar)
       + File.separator
       + ApplicationNamesInfo.getInstance().getLowercaseProductName()
       + "Projects";
 }
 public static void updateLastProjectLocation(final String projectFilePath) {
   File lastProjectLocation = new File(projectFilePath);
   if (lastProjectLocation.isFile()) {
     lastProjectLocation =
         lastProjectLocation.getParentFile(); // for directory-based project storage
   }
   if (lastProjectLocation == null) { // the immediate parent of the ipr file
     return;
   }
   lastProjectLocation =
       lastProjectLocation.getParentFile(); // the candidate directory to be saved
   if (lastProjectLocation == null) {
     return;
   }
   String path = lastProjectLocation.getPath();
   try {
     path = FileUtil.resolveShortWindowsName(path);
   } catch (IOException e) {
     LOG.info(e);
     return;
   }
   RecentProjectsManager.getInstance()
       .setLastProjectCreationLocation(path.replace(File.separatorChar, '/'));
 }
  public FlatWelcomeFrame() {
    final JRootPane rootPane = getRootPane();
    myScreen = new FlatWelcomeScreen();

    final IdeGlassPaneImpl glassPane =
        new IdeGlassPaneImpl(rootPane) {
          @Override
          public void addNotify() {
            super.addNotify();
            rootPane.remove(getProxyComponent());
            //noinspection SSBasedInspection
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    JBProtocolCommand.handleCurrentCommand();
                  }
                });
          }
        };

    setGlassPane(glassPane);
    glassPane.setVisible(false);
    // setUndecorated(true);
    setContentPane(myScreen.getWelcomePanel());
    setTitle("Welcome to " + ApplicationNamesInfo.getInstance().getFullProductName());
    AppUIUtil.updateWindowIcon(this);
    final int width =
        RecentProjectsManager.getInstance().getRecentProjectsActions(false).length == 0 ? 666 : 777;
    setSize(JBUI.size(width, 460));
    setResizable(false);
    // int x = bounds.x + (bounds.width - getWidth()) / 2;
    // int y = bounds.y + (bounds.height - getHeight()) / 2;
    Point location = DimensionService.getInstance().getLocation(WelcomeFrame.DIMENSION_KEY, null);
    Rectangle screenBounds =
        ScreenUtil.getScreenRectangle(location != null ? location : new Point(0, 0));
    setLocation(
        new Point(
            screenBounds.x + (screenBounds.width - getWidth()) / 2,
            screenBounds.y + (screenBounds.height - getHeight()) / 3));

    // setLocation(x, y);
    ProjectManager.getInstance()
        .addProjectManagerListener(
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(Project project) {
                dispose();
              }
            });

    myBalloonLayout = new BalloonLayoutImpl(rootPane, JBUI.insets(8));

    WelcomeFrame.setupCloseAction(this);
    MnemonicHelper.init(this);
    Disposer.register(
        ApplicationManager.getApplication(),
        new Disposable() {
          @Override
          public void dispose() {
            FlatWelcomeFrame.this.dispose();
          }
        });
  }