public BuildoutConfigPanel(Module module, BuildoutFacetConfiguration config) { myModule = module; myConfiguration = config; setLayout(new BorderLayout()); add(myPanel); FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); //descriptor.setRoot(myConfiguration.getRoot()); myScript.addBrowseFolderListener( "Choose a buildout script", "Select the target script that will invoke your code", null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT, false ); myScript.getComboBox().setEditable(true); initErrorValidation(); }
public JComponent createComponent() { // all listeners will be removed when dialog is closed mavenHomeComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.home.directory"), "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); mavenHomeField.addDocumentListener(new DocumentAdapter() { protected void textChanged(DocumentEvent e) { updateMavenVersionLabel(); } }); settingsFileComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.settings.file"), "", null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); localRepositoryComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.local.repository"), "", null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); return panel; }
public JComponent createPanel(@NotNull TerminalOptionsProvider provider) { myOptionsProvider = provider; FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); myShellPathField.addBrowseFolderListener( "", "Shell Executable Path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false ); return myWholePanel; }
private void setupScriptPathField(@NotNull final Project project) { final ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>( "Select Script", "", myScriptPathField, project, FileChooserDescriptorFactory.createSingleFileDescriptor(TheRFileType.INSTANCE), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT ) { @Override protected void onFileChosen(@NotNull final VirtualFile chosenFile) { super.onFileChosen(chosenFile); TheRRunConfigurationUtils.setSuggestedWorkingDirectoryPathIfNotSpecified(TheRRunConfigurationForm.this); } }; myScriptPathField.addActionListener(listener); }
public ToolPath(JCheckBox checkBox, TextFieldWithBrowseButton textField, @Nullable JTextField parameters, StringProperty pathProperty, BooleanProperty enabledProperty, @Nullable StringProperty parametersProperty) { myCheckBox = checkBox; myTextField = textField; myPathProperty = pathProperty; myEnabledProperty = enabledProperty; myParameters = parameters; myParametersProperty = parametersProperty; final ButtonModel model = myCheckBox.getModel(); model.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateEnabledEffect(); } }); myTextField.addBrowseFolderListener(DiffBundle.message("select.external.diff.program.dialog.title"), null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(), TextComponentAccessor.TEXT_FIELD_SELECTED_TEXT); }
private static TextComponentAccessor<EditorTextField> getTextComponentAccessor() { return new TextComponentAccessor<EditorTextField>() { @Override public String getText(EditorTextField component) { String text = component.getText(); final VirtualFile file = VirtualFileManager.getInstance() .findFileByUrl(VfsUtil.pathToUrl(text.replace(File.separatorChar, '/'))); if (file != null && !file.isDirectory()) { final VirtualFile parent = file.getParent(); assert parent != null; return parent.getPresentableUrl(); } return text; } @Override public void setText(EditorTextField component, String text) { component.setText(text); } }; }
public ToolPath(JCheckBox checkBox, TextFieldWithBrowseButton textField, @Nullable JTextField parameters, StringProperty pathProperty, BooleanProperty enabledProperty, @Nullable StringProperty parametersProperty) { myCheckBox = checkBox; myTextField = textField; myPathProperty = pathProperty; myEnabledProperty = enabledProperty; myParameters = parameters; myParametersProperty = parametersProperty; final ButtonModel model = myCheckBox.getModel(); model.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateEnabledEffect(); } }); myTextField.addBrowseFolderListener(DiffBundle.message("select.external.diff.program.dialog.title"), null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(), TextComponentAccessor.TEXT_FIELD_SELECTED_TEXT); }
MySourceCodeChooserActionListener(final FileChooserDescriptor fileChooserDescriptor) { super( HybrisI18NBundleUtils.message("hybris.import.label.select.hybris.src.file"), "", HybrisWorkspaceRootStep.this.sourceCodeFilesInChooser, (Project) null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT ); }
@Override public void addBrowseFolderListener(@Nullable String title, @Nullable String description, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor, TextComponentAccessor<TextFieldWithHistory> accessor) { super.addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor); FileChooserFactory.getInstance().installFileCompletion(getChildComponent().getTextEditor(), fileChooserDescriptor, false, project); }
@Override public void addBrowseFolderListener(@Nullable String title, @Nullable String description, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor, TextComponentAccessor<TextFieldWithHistory> accessor, boolean autoRemoveOnHide) { super.addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor, autoRemoveOnHide); FileChooserFactory.getInstance().installFileCompletion(getChildComponent().getTextEditor(), fileChooserDescriptor, false, project); }
@Override protected JComponent createCenterPanel() { myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0); } }); return myWholePanel; }
public PythonRunConfigurationForm(PythonRunConfiguration configuration) { myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData()); myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel(), BorderLayout.CENTER); myProject = configuration.getProject(); FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py"); } }; //chooserDescriptor.setRoot(s.getProject().getBaseDir()); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>("Select Script", "", myScriptTextField, myProject, chooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { @Override protected void onFileChosen(@NotNull VirtualFile chosenFile) { super.onFileChosen(chosenFile); myCommonOptionsForm.setWorkingDirectory(chosenFile.getParent().getPath()); } }; myScriptTextField.addActionListener(listener); setAnchor(myCommonOptionsForm.getAnchor()); }
public AppEngineSdkEditor(final @Nullable Project project) { myPathEditor = new ComboboxWithBrowseButton(new ComboBox(100)); myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK", "Specify Google App Engine Java SDK home", myPathEditor, project, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT)); final JComboBox comboBox = myPathEditor.getComboBox(); comboBox.setEditable(true); comboBox.removeAllItems(); for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) { comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath())); } }
private FileSelectorWithStoredHistory(TextFieldWithStoredHistory textField, String title) { super(textField, null); addBrowseFolderListener( title, "", null, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_STORED_HISTORY_WHOLE_TEXT); }
public LocalAndServerPathsForm() { Disposer.register(this, myServerPathForm); myServerPathForm.addListener(new TfsTreeForm.SelectionListener() { @Override public void selectionChanged() { myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this)); } }); myLocalPathLabel.setLabelFor(myLocalPathField.getChildComponent()); myLocalPathField.getChildComponent().getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(final DocumentEvent e) { myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this)); } }); FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(TFSBundle.message("choose.local.path.title"), TFSBundle.message("choose.local.path.description"), myLocalPathField, null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myServerPathLabel.setLabelFor(myServerPathForm.getPreferredFocusedComponent()); myLocalPathField.addActionListener(listener); myMessageLabel.setIcon(UIUtil.getBalloonWarningIcon()); }
@Nullable @Override public JComponent createComponent() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DLangBundle.message("dub.config.selectexecutable.title")); fcd.setDescription(DLangBundle.message("dub.config.selectexecutable.description")); fcd.setHideIgnored(false); pathDubExecutable.addBrowseFolderListener(null, new TextFieldWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), pathDubExecutable, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) ); return panel; }
@NotNull @Override protected JComponent createEditor() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DLangBundle.message("dmd.run.config.selectworkingdir.title")); fcd.setDescription(DLangBundle.message("dmd.run.config.selectworkingdir.description")); fcd.setHideIgnored(false); pathWorkingDir.addBrowseFolderListener(null, new TextFieldWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), pathWorkingDir, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) ); return myMainPanel; }
private void initComponents() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title")); fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description")); fcd.setHideIgnored(false); parentDirectory.addActionListener( new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>( fcd.getTitle(), fcd.getDescription(), parentDirectory, project, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { @Override protected VirtualFile getInitialFile() { String text = getComponentText(); if (text.length() == 0) { VirtualFile file = project.getBaseDir(); if (file != null) { return file; } } return super.getInitialFile(); } }); final DocumentListener updateOkButtonListener = new DocumentAdapter() { @Override protected void textChanged(DocumentEvent event) { updateButtons(); } }; parentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener); parentDirectory.setText(ProjectUtil.getBaseDir()); directoryName.getDocument().addDocumentListener(updateOkButtonListener); setOKActionEnabled(false); }
public ImageFileBrowserFolderActionListener(String title, Project project, ComponentWithBrowseButton<JTextField> componentWithBrowseButton, FileChooserDescriptor fileChooserDescriptor) { super(title, null, componentWithBrowseButton, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); this.title = title; this.project = project; }
public AlternativeJREPanel() { myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); myFieldWithHistory = new TextFieldWithHistory(); final ArrayList<String> foundJDKs = new ArrayList<String>(); for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { foundJDKs.add(path); } } final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks(); for (Sdk jdk : allJDKs) { foundJDKs.add(jdk.getHomePath()); } myFieldWithHistory.setHistory(foundJDKs); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"), ExecutionBundle.message("run.configuration.select.jre.dir.label"), null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); setLayout(new MigLayout("ins 0, gap 10, fill, flowx")); add(myCbEnabled, "shrinkx"); add(myPathField, "growx, pushx"); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); myCbEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enabledChanged(); } }); enabledChanged(); setAnchor(myCbEnabled); updateUI(); }
private void addSourcePath(SettingsStep settingsStep) { Project project = settingsStep.getContext().getProject(); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener = new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>( IdeBundle.message("prompt.select.source.directory"), null, mySourcePath, project, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { @Override protected void onFileChoosen(VirtualFile chosenFile) { String contentEntryPath = myModuleBuilder.getContentEntryPath(); String path = chosenFile.getPath(); if (contentEntryPath != null) { int i = StringUtil.commonPrefixLength(contentEntryPath, path); mySourcePath.setText(path.substring(i)); } else { mySourcePath.setText(path); } } }; mySourcePath.addBrowseFolderListener(project, listener); myCreateSourceRoot.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mySourcePath.setEnabled(myCreateSourceRoot.isSelected()); } }); settingsStep.addExpertPanel(myPanel); }
@Override protected JComponent createNorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); 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()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); Disposer.register(getDisposable(), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP).getPanel(); }
public AppEngineSdkEditor(final @Nullable Project project) { myPathEditor = new ComboboxWithBrowseButton(); final ComboboxWithBrowseButton pathEditor = myPathEditor; myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK", "Specify Google App Engine Java SDK home", pathEditor, project, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT)); final JComboBox comboBox = myPathEditor.getComboBox(); comboBox.setEditable(true); comboBox.removeAllItems(); for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) { comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath())); } }
public JComponent createPanel(@NotNull TerminalOptionsProvider provider) { myOptionsProvider = provider; FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); myShellPathField.addBrowseFolderListener("", "Shell Executable Path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false); return myWholePanel; }
public AlternativeJREPanel() { myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); myFieldWithHistory = new TextFieldWithHistory(); final ArrayList<String> foundJDKs = new ArrayList<String>(); final Sdk[] allJDKs = SdkTable.getInstance().getAllSdks(); for (Sdk jdk : allJDKs) { foundJDKs.add(jdk.getHomePath()); } myFieldWithHistory.setHistory(foundJDKs); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"), ExecutionBundle.message("run.configuration.select.jre.dir.label"), null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); setLayout(new MigLayout("ins 0, gap 10, fill, flowx")); add(myCbEnabled, "shrinkx"); add(myPathField, "growx, pushx"); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); myCbEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enabledChanged(); } }); enabledChanged(); setAnchor(myCbEnabled); updateUI(); }
public AlternativeJREPanel() { myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); myFieldWithHistory = new TextFieldWithHistory(); myFieldWithHistory.setHistorySize(-1); final ArrayList<String> foundJDKs = new ArrayList<String>(); final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks(); for (Sdk sdk : allJDKs) { foundJDKs.add(sdk.getName()); } for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { foundJDKs.add(path); } } for (Sdk jdk : allJDKs) { String homePath = jdk.getHomePath(); if (!SystemInfo.isMac) { final File jre = new File(jdk.getHomePath(), "jre"); if (jre.isDirectory()) { homePath = jre.getPath(); } } if (!foundJDKs.contains(homePath)) { foundJDKs.add(homePath); } } myFieldWithHistory.setHistory(foundJDKs); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"), ExecutionBundle.message("run.configuration.select.jre.dir.label"), null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); setLayout(new MigLayout("ins 0, gap 10, fill, flowx")); add(myCbEnabled, "shrinkx"); add(myPathField, "growx, pushx"); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); myCbEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enabledChanged(); } }); enabledChanged(); setAnchor(myCbEnabled); updateUI(); }
public void addBrowseFolderListener(Project project, FileChooserDescriptor descriptor) { addBrowseFolderListener(null, null, project, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT); }
public LocationNameFieldsBinding(@Nullable Project project, final TextFieldWithBrowseButton locationField, final JTextField nameField, String baseDir, String title) { myBaseDir = baseDir; File suggestedProjectDirectory = FileUtil.findSequentNonexistentFile(new File(baseDir), "untitled", ""); locationField.setText(suggestedProjectDirectory.toString()); nameField.setDocument(new NameFieldDocument(nameField, locationField)); mySuggestedProjectName = suggestedProjectDirectory.getName(); nameField.setText(mySuggestedProjectName); nameField.selectAll(); FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); BrowseFolderActionListener<JTextField> listener = new BrowseFolderActionListener<JTextField>(title, "", locationField, project, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { @Override protected void onFileChosen(@NotNull VirtualFile chosenFile) { myBaseDir = chosenFile.getPath(); if (isProjectNameChanged(nameField.getText()) && !nameField.getText().equals(chosenFile.getName())) { myExternalModify = true; locationField.setText(new File(chosenFile.getPath(), nameField.getText()).toString()); myExternalModify = false; } else { myExternalModify = true; locationField.setText(chosenFile.getPath()); nameField.setText(chosenFile.getName()); myExternalModify = false; } } }; locationField.addActionListener(listener); locationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { if (myExternalModify) { return; } myModifyingLocation = true; String path = locationField.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 (!nameField.getText().trim().isEmpty()) { myBaseDir = path.substring(0, ind); } if (!projectName.equals(nameField.getText())) { if (!myModifyingProjectName) { nameField.setText(projectName); } } } myModifyingLocation = false; } }); }
@Override protected JComponent createNorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); 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()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); Disposer.register(getDisposable(), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor"); myOpenInEditorCb.setSelected(isOpenInEditor()); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP) .addComponentToRightColumn(myOpenInEditorCb, UIUtil.LARGE_VGAP) .getPanel(); }
@Override protected JComponent createNorthPanel() { myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap( UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JBTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField); } if (myShowDirectoryField) { myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH); 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.copied.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)); } final JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(myOpenFilesInEditor, BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }
PyExtractSuperclassViewSwingImpl(@NotNull final PyClass classUnderRefactoring, @NotNull final Project project, @NotNull final PyExtractSuperclassPresenter presenter) { super(project, presenter, RefactoringBundle.message("extract.superclass.from"), true); setTitle(PyExtractSuperclassHandler.REFACTORING_NAME); final Box box = Box.createVerticalBox(); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel(RefactoringBundle.message("extract.superclass.from")), BorderLayout.NORTH); final JTextField sourceClassField = new JTextField(); sourceClassField.setEditable(false); sourceClassField.setText(classUnderRefactoring.getName()); panel.add(sourceClassField, BorderLayout.CENTER); box.add(panel); box.add(Box.createVerticalStrut(10)); final JLabel superNameLabel = new JLabel(); superNameLabel.setText(RefactoringBundle.message("superclass.name")); panel = new JPanel(new BorderLayout()); panel.add(superNameLabel, BorderLayout.NORTH); panel.add(myExtractedSuperNameField, BorderLayout.CENTER); box.add(panel); box.add(Box.createVerticalStrut(5)); myFileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); myFileChooserDescriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots()); myFileChooserDescriptor.withTreeRootVisible(true); myTargetDirField = new TextFieldWithBrowseButton(); myTargetDirField .addBrowseFolderListener(FILE_OR_DIRECTORY, null, project, myFileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); panel = new JPanel(new BorderLayout()); final JLabel dirLabel = new JLabel(); dirLabel.setText(FILE_OR_DIRECTORY); //u18n panel.add(dirLabel, BorderLayout.NORTH); panel.add(myTargetDirField, BorderLayout.CENTER); box.add(panel); box.add(Box.createVerticalStrut(10)); myTopPanel.add(box, BorderLayout.CENTER); myCenterPanel.add(myPyMemberSelectionPanel, BorderLayout.CENTER); setPreviewResults(false); }
private void fillUi(JPanel canvas) { JLabel projectDataDirLabel = new JBLabel("Project data directory:"); canvas.setPreferredSize(ProjectViewUi.getContainerSize()); projectDataDirField = new TextFieldWithBrowseButton(); projectDataDirField.setName("project-data-dir-field"); projectDataDirField.addBrowseFolderListener( "", buildSystemName + " project data directory", null, PROJECT_FOLDER_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false); final String dataDirToolTipText = "Directory in which to store the project's metadata. " + "Choose a directory outside of your workspace."; projectDataDirField.setToolTipText(dataDirToolTipText); projectDataDirLabel.setToolTipText(dataDirToolTipText); canvas.add(projectDataDirLabel, UiUtil.getLabelConstraints(0)); canvas.add(projectDataDirField, UiUtil.getFillLineConstraints(0)); JLabel projectNameLabel = new JLabel("Project name:"); projectNameField = new JTextField(); final String projectNameToolTipText = "Project display name."; projectNameField.setToolTipText(projectNameToolTipText); projectNameField.setName("project-name-field"); projectNameLabel.setToolTipText(projectNameToolTipText); canvas.add(projectNameLabel, UiUtil.getLabelConstraints(0)); canvas.add(projectNameField, UiUtil.getFillLineConstraints(0)); JLabel defaultNameLabel = new JLabel("Infer name from:"); workspaceDefaultNameOption = new JRadioButton("Workspace"); branchDefaultNameOption = new JRadioButton("Branch"); importDirectoryDefaultNameOption = new JRadioButton("Import Directory"); workspaceDefaultNameOption.setToolTipText("Infer default name from the workspace name"); branchDefaultNameOption.setToolTipText( "Infer default name from the current branch of your workspace"); importDirectoryDefaultNameOption.setToolTipText( "Infer default name from the directory used to import your project view"); workspaceDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged()); branchDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged()); importDirectoryDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged()); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(workspaceDefaultNameOption); buttonGroup.add(branchDefaultNameOption); buttonGroup.add(importDirectoryDefaultNameOption); canvas.add(defaultNameLabel, UiUtil.getLabelConstraints(0)); canvas.add(workspaceDefaultNameOption, UiUtil.getLabelConstraints(0)); canvas.add(branchDefaultNameOption, UiUtil.getLabelConstraints(0)); canvas.add(importDirectoryDefaultNameOption, UiUtil.getLabelConstraints(0)); canvas.add(new JPanel(), UiUtil.getFillLineConstraints(0)); projectViewUi.fillUi(canvas); }
public MyBrowseFolderListener(@NotNull FileChooserDescriptor descriptor) { super(SquirrelBundle.message("squirrel.sdk.select.root.dir"), "", mySdkPathField, myProject, descriptor, TextComponentAccessor .TEXT_FIELD_WHOLE_TEXT); }