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

项目:intellij-ce-playground    文件:DebuggerExpressionComboBox.java   
public DebuggerExpressionComboBox(@NotNull Project project, @NotNull Disposable parentDisposable, @Nullable PsiElement context, @Nullable String recentsId, @NotNull CodeFragmentFactory factory) {
  super(project, factory, parentDisposable, context, recentsId);

  setLayout(new BorderLayout(0, 0));

  myComboBox = new ComboBox(new MyComboboxModel(getRecents()), 100);
  myComboBox.setSwingPopup(false);

  // Have to turn this off because when used in DebuggerTreeInplaceEditor, the combobox popup is hidden on every change of selection
  // See comment to SynthComboBoxUI.FocusHandler.focusLost()
  myComboBox.setLightWeightPopupEnabled(false);

  myEditor = new MyEditorComboBoxEditor(getProject(), getCurrentFactory().getFileType());
  //noinspection GtkPreferredJComboBoxRenderer
  myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));

  myComboBox.setEditable(true);
  myComboBox.setEditor(myEditor);
  add(addChooseFactoryLabel(myComboBox, false));
}
项目:intellij-ce-playground    文件:XDebuggerExpressionComboBox.java   
private void initEditor() {
  myEditor = new EditorComboBoxEditor(getProject(), getEditorsProvider().getFileType()) {
    @Override
    public void setItem(Object anObject) {
      if (anObject == null) {
        anObject = XExpressionImpl.EMPTY_EXPRESSION;
      }
      super.setItem(createDocument(((XExpression)anObject)));
    }

    @Override
    protected void onEditorCreate(EditorEx editor) {
      editor.putUserData(DebuggerCopyPastePreprocessor.REMOVE_NEWLINES_ON_PASTE, true);
      editor.getColorsScheme().setEditorFontSize(myComboBox.getFont().getSize());
    }
  };
  myEditor.getEditorComponent().setFontInheritedFromLAF(false);
  myComboBox.setEditor(myEditor);
  //myEditor.setItem(myExpression);
  myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));
  myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
项目:intellij-ce-playground    文件:NameSuggestionsField.java   
private void setupComboBox(final ComboBox combobox, FileType fileType) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
    @Override
    public void setItem(Object anObject) {
      myNonHumanChange = true;
      super.setItem(anObject);
    }
  };

  combobox.setEditor(comboEditor);
  combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));

  combobox.setEditable(true);
  combobox.setMaximumRowCount(8);

  comboEditor.selectAll();
}
项目:tools-idea    文件:DebuggerExpressionComboBox.java   
public DebuggerExpressionComboBox(Project project, PsiElement context, @NonNls String recentsId, final CodeFragmentFactory factory) {
  super(project, context, recentsId, factory);
  setLayout(new BorderLayout(0, 0));

  myComboBox = new ComboBox(new MyComboboxModel(getRecents()), 100);
  myComboBox.setSwingPopup(false);

  // Have to turn this off because when used in DebuggerTreeInplaceEditor, the combobox popup is hidden on every change of selection
  // See comment to SynthComboBoxUI.FocusHandler.focusLost()
  myComboBox.setLightWeightPopupEnabled(false);

  myEditor = new MyEditorComboBoxEditor(getProject(), getCurrentFactory().getFileType());
  //noinspection GtkPreferredJComboBoxRenderer
  myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));

  myComboBox.setEditable(true);
  myComboBox.setEditor(myEditor);
  add(addChooseFactoryLabel(myComboBox, false));
}
项目:tools-idea    文件:XDebuggerExpressionComboBox.java   
private void initEditor() {
  myEditor = new EditorComboBoxEditor(getProject(), myDebuggerEditorsProvider.getFileType()) {
    public void setItem(Object anObject) {
      if (anObject == null) {
        anObject = "";
      }
      super.setItem(createDocument((String)anObject));
    }

    public Object getItem() {
      return ((Document)super.getItem()).getText();
    }
  };
  myComboBox.setEditor(myEditor);
  myEditor.setItem(myExpression);
  myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));
  myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
