@Override
 protected SettingsEditor<? extends RunConfiguration> createConfigurationEditor() {
   RestConfigurationEditor editor =
       new RestConfigurationEditor(getProject(), this, new SphinxTasksModel());
   editor.setConfigurationName("Sphinx task");
   editor.setOpenInBrowserVisible(false);
   editor.setInputDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor());
   editor.setOutputDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor());
   return editor;
 }
 public JavadocPathsEditor(Sdk sdk) {
   super(
       ProjectBundle.message("sdk.configure.javadoc.tab"),
       JavadocOrderRootType.getInstance(),
       FileChooserDescriptorFactory.createMultipleJavaPathDescriptor());
   mySdk = sdk;
 }
 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);
 }
 public PyRemotePathEditor(Sdk sdk) {
   super(
       "Classes",
       OrderRootType.CLASSES,
       FileChooserDescriptorFactory.createAllButJarContentsDescriptor());
   mySdk = sdk;
   myRemoteSdkData = (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData();
 }
  @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);
  }
  /** Init components */
  private void initListeners() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(GitBundle.getString("clone.destination.directory.title"));
    fcd.setDescription(GitBundle.getString("clone.destination.directory.description"));
    fcd.setHideIgnored(false);
    myParentDirectory.addActionListener(
        new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(),
            fcd.getDescription(),
            myParentDirectory,
            myProject,
            fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
          @Override
          protected VirtualFile getInitialFile() {
            // suggest project base directory only if nothing is typed in the component.
            String text = getComponentText();
            if (text.length() == 0) {
              VirtualFile file = myProject.getBaseDir();
              if (file != null) {
                return file;
              }
            }
            return super.getInitialFile();
          }
        });

    final DocumentListener updateOkButtonListener =
        new DocumentAdapter() {
          @Override
          protected void textChanged(DocumentEvent e) {
            updateButtons();
          }
        };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    String parentDir = GitRememberedInputs.getInstance().getCloneParentDir();
    if (StringUtil.isEmptyOrSpaces(parentDir)) {
      parentDir = ProjectUtil.getBaseDir();
    }
    myParentDirectory.setText(parentDir);

    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    myTestButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            test();
          }
        });

    setOKActionEnabled(false);
    myTestButton.setEnabled(false);
  }
  @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;
  }
 @NotNull
 public List<? extends DirectoryCopyPackagingElement> chooseAndCreate(
     @NotNull ArtifactEditorContext context,
     @NotNull Artifact artifact,
     @NotNull CompositePackagingElement<?> parent) {
   final FileChooserDescriptor descriptor =
       FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
   final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null);
   final List<DirectoryCopyPackagingElement> list = new ArrayList<DirectoryCopyPackagingElement>();
   for (VirtualFile file : files) {
     list.add(new DirectoryCopyPackagingElement(file.getPath()));
   }
   return list;
 }
