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

项目:intellij-ce-playground    文件:I18nInspection.java   
@SuppressWarnings("NonStaticInitializer")
private DialogWrapper createIgnoreExceptionsConfigurationDialog(final Project project, final JTextField specifiedExceptions) {
  return new DialogWrapper(true) {
    private AddDeleteListPanel myPanel;
    {
      setTitle(CodeInsightBundle.message(
        "inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"));
      init();
    }

    @Override
    protected JComponent createCenterPanel() {
      final String[] ignored = ignoreForSpecifiedExceptionConstructors.split(",");
      final List<String> initialList = new ArrayList<String>();
      for (String e : ignored) {
        if (!e.isEmpty()) initialList.add(e);
      }
      myPanel = new AddDeleteListPanel<String>(null, initialList) {
        @Override
        protected String findItemToAdd() {
          final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
          TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).
            createInheritanceClassChooser(
              CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), scope,
              JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", scope), true, true, null);
          chooser.showDialog();
          PsiClass selectedClass = chooser.getSelected();
          return selectedClass != null ? selectedClass.getQualifiedName() : null;
        }
      };
      return myPanel;
    }

    @Override
    protected void doOKAction() {
      StringBuilder buf = new StringBuilder();
      final Object[] exceptions = myPanel.getListItems();
      for (Object exception : exceptions) {
        buf.append(",").append(exception);
      }
      specifiedExceptions.setText(buf.length() > 0 ? buf.substring(1) : buf.toString());
      super.doOKAction();
    }
  };
}
项目:tools-idea    文件:I18nInspection.java   
@SuppressWarnings({"NonStaticInitializer"})
private DialogWrapper createIgnoreExceptionsConfigurationDialog(final Project project, final JTextField specifiedExceptions) {
  return new DialogWrapper(true) {
    private AddDeleteListPanel myPanel;
    {
      setTitle(CodeInsightBundle.message(
        "inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"));
      init();
    }

    @Override
    protected JComponent createCenterPanel() {
      final String[] ignored = ignoreForSpecifiedExceptionConstructors.split(",");
      final List<String> initialList = new ArrayList<String>();
      if (ignored != null){
        for (String e : ignored) {
          if (e.length() > 0) initialList.add(e);
        }
      }
      myPanel = new AddDeleteListPanel<String>(null, initialList) {
        @Override
        protected String findItemToAdd() {
          final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
          TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).
            createInheritanceClassChooser(
              CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), scope,
              JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", scope), true, true, null);
          chooser.showDialog();
          PsiClass selectedClass = chooser.getSelected();
          return selectedClass != null ? selectedClass.getQualifiedName() : null;
        }
      };
      return myPanel;
    }

    @Override
    protected void doOKAction() {
      StringBuilder buf = new StringBuilder();
      final Object[] exceptions = myPanel.getListItems();
      for (Object exception : exceptions) {
        buf.append(",").append(exception);
      }
      specifiedExceptions.setText(buf.length() > 0 ? buf.substring(1) : buf.toString());
      super.doOKAction();
    }
  };
}
项目:consulo-java    文件:I18nInspection.java   
@SuppressWarnings({"NonStaticInitializer"})
private DialogWrapper createIgnoreExceptionsConfigurationDialog(final Project project, final JTextField specifiedExceptions) {
  return new DialogWrapper(true) {
    private AddDeleteListPanel myPanel;
    {
      setTitle(CodeInsightBundle.message(
        "inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"));
      init();
    }

    @Override
    protected JComponent createCenterPanel() {
      final String[] ignored = ignoreForSpecifiedExceptionConstructors.split(",");
      final List<String> initialList = new ArrayList<String>();
      if (ignored != null){
        for (String e : ignored) {
          if (e.length() > 0) initialList.add(e);
        }
      }
      myPanel = new AddDeleteListPanel<String>(null, initialList) {
        @Override
        protected String findItemToAdd() {
          final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
          TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).
            createInheritanceClassChooser(
              CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), scope,
              JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", scope), true, true, null);
          chooser.showDialog();
          PsiClass selectedClass = chooser.getSelected();
          return selectedClass != null ? selectedClass.getQualifiedName() : null;
        }
      };
      return myPanel;
    }

    @Override
    protected void doOKAction() {
      StringBuilder buf = new StringBuilder();
      final Object[] exceptions = myPanel.getListItems();
      for (Object exception : exceptions) {
        buf.append(",").append(exception);
      }
      specifiedExceptions.setText(buf.length() > 0 ? buf.substring(1) : buf.toString());
      super.doOKAction();
    }
  };
}