项目:tools-idea    文件:NameSuggestionsField.java   
private void setupComboBox(final ComboBox combobox, FileType fileType) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
    @Override
    public void setItem(Object anObject) {
      myNonHumanChange = true;
      super.setItem(anObject);
    }
  };

  combobox.setEditor(comboEditor);
  combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));

  combobox.setEditable(true);
  combobox.setMaximumRowCount(8);

  comboEditor.selectAll();
}
项目:consulo-csharp    文件:CSharpIntroduceDialog.java   
private void setUpNameComboBox(Collection<String> possibleNames) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, CSharpFileType.INSTANCE, myNameComboBox);

  myNameComboBox.setEditor(comboEditor);
  myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
  myNameComboBox.setEditable(true);
  myNameComboBox.setMaximumRowCount(8);

  myContentPane.registerKeyboardAction(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      myNameComboBox.requestFocus();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

  for (String possibleName : possibleNames) {
    myNameComboBox.addItem(possibleName);
  }
}
项目:intellij-haxe    文件:HaxeIntroduceDialog.java   
private void setUpNameComboBox(Collection<String> possibleNames) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, HaxeFileType.HAXE_FILE_TYPE, myNameComboBox);

  myNameComboBox.setEditor(comboEditor);
  myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
  myNameComboBox.setEditable(true);
  myNameComboBox.setMaximumRowCount(8);

  myContentPane.registerKeyboardAction(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      myNameComboBox.requestFocus();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

  for (String possibleName : possibleNames) {
    myNameComboBox.addItem(possibleName);
  }
}
项目:consulo-haxe    文件:HaxeIntroduceDialog.java   
private void setUpNameComboBox(Collection<String> possibleNames) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, HaxeFileType.HAXE_FILE_TYPE, myNameComboBox);

  myNameComboBox.setEditor(comboEditor);
  myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
  myNameComboBox.setEditable(true);
  myNameComboBox.setMaximumRowCount(8);

  myContentPane.registerKeyboardAction(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      myNameComboBox.requestFocus();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

  for (String possibleName : possibleNames) {
    myNameComboBox.addItem(possibleName);
  }
}
项目:consulo    文件:NameSuggestionsField.java   
private void setupComboBox(final ComboBox combobox, FileType fileType) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
    @Override
    public void setItem(Object anObject) {
      myNonHumanChange = true;
      super.setItem(anObject);
    }
  };

  combobox.setEditor(comboEditor);
  combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));

  combobox.setEditable(true);
  combobox.setMaximumRowCount(8);

  comboEditor.selectAll();
}
项目:consulo    文件:XDebuggerExpressionComboBox.java   
private void initEditor() {
  myEditor = new XDebuggerComboBoxEditor();
  myComboBox.setEditor(myEditor);
  //myEditor.setItem(myExpression);
  myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));
  myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
