本文整理汇总了Java中com.intellij.openapi.ui.TextBrowseFolderListener类的典型用法代码示例。如果您正苦于以下问题:Java TextBrowseFolderListener类的具体用法?Java TextBrowseFolderListener怎么用?Java TextBrowseFolderListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextBrowseFolderListener类属于com.intellij.openapi.ui包,在下文中一共展示了TextBrowseFolderListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createComponent
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
@Nullable
@Override
public JComponent createComponent() {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
imageFolder.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
String current = imageFolder.getText();
if (!current.isEmpty()) {
fc.setCurrentDirectory(new File(current));
}
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(rootPanel);
File file = fc.getSelectedFile();
String path = file == null
? ""
: file.getAbsolutePath();
imageFolder.setText(path);
}
});
autoChangeCheckBox.addActionListener(e -> intervalSpinner.setEnabled(autoChangeCheckBox.isSelected()));
return rootPanel;
}
示例2: addSourcePath
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
private void addSourcePath(SettingsStep settingsStep) {
Project project = settingsStep.getContext().getProject();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(IdeBundle.message("prompt.select.source.directory"));
mySourcePath.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
String contentEntryPath = myModuleBuilder.getContentEntryPath();
String path = chosenFile.getPath();
return contentEntryPath == null ? path : path.substring(StringUtil.commonPrefixLength(contentEntryPath, path));
}
});
myCreateSourceRoot.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mySourcePath.setEnabled(myCreateSourceRoot.isSelected());
}
});
settingsStep.addExpertPanel(myPanel);
}
示例3: setupUrlField
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field, @NotNull final Project project) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
return HtmlUtil.isHtmlFile(file) || virtualFileToUrl(file, project) != null;
}
};
descriptor.setTitle(XmlBundle.message("javascript.debugger.settings.choose.file.title"));
descriptor.setDescription(XmlBundle.message("javascript.debugger.settings.choose.file.subtitle"));
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
field.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
if (chosenFile.isDirectory()) {
return chosenFile.getPath();
}
Url url = virtualFileToUrl(chosenFile, project);
return url == null ? chosenFile.getUrl() : url.toDecodedForm();
}
});
}
示例4: setupSourceLocationControls
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
private void setupSourceLocationControls(@Nullable VirtualFile importSource) {
if (importSource == null) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
descriptor.setTitle("Select Source Location");
descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
invalidate();
}
});
}
else {
mySourceLocation.setVisible(false);
myLocationLabel.setVisible(false);
mySourceLocation.setText(importSource.getPath());
}
applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
myErrorWarning.setIcon(null);
myErrorWarning.setText(null);
}
示例5: initForWizard
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public void initForWizard() {
jdkCheckBox.addItemListener(createJdkCheckBoxListener());
jdkPath.addActionListener(UIUtils.createFileChooserListener(jdkPath, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()));
jdkPath.getTextField().getDocument().addDocumentListener(createJdkPathListener());
uploadLocalJdk.addActionListener(createUploadLocalJdkListener());
uploadLocalJdk.setSelected(true);
jdkChkBoxUnChecked();
serverPath.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
super.onFileChosen(chosenFile);
serBrowseBtnListener();
modifySrvText(waRole, message("dlNtLblDirSrv"));
modified = true;
}
});
serverCheckBox.addItemListener(createServerListener());
serverCheckBox.setSelected(false);
serverType.addItemListener(createServerTypeListener());
}
示例6: ExportDialogBase
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public ExportDialogBase(Project project, ExporterToTextFile exporter) {
super(project, true);
myProject = project;
myExporter = exporter;
myTfFile = new TextFieldWithBrowseButton();
myTfFile.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), myProject) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
String res = super.chosenFileToResultingText(chosenFile);
if (chosenFile.isDirectory()) {
res += File.separator + PathUtil.getFileName(myExporter.getDefaultFilePath());
}
return res;
}
});
setTitle(IdeBundle.message("title.export.preview"));
setOKButtonText(IdeBundle.message("button.save"));
setButtonsMargin(null);
init();
try {
myListener = new ChangeListener() {
public void stateChanged(ChangeEvent e) {
initText();
}
};
myExporter.addSettingsChangedListener(myListener);
}
catch (TooManyListenersException e) {
LOG.error(e);
}
initText();
}
示例7: AdtImportLocationStep
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public AdtImportLocationStep(WizardContext context) {
super(context);
myDestinationLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
String prev = context.getProjectFileDirectory();
mySourceProject = new File(FileUtil.toSystemDependentName(prev));
String name = new File(prev).getName();
//noinspection ConstantConditions
context.setProjectFileDirectory(null);
String defaultDir = context.getProjectFileDirectory();
int index = 0;
File file;
do {
String suffix = index == 0 ? "" : Integer.toString(index);
index++;
file = new File(defaultDir, name + suffix);
} while (file.exists());
myDestDirText.setText(file.getPath());
context.setProjectFileDirectory(prev);
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle("Choose Destination Directory");
descriptor.setDescription("Pick a directory to import the given Eclipse Android project into");
myDestDirText.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
@Override
protected void onFileChosen(@NotNull VirtualFile chosenFile) {
super.onFileChosen(chosenFile);
myIsPathChangedByUser = true;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
myIsPathChangedByUser = true;
}
});
}
示例8: IcsSettingsPanel
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public IcsSettingsPanel(@Nullable Project project) {
super(project, true);
urlTextField.setText(IcsManagerKt.getIcsManager().getRepositoryManager().getUpstream());
urlTextField.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()));
syncActions = UpstreamEditorKt.createMergeActions(project, urlTextField, getRootPane(), new Function0<Unit>() {
@Override
public Unit invoke() {
doOKAction();
return null;
}
});
urlTextField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
UpstreamEditorKt.updateSyncButtonState(StringUtil.nullize(urlTextField.getText()), syncActions);
}
});
UpstreamEditorKt.updateSyncButtonState(StringUtil.nullize(urlTextField.getText()), syncActions);
setTitle(IcsBundleKt.icsMessage("settings.panel.title"));
setResizable(false);
init();
}
示例9: initAndroidIconsSettings
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
private void initAndroidIconsSettings() {
FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
if (persistedAndroidIconsFile != null) {
VirtualFile loadedFile = VirtualFileManager.getInstance().findFileByUrl(persistedAndroidIconsFile);
if (loadedFile != null) {
androidIconsAssetHome.setText(loadedFile.getCanonicalPath());
selectedAndroidIconsFile = loadedFile;
}
}
String title = "Select res directory";
workingDirectoryChooserDescriptor.setTitle(title);
androidIconsAssetHome.addBrowseFolderListener(title, null, null, workingDirectoryChooserDescriptor);
androidIconsAssetHome.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
@Override
@SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
super.onFileChoosen(chosenFile);
selectionPerformed = true;
selectedAndroidIconsFile = chosenFile;
scanForAndroidIconsAssets();
}
});
androidIconsOpenBrowser.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
BrowserUtil.browse(ANDROID_ICONS_URL);
}
});
scanForAndroidIconsAssets();
}
示例10: initMaterialIconsSettings
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
private void initMaterialIconsSettings() {
FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
if (persistedMaterialIconsFile != null) {
VirtualFile loadedFile = VirtualFileManager.getInstance().findFileByUrl(persistedMaterialIconsFile);
if (loadedFile != null) {
materialIconsAssetHome.setText(loadedFile.getCanonicalPath());
selectedMaterialIconsFile = loadedFile;
}
}
String title = "Select res directory";
workingDirectoryChooserDescriptor.setTitle(title);
materialIconsAssetHome.addBrowseFolderListener(title, null, null, workingDirectoryChooserDescriptor);
materialIconsAssetHome.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
@Override
@SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
super.onFileChoosen(chosenFile);
selectionPerformed = true;
selectedMaterialIconsFile = chosenFile;
scanForMaterialIconsAssets();
}
});
materialIconsOpenBrowser.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
BrowserUtil.browse(MATERIAL_ICONS_URL);
}
});
scanForMaterialIconsAssets();
}
示例11: initResourceBrowser
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public static void initResourceBrowser(final Project project, Module module, final String title, @Nullable final TextFieldWithBrowseButton browser) {
final VirtualFile resRoot = SettingsHelper.getResRootForProject(project);
if (resRoot == null) {
getResRootFile(project, module, new ResourcesDialog.ResourceSelectionListener() {
@Override
public void onResourceSelected(VirtualFile resDir) {
if (browser != null) {
browser.setText(resDir.getCanonicalPath());
}
SettingsHelper.saveResRootForProject(project, resDir.getUrl());
}
});
} else {
if (browser != null) {
browser.setText(resRoot.getCanonicalPath());
}
}
if (browser != null) {
FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
workingDirectoryChooserDescriptor.setTitle(title);
browser.addBrowseFolderListener(title, null, project, workingDirectoryChooserDescriptor);
browser.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
@Override
@SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
super.onFileChoosen(chosenFile);
SettingsHelper.saveResRootForProject(project, chosenFile.getUrl());
}
});
}
}
示例12: CreatePatchConfigurationPanel
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public CreatePatchConfigurationPanel(@Nonnull final Project project) {
myProject = project;
initMainPanel();
myFileNameField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final FileSaverDialog dialog =
FileChooserFactory.getInstance().createSaveFileDialog(
new FileSaverDescriptor("Save Patch to", ""), myMainPanel);
final String path = FileUtil.toSystemIndependentName(getFileName());
final int idx = path.lastIndexOf("/");
VirtualFile baseDir = idx == -1 ? project.getBaseDir() :
(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path.substring(0, idx))));
baseDir = baseDir == null ? project.getBaseDir() : baseDir;
final String name = idx == -1 ? path : path.substring(idx + 1);
final VirtualFileWrapper fileWrapper = dialog.save(baseDir, name);
if (fileWrapper != null) {
myFileNameField.setText(fileWrapper.getFile().getPath());
}
}
});
myFileNameField.setTextFieldPreferredWidth(TEXT_FIELD_WIDTH);
myBasePathField.setTextFieldPreferredWidth(TEXT_FIELD_WIDTH);
myBasePathField.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()));
myWarningLabel.setForeground(JBColor.RED);
selectBasePath(ObjectUtils.assertNotNull(myProject.getBaseDir()));
initEncodingCombo();
}
示例13: ChooseAndroidAndJavaSdkStep
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
public ChooseAndroidAndJavaSdkStep() {
myAndroidSdkLocationField.addBrowseFolderListener(new TextBrowseFolderListener(
new FileChooserDescriptor(false, true, false, false, false, false)));
myJavaSdkCombo.setSetupButton(myNewButton, null, mySdksModel, new JdkComboBox.NoneJdkComboBoxItem(), null, false);
}
示例14: configureDirChooser
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
private void configureDirChooser(LabeledComponent<TextFieldWithBrowseButton> field, String title) {
FileChooserDescriptor dirFileChooser = FileChooserDescriptorFactory.createSingleFolderDescriptor();
dirFileChooser.setTitle(title);
TextBrowseFolderListener listener = new TextBrowseFolderListener(dirFileChooser, runConfiguration.getProject());
field.getComponent().addBrowseFolderListener(listener);
}
示例15: createCenterPanel
import com.intellij.openapi.ui.TextBrowseFolderListener; //导入依赖的package包/类
@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;
}