當前位置: 首頁>>代碼示例>>Java>>正文


Java TextFieldWithBrowseButton.addActionListener方法代碼示例

本文整理匯總了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());
                }
            }
        );
    }
 
開發者ID:SlalomConsulting,項目名稱:sutr-io,代碼行數:19,代碼來源:SutrConfigPanel.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:37,代碼來源:ClassFilterEditorAddDialog.java

示例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());
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:ManifestFileUtil.java

示例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);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:TagsHelper.java

示例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);
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:51,代碼來源:DomGenPanel.java

示例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;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:61,代碼來源:LocationNameFieldsBinding.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:46,代碼來源:DomGenPanel.java


注:本文中的com.intellij.openapi.ui.TextFieldWithBrowseButton.addActionListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。