Java Code Examples for com.intellij.openapi.util.text.StringUtil#notNullizeIfEmpty()

The following examples show how to use com.intellij.openapi.util.text.StringUtil#notNullizeIfEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EarlyAccessProgramConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  CheckBoxList checkBoxList = (CheckBoxList)list;
  EarlyAccessProgramDescriptor earlyAccessProgramDescriptor = (EarlyAccessProgramDescriptor)checkBoxList.getItemAt(index);

  JCheckBox checkbox = (JCheckBox)value;

  checkbox.setEnabled(list.isEnabled());
  checkbox.setFocusPainted(false);
  checkbox.setBorderPainted(true);

  if (earlyAccessProgramDescriptor == null) {
    return checkbox;
  }
  else {
    checkbox.setEnabled(earlyAccessProgramDescriptor.isAvailable());

    JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, true)) {
      @Override
      public Dimension getPreferredSize() {
        Dimension size = super.getPreferredSize();
        return new Dimension(Math.min(size.width, 200), size.height);
      }
    };
    panel.setEnabled(earlyAccessProgramDescriptor.isAvailable());

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(checkbox, BorderLayout.WEST);

    if (earlyAccessProgramDescriptor.isRestartRequired()) {
      JBLabel comp = new JBLabel("Restart required");
      comp.setForeground(JBColor.GRAY);
      topPanel.add(comp, BorderLayout.EAST);
    }

    panel.add(topPanel);
    panel.setBorder(new CustomLineBorder(0, 0, 1, 0));

    String description = StringUtil.notNullizeIfEmpty(earlyAccessProgramDescriptor.getDescription(), "Description is not available");
    JTextPane textPane = new JTextPane();
    textPane.setText(description);
    textPane.setEditable(false);
    if (!earlyAccessProgramDescriptor.isAvailable()) {
      textPane.setForeground(JBColor.GRAY);
    }
    panel.add(textPane);
    return panel;
  }
}
 
Example 2
Source File: InspectionFilterAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public LanguageFilterAction(final Language language) {
  super(StringUtil.notNullizeIfEmpty(language.getDisplayName(), language.getID()));
  myLanguage = language;
}