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

项目:intellij-ce-playground    文件:ShowFeatureUsageStatisticsDialog.java   
protected JComponent createCenterPanel() {
  Splitter splitter = new Splitter(true);
  splitter.setShowDividerControls(true);

  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  ArrayList<FeatureDescriptor> features = new ArrayList<FeatureDescriptor>();
  for (String id : registry.getFeatureIds()) {
    features.add(registry.getFeatureDescriptor(id));
  }
  final TableView table = new TableView<FeatureDescriptor>(new ListTableModel<FeatureDescriptor>(COLUMNS, features, 0));
  new TableViewSpeedSearch<FeatureDescriptor>(table) {
    @Override
    protected String getItemText(@NotNull FeatureDescriptor element) {
      return element.getDisplayName();
    }
  };

  JPanel controlsPanel = new JPanel(new VerticalFlowLayout());


  Application app = ApplicationManager.getApplication();
  long uptime = System.currentTimeMillis() - app.getStartTime();
  long idleTime = app.getIdleTime();

  final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime",
                                                         ApplicationNamesInfo.getInstance().getFullProductName(),
                                                         DateFormatUtil.formatDuration(uptime));

  final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time",
                                                           DateFormatUtil.formatDuration(idleTime));

  String labelText = uptimeS + ", " + idleTimeS;
  CompletionStatistics stats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getCompletionStatistics();
  if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
    String total = formatCharacterCount(stats.sparedCharacters, true);
    String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
    labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) +
                 " (~" + perDay + " per working day)";
  }

  CumulativeStatistics fstats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats();
  if (fstats.dayCount > 0 && fstats.invocations > 0) {
    labelText +=
      "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) +
      " (~" + fstats.invocations / fstats.dayCount + " per working day)";
  }

  controlsPanel.add(new JLabel(XmlStringUtil.wrapInHtml(labelText)), BorderLayout.NORTH);

  JPanel topPanel = new JPanel(new BorderLayout());
  topPanel.add(controlsPanel, BorderLayout.NORTH);
  topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);

  splitter.setFirstComponent(topPanel);

  final JEditorPane browser = TipUIUtil.createTipBrowser();
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));

  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      Collection selection = table.getSelection();
      try {
        if (selection.isEmpty()) {
          browser.read(new StringReader(""), null);
        }
        else {
          FeatureDescriptor feature = (FeatureDescriptor)selection.iterator().next();
          TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
        }
      }
      catch (IOException ex) {
        LOG.info(ex);
      }
    }
  });

  return splitter;
}
项目:tools-idea    文件:ShowFeatureUsageStatisticsDialog.java   
protected JComponent createCenterPanel() {
  Splitter splitter = new Splitter(true);
  splitter.setShowDividerControls(true);

  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  ArrayList<FeatureDescriptor> features = new ArrayList<FeatureDescriptor>();
  for (String id : registry.getFeatureIds()) {
    features.add(registry.getFeatureDescriptor(id));
  }
  final TableView table = new TableView<FeatureDescriptor>(new ListTableModel<FeatureDescriptor>(COLUMNS, features, 0));
  new TableViewSpeedSearch<FeatureDescriptor>(table) {
    @Override
    protected String getItemText(@NotNull FeatureDescriptor element) {
      return element.getDisplayName();
    }
  };

  JPanel controlsPanel = new JPanel(new VerticalFlowLayout());


  Application app = ApplicationManager.getApplication();
  long uptime = System.currentTimeMillis() - app.getStartTime();
  long idleTime = app.getIdleTime();

  final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime",
                                                         ApplicationNamesInfo.getInstance().getFullProductName(),
                                                         DateFormatUtil.formatDuration(uptime));

  final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time",
                                                           DateFormatUtil.formatDuration(idleTime));

  String labelText = uptimeS + ", " + idleTimeS;
  CompletionStatistics stats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getCompletionStatistics();
  if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
    String total = formatCharacterCount(stats.sparedCharacters, true);
    String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
    labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) +
                 " (~" + perDay + " per working day)";
  }

  CumulativeStatistics fstats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats();
  if (fstats.dayCount > 0 && fstats.invocations > 0) {
    labelText +=
      "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) +
      " (~" + fstats.invocations / fstats.dayCount + " per working day)";
  }

  controlsPanel.add(new JLabel("<html><body>" + labelText + "</body></html>"), BorderLayout.NORTH);

  JPanel topPanel = new JPanel(new BorderLayout());
  topPanel.add(controlsPanel, BorderLayout.NORTH);
  topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);

  splitter.setFirstComponent(topPanel);

  final JEditorPane browser = new JEditorPane(UIUtil.HTML_MIME, "");
  browser.setEditable(false);
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));

  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      Collection selection = table.getSelection();
      try {
        if (selection.isEmpty()) {
          browser.read(new StringReader(""), null);
        }
        else {
          FeatureDescriptor feature = (FeatureDescriptor)selection.iterator().next();
          TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
        }
      }
      catch (IOException ex) {
        LOG.info(ex);
      }
    }
  });

  return splitter;
}
项目:consulo    文件:ShowFeatureUsageStatisticsDialog.java   
protected JComponent createCenterPanel() {
  Splitter splitter = new Splitter(true);
  splitter.setShowDividerControls(true);

  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  ArrayList<FeatureDescriptor> features = new ArrayList<FeatureDescriptor>();
  for (String id : registry.getFeatureIds()) {
    features.add(registry.getFeatureDescriptor(id));
  }
  final TableView table = new TableView<FeatureDescriptor>(new ListTableModel<FeatureDescriptor>(COLUMNS, features, 0));
  new TableViewSpeedSearch<FeatureDescriptor>(table) {
    @Override
    protected String getItemText(@Nonnull FeatureDescriptor element) {
      return element.getDisplayName();
    }
  };

  JPanel controlsPanel = new JPanel(new VerticalFlowLayout());


  Application app = ApplicationManager.getApplication();
  long uptime = System.currentTimeMillis() - app.getStartTime();
  long idleTime = app.getIdleTime();

  final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime",
                                                         ApplicationNamesInfo.getInstance().getFullProductName(),
                                                         DateFormatUtil.formatDuration(uptime));

  final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time",
                                                           DateFormatUtil.formatDuration(idleTime));

  String labelText = uptimeS + ", " + idleTimeS;
  CompletionStatistics stats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getCompletionStatistics();
  if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
    String total = formatCharacterCount(stats.sparedCharacters, true);
    String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
    labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) +
                 " (~" + perDay + " per working day)";
  }

  CumulativeStatistics fstats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats();
  if (fstats.dayCount > 0 && fstats.invocations > 0) {
    labelText +=
      "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) +
      " (~" + fstats.invocations / fstats.dayCount + " per working day)";
  }

  controlsPanel.add(new JLabel("<html><body>" + labelText + "</body></html>"), BorderLayout.NORTH);

  JPanel topPanel = new JPanel(new BorderLayout());
  topPanel.add(controlsPanel, BorderLayout.NORTH);
  topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);

  splitter.setFirstComponent(topPanel);

  final JEditorPane browser = new JEditorPane(UIUtil.HTML_MIME, "");
  browser.setEditable(false);
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));

  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      Collection selection = table.getSelection();
      try {
        if (selection.isEmpty()) {
          browser.read(new StringReader(""), null);
        }
        else {
          FeatureDescriptor feature = (FeatureDescriptor)selection.iterator().next();
          TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
        }
      }
      catch (IOException ex) {
        LOG.info(ex);
      }
    }
  });

  return splitter;
}