Beispiel #9
0
  @Nullable
  public static AddModuleWizard selectFileAndCreateWizard(
      final Project project, Component dialogParent) {
    FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    descriptor.setHideIgnored(false);
    descriptor.setTitle("Select File or Directory to Import");
    ProjectImportProvider[] providers =
        ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions();
    String description = getFileChooserDescription(project);
    descriptor.setDescription(description);

    return selectFileAndCreateWizard(project, dialogParent, descriptor, providers);
  }
 private PythonPathEditor createPathEditor(final Sdk sdk) {
   if (PySdkUtil.isRemote(sdk)) {
     return new PyRemotePathEditor(sdk);
   } else {
     return new PythonPathEditor(
         "Classes",
         OrderRootType.CLASSES,
         FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
       @Override
       protected void onReloadButtonClicked() {
         reloadSdk();
       }
     };
   }
 }
 private void setupRootAndAnnotateExternally(
     @NotNull final OrderEntry entry,
     @NotNull final Project project,
     @NotNull final PsiModifierListOwner listOwner,
     @NotNull final String annotationFQName,
     @NotNull final PsiFile fromFile,
     @NotNull final String packageName,
     @Nullable final PsiNameValuePair[] value) {
   final FileChooserDescriptor descriptor =
       FileChooserDescriptorFactory.createSingleFolderDescriptor();
   descriptor.setTitle(
       ProjectBundle.message(
           "external.annotations.root.chooser.title", entry.getPresentableName()));
   descriptor.setDescription(
       ProjectBundle.message("external.annotations.root.chooser.description"));
   final VirtualFile newRoot = FileChooser.chooseFile(descriptor, project, null);
   if (newRoot == null) {
     notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
     return;
   }
   new WriteCommandAction(project) {
     @Override
     protected void run(final Result result) throws Throwable {
       appendChosenAnnotationsRoot(entry, newRoot);
       XmlFile xmlFileInRoot =
           findXmlFileInRoot(findExternalAnnotationsXmlFiles(listOwner), newRoot);
       if (xmlFileInRoot != null) { // file already exists under appeared content root
         if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFileInRoot)) {
           notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
           return;
         }
         annotateExternally(listOwner, annotationFQName, xmlFileInRoot, fromFile, value);
       } else {
         final XmlFile annotationsXml = createAnnotationsXml(newRoot, packageName);
         if (annotationsXml != null) {
           final List<PsiFile> createdFiles = new ArrayList<PsiFile>();
           createdFiles.add(annotationsXml);
           String fqn = getFQN(packageName, fromFile);
           if (fqn != null) {
             myExternalAnnotations.put(fqn, createdFiles);
           }
         }
         annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
       }
     }
   }.execute();
 }
    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));
    }
 @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 ContentEntryTreeEditor(
      Project project, List<ModuleSourceRootEditHandler<?>> editHandlers) {
    myProject = project;
    myEditHandlers = editHandlers;
    myTree = new Tree();
    myTree.setRootVisible(true);
    myTree.setShowsRootHandles(true);

    myEditingActionsGroup = new DefaultActionGroup();

    TreeUtil.installActions(myTree);
    new TreeSpeedSearch(myTree);

    myTreePanel = new MyPanel(new BorderLayout());
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    myTreePanel.add(
        new ToolbarPanel(scrollPane, myEditingActionsGroup, TOOLBAR_PLACE), BorderLayout.CENTER);

    myTreePanel.setVisible(false);
    myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
    myDescriptor.setShowFileSystemRoots(false);
  }
  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);
                }
              }
            });
  }
  protected JComponent createNorthPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(0, 2, 0, 0);

    myNameLabel = new JLabel();
    panel.add(myNameLabel, c);
    c.insets.top = 10;
    c.gridy++;
    panel.add(new JLabel(RefactoringBundle.message("move.files.to.directory.label")), c);
    c.insets.top = 0;

    myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
    final List<String> recentEntries =
        RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
    if (recentEntries != null) {
      myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
    }
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myTargetDirectoryField.addBrowseFolderListener(
        RefactoringBundle.message("select.target.directory"),
        RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),
        myProject,
        descriptor,
        TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor();
    FileChooserFactory.getInstance()
        .installFileCompletion(textField, descriptor, true, getDisposable());
    myTargetDirectoryField.setTextFieldPreferredWidth(60);
    c.insets.left = 0;
    c.gridy++;
    panel.add(myTargetDirectoryField, c);
    String shortcutText =
        KeymapUtil.getFirstKeyboardShortcutText(
            ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
    final JLabel label =
        new JLabel(RefactoringBundle.message("path.completion.shortcut", shortcutText));
    UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label);
    c.insets.left = 6;
    c.gridy++;
    panel.add(label, c);

    myCbSearchForReferences =
        new NonFocusableCheckBox(RefactoringBundle.message("search.for.references"));
    myCbSearchForReferences.setSelected(
        RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE);
    c.insets.top = 10;
    c.insets.left = 0;
    c.gridy++;
    panel.add(myCbSearchForReferences, c);

    textField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                validateOKButton();
              }
            });
    Disposer.register(getDisposable(), myTargetDirectoryField);

    return panel;
  }
