public GoRunConfigurationEditorForm(final Project project) {

    applicationName
        .getButton()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {

                TreeFileChooser fileChooser =
                    TreeFileChooserFactory.getInstance(project)
                        .createFileChooser(
                            "Go Application Chooser",
                            null,
                            GoFileType.INSTANCE,
                            new TreeFileChooser.PsiFileFilter() {
                              public boolean accept(PsiFile file) {

                                if (!(file instanceof GoFile)) {
                                  return false;
                                }

                                GoFile goFile = (GoFile) file;

                                return goFile.getPackage().isMainPackage();
                              }
                            },
                            true,
                            false);

                fileChooser.showDialog();

                PsiFile selectedFile = fileChooser.getSelectedFile();
                if (selectedFile != null) {
                  setChosenFile(selectedFile.getVirtualFile());
                }
              }
            });

    buildDirectoryPathBrowser.addBrowseFolderListener(
        "Go executable build path",
        "Go executable build path",
        project,
        new FileChooserDescriptor(false, true, false, false, false, false));

    workingDirectoryBrowser.addBrowseFolderListener(
        "Application working directory",
        "Application working directory",
        project,
        new FileChooserDescriptor(false, true, false, false, false, false));

    buildBeforeRunCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            buildDirectoryPathBrowser.setEnabled(buildBeforeRunCheckBox.isSelected());
          }
        });
  }
Exemplo n.º 2
0
 PluginPathPane(final Project project, final String plugin) {
   super(new BorderLayout());
   _importCheckbox = new JCheckBox("Import");
   _importCheckbox.addActionListener(
       new ActionListener() {
         public void actionPerformed(final ActionEvent e) {
           _pathTextField.setEnabled(isImport());
         }
       });
   _pathTextField = new TextFieldWithBrowseButton();
   _pathTextField.setEnabled(false);
   try {
     _pathTextField.setText(FindBugsCustomPluginUtil.getAsFile(plugin).getPath());
   } catch (final MalformedURLException e) {
     LOGGER.debug("invalid plugin=" + plugin, e);
     _pathTextField.setText(plugin);
   }
   _pathTextField.addBrowseFolderListener(
       "Choose plugin",
       "Please select the plugin archive.",
       project,
       createJarChooserDescriptor());
   add(_importCheckbox, BorderLayout.NORTH);
   add(_pathTextField);
   add(
       new Box.Filler(new Dimension(16, 0), new Dimension(16, 0), new Dimension(16, 0)),
       BorderLayout.WEST);
 }
  private void initControls(final LauncherParameters launcherParameters) {
    final LauncherParameters.LauncherType launcherType = launcherParameters.getLauncherType();
    myDefaultOSApplicationRadioButton.setSelected(
        launcherType == LauncherParameters.LauncherType.OSDefault);
    myBrowserRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Browser);
    myPlayerRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Player);

    myBrowserSelector.setSelected(launcherParameters.getBrowser());

    myPlayerTextWithBrowse.setText(
        FileUtil.toSystemDependentName(launcherParameters.getPlayerPath()));
    myPlayerTextWithBrowse.addBrowseFolderListener(
        null,
        null,
        myProject,
        new FileChooserDescriptor(true, true, false, false, false, false) {
          @Override
          public boolean isFileSelectable(final VirtualFile file) {
            return SystemInfo.isMac
                    && file.isDirectory()
                    && "app".equalsIgnoreCase(file.getExtension())
                || !file.isDirectory();
          }
        });
    myNewPlayerInstanceCheckBox.setVisible(SystemInfo.isMac);
  }
