Java 类com.intellij.ui.TextFieldWithAutoCompletion 实例源码

项目:ijphab    文件:PhabricatorRepositoryEditor.java   
@Nullable
@Override
protected JComponent createCustomPanel() {
  myIconProjectsLabel = new JBLabel("Icon Projects:", SwingConstants.RIGHT);
  myIconProjects = TextFieldWithAutoCompletion.create(
    myProject,
    Collections.emptyList(),
    true,
    myRepository.getIconProjects()
  );
  JBLabel descLabel = new JBLabel();
  descLabel.setCopyable(true);
  descLabel.setText("Only one icon is shown for each task. " +
                    "This icon is extracted from the projects the task belongs to.<br>" +
                    "You can specify the projects whose icons will be used first. " +
                    "Separate multiple projects with commas.");
  descLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL);
  return FormBuilder.createFormBuilder()
    .addLabeledComponent(myIconProjectsLabel, myIconProjects)
    .addComponentToRightColumn(descLabel)
    .getPanel();
}
项目:intellij-ce-playground    文件:DefaultSchemasConfigurable.java   
@Nullable
@Override
public JComponent createComponent() {
  final String[] urls = ExternalResourceManager.getInstance().getResourceUrls(null, true);
  myDoctypeTextField = TextFieldWithAutoCompletion.create(myProject, Arrays.asList(urls), null, true, null);
  myOtherDoctypeWrapper.add(myDoctypeTextField);
  ActionListener listener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myDoctypeTextField.setEnabled(myOtherRadioButton.isSelected());
    }
  };
  myHtml4RadioButton.addActionListener(listener);
  myHtml5RadioButton.addActionListener(listener);
  myOtherRadioButton.addActionListener(listener);
  return myContentPanel;
}
项目:intellij-ce-playground    文件:CreateResourceFileDialog.java   
private void updateRootElementTextField() {
  final CreateTypedResourceFileAction action = getSelectedAction();

  if (action != null) {
    final List<String> allowedTagNames = action.getSortedAllowedTagNames(myFacet);
    myRootElementField = new TextFieldWithAutoCompletion<String>(
      myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true, null);
    myRootElementField.setEnabled(allowedTagNames.size() > 1);
    myRootElementField.setText(!action.isChooseTagName()
                               ? action.getDefaultRootTag()
                               : "");
    myRootElementFieldWrapper.removeAll();
    myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
    myRootElementLabel.setLabelFor(myRootElementField);
  }
}
项目:intellij-ce-playground    文件:CreateMultiRootResourceFileAction.java   
protected MyDialog(@NotNull AndroidFacet facet, @Nullable InputValidator validator) {
  super(facet.getModule().getProject());
  myValidator = validator;
  setTitle(AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName));
  final List<String> tagNames = getSortedAllowedTagNames(facet);
  myRootElementField = new TextFieldWithAutoCompletion<String>(
    facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true, null);
  myRootElementField.setText(myDefaultRootTag);
  myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
  myRootElementLabel.setLabelFor(myRootElementField);
  init();

  myFileNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      final String text = myFileNameField.getText().trim();
      if (myValidator instanceof InputValidatorEx) {
        setErrorText(((InputValidatorEx) myValidator).getErrorText(text));
      }
    }
  });
}
项目:intellij-ce-playground    文件:GradleEditTaskDialog.java   
protected GradleEditTaskDialog(@Nullable Project project) {
  super(project);

  setTitle("Select Gradle Task");
  setModal(true);

  TextFieldWithAutoCompletionListProvider<String> provider = new TextFieldWithAutoCompletion.StringsCompletionProvider(null, null) {
    @NotNull
    @Override
    public Collection<String> getItems(String prefix, boolean cached, CompletionParameters parameters) {
      setItems(myAvailableTasks);
      return super.getItems(prefix, cached, parameters);
    }
  };
  myTaskField = new TextFieldWithAutoCompletion<String>(project, provider, true, null);
  myTaskPanel.add(myTaskField);

  init();
}
项目:intellij-ce-playground    文件:AttributeReferenceRendererEditor.java   
/**
 * Constructs a new <code>AttributeReferenceRendererEditor</code> with optional auto-completion.
 * @param project the project to be used for auto-completion.
 * @param completionProvider an optional {@link CompletionProvider} to provide the completion suggestions.
 */