Beispiel #17
0
  public NewLanguageSettings(String projectPath) {
    super(new GridLayoutManager(5, 1, new Insets(0, 5, 5, 5), -1, -1));
    myProjectPath = projectPath;

    this.add(new JLabel("Language name:"), Util.getGridConstraints(0));
    myLanguageName = new JTextField();
    myLanguageName.setName("Name");
    myLanguageName
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(DocumentEvent p0) {
                if ((myProjectPath == null || myProjectPath.length() == 0)) {
                  return;
                }
                String path = myProjectPath + File.separator + "languages" + File.separator;
                final String langName = getLanguageName();
                if (!(langName.equals(getLanguageLocation()))) {
                  path += langName;
                }
                if (!(myLangLocationChangedByUser)) {
                  setLanguageLocation(path);
                }
                fireChanged();
              }
            });
    this.add(myLanguageName, Util.getGridConstraints(1));

    myLanguageLocation = new JTextField();
    myLanguageLocation.setName("Path");
    myLanguageLocation
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(DocumentEvent p0) {
                if (myLangLocationDocListenerEnabled) {
                  myLangLocationChangedByUser = true;
                }
              }
            });
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(myLanguageLocation, descriptor);
    BrowseFilesListener listener =
        new BrowseFilesListener(
            myLanguageLocation, "Choose Language Location Folder", "", descriptor);
    FieldPanel fieldPanel =
        new FieldPanel(
            myLanguageLocation, "Language location:", null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance()
        .installFileCompletion(fieldPanel.getTextField(), descriptor, false, null);
    this.add(fieldPanel, Util.getGridConstraints(2));

    myRuntimeSolution = new JCheckBox("Create Runtime Solution");
    this.add(myRuntimeSolution, Util.getGridConstraints(3));

    mySandboxSolution = new JCheckBox("Create Sandbox Solution");
    this.add(mySandboxSolution, Util.getGridConstraints(4));

    this.setPreferredSize(new Dimension(400, 100));

    reset();
  }
 public static FileChooserDescriptor createDescriptorForManifestDirectory() {
   FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
   descriptor.setTitle("Select Directory for META-INF/MANIFEST.MF file");
   return descriptor;
 }
  @NotNull
  protected PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setRoots(project.getBaseDir());
    PsiDirectory currentDir = currentFile.getContainingDirectory();
    PsiDirectory includeDir = currentDir.findSubdirectory("Includes");
    VirtualFile selectDir = directory.getVirtualFile();
    if (includeDir == null) {
      PsiDirectory parentDir = currentDir.getParentDirectory();
      if (parentDir != null) {
        includeDir = parentDir.findSubdirectory("Includes");
      }
    }
    if (includeDir != null) selectDir = includeDir.getVirtualFile();

    final VirtualFile myFolder = FileChooser.chooseFile(descriptor, project, selectDir);
    if (myFolder != null) {
      PsiDirectory myDirectory = PsiManager.getInstance(project).findDirectory(myFolder);
      final MyInputValidator validator = new MyInputValidator(project, myDirectory);
      final String fileName =
          Messages.showInputDialog(
              project,
              getDialogPrompt(),
              getDialogTitle(),
              Messages.getQuestionIcon(),
              "",
              validator);

      final PsiElement[] elements = validator.getCreatedElements();
      if (elements.length > 0) {
        ApplicationManager.getApplication()
            .invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    ApplicationManager.getApplication()
                        .runWriteAction(
                            new Runnable() {
                              @Override
                              public void run() {
                                try {
                                  CodeStyleManager codeStyleManager =
                                      CodeStyleManager.getInstance(project);
                                  CaretModel caretModel = editor.getCaretModel();
                                  int caretOffset = selectonModel.getSelectionStart();
                                  EditorModificationUtil.deleteSelectedText(editor);
                                  PsiDocumentManager psiDocumentManager =
                                      PsiDocumentManager.getInstance(project);
                                  caretModel.moveToOffset(caretOffset);
                                  EditorModificationUtil.insertStringAtCaret(
                                      editor, "<% include " + fileName + " %>", true, false);
                                  PsiFile createdFile = (PsiFile) elements[0];
                                  codeStyleManager.reformat(createdFile);
                                  psiDocumentManager.commitDocument(
                                      psiDocumentManager.getDocument(currentFile));
                                  FileEditorManager.getInstance(project)
                                      .openFile(currentFile.getVirtualFile(), true);
                                  codeStyleManager.adjustLineIndent(currentFile, caretOffset);
                                  psiDocumentManager.commitDocument(
                                      psiDocumentManager.getDocument(currentFile));
                                } catch (Exception e) {
                                  e.printStackTrace(); // To change body of catch statement use
                                  // File | Settings | File Templates.
                                }
                              }
                            });
                  }
                });
      }
      return elements;
    }
    return PsiElement.EMPTY_ARRAY;
  }
  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));
                  }
                }
              }
            });
  }
  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;
  }
  @Override
  protected JComponent createCenterPanel() {
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createAllButJarContentsDescriptor();
    calculateRoots();
    final ArrayList<VirtualFile> list = new ArrayList<VirtualFile>(myRoots);
    final Comparator<VirtualFile> comparator =
        new Comparator<VirtualFile>() {
          @Override
          public int compare(VirtualFile o1, VirtualFile o2) {
            final boolean isDir1 = o1.isDirectory();
            final boolean isDir2 = o2.isDirectory();
            if (isDir1 != isDir2) return isDir1 ? -1 : 1;

            final String module1 = myModulesSet.get(o1);
            final String path1 = module1 != null ? module1 : o1.getPath();
            final String module2 = myModulesSet.get(o2);
            final String path2 = module2 != null ? module2 : o2.getPath();
            return path1.compareToIgnoreCase(path2);
          }
        };
    descriptor.setRoots(list);
    myTree = new Tree();
    myTree.setMinimumSize(new Dimension(200, 200));
    myTree.setBorder(BORDER);
    myTree.setShowsRootHandles(true);
    myTree.setRootVisible(true);
    myTree.getExpandableItemsHandler().setEnabled(false);
    final MyCheckboxTreeCellRenderer cellRenderer =
        new MyCheckboxTreeCellRenderer(
            mySelectionManager, myModulesSet, myProject, myTree, myRoots);
    final FileSystemTreeImpl fileSystemTree =
        new FileSystemTreeImpl(
            myProject,
            descriptor,
            myTree,
            cellRenderer,
            null,
            new Convertor<TreePath, String>() {
              @Override
              public String convert(TreePath o) {
                final DefaultMutableTreeNode lastPathComponent =
                    ((DefaultMutableTreeNode) o.getLastPathComponent());
                final Object uo = lastPathComponent.getUserObject();
                if (uo instanceof FileNodeDescriptor) {
                  final VirtualFile file = ((FileNodeDescriptor) uo).getElement().getFile();
                  final String module = myModulesSet.get(file);
                  if (module != null) return module;
                  return file == null ? "" : file.getName();
                }
                return o.toString();
              }
            });
    final AbstractTreeUi ui = fileSystemTree.getTreeBuilder().getUi();
    ui.setNodeDescriptorComparator(
        new Comparator<NodeDescriptor>() {
          @Override
          public int compare(NodeDescriptor o1, NodeDescriptor o2) {
            if (o1 instanceof FileNodeDescriptor && o2 instanceof FileNodeDescriptor) {
              final VirtualFile f1 = ((FileNodeDescriptor) o1).getElement().getFile();
              final VirtualFile f2 = ((FileNodeDescriptor) o2).getElement().getFile();
              return comparator.compare(f1, f2);
            }
            return o1.getIndex() - o2.getIndex();
          }
        });
    myRoot = (DefaultMutableTreeNode) myTree.getModel().getRoot();

    new ClickListener() {
      @Override
      public boolean onClick(@NotNull MouseEvent e, int clickCount) {
        int row = myTree.getRowForLocation(e.getX(), e.getY());
        if (row < 0) return false;
        final Object o = myTree.getPathForRow(row).getLastPathComponent();
        if (myRoot == o || getFile(o) == null) return false;

        Rectangle rowBounds = myTree.getRowBounds(row);
        cellRenderer.setBounds(rowBounds);
        Rectangle checkBounds = cellRenderer.myCheckbox.getBounds();
        checkBounds.setLocation(rowBounds.getLocation());

        if (checkBounds.height == 0) checkBounds.height = rowBounds.height;

        if (checkBounds.contains(e.getPoint())) {
          mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
          myTree.revalidate();
          myTree.repaint();
        }
        return true;
      }
    }.installOn(myTree);

    myTree.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE) {
              TreePath[] paths = myTree.getSelectionPaths();
              if (paths == null) return;
              for (TreePath path : paths) {
                if (path == null) continue;
                final Object o = path.getLastPathComponent();
                if (myRoot == o || getFile(o) == null) return;
                mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
              }

              myTree.revalidate();
              myTree.repaint();
              e.consume();
            }
          }
        });

    JBPanel panel = new JBPanel(new BorderLayout());
    panel.add(new JBScrollPane(fileSystemTree.getTree()), BorderLayout.CENTER);
    mySelectedLabel = new JLabel("");
    mySelectedLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    panel.add(mySelectedLabel, BorderLayout.SOUTH);

    mySelectionManager.setSelectionChangeListener(
        new PlusMinus<VirtualFile>() {
          @Override
          public void plus(VirtualFile virtualFile) {
            mySelectedFiles.add(virtualFile);
            recalculateErrorText();
          }

          private void recalculateErrorText() {
            checkEmpty();
            if (mySelectionManager.canAddSelection()) {
              mySelectedLabel.setText("");
            } else {
              mySelectedLabel.setText(CAN_NOT_ADD_TEXT);
            }
            mySelectedLabel.revalidate();
          }

          @Override
          public void minus(VirtualFile virtualFile) {
            mySelectedFiles.remove(virtualFile);
            recalculateErrorText();
          }
        });
    return panel;
  }
  public LocationNameFieldsBinding(
      Project project,
      final TextFieldWithBrowseButton locationTextField,
      final JTextField nameTextField,
      String baseDir,
      final String browseFolderTitle) {

    myBaseDir = baseDir;
    File suggestedProjectDirectory =
        FileUtil.findSequentNonexistentFile(new File(baseDir), "untitled", "");
    locationTextField.setText(suggestedProjectDirectory.toString());
    nameTextField.setDocument(new NameFieldDocument(nameTextField, locationTextField));
    mySuggestedProjectName = suggestedProjectDirectory.getName();
    nameTextField.setText(mySuggestedProjectName);
    nameTextField.selectAll();

    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
        new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            browseFolderTitle,
            "",
            locationTextField,
            project,
            descriptor,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
          protected void onFileChoosen(VirtualFile chosenFile) {
            myBaseDir = chosenFile.getPath();
            if (isProjectNameChanged(nameTextField.getText())
                && !nameTextField.getText().equals(chosenFile.getName())) {
              myExternalModify = true;
              locationTextField.setText(
                  new File(chosenFile.getPath(), nameTextField.getText()).toString());
              myExternalModify = false;
            } else {
              myExternalModify = true;
              locationTextField.setText(chosenFile.getPath());
              nameTextField.setText(chosenFile.getName());
              myExternalModify = false;
            }
          }
        };
    locationTextField.addActionListener(listener);
    locationTextField
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                if (myExternalModify) {
                  return;
                }
                myModifyingLocation = true;
                String path = locationTextField.getText().trim();
                if (path.endsWith(File.separator)) {
                  path = path.substring(0, path.length() - File.separator.length());
                }
                int ind = path.lastIndexOf(File.separator);
                if (ind != -1) {
                  String projectName = path.substring(ind + 1, path.length());
                  if (!nameTextField.getText().trim().isEmpty()) {
                    myBaseDir = path.substring(0, ind);
                  }
                  if (!projectName.equals(nameTextField.getText())) {
                    if (!myModifyingProjectName) {
                      nameTextField.setText(projectName);
                    }
                  }
                }
                myModifyingLocation = false;
              }
            });
  }