List of usage examples for com.intellij.openapi.ui ComponentWithBrowseButton.BrowseFolderActionListener ComponentWithBrowseButton.BrowseFolderActionListener
public BrowseFolderActionListener(@Nullable @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable @Nls(capitalization = Nls.Capitalization.Sentence) String description, @Nullable ComponentWithBrowseButton<T> textField, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor, TextComponentAccessor<? super T> accessor)
From source file:com.android.tools.idea.gradle.actions.LinkExternalCppProjectDialog.java
License:Apache License
public LinkExternalCppProjectDialog(@NotNull Module module) { super(false); myModule = module;//from w w w . j av a 2 s . c o m init(); setTitle("Link C++ Project with Gradle"); myBuildSystemCombo.addItem(BuildSystem.CMAKE); myBuildSystemCombo.addItem(BuildSystem.NDK_BUILD); myBuildSystemCombo.setSelectedItem(BuildSystem.CMAKE); myProjectPathDescriptionLabel.setText(CMAKE_PATH_DESCRIPTION); myBuildSystemCombo.addItemListener(e -> { if (myBuildSystemCombo.getSelectedItem() == BuildSystem.CMAKE) { myProjectPathDescriptionLabel.setText(CMAKE_PATH_DESCRIPTION); } else { myProjectPathDescriptionLabel.setText(NDK_BUILD_PATH_DESCRIPTION); } }); getOKAction().setEnabled(false); myProjectPathTextField.setTextFieldPreferredWidth(50); FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public void validateSelectedFiles(VirtualFile[] files) throws Exception { for (VirtualFile virtualFile : files) { String errorMessage = validateProjectFilePath(virtualToIoFile(virtualFile)); if (errorMessage != null) { throw new IllegalArgumentException(errorMessage); } } } }; descriptor.setTitle("Choose C++ Project Location"); myProjectPathTextField.addActionListener( new ComponentWithBrowseButton.BrowseFolderActionListener<>("Select C++ Project Location", null, myProjectPathTextField, null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); myProjectPathResultLabel.setVisible(false); }
From source file:com.android.tools.idea.sdk.SelectNdkDialog.java
License:Apache License
private void configureNdkTextField() { myNdkTextFieldWithButton.setTextFieldPreferredWidth(50); FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) { @Override//from ww w . j av a 2 s. co m public void validateSelectedFiles(VirtualFile[] files) throws Exception { for (VirtualFile virtualFile : files) { File file = virtualToIoFile(virtualFile); ValidationResult validationResult = validateAndroidNdk(file, false); if (!validationResult.success) { String msg = validationResult.message; if (isEmpty(msg)) { msg = "Please choose a valid Android NDK directory."; } throw new IllegalArgumentException(msg); } } } }; if (SystemInfo.isMac) { descriptor.withShowHiddenFiles(true); } descriptor.setTitle("Choose Android NDK Location"); myNdkTextFieldWithButton.addActionListener( new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>("Select Android NDK Home", null, myNdkTextFieldWithButton, null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); }
From source file:com.intellij.dvcs.ui.CloneDvcsDialog.java
License:Apache License
/** * Init components//from w ww .jav a 2s . c o m */ private void initListeners() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DvcsBundle.message("clone.destination.directory.title")); fcd.setDescription(DvcsBundle.message("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 = getRememberedInputs().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); }
From source file:intellijeval.git.GitCloneDialog.java
License:Apache License
/** * Init components//from ww w . j a v a 2 s .c om */ 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(); // } //noinspection ConstantIfStatement myParentDirectory.setText(EvalComponent.pluginsRootPath()); // FORK DIFF myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener); myTestButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { test(); } }); setOKActionEnabled(false); myTestButton.setEnabled(false); }
From source file:liveplugin.toolwindow.addplugin.git.GitCloneDialog.java
License:Apache License
/** * Init components//from www. j av a2 s . co m */ private void initListeners() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DvcsBundle.getString("clone.destination.directory.title")); fcd.setDescription(DvcsBundle.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(); // } //noinspection ConstantIfStatement myParentDirectory.setText(LivePluginAppComponent.pluginsRootPath()); // FORK DIFF myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener); myTestButton.addActionListener(new ActionListener() { public void actionPerformed(@NotNull final ActionEvent e) { test(); } }); setOKActionEnabled(false); myTestButton.setEnabled(false); }
From source file:org.codinjutsu.tools.nosql.commons.view.ServerConfigurationPanel.java
License:Apache License
private void createUIComponents() { shellWorkingDirField = new TextFieldWithBrowseButton(); FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);/*from w w w. j a v a2s . co m*/ ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> browseFolderActionListener = new ComponentWithBrowseButton.BrowseFolderActionListener<>( "Shell working directory", null, shellWorkingDirField, null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); shellWorkingDirField.addBrowseFolderListener(null, browseFolderActionListener, false); shellWorkingDirField.setName("shellWorkingDirField"); }
From source file:org.community.intellij.plugins.communitycase.checkout.CloneDialog.java
License:Apache License
/** * Init components// w ww.j ava 2 s . com */ private void initListeners() { FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false); fcd.setShowFileSystemRoots(true); fcd.setTitle(Bundle.getString("clone.destination.directory.title")); fcd.setDescription(Bundle.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 DocumentListener() { // update Ok button state depending on the current state of the fields public void insertUpdate(final DocumentEvent e) { updateOkButton(); } public void removeUpdate(final DocumentEvent e) { updateOkButton(); } public void changedUpdate(final DocumentEvent e) { updateOkButton(); } }; myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener); myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener); myOriginName.getDocument().addDocumentListener(updateOkButtonListener); myRepositoryURL.getDocument().addDocumentListener(new DocumentListener() { // enable test button only if something is entered in repository URL public void insertUpdate(final DocumentEvent e) { changed(); } public void removeUpdate(final DocumentEvent e) { changed(); } public void changedUpdate(final DocumentEvent e) { changed(); } private void changed() { final String url = myRepositoryURL.getText(); myTestButton.setEnabled(url.length() != 0); if (myDefaultDirectoryName.equals(myDirectoryName.getText()) || myDirectoryName.getText().length() == 0) { // modify field if it was unmodified or blank myDefaultDirectoryName = defaultDirectoryName(url); myDirectoryName.setText(myDefaultDirectoryName); } updateOkButton(); } }); myTestButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { myTestURL = myRepositoryURL.getText(); String output = HandlerUtil.doSynchronously(checkRepository(myProject, myTestURL), Bundle.message("clone.testing", myTestURL), "connection test"); if (output != null) { Messages.showInfoMessage(myTestButton, Bundle.message("clone.test.success.message", myTestURL), Bundle.getString("clone.test.success")); myTestResult = Boolean.TRUE; } else { myTestResult = Boolean.FALSE; } updateOkButton(); } }); setOKActionEnabled(false); }
From source file:pl.tajchert.wearhighlight.configuration.ui.MappingEditor.java
License:Apache License
public MappingEditor(final Project project, final String directory, final Map<String, FolderConfiguration> configurationMap) { super(project, false); this.configurationMap = configurationMap; if (directory != null) { configurationDirectoryTF.getChildComponent().setText(directory); folderConfiguration = configurationMap.get(directory).cloneMe(); }//from w ww .j ava2s .c o m if (folderConfiguration == null) { folderConfiguration = new GlobalConfig().cloneMe(); } relativeToTF.getChildComponent().setText(folderConfiguration.getRelativeTo()); sharedSettingsComp.setData(folderConfiguration); configurationDirectoryTF.addActionListener(new BrowseFolderListener(project)); relativeToTF.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>( "Select Directory", "Select directory relative to which you want see path in tab", relativeToTF, project, new FileChooserDescriptor(false, true, false, false, false, false), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); setTitle("Folder Tabdir Configuration"); init(); }