public AttributeReferenceRendererEditor(@Nullable Project project,
                                        @Nullable CompletionProvider completionProvider) {
  if (project != null) {
    myCompletionProvider = completionProvider;
  } else {
    myCompletionProvider = null;
  }

  myTextField = new TextFieldWithAutoCompletion<String>(project, TextFieldWithAutoCompletion.EMPTY_COMPLETION, true, null) {
    @Override
    protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        stopCellEditing();
        return true;
      }
      return false;
    }
  };

  myBox.add(myTextField);
  myBox.add(Box.createHorizontalGlue());
  myTextField.setAlignmentX(Component.LEFT_ALIGNMENT);
  myTextField.setOneLineMode(true);
  myLabel.setOpaque(true); // Allows for colored background
}
项目:intellij    文件:BlazeCreateResourceFileDialog.java   
private void updateRootElementTextField() {
  final CreateTypedResourceFileAction action = getSelectedAction(myResourceTypeCombo);

  if (action != null) {
    final List<String> allowedTagNames = action.getSortedAllowedTagNames(myFacet);
    myRootElementField =
        new TextFieldWithAutoCompletion<>(
            myFacet.getModule().getProject(),
            new StringsCompletionProvider(allowedTagNames, null),
            true,
            null);
    myRootElementField.setEnabled(allowedTagNames.size() > 1);
    myRootElementField.setText(!action.isChooseTagName() ? action.getDefaultRootTag() : "");
    myRootElementFieldWrapper.removeAll();
    myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
    myRootElementLabel.setLabelFor(myRootElementField);
  }
}
项目:tools-idea    文件:GenericRepositoryEditor.java   
private void createUIComponents() {
  //todo completion
  //todo completion without whitespace before cursor
  final ArrayList<String> completionList = ContainerUtil.newArrayList(SERVER_URL_PLACEHOLDER, USERNAME_PLACEHOLDER, PASSWORD_PLACEHOLDER);
  myLoginURLText = TextFieldWithAutoCompletion.create(myProject, completionList, null, false, myRepository.getLoginURL());

  final ArrayList<String> completionList1 = ContainerUtil.newArrayList(SERVER_URL_PLACEHOLDER, QUERY_PLACEHOLDER, MAX_COUNT_PLACEHOLDER);
  myTasksListURLText = TextFieldWithAutoCompletion.create(myProject, completionList1, null, false, myRepository.getTasksListURL());

  final Document document = EditorFactory.getInstance().createDocument(myRepository.getTaskPattern());
  myTaskPatternText = new EditorTextField(document, myProject, myRepository.getResponseType().getFileType(), false, false);
  final ArrayList<String> completionList2 = ContainerUtil.newArrayList("({id}.+?)", "({summary}.+?)");
  TextFieldWithAutoCompletionContributor
    .installCompletion(document, myProject, new TextFieldWithAutoCompletion.StringsCompletionProvider(completionList2, null), true);
  myTaskPatternText.setFontInheritedFromLAF(false);
}
项目:intellij-idea-plugin    文件:JavaPackageChooserComponentBuilder.java   
@Override
public ForgeComponent build(final UIContext context, InputComponent<?, Object> input)
{
   return new LabeledComponent(input, new ChooserComponent(context, input)
   {
      @Override
      public ActionListener createBrowseButtonActionListener(final TextFieldWithAutoCompletion<String> textField)
      {
         return e -> {
            String initialValue = textField.getText();
            String value = IDEUtil.choosePackage(context, initialValue);
            if (value != null)
            {
               textField.setText(value);
            }
         };
      }
   });
}
项目:intellij-idea-plugin    文件:JavaClassChooserComponentBuilder.java   
@Override
public ForgeComponent build(final UIContext context, InputComponent<?, Object> input)
{
   return new LabeledComponent(input, new ChooserComponent(context, input)
   {
      @Override
      public ActionListener createBrowseButtonActionListener(final TextFieldWithAutoCompletion<String> textField)
      {
         return e -> {
            String initialValue = textField.getText();
            String value = IDEUtil.chooseClass(context, initialValue);
            if (value != null)
            {
               textField.setText(value);
            }
         };
      }
   });
}
项目:intellij-ce-playground    文件:BugzillaRepositoryEditor.java   
@Nullable
@Override
protected JComponent createCustomPanel() {
  myProductLabel = new JBLabel("Product:", SwingConstants.RIGHT);
  myProductInput = TextFieldWithAutoCompletion.create(myProject, Collections.<String>emptyList(), true,
                                                      myRepository.getProductName());
  myComponentLabel = new JBLabel("Component:", SwingConstants.RIGHT);
  myComponentInput = TextFieldWithAutoCompletion.create(myProject, Collections.<String>emptyList(), false,
                                                        myRepository.getComponentName());
  return FormBuilder.createFormBuilder()
    .addLabeledComponent(myProductLabel, myProductInput)
    .addLabeledComponent(myComponentLabel, myComponentInput)
    .getPanel();
}
项目:intellij    文件:BlazeCommandRunConfiguration.java   
BlazeCommandRunConfigurationSettingsEditor(BlazeCommandRunConfiguration config) {
  Project project = config.getProject();
  targetField =
      new TextFieldWithAutoCompletion<>(
          project, new TargetCompletionProvider(project), true, null);
  elementState = config.elementState.clone();
  targetExpressionLabel = new JBLabel(UIUtil.ComponentStyle.LARGE);
  keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
  editorWithoutSyncCheckBox = UiUtil.createBox(targetExpressionLabel, targetField);
  editor = UiUtil.createBox(editorWithoutSyncCheckBox, keepInSyncCheckBox);
  updateEditor(config);
  updateHandlerEditor(config);
  keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
项目:intellij-idea-plugin    文件:CompletionUtil.java   
public static TextFieldWithAutoCompletion<String> createTextFieldWithAutoCompletion(UIContext context,
         boolean hasCompletions)
{
   return TextFieldWithAutoCompletion.create(
            IDEUtil.projectFromContext(context),
            Collections.<String> emptyList(),
            hasCompletions,
            "");
}
项目:intellij-ce-playground    文件:TextFieldWithProgress.java   
public TextFieldWithProgress(@NotNull Project project, @NotNull Collection<String> variants) {
  super(new BorderLayout());
  setBorder(IdeBorderFactory.createEmptyBorder(3));

  myProgressIcon = new AsyncProcessIcon("Loading commits");
  myTextField =
    new TextFieldWithAutoCompletion<String>(project, new TextFieldWithAutoCompletion.StringsCompletionProvider(variants, null), false,
                                            null) {
      @Override
      public void setBackground(Color bg) {
        super.setBackground(bg);
        myProgressIcon.setBackground(bg);
      }

      @Override
      protected EditorEx createEditor() {
        // spell check is not needed
        EditorEx editor = super.createEditor();
        EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization();
        if (customization != null) {
          customization.customize(editor);
        }
        return editor;
      }

      @Override
      protected boolean processKeyBinding(KeyStroke ks, final KeyEvent e, int condition, boolean pressed) {
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
          onOk();
          return true;
        }
        return false;
      }
    };
  myTextField.setBorder(IdeBorderFactory.createEmptyBorder());

  myProgressIcon.setOpaque(true);
  myProgressIcon.setBackground(myTextField.getBackground());

  add(myTextField, BorderLayout.CENTER);
  add(myProgressIcon, BorderLayout.EAST);

  hideProgress();
}
项目:intellij-idea-plugin    文件:CompletionUtil.java   
public static TextFieldWithAutoCompletion<String> createTextFieldWithAutoCompletion(UIContext context,
         InputComponent<?, Object> input)
{
   return createTextFieldWithAutoCompletion(context, hasCompletions(input));
}
项目:intellij-idea-plugin    文件:ChooserComponent.java   
public abstract ActionListener createBrowseButtonActionListener(TextFieldWithAutoCompletion<String> textField);