Example #1
0
 /**
  * Create the physical control.
  *
  * @param bEditableControl Is this control editable?
  * @return The new control.
  */
 public Component setupControl(boolean bEditableControl) {
   String strDesc = ((SRadioButton) this.getScreenField()).getButtonDesc();
   JRadioButton control = null;
   String m_strImageButton = ((SRadioButton) this.getScreenField()).getImageButtonName();
   if (m_strImageButton == null) control = new JRadioButton(strDesc); // Physical control
   else if ((strDesc == null) || (strDesc.length() == 0))
     control =
         new JRadioButton(
             this.loadImageIcon(
                 m_strImageButton, null)); // Get this image, then redisplay me when you're done
   else
     control =
         new JRadioButton(
             strDesc,
             this.loadImageIcon(
                 m_strImageButton, null)); // Get this image, then redisplay me when you're done
   control.setOpaque(false);
   control.setHorizontalTextPosition(JToggleButton.LEFT);
   control.setIconTextGap(
       org.jbundle.base.screen.control.javafx.util.ScreenInfo.EXTRA_COL_SPACING);
   if (bEditableControl) {
     control.addFocusListener(this);
     control.addActionListener(this);
   }
   return control;
 }
  public void init() {
    myExistingListsCombo.setRenderer(
        new ColoredListCellRendererWrapper() {
          private final IssueLinkRenderer myLinkRenderer = new IssueLinkRenderer(myProject, this);

          @Override
          protected void doCustomize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof LocalChangeList) {
              String name = ((LocalChangeList) value).getName();

              if (myExistingListsCombo.getWidth() == 0) {
                name = name.length() > 10 ? name.substring(0, 7) + " .." : name;
              } else {
                final FontMetrics fm = list.getFontMetrics(list.getFont());
                final int width = fm.stringWidth(name);
                final int listWidth = myExistingListsCombo.getWidth();
                if ((listWidth > 0) && (width > listWidth)) {
                  final String truncated =
                      CommittedChangeListRenderer.truncateDescription(
                          name, fm, listWidth - fm.stringWidth(" ..") - 7);
                  if (truncated.length() > 5) {
                    name = truncated + " ..";
                  }
                }
              }
              myLinkRenderer.appendTextWithLinks(
                  name,
                  ((LocalChangeList) value).isDefault()
                      ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                      : SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
          }
        });
    myNewListPanel.init(null);
    myRbNew.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            getPreferredFocusedComponent().requestFocusInWindow();
          }
        });
    final ComboboxSpeedSearch search = new ComboboxSpeedSearch(myExistingListsCombo);
    search.setComparator(new SpeedSearchComparator(true, false));
  }