本文整理汇总了Java中com.intellij.openapi.ui.TextFieldWithBrowseButton.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextFieldWithBrowseButton.addActionListener方法的具体用法?Java TextFieldWithBrowseButton.addActionListener怎么用?Java TextFieldWithBrowseButton.addActionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.TextFieldWithBrowseButton
的用法示例。
在下文中一共展示了TextFieldWithBrowseButton.addActionListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AddFileSelectorHandler
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
private void AddFileSelectorHandler(TextFieldWithBrowseButton textFieldWithBrowseButton, Project project, String label, String description) {
textFieldWithBrowseButton.addActionListener(
e -> {
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor(label, description), myPanel);
final String path = FileUtil.toSystemIndependentName(getFileName(textFieldWithBrowseButton));
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) {
textFieldWithBrowseButton.setText(fileWrapper.getFile().getPath());
}
}
);
}
示例2: createCenterPanel
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new GridBagLayout());
final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern"));
myClassName = new TextFieldWithBrowseButton(new JTextField(35));
final JLabel iconLabel = new JLabel(Messages.getQuestionIcon());
panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0));
myClassName.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createNoInnerClassesScopeChooser(
UIBundle.message("class.filter.editor.choose.class.title"), GlobalSearchScope.allScope(myProject), null, null);
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassName.setText(selectedClass.getQualifiedName());
}
}
});
myClassName.setEnabled(myProject != null);
return panel;
}
示例3: setupMainClassField
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
public static void setupMainClassField(final Project project, final TextFieldWithBrowseButton field) {
field.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final PsiClass selected = selectMainClass(project, field.getText());
if (selected != null) {
field.setText(selected.getQualifiedName());
}
}
});
}
示例4: addChooseBranchAction
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
public static void addChooseBranchAction(final TextFieldWithBrowseButton field, final Collection<FilePath> files, final Project project) {
field.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String branchName = chooseBranch(files, project);
if (branchName != null) field.setText(branchName);
}
});
}
示例5: createUIComponents
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
private void createUIComponents() {
mySchemaLocation = new TextFieldWithBrowseButton();
final String title = "Choose XSD or DTD schema";
mySchemaLocation.addBrowseFolderListener(
title,
"Make sure there are only necessary schemes in directory where your XSD or DTD schema is located",
myProject,
new FileTypeDescriptor(title, "xsd", "dtd")
);
mySchemaLocation.getTextField().setEditable(false);
mySchemaLocation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final File file = new File(mySchemaLocation.getText());
if (file.exists() && file.getName().toLowerCase().endsWith(".xsd")) {
final VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file);
if (vf != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
if (psiFile instanceof XmlFile) {
final XmlDocument xml = ((XmlFile) psiFile).getDocument();
if (xml != null) {
final XmlTag rootTag = xml.getRootTag();
if (rootTag != null) {
String target = null;
ArrayList<String> ns = new ArrayList<String>();
for (XmlAttribute attr : rootTag.getAttributes()) {
if ("targetNamespace".equals(attr.getName())) {
target = attr.getValue();
} else if (attr.getName().startsWith("xmlns")) {
ns.add(attr.getValue());
}
}
ns.remove(target);
if (target != null) {
myNamespace.setText(target);
}
mySkipSchemas.setText(StringUtil.join(ArrayUtil.toStringArray(ns), "\n"));
}
}
}
}
}
}
});
myOutputDir = new TextFieldWithBrowseButton();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myOutputDir.addBrowseFolderListener("Select Output Directory For Generated Files", "", myProject, descriptor);
}
示例6: LocationNameFieldsBinding
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
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;
}
});
}
示例7: createUIComponents
import com.intellij.openapi.ui.TextFieldWithBrowseButton; //导入方法依赖的package包/类
private void createUIComponents() {
mySchemaLocation = new TextFieldWithBrowseButton();
final String title = "Choose XSD or DTD schema";
mySchemaLocation.addBrowseFolderListener(title, "Make sure there are only necessary schemes in directory where your XSD or DTD schema is located", myProject, new FileTypeDescriptor(title, "xsd", "dtd"));
mySchemaLocation.getTextField().setEditable(false);
mySchemaLocation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final File file = new File(mySchemaLocation.getText());
if (file.exists() && file.getName().toLowerCase().endsWith(".xsd")) {
final VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file);
if (vf != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
if (psiFile instanceof XmlFile) {
final XmlDocument xml = ((XmlFile)psiFile).getDocument();
if (xml != null) {
final XmlTag rootTag = xml.getRootTag();
if (rootTag != null) {
String target = null;
ArrayList<String> ns = new ArrayList<String>();
for (XmlAttribute attr : rootTag.getAttributes()) {
if ("targetNamespace".equals(attr.getName())) {
target = attr.getValue();
}
else if (attr.getName().startsWith("xmlns")) {
ns.add(attr.getValue());
}
}
ns.remove(target);
if (target != null) {
myNamespace.setText(target);
}
mySkipSchemas.setText(StringUtil.join(ArrayUtil.toStringArray(ns), "\n"));
}
}
}
}
}
}
});
myOutputDir = new TextFieldWithBrowseButton();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myOutputDir.addBrowseFolderListener("Select Output Directory For Generated Files", "", myProject, descriptor);
}