项目:intellij-ce-playground    文件:GradleRunTaskDialog.java   
private void setUpDialog() {
  JComponent commandLineComponent;
  if (myHistory == null) {
    commandLineEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
    commandLineComponent = commandLineEditor;

    commandLineLabel.setLabelFor(commandLineEditor);
  }
  else {
    commandLineComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
    commandLineComponent = commandLineComboBox;

    commandLineLabel.setLabelFor(commandLineComboBox);

    commandLineComboBox.setLightWeightPopupEnabled(false);

    EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, commandLineComboBox);
    //noinspection GtkPreferredJComboBoxRenderer
    commandLineComboBox.setRenderer(new EditorComboBoxRenderer(editor));

    commandLineComboBox.setEditable(true);
    commandLineComboBox.setEditor(editor);
    commandLineComboBox.setFocusable(true);

    commandLineEditor = editor.getEditorComponent();
  }

  commandLinePanel.add(commandLineComponent);

  ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
  FileChooserDescriptor projectPathChooserDescriptor = null;
  if (manager instanceof ExternalSystemUiAware) {
    projectPathChooserDescriptor = ((ExternalSystemUiAware)manager).getExternalProjectConfigDescriptor();
  }
  if (projectPathChooserDescriptor == null) {
    projectPathChooserDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
  }

  String title = ExternalSystemBundle.message("settings.label.select.project", GradleConstants.SYSTEM_ID.getReadableName());
  myProjectPathField = new ExternalProjectPathField(myProject, GradleConstants.SYSTEM_ID, projectPathChooserDescriptor, title) {
    @Override
    public Dimension getPreferredSize() {
      return commandLinePanel == null ? super.getPreferredSize() : commandLinePanel.getPreferredSize();
    }
  };

  projectPathFieldPanel.add(myProjectPathField);

  new GradleArgumentsCompletionProvider(myProject, myProjectPathField).apply(commandLineEditor);
}
项目:intellij-ce-playground    文件:MavenEditGoalDialog.java   
private void setUpDialog() {
  JComponent goalComponent;
  if (myHistory == null) {
    goalsEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
    goalComponent = goalsEditor;

    goalsLabel.setLabelFor(goalsEditor);
  }
  else {
    goalsComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
    goalComponent = goalsComboBox;

    goalsLabel.setLabelFor(goalsComboBox);

    goalsComboBox.setLightWeightPopupEnabled(false);

    EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, goalsComboBox);
    goalsComboBox.setRenderer(new EditorComboBoxRenderer(editor));

    goalsComboBox.setEditable(true);
    goalsComboBox.setEditor(editor);
    goalsComboBox.setFocusable(true);

    goalsEditor = editor.getEditorComponent();
  }

  goalsPanel.add(goalComponent);

  new MavenArgumentsCompletionProvider(myProject).apply(goalsEditor);


  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);

  showProjectTreeButton.setIcon(AllIcons.Actions.Module);
  MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton,
                                                        goalsComboBox != null ? goalsComboBox : goalsEditor);

  workDirectoryField.addBrowseFolderListener(
    RunnerBundle.message("maven.select.maven.project.file"), "", myProject,
    new FileChooserDescriptor(false, true, false, false, false, false) {
      @Override
      public boolean isFileSelectable(VirtualFile file) {
        if (!super.isFileSelectable(file)) return false;
        return file.findChild(MavenConstants.POM_XML) != null;
      }
    });
}
项目:tools-idea    文件:FindDialog.java   
private void revealWhitespaces(@NotNull ComboBox comboBox) {
  ComboBoxEditor comboBoxEditor = new RevealingSpaceComboboxEditor(myProject, comboBox);
  comboBox.setEditor(comboBoxEditor);
  comboBox.setRenderer(new EditorComboBoxRenderer(comboBoxEditor));
}
项目:tools-idea    文件:MavenEditGoalDialog.java   
private void setUpDialog() {
  JComponent goalComponent;
  if (myHistory == null) {
    goalsEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
    goalComponent = goalsEditor;

    goalsLabel.setLabelFor(goalsEditor);
  }
  else {
    //noinspection SSBasedInspection
    goalsComboBox = new ComboBox(myHistory.toArray(new String[myHistory.size()]), -1);
    goalComponent = goalsComboBox;

    goalsLabel.setLabelFor(goalsComboBox);

    goalsComboBox.setLightWeightPopupEnabled(false);

    EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, goalsComboBox);
    goalsComboBox.setRenderer(new EditorComboBoxRenderer(editor));

    goalsComboBox.setEditable(true);
    goalsComboBox.setEditor(editor);
    goalsComboBox.setFocusable(true);

    goalsEditor = editor.getEditorComponent();
  }

  goalsPanel.add(goalComponent);

  new MavenArgumentsCompletionProvider(myProject).apply(goalsEditor);


  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);

  showProjectTreeButton.setIcon(AllIcons.Actions.Module);
  MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton,
                                                        goalsComboBox != null ? goalsComboBox : goalsEditor);

  workDirectoryField.addBrowseFolderListener(
    RunnerBundle.message("maven.select.maven.project.file"), "", myProject,
    new FileChooserDescriptor(false, true, false, false, false, false) {
      @Override
      public boolean isFileSelectable(VirtualFile file) {
        if (!super.isFileSelectable(file)) return false;
        return file.findChild(MavenConstants.POM_XML) != null;
      }
    });
}