Exemplo n.º 4
0
 /**
  * The constructor
  *
  * @param project the context project
  */
 public GitVcsPanel(@NotNull Project project) {
   myVcs = GitVcs.getInstance(project);
   myAppSettings = GitVcsApplicationSettings.getInstance();
   myProjectSettings = GitVcsSettings.getInstance(project);
   myProject = project;
   mySSHExecutableComboBox.addItem(IDEA_SSH);
   mySSHExecutableComboBox.addItem(NATIVE_SSH);
   mySSHExecutableComboBox.setSelectedItem(
       GitVcsSettings.isDefaultIdeaSsh() ? IDEA_SSH : NATIVE_SSH);
   mySSHExecutableComboBox.setToolTipText(
       GitBundle.message(
           "git.vcs.config.ssh.mode.tooltip",
           ApplicationNamesInfo.getInstance().getFullProductName()));
   myTestButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           testConnection();
         }
       });
   myConvertTextFilesComboBox.addItem(CRLF_DO_NOT_CONVERT);
   myConvertTextFilesComboBox.addItem(CRLF_CONVERT_TO_PROJECT);
   myConvertTextFilesComboBox.addItem(CRLF_ASK);
   myConvertTextFilesComboBox.setSelectedItem(CRLF_ASK);
   myGitField.addBrowseFolderListener(
       GitBundle.getString("find.git.title"),
       GitBundle.getString("find.git.description"),
       project,
       new FileChooserDescriptor(true, false, false, false, false, false));
 }
 private void setUpChooseHtmlToShow() {
   FileChooserDescriptor fileChooserDescriptor =
       FileChooserDescriptorFactory.createSingleFileDescriptor(StdFileTypes.HTML);
   fileChooserDescriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
   htmlChooseFile.addBrowseFolderListener(
       "Choose file to show after translation is finished", null, project, fileChooserDescriptor);
 }
  @SuppressWarnings("UseJBColor") // Colors are used for the graphics generator, not the plugin UI
  public RasterAssetSetStep(
      TemplateWizardState state,
      @Nullable Project project,
      @Nullable Module module,
      @Nullable Icon sidePanelIcon,
      UpdateListener updateListener,
      @Nullable VirtualFile invocationTarget) {
    super(state, project, module, sidePanelIcon, updateListener, invocationTarget);

    // Speed the scrolling of myScrollPane
    myScrollPane.getVerticalScrollBar().setUnitIncrement(16);

    register(ATTR_TEXT, myText);
    register(ATTR_SCALING, myCropRadioButton, Scaling.CROP);
    register(ATTR_SCALING, myCenterRadioButton, Scaling.CENTER);
    register(ATTR_SHAPE, myCircleRadioButton, GraphicGenerator.Shape.CIRCLE);
    register(ATTR_SHAPE, myNoneRadioButton, GraphicGenerator.Shape.NONE);
    register(ATTR_SHAPE, mySquareRadioButton, GraphicGenerator.Shape.SQUARE);
    register(ATTR_SHAPE, myVerticalRadioButton, GraphicGenerator.Shape.VRECT);
    register(ATTR_SHAPE, myHorizontalRadioButton, GraphicGenerator.Shape.HRECT);
    register(ATTR_DOGEAR, myDogEarEffectCheckBox);
    register(ATTR_PADDING, myPaddingSlider);
    register(ATTR_TRIM, myTrimBlankSpace);
    register(ATTR_FONT, myFontFamily);
    register(ATTR_SOURCE_TYPE, myImageRadioButton, AssetStudioAssetGenerator.SourceType.IMAGE);
    register(ATTR_SOURCE_TYPE, myClipartRadioButton, AssetStudioAssetGenerator.SourceType.CLIPART);
    register(ATTR_SOURCE_TYPE, myTextRadioButton, AssetStudioAssetGenerator.SourceType.TEXT);
    register(ATTR_FOREGROUND_COLOR, myForegroundColor);
    register(ATTR_BACKGROUND_COLOR, myBackgroundColor);
    register(ATTR_ASSET_TYPE, myAssetTypeComboBox);
    register(ATTR_ASSET_THEME, myChooseThemeComboBox);
    register(ATTR_ASSET_NAME, myResourceNameField);

    myImageFile.addBrowseFolderListener(
        null, null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
    myForegroundColor.setSelectedColor(Color.BLUE);
    myBackgroundColor.setSelectedColor(Color.WHITE);

    for (String font :
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) {
      myFontFamily.addItem(new ComboBoxItem(font, font, 1, 1));
      if (font.equals(myTemplateState.get(ATTR_FONT))) {
        myFontFamily.setSelectedIndex(myFontFamily.getItemCount() - 1);
      }
    }

    myChooseClipart.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            displayClipartDialog();
          }
        });

    populateComboBox(myAssetTypeComboBox, AssetType.class);
    populateComboBox(myChooseThemeComboBox, ActionBarIconGenerator.Theme.class);
  }
  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    final JPanel content = new JPanel(new BorderLayout());

    final JPanel topLine = new JPanel(new BorderLayout());
    content.setBorder(
        IdeBorderFactory.createTitledBorder(
            "Thrift compiler " + myGenerator.getType().name(), false));
    myOutputFolderChooser.addBrowseFolderListener(
        new TextBrowseFolderListener(
            FileChooserDescriptorFactory.createSingleFolderDescriptor(), myProject) {
          @Nullable
          @Override
          protected VirtualFile getInitialFile() {
            if (myGenerator.getOutputDir() != null) {
              return LocalFileFinder.findFile(myGenerator.getOutputDir());
            } else {
              return null;
            }
          }

          @Override
          protected void onFileChosen(@NotNull VirtualFile chosenFile) {
            final String absolutePath = VfsUtil.virtualToIoFile(chosenFile).getAbsolutePath();
            myOutputFolderChooser.setText(absolutePath);
          }
        });

    topLine.add(new JBLabel("Output folder:"), BorderLayout.WEST);
    topLine.add(myOutputFolderChooser, BorderLayout.CENTER);

    content.add(topLine, BorderLayout.NORTH);

    final JPanel options = new JPanel(new BorderLayout());
    content.add(options, BorderLayout.CENTER);

    myPane = AOptionPane.get(myGenerator.getType());
    if (myPane != null) {
      options.setBorder(IdeBorderFactory.createTitledBorder("Additional options"));
      options.add(myPane.getPanel());
      myPane.setValues(myGenerator);
    } else {
      options.setBorder(null);
    }

    final String url = myGenerator.getOutputDir();
    final VirtualFile file =
        url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url);
    myOutputFolderChooser.setText(file == null ? VfsUtil.urlToPath(url) : file.getPath());

    return content;
  }
  private static void setupFileChooser(
      @NotNull JLabel label,
      @NotNull TextFieldWithBrowseButton fileChooser,
      @NotNull String title) {
    label.setLabelFor(fileChooser);

    fileChooser.addBrowseFolderListener(
        title,
        null,
        null,
        new FileChooserDescriptor(true, false, false, false, false, false),
        TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
        false);
  }
 @NotNull
 private static FileChooserDescriptor addFileChooser(
     @NotNull final String title,
     @NotNull final TextFieldWithBrowseButton textField,
     @NotNull final Project project) {
   final FileChooserDescriptor fileChooserDescriptor =
       new FileChooserDescriptor(false, true, false, false, false, false) {
         @Override
         public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
           return super.isFileVisible(file, showHiddenFiles) && file.isDirectory();
         }
       };
   fileChooserDescriptor.setTitle(title);
   textField.addBrowseFolderListener(title, null, project, fileChooserDescriptor);
   return fileChooserDescriptor;
 }
    private AskForWorkDir(Project project) {
      super(project);

      setTitle("Set Sphinx Working Directory: ");
      init();
      VirtualFile baseDir = project.getBaseDir();
      String path = baseDir != null ? baseDir.getPath() : "";
      myInputFile.setText(path);
      myInputFile.setEditable(false);
      myInputFile.addBrowseFolderListener(
          "Choose sphinx working directory (containing makefile): ",
          null,
          project,
          FileChooserDescriptorFactory.createSingleFolderDescriptor());

      myPanel.setPreferredSize(new Dimension(600, 20));
    }
 private static TextFieldWithBrowseButton createBrowseField() {
   TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
   textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
   textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
   final FileChooserDescriptor fileChooserDescriptor =
       new FileChooserDescriptor(true, false, false, false, false, false) {
         public boolean isFileSelectable(VirtualFile file) {
           //noinspection HardCodedStringLiteral
           return file.getName().endsWith(".png");
         }
       };
   textField.addBrowseFolderListener(
       IdeBundle.message("title.browse.icon"),
       IdeBundle.message("prompt.browse.icon.for.selected.action"),
       null,
       fileChooserDescriptor);
   InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
   return textField;
 }
 @NotNull
 private JPanel createSelectDirectoryPanel(
     @NotNull Project project, @NotNull JTextField directoryTextField) {
   FileChooserDescriptor fileChooserDescriptor =
       FileChooserDescriptorFactory.createSingleFolderDescriptor();
   String adapterName = getAssertFrameworkAdapterName();
   String title = "Select a directory for " + adapterName + " files";
   String description = adapterName + " source files will be copied to the selected directory";
   TextFieldWithBrowseButton directoryTextFieldWithBrowseButton =
       new TextFieldWithBrowseButton(directoryTextField);
   directoryTextFieldWithBrowseButton.addBrowseFolderListener(
       title, description, project, fileChooserDescriptor);
   Dimension oldDimension = directoryTextFieldWithBrowseButton.getPreferredSize();
   directoryTextFieldWithBrowseButton.setMaximumSize(oldDimension);
   JPanel panel = new JPanel(new BorderLayout(0, 2));
   panel.add(new JLabel("Copy these files to directory:"), BorderLayout.NORTH);
   panel.add(directoryTextFieldWithBrowseButton, BorderLayout.CENTER);
   return SwingHelper.wrapWithHorizontalStretch(panel);
 }
  public PathMacroEditor(String title, String macroName, String value, Validator validator) {
    super(true);
    setTitle(title);
    myValidator = validator;
    myNameField.setText(macroName);
    DocumentListener documentListener =
        new DocumentAdapter() {
          public void textChanged(DocumentEvent event) {
            updateControls();
          }
        };
    myNameField.getDocument().addDocumentListener(documentListener);
    myValueField.setText(value);
    myValueField.addBrowseFolderListener(
        null,
        null,
        null,
        new FileChooserDescriptor(false, true, true, false, true, false),
        new TextComponentAccessor<JTextField>() {
          public String getText(JTextField component) {
            return component.getText();
          }

          public void setText(JTextField component, String text) {
            final int len = text.length();
            if (len > 0 && text.charAt(len - 1) == File.separatorChar) {
              text = text.substring(0, len - 1);
            }
            component.setText(text);
          }
        });
    myValueField.getTextField().getDocument().addDocumentListener(documentListener);

    init();
    updateControls();
  }
  private void setUpChooseGenerateFilePath() {
    FileChooserDescriptor fileChooserDescriptor =
        FileChooserDescriptorFactory.getDirectoryChooserDescriptor(
            "directory where generated files will be stored");
    fileChooserDescriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
    generatedChooseFile.addBrowseFolderListener(null, null, project, fileChooserDescriptor);
    final JTextField textField = generatedChooseFile.getTextField();
    textField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                onChange();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                onChange();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                onChange();
              }

              private void onChange() {
                File file = new File(generatedChooseFile.getText());
                if (!file.isDirectory()) {
                  textField.setForeground(Color.RED);
                } else {
                  textField.setForeground(Color.BLACK);
                }
              }
            });
  }
