private JPanel createShortContextPanel() {
    JLabel ctxLabel = new JBLabel();
    ActionLink change = new ActionLink(CodeInsightBundle.message("link.change.context"));
    change.setDropDownLinkIcon();

    final Runnable updateLabel = () -> {
      myExpandByCombo.setEnabled(isExpandableFromEditor());
      updateHighlighter();

      StringBuilder sb = new StringBuilder();
      String oldPrefix = "";
      for (TemplateContextType type : getApplicableContexts()) {
        final TemplateContextType base = type.getBaseContextType();
        String ownName = presentableName(type);
        String prefix = "";
        if (base != null && !(base instanceof EverywhereContextType)) {
          prefix = presentableName(base) + ": ";
          ownName = StringUtil.decapitalize(ownName);
        }
        if (type instanceof EverywhereContextType) {
          ownName = CodeInsightBundle.message("dialog.edit.template.context.other");
        }
        if (sb.length() > 0) {
          sb.append(oldPrefix.equals(prefix) ? ", " : "; ");
        }
        if (!oldPrefix.equals(prefix)) {
          sb.append(prefix);
          oldPrefix = prefix;
        }
        sb.append(ownName);
      }

      String contexts = CodeInsightBundle.message("dialog.edit.template.applicable.in.contexts", sb.toString());
      change.setText(CodeInsightBundle.message("link.change.context"));

      final boolean noContexts = sb.length() == 0;
      if (noContexts) {
        contexts = CodeInsightBundle.message("dialog.edit.template.no.applicable.contexts");
        ctxLabel.setIcon(AllIcons.General.BalloonWarning);
        change.setText(CodeInsightBundle.message("link.define.context"));
      }
      else {
        ctxLabel.setForeground(UIUtil.getLabelForeground());
        ctxLabel.setIcon(null);
      }
      ctxLabel.setText(StringUtil.first(contexts + ". ", 100, true));

      myTemplateOptionsPanel.removeAll();
      myTemplateOptionsPanel.add(createTemplateOptionsPanel());
    };

    change.addActionListener(event -> {
        if (disposeContextPopup()) return;
        Pair<JPanel, CheckboxTree> pair = createPopupContextPanel(updateLabel, myContext);
        final JPanel content = pair.first;
        Dimension prefSize = content.getPreferredSize();
        if (myLastSize != null && (myLastSize.width > prefSize.width || myLastSize.height > prefSize.height)) {
          content.setPreferredSize(new Dimension(Math.max(prefSize.width, myLastSize.width), Math.max(prefSize.height, myLastSize.height)));
        }
        myContextPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(content, pair.second)
          .setRequestFocus(true)
          .setResizable(true).createPopup();
        myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - JBUIScale.scale(4))));
        myContextPopup.addListener(new JBPopupListener() {
          @Override
          public void onClosed(@NotNull LightweightWindowEvent event) {
            myLastSize = content.getSize();
          }
        });
    });

    updateLabel.run();
    return new FormBuilder()
      .addComponent(ctxLabel)
      .addComponent(change)
      .getPanel();
  }
private JPanel createShortContextPanel()