Exemplo n.º 15
0
  public static void initDartSdkAndDartiumControls(
      final @Nullable Project project,
      final @NotNull TextFieldWithBrowseButton dartSdkPathComponent,
      final @NotNull JBLabel versionLabel,
      final @NotNull TextFieldWithBrowseButton dartiumPathComponent,
      final @NotNull Computable<Boolean> isResettingControlsComputable) {
    final TextComponentAccessor<JTextField> textComponentAccessor =
        new TextComponentAccessor<JTextField>() {
          @Override
          public String getText(final JTextField component) {
            return component.getText();
          }

          @Override
          public void setText(final JTextField component, @NotNull String text) {
            if (!text.isEmpty() && !isDartSdkHome(text)) {
              final String probablySdkPath = text + "/dart-sdk";
              if (isDartSdkHome(probablySdkPath)) {
                component.setText(FileUtilRt.toSystemDependentName(probablySdkPath));
                return;
              }
            }

            component.setText(FileUtilRt.toSystemDependentName(text));
          }
        };

    final ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> browseFolderListener =
        new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            "Select Dart SDK path",
            null,
            dartSdkPathComponent,
            project,
            FileChooserDescriptorFactory.createSingleFolderDescriptor(),
            textComponentAccessor);
    dartSdkPathComponent.addBrowseFolderListener(project, browseFolderListener);

    dartiumPathComponent.addBrowseFolderListener(
        "Select Dartium browser path",
        null,
        project,
        FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor());

    dartSdkPathComponent
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(final DocumentEvent e) {
                final String sdkHomePath = dartSdkPathComponent.getText().trim();
                versionLabel.setText(sdkHomePath.isEmpty() ? "" : getSdkVersion(sdkHomePath));

                if (!isResettingControlsComputable.compute() && isDartSdkHome(sdkHomePath)) {
                  final String dartiumPath = DartiumUtil.getDartiumPathForSdk(sdkHomePath);
                  if (dartiumPath != null) {
                    dartiumPathComponent.setText(FileUtilRt.toSystemDependentName(dartiumPath));
                  }
                }
              }
            });
  }
Exemplo n.º 16
0
  protected JComponent createNorthPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    panel.setBorder(IdeBorderFactory.createBorder());

    myNameLabel = new JLabel();
    panel.add(
        myNameLabel,
        new GridBagConstraints(
            0,
            0,
            2,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 8, 4, 8),
            0,
            0));

    panel.add(
        new JLabel(RefactoringBundle.message("move.files.to.directory.label")),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 8, 4, 8),
            0,
            0));

    myTargetDirectoryField = new TextFieldWithBrowseButton();
    myTargetDirectoryField.addBrowseFolderListener(
        RefactoringBundle.message("select.target.directory"),
        RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),
        null,
        FileChooserDescriptorFactory.createSingleFolderDescriptor());
    myTargetDirectoryField.setTextFieldPreferredWidth(60);
    panel.add(
        myTargetDirectoryField,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 0, 4, 8),
            0,
            0));

    myTargetDirectoryField
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              public void textChanged(DocumentEvent event) {
                validateOKButton();
              }
            });

    return panel;
  }
  public void bindModuleSettings() {

    myNamePathComponent
        .getNameComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myModuleNameChangedByUser) {
                  setModuleName(myNamePathComponent.getNameValue());
                }
              }
            });

    myModuleContentRoot.addBrowseFolderListener(
        ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"),
        ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
        myWizardContext.getProject(),
        BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);

    myNamePathComponent
        .getPathComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myContentRootChangedByUser) {
                  setModuleContentRoot(myNamePathComponent.getPath());
                }
              }
            });
    myModuleName
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myModuleNameDocListenerEnabled) {
                  myModuleNameChangedByUser = true;
                }
                String path = getDefaultBaseDir(myWizardContext);
                final String moduleName = getModuleName();
                if (path.length() > 0
                    && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
                  path += "/" + moduleName;
                }
                if (!myContentRootChangedByUser) {
                  final boolean f = myModuleNameChangedByUser;
                  myModuleNameChangedByUser = true;
                  setModuleContentRoot(path);
                  myModuleNameChangedByUser = f;
                }
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(path);
                }
              }
            });
    myModuleContentRoot
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myContentRootDocListenerEnabled) {
                  myContentRootChangedByUser = true;
                }
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(getModuleContentRoot());
                }
                if (!myModuleNameChangedByUser) {
                  final String path = FileUtil.toSystemIndependentName(getModuleContentRoot());
                  final int idx = path.lastIndexOf("/");

                  boolean f = myContentRootChangedByUser;
                  myContentRootChangedByUser = true;

                  boolean i = myImlLocationChangedByUser;
                  myImlLocationChangedByUser = true;

                  setModuleName(idx >= 0 ? path.substring(idx + 1) : "");

                  myContentRootChangedByUser = f;
                  myImlLocationChangedByUser = i;
                }
              }
            });

    myModuleFileLocation.addBrowseFolderListener(
        ProjectBundle.message("project.new.wizard.module.file.chooser.title"),
        ProjectBundle.message("project.new.wizard.module.file.description"),
        myWizardContext.getProject(),
        BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
    myModuleFileLocation
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myImlLocationDocListenerEnabled) {
                  myImlLocationChangedByUser = true;
                }
              }
            });
    myNamePathComponent
        .getPathComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(myNamePathComponent.getPath());
                }
              }
            });
    if (myWizardContext.isCreatingNewProject()) {
      setModuleName(myNamePathComponent.getNameValue());
      setModuleContentRoot(myNamePathComponent.getPath());
      setImlFileLocation(myNamePathComponent.getPath());
    } else {
      final Project project = myWizardContext.getProject();
      assert project != null;
      VirtualFile baseDir = project.getBaseDir();
      if (baseDir != null) { // e.g. was deleted
        final String baseDirPath = baseDir.getPath();
        String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
        String contentRoot = baseDirPath + "/" + moduleName;
        if (!Comparing.strEqual(project.getName(), myWizardContext.getProjectName())
            && !myWizardContext.isCreatingNewProject()
            && myWizardContext.getProjectName() != null) {
          moduleName =
              ProjectWizardUtil.findNonExistingFileName(
                  myWizardContext.getProjectFileDirectory(), myWizardContext.getProjectName(), "");
          contentRoot = myWizardContext.getProjectFileDirectory();
        }
        setModuleName(moduleName);
        setModuleContentRoot(contentRoot);
        setImlFileLocation(contentRoot);
        myModuleName.select(0, moduleName.length());
      }
    }
  }
  public ProjectNameWithTypeStep(
      final WizardContext wizardContext, StepSequence sequence, final WizardMode mode) {
    super(wizardContext, mode);
    mySequence = sequence;
    myAdditionalContentPanel.add(
        myModulePanel,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1,
            1,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    myHeader.setVisible(myWizardContext.isCreatingNewProject() && !isCreateFromTemplateMode());
    myCreateModuleCb.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            UIUtil.setEnabled(myInternalPanel, myCreateModuleCb.isSelected(), true);
            fireStateChanged();
          }
        });
    myCreateModuleCb.setSelected(true);
    if (!myWizardContext.isCreatingNewProject()) {
      myInternalPanel.setBorder(null);
    }
    myModuleDescriptionPane.setContentType(UIUtil.HTML_MIME);
    myModuleDescriptionPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                BrowserUtil.launchBrowser(e.getURL().toString());
              } catch (IllegalThreadStateException ex) {
                // it's nnot a problem
              }
            }
          }
        });
    myModuleDescriptionPane.setEditable(false);

    final DefaultListModel defaultListModel = new DefaultListModel();
    for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
      defaultListModel.addElement(builder);
    }
    myTypesList.setModel(defaultListModel);
    myTypesList.setSelectionModel(new PermanentSingleSelectionModel());
    myTypesList.setCellRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              final JList list,
              final Object value,
              final int index,
              final boolean isSelected,
              final boolean cellHasFocus) {
            final Component rendererComponent =
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            final ModuleBuilder builder = (ModuleBuilder) value;
            setIcon(builder.getBigIcon());
            setDisabledIcon(builder.getBigIcon());
            setText(builder.getPresentableName());
            return rendererComponent;
          }
        });
    myTypesList.addListSelectionListener(
        new ListSelectionListener() {
          @SuppressWarnings({"HardCodedStringLiteral"})
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
              return;
            }

            final ModuleBuilder typeSelected = (ModuleBuilder) myTypesList.getSelectedValue();

            final StringBuilder sb = new StringBuilder("<html><body><font face=\"Verdana\" ");
            sb.append(SystemInfo.isMac ? "" : "size=\"-1\"").append('>');
            sb.append(typeSelected.getDescription()).append("</font></body></html>");

            myModuleDescriptionPane.setText(sb.toString());

            boolean focusOwner = myTypesList.isFocusOwner();
            fireStateChanged();
            if (focusOwner) {
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      myTypesList.requestFocusInWindow();
                    }
                  });
            }
          }
        });
    myTypesList.setSelectedIndex(0);
    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        myWizardContext.requestNextStep();
        return true;
      }
    }.installOn(myTypesList);

    final Dimension preferredSize = calcTypeListPreferredSize(ModuleBuilder.getAllBuilders());
    final JBScrollPane pane = IJSwingUtilities.findParentOfType(myTypesList, JBScrollPane.class);
    pane.setPreferredSize(preferredSize);
    pane.setMinimumSize(preferredSize);

    myNamePathComponent
        .getNameComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myModuleNameChangedByUser) {
                  setModuleName(myNamePathComponent.getNameValue());
                }
              }
            });

    myModuleContentRoot.addBrowseFolderListener(
        ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"),
        ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
        myWizardContext.getProject(),
        BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);

    myNamePathComponent
        .getPathComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myContentRootChangedByUser) {
                  setModuleContentRoot(myNamePathComponent.getPath());
                }
              }
            });
    myModuleName
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myModuleNameDocListenerEnabled) {
                  myModuleNameChangedByUser = true;
                }
                String path = getDefaultBaseDir(wizardContext);
                final String moduleName = getModuleName();
                if (path.length() > 0
                    && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
                  path += "/" + moduleName;
                }
                if (!myContentRootChangedByUser) {
                  final boolean f = myModuleNameChangedByUser;
                  myModuleNameChangedByUser = true;
                  setModuleContentRoot(path);
                  myModuleNameChangedByUser = f;
                }
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(path);
                }
              }
            });
    myModuleContentRoot
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myContentRootDocListenerEnabled) {
                  myContentRootChangedByUser = true;
                }
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(myModuleContentRoot.getText());
                }
                if (!myModuleNameChangedByUser) {
                  final String path =
                      FileUtil.toSystemIndependentName(myModuleContentRoot.getText());
                  final int idx = path.lastIndexOf("/");

                  boolean f = myContentRootChangedByUser;
                  myContentRootChangedByUser = true;

                  boolean i = myImlLocationChangedByUser;
                  myImlLocationChangedByUser = true;

                  setModuleName(idx >= 0 ? path.substring(idx + 1) : "");

                  myContentRootChangedByUser = f;
                  myImlLocationChangedByUser = i;
                }
              }
            });

    myModuleFileLocation.addBrowseFolderListener(
        ProjectBundle.message("project.new.wizard.module.file.chooser.title"),
        ProjectBundle.message("project.new.wizard.module.file.description"),
        myWizardContext.getProject(),
        BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
    myModuleFileLocation
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (myImlLocationDocListenerEnabled) {
                  myImlLocationChangedByUser = true;
                }
              }
            });
    myNamePathComponent
        .getPathComponent()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                if (!myImlLocationChangedByUser) {
                  setImlFileLocation(myNamePathComponent.getPath());
                }
              }
            });
    if (wizardContext.isCreatingNewProject()) {
      setModuleName(myNamePathComponent.getNameValue());
      setModuleContentRoot(myNamePathComponent.getPath());
      setImlFileLocation(myNamePathComponent.getPath());
    } else {
      final Project project = wizardContext.getProject();
      assert project != null;
      VirtualFile baseDir = project.getBaseDir();
      if (baseDir != null) { // e.g. was deleted
        final String baseDirPath = baseDir.getPath();
        String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
        String contentRoot = baseDirPath + "/" + moduleName;
        if (!Comparing.strEqual(project.getName(), wizardContext.getProjectName())
            && !wizardContext.isCreatingNewProject()
            && wizardContext.getProjectName() != null) {
          moduleName =
              ProjectWizardUtil.findNonExistingFileName(
                  wizardContext.getProjectFileDirectory(), wizardContext.getProjectName(), "");
          contentRoot = wizardContext.getProjectFileDirectory();
        }
        setModuleName(moduleName);
        setModuleContentRoot(contentRoot);
        setImlFileLocation(contentRoot);
        myModuleName.select(0, moduleName.length());
      }
    }

    if (isCreateFromTemplateMode()) {
      replaceModuleTypeOptions(new JPanel());
    } else {
      final AnAction arrow =
          new AnAction() {
            @Override
            public void actionPerformed(AnActionEvent e) {
              if (e.getInputEvent() instanceof KeyEvent) {
                final int code = ((KeyEvent) e.getInputEvent()).getKeyCode();
                if (!myCreateModuleCb.isSelected()) return;
                int i = myTypesList.getSelectedIndex();
                if (code == KeyEvent.VK_DOWN) {
                  if (++i == myTypesList.getModel().getSize()) return;
                } else if (code == KeyEvent.VK_UP) {
                  if (--i == -1) return;
                }
                myTypesList.setSelectedIndex(i);
              }
            }
          };
      CustomShortcutSet shortcutSet = new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN);
      arrow.registerCustomShortcutSet(shortcutSet, myNamePathComponent.getNameComponent());
      arrow.registerCustomShortcutSet(shortcutSet, myModuleName);
    }
  }